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 |
|
---|
22 | class molecule;
|
---|
23 | class QKeyEvent;
|
---|
24 | class GLWorldScene;
|
---|
25 | class QGLPainter;
|
---|
26 | class QToolBar;
|
---|
27 | class QTimer;
|
---|
28 | class QtSelectionChangedAgent;
|
---|
29 |
|
---|
30 | class QtInstanceInformationBoard;
|
---|
31 |
|
---|
32 | /** This class is the view on the 3D representation of the World, i.e. the whole
|
---|
33 | * of all molecules (consisting of atoms).
|
---|
34 | *
|
---|
35 | */
|
---|
36 | class GLWorldView : public QGLView, public Observer
|
---|
37 | {
|
---|
38 | Q_OBJECT
|
---|
39 | public:
|
---|
40 | GLWorldView(
|
---|
41 | QtInstanceInformationBoard * _board,
|
---|
42 | QWidget *parent=0);
|
---|
43 | virtual ~GLWorldView();
|
---|
44 |
|
---|
45 | void addToolBarActions(QToolBar *toolbar);
|
---|
46 | void createDomainBox();
|
---|
47 | void createDreiBein();
|
---|
48 |
|
---|
49 | void setSelectionChangedAgent(QtSelectionChangedAgent *agent);
|
---|
50 |
|
---|
51 | // Observer functions
|
---|
52 | void update(Observable *publisher);
|
---|
53 | void subjectKilled(Observable *publisher);
|
---|
54 | void recieveNotification(Observable *publisher, Notification_ptr notification);
|
---|
55 |
|
---|
56 | public slots:
|
---|
57 | void changeSignalled();
|
---|
58 | void checkChanges();
|
---|
59 | void sceneChangeSignalled();
|
---|
60 | void sceneHoverSignalled(const atomId_t _id);
|
---|
61 | void sceneHoverSignalled(const moleculeId_t _id, int);
|
---|
62 | void changeDreiBein();
|
---|
63 | void changeDomain();
|
---|
64 |
|
---|
65 | signals:
|
---|
66 | void changed();
|
---|
67 | void TimeChanged();
|
---|
68 | void atomInserted(const moleculeId_t _molid, const atomId_t _atomid);
|
---|
69 | void atomRemoved(const moleculeId_t _molid, const atomId_t _atomid);
|
---|
70 | void moleculeInserted(const moleculeId_t _id);
|
---|
71 | void moleculeRemoved(const moleculeId_t _id);
|
---|
72 | void worldSelectionChanged();
|
---|
73 | void hoverChanged(const atomId_t _id);
|
---|
74 | void hoverChanged(const moleculeId_t _id, int);
|
---|
75 | void ShapeAdded(const std::string &);
|
---|
76 | void ShapeRemoved(const std::string &);
|
---|
77 | void moleculesVisibilityChanged(const moleculeId_t,bool);
|
---|
78 |
|
---|
79 | protected:
|
---|
80 | void initializeGL(QGLPainter *painter);
|
---|
81 | void paintGL(QGLPainter *painter);
|
---|
82 | void drawDomainBox(QGLPainter *painter) const;
|
---|
83 | void drawDreiBein(QGLPainter *painter);
|
---|
84 |
|
---|
85 | // input functions
|
---|
86 | void mousePressEvent(QMouseEvent *event);
|
---|
87 | void mouseMoveEvent(QMouseEvent *event);
|
---|
88 | void keyPressEvent(QKeyEvent *event);
|
---|
89 | void wheelEvent(QWheelEvent *event);
|
---|
90 |
|
---|
91 | // camera functions
|
---|
92 | enum CameraControlModeType{
|
---|
93 | Rotate,
|
---|
94 | Translate
|
---|
95 | };
|
---|
96 |
|
---|
97 | void setCameraControlMode(CameraControlModeType mode);
|
---|
98 | CameraControlModeType getCameraControlMode(bool inverted = false);
|
---|
99 | public slots:
|
---|
100 | void fitCameraToDomain();
|
---|
101 | void setCameraControlModeRotation();
|
---|
102 | void setCameraControlModeTranslation();
|
---|
103 | void setCameraStereoModeDisable();
|
---|
104 | void setCameraStereoModeHardware();
|
---|
105 | void setCameraStereoModeLeftRight();
|
---|
106 | void setCameraStereoModeRightLeft();
|
---|
107 | void setCameraStereoModeTopBottom();
|
---|
108 | void setCameraStereoModeBottomTop();
|
---|
109 | void setCameraStereoModeAnaglyph();
|
---|
110 |
|
---|
111 | protected:
|
---|
112 | CameraControlModeType cameraControlMode;
|
---|
113 |
|
---|
114 | private:
|
---|
115 | void setdreiBeinStatus(const bool status);
|
---|
116 | void setDomainStatus(const bool status);
|
---|
117 |
|
---|
118 | void signOnToMolecule(const molecule *_mol);
|
---|
119 | void signOffFromMolecule(const molecule *_mol);
|
---|
120 |
|
---|
121 | private:
|
---|
122 |
|
---|
123 | GLWorldScene *worldscene;
|
---|
124 |
|
---|
125 | bool changesPresent;
|
---|
126 | bool processingSelectionChanged; // workaround to prevent a loop in (atom_iterator <-> observer)
|
---|
127 |
|
---|
128 | QPointF lastMousePos;
|
---|
129 |
|
---|
130 | QGLSceneNode *meshDomainBox;
|
---|
131 | QGLSceneNode *meshDreiBein;
|
---|
132 |
|
---|
133 | QGLMaterial *domainBoxMaterial;
|
---|
134 | QGLMaterial *dreiBeinMaterial[3];
|
---|
135 |
|
---|
136 | QTimer *redrawTimer;
|
---|
137 | bool needsRedraw;
|
---|
138 |
|
---|
139 | double defaultEyeSeparation;
|
---|
140 |
|
---|
141 | typedef std::multiset<molecule *> ObservedMolecules_t;
|
---|
142 | //!> sorted list of molecules we are sign on to
|
---|
143 | ObservedMolecules_t ObservedMolecules;
|
---|
144 | };
|
---|
145 |
|
---|
146 | #endif /* GLWORLDVIEW_HPP_ */
|
---|