[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;
|
---|
[d238e7] | 28 |
|
---|
[2f7988] | 29 | class QtObservedInstanceBoard;
|
---|
[15c8a9] | 30 |
|
---|
[d238e7] | 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 | */
|
---|
[7188b1] | 35 | class GLWorldView : public QGLView, public Observer
|
---|
[d238e7] | 36 | {
|
---|
[06ebf5] | 37 | Q_OBJECT
|
---|
[d238e7] | 38 | public:
|
---|
[15c8a9] | 39 | GLWorldView(
|
---|
[2f7988] | 40 | QtObservedInstanceBoard * _board,
|
---|
[15c8a9] | 41 | QWidget *parent=0);
|
---|
[06ebf5] | 42 | virtual ~GLWorldView();
|
---|
[d238e7] | 43 |
|
---|
[0e5d14] | 44 | void addToolBarActions(QToolBar *toolbar);
|
---|
[26ed25] | 45 | void createDomainBox();
|
---|
| 46 | void createDreiBein();
|
---|
[0e5d14] | 47 |
|
---|
[7188b1] | 48 | // Observer functions
|
---|
| 49 | void update(Observable *publisher);
|
---|
| 50 | void subjectKilled(Observable *publisher);
|
---|
| 51 | void recieveNotification(Observable *publisher, Notification_ptr notification);
|
---|
| 52 |
|
---|
[d238e7] | 53 | public slots:
|
---|
[65487f] | 54 | void changeSignalled();
|
---|
[585f78] | 55 | void checkChanges();
|
---|
| 56 | void sceneChangeSignalled();
|
---|
[704d59] | 57 | void sceneHoverSignalled(const atomId_t _id);
|
---|
| 58 | void sceneHoverSignalled(const moleculeId_t _id, int);
|
---|
[592d42] | 59 | void changeDreiBein();
|
---|
| 60 | void changeDomain();
|
---|
[d238e7] | 61 |
|
---|
[7188b1] | 62 | signals:
|
---|
| 63 | void changed();
|
---|
[ce4126] | 64 | void TimeChanged();
|
---|
[3927ef] | 65 | void worldSelectionChanged();
|
---|
[704d59] | 66 | void hoverChanged(const atomId_t _id);
|
---|
| 67 | void hoverChanged(const moleculeId_t _id, int);
|
---|
[07136a] | 68 | void ShapeAdded(const std::string &);
|
---|
| 69 | void ShapeRemoved(const std::string &);
|
---|
[739ee9] | 70 | void moleculesVisibilityChanged(const moleculeId_t,bool);
|
---|
[7188b1] | 71 |
|
---|
[d238e7] | 72 | protected:
|
---|
[06ebf5] | 73 | void initializeGL(QGLPainter *painter);
|
---|
| 74 | void paintGL(QGLPainter *painter);
|
---|
[e8c636] | 75 | void drawDomainBox(QGLPainter *painter) const;
|
---|
| 76 | void drawDreiBein(QGLPainter *painter);
|
---|
[8880c9] | 77 |
|
---|
| 78 | // input functions
|
---|
| 79 | void mousePressEvent(QMouseEvent *event);
|
---|
| 80 | void mouseMoveEvent(QMouseEvent *event);
|
---|
| 81 | void keyPressEvent(QKeyEvent *event);
|
---|
| 82 | void wheelEvent(QWheelEvent *event);
|
---|
[d238e7] | 83 |
|
---|
[e13b34] | 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();
|
---|
[8e7dd9] | 96 | void setCameraStereoModeDisable();
|
---|
| 97 | void setCameraStereoModeHardware();
|
---|
| 98 | void setCameraStereoModeLeftRight();
|
---|
| 99 | void setCameraStereoModeRightLeft();
|
---|
| 100 | void setCameraStereoModeTopBottom();
|
---|
| 101 | void setCameraStereoModeBottomTop();
|
---|
| 102 | void setCameraStereoModeAnaglyph();
|
---|
[e13b34] | 103 |
|
---|
| 104 | protected:
|
---|
| 105 | CameraControlModeType cameraControlMode;
|
---|
| 106 |
|
---|
[592d42] | 107 | private:
|
---|
| 108 | void setdreiBeinStatus(const bool status);
|
---|
| 109 | void setDomainStatus(const bool status);
|
---|
| 110 |
|
---|
[d238e7] | 111 | private:
|
---|
[284551] | 112 |
|
---|
[06ebf5] | 113 | GLWorldScene *worldscene;
|
---|
[65487f] | 114 |
|
---|
| 115 | bool changesPresent;
|
---|
[3927ef] | 116 | bool processingSelectionChanged; // workaround to prevent a loop in (atom_iterator <-> observer)
|
---|
[8880c9] | 117 |
|
---|
| 118 | QPointF lastMousePos;
|
---|
[e8c636] | 119 |
|
---|
[26ed25] | 120 | QGLSceneNode *meshDomainBox;
|
---|
| 121 | QGLSceneNode *meshDreiBein;
|
---|
| 122 |
|
---|
[e8c636] | 123 | QGLMaterial *domainBoxMaterial;
|
---|
| 124 | QGLMaterial *dreiBeinMaterial[3];
|
---|
[585f78] | 125 |
|
---|
| 126 | QTimer *redrawTimer;
|
---|
| 127 | bool needsRedraw;
|
---|
[8e7dd9] | 128 |
|
---|
| 129 | double defaultEyeSeparation;
|
---|
[d238e7] | 130 | };
|
---|
| 131 |
|
---|
| 132 | #endif /* GLWORLDVIEW_HPP_ */
|
---|