source: src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp@ 3f5b0a

Candidate_v1.7.0 stable
Last change on this file since 3f5b0a was 3f5b0a, checked in by Frederik Heber <frederik.heber@…>, 5 years ago

Added mutex on changes_present in GLWorldView.

  • this should prevent selections from being not updated immediatelty.
  • This happens because the selections may occur during painting of the WorldView and race conditions of setting change_present.
  • Property mode set to 100644
File size: 3.2 KB
Line 
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
24class molecule;
25class QKeyEvent;
26class GLWorldScene;
27class QGLPainter;
28class QToolBar;
29class QTimer;
30
31class 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 */
39class GLWorldView : public QGLView, public Observer
40{
41 Q_OBJECT
42public:
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
57public 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
66signals:
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
76protected:
77 void initializeGL(QGLPainter *painter);
78 void paintGL(QGLPainter *painter);
79 void drawDomainBox(QGLPainter *painter) const;
80 void drawDreiBein(QGLPainter *painter);
81
82 // input functions
83 void mousePressEvent(QMouseEvent *event);
84 void mouseMoveEvent(QMouseEvent *event);
85 void keyPressEvent(QKeyEvent *event);
86 void wheelEvent(QWheelEvent *event);
87
88 // camera functions
89 enum CameraControlModeType{
90 Rotate,
91 Translate
92 };
93
94 void setCameraControlMode(CameraControlModeType mode);
95 CameraControlModeType getCameraControlMode(bool inverted = false);
96public slots:
97 void fitCameraToDomain();
98 void setCameraControlModeRotation();
99 void setCameraControlModeTranslation();
100 void setCameraStereoModeDisable();
101 void setCameraStereoModeHardware();
102 void setCameraStereoModeLeftRight();
103 void setCameraStereoModeRightLeft();
104 void setCameraStereoModeTopBottom();
105 void setCameraStereoModeBottomTop();
106 void setCameraStereoModeAnaglyph();
107
108protected:
109 CameraControlModeType cameraControlMode;
110
111private:
112 void setdreiBeinStatus(const bool status);
113 void setDomainStatus(const bool status);
114
115private:
116
117 GLWorldScene *worldscene;
118
119 bool changesPresent;
120 bool processingSelectionChanged; // workaround to prevent a loop in (atom_iterator <-> observer)
121
122 QPointF lastMousePos;
123
124 QGLSceneNode *meshDomainBox;
125 QGLSceneNode *meshDreiBein;
126
127 QGLMaterial *domainBoxMaterial;
128 QGLMaterial *dreiBeinMaterial[3];
129
130 QTimer *redrawTimer;
131 bool needsRedraw;
132
133 double defaultEyeSeparation;
134
135 boost::recursive_mutex changed_mutex;
136
137};
138
139#endif /* GLWORLDVIEW_HPP_ */
Note: See TracBrowser for help on using the repository browser.