source: src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp@ e13b34

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since e13b34 was e13b34, checked in by Michael Ankele <ankele@…>, 13 years ago

GLWorldView: add (dummy) cameraControlMode

  • Property mode set to 100644
File size: 42.3 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * GLWorldView.cpp
10 *
11 * Created on: Aug 1, 2010
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "GLWorldView.hpp"
21
22#include <Qt/qevent.h>
23
24#include "GLWorldScene.hpp"
25
26#include "CodePatterns/MemDebug.hpp"
27
28#include "Atom/AtomObserver.hpp"
29#include "Atom/atom_observable.hpp"
30#include "CodePatterns/Log.hpp"
31#include "CodePatterns/Observer/Notification.hpp"
32#include "World.hpp"
33
34GLWorldView::GLWorldView(QWidget *parent)
35 : QGLView(parent), Observer("GLWorldView"), worldscene(NULL), changesPresent(false)
36{
37 worldscene = new GLWorldScene(this);
38
39 setOption(QGLView::ObjectPicking, true);
40
41 connect(worldscene, SIGNAL(changeOccured()), this, SLOT(changeSignalled()));
42 connect(worldscene, SIGNAL(changed()), this, SIGNAL(changed()));
43 connect(this, SIGNAL(atomInserted(const atom *)), worldscene, SLOT(atomInserted(const atom *)));
44 connect(this, SIGNAL(atomRemoved(const atom *)), worldscene, SLOT(atomRemoved(const atom *)));
45 connect(this, SIGNAL(worldSelectionChanged()), worldscene, SLOT(worldSelectionChanged()));
46 connect(this, SIGNAL(moleculeRemoved(const molecule *)), worldscene, SLOT(moleculeRemoved(const molecule *)));
47 connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
48
49 // sign on to changes in the world
50 World::getInstance().signOn(this);
51 World::getInstance().signOn(this, World::AtomInserted);
52 World::getInstance().signOn(this, World::AtomRemoved);
53 World::getInstance().signOn(this, World::MoleculeInserted);
54 World::getInstance().signOn(this, World::MoleculeRemoved);
55 World::getInstance().signOn(this, World::SelectionChanged);
56 AtomObserver::getInstance().signOn(this, AtomObservable::PositionChanged);
57}
58
59GLWorldView::~GLWorldView()
60{
61 World::getInstance().signOff(this);
62 World::getInstance().signOff(this, World::AtomInserted);
63 World::getInstance().signOff(this, World::AtomRemoved);
64 World::getInstance().signOff(this, World::MoleculeInserted);
65 World::getInstance().signOff(this, World::MoleculeRemoved);
66 World::getInstance().signOff(this, World::SelectionChanged);
67 AtomObserver::getInstance().signOff(this, AtomObservable::PositionChanged);
68 delete worldscene;
69}
70
71/**
72 * Update operation which can be invoked by the observable (which should be the
73 * change tracker here).
74 */
75void GLWorldView::update(Observable *publisher)
76{
77 emit changed();
78}
79
80/**
81 * The observable can tell when it dies.
82 */
83void GLWorldView::subjectKilled(Observable *publisher) {}
84
85/** Listen to specific changes to the world.
86 *
87 * @param publisher ref to observable.
88 * @param notification type of notification
89 */
90void GLWorldView::recieveNotification(Observable *publisher, Notification_ptr notification)
91{
92 if (static_cast<World *>(publisher) == World::getPointer()) {
93 switch (notification->getChannelNo()) {
94 case World::AtomInserted:
95 {
96 const atom *_atom = World::getInstance().lastChanged<atom>();
97 #ifdef LOG_OBSERVER
98 observerLog().addMessage() << "++ Observer " << observerLog().getName(this) << " received notification that atom "+toString(_atom->getId())+" has been inserted.";
99 #endif
100 emit atomInserted(_atom);
101 break;
102 }
103 case World::AtomRemoved:
104 {
105 const atom *_atom = World::getInstance().lastChanged<atom>();
106 #ifdef LOG_OBSERVER
107 observerLog().addMessage() << "++ Observer " << observerLog().getName(this) << " received notification that atom "+toString(_atom->getId())+" has been removed.";
108 #endif
109 emit atomRemoved(_atom);
110 break;
111 }
112 case World::SelectionChanged:
113 {
114 #ifdef LOG_OBSERVER
115 observerLog().addMessage() << "++ Observer " << observerLog().getName(this) << " received notification that selection has changed.";
116 #endif
117 emit worldSelectionChanged();
118 break;
119 }
120 case World::MoleculeInserted:
121 {
122 const molecule *_molecule = World::getInstance().lastChanged<molecule>();
123 #ifdef LOG_OBSERVER
124 observerLog().addMessage() << "++ Observer " << observerLog().getName(this) << " received notification that molecule "+toString(_molecule->getId())+" has been removed.";
125 #endif
126 emit moleculeInserted(_molecule);
127 break;
128 }
129 case World::MoleculeRemoved:
130 {
131 const molecule *_molecule = World::getInstance().lastChanged<molecule>();
132 #ifdef LOG_OBSERVER
133 observerLog().addMessage() << "++ Observer " << observerLog().getName(this) << " received notification that molecule "+toString(_molecule->getId())+" has been removed.";
134 #endif
135 emit moleculeRemoved(_molecule);
136 break;
137 }
138 default:
139 ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here.");
140 break;
141 }
142 } else if (dynamic_cast<AtomObservable *>(publisher) != NULL) {
143 switch (notification->getChannelNo()) {
144 case AtomObservable::PositionChanged:
145 {
146 const atom *_atom = dynamic_cast<const atom *>(publisher);
147 #ifdef LOG_OBSERVER
148 observerLog().addMessage() << "++ Observer " << observerLog().getName(this) << " received notification that atom "+toString(_atom->getId())+" has changed its position.";
149 #endif
150 emit changed();
151 break;
152 }
153 default:
154 ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here.");
155 break;
156 }
157 } else
158 ASSERT(0, "GLWorldView::recieveNotification() - received notification from unknown source.");
159}
160
161void GLWorldView::initializeGL(QGLPainter *painter)
162{
163 worldscene->initialize(this, painter);
164 changesPresent = false;
165}
166
167void GLWorldView::paintGL(QGLPainter *painter)
168{
169 if (changesPresent) {
170 initializeGL(painter);
171 changesPresent = false;
172 }
173 worldscene->draw(painter);
174}
175
176void GLWorldView::keyPressEvent(QKeyEvent *e)
177{
178 if (e->key() == Qt::Key_Tab) {
179 // The Tab key turns the ShowPicking option on and off,
180 // which helps show what the pick buffer looks like.
181 setOption(QGLView::ShowPicking, ((options() & QGLView::ShowPicking) == 0));
182 updateGL();
183 }
184 QGLView::keyPressEvent(e);
185}
186
187void GLWorldView::changeSignalled()
188{
189 changesPresent = true;
190}
191
192
193void GLWorldView::setCameraControlMode(GLWorldView::CameraControlModeType mode)
194{
195 cameraControlMode = mode;
196}
197
198void GLWorldView::setCameraControlModeRotation()
199{
200 setCameraControlMode(Rotate);
201}
202
203void GLWorldView::setCameraControlModeTranslation()
204{
205 setCameraControlMode(Translate);
206}
207
208GLWorldView::CameraControlModeType GLWorldView::getCameraControlMode(bool inverted)
209{
210 if (inverted){
211 if (cameraControlMode == Rotate)
212 return Translate;
213 if (cameraControlMode == Translate)
214 return Rotate;
215 return Rotate;
216 }else
217 return cameraControlMode;
218}
219
220void GLWorldView::fitCameraToDomain()
221{
222}
223
224//#include <GL/glu.h>
225//#include <QtGui/qslider.h>
226//#include <QtGui/qevent.h>
227//
228//#include "ui_dialoglight.h"
229//
230//#include "CodePatterns/MemDebug.hpp"
231//
232//#include <iostream>
233//#include <boost/shared_ptr.hpp>
234//
235//#include "LinearAlgebra/Line.hpp"
236//#include "Atom/atom.hpp"
237//#include "Bond/bond.hpp"
238//#include "Element/element.hpp"
239//#include "molecule.hpp"
240//#include "Element/periodentafel.hpp"
241//#include "World.hpp"
242//
243//#if defined(Q_CC_MSVC)
244//#pragma warning(disable:4305) // init: truncation from const double to float
245//#endif
246//
247//
248//GLMoleculeView::GLMoleculeView(QWidget *parent) :
249// QGLWidget(parent), Observer("GLMoleculeView"), X(Vector(1,0,0)), Y(Vector(0,1,0)), Z(Vector(0,0,1))
250//{
251// xRot = yRot = zRot = 0.0; // default object rotation
252// scale = 5.; // default object scale
253// object = 0;
254// LightPosition[0] = 0.0f;
255// LightPosition[1] = 2.0f;
256// LightPosition[2] = 2.0f;
257// LightPosition[3] = 0.0f;
258// LightDiffuse[0] = 0.5f;
259// LightDiffuse[1] = 0.5f;
260// LightDiffuse[2] = 0.5f;
261// LightDiffuse[3] = 0.0f;
262// LightAmbient[0] = 0.0f;
263// LightAmbient[1] = 0.0f;
264// LightAmbient[2] = 0.0f;
265// LightAmbient[3] = 0.0f;
266//
267// SelectionColor[0] = 0;
268// SelectionColor[1] = 128;
269// SelectionColor[2] = 128;
270//
271// MultiViewEnabled = true;
272//
273// isSignaller = false;
274//
275// World::getInstance().signOn(this);
276//}
277//
278///** Destructor of GLMoleculeView.
279// * Free's the CallList.
280// */
281//GLMoleculeView::~GLMoleculeView()
282//{
283// makeCurrent();
284// glDeleteLists( object, 1 );
285//
286// World::getInstance().signOff(this);
287//}
288//
289///** Paints the conents of the OpenGL window.
290// * Clears the GL buffers, enables lighting and depth.
291// * Window is either quartered (if GLMoleculeView::MultiViewEnabled) and xy, xz, yz planar views
292// * are added. Uses the CallList, constructed during InitializeGL().
293// */
294//void GLMoleculeView::paintGL()
295//{
296// Vector spot;
297//
298// glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
299// glShadeModel(GL_SMOOTH); // Enable Smooth Shading
300// glEnable(GL_LIGHTING); // Enable Light One
301// glEnable(GL_DEPTH_TEST); // Enables Depth Testing
302// glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
303// glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
304//
305// // 3d viewport
306// if (MultiViewEnabled)
307// glViewport( 0, 0, (GLint)width/2, (GLint)height/2 );
308// else
309// glViewport( 0, 0, (GLint)width, (GLint)height );
310// glMatrixMode( GL_PROJECTION );
311// glLoadIdentity();
312// glFrustum( -1.0, 1.0, -1.0, 1.0, 1.0, 50.0 );
313// glMatrixMode( GL_MODELVIEW );
314// glLoadIdentity();
315//
316// // calculate point of view and direction
317// glTranslated(position[0],position[1],position[2]);
318// glTranslated(0.0, 0.0, -scale);
319// glRotated(xRot, 1.0, 0.0, 0.0);
320// glRotated(yRot, 0.0, 1.0, 0.0);
321// glRotated(zRot, 0.0, 0.0, 1.0);
322//
323// // render scene
324// glCallList(object);
325//
326// // enable light
327// glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
328// glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
329// glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light
330// glEnable(GL_LIGHT1); // Enable Light One
331//
332// if (MultiViewEnabled) {
333// // xy view port
334// glViewport( (GLint)width/2, 0, (GLint)width/2, (GLint)height/2 );
335// glMatrixMode( GL_PROJECTION );
336// glLoadIdentity();
337// glScalef(1./scale, 1./scale,1./scale);
338// glOrtho(0, width/2, 0, height/2, 0,0);
339// glMatrixMode( GL_MODELVIEW );
340// glLoadIdentity();
341//
342// // calculate point of view and direction
343// view = position;
344// spot = Vector(0.,0.,scale);
345// top = Vector(0.,1.,0.);
346// gluLookAt(
347// spot[0], spot[1], spot[2],
348// view[0], view[1], view[2],
349// top[0], top[1], top[2]);
350//
351// // enable light
352// glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
353// glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
354// glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light
355// glEnable(GL_LIGHT1); // Enable Light One
356//
357// // render scene
358// glCallList(object);
359//
360// // xz viewport
361// glViewport( 0, (GLint)height/2, (GLint)width/2, (GLint)height/2 );
362// glMatrixMode( GL_PROJECTION );
363// glLoadIdentity();
364// glScalef(1./scale, 1./scale,1./scale);
365// glOrtho(0, width/2, 0, height/2, 0,0);
366// glMatrixMode( GL_MODELVIEW );
367// glLoadIdentity();
368//
369// // calculate point of view and direction
370// view = position;
371// spot = Vector(0.,scale,0.);
372// top = Vector(1.,0.,0.);
373// gluLookAt(
374// spot[0], spot[1], spot[2],
375// view[0], view[1], view[2],
376// top[0], top[1], top[2]);
377//
378// // enable light
379// glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
380// glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
381// glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light
382// glEnable(GL_LIGHT1); // Enable Light One
383//
384// // render scene
385// glCallList(object);
386//
387// //yz viewport
388// glViewport( (GLint)width/2, (GLint)height/2, (GLint)width/2, (GLint)height/2 );
389// glMatrixMode( GL_PROJECTION );
390// glLoadIdentity();
391// glScalef(1./scale, 1./scale,1./scale);
392// glOrtho(0, width/2, 0, height/2, 0,0);
393// glMatrixMode( GL_MODELVIEW );
394// glLoadIdentity();
395//
396// // calculate point of view and direction
397// view= position;
398// spot = Vector(scale,0.,0.);
399// top = Vector(0.,1.,0.);
400// gluLookAt(
401// spot[0], spot[1], spot[2],
402// view[0], view[1], view[2],
403// top[0], top[1], top[2]);
404//
405// // enable light
406// glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
407// glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
408// glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light
409// glEnable(GL_LIGHT1); // Enable Light One
410//
411// // render scene
412// glCallList(object);
413// }
414// //CoordinatesBar->setText( QString ("X: %1, Y: %2, Z: %3").arg(position[0]).arg(position[1]).arg(position[2]) );
415//}
416//
417////void polarView{GLdouble distance, GLdouble twist,
418//// GLdouble elevation, GLdouble azimuth)
419////{
420//// glTranslated(0.0, 0.0, -distance);
421//// glRotated(-twist, 0.0, 0.0, 1.0);
422//// glRotated(-elevation, 1.0, 0.0, 0.0);
423//// glRotated(azimuth, 0.0, 0.0, 1.0);
424////}
425//
426///** Make a sphere.
427// * \param x position
428// * \param radius radius
429// * \param color[3] color rgb values
430// */
431//void GLMoleculeView::makeSphere(const Vector &x, double radius, const unsigned char color[3])
432//{
433// 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
434// GLUquadricObj* q = gluNewQuadric ();
435// gluQuadricOrientation(q, GLU_OUTSIDE);
436//
437// std::cout << "Setting sphere at " << x << " with color r"
438// << (int)color[0] << ",g" << (int)color[1] << ",b" << (int)color[2] << "." << endl;
439//
440// glPushMatrix();
441// glTranslatef( x[0], x[1], x[2]);
442//// glRotatef( xRot, 1.0, 0.0, 0.0);
443//// glRotatef( yRot, 0.0, 1.0, 0.0);
444//// glRotatef( zRot, 0.0, 0.0, 1.0);
445// glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blueMaterial);
446// gluSphere (q, (GLdouble)radius, 10, 10);
447// glPopMatrix();
448//}
449//
450///** Make a cylinder.
451// * \param x origin
452// * \param y direction
453// * \param radius thickness
454// * \param height length
455// * \color[3] color rgb values
456// */
457//void GLMoleculeView::makeCylinder(const Vector &x, const Vector &y, double radius, double height, const unsigned char color[3])
458//{
459// float blueMaterial[] = { 255./(float)color[0], 255./(float)color[1], 255./(float)color[2], 1 };
460// GLUquadricObj* q = gluNewQuadric ();
461// gluQuadricOrientation(q, GLU_OUTSIDE);
462// Vector a,b;
463// Vector OtherAxis;
464// double alpha;
465// a = x - y;
466// // construct rotation axis
467// b = a;
468// b.VectorProduct(Z);
469// Line axis(zeroVec, b);
470// // calculate rotation angle
471// alpha = a.Angle(Z);
472// // construct other axis to check right-hand rule
473// OtherAxis = b;
474// OtherAxis.VectorProduct(Z);
475// // assure right-hand rule for the rotation
476// if (a.ScalarProduct(OtherAxis) < MYEPSILON)
477// alpha = M_PI-alpha;
478// // check
479// Vector a_rotated = axis.rotateVector(a, alpha);
480// std::cout << "Setting cylinder from "// << x << " to " << y
481// << a << " to " << a_rotated << " around " << b << " by " << alpha/M_PI*180. << ", respectively, "
482// << " with color r"
483// << (int)color[0] << ",g" << (int)color[1] << ",b" << (int)color[2] << "." << endl;
484//
485// glPushMatrix();
486// glTranslatef( x[0], x[1], x[2]);
487// glRotatef( alpha/M_PI*180., b[0], b[1], b[2]);
488// glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blueMaterial);
489// gluCylinder (q, (GLdouble)radius, (GLdouble)radius, (GLdouble)height, 10, 10);
490// glPopMatrix();
491//}
492//
493///** Defines the display CallList.
494// * Goes through all molecules and their atoms and adds spheres for atoms and cylinders
495// * for bonds. Heeds GLMoleculeView::SelectedAtom and GLMoleculeView::SelectedMolecule.
496// */
497//void GLMoleculeView::initializeGL()
498//{
499// double x[3] = {-1, 0, -10};
500// unsigned char white[3] = {255,255,255};
501// Vector Position, OtherPosition;
502// QSize window = size();
503// width = window.width();
504// height = window.height();
505// std::cout << "Setting width to " << width << " and height to " << height << std::endl;
506// GLfloat shininess[] = { 0.0 };
507// GLfloat specular[] = { 0, 0, 0, 1 };
508// glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Let OpenGL clear to black
509// object = glGenLists(1);
510// glNewList( object, GL_COMPILE );
511// glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
512// glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
513//
514// const std::vector<molecule*> &molecules = World::getInstance().getAllMolecules();
515//
516// if (molecules.size() > 0) {
517// for (std::vector<molecule*>::const_iterator Runner = molecules.begin();
518// Runner != molecules.end();
519// Runner++) {
520// for (molecule::const_iterator atomiter = (*Runner)->begin();
521// atomiter != (*Runner)->end();
522// ++atomiter) {
523// // create atom
524// const element *ptr = (*atomiter)->getType();
525// boost::shared_ptr<Vector> MolCenter((*Runner)->DetermineCenterOfGravity());
526// Position = (*atomiter)->getPosition() - *MolCenter;
527// const unsigned char* color = NULL;
528// if ((World::getInstance().isSelected(*atomiter)) || (World::getInstance().isSelected((*Runner))))
529// color = SelectionColor;
530// else
531// color = ptr->getColor();
532// makeSphere(Position, ptr->getVanDerWaalsRadius()*0.25, color);
533//
534// // create bonds
535// const BondList &bonds = (*atomiter)->getListOfBonds();
536// for (BondList::const_iterator bonditer = bonds.begin();
537// bonditer != bonds.end();
538// ++bonditer) {
539// if ((*bonditer)->leftatom->getId() == (*atomiter)->getId()) {
540// Position = (*bonditer)->leftatom->getPosition() - *MolCenter;
541// OtherPosition = (*bonditer)->rightatom->getPosition() - *MolCenter;
542// const double distance = sqrt(Position.DistanceSquared(OtherPosition))/2.;
543// const unsigned char *color1 = (*bonditer)->leftatom->getType()->getColor();
544// const unsigned char *color2 = (*bonditer)->rightatom->getType()->getColor();
545// makeCylinder(Position, OtherPosition, 0.1, distance, color1);
546// makeCylinder(OtherPosition, Position, 0.1, distance, color2);
547// }
548// }
549// }
550// }
551// } else {
552// makeSphere( x,1, white);
553// }
554// glEndList();
555//}
556//
557//
558///* ================================== SLOTS ============================== */
559//
560///** Initializes some public variables.
561// * \param *ptr pointer to QLabel statusbar
562// */
563//void GLMoleculeView::init(QLabel *ptr)
564//{
565// StatusBar = ptr;
566//}
567//
568///** Initializes the viewport statusbar.
569// * \param *ptr pointer to QLabel for showing view pointcoordinates.
570// */
571//void GLMoleculeView::initCoordinates(QLabel *ptr)
572//{
573// CoordinatesBar = ptr;
574//}
575//
576///** Slot to be called when to initialize GLMoleculeView::MolData.
577// */
578//void GLMoleculeView::createView( )
579//{
580// initializeGL();
581// updateGL();
582//}
583//
584///** Slot of window is resized.
585// * Copies new width and height to GLMoleculeView::width and GLMoleculeView::height and calls updateGL().
586// * \param w new width of window
587// * \param h new height of window
588// */
589//void GLMoleculeView::resizeGL( int w, int h )
590//{
591// width = w;
592// height = h;
593// updateGL();
594//}
595//
596///** Sets x rotation angle.
597// * sets GLMoleculeView::xRot and calls updateGL().
598// * \param degrees new rotation angle in degrees
599// */
600//void GLMoleculeView::setXRotation( int degrees )
601//{
602// xRot = (GLfloat)(degrees % 360);
603// updateGL();
604//}
605//
606//
607///** Sets y rotation angle.
608// * sets GLMoleculeView::yRot and calls updateGL().
609// * \param degrees new rotation angle in degrees
610// */
611//void GLMoleculeView::setYRotation( int degrees )
612//{
613// yRot = (GLfloat)(degrees % 360);
614// updateGL();
615//}
616//
617//
618///** Sets z rotation angle.
619// * sets GLMoleculeView::zRot and calls updateGL().
620// * \param degrees new rotation angle in degrees
621// */
622//void GLMoleculeView::setZRotation( int degrees )
623//{
624// zRot = (GLfloat)(degrees % 360);
625// updateGL();
626//}
627//
628///** Sets the scale of the scene.
629// * sets GLMoleculeView::scale and calls updateGL().
630// * \param distance distance divided by 100 is the new scale
631// */
632//void GLMoleculeView::setScale( int distance )
633//{
634// scale = (GLfloat)(distance / 100.);
635// updateGL();
636//}
637//
638///** Update the ambient light.
639// * \param light[4] light strength per axis and position (w)
640// */
641//void GLMoleculeView::setLightAmbient( int *light )
642//{
643// for(int i=0;i<4;i++)
644// LightAmbient[i] = light[i];
645// updateGL();
646//}
647//
648///** Update the diffuse light.
649// * \param light[4] light strength per axis and position (w)
650// */
651//void GLMoleculeView::setLightDiffuse( int *light )
652//{
653// for(int i=0;i<4;i++)
654// LightDiffuse[i] = light[i];
655// updateGL();
656//}
657//
658///** Update the position of light.
659// * \param light[4] light strength per axis and position (w)
660// */
661//void GLMoleculeView::setLightPosition( int *light )
662//{
663// for(int i=0;i<4;i++)
664// LightPosition[i] = light[i];
665// updateGL();
666//}
667//
668///** Toggles the boolean GLMoleculeView::MultiViewEnabled.
669// * Flips the boolean and calls updateGL().
670// */
671//void GLMoleculeView::toggleMultiViewEnabled ( )
672//{
673// MultiViewEnabled = !MultiViewEnabled;
674// cout << "Setting MultiView to " << MultiViewEnabled << "." << endl;
675// updateGL();
676//}
677//
678///** Launch a dialog to configure the lights.
679// */
680//void GLMoleculeView::createDialogLight()
681//{
682//// Ui_DialogLight *Lights = new Ui_DialogLight();
683//// if (Lights == NULL)
684//// return;
685//// // Set up the dynamic dialog here
686//// QLineEdit *Field = NULL;
687//// Field = Lights->findChild<QLineEdit *>("LightPositionX");
688//// if (Field) Field->setText( QString("%1").arg(LightPosition[0]) );
689//// Field = Lights->findChild<QLineEdit *>("LightPositionY");
690//// if (Field) Field->setText( QString("%1").arg(LightPosition[1]) );
691//// Field = Lights->findChild<QLineEdit *>("LightPositionZ");
692//// if (Field) Field->setText( QString("%1").arg(LightPosition[2]) );
693//// Field = Lights->findChild<QLineEdit *>("LightPositionW");
694//// if (Field) Field->setText( QString("%1").arg(LightPosition[3]) );
695////
696//// Field = Lights->findChild<QLineEdit *>("LightDiffuseX");
697//// if (Field) Field->setText( QString("%1").arg(LightDiffuse[0]) );
698//// Field = Lights->findChild<QLineEdit *>("LightDiffuseY");
699//// if (Field) Field->setText( QString("%1").arg(LightDiffuse[1]) );
700//// Field = Lights->findChild<QLineEdit *>("LightDiffuseZ");
701//// if (Field) Field->setText( QString("%1").arg(LightDiffuse[2]) );
702//// Field = Lights->findChild<QLineEdit *>("LightDiffuseW");
703//// if (Field) Field->setText( QString("%1").arg(LightDiffuse[3]) );
704////
705//// Field = Lights->findChild<QLineEdit *>("LightAmbientX");
706//// if (Field) Field->setText( QString("%1").arg(LightAmbient[0]) );
707//// Field = Lights->findChild<QLineEdit *>("LightAmbientY");
708//// if (Field) Field->setText( QString("%1").arg(LightAmbient[1]) );
709//// Field = Lights->findChild<QLineEdit *>("LightAmbientZ");
710//// if (Field) Field->setText( QString("%1").arg(LightAmbient[2]) );
711//// Field = Lights->findChild<QLineEdit *>("LightAmbientW");
712//// if (Field) Field->setText( QString("%1").arg(LightAmbient[3]) );
713////
714//// if ( Lights->exec() ) {
715//// //cout << "User accepted.\n";
716//// // The user accepted, act accordingly
717//// Field = Lights->findChild<QLineEdit *>("LightPositionX");
718//// if (Field) LightPosition[0] = Field->text().toDouble();
719//// Field = Lights->findChild<QLineEdit *>("LightPositionY");
720//// if (Field) LightPosition[1] = Field->text().toDouble();
721//// Field = Lights->findChild<QLineEdit *>("LightPositionZ");
722//// if (Field) LightPosition[2] = Field->text().toDouble();
723//// Field = Lights->findChild<QLineEdit *>("LightPositionW");
724//// if (Field) LightPosition[3] = Field->text().toDouble();
725////
726//// Field = Lights->findChild<QLineEdit *>("LightDiffuseX");
727//// if (Field) LightDiffuse[0] = Field->text().toDouble();
728//// Field = Lights->findChild<QLineEdit *>("LightDiffuseY");
729//// if (Field) LightDiffuse[1] = Field->text().toDouble();
730//// Field = Lights->findChild<QLineEdit *>("LightDiffuseZ");
731//// if (Field) LightDiffuse[2] = Field->text().toDouble();
732//// Field = Lights->findChild<QLineEdit *>("LightDiffuseW");
733//// if (Field) LightDiffuse[3] = Field->text().toDouble();
734////
735//// Field = Lights->findChild<QLineEdit *>("LightAmbientX");
736//// if (Field) LightAmbient[0] = Field->text().toDouble();
737//// Field = Lights->findChild<QLineEdit *>("LightAmbientY");
738//// if (Field) LightAmbient[1] = Field->text().toDouble();
739//// Field = Lights->findChild<QLineEdit *>("LightAmbientZ");
740//// if (Field) LightAmbient[2] = Field->text().toDouble();
741//// Field = Lights->findChild<QLineEdit *>("LightAmbientW");
742//// if (Field) LightAmbient[3] = Field->text().toDouble();
743//// updateGL();
744//// } else {
745//// //cout << "User reclined.\n";
746//// }
747//// delete(Lights);
748//}
749//
750///** Slot for event of pressed mouse button.
751// * Switch discerns between buttons and stores position of event in GLMoleculeView::LeftButtonPos,
752// * GLMoleculeView::MiddleButtonPos or GLMoleculeView::RightButtonPos.
753// * \param *event structure containing information of the event
754// */
755//void GLMoleculeView::mousePressEvent(QMouseEvent *event)
756//{
757// std::cout << "MousePressEvent." << endl;
758// QPoint *pos = NULL;
759// switch (event->button()) { // get the right array
760// case Qt::LeftButton:
761// pos = &LeftButtonPos;
762// std::cout << "Left Button" << endl;
763// break;
764// case Qt::MidButton:
765// pos = &MiddleButtonPos;
766// std::cout << "Middle Button" << endl;
767// break;
768// case Qt::RightButton:
769// pos = &RightButtonPos;
770// std::cout << "Right Button" << endl;
771// break;
772// default:
773// break;
774// }
775// if (pos) { // store the position
776// pos->setX(event->pos().x());
777// pos->setY(event->pos().y());
778// std::cout << "Stored src position is (" << pos->x() << "," << pos->y() << ")." << endl;
779// } else {
780// std::cout << "pos is NULL." << endl;
781// }
782//}
783//
784///** Slot for event of pressed mouse button.
785// * Switch discerns between buttons:
786// * -# Left Button: Rotates the view of the GLMoleculeView, relative to GLMoleculeView::LeftButtonPos.
787// * -# Middle Button: nothing
788// * -# Right Button: Shifts the selected molecule or atom, relative to GLMoleculeView::RightButtonPos.
789// * \param *event structure containing information of the event
790// */
791//void GLMoleculeView::mouseReleaseEvent(QMouseEvent *event)
792//{
793// std::cout << "MouseReleaseEvent." << endl;
794// QPoint *srcpos = NULL;
795// QPoint destpos = event->pos();
796// int Width = (MultiViewEnabled) ? width/2 : width;
797// int Height = (MultiViewEnabled) ? height/2 : height;
798// std::cout << "Received dest position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
799// switch (event->button()) { // get the right array
800// case Qt::LeftButton: // LeftButton rotates the view
801// srcpos = &LeftButtonPos;
802// std::cout << "Left Button" << endl;
803// if (srcpos) { // subtract the position and act
804// std::cout << "Stored src position is (" << srcpos->x() << "," << srcpos->y() << ")." << endl;
805// destpos -= *srcpos;
806// std::cout << "Resulting diff position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
807// std::cout << "Width and Height are " << Width << "," << Height << "." << endl;
808//
809// int pos = (int)floor((double)srcpos->x()/(double)Width) + ((int)floor((double)srcpos->y()/(double)Height))*2;
810// if ((MultiViewEnabled) && (pos != 2)) { // means four regions, and we are in a shifting one
811// // switch between three regions
812// // decide into which of the four screens the initial click has been made
813// std::cout << "Position is " << pos << "." << endl;
814// switch(pos) {
815// case 0: // lower left = xz
816// position[0] += -destpos.y()/100.;
817// position[2] += destpos.x()/100.;
818// break;
819// case 1: // lower right = yz
820// position[1] += -destpos.y()/100.;
821// position[2] += -destpos.x()/100.;
822// break;
823// case 2: // upper left = projected
824// std::cout << "This is impossible: Shifting in the projected region, we should rotate!." << endl;
825// break;
826// case 3: // upper right = xy
827// position[0] += destpos.x()/100.;
828// position[1] += -destpos.y()/100.;
829// break;
830// default:
831// std::cout << "click was not in any of the four regions." << endl;
832// break;
833// }
834// updateGL();
835// } else { // we are in rotation region
836// QWidget *Parent = parentWidget();
837// QSlider *sliderX = Parent->findChild<QSlider *>("sliderX");
838// QSlider *sliderY = Parent->findChild<QSlider *>("sliderY");
839// std::cout << sliderX << " and " << sliderY << endl;
840// if (sliderX) {
841// int xrange = sliderX->maximum() - sliderX->minimum();
842// double xValue = ((destpos.x() + Width) % Width);
843// xValue *= (double)xrange/(double)Width;
844// xValue += sliderX->value();
845// int xvalue = (int) xValue % xrange;
846// std::cout << "Setting x to " << xvalue << " within range " << xrange << "." << endl;
847// setXRotation(xvalue);
848// sliderX->setValue(xvalue);
849// } else {
850// std::cout << "sliderX is NULL." << endl;
851// }
852// if (sliderY) {
853// int yrange = sliderY->maximum() - sliderY->minimum();
854// double yValue = ((destpos.y() + Height) % Height);
855// yValue *= (double)yrange/(double)Height;
856// yValue += sliderY->value();
857// int yvalue = (int) yValue % yrange;
858// std::cout << "Setting y to " << yvalue << " within range " << yrange << "." << endl;
859// setYRotation(yvalue);
860// sliderY->setValue(yvalue);
861// } else {
862// std::cout << "sliderY is NULL." << endl;
863// }
864// }
865// } else {
866// std::cout << "srcpos is NULL." << endl;
867// }
868// break;
869//
870// case Qt::MidButton: // MiddleButton has no function so far
871// srcpos = &MiddleButtonPos;
872// std::cout << "Middle Button" << endl;
873// if (srcpos) { // subtract the position and act
874// QWidget *Parent = parentWidget();
875// QSlider *sliderZ = Parent->findChild<QSlider *>("sliderZ");
876// QSlider *sliderScale = Parent->findChild<QSlider *>("sliderScale");
877// std::cout << sliderZ << " and " << sliderScale << endl;
878// std::cout << "Stored src position is (" << srcpos->x() << "," << srcpos->y() << ")." << endl;
879// destpos -= *srcpos;
880// std::cout << "Resulting diff position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
881// std::cout << "Width and Height are " << Width << "," << Height << "." << endl;
882// if (sliderZ) {
883// int xrange = sliderZ->maximum() - sliderZ->minimum();
884// double xValue = ((destpos.x() + Width) % Width);
885// xValue *= (double)xrange/(double)Width;
886// xValue += sliderZ->value();
887// int xvalue = (int) xValue % xrange;
888// std::cout << "Setting x to " << xvalue << " within range " << xrange << "." << endl;
889// setZRotation(xvalue);
890// sliderZ->setValue(xvalue);
891// } else {
892// std::cout << "sliderZ is NULL." << endl;
893// }
894// if (sliderScale) {
895// int yrange = sliderScale->maximum() - sliderScale->minimum();
896// double yValue = ((destpos.y() + Height) % Height);
897// yValue *= (double)yrange/(double)Height;
898// yValue += sliderScale->value();
899// int yvalue = (int) yValue % yrange;
900// std::cout << "Setting y to " << yvalue << " within range " << yrange << "." << endl;
901// setScale(yvalue);
902// sliderScale->setValue(yvalue);
903// } else {
904// std::cout << "sliderScale is NULL." << endl;
905// }
906// } else {
907// std::cout << "srcpos is NULL." << endl;
908// }
909// break;
910// break;
911//
912// case Qt::RightButton: // RightButton moves eitstdher the selected molecule or atom
913// srcpos = &RightButtonPos;
914// std::cout << "Right Button" << endl;
915// if (srcpos) { // subtract the position and act
916// std::cout << "Stored src position is (" << srcpos->x() << "," << srcpos->y() << ")." << endl;
917// destpos -= *srcpos;
918// std::cout << "Resulting diff position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
919// std::cout << "Width and Height are " << Width << "," << Height << "." << endl;
920// if (MultiViewEnabled) {
921// // which vector to change
922// Vector SelectedPosition;
923// const std::vector<atom*> &SelectedAtoms = World::getInstance().getSelectedAtoms();
924// const std::vector<molecule*> &SelectedMolecules = World::getInstance().getSelectedMolecules();
925// if (SelectedMolecules.size()) {
926// if (SelectedAtoms.size())
927// SelectedPosition = (*SelectedAtoms.begin())->getPosition();
928// else
929// SelectedPosition = (*(*SelectedMolecules.begin())->begin())->getPosition();
930// }
931// // decide into which of the four screens the initial click has been made
932// int pos = (int)floor((double)srcpos->x()/(double)Width) + ((int)floor((double)srcpos->y()/(double)Height))*2;
933// if (!SelectedPosition.IsZero()) {
934// std::cout << "Position is " << pos << "." << endl;
935// switch(pos) {
936// case 0: // lower left = xz
937// SelectedPosition[0] += -destpos.y()/100.;
938// SelectedPosition[2] += destpos.x()/100.;
939// break;
940// case 1: // lower right = yz
941// SelectedPosition[1] += -destpos.y()/100.;
942// SelectedPosition[2] += -destpos.x()/100.;
943// break;
944// case 2: // upper left = projected
945// SelectedPosition[0] += destpos.x()/100.;
946// SelectedPosition[1] += destpos.y()/100.;
947// SelectedPosition[2] += destpos.y()/100.;
948// break;
949// case 3: // upper right = xy
950// SelectedPosition[0] += destpos.x()/100.;
951// SelectedPosition[1] += -destpos.y()/100.;
952// break;
953// default:
954// std::cout << "click was not in any of the four regions." << endl;
955// break;
956// }
957// } else {
958// std::cout << "Nothing selected." << endl;
959// }
960// // update Tables
961// if (SelectedMolecules.size()) {
962// isSignaller = true;
963// if (SelectedAtoms.size())
964// emit notifyAtomChanged( (*SelectedMolecules.begin()), (*SelectedAtoms.begin()), AtomPosition);
965// else
966// emit notifyMoleculeChanged( (*SelectedMolecules.begin()), MoleculePosition );
967// }
968// // update graphic
969// initializeGL();
970// updateGL();
971// } else {
972// cout << "MultiView is not enabled." << endl;
973// }
974// } else {
975// cout << "srcpos is NULL." << endl;
976// }
977// break;
978//
979// default:
980// break;
981// }
982//}
983//
984///* ======================================== SLOTS ================================ */
985//
986///** Hear announcement of selected molecule.
987// * \param *mol pointer to selected molecule
988// */
989//void GLMoleculeView::hearMoleculeSelected(molecule *mol)
990//{
991// if (isSignaller) { // if we emitted the signal, return
992// isSignaller = false;
993// return;
994// }
995// initializeGL();
996// updateGL();
997//};
998//
999///** Hear announcement of selected atom.
1000// * \param *mol pointer to molecule containing atom
1001// * \param *Walker pointer to selected atom
1002// */
1003//void GLMoleculeView::hearAtomSelected(molecule *mol, atom *Walker)
1004//{
1005// if (isSignaller) { // if we emitted the signal, return
1006// isSignaller = false;
1007// return;
1008// }
1009// initializeGL();
1010// updateGL();
1011//};
1012//
1013///** Hear announcement of changed molecule.
1014// * \param *mol pointer to changed molecule
1015// * \param type of change
1016// */
1017//void GLMoleculeView::hearMoleculeChanged(molecule *mol, enum ChangesinMolecule type)
1018//{
1019// if (isSignaller) { // if we emitted the signal, return
1020// isSignaller = false;
1021// return;
1022// }
1023// initializeGL();
1024// updateGL();
1025//};
1026//
1027///** Hear announcement of changed atom.
1028// * \param *mol pointer to molecule containing atom
1029// * \param *Walker pointer to changed atom
1030// * \param type type of change
1031// */
1032//void GLMoleculeView::hearAtomChanged(molecule *mol, atom *Walker, enum ChangesinAtom type)
1033//{
1034// if (isSignaller) { // if we emitted the signal, return
1035// isSignaller = false;
1036// return;
1037// }
1038// initializeGL();
1039// updateGL();
1040//};
1041//
1042///** Hear announcement of changed element.
1043// * \param *Runner pointer to changed element
1044// * \param type of change
1045// */
1046//void GLMoleculeView::hearElementChanged(element *Runner, enum ChangesinElement type)
1047//{
1048// if (isSignaller) { // if we emitted the signal, return
1049// isSignaller = false;
1050// return;
1051// }
1052// switch(type) {
1053// default:
1054// case ElementName:
1055// case ElementSymbol:
1056// case ElementMass:
1057// case ElementValence:
1058// case ElementZ:
1059// break;
1060// case ElementCovalent:
1061// case ElementVanderWaals:
1062// initializeGL();
1063// updateGL();
1064// break;
1065// }
1066//};
1067//
1068///** Hear announcement of added molecule.
1069// * \param *mol pointer to added molecule
1070// */
1071//void GLMoleculeView::hearMoleculeAdded(molecule *mol)
1072//{
1073// if (isSignaller) { // if we emitted the signal, return
1074// isSignaller = false;
1075// return;
1076// }
1077// initializeGL();
1078// updateGL();
1079//};
1080//
1081///** Hear announcement of added atom.
1082// * \param *mol pointer to molecule containing atom
1083// * \param *Walker pointer to added atom
1084// */
1085//void GLMoleculeView::hearAtomAdded(molecule *mol, atom *Walker)
1086//{
1087// if (isSignaller) { // if we emitted the signal, return
1088// isSignaller = false;
1089// return;
1090// }
1091// initializeGL();
1092// updateGL();
1093//};
1094//
1095///** Hear announcement of removed molecule.
1096// * \param *mol pointer to removed molecule
1097// */
1098//void GLMoleculeView::hearMoleculeRemoved(molecule *mol)
1099//{
1100// if (isSignaller) { // if we emitted the signal, return
1101// isSignaller = false;
1102// return;
1103// }
1104// initializeGL();
1105// updateGL();
1106//};
1107//
1108///** Hear announcement of removed atom.
1109// * \param *mol pointer to molecule containing atom
1110// * \param *Walker pointer to removed atom
1111// */
1112//void GLMoleculeView::hearAtomRemoved(molecule *mol, atom *Walker)
1113//{
1114// if (isSignaller) { // if we emitted the signal, return
1115// isSignaller = false;
1116// return;
1117// }
1118// initializeGL();
1119// updateGL();
1120//};
1121//
1122//void GLMoleculeView::update(Observable *publisher)
1123//{
1124// initializeGL();
1125// updateGL();
1126//}
1127//
1128///**
1129// * This method is called when a special named change
1130// * of the Observable occured
1131// */
1132//void GLMoleculeView::recieveNotification(Observable *publisher, Notification_ptr notification)
1133//{
1134// initializeGL();
1135// updateGL();
1136//}
1137//
1138///**
1139// * This method is called when the observed object is destroyed.
1140// */
1141//void GLMoleculeView::subjectKilled(Observable *publisher)
1142//{
1143//
1144//}
1145//
1146//
1147//// new stuff
1148//
1149///** Returns the ref to the Material for element No \a from the map.
1150// *
1151// * \note We create a new one if the element is missing.
1152// *
1153// * @param no element no
1154// * @return ref to QGLMaterial
1155// */
1156//QGLMaterial* GLMoleculeView::getMaterial(size_t no)
1157//{
1158// if (ElementNoMaterialMap.find(no) != ElementNoMaterialMap.end()){
1159// // get present one
1160//
1161// } else {
1162// ASSERT( (no >= 0) && (no < MAX_ELEMENTS),
1163// "GLMoleculeView::getMaterial() - Element no "+toString(no)+" is invalid.");
1164// // create new one
1165// LOG(1, "Creating new material for element "+toString(no)+".");
1166// QGLMaterial *newmaterial = new QGLMaterial(this);
1167// periodentafel *periode = World::getInstance().getPeriode();
1168// element *desiredelement = periode->FindElement(no);
1169// ASSERT(desiredelement != NULL,
1170// "GLMoleculeView::getMaterial() - desired element "+toString(no)+" not present in periodentafel.");
1171// const unsigned char* color = desiredelement->getColor();
1172// newmaterial->setAmbientColor( QColor(color[0], color[1], color[2]) );
1173// newmaterial->setSpecularColor( QColor(60, 60, 60) );
1174// newmaterial->setShininess( QColor(128) );
1175// ElementNoMaterialMap.insert( no, newmaterial);
1176// }
1177//}
1178//
1179//QGLSceneNode* GLMoleculeView::getAtom(size_t no)
1180//{
1181// // first some sensibility checks
1182// ASSERT(World::getInstance().getAtom(AtomById(no)) != NULL,
1183// "GLMoleculeView::getAtom() - desired atom "
1184// +toString(no)+" not present in the World.");
1185// ASSERT(AtomsinSceneMap.find(no) != AtomsinSceneMap.end(),
1186// "GLMoleculeView::getAtom() - desired atom "
1187// +toString(no)+" not present in the AtomsinSceneMap.");
1188//
1189// return AtomsinSceneMap[no];
1190//}
1191//
1192//QGLSceneNode* GLMoleculeView::getBond(size_t leftno, size_t rightno)
1193//{
1194// // first some sensibility checks
1195// ASSERT(World::getInstance().getAtom(AtomById(leftno)) != NULL,
1196// "GLMoleculeView::getAtom() - desired atom "
1197// +toString(leftno)+" of bond not present in the World.");
1198// ASSERT(World::getInstance().getAtom(AtomById(rightno)) != NULL,
1199// "GLMoleculeView::getAtom() - desired atom "
1200// +toString(rightno)+" of bond not present in the World.");
1201// ASSERT(AtomsinSceneMap.find(leftno) != AtomsinSceneMap.end(),
1202// "GLMoleculeView::getAtom() - desired atom "
1203// +toString(leftno)+" of bond not present in the AtomsinSceneMap.");
1204// ASSERT(AtomsinSceneMap.find(rightno) != AtomsinSceneMap.end(),
1205// "GLMoleculeView::getAtom() - desired atom "
1206// +toString(rightno)+" of bond not present in the AtomsinSceneMap.");
1207// ASSERT(leftno == rightno,
1208// "GLMoleculeView::getAtom() - bond must not be between the same atom: "
1209// +toString(leftno)+" == "+toString(rightno)+".");
1210//
1211// // then return with smaller index first
1212// if (leftno > rightno)
1213// return AtomsinSceneMap[ make_pair(rightno, leftno) ];
1214// else
1215// return AtomsinSceneMap[ make_pair(leftno, rightno) ];
1216//}
1217//
Note: See TracBrowser for help on using the repository browser.