Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
omni::ui::GLView Class Referenceabstract

GLView for visualizing tunings or session Holds shared_ptr to session as data model. More...

#include <GLView.h>

Inheritance diagram for omni::ui::GLView:
Inheritance graph
[legend]
Collaboration diagram for omni::ui::GLView:
Collaboration graph
[legend]

Public Slots

void triggerUpdate ()
 
void paintGLDone ()
 

Public Member Functions

 GLView (QWidget *_parent=nullptr)
 
virtual ~GLView ()
 
float aspect () const
 Return aspect ratio of widget. More...
 
QPointF mousePosition () const
 Return mouse position. More...
 
bool initialized () const
 Return boolean value if widget has been initialized. More...
 
float updateFrequency () const
 Return update frequency. More...
 
void setUpdateFrequency (float _updateFrequency)
 Return update frequency. More...
 

Protected Member Functions

void initializeGL ()
 Initialize OpenGL contents. More...
 
virtual void resizeGL (int _w, int _h)
 Resize GL and viewport. More...
 
virtual void paintGL ()
 Paint GL routine. More...
 
virtual void mousePressEvent (QMouseEvent *)
 Mouse press event sets mouse position. More...
 
void timerEvent (QTimerEvent *)
 
void paintGLReady ()
 

Protected Attributes

bool updateTriggered_ = false
 
QPointF mousePosition_
 Mouse position stored. More...
 

Private Member Functions

virtual bool initialize ()=0
 Pure virtual function to initialize GL contents. More...
 

Private Attributes

bool initialized_ = false
 Is initialized flag is set to true after successful initialization. More...
 
float updateFreq_ = 0.0
 
int timerId_ = 0
 

Detailed Description

GLView for visualizing tunings or session Holds shared_ptr to session as data model.

Constructor & Destructor Documentation

omni::ui::GLView::GLView ( QWidget *  _parent = nullptr)
explicit
35  :
36  QOpenGLWidget(_parent)
37  {
38  }
omni::ui::GLView::~GLView ( )
virtual
41  {
42  // Kill timer
43  setUpdateFrequency(0.0);
44  }
void setUpdateFrequency(float _updateFrequency)
Return update frequency.
Definition: GLView.cpp:62

Member Function Documentation

float omni::ui::GLView::aspect ( ) const

Return aspect ratio of widget.

81  {
82  return (float)width() / height();
83  }
virtual bool omni::ui::GLView::initialize ( )
privatepure virtual

Pure virtual function to initialize GL contents.

Implemented in omni::ui::TuningGLView, omni::ui::InputPreview, omni::ui::SceneGLView, and omni::ui::AboutGL.

bool omni::ui::GLView::initialized ( ) const

Return boolean value if widget has been initialized.

91  {
92  return initialized_;
93  }
bool initialized_
Is initialized flag is set to true after successful initialization.
Definition: GLView.h:93
void omni::ui::GLView::initializeGL ( )
protected

Initialize OpenGL contents.

96  {
97  initializeOpenGLFunctions();
98 
99  makeCurrent();
101 
103  }
void resetOpenGLState()
Reset openGL state to its defaults.
Definition: util.cpp:86
bool initialized_
Is initialized flag is set to true after successful initialization.
Definition: GLView.h:93
virtual bool initialize()=0
Pure virtual function to initialize GL contents.
QPointF omni::ui::GLView::mousePosition ( ) const

Return mouse position.

86  {
87  return mousePosition_;
88  }
QPointF mousePosition_
Mouse position stored.
Definition: GLView.h:86
void omni::ui::GLView::mousePressEvent ( QMouseEvent *  event)
protectedvirtual

Mouse press event sets mouse position.

Reimplemented in omni::ui::TuningGLView, omni::ui::AboutGL, and omni::ui::TestInputPreview.

123  {
124  QOpenGLWidget::mousePressEvent(event);
125  setFocus();
126  mousePosition_ = event->pos();
127 
128  update();
129  }
QPointF mousePosition_
Mouse position stored.
Definition: GLView.h:86
void omni::ui::GLView::paintGL ( )
protectedvirtual

Paint GL routine.

Reimplemented in omni::ui::TuningGLView, omni::ui::InputPreview, omni::ui::SceneGLView, and omni::ui::AboutGL.

119  {
120  }
void omni::ui::GLView::paintGLDone ( )
inlineslot
61  {
62  updateTriggered_ = true;
63  // doneCurrent();
64  }
bool updateTriggered_
Definition: GLView.h:67
void omni::ui::GLView::paintGLReady ( )
protected
void omni::ui::GLView::resizeGL ( int  _w,
int  _h 
)
protectedvirtual

Resize GL and viewport.

Reimplemented in omni::ui::AboutGL.

106  {
107  _w = _w & ~1;
108  _h = _h & ~1;
109  makeCurrent();
110  visual::viewport(this);
111  withCurrentContext([&](QOpenGLFunctions& _) {
112  _.glClearColor(0.0,0.0,0.0,1.0);
113  });
114 
115  update();
116  }
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
void viewport(WIDGET *_widget)
Set viewport for widget.
Definition: util.h:131
void omni::ui::GLView::setUpdateFrequency ( float  _updateFrequency)

Return update frequency.

62  {
63  updateFreq_ = _updateFrequency;
64 
65  if (timerId_) {
66  killTimer(timerId_);
67  timerId_ = 0;
68  }
69 
70  if (updateFreq_ <= 0.0) {
71  return;
72  }
73 
74  int _timerId = startTimer(1000.0 / updateFreq_);
75  if (!timerId_) {
76  timerId_ = _timerId;
77  }
78  }
int timerId_
Definition: GLView.h:96
float updateFreq_
Definition: GLView.h:95
void omni::ui::GLView::timerEvent ( QTimerEvent *  )
protected
52  {
53  if (!updateTriggered_) {
54  update();
55  }
56  }
bool updateTriggered_
Definition: GLView.h:67
void omni::ui::GLView::triggerUpdate ( )
slot
46  {
47  if (updateFreq_ <= 0.0) update();
48 
49  updateTriggered_ = false;
50  }
float updateFreq_
Definition: GLView.h:95
bool updateTriggered_
Definition: GLView.h:67
float omni::ui::GLView::updateFrequency ( ) const

Return update frequency.

58  {
59  return updateFreq_;
60  }
float updateFreq_
Definition: GLView.h:95

Field Documentation

bool omni::ui::GLView::initialized_ = false
private

Is initialized flag is set to true after successful initialization.

QPointF omni::ui::GLView::mousePosition_
protected

Mouse position stored.

int omni::ui::GLView::timerId_ = 0
private
float omni::ui::GLView::updateFreq_ = 0.0
private
bool omni::ui::GLView::updateTriggered_ = false
protected

The documentation for this class was generated from the following files: