Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLView.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_UI_GLVIEW_H_
21 #define OMNI_UI_GLVIEW_H_
22 
23 #include <set>
24 #include <QOpenGLWidget>
25 #include <QOpenGLFunctions>
26 #include <QOpenGLShaderProgram>
27 #include <QPointF>
28 
29 namespace omni {
30 
31  namespace ui {
32  /**@brief GLView for visualizing tunings or session
33  @detail Holds shared_ptr to session as data model
34  **/
35  class GLView :
36  public QOpenGLWidget,
37  protected QOpenGLFunctions {
38  Q_OBJECT
39 
40  public:
41  explicit GLView(QWidget *_parent = nullptr);
42  virtual ~GLView();
43 
44  /// Return aspect ratio of widget
45  float aspect() const;
46 
47  /// Return mouse position
48  QPointF mousePosition() const;
49 
50  /// Return boolean value if widget has been initialized
51  bool initialized() const;
52 
53  /// Return update frequency
54  float updateFrequency() const;
55 
56  /// Return update frequency
57  void setUpdateFrequency(float _updateFrequency);
58 
59  public slots:
60  void triggerUpdate();
61  inline void paintGLDone() {
62  updateTriggered_ = true;
63  // doneCurrent();
64  }
65 
66  protected:
67  bool updateTriggered_ = false;
68  /// Initialize OpenGL contents
69  void initializeGL();
70 
71  /// Resize GL and viewport
72  virtual void resizeGL(int _w,
73  int _h);
74 
75  /// Paint GL routine
76  virtual void paintGL();
77 
78  /// Mouse press event sets mouse position
79  virtual void mousePressEvent(QMouseEvent *);
80 
81  void timerEvent(QTimerEvent*);
82 
83  void paintGLReady();
84 
85  /// Mouse position stored
86  QPointF mousePosition_;
87 
88  private:
89  /// Pure virtual function to initialize GL contents
90  virtual bool initialize() = 0;
91 
92  /// Is initialized flag is set to true after successful initialization
93  bool initialized_ = false;
94 
95  float updateFreq_ = 0.0;
96  int timerId_ = 0;
97  };
98  }
99 }
100 
101 #endif /* OMNI_UI_GLVIEW_H_ */
void initializeGL()
Initialize OpenGL contents.
Definition: GLView.cpp:95
QPointF mousePosition() const
Return mouse position.
Definition: GLView.cpp:85
virtual ~GLView()
Definition: GLView.cpp:40
float updateFrequency() const
Return update frequency.
Definition: GLView.cpp:58
QPointF mousePosition_
Mouse position stored.
Definition: GLView.h:86
int timerId_
Definition: GLView.h:96
float aspect() const
Return aspect ratio of widget.
Definition: GLView.cpp:80
virtual void paintGL()
Paint GL routine.
Definition: GLView.cpp:118
void triggerUpdate()
Definition: GLView.cpp:46
bool initialized_
Is initialized flag is set to true after successful initialization.
Definition: GLView.h:93
void paintGLDone()
Definition: GLView.h:61
bool initialized() const
Return boolean value if widget has been initialized.
Definition: GLView.cpp:90
virtual void resizeGL(int _w, int _h)
Resize GL and viewport.
Definition: GLView.cpp:105
virtual bool initialize()=0
Pure virtual function to initialize GL contents.
void timerEvent(QTimerEvent *)
Definition: GLView.cpp:52
float updateFreq_
Definition: GLView.h:95
bool updateTriggered_
Definition: GLView.h:67
GLView for visualizing tunings or session Holds shared_ptr to session as data model.
Definition: GLView.h:35
void setUpdateFrequency(float _updateFrequency)
Return update frequency.
Definition: GLView.cpp:62
GLView(QWidget *_parent=nullptr)
Definition: GLView.cpp:35
virtual void mousePressEvent(QMouseEvent *)
Mouse press event sets mouse position.
Definition: GLView.cpp:122