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 | /** 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 | */
|
---|
33 | class GLWorldView : public QGLView, public Observer
|
---|
34 | {
|
---|
35 | Q_OBJECT
|
---|
36 | public:
|
---|
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 |
|
---|
49 | public slots:
|
---|
50 | void changeSignalled();
|
---|
51 | void checkChanges();
|
---|
52 | void sceneChangeSignalled();
|
---|
53 | void sceneHoverSignalled(const atom *_atom);
|
---|
54 | void changeDreiBein();
|
---|
55 | void changeDomain();
|
---|
56 |
|
---|
57 | signals:
|
---|
58 | void changed();
|
---|
59 | void atomInserted(const atomicNumber_t _id);
|
---|
60 | void atomRemoved(const atomicNumber_t _id);
|
---|
61 | void moleculeInserted(const molecule *_molecule);
|
---|
62 | void moleculeRemoved(const molecule *_molecule);
|
---|
63 | void worldSelectionChanged();
|
---|
64 | void hoverChanged(const atom *_atom);
|
---|
65 | void ShapeAdded();
|
---|
66 | void ShapeRemoved();
|
---|
67 |
|
---|
68 | protected:
|
---|
69 | void initializeGL(QGLPainter *painter);
|
---|
70 | void paintGL(QGLPainter *painter);
|
---|
71 | void drawDomainBox(QGLPainter *painter) const;
|
---|
72 | void drawDreiBein(QGLPainter *painter);
|
---|
73 |
|
---|
74 | // input functions
|
---|
75 | void mousePressEvent(QMouseEvent *event);
|
---|
76 | void mouseMoveEvent(QMouseEvent *event);
|
---|
77 | void keyPressEvent(QKeyEvent *event);
|
---|
78 | void wheelEvent(QWheelEvent *event);
|
---|
79 |
|
---|
80 | // camera functions
|
---|
81 | enum CameraControlModeType{
|
---|
82 | Rotate,
|
---|
83 | Translate
|
---|
84 | };
|
---|
85 |
|
---|
86 | void setCameraControlMode(CameraControlModeType mode);
|
---|
87 | CameraControlModeType getCameraControlMode(bool inverted = false);
|
---|
88 | public slots:
|
---|
89 | void fitCameraToDomain();
|
---|
90 | void setCameraControlModeRotation();
|
---|
91 | void setCameraControlModeTranslation();
|
---|
92 | void setCameraStereoModeDisable();
|
---|
93 | void setCameraStereoModeHardware();
|
---|
94 | void setCameraStereoModeLeftRight();
|
---|
95 | void setCameraStereoModeRightLeft();
|
---|
96 | void setCameraStereoModeTopBottom();
|
---|
97 | void setCameraStereoModeBottomTop();
|
---|
98 | void setCameraStereoModeAnaglyph();
|
---|
99 |
|
---|
100 | protected:
|
---|
101 | CameraControlModeType cameraControlMode;
|
---|
102 |
|
---|
103 | private:
|
---|
104 | void setdreiBeinStatus(const bool status);
|
---|
105 | void setDomainStatus(const bool status);
|
---|
106 |
|
---|
107 | private:
|
---|
108 |
|
---|
109 | GLWorldScene *worldscene;
|
---|
110 |
|
---|
111 | bool changesPresent;
|
---|
112 | bool processingSelectionChanged; // workaround to prevent a loop in (atom_iterator <-> observer)
|
---|
113 |
|
---|
114 | QPointF lastMousePos;
|
---|
115 |
|
---|
116 | QGLSceneNode *meshDomainBox;
|
---|
117 | QGLSceneNode *meshDreiBein;
|
---|
118 |
|
---|
119 | QGLMaterial *domainBoxMaterial;
|
---|
120 | QGLMaterial *dreiBeinMaterial[3];
|
---|
121 |
|
---|
122 | QTimer *redrawTimer;
|
---|
123 | bool needsRedraw;
|
---|
124 |
|
---|
125 | double defaultEyeSeparation;
|
---|
126 | };
|
---|
127 |
|
---|
128 | #endif /* GLWORLDVIEW_HPP_ */
|
---|