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