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