| [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);
|
|---|
| [7188b1] | 75 |
|
|---|
| [d238e7] | 76 | protected:
|
|---|
| [06ebf5] | 77 | void initializeGL(QGLPainter *painter);
|
|---|
| 78 | void paintGL(QGLPainter *painter);
|
|---|
| [e8c636] | 79 | void drawDomainBox(QGLPainter *painter) const;
|
|---|
| 80 | void drawDreiBein(QGLPainter *painter);
|
|---|
| [8880c9] | 81 |
|
|---|
| 82 | // input functions
|
|---|
| 83 | void mousePressEvent(QMouseEvent *event);
|
|---|
| 84 | void mouseMoveEvent(QMouseEvent *event);
|
|---|
| 85 | void keyPressEvent(QKeyEvent *event);
|
|---|
| 86 | void wheelEvent(QWheelEvent *event);
|
|---|
| [d238e7] | 87 |
|
|---|
| [e13b34] | 88 | // camera functions
|
|---|
| 89 | enum CameraControlModeType{
|
|---|
| 90 | Rotate,
|
|---|
| 91 | Translate
|
|---|
| 92 | };
|
|---|
| 93 |
|
|---|
| 94 | void setCameraControlMode(CameraControlModeType mode);
|
|---|
| 95 | CameraControlModeType getCameraControlMode(bool inverted = false);
|
|---|
| 96 | public slots:
|
|---|
| 97 | void fitCameraToDomain();
|
|---|
| 98 | void setCameraControlModeRotation();
|
|---|
| 99 | void setCameraControlModeTranslation();
|
|---|
| [8e7dd9] | 100 | void setCameraStereoModeDisable();
|
|---|
| 101 | void setCameraStereoModeHardware();
|
|---|
| 102 | void setCameraStereoModeLeftRight();
|
|---|
| 103 | void setCameraStereoModeRightLeft();
|
|---|
| 104 | void setCameraStereoModeTopBottom();
|
|---|
| 105 | void setCameraStereoModeBottomTop();
|
|---|
| 106 | void setCameraStereoModeAnaglyph();
|
|---|
| [e13b34] | 107 |
|
|---|
| 108 | protected:
|
|---|
| 109 | CameraControlModeType cameraControlMode;
|
|---|
| 110 |
|
|---|
| [592d42] | 111 | private:
|
|---|
| 112 | void setdreiBeinStatus(const bool status);
|
|---|
| 113 | void setDomainStatus(const bool status);
|
|---|
| 114 |
|
|---|
| [d238e7] | 115 | private:
|
|---|
| [284551] | 116 |
|
|---|
| [06ebf5] | 117 | GLWorldScene *worldscene;
|
|---|
| [65487f] | 118 |
|
|---|
| 119 | bool changesPresent;
|
|---|
| [3927ef] | 120 | bool processingSelectionChanged; // workaround to prevent a loop in (atom_iterator <-> observer)
|
|---|
| [8880c9] | 121 |
|
|---|
| 122 | QPointF lastMousePos;
|
|---|
| [e8c636] | 123 |
|
|---|
| [26ed25] | 124 | QGLSceneNode *meshDomainBox;
|
|---|
| 125 | QGLSceneNode *meshDreiBein;
|
|---|
| 126 |
|
|---|
| [e8c636] | 127 | QGLMaterial *domainBoxMaterial;
|
|---|
| 128 | QGLMaterial *dreiBeinMaterial[3];
|
|---|
| [585f78] | 129 |
|
|---|
| 130 | QTimer *redrawTimer;
|
|---|
| 131 | bool needsRedraw;
|
|---|
| [8e7dd9] | 132 |
|
|---|
| 133 | double defaultEyeSeparation;
|
|---|
| [3f5b0a] | 134 |
|
|---|
| 135 | boost::recursive_mutex changed_mutex;
|
|---|
| 136 |
|
|---|
| [d238e7] | 137 | };
|
|---|
| 138 |
|
|---|
| 139 | #endif /* GLWORLDVIEW_HPP_ */
|
|---|