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