| [d238e7] | 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 |  | 
|---|
| [4269ca] | 16 | #include <Qt3D/qglview.h> | 
|---|
| [d238e7] | 17 |  | 
|---|
| [02ce36] | 18 | #include "CodePatterns/Observer/Observer.hpp" | 
|---|
| [7188b1] | 19 |  | 
|---|
|  | 20 | #include "World.hpp" | 
|---|
|  | 21 |  | 
|---|
| [3f5b0a] | 22 | #include <boost/thread/recursive_mutex.hpp> | 
|---|
|  | 23 |  | 
|---|
| [3e93332] | 24 | class molecule; | 
|---|
| [907636] | 25 | class QKeyEvent; | 
|---|
|  | 26 | class GLWorldScene; | 
|---|
| [d238e7] | 27 | class QGLPainter; | 
|---|
| [0e5d14] | 28 | class QToolBar; | 
|---|
| [585f78] | 29 | class QTimer; | 
|---|
| [d238e7] | 30 |  | 
|---|
| [2f7988] | 31 | class QtObservedInstanceBoard; | 
|---|
| [15c8a9] | 32 |  | 
|---|
| [f91ef6] | 33 | #include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp" | 
|---|
|  | 34 |  | 
|---|
| [d238e7] | 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 | */ | 
|---|
| [7188b1] | 39 | class GLWorldView : public QGLView, public Observer | 
|---|
| [d238e7] | 40 | { | 
|---|
| [06ebf5] | 41 | Q_OBJECT | 
|---|
| [d238e7] | 42 | public: | 
|---|
| [15c8a9] | 43 | GLWorldView( | 
|---|
| [2f7988] | 44 | QtObservedInstanceBoard * _board, | 
|---|
| [15c8a9] | 45 | QWidget *parent=0); | 
|---|
| [06ebf5] | 46 | virtual ~GLWorldView(); | 
|---|
| [d238e7] | 47 |  | 
|---|
| [0e5d14] | 48 | void addToolBarActions(QToolBar *toolbar); | 
|---|
| [26ed25] | 49 | void createDomainBox(); | 
|---|
|  | 50 | void createDreiBein(); | 
|---|
| [0e5d14] | 51 |  | 
|---|
| [7188b1] | 52 | // Observer functions | 
|---|
|  | 53 | void update(Observable *publisher); | 
|---|
|  | 54 | void subjectKilled(Observable *publisher); | 
|---|
|  | 55 | void recieveNotification(Observable *publisher, Notification_ptr notification); | 
|---|
|  | 56 |  | 
|---|
| [d238e7] | 57 | public slots: | 
|---|
| [65487f] | 58 | void changeSignalled(); | 
|---|
| [585f78] | 59 | void checkChanges(); | 
|---|
|  | 60 | void sceneChangeSignalled(); | 
|---|
| [704d59] | 61 | void sceneHoverSignalled(const atomId_t _id); | 
|---|
|  | 62 | void sceneHoverSignalled(const moleculeId_t _id, int); | 
|---|
| [592d42] | 63 | void changeDreiBein(); | 
|---|
|  | 64 | void changeDomain(); | 
|---|
| [d238e7] | 65 |  | 
|---|
| [7188b1] | 66 | signals: | 
|---|
|  | 67 | void changed(); | 
|---|
| [ce4126] | 68 | void TimeChanged(); | 
|---|
| [3927ef] | 69 | void worldSelectionChanged(); | 
|---|
| [704d59] | 70 | void hoverChanged(const atomId_t _id); | 
|---|
|  | 71 | void hoverChanged(const moleculeId_t _id, int); | 
|---|
| [07136a] | 72 | void ShapeAdded(const std::string &); | 
|---|
|  | 73 | void ShapeRemoved(const std::string &); | 
|---|
| [f91ef6] | 74 | void moleculesVisibilityChanged(ObservedValue_Index_t,bool); | 
|---|
| [9cdab3] | 75 | void customContextMenuRequested(const QPoint&); | 
|---|
| [7188b1] | 76 |  | 
|---|
| [d238e7] | 77 | protected: | 
|---|
| [06ebf5] | 78 | void initializeGL(QGLPainter *painter); | 
|---|
|  | 79 | void paintGL(QGLPainter *painter); | 
|---|
| [e8c636] | 80 | void drawDomainBox(QGLPainter *painter) const; | 
|---|
|  | 81 | void drawDreiBein(QGLPainter *painter); | 
|---|
| [8880c9] | 82 |  | 
|---|
|  | 83 | // input functions | 
|---|
|  | 84 | void mousePressEvent(QMouseEvent *event); | 
|---|
|  | 85 | void mouseMoveEvent(QMouseEvent *event); | 
|---|
|  | 86 | void keyPressEvent(QKeyEvent *event); | 
|---|
|  | 87 | void wheelEvent(QWheelEvent *event); | 
|---|
| [d238e7] | 88 |  | 
|---|
| [e13b34] | 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(); | 
|---|
| [8e7dd9] | 101 | void setCameraStereoModeDisable(); | 
|---|
|  | 102 | void setCameraStereoModeHardware(); | 
|---|
|  | 103 | void setCameraStereoModeLeftRight(); | 
|---|
|  | 104 | void setCameraStereoModeRightLeft(); | 
|---|
|  | 105 | void setCameraStereoModeTopBottom(); | 
|---|
|  | 106 | void setCameraStereoModeBottomTop(); | 
|---|
|  | 107 | void setCameraStereoModeAnaglyph(); | 
|---|
| [e13b34] | 108 |  | 
|---|
|  | 109 | protected: | 
|---|
|  | 110 | CameraControlModeType cameraControlMode; | 
|---|
|  | 111 |  | 
|---|
| [592d42] | 112 | private: | 
|---|
|  | 113 | void setdreiBeinStatus(const bool status); | 
|---|
|  | 114 | void setDomainStatus(const bool status); | 
|---|
|  | 115 |  | 
|---|
| [d238e7] | 116 | private: | 
|---|
| [284551] | 117 |  | 
|---|
| [06ebf5] | 118 | GLWorldScene *worldscene; | 
|---|
| [65487f] | 119 |  | 
|---|
|  | 120 | bool changesPresent; | 
|---|
| [3927ef] | 121 | bool processingSelectionChanged; // workaround to prevent a loop in (atom_iterator <-> observer) | 
|---|
| [8880c9] | 122 |  | 
|---|
|  | 123 | QPointF lastMousePos; | 
|---|
| [e8c636] | 124 |  | 
|---|
| [26ed25] | 125 | QGLSceneNode *meshDomainBox; | 
|---|
|  | 126 | QGLSceneNode *meshDreiBein; | 
|---|
|  | 127 |  | 
|---|
| [e8c636] | 128 | QGLMaterial *domainBoxMaterial; | 
|---|
|  | 129 | QGLMaterial *dreiBeinMaterial[3]; | 
|---|
| [585f78] | 130 |  | 
|---|
|  | 131 | QTimer *redrawTimer; | 
|---|
|  | 132 | bool needsRedraw; | 
|---|
| [8e7dd9] | 133 |  | 
|---|
|  | 134 | double defaultEyeSeparation; | 
|---|
| [3f5b0a] | 135 |  | 
|---|
|  | 136 | boost::recursive_mutex changed_mutex; | 
|---|
|  | 137 |  | 
|---|
| [d238e7] | 138 | }; | 
|---|
|  | 139 |  | 
|---|
|  | 140 | #endif /* GLWORLDVIEW_HPP_ */ | 
|---|