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