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