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

A GLView for visualizing all modes of a projector view (tuning) More...

#include <TuningGLView.h>

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

Public Slots

void setTuningIndex (int)
 Set tuning index from session. More...
 
void setKeepAspectRatio (bool)
 If disabled, screen rect will be stretched over whole widget. More...
 
void setViewOnly (bool)
 If true, this widget does NOT accept user inputs. More...
 
void setShowCursor (bool)
 
void setDrawingEnabled (bool)
 Set flag which tells if projector view is actually drawn Used for activate/deactivate fullscreen view. More...
 
void setBorder (float)
 Set relative border distance. More...
 
void setFullScreenMode (bool)
 Set fullscreen mode. More...
 
void updateWithChildViews ()
 
- Public Slots inherited from omni::ui::GLView
void triggerUpdate ()
 
void paintGLDone ()
 

Signals

void dataModelChanged ()
 

Public Member Functions

 TuningGLView (QWidget *=nullptr)
 
 ~TuningGLView ()
 
bool viewOnly () const
 If disabled, this widget accepts user inputs. More...
 
bool keepAspectRatio () const
 If disabled, screen rect will be stretched over whole widget. More...
 
bool isDrawingEnabled () const
 Flag for toggling drawing. Only black background is shown when false. More...
 
bool showCursor () const
 Returns true if cursor is visible. More...
 
bool fullscreenMode () const
 
float border () const
 Return relative border value. More...
 
void setChildViews (std::set< TuningGLView * >const &)
 
std::set< TuningGLView * > childViews () const
 
- Public Member Functions inherited from omni::ui::GLView
 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...
 
- Public Member Functions inherited from omni::ui::mixin::DataModel< DATAMODEL, SHARED >
 DataModel ()
 
void setDataModel (pointer_type _dataModel)
 Set new data model. More...
 
pointer_type dataModel ()
 Return pointer to data model. More...
 
const pointer_type dataModel () const
 Return pointer to data model (const version) More...
 
virtual void updateFrontend ()
 Push data to frontend widgets and all child widgets. More...
 
virtual void updateDataModel ()
 Update the data model interface. More...
 
- Public Member Functions inherited from omni::ui::mixin::TuningFromIndex< TuningGLView >
 TuningFromIndex (TuningGLView &_widget)
 
int index () const
 
void setIndex (int _index)
 Set index of tuning. More...
 
void setIndexToCurrent ()
 Set index to current index. More...
 
omni::proj::Tuningtuning ()
 Return pointer to tuning. More...
 
omni::proj::Tuning const * tuning () const
 Return pointer to tuning (const version) More...
 
omni::BlendMaskblendMask ()
 Return pointer to blend mask. More...
 
omni::BlendMask const * blendMask () const
 Return pointer to blend mask (const version) More...
 
omni::WarpGridwarpGrid ()
 Return pointer to warp grid. More...
 
omni::WarpGrid const * warpGrid () const
 Return pointer to warp grid (const version) More...
 

Protected Member Functions

void paintGL ()
 Paint GL routine. More...
 
void mouseMoveEvent (QMouseEvent *event)
 
void mousePressEvent (QMouseEvent *event)
 Mouse press event sets mouse position. More...
 
void mouseReleaseEvent (QMouseEvent *event)
 
void wheelEvent (QWheelEvent *event)
 
void keyPressEvent (QKeyEvent *event)
 
void showEvent (QShowEvent *event)
 
- Protected Member Functions inherited from omni::ui::GLView
void initializeGL ()
 Initialize OpenGL contents. More...
 
virtual void resizeGL (int _w, int _h)
 Resize GL and viewport. More...
 
void timerEvent (QTimerEvent *)
 
void paintGLReady ()
 
- Protected Member Functions inherited from omni::ui::mixin::Locked
template<typename F >
void locked (F f)
 Lock widget and execute given functor. More...
 
bool isLocked () const
 Return true if widget is locked. More...
 

Private Member Functions

virtual void dataToFrontend ()
 Pure virtual method which determines how data model is represented in frontend. More...
 
virtual bool frontendToData ()
 Return true if data has changed by front end. More...
 
bool flipped () const
 
void drawOutput (float _blendMaskOpacity, float _inputOpacity=1.0, QColor _color=Qt::white)
 
void drawCanvas ()
 Draw Canvas from Projector's perspective. More...
 
void drawWarpGrid ()
 Draw warp grid with handles while keeping aspect ratio. More...
 
void drawBlendMask ()
 Draw blend mask with stroke buffer. More...
 
void drawTestCard ()
 Draw test card image. More...
 
void drawScreenBorder ()
 Draw screen border (only if widget is not in view only mode) More...
 
void drawColorCorrected ()
 Draw color corrected view (also used in export mode) More...
 
void drawLiveView ()
 Draw fast live view. More...
 
void updateWarpBuffer ()
 Update warp buffer which contains image of projector perspective. More...
 
QRectF viewRect () const
 Get rectangle of orthogonal view frustum. More...
 
QPointF screenPos (QPointF const &_pos) const
 Transform widget position to view position. More...
 
QPointF pixelPos (QPointF const &_pos) const
 
template<typename F >
void drawOnSurface (F f)
 Drawing function for drawing on orthogonal 2D surface within view. More...
 
bool initialize ()
 Initialize OpenGL objects. More...
 

Private Attributes

bool keepAspectRatio_ = false
 Flags which determines if aspect ratio is used when drawing content. More...
 
bool viewOnly_ = false
 Flag determines if user input is not accepted. More...
 
bool drawingEnabled_ = true
 Flag for toggling drawing. Only black background is shown when false. More...
 
bool mouseDown_ = false
 Flag which tells if mouse button is down. More...
 
QPointF cursorPosition_
 Cursor position (is not mouse position when widget is view only) More...
 
QPointF lastStrokePos_
 Last stroke position. More...
 
bool showCursor_ = true
 Show cursor flag (cursor is also shown when widget is view only) More...
 
float leftOverDistance_ = 0.0
 Left over distance value for blend blush. More...
 
float border_ = 0.0
 Relative border. More...
 
bool fullscreenMode_ = false
 True if this widget is shown in fullscreen mode. More...
 
std::set< TuningGLView * > childViews_
 

Additional Inherited Members

- Public Types inherited from omni::ui::mixin::DataModel< DATAMODEL, SHARED >
typedef DATAMODEL data_model_type
 Data type. More...
 
typedef DataModel
< data_model_type, SHARED > 
type
 This type. More...
 
typedef detail::PointerType
< data_model_type, SHARED > 
pointer_type_handler
 Pointer type handler. More...
 
typedef pointer_type_handler::type pointer_type
 Derived pointer type. More...
 
- Protected Attributes inherited from omni::ui::GLView
bool updateTriggered_ = false
 
QPointF mousePosition_
 Mouse position stored. More...
 

Detailed Description

A GLView for visualizing all modes of a projector view (tuning)

Constructor & Destructor Documentation

omni::ui::TuningGLView::TuningGLView ( QWidget *  _parent = nullptr)
30  :
31  GLView(_parent),
32  mixin::TuningFromIndex<TuningGLView>(*this),
33  cursorPosition_(0.0, 0.0)
34  {
35  setViewOnly(false);
36  setFocusPolicy(Qt::StrongFocus);
37  setMouseTracking(showCursor_ && !viewOnly_);
38  }
bool showCursor_
Show cursor flag (cursor is also shown when widget is view only)
Definition: TuningGLView.h:177
QPointF cursorPosition_
Cursor position (is not mouse position when widget is view only)
Definition: TuningGLView.h:171
GLView(QWidget *_parent=nullptr)
Definition: GLView.cpp:35
bool viewOnly_
Flag determines if user input is not accepted.
Definition: TuningGLView.h:162
void setViewOnly(bool)
If true, this widget does NOT accept user inputs.
Definition: TuningGLView.cpp:73
omni::ui::TuningGLView::~TuningGLView ( )
41  {
42  }

Member Function Documentation

float omni::ui::TuningGLView::border ( ) const

Return relative border value.

110  {
111  return border_;
112  }
float border_
Relative border.
Definition: TuningGLView.h:183
std::set< TuningGLView * > omni::ui::TuningGLView::childViews ( ) const
120  {
121  return childViews_;
122  }
std::set< TuningGLView * > childViews_
Definition: TuningGLView.h:188
void omni::ui::TuningGLView::dataModelChanged ( )
signal
void omni::ui::TuningGLView::dataToFrontend ( )
privatevirtual

Pure virtual method which determines how data model is represented in frontend.

Implements omni::ui::mixin::DataModel< DATAMODEL, SHARED >.

627  {
628  makeCurrent();
629  dataModel()->makeVisualizer();
630 
631  if (context() && !initialized()) {
632  initializeGL();
633  }
634  }
void initializeGL()
Initialize OpenGL contents.
Definition: GLView.cpp:95
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
bool initialized() const
Return boolean value if widget has been initialized.
Definition: GLView.cpp:90
void omni::ui::TuningGLView::drawBlendMask ( )
private

Draw blend mask with stroke buffer.

478  {
479  auto & _blendSettings = dataModel()->blendSettings();
480  auto _colorMode = _blendSettings.colorMode();
481  float _inputOpacity = _blendSettings.inputOpacity();
482  QColor _color = tuning()->color();
483 
484  if (_colorMode == BlendSettings::ColorMode::WHITE) {
485  _color = Qt::white;
486  }
487  drawOutput(1.0, _inputOpacity, _color);
488 
489  glDisable(GL_DEPTH_TEST);
490 
491  if ((showCursor_) &&
492  (tuning() == dataModel()->tunings().current())) {
494  }
495  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
bool showCursor_
Show cursor flag (cursor is also shown when widget is view only)
Definition: TuningGLView.h:177
visualizer_type * visualizer()
Return pointer to visualizer.
Definition: Tuning.cpp:135
void drawCursor(QPointF const &_pos)
Draw cursor for blend brush.
Definition: Tuning.cpp:216
QPointF cursorPosition_
Cursor position (is not mouse position when widget is view only)
Definition: TuningGLView.h:171
QColor color() const
Returns color for mapping.
Definition: Tuning.cpp:124
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void drawOutput(float _blendMaskOpacity, float _inputOpacity=1.0, QColor _color=Qt::white)
Definition: TuningGLView.cpp:502
void omni::ui::TuningGLView::drawCanvas ( )
private

Draw Canvas from Projector's perspective.

412  {
413  glMatrixMode(GL_PROJECTION);
414  glLoadIdentity();
415  glMultMatrixf(tuning()->projector().projectionMatrix().constData());
416  glMatrixMode(GL_MODELVIEW);
417 
418  glLoadIdentity();
419 
420  withCurrentContext([this](QOpenGLFunctions& _)
421  {
422  _.glDisable(GL_LIGHTING);
423  _.glDisable(GL_CULL_FACE);
424  _.glEnable(GL_DEPTH_TEST);
425  dataModel()->visualizer()->drawCanvas(mapping::OutputMode::MAPPED_INPUT,
426  tuning()->outputDisabled() &&
427  viewOnly());
428  dataModel()->visualizer()->drawCanvasWireframe();
429  _.glDisable(GL_DEPTH_TEST);
430  });
431  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
bool viewOnly() const
If disabled, this widget accepts user inputs.
Definition: TuningGLView.cpp:68
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::TuningGLView::drawColorCorrected ( )
private

Draw color corrected view (also used in export mode)

520  {
521  drawOutput(
522  1.0 /* draw blend mask with alpha = 1.0 */,
523  1.0 /* draw input */);
524  }
void drawOutput(float _blendMaskOpacity, float _inputOpacity=1.0, QColor _color=Qt::white)
Definition: TuningGLView.cpp:502
void omni::ui::TuningGLView::drawLiveView ( )
private

Draw fast live view.

526  {
528  }
visualizer_type * visualizer()
Return pointer to visualizer.
Definition: Tuning.cpp:135
void drawCalibratedInput(bool _flipped=false)
Definition: Tuning.cpp:411
bool flipped() const
Definition: TuningGLView.cpp:497
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
template<typename F >
void omni::ui::TuningGLView::drawOnSurface ( f)
private

Drawing function for drawing on orthogonal 2D surface within view.

435  {
436  withCurrentContext([&](QOpenGLFunctions& _)
437  {
438  visual::viewport(this);
439  _.glClearColor(0.0, 0.0, 0.0, 1.0);
440  glMatrixMode(GL_PROJECTION);
441  glLoadIdentity();
442  QMatrix4x4 _m;
443  QRectF && _rect = viewRect();
444  _m.ortho(_rect.left(), _rect.right(), _rect.top(), _rect.bottom(), -1.0,
445  1.0);
446 
447  glMultMatrixf(_m.constData());
448  glMatrixMode(GL_MODELVIEW);
449  glLoadIdentity();
450  f(_);
451  });
452  }
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
QRectF viewRect() const
Get rectangle of orthogonal view frustum.
Definition: TuningGLView.cpp:363
void viewport(WIDGET *_widget)
Set viewport for widget.
Definition: util.h:131
void omni::ui::TuningGLView::drawOutput ( float  _blendMaskOpacity,
float  _inputOpacity = 1.0,
QColor  _color = Qt::white 
)
private
504  {
505  tuning()->visualizer()->updateWarpBuffer(dataModel()->visualizer());
506 
507  drawOnSurface([&](QOpenGLFunctions& _)
508  {
510  _inputOpacity, _color, _blendMaskOpacity,
511  tuning()->outputDisabled() && viewOnly());
512 
513  if (!fullscreenMode()) {
515  }
516  });
517  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void drawScreenBorder()
Draw screen border (only if widget is not in view only mode)
Definition: TuningGLView.cpp:530
visualizer_type * visualizer()
Return pointer to visualizer.
Definition: Tuning.cpp:135
void drawOnSurface(F f)
Drawing function for drawing on orthogonal 2D surface within view.
Definition: TuningGLView.cpp:434
void updateWarpBuffer(visual::Session const *_vizSession)
Update warp buffer which contains image of projector perspective.
Definition: Tuning.cpp:351
bool fullscreenMode() const
Definition: TuningGLView.cpp:95
bool viewOnly() const
If disabled, this widget accepts user inputs.
Definition: TuningGLView.cpp:68
void drawOutput(float _inputOpacity=0.0, QColor const &_color=Qt::white, float _blendMaskOpacity=1.0, bool _grayscale=true) const
Draws Blendmask with warp grid and brush stroke layer.
Definition: Tuning.cpp:240
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::TuningGLView::drawScreenBorder ( )
private

Draw screen border (only if widget is not in view only mode)

531  {
532  // Draw screen border rectangle on top
533  if (!viewOnly())
534  {
535  glPolygonMode(GL_FRONT, GL_LINE);
536  glPolygonMode(GL_BACK, GL_LINE);
537  auto _color = tuning()->color();
538  glColor4f(_color.redF(), _color.greenF(), _color.blueF(), 1.0);
540  glPolygonMode(GL_FRONT, GL_FILL);
541  glPolygonMode(GL_BACK, GL_FILL);
542  }
543  }
QColor color() const
Returns color for mapping.
Definition: Tuning.cpp:124
static void draw(float _left=-0.5, float _right=0.5, float _top=0.5, float _bottom=-0.5)
Draw rectangle from border coordinates.
Definition: Rectangle.cpp:28
bool viewOnly() const
If disabled, this widget accepts user inputs.
Definition: TuningGLView.cpp:68
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::TuningGLView::drawTestCard ( )
private

Draw test card image.

546  {
547  drawOnSurface([&](QOpenGLFunctions& _)
548  {
549  tuning()->visualizer()->drawTestCard(index() + 1,
550  tuning()->outputDisabled() &&
551  viewOnly());
552  });
553  }
visualizer_type * visualizer()
Return pointer to visualizer.
Definition: Tuning.cpp:135
void drawOnSurface(F f)
Drawing function for drawing on orthogonal 2D surface within view.
Definition: TuningGLView.cpp:434
int index() const
Definition: TuningFromIndex.h:35
void drawTestCard(int _id, bool _grayscale=false)
Draw Test card image for screen setup.
Definition: Tuning.cpp:50
bool viewOnly() const
If disabled, this widget accepts user inputs.
Definition: TuningGLView.cpp:68
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::TuningGLView::drawWarpGrid ( )
private

Draw warp grid with handles while keeping aspect ratio.

455  {
456  drawOutput(
457  dataModel()->blendSettings().showInWarpMode() ? 1.0 : 0.0 /* zero
458  blend
459  mask
460  opacity
461  */
462  );
463 
464  drawOnSurface([&](QOpenGLFunctions& _)
465  {
466  _.glDisable(GL_LIGHTING);
467  _.glBindTexture(GL_TEXTURE_2D, 0);
468  _.glDisable(GL_COLOR_MATERIAL);
469  _.glEnable(GL_BLEND);
470  _.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
472  _.glEnable(GL_LIGHTING);
473  _.glEnable(GL_COLOR_MATERIAL);
474  });
475  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
visualizer_type * visualizer()
Return pointer to visualizer.
Definition: Tuning.cpp:135
void drawOnSurface(F f)
Drawing function for drawing on orthogonal 2D surface within view.
Definition: TuningGLView.cpp:434
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void drawWarpGrid() const
Draws warp grid with lines and handles.
Definition: Tuning.cpp:65
void drawOutput(float _blendMaskOpacity, float _inputOpacity=1.0, QColor _color=Qt::white)
Definition: TuningGLView.cpp:502
bool omni::ui::TuningGLView::flipped ( ) const
private
497  {
498  return tuning()->projector().setup()->flipped() &&
499  (!fullscreenMode_ || !dataModel()->hasOutput() || dataModel()->mode() == Session::Mode::SCREENSETUP);
500  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
Projector & projector()
Definition: Tuning.cpp:76
bool fullscreenMode_
True if this widget is shown in fullscreen mode.
Definition: TuningGLView.h:186
Setup * setup(Id const &_setupId, float _sceneScale=1.0)
Make a new projector setup with a certain id and delete old one.
Definition: Projector.cpp:40
virtual bool flipped() const =0
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
virtual bool omni::ui::TuningGLView::frontendToData ( )
inlineprivatevirtual

Return true if data has changed by front end.

Implements omni::ui::mixin::DataModel< DATAMODEL, SHARED >.

106  {
107  return false;
108  }
bool omni::ui::TuningGLView::fullscreenMode ( ) const
95  {
96  return fullscreenMode_;
97  }
bool fullscreenMode_
True if this widget is shown in fullscreen mode.
Definition: TuningGLView.h:186
bool omni::ui::TuningGLView::initialize ( )
privatevirtual

Initialize OpenGL objects.

Implements omni::ui::GLView.

350  {
351  dataModel()->makeVisualizer();
352  dataModel()->visualizer()->update();
353 
354  if (dataModel()->canvas()) {
355  dataModel()->canvas()->update();
356  }
357 
358  dataModel()->scene().updateGrid();
359  dataModel()->scene().updateLights();
360  return context() != nullptr;
361  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
bool omni::ui::TuningGLView::isDrawingEnabled ( ) const

Flag for toggling drawing. Only black background is shown when false.

100  {
101  return drawingEnabled_;
102  }
bool drawingEnabled_
Flag for toggling drawing. Only black background is shown when false.
Definition: TuningGLView.h:165
bool omni::ui::TuningGLView::keepAspectRatio ( ) const

If disabled, screen rect will be stretched over whole widget.

58  {
59  return keepAspectRatio_;
60  }
bool keepAspectRatio_
Flags which determines if aspect ratio is used when drawing content.
Definition: TuningGLView.h:159
void omni::ui::TuningGLView::keyPressEvent ( QKeyEvent *  event)
protected
311  {
312  auto _mode = dataModel()->mode();
313 
314  if (_mode == Session::Mode::WARP) {
315  const float _distance = 0.005;
316  auto _moveWarpPoint = [&](float _x, float _y) {
317  auto& _warpGrid = tuning()->warpGrid();
318 
319  auto &&
320  _selectedPoints = _warpGrid.getSelected();
321 
322  for (auto& _p : _selectedPoints) {
323  _p->pos() += QPointF(_x, _y);
324  }
327  };
328 
329  switch (event->key()) {
330  case Qt::Key_Down:
331  _moveWarpPoint(0.0, _distance);
332  break;
333 
334  case Qt::Key_Up:
335  _moveWarpPoint(0.0, -_distance);
336  break;
337 
338  case Qt::Key_Left:
339  _moveWarpPoint(-_distance, 0.0);
340  break;
341 
342  case Qt::Key_Right:
343  _moveWarpPoint(_distance, 0.0);
344  break;
345  }
346  }
347  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
visualizer_type * visualizer()
Return pointer to visualizer.
Definition: Tuning.cpp:135
void updateWithChildViews()
Definition: TuningGLView.cpp:124
WarpGrid & warpGrid()
Returns reference to warp grid.
Definition: Tuning.cpp:86
std::set< WarpPoint * > getSelected()
Returns pointer set of selected points.
Definition: WarpGrid.cpp:180
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void updateWarpGrid()
Update warp grid mesh.
Definition: Tuning.cpp:342
void omni::ui::TuningGLView::mouseMoveEvent ( QMouseEvent *  event)
protected
141  {
142  if (!dataModel() || !tuning() || (viewOnly() && !showCursor_)) return;
143 
144  auto && _rect = viewRect();
145  float dx = float(event->x() - mousePosition().x()) / width() *
146  _rect.width();
147  float dy = float(event->y() - mousePosition().y()) / height() *
148  _rect.height();
149 
150  auto _mode = dataModel()->mode();
151 
152  if (mouseDown_)
153  {
154  auto& _warpGrid = tuning()->warpGrid();
155 
156  // Manipulate selected warp grid point, when mouse button is pressed
157  if (_mode == Session::Mode::WARP)
158  {
159  auto && _selectedPoints = _warpGrid.getSelected();
160 
161  for (auto& _selected : _selectedPoints)
162  {
163  _selected->pos() += QPointF(dx, -dy);
164  }
165  auto *_vizTuning = tuning()->visualizer();
166  _vizTuning->updateWarpGrid();
168  }
169  else if (_mode == Session::Mode::BLEND)
170  {
171  auto _from = pixelPos(mousePosition_).toPoint();
172  auto _to = pixelPos(event->pos()).toPoint();
173 
174  if (!(event->modifiers() & Qt::ShiftModifier)) {
176  _to,
178  lastStrokePos_ = _from;
179  }
180 
181  for (auto& _childView : childViews_)
182  {
183  _childView->cursorPosition_ = cursorPosition_;
184  }
185 
186  auto *_vizTuning = tuning()->visualizer();
187  _vizTuning->setBlendTextureUpdateRect(QRect(_from, _to));
188  _vizTuning->updateBlendTexture();
190  }
191  }
192 
193  mousePosition_ = event->pos();
195 
196  if (!mouseDown_ && showCursor())
197  {
198  for (auto& _childView : childViews_)
199  {
200  _childView->cursorPosition_ = cursorPosition_;
201 
202  if (_childView->showCursor()) _childView->triggerUpdate();
203  }
204  triggerUpdate();
205  }
206  }
void setBlendTextureUpdateRect(QRect const &)
Set portion of blend mask which is to be updated.
Definition: Tuning.cpp:130
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
bool showCursor_
Show cursor flag (cursor is also shown when widget is view only)
Definition: TuningGLView.h:177
visualizer_type * visualizer()
Return pointer to visualizer.
Definition: Tuning.cpp:135
void updateWithChildViews()
Definition: TuningGLView.cpp:124
QPointF cursorPosition_
Cursor position (is not mouse position when widget is view only)
Definition: TuningGLView.h:171
std::set< TuningGLView * > childViews_
Definition: TuningGLView.h:188
bool showCursor() const
Returns true if cursor is visible.
Definition: TuningGLView.cpp:90
QPointF mousePosition() const
Return mouse position.
Definition: GLView.cpp:85
WarpGrid & warpGrid()
Returns reference to warp grid.
Definition: Tuning.cpp:86
QPointF mousePosition_
Mouse position stored.
Definition: GLView.h:86
QPointF screenPos(QPointF const &_pos) const
Transform widget position to view position.
Definition: TuningGLView.cpp:392
float leftOverDistance_
Left over distance value for blend blush.
Definition: TuningGLView.h:180
BlendMask & blendMask()
Returns reference to blend mask.
Definition: Tuning.cpp:96
std::set< WarpPoint * > getSelected()
Returns pointer set of selected points.
Definition: WarpGrid.cpp:180
bool viewOnly() const
If disabled, this widget accepts user inputs.
Definition: TuningGLView.cpp:68
QRectF viewRect() const
Get rectangle of orthogonal view frustum.
Definition: TuningGLView.cpp:363
void triggerUpdate()
Definition: GLView.cpp:46
QPointF lastStrokePos_
Last stroke position.
Definition: TuningGLView.h:174
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
float drawLine(QPointF const &_p0, QPointF const &_p1, float _leftOver=0.0)
Draws a line on stroke buffer.
Definition: BlendMask.cpp:118
bool mouseDown_
Flag which tells if mouse button is down.
Definition: TuningGLView.h:168
QPointF pixelPos(QPointF const &_pos) const
Definition: TuningGLView.cpp:401
void updateWarpGrid()
Update warp grid mesh.
Definition: Tuning.cpp:342
void omni::ui::TuningGLView::mousePressEvent ( QMouseEvent *  event)
protectedvirtual

Mouse press event sets mouse position.

Reimplemented from omni::ui::GLView.

209  {
210  QOpenGLWidget::mousePressEvent(event);
211 
212  if (!dataModel() || !tuning() || viewOnly()) return;
213 
214  this->mousePosition_ = event->pos();
215  auto && _newPos = screenPos(this->mousePosition_);
216  mouseDown_ = true;
217 
218  auto _mode = dataModel()->mode();
219 
220  if (_mode == Session::Mode::WARP)
221  {
222  auto& _warpGrid = tuning()->warpGrid();
223 
224  auto && _selectedPoints = _warpGrid.getSelected();
225  auto _p = _warpGrid.selectNearest(QPointF(_newPos.x(), _newPos.y()));
226 
227  if (!_p) return;
228 
229  // Deselect points if ctrl key is not pressed
230  if (!(event->modifiers() & Qt::ControlModifier))
231  {
232  _warpGrid.selectNone();
233  }
234 
235  // Select point if it is not selected already or
236  // number of selected point is larger than 1
237  _p->setSelected(!_p->selected() || (_selectedPoints.size() > 1));
238  }
239  else if (_mode == Session::Mode::BLEND)
240  {
241  bool _inv = tuning()->blendMask().brush().invert();
243 
244  // Invert brush on right click
245  if (event->button() == Qt::RightButton)
246  {
247  tuning()->blendMask().invertBrush(!_inv);
248  }
249 
250  auto& _blendMask = tuning()->blendMask();
251  _blendMask.stamp(pixelPos(event->pos()));
252 
253  auto *_vizTuning = tuning()->visualizer();
254  _vizTuning->updateBlendTexture();
255 
256  leftOverDistance_ = 0.0;
257  }
258 
259  for (auto& _childView : childViews_)
260  {
261  _childView->cursorPosition_ = cursorPosition_;
262  }
264  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
visualizer_type * visualizer()
Return pointer to visualizer.
Definition: Tuning.cpp:135
void updateWithChildViews()
Definition: TuningGLView.cpp:124
QPointF cursorPosition_
Cursor position (is not mouse position when widget is view only)
Definition: TuningGLView.h:171
std::set< TuningGLView * > childViews_
Definition: TuningGLView.h:188
WarpGrid & warpGrid()
Returns reference to warp grid.
Definition: Tuning.cpp:86
QPointF mousePosition_
Mouse position stored.
Definition: GLView.h:86
QPointF screenPos(QPointF const &_pos) const
Transform widget position to view position.
Definition: TuningGLView.cpp:392
float leftOverDistance_
Left over distance value for blend blush.
Definition: TuningGLView.h:180
BlendMask & blendMask()
Returns reference to blend mask.
Definition: Tuning.cpp:96
void stamp(const QPointF &_pos)
Stamp on stroke buffer with current brush at position x y.
Definition: BlendMask.cpp:113
std::set< WarpPoint * > getSelected()
Returns pointer set of selected points.
Definition: WarpGrid.cpp:180
void updateBlendTexture()
Updates blend texture after it has changed by blend brush.
Definition: Tuning.cpp:142
void invertBrush(bool)
Invert brush.
Definition: BlendMask.cpp:93
bool viewOnly() const
If disabled, this widget accepts user inputs.
Definition: TuningGLView.cpp:68
BlendBrush const & brush() const
Return reference blend brush (const version)
Definition: BlendMask.cpp:104
QPointF lastStrokePos_
Last stroke position.
Definition: TuningGLView.h:174
bool invert() const
Returns true if the brush is inverted (aka eraser mode)
Definition: BlendBrush.cpp:89
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
bool mouseDown_
Flag which tells if mouse button is down.
Definition: TuningGLView.h:168
QPointF pixelPos(QPointF const &_pos) const
Definition: TuningGLView.cpp:401
void omni::ui::TuningGLView::mouseReleaseEvent ( QMouseEvent *  event)
protected
267  {
268  if (!dataModel() || !tuning() || viewOnly()) return;
269 
270  mouseDown_ = false;
271  auto _mode = dataModel()->mode();
272 
273  if (_mode == Session::Mode::BLEND)
274  {
275  if (event->modifiers() & Qt::ShiftModifier) {
276  auto _from = lastStrokePos_;
277  auto _to = pixelPos(event->pos()).toPoint();
278  tuning()->blendMask().drawLine(_from, _to, leftOverDistance_);
279  }
280  leftOverDistance_ = 0.0;
281 
282  // Invert brush on right click
283  bool _inv = tuning()->blendMask().brush().invert();
284 
285  if (event->button() == Qt::RightButton)
286  {
287  tuning()->blendMask().invertBrush(!_inv);
288  }
289  }
290  this->mousePosition_ = event->pos();
292 
294  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void updateWithChildViews()
Definition: TuningGLView.cpp:124
QPointF cursorPosition_
Cursor position (is not mouse position when widget is view only)
Definition: TuningGLView.h:171
QPointF mousePosition_
Mouse position stored.
Definition: GLView.h:86
QPointF screenPos(QPointF const &_pos) const
Transform widget position to view position.
Definition: TuningGLView.cpp:392
float leftOverDistance_
Left over distance value for blend blush.
Definition: TuningGLView.h:180
BlendMask & blendMask()
Returns reference to blend mask.
Definition: Tuning.cpp:96
void invertBrush(bool)
Invert brush.
Definition: BlendMask.cpp:93
bool viewOnly() const
If disabled, this widget accepts user inputs.
Definition: TuningGLView.cpp:68
BlendBrush const & brush() const
Return reference blend brush (const version)
Definition: BlendMask.cpp:104
QPointF lastStrokePos_
Last stroke position.
Definition: TuningGLView.h:174
bool invert() const
Returns true if the brush is inverted (aka eraser mode)
Definition: BlendBrush.cpp:89
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
float drawLine(QPointF const &_p0, QPointF const &_p1, float _leftOver=0.0)
Draws a line on stroke buffer.
Definition: BlendMask.cpp:118
bool mouseDown_
Flag which tells if mouse button is down.
Definition: TuningGLView.h:168
QPointF pixelPos(QPointF const &_pos) const
Definition: TuningGLView.cpp:401
void omni::ui::TuningGLView::paintGL ( )
protectedvirtual

Paint GL routine.

Reimplemented from omni::ui::GLView.

571  {
572  if (!tuning() || !tuning()->visualizer()) return;
573  makeCurrent();
574 
575  auto *_vizSession = dataModel()->visualizer();
576  if (!_vizSession) return;
577 
578  withCurrentContext([&](QOpenGLFunctions& _)
579  {
580  _.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
581 
582  visual::viewport(this);
583  _.glClearColor(0.0, 0.0, 0.0, 1.0);
584  if (!dataModel()->hasOutput())
585  {
586  drawTestCard();
587  return;
588  }
589 
590  if (tuning()->outputDisabled() && this->fullscreenMode()) return;
591 
592  switch (dataModel()->mode())
593  {
595  drawTestCard();
596  break;
597 
599  drawCanvas();
600  break;
601 
602  case Session::Mode::WARP:
603  drawWarpGrid();
604  break;
605 
607  drawBlendMask();
608  break;
609 
613  break;
614 
615  case Session::Mode::LIVE:
616  drawLiveView();
617  break;
618 
619  default: break;
620  }
621  });
622 
623  paintGLDone();
624  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void drawTestCard()
Draw test card image.
Definition: TuningGLView.cpp:545
void drawLiveView()
Draw fast live view.
Definition: TuningGLView.cpp:526
bool fullscreenMode() const
Definition: TuningGLView.cpp:95
void drawBlendMask()
Draw blend mask with stroke buffer.
Definition: TuningGLView.cpp:477
void drawCanvas()
Draw Canvas from Projector's perspective.
Definition: TuningGLView.cpp:411
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
void paintGLDone()
Definition: GLView.h:61
void drawWarpGrid()
Draw warp grid with handles while keeping aspect ratio.
Definition: TuningGLView.cpp:454
void drawColorCorrected()
Draw color corrected view (also used in export mode)
Definition: TuningGLView.cpp:519
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void viewport(WIDGET *_widget)
Set viewport for widget.
Definition: util.h:131
QPointF omni::ui::TuningGLView::pixelPos ( QPointF const &  _pos) const
private
402  {
403  if (!tuning()) return QPointF(0, 0);
404 
405  auto && _s = screenPos(QPointF(_pos.x(), _pos.y()));
406  return QPointF(
407  float(_s.x() + 0.5) * tuning()->width(),
408  float(_s.y() + 0.5) * tuning()->height());
409  }
QPointF screenPos(QPointF const &_pos) const
Transform widget position to view position.
Definition: TuningGLView.cpp:392
int height() const
Returns height of screen.
Definition: Tuning.cpp:192
int width() const
Returns width of screen.
Definition: Tuning.cpp:187
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
QPointF omni::ui::TuningGLView::screenPos ( QPointF const &  _pos) const
private

Transform widget position to view position.

393  {
394  QRectF && _rect = viewRect();
395  QPointF _p = QPointF(_pos.x() / width() - 0.5, _pos.y() / height() - 0.5);
396 
397 
398  return QPointF(_p.x() * _rect.width(), -_p.y() * _rect.height());
399  }
QRectF viewRect() const
Get rectangle of orthogonal view frustum.
Definition: TuningGLView.cpp:363
void omni::ui::TuningGLView::setBorder ( float  _border)
slot

Set relative border distance.

135  {
136  border_ = _border;
137  triggerUpdate();
138  }
float border_
Relative border.
Definition: TuningGLView.h:183
void triggerUpdate()
Definition: GLView.cpp:46
void omni::ui::TuningGLView::setChildViews ( std::set< TuningGLView * >const &  _childViews)
115  {
116  childViews_ = _childViews;
117  }
std::set< TuningGLView * > childViews_
Definition: TuningGLView.h:188
void omni::ui::TuningGLView::setDrawingEnabled ( bool  _drawingEnabled)
slot

Set flag which tells if projector view is actually drawn Used for activate/deactivate fullscreen view.

105  {
106  drawingEnabled_ = _drawingEnabled;
107  }
bool drawingEnabled_
Flag for toggling drawing. Only black background is shown when false.
Definition: TuningGLView.h:165
void omni::ui::TuningGLView::setFullScreenMode ( bool  _fullscreenMode)
slot

Set fullscreen mode.

85  {
86  fullscreenMode_ = _fullscreenMode;
87  triggerUpdate();
88  }
bool fullscreenMode_
True if this widget is shown in fullscreen mode.
Definition: TuningGLView.h:186
void triggerUpdate()
Definition: GLView.cpp:46
void omni::ui::TuningGLView::setKeepAspectRatio ( bool  _keepAspectRatio)
slot

If disabled, screen rect will be stretched over whole widget.

63  {
64  keepAspectRatio_ = _keepAspectRatio;
65  sizePolicy().setHeightForWidth(keepAspectRatio_);
66  }
bool keepAspectRatio_
Flags which determines if aspect ratio is used when drawing content.
Definition: TuningGLView.h:159
void omni::ui::TuningGLView::setShowCursor ( bool  _showCursor)
slot
80  {
81  showCursor_ = _showCursor;
82  setMouseTracking(showCursor_ && !viewOnly_);
83  }
bool showCursor_
Show cursor flag (cursor is also shown when widget is view only)
Definition: TuningGLView.h:177
bool viewOnly_
Flag determines if user input is not accepted.
Definition: TuningGLView.h:162
void omni::ui::TuningGLView::setTuningIndex ( int  _index)
slot

Set tuning index from session.

45  {
46  setIndex(_index);
47  auto *_tuning = tuning();
48 
49  if (!_tuning) return;
50 
51  if (_tuning->makeVisualizer()) {
52  _tuning->visualizer()->update();
53  update();
54  }
55  }
void setIndex(int _index)
Set index of tuning.
Definition: TuningFromIndex.h:44
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::TuningGLView::setViewOnly ( bool  _viewOnly)
slot

If true, this widget does NOT accept user inputs.

74  {
75  viewOnly_ = _viewOnly;
76  setMouseTracking(showCursor_ && !viewOnly_);
77  }
bool showCursor_
Show cursor flag (cursor is also shown when widget is view only)
Definition: TuningGLView.h:177
bool viewOnly_
Flag determines if user input is not accepted.
Definition: TuningGLView.h:162
bool omni::ui::TuningGLView::showCursor ( ) const

Returns true if cursor is visible.

91  {
92  return showCursor_;
93  }
bool showCursor_
Show cursor flag (cursor is also shown when widget is view only)
Definition: TuningGLView.h:177
void omni::ui::TuningGLView::showEvent ( QShowEvent *  event)
protected
555  {
556 
557  makeCurrent();
558  dataModel()->makeVisualizer()->update();
559 
560  if (dataModel()->canvas()) {
561  dataModel()->canvas()->update();
562  }
563 
564  dataModel()->scene().updateGrid();
565  dataModel()->scene().updateLights();
566 
567  triggerUpdate();
568  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void triggerUpdate()
Definition: GLView.cpp:46
void omni::ui::TuningGLView::updateWarpBuffer ( )
private

Update warp buffer which contains image of projector perspective.

void omni::ui::TuningGLView::updateWithChildViews ( )
slot
125  {
126  triggerUpdate();
127 
128  for (auto& _childView : childViews_)
129  {
130  _childView->triggerUpdate();
131  }
132  }
std::set< TuningGLView * > childViews_
Definition: TuningGLView.h:188
void triggerUpdate()
Definition: GLView.cpp:46
bool omni::ui::TuningGLView::viewOnly ( ) const

If disabled, this widget accepts user inputs.

69  {
70  return viewOnly_;
71  }
bool viewOnly_
Flag determines if user input is not accepted.
Definition: TuningGLView.h:162
QRectF omni::ui::TuningGLView::viewRect ( ) const
private

Get rectangle of orthogonal view frustum.

364  {
365  float _projAspect = float(tuning()->width()) / tuning()->height();
366  float _viewAspect = float(width()) / height();
367  float b = border_ * 0.5;
368  float _left = -0.5 - b, _right = 0.5 + b, _bottom = -0.5 - b,
369  _top = 0.5 + b;
370 
371  if (keepAspectRatio())
372  {
373  if (_projAspect > _viewAspect)
374  {
375  _top *= _projAspect / _viewAspect;
376  _bottom *= _projAspect / _viewAspect;
377  }
378  else
379  {
380  _left *= _viewAspect / _projAspect;
381  _right *= _viewAspect / _projAspect;
382  }
383  }
384 
385  if (flipped()) {
386  std::swap(_left,_right);
387  std::swap(_top,_bottom);
388  }
389  return QRectF(QPointF(_left, _top), QPointF(_right, _bottom));
390  }
float border_
Relative border.
Definition: TuningGLView.h:183
int height() const
Returns height of screen.
Definition: Tuning.cpp:192
bool flipped() const
Definition: TuningGLView.cpp:497
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
bool keepAspectRatio() const
If disabled, screen rect will be stretched over whole widget.
Definition: TuningGLView.cpp:57
void omni::ui::TuningGLView::wheelEvent ( QWheelEvent *  event)
protected
297  {
298  if (!dataModel()) return;
299 
300  auto _mode = dataModel()->mode();
301 
302  if (_mode == Session::Mode::BLEND)
303  {
304  auto& _blendMask = tuning()->blendMask();
305  _blendMask.changeBrushSize(event->delta() / 5.0);
307  }
308  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void updateWithChildViews()
Definition: TuningGLView.cpp:124
BlendMask & blendMask()
Returns reference to blend mask.
Definition: Tuning.cpp:96
void changeBrushSize(float _delta)
Change brush size by +- amount of pixel.
Definition: BlendMask.cpp:98
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54

Field Documentation

float omni::ui::TuningGLView::border_ = 0.0
private

Relative border.

std::set<TuningGLView *> omni::ui::TuningGLView::childViews_
private
QPointF omni::ui::TuningGLView::cursorPosition_
private

Cursor position (is not mouse position when widget is view only)

bool omni::ui::TuningGLView::drawingEnabled_ = true
private

Flag for toggling drawing. Only black background is shown when false.

bool omni::ui::TuningGLView::fullscreenMode_ = false
private

True if this widget is shown in fullscreen mode.

bool omni::ui::TuningGLView::keepAspectRatio_ = false
private

Flags which determines if aspect ratio is used when drawing content.

QPointF omni::ui::TuningGLView::lastStrokePos_
private

Last stroke position.

float omni::ui::TuningGLView::leftOverDistance_ = 0.0
private

Left over distance value for blend blush.

bool omni::ui::TuningGLView::mouseDown_ = false
private

Flag which tells if mouse button is down.

bool omni::ui::TuningGLView::showCursor_ = true
private

Show cursor flag (cursor is also shown when widget is view only)

bool omni::ui::TuningGLView::viewOnly_ = false
private

Flag determines if user input is not accepted.


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