source: src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp@ ce4126

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

FIX: Added update mechanism to GLWorldScene when WorldTime changes.

  • bonds were not updated when WorldTime changed, atoms only change because each was subscribed to WorldTime.
  • Now, just GLWorldView is subscribed to WorldTime::TimeChanged, emitting TimeChanged and activating GLWorldScene::updated() signal.
  • GLWorldScene has access to private reset..() functions of GLMoleculeObject_atom and GLMoleculeObject_bond.
  • added GLWorldScene::update(), enhancing (also modified) ::init() function. It does not use molecules anymore, but directly the World's atoms. These are iterated over, checked whether already present and updated or added. Similarly with bonds. update() is activated on signal updated().
  • Property mode set to 100644
File size: 7.6 KB
Line 
1/*
2 * GLWorldView.hpp
3 *
4 * Created on: Auf 11, 2010
5 * Author: heber
6 */
7
8#ifndef GLWORLDVIEW_HPP_
9#define GLWORLDVIEW_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <Qt3D/qglview.h>
17
18#include "CodePatterns/Observer/Observer.hpp"
19
20#include "World.hpp"
21
22class molecule;
23class QKeyEvent;
24class GLWorldScene;
25class QGLPainter;
26class QToolBar;
27class QTimer;
28
29/** This class is the view on the 3D representation of the World, i.e. the whole
30 * of all molecules (consisting of atoms).
31 *
32 */
33class GLWorldView : public QGLView, public Observer
34{
35 Q_OBJECT
36public:
37 GLWorldView(QWidget *parent=0);
38 virtual ~GLWorldView();
39
40 void addToolBarActions(QToolBar *toolbar);
41 void createDomainBox();
42 void createDreiBein();
43
44 // Observer functions
45 void update(Observable *publisher);
46 void subjectKilled(Observable *publisher);
47 void recieveNotification(Observable *publisher, Notification_ptr notification);
48
49public slots:
50 void changeSignalled();
51 void checkChanges();
52 void sceneChangeSignalled();
53 void sceneHoverSignalled(const atom *_atom);
54 void changeDreiBein();
55 void changeDomain();
56
57signals:
58 void changed();
59 void TimeChanged();
60 void atomInserted(const atomicNumber_t _id);
61 void atomRemoved(const atomicNumber_t _id);
62 void moleculeInserted(const molecule *_molecule);
63 void moleculeRemoved(const molecule *_molecule);
64 void worldSelectionChanged();
65 void hoverChanged(const atom *_atom);
66 void ShapeAdded();
67 void ShapeRemoved();
68
69protected:
70 void initializeGL(QGLPainter *painter);
71 void paintGL(QGLPainter *painter);
72 void drawDomainBox(QGLPainter *painter) const;
73 void drawDreiBein(QGLPainter *painter);
74
75 // input functions
76 void mousePressEvent(QMouseEvent *event);
77 void mouseMoveEvent(QMouseEvent *event);
78 void keyPressEvent(QKeyEvent *event);
79 void wheelEvent(QWheelEvent *event);
80
81 // camera functions
82 enum CameraControlModeType{
83 Rotate,
84 Translate
85 };
86
87 void setCameraControlMode(CameraControlModeType mode);
88 CameraControlModeType getCameraControlMode(bool inverted = false);
89public slots:
90 void fitCameraToDomain();
91 void setCameraControlModeRotation();
92 void setCameraControlModeTranslation();
93 void setCameraStereoModeDisable();
94 void setCameraStereoModeHardware();
95 void setCameraStereoModeLeftRight();
96 void setCameraStereoModeRightLeft();
97 void setCameraStereoModeTopBottom();
98 void setCameraStereoModeBottomTop();
99 void setCameraStereoModeAnaglyph();
100
101protected:
102 CameraControlModeType cameraControlMode;
103
104private:
105 void setdreiBeinStatus(const bool status);
106 void setDomainStatus(const bool status);
107
108private:
109
110 GLWorldScene *worldscene;
111
112 bool changesPresent;
113 bool processingSelectionChanged; // workaround to prevent a loop in (atom_iterator <-> observer)
114
115 QPointF lastMousePos;
116
117 QGLSceneNode *meshDomainBox;
118 QGLSceneNode *meshDreiBein;
119
120 QGLMaterial *domainBoxMaterial;
121 QGLMaterial *dreiBeinMaterial[3];
122
123 QTimer *redrawTimer;
124 bool needsRedraw;
125
126 double defaultEyeSeparation;
127};
128
129
130
131//#include "CodePatterns/Observer/Observer.hpp"
132//#include "LinearAlgebra/Vector.hpp"
133//#include "changetypes.hpp"
134//
135//class atom;
136//class element;
137//class molecule;
138//
139//class GLMoleculeView : public QGLWidget, public Observer
140//{
141// Q_OBJECT
142//
143//public:
144//
145// GLMoleculeView( QWidget* parent);
146// ~GLMoleculeView();
147//
148//public slots:
149//
150// void setXRotation( int degrees );
151// void setYRotation( int degrees );
152// void setZRotation( int degrees );
153// void setScale( int distance );
154// void setLightPosition( int *light );
155// void setLightDiffuse( int *light );
156// void setLightAmbient( int *light );
157// void createDialogLight();
158// void toggleMultiViewEnabled();
159//
160// void init( QLabel *ptr );
161// void initCoordinates(QLabel *ptr);
162// void createView();
163// void hearMoleculeSelected(molecule *mol);
164// void hearAtomSelected(molecule *mol, atom *Walker);
165// void hearMoleculeChanged(molecule *mol, enum ChangesinMolecule type);
166// void hearAtomChanged(molecule *mol, atom *Walker, enum ChangesinAtom type);
167// void hearElementChanged(element *Runner, enum ChangesinElement type);
168// void hearMoleculeAdded(molecule *mol);
169// void hearAtomAdded(molecule *mol, atom *Walker);
170// void hearMoleculeRemoved(molecule *mol);
171// void hearAtomRemoved(molecule *mol, atom *Walker);
172//
173//signals:
174// void notifyMoleculeSelected( molecule *mol );
175// void notifyAtomSelected( molecule *mol, atom *Walker );
176// void notifyMoleculeChanged( molecule *mol, enum ChangesinMolecule type );
177// void notifyAtomChanged( molecule *mol, atom *Walker, enum ChangesinAtom type );
178// void notifyElementChanged( element *Runner, enum ChangesinElement type );
179// void notifyMoleculeAdded( molecule *mol);
180// void notifyElementAdded( element *Runner);
181// void notifyAtomAdded( molecule *mol, atom *Walker );
182// void notifyMoleculeRemoved( molecule *mol );
183// void notifyAtomRemoved( molecule *mol, atom *Walker );
184//
185//protected:
186//
187// void initializeGL();
188// void paintGL();
189// void resizeGL( int w, int h );
190// void makeSphere(const Vector &x, double radius, const unsigned char color[3]);
191// void makeCylinder(const Vector &x, const Vector &y, double radius, double height, const unsigned char color[3]);
192// void mousePressEvent(QMouseEvent* event);
193// void mouseReleaseEvent(QMouseEvent* event);
194//
195//public:
196//
197// /** Update function as we are an Observer.
198// *
199// * @param publisher ref to Observable
200// */
201// void update(Observable *publisher);
202//
203// /**
204// * This method is called when a special named change
205// * of the Observable occured
206// */
207// void recieveNotification(Observable *publisher, Notification_ptr notification);
208//
209// /**
210// * This method is called when the observed object is destroyed.
211// */
212// void subjectKilled(Observable *publisher);
213//
214//
215//private:
216//
217// typedef std::map< size_t, node > AtomNodeMap;
218// typedef std::map< std::pair< size_t, size_t> , node > BondNodeMap;
219// typedef std::map< size_t, QGLMaterial *> ElementMaterialMap;
220//
221// ElementMaterialMap ElementNoMaterialMap;
222// AtomNodeMap AtomsinSceneMap;
223// BondNodeMap BondsinSceneMap;
224//
225// QGLMaterial* getMaterial(size_t);
226// QGLSceneNode* getAtom(size_t);
227// QGLSceneNode* getBond(size_t, size_t);
228//
229// // old stuff
230//
231// GLuint object; // call list for the scene to be rendered
232// GLfloat xRot, yRot, zRot, scale; // rotation angles and scaling (zoom)
233// Vector position; //!< position of observer
234// Vector view; //!< point along line of view
235// Vector top; //!< giving upwards direction
236// Vector X,Y,Z; //!< vectors defining the coordinate system
237// int width; //!< width of window
238// int height; //!< height of window
239//
240// QLabel *StatusBar; //!< pointer to status bar for messages
241// QLabel *CoordinatesBar; //!< pointer to coordinates bar for view port
242//
243// GLfloat LightPosition[4]; //!< Light Position
244// GLfloat LightDiffuse[4]; //!< Diffuse Light Values
245// GLfloat LightAmbient[4]; //!< Ambient Light Values
246//
247// QPoint LeftButtonPos; //!< mouse position on mousePressEvent for LeftButton
248// QPoint MiddleButtonPos; //!< mouse position on mousePressEvent for MidButton
249// QPoint RightButtonPos; //!< mouse position on mousePressEvent for RightButton
250//
251// unsigned char SelectionColor[3] ; //!< highlight color
252//
253// bool isSignaller;
254//
255// bool MultiViewEnabled; //!< if true, split screen into four parts with additional xy,xz,yz views
256//};
257
258#endif /* GLWORLDVIEW_HPP_ */
Note: See TracBrowser for help on using the repository browser.