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
RevLine 
[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]24class molecule;
[907636]25class QKeyEvent;
26class GLWorldScene;
[d238e7]27class QGLPainter;
[0e5d14]28class QToolBar;
[585f78]29class QTimer;
[d238e7]30
[2f7988]31class 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]39class GLWorldView : public QGLView, public Observer
[d238e7]40{
[06ebf5]41 Q_OBJECT
[d238e7]42public:
[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]57public 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]66signals:
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]76protected:
[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);
96public 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
108protected:
109 CameraControlModeType cameraControlMode;
110
[592d42]111private:
112 void setdreiBeinStatus(const bool status);
113 void setDomainStatus(const bool status);
114
[d238e7]115private:
[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_ */
Note: See TracBrowser for help on using the repository browser.