[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 |
|
---|
[3e93332] | 22 | class molecule;
|
---|
[907636] | 23 | class QKeyEvent;
|
---|
| 24 | class GLWorldScene;
|
---|
[d238e7] | 25 | class QGLPainter;
|
---|
[0e5d14] | 26 | class QToolBar;
|
---|
[585f78] | 27 | class QTimer;
|
---|
[015f8c] | 28 | class QtSelectionChangedAgent;
|
---|
[d238e7] | 29 |
|
---|
[15c8a9] | 30 | class QtInstanceInformationBoard;
|
---|
| 31 |
|
---|
[d238e7] | 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 | */
|
---|
[7188b1] | 36 | class GLWorldView : public QGLView, public Observer
|
---|
[d238e7] | 37 | {
|
---|
[06ebf5] | 38 | Q_OBJECT
|
---|
[d238e7] | 39 | public:
|
---|
[15c8a9] | 40 | GLWorldView(
|
---|
| 41 | QtInstanceInformationBoard * _board,
|
---|
| 42 | QWidget *parent=0);
|
---|
[06ebf5] | 43 | virtual ~GLWorldView();
|
---|
[d238e7] | 44 |
|
---|
[0e5d14] | 45 | void addToolBarActions(QToolBar *toolbar);
|
---|
[26ed25] | 46 | void createDomainBox();
|
---|
| 47 | void createDreiBein();
|
---|
[0e5d14] | 48 |
|
---|
[015f8c] | 49 | void setSelectionChangedAgent(QtSelectionChangedAgent *agent);
|
---|
| 50 |
|
---|
[7188b1] | 51 | // Observer functions
|
---|
| 52 | void update(Observable *publisher);
|
---|
| 53 | void subjectKilled(Observable *publisher);
|
---|
| 54 | void recieveNotification(Observable *publisher, Notification_ptr notification);
|
---|
| 55 |
|
---|
[d238e7] | 56 | public slots:
|
---|
[65487f] | 57 | void changeSignalled();
|
---|
[585f78] | 58 | void checkChanges();
|
---|
| 59 | void sceneChangeSignalled();
|
---|
[704d59] | 60 | void sceneHoverSignalled(const atomId_t _id);
|
---|
| 61 | void sceneHoverSignalled(const moleculeId_t _id, int);
|
---|
[592d42] | 62 | void changeDreiBein();
|
---|
| 63 | void changeDomain();
|
---|
[d238e7] | 64 |
|
---|
[7188b1] | 65 | signals:
|
---|
| 66 | void changed();
|
---|
[ce4126] | 67 | void TimeChanged();
|
---|
[9c259e] | 68 | void atomInserted(const moleculeId_t _molid, const atomId_t _atomid);
|
---|
| 69 | void atomRemoved(const moleculeId_t _molid, const atomId_t _atomid);
|
---|
[ef3013] | 70 | void moleculeInserted(const moleculeId_t _id);
|
---|
[8c001a] | 71 | void moleculeRemoved(const moleculeId_t _id);
|
---|
[3927ef] | 72 | void worldSelectionChanged();
|
---|
[704d59] | 73 | void hoverChanged(const atomId_t _id);
|
---|
| 74 | void hoverChanged(const moleculeId_t _id, int);
|
---|
[07136a] | 75 | void ShapeAdded(const std::string &);
|
---|
| 76 | void ShapeRemoved(const std::string &);
|
---|
[739ee9] | 77 | void moleculesVisibilityChanged(const moleculeId_t,bool);
|
---|
[7188b1] | 78 |
|
---|
[d238e7] | 79 | protected:
|
---|
[06ebf5] | 80 | void initializeGL(QGLPainter *painter);
|
---|
| 81 | void paintGL(QGLPainter *painter);
|
---|
[e8c636] | 82 | void drawDomainBox(QGLPainter *painter) const;
|
---|
| 83 | void drawDreiBein(QGLPainter *painter);
|
---|
[8880c9] | 84 |
|
---|
| 85 | // input functions
|
---|
| 86 | void mousePressEvent(QMouseEvent *event);
|
---|
| 87 | void mouseMoveEvent(QMouseEvent *event);
|
---|
| 88 | void keyPressEvent(QKeyEvent *event);
|
---|
| 89 | void wheelEvent(QWheelEvent *event);
|
---|
[d238e7] | 90 |
|
---|
[e13b34] | 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();
|
---|
[8e7dd9] | 103 | void setCameraStereoModeDisable();
|
---|
| 104 | void setCameraStereoModeHardware();
|
---|
| 105 | void setCameraStereoModeLeftRight();
|
---|
| 106 | void setCameraStereoModeRightLeft();
|
---|
| 107 | void setCameraStereoModeTopBottom();
|
---|
| 108 | void setCameraStereoModeBottomTop();
|
---|
| 109 | void setCameraStereoModeAnaglyph();
|
---|
[e13b34] | 110 |
|
---|
| 111 | protected:
|
---|
| 112 | CameraControlModeType cameraControlMode;
|
---|
| 113 |
|
---|
[592d42] | 114 | private:
|
---|
| 115 | void setdreiBeinStatus(const bool status);
|
---|
| 116 | void setDomainStatus(const bool status);
|
---|
| 117 |
|
---|
[9c259e] | 118 | void signOnToMolecule(const molecule *_mol);
|
---|
| 119 | void signOffFromMolecule(const molecule *_mol);
|
---|
| 120 |
|
---|
[d238e7] | 121 | private:
|
---|
[284551] | 122 |
|
---|
[06ebf5] | 123 | GLWorldScene *worldscene;
|
---|
[65487f] | 124 |
|
---|
| 125 | bool changesPresent;
|
---|
[3927ef] | 126 | bool processingSelectionChanged; // workaround to prevent a loop in (atom_iterator <-> observer)
|
---|
[8880c9] | 127 |
|
---|
| 128 | QPointF lastMousePos;
|
---|
[e8c636] | 129 |
|
---|
[26ed25] | 130 | QGLSceneNode *meshDomainBox;
|
---|
| 131 | QGLSceneNode *meshDreiBein;
|
---|
| 132 |
|
---|
[e8c636] | 133 | QGLMaterial *domainBoxMaterial;
|
---|
| 134 | QGLMaterial *dreiBeinMaterial[3];
|
---|
[585f78] | 135 |
|
---|
| 136 | QTimer *redrawTimer;
|
---|
| 137 | bool needsRedraw;
|
---|
[8e7dd9] | 138 |
|
---|
| 139 | double defaultEyeSeparation;
|
---|
[9c259e] | 140 |
|
---|
| 141 | typedef std::multiset<molecule *> ObservedMolecules_t;
|
---|
| 142 | //!> sorted list of molecules we are sign on to
|
---|
| 143 | ObservedMolecules_t ObservedMolecules;
|
---|
[d238e7] | 144 | };
|
---|
| 145 |
|
---|
| 146 | #endif /* GLWORLDVIEW_HPP_ */
|
---|