1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
5 | * Copyright (C) 2013 Frederik Heber. All rights reserved.
|
---|
6 | *
|
---|
7 | *
|
---|
8 | * This file is part of MoleCuilder.
|
---|
9 | *
|
---|
10 | * MoleCuilder is free software: you can redistribute it and/or modify
|
---|
11 | * it under the terms of the GNU General Public License as published by
|
---|
12 | * the Free Software Foundation, either version 2 of the License, or
|
---|
13 | * (at your option) any later version.
|
---|
14 | *
|
---|
15 | * MoleCuilder is distributed in the hope that it will be useful,
|
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | * GNU General Public License for more details.
|
---|
19 | *
|
---|
20 | * You should have received a copy of the GNU General Public License
|
---|
21 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
---|
22 | */
|
---|
23 |
|
---|
24 | /*
|
---|
25 | * GLWorldView.cpp
|
---|
26 | *
|
---|
27 | * Created on: Aug 1, 2010
|
---|
28 | * Author: heber
|
---|
29 | */
|
---|
30 |
|
---|
31 | // include config.h
|
---|
32 | #ifdef HAVE_CONFIG_H
|
---|
33 | #include <config.h>
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #include "GLWorldView.hpp"
|
---|
37 |
|
---|
38 | #include <Qt/qevent.h>
|
---|
39 | #include <Qt/qaction.h>
|
---|
40 | #include <QtGui/QMenu>
|
---|
41 | #include <QtGui/QToolBar>
|
---|
42 | #include <QtGui/QToolButton>
|
---|
43 | #include <Qt/qtimer.h>
|
---|
44 | #include <Qt/qsettings.h>
|
---|
45 | #include <Qt3D/qglbuilder.h>
|
---|
46 | #include <Qt3D/qglscenenode.h>
|
---|
47 | #include <Qt3D/qglsphere.h>
|
---|
48 | #include <Qt3D/qglcylinder.h>
|
---|
49 | #include <Qt3D/qglcube.h>
|
---|
50 |
|
---|
51 | #include "GLWorldScene.hpp"
|
---|
52 |
|
---|
53 | #include "CodePatterns/MemDebug.hpp"
|
---|
54 |
|
---|
55 | #include "Atom/AtomObserver.hpp"
|
---|
56 | #include "Atom/atom_observable.hpp"
|
---|
57 | #include "Box.hpp"
|
---|
58 | #include "CodePatterns/Log.hpp"
|
---|
59 | #include "CodePatterns/Observer/Notification.hpp"
|
---|
60 | #include "CodePatterns/Observer/ObserverLog.hpp"
|
---|
61 | #include "molecule.hpp"
|
---|
62 | #include "Shapes/ShapeRegistry.hpp"
|
---|
63 | #include "World.hpp"
|
---|
64 | #include "WorldTime.hpp"
|
---|
65 |
|
---|
66 | GLWorldView::GLWorldView(QWidget *parent)
|
---|
67 | : QGLView(parent), Observer("GLWorldView"), worldscene(NULL), changesPresent(false), needsRedraw(false)
|
---|
68 | {
|
---|
69 | worldscene = new GLWorldScene(this);
|
---|
70 |
|
---|
71 | setOption(QGLView::ObjectPicking, true);
|
---|
72 | setOption(QGLView::CameraNavigation, false);
|
---|
73 | setCameraControlMode(Rotate);
|
---|
74 | defaultEyeSeparation = 4.0;
|
---|
75 |
|
---|
76 | createDomainBox();
|
---|
77 | createDreiBein();
|
---|
78 | //changeMaterials(false);
|
---|
79 |
|
---|
80 | qRegisterMetaType<atomicNumber_t>("atomicNumber_t");
|
---|
81 |
|
---|
82 | connect(this, SIGNAL(ShapeAdded()), worldscene, SLOT(addShape()));
|
---|
83 | connect(this, SIGNAL(ShapeRemoved()), worldscene, SLOT(removeShape()));
|
---|
84 | connect(this, SIGNAL(TimeChanged()), worldscene, SIGNAL(updated()));
|
---|
85 | connect(worldscene, SIGNAL(changeOccured()), this, SLOT(changeSignalled()));
|
---|
86 | connect(worldscene, SIGNAL(changed()), this, SIGNAL(changed()));
|
---|
87 | connect(worldscene, SIGNAL(hoverChanged(const atom *)), this, SLOT(sceneHoverSignalled(const atom *)));
|
---|
88 | connect(this, SIGNAL(atomInserted(const atomicNumber_t)), worldscene, SLOT(atomInserted(const atomicNumber_t)));
|
---|
89 | connect(this, SIGNAL(atomRemoved(const atomicNumber_t)), worldscene, SLOT(atomRemoved(const atomicNumber_t)));
|
---|
90 | connect(this, SIGNAL(worldSelectionChanged()), worldscene, SLOT(worldSelectionChanged()));
|
---|
91 | connect(this, SIGNAL(moleculeRemoved(const molecule *)), worldscene, SLOT(moleculeRemoved(const molecule *)));
|
---|
92 | //connect(this, SIGNAL(moleculeInserted(const molecule *)), worldscene, SLOT(moleculeInserted(const molecule *)));
|
---|
93 | //connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
|
---|
94 | connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled()));
|
---|
95 |
|
---|
96 | // sign on to changes in the world
|
---|
97 | World::getInstance().signOn(this);
|
---|
98 | World::getInstance().signOn(this, World::AtomInserted);
|
---|
99 | World::getInstance().signOn(this, World::AtomRemoved);
|
---|
100 | World::getInstance().signOn(this, World::MoleculeInserted);
|
---|
101 | World::getInstance().signOn(this, World::MoleculeRemoved);
|
---|
102 | World::getInstance().signOn(this, World::SelectionChanged);
|
---|
103 | WorldTime::getInstance().signOn(this, WorldTime::TimeChanged);
|
---|
104 | AtomObserver::getInstance().signOn(this, AtomObservable::PositionChanged);
|
---|
105 |
|
---|
106 | ShapeRegistry::getInstance().signOn(this);
|
---|
107 | ShapeRegistry::getInstance().signOn(this, ShapeRegistry::ShapeInserted);
|
---|
108 | ShapeRegistry::getInstance().signOn(this, ShapeRegistry::ShapeRemoved);
|
---|
109 | ShapeRegistry::getInstance().signOn(this, ShapeRegistry::SelectionChanged);
|
---|
110 |
|
---|
111 | redrawTimer = new QTimer(this);
|
---|
112 | }
|
---|
113 |
|
---|
114 | GLWorldView::~GLWorldView()
|
---|
115 | {
|
---|
116 | QSettings settings;
|
---|
117 | settings.beginGroup("WorldView");
|
---|
118 | settings.setValue("domainBoxEnabled", (meshDomainBox->options() & QGLSceneNode::HideNode) == 0);
|
---|
119 | settings.setValue("dreiBeinEnabled", (meshDreiBein->options() & QGLSceneNode::HideNode) == 0);
|
---|
120 | settings.endGroup();
|
---|
121 |
|
---|
122 |
|
---|
123 | World::getInstance().signOff(this);
|
---|
124 | World::getInstance().signOff(this, World::AtomInserted);
|
---|
125 | World::getInstance().signOff(this, World::AtomRemoved);
|
---|
126 | World::getInstance().signOff(this, World::MoleculeInserted);
|
---|
127 | World::getInstance().signOff(this, World::MoleculeRemoved);
|
---|
128 | World::getInstance().signOff(this, World::SelectionChanged);
|
---|
129 | WorldTime::getInstance().signOff(this, WorldTime::TimeChanged);
|
---|
130 | AtomObserver::getInstance().signOff(this, AtomObservable::PositionChanged);
|
---|
131 | ShapeRegistry::getInstance().signOff(this);
|
---|
132 | ShapeRegistry::getInstance().signOff(this, ShapeRegistry::ShapeInserted);
|
---|
133 | ShapeRegistry::getInstance().signOff(this, ShapeRegistry::ShapeRemoved);
|
---|
134 | ShapeRegistry::getInstance().signOff(this, ShapeRegistry::SelectionChanged);
|
---|
135 | delete worldscene;
|
---|
136 |
|
---|
137 | delete(domainBoxMaterial);
|
---|
138 | for (int i=0;i<3;i++)
|
---|
139 | delete(dreiBeinMaterial[i]);
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * Add some widget specific actions to the toolbar:
|
---|
145 | * - camera rotation/translation mode
|
---|
146 | * - camera fit to domain
|
---|
147 | */
|
---|
148 | void GLWorldView::addToolBarActions(QToolBar *toolbar)
|
---|
149 | {
|
---|
150 | // camera control mode
|
---|
151 | toolbar->addSeparator();
|
---|
152 | QAction *transAction = new QAction(QIcon::fromTheme("forward"), tr("camera translation mode"), this);
|
---|
153 | connect(transAction, SIGNAL(triggered()), this, SLOT(setCameraControlModeTranslation()));
|
---|
154 | toolbar->addAction(transAction);
|
---|
155 | QAction *rotAction = new QAction(QIcon::fromTheme("object-rotate-left"), tr("camera rotation mode"), this);
|
---|
156 | connect(rotAction, SIGNAL(triggered()), this, SLOT(setCameraControlModeRotation()));
|
---|
157 | toolbar->addAction(rotAction);
|
---|
158 | QAction *fitAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("camera fit to domain"), this);
|
---|
159 | connect(fitAction, SIGNAL(triggered()), this, SLOT(fitCameraToDomain()));
|
---|
160 | toolbar->addAction(fitAction);
|
---|
161 |
|
---|
162 | // stereo mode
|
---|
163 | QToolButton *stereoButton = new QToolButton(toolbar);
|
---|
164 | QMenu *stereoMenu = new QMenu();
|
---|
165 | QAction *stereoDisableAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("disable"), this);
|
---|
166 | connect(stereoDisableAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeDisable()));
|
---|
167 | stereoMenu->addAction(stereoDisableAction);
|
---|
168 | QAction *stereoHardwareAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("hardware"), this);
|
---|
169 | connect(stereoHardwareAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeHardware()));
|
---|
170 | stereoMenu->addAction(stereoHardwareAction);
|
---|
171 | QAction *stereoLeftRightAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("left right"), this);
|
---|
172 | connect(stereoLeftRightAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeLeftRight()));
|
---|
173 | stereoMenu->addAction(stereoLeftRightAction);
|
---|
174 | QAction *stereoRightLeftAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("right left"), this);
|
---|
175 | connect(stereoRightLeftAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeRightLeft()));
|
---|
176 | stereoMenu->addAction(stereoRightLeftAction);
|
---|
177 | QAction *stereoTopBottomAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("top bottom"), this);
|
---|
178 | connect(stereoTopBottomAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeTopBottom()));
|
---|
179 | stereoMenu->addAction(stereoTopBottomAction);
|
---|
180 | QAction *stereoBottomTopAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("bottom top"), this);
|
---|
181 | connect(stereoBottomTopAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeBottomTop()));
|
---|
182 | stereoMenu->addAction(stereoBottomTopAction);
|
---|
183 | QAction *stereoAnaglyphAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("anaglyph"), this);
|
---|
184 | connect(stereoAnaglyphAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeAnaglyph()));
|
---|
185 | stereoMenu->addAction(stereoAnaglyphAction);
|
---|
186 | stereoButton->setMenu(stereoMenu);
|
---|
187 | stereoButton->setIcon(QIcon(QPixmap(":/icon_view_stereo.png")));
|
---|
188 | stereoButton->setPopupMode(QToolButton::InstantPopup);
|
---|
189 | toolbar->addWidget(stereoButton);
|
---|
190 |
|
---|
191 | // selection mode
|
---|
192 | toolbar->addSeparator();
|
---|
193 | QAction *selAtomAction = new QAction(QIcon(QPixmap(":/icon_select_atom.png")), tr("select atom by clicking"), this);
|
---|
194 | connect(selAtomAction, SIGNAL(triggered()), worldscene, SLOT(setSelectionModeAtom()));
|
---|
195 | toolbar->addAction(selAtomAction);
|
---|
196 | QAction *selMolAction = new QAction(QIcon(QPixmap(":/icon_select_molecule.png")), tr("select molecule by clicking"), this);
|
---|
197 | connect(selMolAction, SIGNAL(triggered()), worldscene, SLOT(setSelectionModeMolecule()));
|
---|
198 | toolbar->addAction(selMolAction);
|
---|
199 |
|
---|
200 | // dreiBein/domain enabler
|
---|
201 | toolbar->addSeparator();
|
---|
202 | QAction *seldreiBein = new QAction(QIcon(QPixmap(":/icon_dreiBein.png")), tr("enable/disable dreiBein"), this);
|
---|
203 | connect(seldreiBein, SIGNAL(triggered()), this, SLOT(changeDreiBein()));
|
---|
204 | toolbar->addAction(seldreiBein);
|
---|
205 | QAction *seldomain = new QAction(QIcon(QPixmap(":/icon_domain.png")), tr("enable/disable domain box"), this);
|
---|
206 | connect(seldomain, SIGNAL(triggered()), this, SLOT(changeDomain()));
|
---|
207 | toolbar->addAction(seldomain);
|
---|
208 | }
|
---|
209 |
|
---|
210 | void GLWorldView::createDomainBox()
|
---|
211 | {
|
---|
212 | QSettings settings;
|
---|
213 | settings.beginGroup("WorldView");
|
---|
214 | QColor colorFrame = settings.value("domainBoxColorFrame", QColor(150,160,200,255)).value<QColor>();
|
---|
215 | QColor colorAmbient = settings.value("domainBoxColorAmbient", QColor(50,60,100,255)).value<QColor>();
|
---|
216 | QColor colorDiffuse = settings.value("domainBoxColorDiffuse", QColor(150,160,200,180)).value<QColor>();
|
---|
217 | settings.setValue("domainBoxColorFrame", colorFrame);
|
---|
218 | settings.setValue("domainBoxColorAmbient", colorAmbient);
|
---|
219 | settings.setValue("domainBoxColorDiffuse", colorDiffuse);
|
---|
220 | const bool status = settings.value("domainBoxEnabled").toBool();
|
---|
221 | settings.endGroup();
|
---|
222 |
|
---|
223 | domainBoxMaterial = new QGLMaterial;
|
---|
224 | domainBoxMaterial->setAmbientColor(QColor(0,0,0,255));
|
---|
225 | domainBoxMaterial->setDiffuseColor(QColor(0,0,0,255));
|
---|
226 | domainBoxMaterial->setEmittedLight(colorFrame);
|
---|
227 |
|
---|
228 |
|
---|
229 | QGLMaterial *material = new QGLMaterial;
|
---|
230 | material->setAmbientColor(colorAmbient);
|
---|
231 | material->setDiffuseColor(colorDiffuse);
|
---|
232 |
|
---|
233 | QGLBuilder builder;
|
---|
234 | builder << QGL::Faceted;
|
---|
235 | builder << QGLCube(-1.0); // "inverted" => inside faces are used as front.
|
---|
236 | meshDomainBox = builder.finalizedSceneNode();
|
---|
237 | QMatrix4x4 mat;
|
---|
238 | mat.translate(0.5f, 0.5f, 0.5f);
|
---|
239 | meshDomainBox->setLocalTransform(mat);
|
---|
240 | meshDomainBox->setMaterial(material);
|
---|
241 |
|
---|
242 | setDomainStatus( status );
|
---|
243 | }
|
---|
244 |
|
---|
245 | void GLWorldView::createDreiBein()
|
---|
246 | {
|
---|
247 | QSettings settings;
|
---|
248 | settings.beginGroup("WorldView");
|
---|
249 | QColor colorX = settings.value("dreiBeinColorX", QColor(255,50,50,255)).value<QColor>();
|
---|
250 | QColor colorY = settings.value("dreiBeinColorY", QColor(50,255,50,255)).value<QColor>();
|
---|
251 | QColor colorZ = settings.value("dreiBeinColorZ", QColor(50,50,255,255)).value<QColor>();
|
---|
252 | settings.setValue("dreiBeinColorX", colorX);
|
---|
253 | settings.setValue("dreiBeinColorY", colorY);
|
---|
254 | settings.setValue("dreiBeinColorZ", colorZ);
|
---|
255 | const bool status = settings.value("dreiBeinEnabled").toBool();
|
---|
256 | settings.endGroup();
|
---|
257 |
|
---|
258 | // Create 3 color for the 3 axes.
|
---|
259 | dreiBeinMaterial[0] = new QGLMaterial;
|
---|
260 | dreiBeinMaterial[0]->setColor(colorX);
|
---|
261 | dreiBeinMaterial[1] = new QGLMaterial;
|
---|
262 | dreiBeinMaterial[1]->setColor(colorY);
|
---|
263 | dreiBeinMaterial[2] = new QGLMaterial;
|
---|
264 | dreiBeinMaterial[2]->setColor(colorZ);
|
---|
265 |
|
---|
266 | // Create the basic meshes (cylinder and cone).
|
---|
267 | QGLBuilder builderCyl;
|
---|
268 | builderCyl << QGLCylinder(.15,.15,1.6,16);
|
---|
269 | QGLSceneNode *cyl = builderCyl.finalizedSceneNode();
|
---|
270 |
|
---|
271 | QGLBuilder builderCone;
|
---|
272 | builderCone << QGLCylinder(0,.4,0.4,16);
|
---|
273 | QGLSceneNode *cone = builderCone.finalizedSceneNode();
|
---|
274 | {
|
---|
275 | QMatrix4x4 mat;
|
---|
276 | mat.translate(0.0f, 0.0f, 1.0f);
|
---|
277 | cone->setLocalTransform(mat);
|
---|
278 | }
|
---|
279 |
|
---|
280 | // Create a scene node from the 3 axes.
|
---|
281 | meshDreiBein = new QGLSceneNode(this);
|
---|
282 |
|
---|
283 | // X-direction
|
---|
284 | QGLSceneNode *node = new QGLSceneNode(meshDreiBein);
|
---|
285 | node->setMaterial(dreiBeinMaterial[0]);
|
---|
286 | node->addNode(cyl);
|
---|
287 | node->setPosition(QVector3D(.8f, 0.f, 0.f));
|
---|
288 | node->addNode(cone);
|
---|
289 | {
|
---|
290 | QMatrix4x4 mat;
|
---|
291 | mat.rotate(90, 0.0f, 1.0f, 0.0f);
|
---|
292 | node->setLocalTransform(mat);
|
---|
293 | }
|
---|
294 |
|
---|
295 | // Y-direction
|
---|
296 | node = new QGLSceneNode(meshDreiBein);
|
---|
297 | node->setMaterial(dreiBeinMaterial[1]);
|
---|
298 | node->addNode(cyl);
|
---|
299 | node->addNode(cone);
|
---|
300 | {
|
---|
301 | QMatrix4x4 mat;
|
---|
302 | mat.rotate(-90, 1.0f, 0.0f, 0.0f);
|
---|
303 | node->setLocalTransform(mat);
|
---|
304 | }
|
---|
305 | node->setPosition(QVector3D(0.f, .8f, 0.f));
|
---|
306 |
|
---|
307 | // Z-direction
|
---|
308 | node = new QGLSceneNode(meshDreiBein);
|
---|
309 | node->setMaterial(dreiBeinMaterial[2]);
|
---|
310 | node->addNode(cyl);
|
---|
311 | node->addNode(cone);
|
---|
312 | node->setPosition(QVector3D(0.f, 0.f, .8f));
|
---|
313 |
|
---|
314 | setdreiBeinStatus( status );
|
---|
315 | }
|
---|
316 |
|
---|
317 | /**
|
---|
318 | * Update operation which can be invoked by the observable (which should be the
|
---|
319 | * change tracker here).
|
---|
320 | */
|
---|
321 | void GLWorldView::update(Observable *publisher)
|
---|
322 | {
|
---|
323 | emit changed();
|
---|
324 | }
|
---|
325 |
|
---|
326 | /**
|
---|
327 | * The observable can tell when it dies.
|
---|
328 | */
|
---|
329 | void GLWorldView::subjectKilled(Observable *publisher) {}
|
---|
330 |
|
---|
331 | /** Listen to specific changes to the world.
|
---|
332 | *
|
---|
333 | * @param publisher ref to observable.
|
---|
334 | * @param notification type of notification
|
---|
335 | */
|
---|
336 | void GLWorldView::recieveNotification(Observable *publisher, Notification_ptr notification)
|
---|
337 | {
|
---|
338 | if (static_cast<World *>(publisher) == World::getPointer()) {
|
---|
339 | switch (notification->getChannelNo()) {
|
---|
340 | case World::AtomInserted:
|
---|
341 | {
|
---|
342 | const atomicNumber_t _id = World::getInstance().lastChanged<atom>()->getId();
|
---|
343 | #ifdef LOG_OBSERVER
|
---|
344 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";
|
---|
345 | #endif
|
---|
346 | emit atomInserted(_id);
|
---|
347 | break;
|
---|
348 | }
|
---|
349 | case World::AtomRemoved:
|
---|
350 | {
|
---|
351 | const atomicNumber_t _id = World::getInstance().lastChanged<atom>()->getId();
|
---|
352 | #ifdef LOG_OBSERVER
|
---|
353 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been removed.";
|
---|
354 | #endif
|
---|
355 | emit atomRemoved(_id);
|
---|
356 | break;
|
---|
357 | }
|
---|
358 | case World::SelectionChanged:
|
---|
359 | {
|
---|
360 | #ifdef LOG_OBSERVER
|
---|
361 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that selection has changed.";
|
---|
362 | #endif
|
---|
363 | emit worldSelectionChanged();
|
---|
364 | break;
|
---|
365 | }
|
---|
366 | case World::MoleculeInserted:
|
---|
367 | {
|
---|
368 | const molecule *_molecule = World::getInstance().lastChanged<molecule>();
|
---|
369 | #ifdef LOG_OBSERVER
|
---|
370 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_molecule->getId())+" has been removed.";
|
---|
371 | #endif
|
---|
372 | emit moleculeInserted(_molecule);
|
---|
373 | break;
|
---|
374 | }
|
---|
375 | case World::MoleculeRemoved:
|
---|
376 | {
|
---|
377 | const molecule *_molecule = World::getInstance().lastChanged<molecule>();
|
---|
378 | #ifdef LOG_OBSERVER
|
---|
379 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_molecule->getId())+" has been removed.";
|
---|
380 | #endif
|
---|
381 | emit moleculeRemoved(_molecule);
|
---|
382 | break;
|
---|
383 | }
|
---|
384 | default:
|
---|
385 | ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for World.");
|
---|
386 | break;
|
---|
387 | }
|
---|
388 | } else if (static_cast<WorldTime *>(publisher) == WorldTime::getPointer()) {
|
---|
389 | switch (notification->getChannelNo()) {
|
---|
390 | case WorldTime::TimeChanged:
|
---|
391 | {
|
---|
392 | #ifdef LOG_OBSERVER
|
---|
393 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that WorldTime's time has changed.";
|
---|
394 | #endif
|
---|
395 | emit changed();
|
---|
396 | emit TimeChanged();
|
---|
397 | break;
|
---|
398 | }
|
---|
399 | default:
|
---|
400 | ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for WorldTime.");
|
---|
401 | break;
|
---|
402 | }
|
---|
403 | } else if (dynamic_cast<AtomObservable *>(publisher) != NULL) {
|
---|
404 | switch (notification->getChannelNo()) {
|
---|
405 | case AtomObservable::PositionChanged:
|
---|
406 | {
|
---|
407 | #ifdef LOG_OBSERVER
|
---|
408 | const atom *_atom = dynamic_cast<const atom *>(publisher);
|
---|
409 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_atom->getId())+" has changed its position.";
|
---|
410 | #endif
|
---|
411 | emit changed();
|
---|
412 | break;
|
---|
413 | }
|
---|
414 | default:
|
---|
415 | ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for AtomObservable.");
|
---|
416 | break;
|
---|
417 | }
|
---|
418 | } else if (static_cast<ShapeRegistry*>(publisher) == ShapeRegistry::getPointer()) {
|
---|
419 | switch (notification->getChannelNo()) {
|
---|
420 | case ShapeRegistry::ShapeInserted:
|
---|
421 | {
|
---|
422 | emit ShapeAdded();
|
---|
423 | break;
|
---|
424 | }
|
---|
425 | case ShapeRegistry::ShapeRemoved:
|
---|
426 | {
|
---|
427 | emit ShapeRemoved();
|
---|
428 | break;
|
---|
429 | }
|
---|
430 | case ShapeRegistry::SelectionChanged:
|
---|
431 | {
|
---|
432 | worldscene->updateSelectedShapes();
|
---|
433 | break;
|
---|
434 | }
|
---|
435 | default:
|
---|
436 | ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for ShapeRegistry.");
|
---|
437 | break;
|
---|
438 | }
|
---|
439 | } else
|
---|
440 | ASSERT(0, "GLWorldView::recieveNotification() - received notification from unknown source.");
|
---|
441 | }
|
---|
442 |
|
---|
443 | void GLWorldView::checkChanges()
|
---|
444 | {
|
---|
445 | updateGL();
|
---|
446 | needsRedraw = false;
|
---|
447 | }
|
---|
448 |
|
---|
449 | void GLWorldView::changeDreiBein()
|
---|
450 | {
|
---|
451 | // invert to new status
|
---|
452 | const bool status = ((meshDreiBein->options() & QGLSceneNode::HideNode) == 0);
|
---|
453 | setdreiBeinStatus(!status);
|
---|
454 | // realize
|
---|
455 | updateGL();
|
---|
456 | needsRedraw = true;
|
---|
457 | }
|
---|
458 |
|
---|
459 | void GLWorldView::setdreiBeinStatus(const bool status)
|
---|
460 | {
|
---|
461 | if (status)
|
---|
462 | meshDreiBein->setOptions( meshDreiBein->options() & (255-QGLSceneNode::HideNode) );
|
---|
463 | else
|
---|
464 | meshDreiBein->setOptions( meshDreiBein->options() | QGLSceneNode::HideNode );
|
---|
465 | }
|
---|
466 |
|
---|
467 | void GLWorldView::changeDomain()
|
---|
468 | {
|
---|
469 | // invert to new status
|
---|
470 | const bool status = ((meshDomainBox->options() & QGLSceneNode::HideNode) == 0);
|
---|
471 | setDomainStatus(!status);
|
---|
472 | // realize
|
---|
473 | updateGL();
|
---|
474 | needsRedraw = true;
|
---|
475 | }
|
---|
476 |
|
---|
477 | void GLWorldView::setDomainStatus(const bool status)
|
---|
478 | {
|
---|
479 | if (status)
|
---|
480 | meshDomainBox->setOptions( meshDomainBox->options() & (255-QGLSceneNode::HideNode) );
|
---|
481 | else
|
---|
482 | meshDomainBox->setOptions( meshDomainBox->options() | QGLSceneNode::HideNode );
|
---|
483 | }
|
---|
484 |
|
---|
485 | void GLWorldView::sceneChangeSignalled()
|
---|
486 | {
|
---|
487 | if (!needsRedraw){
|
---|
488 | redrawTimer->singleShot(0, this, SLOT(checkChanges()));
|
---|
489 | needsRedraw = true;
|
---|
490 | redrawTimer->start();
|
---|
491 | }
|
---|
492 | }
|
---|
493 |
|
---|
494 | void GLWorldView::initializeGL(QGLPainter *painter)
|
---|
495 | {
|
---|
496 | worldscene->initialize(this, painter);
|
---|
497 | changesPresent = false;
|
---|
498 | }
|
---|
499 |
|
---|
500 | void GLWorldView::paintGL(QGLPainter *painter)
|
---|
501 | {
|
---|
502 | if (changesPresent) {
|
---|
503 | initializeGL(painter);
|
---|
504 | changesPresent = false;
|
---|
505 | }
|
---|
506 |
|
---|
507 | QVector3D cameraDir = camera()->center() - camera()->eye();
|
---|
508 | cameraDir.normalize();
|
---|
509 | QVector4D cameraPlane(cameraDir, QVector3D::dotProduct(cameraDir, camera()->eye()));
|
---|
510 | worldscene->draw(painter, cameraPlane);
|
---|
511 |
|
---|
512 | drawDreiBein(painter);
|
---|
513 |
|
---|
514 | // Domain box has to be last because of its transparency.
|
---|
515 | drawDomainBox(painter);
|
---|
516 | }
|
---|
517 |
|
---|
518 | void GLWorldView::keyPressEvent(QKeyEvent *e)
|
---|
519 | {
|
---|
520 | if (e->key() == Qt::Key_Tab) {
|
---|
521 | // The Tab key turns the ShowPicking option on and off,
|
---|
522 | // which helps show what the pick buffer looks like.
|
---|
523 | setOption(QGLView::ShowPicking, ((options() & QGLView::ShowPicking) == 0));
|
---|
524 | updateGL();
|
---|
525 | }
|
---|
526 | QGLView::keyPressEvent(e);
|
---|
527 | }
|
---|
528 |
|
---|
529 | void GLWorldView::changeSignalled()
|
---|
530 | {
|
---|
531 | changesPresent = true;
|
---|
532 | }
|
---|
533 |
|
---|
534 |
|
---|
535 | /**
|
---|
536 | * Set the current camera control mode.
|
---|
537 | */
|
---|
538 | void GLWorldView::setCameraControlMode(GLWorldView::CameraControlModeType mode)
|
---|
539 | {
|
---|
540 | cameraControlMode = mode;
|
---|
541 | }
|
---|
542 |
|
---|
543 | void GLWorldView::setCameraControlModeRotation()
|
---|
544 | {
|
---|
545 | setCameraControlMode(Rotate);
|
---|
546 | }
|
---|
547 |
|
---|
548 | void GLWorldView::setCameraControlModeTranslation()
|
---|
549 | {
|
---|
550 | setCameraControlMode(Translate);
|
---|
551 | }
|
---|
552 |
|
---|
553 | /**
|
---|
554 | * Returns the current camera control mode.
|
---|
555 | * This needs to be invertable (rotation - translation), if the shift key is pressed.
|
---|
556 | */
|
---|
557 | GLWorldView::CameraControlModeType GLWorldView::getCameraControlMode(bool inverted)
|
---|
558 | {
|
---|
559 | if (inverted){
|
---|
560 | if (cameraControlMode == Rotate)
|
---|
561 | return Translate;
|
---|
562 | if (cameraControlMode == Translate)
|
---|
563 | return Rotate;
|
---|
564 | return Rotate;
|
---|
565 | }else
|
---|
566 | return cameraControlMode;
|
---|
567 | }
|
---|
568 |
|
---|
569 | /**
|
---|
570 | * Set the camera so it can oversee the whole domain.
|
---|
571 | */
|
---|
572 | void GLWorldView::fitCameraToDomain()
|
---|
573 | {
|
---|
574 | // Move the camera focus point to the center of the domain box.
|
---|
575 | Vector v = World::getInstance().getDomain().translateIn(Vector(0.5, 0.5, 0.5));
|
---|
576 | camera()->setCenter(QVector3D(v[0], v[1], v[2]));
|
---|
577 |
|
---|
578 | // Guess some eye distance.
|
---|
579 | double dist = v.Norm() * 3;
|
---|
580 | camera()->setEye(QVector3D(v[0], v[1], v[2] + dist));
|
---|
581 | camera()->setUpVector(QVector3D(0, 1, 0));
|
---|
582 | }
|
---|
583 |
|
---|
584 | void GLWorldView::setCameraStereoModeDisable()
|
---|
585 | {
|
---|
586 | setStereoType(QGLView::Hardware);
|
---|
587 | camera()->setEyeSeparation(0.0);
|
---|
588 | updateGL();
|
---|
589 | }
|
---|
590 |
|
---|
591 | void GLWorldView::setCameraStereoModeHardware()
|
---|
592 | {
|
---|
593 | setStereoType(QGLView::Hardware);
|
---|
594 | camera()->setEyeSeparation(defaultEyeSeparation);
|
---|
595 | updateGL();
|
---|
596 | }
|
---|
597 |
|
---|
598 | void GLWorldView::setCameraStereoModeLeftRight()
|
---|
599 | {
|
---|
600 | setStereoType(QGLView::LeftRight);
|
---|
601 | camera()->setEyeSeparation(defaultEyeSeparation);
|
---|
602 | updateGL();
|
---|
603 | }
|
---|
604 |
|
---|
605 | void GLWorldView::setCameraStereoModeRightLeft()
|
---|
606 | {
|
---|
607 | setStereoType(QGLView::RightLeft);
|
---|
608 | camera()->setEyeSeparation(defaultEyeSeparation);
|
---|
609 | updateGL();
|
---|
610 | }
|
---|
611 |
|
---|
612 | void GLWorldView::setCameraStereoModeTopBottom()
|
---|
613 | {
|
---|
614 | setStereoType(QGLView::TopBottom);
|
---|
615 | camera()->setEyeSeparation(defaultEyeSeparation);
|
---|
616 | updateGL();
|
---|
617 | }
|
---|
618 |
|
---|
619 | void GLWorldView::setCameraStereoModeBottomTop()
|
---|
620 | {
|
---|
621 | setStereoType(QGLView::BottomTop);
|
---|
622 | camera()->setEyeSeparation(defaultEyeSeparation);
|
---|
623 | updateGL();
|
---|
624 | }
|
---|
625 |
|
---|
626 | void GLWorldView::setCameraStereoModeAnaglyph()
|
---|
627 | {
|
---|
628 | setStereoType(QGLView::RedCyanAnaglyph);
|
---|
629 | camera()->setEyeSeparation(defaultEyeSeparation);
|
---|
630 | updateGL();
|
---|
631 | }
|
---|
632 |
|
---|
633 | void GLWorldView::mousePressEvent(QMouseEvent *event)
|
---|
634 | {
|
---|
635 | QGLView::mousePressEvent(event);
|
---|
636 |
|
---|
637 | // Reset the saved mouse position.
|
---|
638 | lastMousePos = event->posF();
|
---|
639 | }
|
---|
640 |
|
---|
641 | /**
|
---|
642 | * Handle a mouse move event.
|
---|
643 | * This is used to control the camera (rotation and translation) when the left button is being pressed.
|
---|
644 | */
|
---|
645 | void GLWorldView::mouseMoveEvent(QMouseEvent *event)
|
---|
646 | {
|
---|
647 | if (event->buttons() & Qt::LeftButton){
|
---|
648 | // Find the mouse distance since the last event.
|
---|
649 | QPointF d = event->posF() - lastMousePos;
|
---|
650 | lastMousePos = event->posF();
|
---|
651 |
|
---|
652 | // Rotate or translate? (inverted by shift key)
|
---|
653 | CameraControlModeType mode = getCameraControlMode(event->modifiers() & Qt::ShiftModifier);
|
---|
654 |
|
---|
655 | if (mode == Rotate){
|
---|
656 | // Rotate the camera.
|
---|
657 | d *= 0.3;
|
---|
658 | camera()->tiltPanRollCenter(- d.y(), - d.x(), 0);
|
---|
659 | }else if (mode == Translate){
|
---|
660 | // Translate the camera.
|
---|
661 | d *= 0.02;
|
---|
662 | camera()->translateCenter(- d.x(), d.y(), 0);
|
---|
663 | camera()->translateEye(- d.x(), d.y(), 0);
|
---|
664 | }
|
---|
665 | }else{
|
---|
666 | // Without this Qt would not test for hover events (i.e. mouse over an atom).
|
---|
667 | QGLView::mouseMoveEvent(event);
|
---|
668 | }
|
---|
669 | }
|
---|
670 |
|
---|
671 | /**
|
---|
672 | * When the mouse wheel is used, zoom in or out.
|
---|
673 | */
|
---|
674 | void GLWorldView::wheelEvent(QWheelEvent *event)
|
---|
675 | {
|
---|
676 | // Find the distance between the eye and focus point.
|
---|
677 | QVector3D d = camera()->eye() - camera()->center();
|
---|
678 |
|
---|
679 | // Scale the distance.
|
---|
680 | if (event->delta() < 0)
|
---|
681 | d *= 1.2;
|
---|
682 | else if (event->delta() > 0)
|
---|
683 | d /= 1.2;
|
---|
684 |
|
---|
685 | // Set new eye position.
|
---|
686 | camera()->setEye(camera()->center() + d);
|
---|
687 | }
|
---|
688 |
|
---|
689 | /**
|
---|
690 | * Draw a transparent cube representing the domain.
|
---|
691 | */
|
---|
692 | void GLWorldView::drawDomainBox(QGLPainter *painter) const
|
---|
693 | {
|
---|
694 | // Apply the domain matrix.
|
---|
695 | RealSpaceMatrix m = World::getInstance().getDomain().getM();
|
---|
696 | painter->modelViewMatrix().push();
|
---|
697 | painter->modelViewMatrix() *= QMatrix4x4(m.at(0,0), m.at(0,1), m.at(0,2), 0.0,
|
---|
698 | m.at(1,0), m.at(1,1), m.at(1,2), 0.0,
|
---|
699 | m.at(2,0), m.at(2,1), m.at(2,2), 0.0,
|
---|
700 | 0.0, 0.0, 0.0, 1.0);
|
---|
701 |
|
---|
702 | // Draw the transparent cube.
|
---|
703 | painter->setStandardEffect(QGL::LitMaterial);
|
---|
704 | glCullFace(GL_BACK);
|
---|
705 | glEnable(GL_CULL_FACE);
|
---|
706 | glEnable(GL_BLEND);
|
---|
707 | glDepthMask(0);
|
---|
708 | //glDisable(GL_DEPTH_TEST);
|
---|
709 | meshDomainBox->draw(painter);
|
---|
710 | //glEnable(GL_DEPTH_TEST);
|
---|
711 | glDepthMask(1);
|
---|
712 | glDisable(GL_BLEND);
|
---|
713 | glDisable(GL_CULL_FACE);
|
---|
714 |
|
---|
715 | // Draw the outlines (if we have drawn the box itself)
|
---|
716 | if ((meshDomainBox->options() & QGLSceneNode::HideNode) == 0) {
|
---|
717 | painter->setFaceMaterial(QGL::AllFaces, domainBoxMaterial);
|
---|
718 | //glEnable(GL_LINE_SMOOTH);
|
---|
719 | QVector3DArray array;
|
---|
720 | array.append(0, 0, 0); array.append(1, 0, 0);
|
---|
721 | array.append(1, 0, 0); array.append(1, 1, 0);
|
---|
722 | array.append(1, 1, 0); array.append(0, 1, 0);
|
---|
723 | array.append(0, 1, 0); array.append(0, 0, 0);
|
---|
724 |
|
---|
725 | array.append(0, 0, 1); array.append(1, 0, 1);
|
---|
726 | array.append(1, 0, 1); array.append(1, 1, 1);
|
---|
727 | array.append(1, 1, 1); array.append(0, 1, 1);
|
---|
728 | array.append(0, 1, 1); array.append(0, 0, 1);
|
---|
729 |
|
---|
730 | array.append(0, 0, 0); array.append(0, 0, 1);
|
---|
731 | array.append(1, 0, 0); array.append(1, 0, 1);
|
---|
732 | array.append(0, 1, 0); array.append(0, 1, 1);
|
---|
733 | array.append(1, 1, 0); array.append(1, 1, 1);
|
---|
734 | painter->clearAttributes();
|
---|
735 | painter->setVertexAttribute(QGL::Position, array);
|
---|
736 | painter->draw(QGL::Lines, 24);
|
---|
737 | }
|
---|
738 |
|
---|
739 | painter->modelViewMatrix().pop();
|
---|
740 | }
|
---|
741 |
|
---|
742 | void GLWorldView::drawDreiBein(QGLPainter *painter)
|
---|
743 | {
|
---|
744 | painter->modelViewMatrix().push();
|
---|
745 | painter->modelViewMatrix().translate(camera()->center());
|
---|
746 | painter->setStandardEffect(QGL::LitMaterial);
|
---|
747 | painter->setFaceMaterial(QGL::FrontFaces, NULL);
|
---|
748 | meshDreiBein->draw(painter);
|
---|
749 | painter->modelViewMatrix().pop();
|
---|
750 | }
|
---|
751 |
|
---|
752 | void GLWorldView::sceneHoverSignalled(const atom *_atom)
|
---|
753 | {
|
---|
754 | emit hoverChanged(_atom);
|
---|
755 | }
|
---|
756 |
|
---|
757 |
|
---|
758 | //#include <GL/glu.h>
|
---|
759 | //#include <QtGui/qslider.h>
|
---|
760 | //#include <QtGui/qevent.h>
|
---|
761 | //
|
---|
762 | //#include "ui_dialoglight.h"
|
---|
763 | //
|
---|
764 | //#include "CodePatterns/MemDebug.hpp"
|
---|
765 | //
|
---|
766 | //#include <iostream>
|
---|
767 | //#include <boost/shared_ptr.hpp>
|
---|
768 | //
|
---|
769 | //#include "LinearAlgebra/Line.hpp"
|
---|
770 | //#include "Atom/atom.hpp"
|
---|
771 | //#include "Bond/bond.hpp"
|
---|
772 | //#include "Element/element.hpp"
|
---|
773 | //#include "molecule.hpp"
|
---|
774 | //#include "Element/periodentafel.hpp"
|
---|
775 | //#include "World.hpp"
|
---|
776 | //
|
---|
777 | //#if defined(Q_CC_MSVC)
|
---|
778 | //#pragma warning(disable:4305) // init: truncation from const double to float
|
---|
779 | //#endif
|
---|
780 | //
|
---|
781 | //
|
---|
782 | //GLMoleculeView::GLMoleculeView(QWidget *parent) :
|
---|
783 | // QGLWidget(parent), Observer("GLMoleculeView"), X(Vector(1,0,0)), Y(Vector(0,1,0)), Z(Vector(0,0,1))
|
---|
784 | //{
|
---|
785 | // xRot = yRot = zRot = 0.0; // default object rotation
|
---|
786 | // scale = 5.; // default object scale
|
---|
787 | // object = 0;
|
---|
788 | // LightPosition[0] = 0.0f;
|
---|
789 | // LightPosition[1] = 2.0f;
|
---|
790 | // LightPosition[2] = 2.0f;
|
---|
791 | // LightPosition[3] = 0.0f;
|
---|
792 | // LightDiffuse[0] = 0.5f;
|
---|
793 | // LightDiffuse[1] = 0.5f;
|
---|
794 | // LightDiffuse[2] = 0.5f;
|
---|
795 | // LightDiffuse[3] = 0.0f;
|
---|
796 | // LightAmbient[0] = 0.0f;
|
---|
797 | // LightAmbient[1] = 0.0f;
|
---|
798 | // LightAmbient[2] = 0.0f;
|
---|
799 | // LightAmbient[3] = 0.0f;
|
---|
800 | //
|
---|
801 | // SelectionColor[0] = 0;
|
---|
802 | // SelectionColor[1] = 128;
|
---|
803 | // SelectionColor[2] = 128;
|
---|
804 | //
|
---|
805 | // MultiViewEnabled = true;
|
---|
806 | //
|
---|
807 | // isSignaller = false;
|
---|
808 | //
|
---|
809 | // World::getInstance().signOn(this);
|
---|
810 | //}
|
---|
811 | //
|
---|
812 | ///** Destructor of GLMoleculeView.
|
---|
813 | // * Free's the CallList.
|
---|
814 | // */
|
---|
815 | //GLMoleculeView::~GLMoleculeView()
|
---|
816 | //{
|
---|
817 | // makeCurrent();
|
---|
818 | // glDeleteLists( object, 1 );
|
---|
819 | //
|
---|
820 | // World::getInstance().signOff(this);
|
---|
821 | //}
|
---|
822 | //
|
---|
823 | ///** Paints the conents of the OpenGL window.
|
---|
824 | // * Clears the GL buffers, enables lighting and depth.
|
---|
825 | // * Window is either quartered (if GLMoleculeView::MultiViewEnabled) and xy, xz, yz planar views
|
---|
826 | // * are added. Uses the CallList, constructed during InitializeGL().
|
---|
827 | // */
|
---|
828 | //void GLMoleculeView::paintGL()
|
---|
829 | //{
|
---|
830 | // Vector spot;
|
---|
831 | //
|
---|
832 | // glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
---|
833 | // glShadeModel(GL_SMOOTH); // Enable Smooth Shading
|
---|
834 | // glEnable(GL_LIGHTING); // Enable Light One
|
---|
835 | // glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
---|
836 | // glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
---|
837 | // glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
---|
838 | //
|
---|
839 | // // 3d viewport
|
---|
840 | // if (MultiViewEnabled)
|
---|
841 | // glViewport( 0, 0, (GLint)width/2, (GLint)height/2 );
|
---|
842 | // else
|
---|
843 | // glViewport( 0, 0, (GLint)width, (GLint)height );
|
---|
844 | // glMatrixMode( GL_PROJECTION );
|
---|
845 | // glLoadIdentity();
|
---|
846 | // glFrustum( -1.0, 1.0, -1.0, 1.0, 1.0, 50.0 );
|
---|
847 | // glMatrixMode( GL_MODELVIEW );
|
---|
848 | // glLoadIdentity();
|
---|
849 | //
|
---|
850 | // // calculate point of view and direction
|
---|
851 | // glTranslated(position[0],position[1],position[2]);
|
---|
852 | // glTranslated(0.0, 0.0, -scale);
|
---|
853 | // glRotated(xRot, 1.0, 0.0, 0.0);
|
---|
854 | // glRotated(yRot, 0.0, 1.0, 0.0);
|
---|
855 | // glRotated(zRot, 0.0, 0.0, 1.0);
|
---|
856 | //
|
---|
857 | // // render scene
|
---|
858 | // glCallList(object);
|
---|
859 | //
|
---|
860 | // // enable light
|
---|
861 | // glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
|
---|
862 | // glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
|
---|
863 | // glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light
|
---|
864 | // glEnable(GL_LIGHT1); // Enable Light One
|
---|
865 | //
|
---|
866 | // if (MultiViewEnabled) {
|
---|
867 | // // xy view port
|
---|
868 | // glViewport( (GLint)width/2, 0, (GLint)width/2, (GLint)height/2 );
|
---|
869 | // glMatrixMode( GL_PROJECTION );
|
---|
870 | // glLoadIdentity();
|
---|
871 | // glScalef(1./scale, 1./scale,1./scale);
|
---|
872 | // glOrtho(0, width/2, 0, height/2, 0,0);
|
---|
873 | // glMatrixMode( GL_MODELVIEW );
|
---|
874 | // glLoadIdentity();
|
---|
875 | //
|
---|
876 | // // calculate point of view and direction
|
---|
877 | // view = position;
|
---|
878 | // spot = Vector(0.,0.,scale);
|
---|
879 | // top = Vector(0.,1.,0.);
|
---|
880 | // gluLookAt(
|
---|
881 | // spot[0], spot[1], spot[2],
|
---|
882 | // view[0], view[1], view[2],
|
---|
883 | // top[0], top[1], top[2]);
|
---|
884 | //
|
---|
885 | // // enable light
|
---|
886 | // glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
|
---|
887 | // glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
|
---|
888 | // glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light
|
---|
889 | // glEnable(GL_LIGHT1); // Enable Light One
|
---|
890 | //
|
---|
891 | // // render scene
|
---|
892 | // glCallList(object);
|
---|
893 | //
|
---|
894 | // // xz viewport
|
---|
895 | // glViewport( 0, (GLint)height/2, (GLint)width/2, (GLint)height/2 );
|
---|
896 | // glMatrixMode( GL_PROJECTION );
|
---|
897 | // glLoadIdentity();
|
---|
898 | // glScalef(1./scale, 1./scale,1./scale);
|
---|
899 | // glOrtho(0, width/2, 0, height/2, 0,0);
|
---|
900 | // glMatrixMode( GL_MODELVIEW );
|
---|
901 | // glLoadIdentity();
|
---|
902 | //
|
---|
903 | // // calculate point of view and direction
|
---|
904 | // view = position;
|
---|
905 | // spot = Vector(0.,scale,0.);
|
---|
906 | // top = Vector(1.,0.,0.);
|
---|
907 | // gluLookAt(
|
---|
908 | // spot[0], spot[1], spot[2],
|
---|
909 | // view[0], view[1], view[2],
|
---|
910 | // top[0], top[1], top[2]);
|
---|
911 | //
|
---|
912 | // // enable light
|
---|
913 | // glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
|
---|
914 | // glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
|
---|
915 | // glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light
|
---|
916 | // glEnable(GL_LIGHT1); // Enable Light One
|
---|
917 | //
|
---|
918 | // // render scene
|
---|
919 | // glCallList(object);
|
---|
920 | //
|
---|
921 | // //yz viewport
|
---|
922 | // glViewport( (GLint)width/2, (GLint)height/2, (GLint)width/2, (GLint)height/2 );
|
---|
923 | // glMatrixMode( GL_PROJECTION );
|
---|
924 | // glLoadIdentity();
|
---|
925 | // glScalef(1./scale, 1./scale,1./scale);
|
---|
926 | // glOrtho(0, width/2, 0, height/2, 0,0);
|
---|
927 | // glMatrixMode( GL_MODELVIEW );
|
---|
928 | // glLoadIdentity();
|
---|
929 | //
|
---|
930 | // // calculate point of view and direction
|
---|
931 | // view= position;
|
---|
932 | // spot = Vector(scale,0.,0.);
|
---|
933 | // top = Vector(0.,1.,0.);
|
---|
934 | // gluLookAt(
|
---|
935 | // spot[0], spot[1], spot[2],
|
---|
936 | // view[0], view[1], view[2],
|
---|
937 | // top[0], top[1], top[2]);
|
---|
938 | //
|
---|
939 | // // enable light
|
---|
940 | // glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
|
---|
941 | // glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
|
---|
942 | // glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light
|
---|
943 | // glEnable(GL_LIGHT1); // Enable Light One
|
---|
944 | //
|
---|
945 | // // render scene
|
---|
946 | // glCallList(object);
|
---|
947 | // }
|
---|
948 | // //CoordinatesBar->setText( QString ("X: %1, Y: %2, Z: %3").arg(position[0]).arg(position[1]).arg(position[2]) );
|
---|
949 | //}
|
---|
950 | //
|
---|
951 | ////void polarView{GLdouble distance, GLdouble twist,
|
---|
952 | //// GLdouble elevation, GLdouble azimuth)
|
---|
953 | ////{
|
---|
954 | //// glTranslated(0.0, 0.0, -distance);
|
---|
955 | //// glRotated(-twist, 0.0, 0.0, 1.0);
|
---|
956 | //// glRotated(-elevation, 1.0, 0.0, 0.0);
|
---|
957 | //// glRotated(azimuth, 0.0, 0.0, 1.0);
|
---|
958 | ////}
|
---|
959 | //
|
---|
960 | ///** Make a sphere.
|
---|
961 | // * \param x position
|
---|
962 | // * \param radius radius
|
---|
963 | // * \param color[3] color rgb values
|
---|
964 | // */
|
---|
965 | //void GLMoleculeView::makeSphere(const Vector &x, double radius, const unsigned char color[3])
|
---|
966 | //{
|
---|
967 | // float blueMaterial[] = { 255./(float)color[0], 255./(float)color[1], 255./(float)color[2], 1 }; // need to recast from [0,255] with integers into [0,1] with floats
|
---|
968 | // GLUquadricObj* q = gluNewQuadric ();
|
---|
969 | // gluQuadricOrientation(q, GLU_OUTSIDE);
|
---|
970 | //
|
---|
971 | // std::cout << "Setting sphere at " << x << " with color r"
|
---|
972 | // << (int)color[0] << ",g" << (int)color[1] << ",b" << (int)color[2] << "." << endl;
|
---|
973 | //
|
---|
974 | // glPushMatrix();
|
---|
975 | // glTranslatef( x[0], x[1], x[2]);
|
---|
976 | //// glRotatef( xRot, 1.0, 0.0, 0.0);
|
---|
977 | //// glRotatef( yRot, 0.0, 1.0, 0.0);
|
---|
978 | //// glRotatef( zRot, 0.0, 0.0, 1.0);
|
---|
979 | // glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blueMaterial);
|
---|
980 | // gluSphere (q, (GLdouble)radius, 10, 10);
|
---|
981 | // glPopMatrix();
|
---|
982 | //}
|
---|
983 | //
|
---|
984 | ///** Make a cylinder.
|
---|
985 | // * \param x origin
|
---|
986 | // * \param y direction
|
---|
987 | // * \param radius thickness
|
---|
988 | // * \param height length
|
---|
989 | // * \color[3] color rgb values
|
---|
990 | // */
|
---|
991 | //void GLMoleculeView::makeCylinder(const Vector &x, const Vector &y, double radius, double height, const unsigned char color[3])
|
---|
992 | //{
|
---|
993 | // float blueMaterial[] = { 255./(float)color[0], 255./(float)color[1], 255./(float)color[2], 1 };
|
---|
994 | // GLUquadricObj* q = gluNewQuadric ();
|
---|
995 | // gluQuadricOrientation(q, GLU_OUTSIDE);
|
---|
996 | // Vector a,b;
|
---|
997 | // Vector OtherAxis;
|
---|
998 | // double alpha;
|
---|
999 | // a = x - y;
|
---|
1000 | // // construct rotation axis
|
---|
1001 | // b = a;
|
---|
1002 | // b.VectorProduct(Z);
|
---|
1003 | // Line axis(zeroVec, b);
|
---|
1004 | // // calculate rotation angle
|
---|
1005 | // alpha = a.Angle(Z);
|
---|
1006 | // // construct other axis to check right-hand rule
|
---|
1007 | // OtherAxis = b;
|
---|
1008 | // OtherAxis.VectorProduct(Z);
|
---|
1009 | // // assure right-hand rule for the rotation
|
---|
1010 | // if (a.ScalarProduct(OtherAxis) < MYEPSILON)
|
---|
1011 | // alpha = M_PI-alpha;
|
---|
1012 | // // check
|
---|
1013 | // Vector a_rotated = axis.rotateVector(a, alpha);
|
---|
1014 | // std::cout << "Setting cylinder from "// << x << " to " << y
|
---|
1015 | // << a << " to " << a_rotated << " around " << b << " by " << alpha/M_PI*180. << ", respectively, "
|
---|
1016 | // << " with color r"
|
---|
1017 | // << (int)color[0] << ",g" << (int)color[1] << ",b" << (int)color[2] << "." << endl;
|
---|
1018 | //
|
---|
1019 | // glPushMatrix();
|
---|
1020 | // glTranslatef( x[0], x[1], x[2]);
|
---|
1021 | // glRotatef( alpha/M_PI*180., b[0], b[1], b[2]);
|
---|
1022 | // glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blueMaterial);
|
---|
1023 | // gluCylinder (q, (GLdouble)radius, (GLdouble)radius, (GLdouble)height, 10, 10);
|
---|
1024 | // glPopMatrix();
|
---|
1025 | //}
|
---|
1026 | //
|
---|
1027 | ///** Defines the display CallList.
|
---|
1028 | // * Goes through all molecules and their atoms and adds spheres for atoms and cylinders
|
---|
1029 | // * for bonds. Heeds GLMoleculeView::SelectedAtom and GLMoleculeView::SelectedMolecule.
|
---|
1030 | // */
|
---|
1031 | //void GLMoleculeView::initializeGL()
|
---|
1032 | //{
|
---|
1033 | // double x[3] = {-1, 0, -10};
|
---|
1034 | // unsigned char white[3] = {255,255,255};
|
---|
1035 | // Vector Position, OtherPosition;
|
---|
1036 | // QSize window = size();
|
---|
1037 | // width = window.width();
|
---|
1038 | // height = window.height();
|
---|
1039 | // std::cout << "Setting width to " << width << " and height to " << height << std::endl;
|
---|
1040 | // GLfloat shininess[] = { 0.0 };
|
---|
1041 | // GLfloat specular[] = { 0, 0, 0, 1 };
|
---|
1042 | // glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Let OpenGL clear to black
|
---|
1043 | // object = glGenLists(1);
|
---|
1044 | // glNewList( object, GL_COMPILE );
|
---|
1045 | // glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
|
---|
1046 | // glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
|
---|
1047 | //
|
---|
1048 | // const std::vector<molecule*> &molecules = World::getInstance().getAllMolecules();
|
---|
1049 | //
|
---|
1050 | // if (molecules.size() > 0) {
|
---|
1051 | // for (std::vector<molecule*>::const_iterator Runner = molecules.begin();
|
---|
1052 | // Runner != molecules.end();
|
---|
1053 | // Runner++) {
|
---|
1054 | // for (molecule::const_iterator atomiter = (*Runner)->begin();
|
---|
1055 | // atomiter != (*Runner)->end();
|
---|
1056 | // ++atomiter) {
|
---|
1057 | // // create atom
|
---|
1058 | // const element *ptr = (*atomiter)->getType();
|
---|
1059 | // boost::shared_ptr<Vector> MolCenter((*Runner)->DetermineCenterOfGravity());
|
---|
1060 | // Position = (*atomiter)->getPosition() - *MolCenter;
|
---|
1061 | // const unsigned char* color = NULL;
|
---|
1062 | // if ((World::getInstance().isSelected(*atomiter)) || (World::getInstance().isSelected((*Runner))))
|
---|
1063 | // color = SelectionColor;
|
---|
1064 | // else
|
---|
1065 | // color = ptr->getColor();
|
---|
1066 | // makeSphere(Position, ptr->getVanDerWaalsRadius()*0.25, color);
|
---|
1067 | //
|
---|
1068 | // // create bonds
|
---|
1069 | // const BondList &bonds = (*atomiter)->getListOfBonds();
|
---|
1070 | // for (BondList::const_iterator bonditer = bonds.begin();
|
---|
1071 | // bonditer != bonds.end();
|
---|
1072 | // ++bonditer) {
|
---|
1073 | // if ((*bonditer)->leftatom->getId() == (*atomiter)->getId()) {
|
---|
1074 | // Position = (*bonditer)->leftatom->getPosition() - *MolCenter;
|
---|
1075 | // OtherPosition = (*bonditer)->rightatom->getPosition() - *MolCenter;
|
---|
1076 | // const double distance = sqrt(Position.DistanceSquared(OtherPosition))/2.;
|
---|
1077 | // const unsigned char *color1 = (*bonditer)->leftatom->getType()->getColor();
|
---|
1078 | // const unsigned char *color2 = (*bonditer)->rightatom->getType()->getColor();
|
---|
1079 | // makeCylinder(Position, OtherPosition, 0.1, distance, color1);
|
---|
1080 | // makeCylinder(OtherPosition, Position, 0.1, distance, color2);
|
---|
1081 | // }
|
---|
1082 | // }
|
---|
1083 | // }
|
---|
1084 | // }
|
---|
1085 | // } else {
|
---|
1086 | // makeSphere( x,1, white);
|
---|
1087 | // }
|
---|
1088 | // glEndList();
|
---|
1089 | //}
|
---|
1090 | //
|
---|
1091 | //
|
---|
1092 | ///* ================================== SLOTS ============================== */
|
---|
1093 | //
|
---|
1094 | ///** Initializes some public variables.
|
---|
1095 | // * \param *ptr pointer to QLabel statusbar
|
---|
1096 | // */
|
---|
1097 | //void GLMoleculeView::init(QLabel *ptr)
|
---|
1098 | //{
|
---|
1099 | // StatusBar = ptr;
|
---|
1100 | //}
|
---|
1101 | //
|
---|
1102 | ///** Initializes the viewport statusbar.
|
---|
1103 | // * \param *ptr pointer to QLabel for showing view pointcoordinates.
|
---|
1104 | // */
|
---|
1105 | //void GLMoleculeView::initCoordinates(QLabel *ptr)
|
---|
1106 | //{
|
---|
1107 | // CoordinatesBar = ptr;
|
---|
1108 | //}
|
---|
1109 | //
|
---|
1110 | ///** Slot to be called when to initialize GLMoleculeView::MolData.
|
---|
1111 | // */
|
---|
1112 | //void GLMoleculeView::createView( )
|
---|
1113 | //{
|
---|
1114 | // initializeGL();
|
---|
1115 | // updateGL();
|
---|
1116 | //}
|
---|
1117 | //
|
---|
1118 | ///** Slot of window is resized.
|
---|
1119 | // * Copies new width and height to GLMoleculeView::width and GLMoleculeView::height and calls updateGL().
|
---|
1120 | // * \param w new width of window
|
---|
1121 | // * \param h new height of window
|
---|
1122 | // */
|
---|
1123 | //void GLMoleculeView::resizeGL( int w, int h )
|
---|
1124 | //{
|
---|
1125 | // width = w;
|
---|
1126 | // height = h;
|
---|
1127 | // updateGL();
|
---|
1128 | //}
|
---|
1129 | //
|
---|
1130 | ///** Sets x rotation angle.
|
---|
1131 | // * sets GLMoleculeView::xRot and calls updateGL().
|
---|
1132 | // * \param degrees new rotation angle in degrees
|
---|
1133 | // */
|
---|
1134 | //void GLMoleculeView::setXRotation( int degrees )
|
---|
1135 | //{
|
---|
1136 | // xRot = (GLfloat)(degrees % 360);
|
---|
1137 | // updateGL();
|
---|
1138 | //}
|
---|
1139 | //
|
---|
1140 | //
|
---|
1141 | ///** Sets y rotation angle.
|
---|
1142 | // * sets GLMoleculeView::yRot and calls updateGL().
|
---|
1143 | // * \param degrees new rotation angle in degrees
|
---|
1144 | // */
|
---|
1145 | //void GLMoleculeView::setYRotation( int degrees )
|
---|
1146 | //{
|
---|
1147 | // yRot = (GLfloat)(degrees % 360);
|
---|
1148 | // updateGL();
|
---|
1149 | //}
|
---|
1150 | //
|
---|
1151 | //
|
---|
1152 | ///** Sets z rotation angle.
|
---|
1153 | // * sets GLMoleculeView::zRot and calls updateGL().
|
---|
1154 | // * \param degrees new rotation angle in degrees
|
---|
1155 | // */
|
---|
1156 | //void GLMoleculeView::setZRotation( int degrees )
|
---|
1157 | //{
|
---|
1158 | // zRot = (GLfloat)(degrees % 360);
|
---|
1159 | // updateGL();
|
---|
1160 | //}
|
---|
1161 | //
|
---|
1162 | ///** Sets the scale of the scene.
|
---|
1163 | // * sets GLMoleculeView::scale and calls updateGL().
|
---|
1164 | // * \param distance distance divided by 100 is the new scale
|
---|
1165 | // */
|
---|
1166 | //void GLMoleculeView::setScale( int distance )
|
---|
1167 | //{
|
---|
1168 | // scale = (GLfloat)(distance / 100.);
|
---|
1169 | // updateGL();
|
---|
1170 | //}
|
---|
1171 | //
|
---|
1172 | ///** Update the ambient light.
|
---|
1173 | // * \param light[4] light strength per axis and position (w)
|
---|
1174 | // */
|
---|
1175 | //void GLMoleculeView::setLightAmbient( int *light )
|
---|
1176 | //{
|
---|
1177 | // for(int i=0;i<4;i++)
|
---|
1178 | // LightAmbient[i] = light[i];
|
---|
1179 | // updateGL();
|
---|
1180 | //}
|
---|
1181 | //
|
---|
1182 | ///** Update the diffuse light.
|
---|
1183 | // * \param light[4] light strength per axis and position (w)
|
---|
1184 | // */
|
---|
1185 | //void GLMoleculeView::setLightDiffuse( int *light )
|
---|
1186 | //{
|
---|
1187 | // for(int i=0;i<4;i++)
|
---|
1188 | // LightDiffuse[i] = light[i];
|
---|
1189 | // updateGL();
|
---|
1190 | //}
|
---|
1191 | //
|
---|
1192 | ///** Update the position of light.
|
---|
1193 | // * \param light[4] light strength per axis and position (w)
|
---|
1194 | // */
|
---|
1195 | //void GLMoleculeView::setLightPosition( int *light )
|
---|
1196 | //{
|
---|
1197 | // for(int i=0;i<4;i++)
|
---|
1198 | // LightPosition[i] = light[i];
|
---|
1199 | // updateGL();
|
---|
1200 | //}
|
---|
1201 | //
|
---|
1202 | ///** Toggles the boolean GLMoleculeView::MultiViewEnabled.
|
---|
1203 | // * Flips the boolean and calls updateGL().
|
---|
1204 | // */
|
---|
1205 | //void GLMoleculeView::toggleMultiViewEnabled ( )
|
---|
1206 | //{
|
---|
1207 | // MultiViewEnabled = !MultiViewEnabled;
|
---|
1208 | // cout << "Setting MultiView to " << MultiViewEnabled << "." << endl;
|
---|
1209 | // updateGL();
|
---|
1210 | //}
|
---|
1211 | //
|
---|
1212 | ///** Launch a dialog to configure the lights.
|
---|
1213 | // */
|
---|
1214 | //void GLMoleculeView::createDialogLight()
|
---|
1215 | //{
|
---|
1216 | //// Ui_DialogLight *Lights = new Ui_DialogLight();
|
---|
1217 | //// if (Lights == NULL)
|
---|
1218 | //// return;
|
---|
1219 | //// // Set up the dynamic dialog here
|
---|
1220 | //// QLineEdit *Field = NULL;
|
---|
1221 | //// Field = Lights->findChild<QLineEdit *>("LightPositionX");
|
---|
1222 | //// if (Field) Field->setText( QString("%1").arg(LightPosition[0]) );
|
---|
1223 | //// Field = Lights->findChild<QLineEdit *>("LightPositionY");
|
---|
1224 | //// if (Field) Field->setText( QString("%1").arg(LightPosition[1]) );
|
---|
1225 | //// Field = Lights->findChild<QLineEdit *>("LightPositionZ");
|
---|
1226 | //// if (Field) Field->setText( QString("%1").arg(LightPosition[2]) );
|
---|
1227 | //// Field = Lights->findChild<QLineEdit *>("LightPositionW");
|
---|
1228 | //// if (Field) Field->setText( QString("%1").arg(LightPosition[3]) );
|
---|
1229 | ////
|
---|
1230 | //// Field = Lights->findChild<QLineEdit *>("LightDiffuseX");
|
---|
1231 | //// if (Field) Field->setText( QString("%1").arg(LightDiffuse[0]) );
|
---|
1232 | //// Field = Lights->findChild<QLineEdit *>("LightDiffuseY");
|
---|
1233 | //// if (Field) Field->setText( QString("%1").arg(LightDiffuse[1]) );
|
---|
1234 | //// Field = Lights->findChild<QLineEdit *>("LightDiffuseZ");
|
---|
1235 | //// if (Field) Field->setText( QString("%1").arg(LightDiffuse[2]) );
|
---|
1236 | //// Field = Lights->findChild<QLineEdit *>("LightDiffuseW");
|
---|
1237 | //// if (Field) Field->setText( QString("%1").arg(LightDiffuse[3]) );
|
---|
1238 | ////
|
---|
1239 | //// Field = Lights->findChild<QLineEdit *>("LightAmbientX");
|
---|
1240 | //// if (Field) Field->setText( QString("%1").arg(LightAmbient[0]) );
|
---|
1241 | //// Field = Lights->findChild<QLineEdit *>("LightAmbientY");
|
---|
1242 | //// if (Field) Field->setText( QString("%1").arg(LightAmbient[1]) );
|
---|
1243 | //// Field = Lights->findChild<QLineEdit *>("LightAmbientZ");
|
---|
1244 | //// if (Field) Field->setText( QString("%1").arg(LightAmbient[2]) );
|
---|
1245 | //// Field = Lights->findChild<QLineEdit *>("LightAmbientW");
|
---|
1246 | //// if (Field) Field->setText( QString("%1").arg(LightAmbient[3]) );
|
---|
1247 | ////
|
---|
1248 | //// if ( Lights->exec() ) {
|
---|
1249 | //// //cout << "User accepted.\n";
|
---|
1250 | //// // The user accepted, act accordingly
|
---|
1251 | //// Field = Lights->findChild<QLineEdit *>("LightPositionX");
|
---|
1252 | //// if (Field) LightPosition[0] = Field->text().toDouble();
|
---|
1253 | //// Field = Lights->findChild<QLineEdit *>("LightPositionY");
|
---|
1254 | //// if (Field) LightPosition[1] = Field->text().toDouble();
|
---|
1255 | //// Field = Lights->findChild<QLineEdit *>("LightPositionZ");
|
---|
1256 | //// if (Field) LightPosition[2] = Field->text().toDouble();
|
---|
1257 | //// Field = Lights->findChild<QLineEdit *>("LightPositionW");
|
---|
1258 | //// if (Field) LightPosition[3] = Field->text().toDouble();
|
---|
1259 | ////
|
---|
1260 | //// Field = Lights->findChild<QLineEdit *>("LightDiffuseX");
|
---|
1261 | //// if (Field) LightDiffuse[0] = Field->text().toDouble();
|
---|
1262 | //// Field = Lights->findChild<QLineEdit *>("LightDiffuseY");
|
---|
1263 | //// if (Field) LightDiffuse[1] = Field->text().toDouble();
|
---|
1264 | //// Field = Lights->findChild<QLineEdit *>("LightDiffuseZ");
|
---|
1265 | //// if (Field) LightDiffuse[2] = Field->text().toDouble();
|
---|
1266 | //// Field = Lights->findChild<QLineEdit *>("LightDiffuseW");
|
---|
1267 | //// if (Field) LightDiffuse[3] = Field->text().toDouble();
|
---|
1268 | ////
|
---|
1269 | //// Field = Lights->findChild<QLineEdit *>("LightAmbientX");
|
---|
1270 | //// if (Field) LightAmbient[0] = Field->text().toDouble();
|
---|
1271 | //// Field = Lights->findChild<QLineEdit *>("LightAmbientY");
|
---|
1272 | //// if (Field) LightAmbient[1] = Field->text().toDouble();
|
---|
1273 | //// Field = Lights->findChild<QLineEdit *>("LightAmbientZ");
|
---|
1274 | //// if (Field) LightAmbient[2] = Field->text().toDouble();
|
---|
1275 | //// Field = Lights->findChild<QLineEdit *>("LightAmbientW");
|
---|
1276 | //// if (Field) LightAmbient[3] = Field->text().toDouble();
|
---|
1277 | //// updateGL();
|
---|
1278 | //// } else {
|
---|
1279 | //// //cout << "User reclined.\n";
|
---|
1280 | //// }
|
---|
1281 | //// delete(Lights);
|
---|
1282 | //}
|
---|
1283 | //
|
---|
1284 | ///** Slot for event of pressed mouse button.
|
---|
1285 | // * Switch discerns between buttons and stores position of event in GLMoleculeView::LeftButtonPos,
|
---|
1286 | // * GLMoleculeView::MiddleButtonPos or GLMoleculeView::RightButtonPos.
|
---|
1287 | // * \param *event structure containing information of the event
|
---|
1288 | // */
|
---|
1289 | //void GLMoleculeView::mousePressEvent(QMouseEvent *event)
|
---|
1290 | //{
|
---|
1291 | // std::cout << "MousePressEvent." << endl;
|
---|
1292 | // QPoint *pos = NULL;
|
---|
1293 | // switch (event->button()) { // get the right array
|
---|
1294 | // case Qt::LeftButton:
|
---|
1295 | // pos = &LeftButtonPos;
|
---|
1296 | // std::cout << "Left Button" << endl;
|
---|
1297 | // break;
|
---|
1298 | // case Qt::MidButton:
|
---|
1299 | // pos = &MiddleButtonPos;
|
---|
1300 | // std::cout << "Middle Button" << endl;
|
---|
1301 | // break;
|
---|
1302 | // case Qt::RightButton:
|
---|
1303 | // pos = &RightButtonPos;
|
---|
1304 | // std::cout << "Right Button" << endl;
|
---|
1305 | // break;
|
---|
1306 | // default:
|
---|
1307 | // break;
|
---|
1308 | // }
|
---|
1309 | // if (pos) { // store the position
|
---|
1310 | // pos->setX(event->pos().x());
|
---|
1311 | // pos->setY(event->pos().y());
|
---|
1312 | // std::cout << "Stored src position is (" << pos->x() << "," << pos->y() << ")." << endl;
|
---|
1313 | // } else {
|
---|
1314 | // std::cout << "pos is NULL." << endl;
|
---|
1315 | // }
|
---|
1316 | //}
|
---|
1317 | //
|
---|
1318 | ///** Slot for event of pressed mouse button.
|
---|
1319 | // * Switch discerns between buttons:
|
---|
1320 | // * -# Left Button: Rotates the view of the GLMoleculeView, relative to GLMoleculeView::LeftButtonPos.
|
---|
1321 | // * -# Middle Button: nothing
|
---|
1322 | // * -# Right Button: Shifts the selected molecule or atom, relative to GLMoleculeView::RightButtonPos.
|
---|
1323 | // * \param *event structure containing information of the event
|
---|
1324 | // */
|
---|
1325 | //void GLMoleculeView::mouseReleaseEvent(QMouseEvent *event)
|
---|
1326 | //{
|
---|
1327 | // std::cout << "MouseReleaseEvent." << endl;
|
---|
1328 | // QPoint *srcpos = NULL;
|
---|
1329 | // QPoint destpos = event->pos();
|
---|
1330 | // int Width = (MultiViewEnabled) ? width/2 : width;
|
---|
1331 | // int Height = (MultiViewEnabled) ? height/2 : height;
|
---|
1332 | // std::cout << "Received dest position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
|
---|
1333 | // switch (event->button()) { // get the right array
|
---|
1334 | // case Qt::LeftButton: // LeftButton rotates the view
|
---|
1335 | // srcpos = &LeftButtonPos;
|
---|
1336 | // std::cout << "Left Button" << endl;
|
---|
1337 | // if (srcpos) { // subtract the position and act
|
---|
1338 | // std::cout << "Stored src position is (" << srcpos->x() << "," << srcpos->y() << ")." << endl;
|
---|
1339 | // destpos -= *srcpos;
|
---|
1340 | // std::cout << "Resulting diff position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
|
---|
1341 | // std::cout << "Width and Height are " << Width << "," << Height << "." << endl;
|
---|
1342 | //
|
---|
1343 | // int pos = (int)floor((double)srcpos->x()/(double)Width) + ((int)floor((double)srcpos->y()/(double)Height))*2;
|
---|
1344 | // if ((MultiViewEnabled) && (pos != 2)) { // means four regions, and we are in a shifting one
|
---|
1345 | // // switch between three regions
|
---|
1346 | // // decide into which of the four screens the initial click has been made
|
---|
1347 | // std::cout << "Position is " << pos << "." << endl;
|
---|
1348 | // switch(pos) {
|
---|
1349 | // case 0: // lower left = xz
|
---|
1350 | // position[0] += -destpos.y()/100.;
|
---|
1351 | // position[2] += destpos.x()/100.;
|
---|
1352 | // break;
|
---|
1353 | // case 1: // lower right = yz
|
---|
1354 | // position[1] += -destpos.y()/100.;
|
---|
1355 | // position[2] += -destpos.x()/100.;
|
---|
1356 | // break;
|
---|
1357 | // case 2: // upper left = projected
|
---|
1358 | // std::cout << "This is impossible: Shifting in the projected region, we should rotate!." << endl;
|
---|
1359 | // break;
|
---|
1360 | // case 3: // upper right = xy
|
---|
1361 | // position[0] += destpos.x()/100.;
|
---|
1362 | // position[1] += -destpos.y()/100.;
|
---|
1363 | // break;
|
---|
1364 | // default:
|
---|
1365 | // std::cout << "click was not in any of the four regions." << endl;
|
---|
1366 | // break;
|
---|
1367 | // }
|
---|
1368 | // updateGL();
|
---|
1369 | // } else { // we are in rotation region
|
---|
1370 | // QWidget *Parent = parentWidget();
|
---|
1371 | // QSlider *sliderX = Parent->findChild<QSlider *>("sliderX");
|
---|
1372 | // QSlider *sliderY = Parent->findChild<QSlider *>("sliderY");
|
---|
1373 | // std::cout << sliderX << " and " << sliderY << endl;
|
---|
1374 | // if (sliderX) {
|
---|
1375 | // int xrange = sliderX->maximum() - sliderX->minimum();
|
---|
1376 | // double xValue = ((destpos.x() + Width) % Width);
|
---|
1377 | // xValue *= (double)xrange/(double)Width;
|
---|
1378 | // xValue += sliderX->value();
|
---|
1379 | // int xvalue = (int) xValue % xrange;
|
---|
1380 | // std::cout << "Setting x to " << xvalue << " within range " << xrange << "." << endl;
|
---|
1381 | // setXRotation(xvalue);
|
---|
1382 | // sliderX->setValue(xvalue);
|
---|
1383 | // } else {
|
---|
1384 | // std::cout << "sliderX is NULL." << endl;
|
---|
1385 | // }
|
---|
1386 | // if (sliderY) {
|
---|
1387 | // int yrange = sliderY->maximum() - sliderY->minimum();
|
---|
1388 | // double yValue = ((destpos.y() + Height) % Height);
|
---|
1389 | // yValue *= (double)yrange/(double)Height;
|
---|
1390 | // yValue += sliderY->value();
|
---|
1391 | // int yvalue = (int) yValue % yrange;
|
---|
1392 | // std::cout << "Setting y to " << yvalue << " within range " << yrange << "." << endl;
|
---|
1393 | // setYRotation(yvalue);
|
---|
1394 | // sliderY->setValue(yvalue);
|
---|
1395 | // } else {
|
---|
1396 | // std::cout << "sliderY is NULL." << endl;
|
---|
1397 | // }
|
---|
1398 | // }
|
---|
1399 | // } else {
|
---|
1400 | // std::cout << "srcpos is NULL." << endl;
|
---|
1401 | // }
|
---|
1402 | // break;
|
---|
1403 | //
|
---|
1404 | // case Qt::MidButton: // MiddleButton has no function so far
|
---|
1405 | // srcpos = &MiddleButtonPos;
|
---|
1406 | // std::cout << "Middle Button" << endl;
|
---|
1407 | // if (srcpos) { // subtract the position and act
|
---|
1408 | // QWidget *Parent = parentWidget();
|
---|
1409 | // QSlider *sliderZ = Parent->findChild<QSlider *>("sliderZ");
|
---|
1410 | // QSlider *sliderScale = Parent->findChild<QSlider *>("sliderScale");
|
---|
1411 | // std::cout << sliderZ << " and " << sliderScale << endl;
|
---|
1412 | // std::cout << "Stored src position is (" << srcpos->x() << "," << srcpos->y() << ")." << endl;
|
---|
1413 | // destpos -= *srcpos;
|
---|
1414 | // std::cout << "Resulting diff position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
|
---|
1415 | // std::cout << "Width and Height are " << Width << "," << Height << "." << endl;
|
---|
1416 | // if (sliderZ) {
|
---|
1417 | // int xrange = sliderZ->maximum() - sliderZ->minimum();
|
---|
1418 | // double xValue = ((destpos.x() + Width) % Width);
|
---|
1419 | // xValue *= (double)xrange/(double)Width;
|
---|
1420 | // xValue += sliderZ->value();
|
---|
1421 | // int xvalue = (int) xValue % xrange;
|
---|
1422 | // std::cout << "Setting x to " << xvalue << " within range " << xrange << "." << endl;
|
---|
1423 | // setZRotation(xvalue);
|
---|
1424 | // sliderZ->setValue(xvalue);
|
---|
1425 | // } else {
|
---|
1426 | // std::cout << "sliderZ is NULL." << endl;
|
---|
1427 | // }
|
---|
1428 | // if (sliderScale) {
|
---|
1429 | // int yrange = sliderScale->maximum() - sliderScale->minimum();
|
---|
1430 | // double yValue = ((destpos.y() + Height) % Height);
|
---|
1431 | // yValue *= (double)yrange/(double)Height;
|
---|
1432 | // yValue += sliderScale->value();
|
---|
1433 | // int yvalue = (int) yValue % yrange;
|
---|
1434 | // std::cout << "Setting y to " << yvalue << " within range " << yrange << "." << endl;
|
---|
1435 | // setScale(yvalue);
|
---|
1436 | // sliderScale->setValue(yvalue);
|
---|
1437 | // } else {
|
---|
1438 | // std::cout << "sliderScale is NULL." << endl;
|
---|
1439 | // }
|
---|
1440 | // } else {
|
---|
1441 | // std::cout << "srcpos is NULL." << endl;
|
---|
1442 | // }
|
---|
1443 | // break;
|
---|
1444 | // break;
|
---|
1445 | //
|
---|
1446 | // case Qt::RightButton: // RightButton moves eitstdher the selected molecule or atom
|
---|
1447 | // srcpos = &RightButtonPos;
|
---|
1448 | // std::cout << "Right Button" << endl;
|
---|
1449 | // if (srcpos) { // subtract the position and act
|
---|
1450 | // std::cout << "Stored src position is (" << srcpos->x() << "," << srcpos->y() << ")." << endl;
|
---|
1451 | // destpos -= *srcpos;
|
---|
1452 | // std::cout << "Resulting diff position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
|
---|
1453 | // std::cout << "Width and Height are " << Width << "," << Height << "." << endl;
|
---|
1454 | // if (MultiViewEnabled) {
|
---|
1455 | // // which vector to change
|
---|
1456 | // Vector SelectedPosition;
|
---|
1457 | // const std::vector<atom*> &SelectedAtoms = World::getInstance().getSelectedAtoms();
|
---|
1458 | // const std::vector<molecule*> &SelectedMolecules = World::getInstance().getSelectedMolecules();
|
---|
1459 | // if (SelectedMolecules.size()) {
|
---|
1460 | // if (SelectedAtoms.size())
|
---|
1461 | // SelectedPosition = (*SelectedAtoms.begin())->getPosition();
|
---|
1462 | // else
|
---|
1463 | // SelectedPosition = (*(*SelectedMolecules.begin())->begin())->getPosition();
|
---|
1464 | // }
|
---|
1465 | // // decide into which of the four screens the initial click has been made
|
---|
1466 | // int pos = (int)floor((double)srcpos->x()/(double)Width) + ((int)floor((double)srcpos->y()/(double)Height))*2;
|
---|
1467 | // if (!SelectedPosition.IsZero()) {
|
---|
1468 | // std::cout << "Position is " << pos << "." << endl;
|
---|
1469 | // switch(pos) {
|
---|
1470 | // case 0: // lower left = xz
|
---|
1471 | // SelectedPosition[0] += -destpos.y()/100.;
|
---|
1472 | // SelectedPosition[2] += destpos.x()/100.;
|
---|
1473 | // break;
|
---|
1474 | // case 1: // lower right = yz
|
---|
1475 | // SelectedPosition[1] += -destpos.y()/100.;
|
---|
1476 | // SelectedPosition[2] += -destpos.x()/100.;
|
---|
1477 | // break;
|
---|
1478 | // case 2: // upper left = projected
|
---|
1479 | // SelectedPosition[0] += destpos.x()/100.;
|
---|
1480 | // SelectedPosition[1] += destpos.y()/100.;
|
---|
1481 | // SelectedPosition[2] += destpos.y()/100.;
|
---|
1482 | // break;
|
---|
1483 | // case 3: // upper right = xy
|
---|
1484 | // SelectedPosition[0] += destpos.x()/100.;
|
---|
1485 | // SelectedPosition[1] += -destpos.y()/100.;
|
---|
1486 | // break;
|
---|
1487 | // default:
|
---|
1488 | // std::cout << "click was not in any of the four regions." << endl;
|
---|
1489 | // break;
|
---|
1490 | // }
|
---|
1491 | // } else {
|
---|
1492 | // std::cout << "Nothing selected." << endl;
|
---|
1493 | // }
|
---|
1494 | // // update Tables
|
---|
1495 | // if (SelectedMolecules.size()) {
|
---|
1496 | // isSignaller = true;
|
---|
1497 | // if (SelectedAtoms.size())
|
---|
1498 | // emit notifyAtomChanged( (*SelectedMolecules.begin()), (*SelectedAtoms.begin()), AtomPosition);
|
---|
1499 | // else
|
---|
1500 | // emit notifyMoleculeChanged( (*SelectedMolecules.begin()), MoleculePosition );
|
---|
1501 | // }
|
---|
1502 | // // update graphic
|
---|
1503 | // initializeGL();
|
---|
1504 | // updateGL();
|
---|
1505 | // } else {
|
---|
1506 | // cout << "MultiView is not enabled." << endl;
|
---|
1507 | // }
|
---|
1508 | // } else {
|
---|
1509 | // cout << "srcpos is NULL." << endl;
|
---|
1510 | // }
|
---|
1511 | // break;
|
---|
1512 | //
|
---|
1513 | // default:
|
---|
1514 | // break;
|
---|
1515 | // }
|
---|
1516 | //}
|
---|
1517 | //
|
---|
1518 | ///* ======================================== SLOTS ================================ */
|
---|
1519 | //
|
---|
1520 | ///** Hear announcement of selected molecule.
|
---|
1521 | // * \param *mol pointer to selected molecule
|
---|
1522 | // */
|
---|
1523 | //void GLMoleculeView::hearMoleculeSelected(molecule *mol)
|
---|
1524 | //{
|
---|
1525 | // if (isSignaller) { // if we emitted the signal, return
|
---|
1526 | // isSignaller = false;
|
---|
1527 | // return;
|
---|
1528 | // }
|
---|
1529 | // initializeGL();
|
---|
1530 | // updateGL();
|
---|
1531 | //};
|
---|
1532 | //
|
---|
1533 | ///** Hear announcement of selected atom.
|
---|
1534 | // * \param *mol pointer to molecule containing atom
|
---|
1535 | // * \param *Walker pointer to selected atom
|
---|
1536 | // */
|
---|
1537 | //void GLMoleculeView::hearAtomSelected(molecule *mol, atom *Walker)
|
---|
1538 | //{
|
---|
1539 | // if (isSignaller) { // if we emitted the signal, return
|
---|
1540 | // isSignaller = false;
|
---|
1541 | // return;
|
---|
1542 | // }
|
---|
1543 | // initializeGL();
|
---|
1544 | // updateGL();
|
---|
1545 | //};
|
---|
1546 | //
|
---|
1547 | ///** Hear announcement of changed molecule.
|
---|
1548 | // * \param *mol pointer to changed molecule
|
---|
1549 | // * \param type of change
|
---|
1550 | // */
|
---|
1551 | //void GLMoleculeView::hearMoleculeChanged(molecule *mol, enum ChangesinMolecule type)
|
---|
1552 | //{
|
---|
1553 | // if (isSignaller) { // if we emitted the signal, return
|
---|
1554 | // isSignaller = false;
|
---|
1555 | // return;
|
---|
1556 | // }
|
---|
1557 | // initializeGL();
|
---|
1558 | // updateGL();
|
---|
1559 | //};
|
---|
1560 | //
|
---|
1561 | ///** Hear announcement of changed atom.
|
---|
1562 | // * \param *mol pointer to molecule containing atom
|
---|
1563 | // * \param *Walker pointer to changed atom
|
---|
1564 | // * \param type type of change
|
---|
1565 | // */
|
---|
1566 | //void GLMoleculeView::hearAtomChanged(molecule *mol, atom *Walker, enum ChangesinAtom type)
|
---|
1567 | //{
|
---|
1568 | // if (isSignaller) { // if we emitted the signal, return
|
---|
1569 | // isSignaller = false;
|
---|
1570 | // return;
|
---|
1571 | // }
|
---|
1572 | // initializeGL();
|
---|
1573 | // updateGL();
|
---|
1574 | //};
|
---|
1575 | //
|
---|
1576 | ///** Hear announcement of changed element.
|
---|
1577 | // * \param *Runner pointer to changed element
|
---|
1578 | // * \param type of change
|
---|
1579 | // */
|
---|
1580 | //void GLMoleculeView::hearElementChanged(element *Runner, enum ChangesinElement type)
|
---|
1581 | //{
|
---|
1582 | // if (isSignaller) { // if we emitted the signal, return
|
---|
1583 | // isSignaller = false;
|
---|
1584 | // return;
|
---|
1585 | // }
|
---|
1586 | // switch(type) {
|
---|
1587 | // default:
|
---|
1588 | // case ElementName:
|
---|
1589 | // case ElementSymbol:
|
---|
1590 | // case ElementMass:
|
---|
1591 | // case ElementValence:
|
---|
1592 | // case ElementZ:
|
---|
1593 | // break;
|
---|
1594 | // case ElementCovalent:
|
---|
1595 | // case ElementVanderWaals:
|
---|
1596 | // initializeGL();
|
---|
1597 | // updateGL();
|
---|
1598 | // break;
|
---|
1599 | // }
|
---|
1600 | //};
|
---|
1601 | //
|
---|
1602 | ///** Hear announcement of added molecule.
|
---|
1603 | // * \param *mol pointer to added molecule
|
---|
1604 | // */
|
---|
1605 | //void GLMoleculeView::hearMoleculeAdded(molecule *mol)
|
---|
1606 | //{
|
---|
1607 | // if (isSignaller) { // if we emitted the signal, return
|
---|
1608 | // isSignaller = false;
|
---|
1609 | // return;
|
---|
1610 | // }
|
---|
1611 | // initializeGL();
|
---|
1612 | // updateGL();
|
---|
1613 | //};
|
---|
1614 | //
|
---|
1615 | ///** Hear announcement of added atom.
|
---|
1616 | // * \param *mol pointer to molecule containing atom
|
---|
1617 | // * \param *Walker pointer to added atom
|
---|
1618 | // */
|
---|
1619 | //void GLMoleculeView::hearAtomAdded(molecule *mol, atom *Walker)
|
---|
1620 | //{
|
---|
1621 | // if (isSignaller) { // if we emitted the signal, return
|
---|
1622 | // isSignaller = false;
|
---|
1623 | // return;
|
---|
1624 | // }
|
---|
1625 | // initializeGL();
|
---|
1626 | // updateGL();
|
---|
1627 | //};
|
---|
1628 | //
|
---|
1629 | ///** Hear announcement of removed molecule.
|
---|
1630 | // * \param *mol pointer to removed molecule
|
---|
1631 | // */
|
---|
1632 | //void GLMoleculeView::hearMoleculeRemoved(molecule *mol)
|
---|
1633 | //{
|
---|
1634 | // if (isSignaller) { // if we emitted the signal, return
|
---|
1635 | // isSignaller = false;
|
---|
1636 | // return;
|
---|
1637 | // }
|
---|
1638 | // initializeGL();
|
---|
1639 | // updateGL();
|
---|
1640 | //};
|
---|
1641 | //
|
---|
1642 | ///** Hear announcement of removed atom.
|
---|
1643 | // * \param *mol pointer to molecule containing atom
|
---|
1644 | // * \param *Walker pointer to removed atom
|
---|
1645 | // */
|
---|
1646 | //void GLMoleculeView::hearAtomRemoved(molecule *mol, atom *Walker)
|
---|
1647 | //{
|
---|
1648 | // if (isSignaller) { // if we emitted the signal, return
|
---|
1649 | // isSignaller = false;
|
---|
1650 | // return;
|
---|
1651 | // }
|
---|
1652 | // initializeGL();
|
---|
1653 | // updateGL();
|
---|
1654 | //};
|
---|
1655 | //
|
---|
1656 | //void GLMoleculeView::update(Observable *publisher)
|
---|
1657 | //{
|
---|
1658 | // initializeGL();
|
---|
1659 | // updateGL();
|
---|
1660 | //}
|
---|
1661 | //
|
---|
1662 | ///**
|
---|
1663 | // * This method is called when a special named change
|
---|
1664 | // * of the Observable occured
|
---|
1665 | // */
|
---|
1666 | //void GLMoleculeView::recieveNotification(Observable *publisher, Notification_ptr notification)
|
---|
1667 | //{
|
---|
1668 | // initializeGL();
|
---|
1669 | // updateGL();
|
---|
1670 | //}
|
---|
1671 | //
|
---|
1672 | ///**
|
---|
1673 | // * This method is called when the observed object is destroyed.
|
---|
1674 | // */
|
---|
1675 | //void GLMoleculeView::subjectKilled(Observable *publisher)
|
---|
1676 | //{
|
---|
1677 | //
|
---|
1678 | //}
|
---|
1679 | //
|
---|
1680 | //
|
---|
1681 | //// new stuff
|
---|
1682 | //
|
---|
1683 | ///** Returns the ref to the Material for element No \a from the map.
|
---|
1684 | // *
|
---|
1685 | // * \note We create a new one if the element is missing.
|
---|
1686 | // *
|
---|
1687 | // * @param no element no
|
---|
1688 | // * @return ref to QGLMaterial
|
---|
1689 | // */
|
---|
1690 | //QGLMaterial* GLMoleculeView::getMaterial(size_t no)
|
---|
1691 | //{
|
---|
1692 | // if (ElementNoMaterialMap.find(no) != ElementNoMaterialMap.end()){
|
---|
1693 | // // get present one
|
---|
1694 | //
|
---|
1695 | // } else {
|
---|
1696 | // ASSERT( (no >= 0) && (no < MAX_ELEMENTS),
|
---|
1697 | // "GLMoleculeView::getMaterial() - Element no "+toString(no)+" is invalid.");
|
---|
1698 | // // create new one
|
---|
1699 | // LOG(1, "Creating new material for element "+toString(no)+".");
|
---|
1700 | // QGLMaterial *newmaterial = new QGLMaterial(this);
|
---|
1701 | // periodentafel *periode = World::getInstance().getPeriode();
|
---|
1702 | // element *desiredelement = periode->FindElement(no);
|
---|
1703 | // ASSERT(desiredelement != NULL,
|
---|
1704 | // "GLMoleculeView::getMaterial() - desired element "+toString(no)+" not present in periodentafel.");
|
---|
1705 | // const unsigned char* color = desiredelement->getColor();
|
---|
1706 | // newmaterial->setAmbientColor( QColor(color[0], color[1], color[2]) );
|
---|
1707 | // newmaterial->setSpecularColor( QColor(60, 60, 60) );
|
---|
1708 | // newmaterial->setShininess( QColor(128) );
|
---|
1709 | // ElementNoMaterialMap.insert( no, newmaterial);
|
---|
1710 | // }
|
---|
1711 | //}
|
---|
1712 | //
|
---|
1713 | //QGLSceneNode* GLMoleculeView::getAtom(size_t no)
|
---|
1714 | //{
|
---|
1715 | // // first some sensibility checks
|
---|
1716 | // ASSERT(World::getInstance().getAtom(AtomById(no)) != NULL,
|
---|
1717 | // "GLMoleculeView::getAtom() - desired atom "
|
---|
1718 | // +toString(no)+" not present in the World.");
|
---|
1719 | // ASSERT(AtomsinSceneMap.find(no) != AtomsinSceneMap.end(),
|
---|
1720 | // "GLMoleculeView::getAtom() - desired atom "
|
---|
1721 | // +toString(no)+" not present in the AtomsinSceneMap.");
|
---|
1722 | //
|
---|
1723 | // return AtomsinSceneMap[no];
|
---|
1724 | //}
|
---|
1725 | //
|
---|
1726 | //QGLSceneNode* GLMoleculeView::getBond(size_t leftno, size_t rightno)
|
---|
1727 | //{
|
---|
1728 | // // first some sensibility checks
|
---|
1729 | // ASSERT(World::getInstance().getAtom(AtomById(leftno)) != NULL,
|
---|
1730 | // "GLMoleculeView::getAtom() - desired atom "
|
---|
1731 | // +toString(leftno)+" of bond not present in the World.");
|
---|
1732 | // ASSERT(World::getInstance().getAtom(AtomById(rightno)) != NULL,
|
---|
1733 | // "GLMoleculeView::getAtom() - desired atom "
|
---|
1734 | // +toString(rightno)+" of bond not present in the World.");
|
---|
1735 | // ASSERT(AtomsinSceneMap.find(leftno) != AtomsinSceneMap.end(),
|
---|
1736 | // "GLMoleculeView::getAtom() - desired atom "
|
---|
1737 | // +toString(leftno)+" of bond not present in the AtomsinSceneMap.");
|
---|
1738 | // ASSERT(AtomsinSceneMap.find(rightno) != AtomsinSceneMap.end(),
|
---|
1739 | // "GLMoleculeView::getAtom() - desired atom "
|
---|
1740 | // +toString(rightno)+" of bond not present in the AtomsinSceneMap.");
|
---|
1741 | // ASSERT(leftno == rightno,
|
---|
1742 | // "GLMoleculeView::getAtom() - bond must not be between the same atom: "
|
---|
1743 | // +toString(leftno)+" == "+toString(rightno)+".");
|
---|
1744 | //
|
---|
1745 | // // then return with smaller index first
|
---|
1746 | // if (leftno > rightno)
|
---|
1747 | // return AtomsinSceneMap[ make_pair(rightno, leftno) ];
|
---|
1748 | // else
|
---|
1749 | // return AtomsinSceneMap[ make_pair(leftno, rightno) ];
|
---|
1750 | //}
|
---|
1751 | //
|
---|