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

Widget for manipulating projector parameters Also holds a preview OpenGL widget. More...

#include <Tuning.h>

Inheritance diagram for omni::ui::proj::Tuning:
Inheritance graph
[legend]
Collaboration diagram for omni::ui::proj::Tuning:
Collaboration graph
[legend]

Public Types

enum  WindowState {
  NO_DISPLAY, DISPLAY_ONLY, FOV_SLIDERS, ADJUSTMENT_SLIDERS,
  NUM_WINDOW_STATES
}
 View mode (determines which elements are to be displayed) More...
 
typedef
TuningLayout::widgetgroup_type 
widgetgroup_type
 
- Public Types inherited from omni::ui::mixin::Scale< omni::ui::RangedFloat >
typedef omni::ui::RangedFloat slider_type
 
typedef float scalar_type
 
- 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...
 

Public Slots

void setWindowState (WindowState _mode)
 Sets Window State which determines which elements are visible. More...
 
void setNextWindowState ()
 Selects succeeding window state. More...
 
void setSelected (bool)
 Sets flag if Tuning Widget is active A tuning widget should only be active when. More...
 
void sessionModeChange ()
 Display content and widget for specific session mode. More...
 
void attachScreen (QScreen const *_screen, int _subScreenIndex)
 Attaches a screen to this tuning. More...
 
void detachScreen ()
 Detaches screen from this tuning Also triggered when QGuiApplication::screenAdded or QGuiApplication::screenRemoved were fired. More...
 
void updateViews ()
 Update GL View and Fullscreen view, if there is any. More...
 
void fullscreenToggle (bool)
 Enable or disable fullscreen display. More...
 
void resetToFreeSetup ()
 Reset to free projector setup (discards previous projector setup) More...
 
void resetToPeripheralSetup ()
 Reset to peripheral projector setup (discards previous projector. More...
 
- Public Slots inherited from omni::ui::ParameterWidget
void clear ()
 Removes all parameter widgets. More...
 
virtual void updateParameters ()
 
double getParamAsFloat (QString const &) const
 Utility method for retrieving the value from a slider with id. More...
 
void setParamAsFloat (QString const &_str, double _value)
 Set slider value from given value. More...
 
int getParamAsInt (QString const &) const
 Utility method for retrieving the value from a slider with id. More...
 
void setParamAsInt (QString const &_str, int _value)
 Set slider value from given value. More...
 
bool getParamAsBool (QString const &) const
 Utility method for retrieving the value from checkbox with id. More...
 
QWidget * getWidget (QString const &)
 Get parameter widget from parameter map with Id. More...
 
void setParametersVisible (bool)
 Show / hide parameter widgets. More...
 
bool focusNext (bool _circular=false)
 Put focus on next element. More...
 
bool focusPrev (bool _circular=false)
 Put focus on prev element. More...
 
void focus (int _index)
 Focus item in layout with index. More...
 
void focusFirst ()
 Set focus on first widget in parameter list. More...
 
void focusLast ()
 Set focus on last widget in parameter list. More...
 
virtual void setScale (float)
 Set slider ranges. More...
 
virtual void setUnit (QString const &)
 Set slider ranges. More...
 

Signals

void selected (int)
 
void closed (int)
 
void projectorSetupChanged ()
 
void dataModelChanged ()
 
- Signals inherited from omni::ui::ParameterWidget
void parametersUpdated ()
 

Public Member Functions

 Tuning (QWidget *_parent=nullptr)
 Default constructor. More...
 
 Tuning (int _index, std::shared_ptr< omni::Session >_session, QWidget *_parent=nullptr)
 Constructs with a given tuning (called by default from TuningList) More...
 
 ~Tuning ()
 Destructor. More...
 
TuningGLViewfullscreenWidget ()
 Return pointer to fullscreen widget. More...
 
TuningGLView const * fullscreenWidget () const
 Return pointer to fullscreen widget (const version) More...
 
TuningGLViewpreviewWidget ()
 Return pointer to preview widget. More...
 
TuningGLView const * previewWidget () const
 Return pointer to preview widget (const version) More...
 
bool isSelected () const
 Return selected flag. More...
 
WindowState windowState () const
 Return current window state. More...
 
- Public Member Functions inherited from omni::ui::ParameterWidget
 ParameterWidget (QWidget *_parent=nullptr)
 Default constructor. More...
 
virtual ~ParameterWidget ()
 Default Constructor. More...
 
RangedFloataddWidget (QString const &, float, float, float)
 Adds a widget with a name, a value and min-max range. More...
 
RangedIntaddIntegerWidget (QString const &, int, int, int)
 Adds a integer widget with a name, a value and min-max range. More...
 
RangedFloataddAngleWidget (QString const &, float, float, float)
 Adds an angle widget with a name, a value and min-max range. More...
 
RangedFloataddOffsetWidget (QString const &, float, float, float)
 Adds an offset widget with a name, a value and min-max range. More...
 
RotationaddRotationWidget (QString const &)
 Adds an Rotation widget with three dials for X,Y and Z axis. More...
 
omni::ui::AffineTransformaddAffineTransformWidget (QString const &, omni::AffineTransform *)
 Add a new affine transform widget with an id. More...
 
QCheckBox * addCheckBox (QString const &, bool _checked=false)
 Adds a checkbox. More...
 
int focusId () const
 Return id of focused parameter, -1 if no parameter is focused. More...
 
- Public Member Functions inherited from omni::ui::mixin::Scale< omni::ui::RangedFloat >
 Scale ()
 
virtual void setScale (float _scale)
 Set scale and apply to sliders. More...
 
bool rescaleValues () const
 
void setRescaleValues (bool _rescaleValues)
 
float scale () const
 Return scale value. More...
 
QString suffix () const
 Common unit of sliders. More...
 
void setSuffix (QString const &_suffix)
 Set suffix (unit) of slider. More...
 
void registerScaledSlider (slider_type *_slider)
 Register slider to be scaled. More...
 
void unregisterScaledSlider (slider_type *_slider)
 Remove slider from list, keep scale. 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< Tuning >
 TuningFromIndex (Tuning &_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 resizeEvent (QResizeEvent *)
 Handles resizing of sliders and preview. More...
 
void showEvent (QShowEvent *)
 Handles proper resizing of the widget. More...
 
void paintEvent (QPaintEvent *)
 Paint border. More...
 
void mouseMoveEvent (QMouseEvent *)
 Mouse Move Event and handler for dragging to ScreenSetup widget. More...
 
bool eventFilter (QObject *, QEvent *)
 Handles focus events from child widgets. More...
 
void focusInEvent (QFocusEvent *)
 Focus in event used by TuningList to set current tuning for. More...
 
void focusOutEvent (QFocusEvent *)
 Focus out for deselecting tuning. More...
 
- Protected Member Functions inherited from omni::ui::ParameterWidget
void keyPressEvent (QKeyEvent *_event)
 
- 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 Slots

void startDrag ()
 
void updateParameters ()
 Set parameters from sliders to tuning. More...
 
void setFov ()
 Set FOV to projector from slider. More...
 
void setThrowRatio ()
 Set Throw Ratio to projector from slider. More...
 
void setKeyStone ()
 Set keystone correction from slider. More...
 
void updateColor ()
 Update slider and border color. More...
 
void prepareRemove ()
 Clean up. More...
 

Private Member Functions

void dataToFrontend ()
 Pure virtual method which determines how data model is represented in frontend. More...
 
bool frontendToData ()
 Return true if data has changed by front end. More...
 
void setup ()
 Setup (only called in constructor) More...
 
virtual int firstFocusId () const
 Id of first focussed widget. More...
 
void addGroup (QString const &_groupName, widgetgroup_type const &_widgets)
 Adds a new/changes a parameter group. More...
 
void setGroup (QString const &_groupName)
 

Private Attributes

QUniquePtr< TitleBartitleBar_
 Title bar widget. More...
 
QUniquePtr< TuningGLViewglView_
 GL preview widget. More...
 
QUniquePtr< TuningGLViewfullscreen_
 
WindowState windowState_ = ADJUSTMENT_SLIDERS
 Window State. More...
 
bool isSelected_ = true
 Is true when this widgets index and current tuning index are equal. More...
 
TuningLayoutlayout_ = nullptr
 Layout. More...
 
std::map< QString,
widgetgroup_type
groups_
 

Additional Inherited Members

- Static Public Member Functions inherited from omni::ui::mixin::Scale< omni::ui::RangedFloat >
static int getPrecision (float _scale)
 Return precesion by scale. More...
 
- Protected Attributes inherited from omni::ui::ParameterWidget
std::vector< QUniquePtr
< QWidget > > 
parameters_
 Slider parameter widgets. More...
 
std::map< QString, QWidget * > parameterMap_
 Slider widgets, sorted by their label. More...
 

Detailed Description

Widget for manipulating projector parameters Also holds a preview OpenGL widget.

Member Typedef Documentation

Member Enumeration Documentation

View mode (determines which elements are to be displayed)

Enumerator
NO_DISPLAY 
DISPLAY_ONLY 
FOV_SLIDERS 
ADJUSTMENT_SLIDERS 
NUM_WINDOW_STATES 
56  {
57  NO_DISPLAY, // Widget is minimized
58  DISPLAY_ONLY, // Only preview is displayed
59  FOV_SLIDERS, // Only FOV sliders are displayed
60  ADJUSTMENT_SLIDERS, // Only sliders for adjustment are displayed
62  };
Definition: Tuning.h:57

Constructor & Destructor Documentation

omni::ui::proj::Tuning::Tuning ( QWidget *  _parent = nullptr)

Default constructor.

57  :
58  ParameterWidget(_parent),
59  mixin::TuningFromIndex<Tuning>(*this)
60  {
61  setup();
62  }
ParameterWidget(QWidget *_parent=nullptr)
Default constructor.
Definition: ParameterWidget.cpp:28
void setup()
Setup (only called in constructor)
Definition: Tuning.cpp:270
omni::ui::proj::Tuning::Tuning ( int  _index,
std::shared_ptr< omni::Session _session,
QWidget *  _parent = nullptr 
)

Constructs with a given tuning (called by default from TuningList)

omni::ui::proj::Tuning::~Tuning ( )

Destructor.

65  {
66  }

Member Function Documentation

void omni::ui::proj::Tuning::addGroup ( QString const &  _groupName,
widgetgroup_type const &  _widgets 
)
private

Adds a new/changes a parameter group.

435  {
436  if (_groupName != "")
437  {
438  groups_[_groupName] = _widgets;
439  }
440  }
std::map< QString, widgetgroup_type > groups_
Definition: Tuning.h:220
void omni::ui::proj::Tuning::attachScreen ( QScreen const *  _screen,
int  _subScreenIndex 
)
slot

Attaches a screen to this tuning.

247  {
248  tuning()->setScreen(_screen, _subScreenIndex);
249  emit projectorSetupChanged();
250  layout()->update();
251  }
void setScreen(QScreen const *_screen, int _subScreenIndex)
Set screen for this tuning.
Definition: Tuning.cpp:48
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::proj::Tuning::closed ( int  )
signal
void omni::ui::proj::Tuning::dataModelChanged ( )
signal
void omni::ui::proj::Tuning::dataToFrontend ( )
privatevirtual

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

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

68  {
69  glView_->setDataModel(dataModel());
70  glView_->setTuningIndex(index());
71  fullscreen_->setDataModel(dataModel());
72  fullscreen_->setTuningIndex(index());
73  titleBar_->setColor(tuning()->color());
74 
75  setScale(dataModel()->scene().size());
76  setUnit(dataModel()->scene().unit().abbreviation());
77 
78  setParamAsFloat("FOV",
79  tuning()->projector().fov().degrees());
80  setParamAsFloat("Throw Ratio",
81  tuning()->projector().throwRatio());
82  setParamAsFloat("Keystone",
83  tuning()->projector().keystone());
84 
85  auto const* _projSetup = tuning()->projector().setup();
86 
87  if (_projSetup->getTypeId() == "FreeSetup")
88  {
89  auto *_p =
90  static_cast<omni::proj::FreeSetup const*>(_projSetup);
91  setParamAsFloat("Yaw", _p->yaw().degrees());
92  setParamAsFloat("Pitch", _p->pitch().degrees());
93  setParamAsFloat("Roll", _p->roll().degrees());
94  setParamAsFloat("X", _p->pos().x());
95  setParamAsFloat("Y", _p->pos().y());
96  setParamAsFloat("Z", _p->pos().z());
97  }
98  else if (_projSetup->getTypeId() == "PeripheralSetup")
99  {
100  auto *_p =
101  static_cast<omni::proj::PeripheralSetup const*>(
102  _projSetup);
103  setParamAsFloat("Yaw", _p->yaw().degrees());
104  setParamAsFloat("Pitch",
105  _p->pitch().degrees());
106  setParamAsFloat("Roll", _p->roll().degrees());
107  setParamAsFloat("Delta Yaw",
108  _p->deltaYaw().degrees());
109  setParamAsFloat("Distance", _p->distanceCenter());
110  setParamAsFloat("Tower Height", _p->towerHeight());
111  setParamAsFloat("Shift", _p->shift());
112  }
113 
114  updateColor();
115  }
virtual void setUnit(QString const &)
Set slider ranges.
Definition: ParameterWidget.cpp:234
virtual void setScale(float)
Set slider ranges.
Definition: ParameterWidget.cpp:230
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
QUniquePtr< TuningGLView > glView_
GL preview widget.
Definition: Tuning.h:206
void updateColor()
Update slider and border color.
Definition: Tuning.cpp:512
int index() const
Definition: TuningFromIndex.h:35
Projector & projector()
Definition: Tuning.cpp:76
Free projector setup with euler angles and positioning.
Definition: FreeSetup.h:29
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
void setParamAsFloat(QString const &_str, double _value)
Set slider value from given value.
Definition: ParameterWidget.cpp:161
Setup in which projector rotates with yaw angle around center point.
Definition: PeripheralSetup.h:29
QUniquePtr< TitleBar > titleBar_
Title bar widget.
Definition: Tuning.h:203
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
QUniquePtr< TuningGLView > fullscreen_
Definition: Tuning.h:209
void omni::ui::proj::Tuning::detachScreen ( )
slot

Detaches screen from this tuning Also triggered when QGuiApplication::screenAdded or QGuiApplication::screenRemoved were fired.

254  {
255  tuning()->setScreen(nullptr, 0);
256  emit projectorSetupChanged();
257  layout()->update();
258  }
void setScreen(QScreen const *_screen, int _subScreenIndex)
Set screen for this tuning.
Definition: Tuning.cpp:48
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
bool omni::ui::proj::Tuning::eventFilter ( QObject *  _obj,
QEvent *  _event 
)
protected

Handles focus events from child widgets.

Handle focus events

666  {
667  if (this->isLocked()) return QObject::eventFilter(_obj, _event);
668 
669  if ((_event->type() == QEvent::MouseMove) &&
670  ((_obj == glView_.get()) || (_obj == titleBar_.get())))
671  {
672  startDrag();
673  }
674 
675  /// Handle focus events
676  if (_event->type() == QEvent::FocusIn)
677  {
678  setSelected(true);
679  }
680 
681  return QObject::eventFilter(_obj, _event);
682  }
QUniquePtr< TuningGLView > glView_
GL preview widget.
Definition: Tuning.h:206
void setSelected(bool)
Sets flag if Tuning Widget is active A tuning widget should only be active when. ...
Definition: Tuning.cpp:503
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40
QUniquePtr< TitleBar > titleBar_
Title bar widget.
Definition: Tuning.h:203
void startDrag()
Definition: Tuning.cpp:634
virtual int omni::ui::proj::Tuning::firstFocusId ( ) const
inlineprivatevirtual

Id of first focussed widget.

Reimplemented from omni::ui::ParameterWidget.

192  {
193  return std::min(layout()->count()-1,2); // Title bar and view cannot be focussed
194  }
void omni::ui::proj::Tuning::focusInEvent ( QFocusEvent *  event)
protected

Focus in event used by TuningList to set current tuning for.

Focus event used by TuningList to set current tuning for session.

691  {
692  if (!this->isLocked()) setSelected(true);
693  QWidget::focusInEvent(event);
694  }
void setSelected(bool)
Sets flag if Tuning Widget is active A tuning widget should only be active when. ...
Definition: Tuning.cpp:503
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40
void omni::ui::proj::Tuning::focusOutEvent ( QFocusEvent *  event)
protected

Focus out for deselecting tuning.

697  {
698  // if (!this->isLocked()) setSelected(false);
699  QWidget::focusOutEvent(event);
700  }
bool omni::ui::proj::Tuning::frontendToData ( )
privatevirtual

Return true if data has changed by front end.

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

117  {
118  return false;
119  }
void omni::ui::proj::Tuning::fullscreenToggle ( bool  _enabled)
slot

Enable or disable fullscreen display.

143  {
144  tuning()->setOutputEnabled(_enabled);
145  glView_->setUpdateFrequency(_enabled ? 10.0 : 3.0);
146  titleBar_->fullscreenToggle(_enabled);
147  updateViews();
148  emit projectorSetupChanged();
149  }
QUniquePtr< TuningGLView > glView_
GL preview widget.
Definition: Tuning.h:206
void updateViews()
Update GL View and Fullscreen view, if there is any.
Definition: Tuning.cpp:260
void setOutputEnabled(bool _enabled=true)
Enable output if _enabled is true, disable otherwise.
Definition: Tuning.cpp:213
QUniquePtr< TitleBar > titleBar_
Title bar widget.
Definition: Tuning.h:203
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
TuningGLView * omni::ui::proj::Tuning::fullscreenWidget ( )

Return pointer to fullscreen widget.

122  {
123  return fullscreen_.get();
124  }
QUniquePtr< TuningGLView > fullscreen_
Definition: Tuning.h:209
TuningGLView const * omni::ui::proj::Tuning::fullscreenWidget ( ) const

Return pointer to fullscreen widget (const version)

127  {
128  return fullscreen_.get();
129  }
QUniquePtr< TuningGLView > fullscreen_
Definition: Tuning.h:209
bool omni::ui::proj::Tuning::isSelected ( ) const

Return selected flag.

685  {
686  return isSelected_;
687  }
bool isSelected_
Is true when this widgets index and current tuning index are equal.
Definition: Tuning.h:215
void omni::ui::proj::Tuning::mouseMoveEvent ( QMouseEvent *  event)
protected

Mouse Move Event and handler for dragging to ScreenSetup widget.

626  {
627  // Handle drag to ScreenWidget
628  if (event->button() == Qt::LeftButton)
629  {
630  startDrag();
631  }
632  }
void startDrag()
Definition: Tuning.cpp:634
void omni::ui::proj::Tuning::paintEvent ( QPaintEvent *  event)
protected

Paint border.

Paint board if active or color is selected

601  {
602  if (!titleBar_ || !isEnabled()) return;
603 
604  QPainter _p(this);
605 
606  auto _rect = rect().adjusted(2, 2, -2, -2);
607 
608  /// Paint board if active or color is selected
609  if (isSelected_)
610  {
611  _p.setPen(QPen(titleBar_->color(), 5));
612  }
613  else
614  {
615  _p.setPen(Qt::NoPen);
616  }
617 
618  _p.setBrush(QColor("#212121"));
619  _p.drawRect(_rect);
620 
621  QWidget::paintEvent(event);
622  }
QUniquePtr< TitleBar > titleBar_
Title bar widget.
Definition: Tuning.h:203
bool isSelected_
Is true when this widgets index and current tuning index are equal.
Definition: Tuning.h:215
void omni::ui::proj::Tuning::prepareRemove ( )
privateslot

Clean up.

526  {
527  emit closed(index());
528  }
int index() const
Definition: TuningFromIndex.h:35
TuningGLView * omni::ui::proj::Tuning::previewWidget ( )

Return pointer to preview widget.

132  {
133  return glView_.get();
134  }
QUniquePtr< TuningGLView > glView_
GL preview widget.
Definition: Tuning.h:206
TuningGLView const * omni::ui::proj::Tuning::previewWidget ( ) const

Return pointer to preview widget (const version)

137  {
138  return glView_.get();
139  }
QUniquePtr< TuningGLView > glView_
GL preview widget.
Definition: Tuning.h:206
void omni::ui::proj::Tuning::projectorSetupChanged ( )
signal
void omni::ui::proj::Tuning::resetToFreeSetup ( )
slot

Reset to free projector setup (discards previous projector setup)

152  {
153  if (!tuning()) return;
154 
155  tuning()->projector().setup("FreeSetup",dataModel()->scene().size());
157  emit projectorSetupChanged();
158  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void sessionModeChange()
Display content and widget for specific session mode.
Definition: Tuning.cpp:530
Projector & projector()
Definition: Tuning.cpp:76
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
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::proj::Tuning::resetToPeripheralSetup ( )
slot

Reset to peripheral projector setup (discards previous projector.

Reset to peripheral projector setup (discards previous projectorsetup)

161  {
162  if (!tuning()) return;
163 
164  tuning()->projector().setup("PeripheralSetup",dataModel()->scene().size());
166  emit projectorSetupChanged();
167  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void sessionModeChange()
Display content and widget for specific session mode.
Definition: Tuning.cpp:530
Projector & projector()
Definition: Tuning.cpp:76
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
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::proj::Tuning::resizeEvent ( QResizeEvent *  event)
protected

Handles resizing of sliders and preview.

591  {
592  QWidget::resizeEvent(event);
593 
594  update();
595  }
void omni::ui::proj::Tuning::selected ( int  )
signal
void omni::ui::proj::Tuning::sessionModeChange ( )
slot

Display content and widget for specific session mode.

Generate calibration data for visualizer when switching to live mode

531  {
532  if (!dataModel()) return;
533 
534  this->locked([&]() {
535  if (windowState_ == NO_DISPLAY)
536  {
537  setGroup("Minimized");
538  return;
539  }
540 
541  if (windowState_ == DISPLAY_ONLY)
542  {
543  setGroup("PreviewOnly");
544  return;
545  }
546 
547  auto _mode = dataModel()->mode();
548 
549  // Show close button only in screen- and projection setup
550  titleBar_->setCloseButtonVisible(
551  _mode == Session::Mode::SCREENSETUP ||
552  _mode == Session::Mode::ARRANGE);
553 
554  switch (_mode)
555  {
557  setGroup("FOVSliders");
558  break;
559 
561 
562  if (windowState_ ==
563  ADJUSTMENT_SLIDERS) setGroup(tuning()->projector().
564  setup()
565  ->getTypeId().str());
566 
567  if (windowState_ == FOV_SLIDERS) setGroup("FOVSliders");
568  break;
569 
571  case Session::Mode::WARP:
574  setGroup("PreviewOnly");
575  break;
576  case Session::Mode::LIVE:
577  /// Generate calibration data for visualizer when switching to live mode
579  setGroup("PreviewOnly");
580  break;
581 
582  default:
583  break;
584  }
585  });
586 
587  fullscreen_->update();
588  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
visualizer_type * visualizer()
Return pointer to visualizer.
Definition: Tuning.cpp:135
void generateCalibrationData()
Definition: Tuning.cpp:391
void locked(F f)
Lock widget and execute given functor.
Definition: Locked.h:30
Definition: Tuning.h:57
WindowState windowState_
Window State.
Definition: Tuning.h:212
QUniquePtr< TitleBar > titleBar_
Title bar widget.
Definition: Tuning.h:203
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void setGroup(QString const &_groupName)
Definition: Tuning.cpp:442
QUniquePtr< TuningGLView > fullscreen_
Definition: Tuning.h:209
void setup()
Setup (only called in constructor)
Definition: Tuning.cpp:270
void omni::ui::proj::Tuning::setFov ( )
privateslot

Set FOV to projector from slider.

214  {
215  if (!tuning() || isLocked()) return;
216 
217  tuning()->projector().setFov(getParamAsFloat("FOV"));
218  setParamAsFloat("Throw Ratio",
219  tuning()->projector().throwRatio());
220 
221  updateViews();
222  emit projectorSetupChanged();
223  }
double getParamAsFloat(QString const &) const
Utility method for retrieving the value from a slider with id.
Definition: ParameterWidget.cpp:152
void updateViews()
Update GL View and Fullscreen view, if there is any.
Definition: Tuning.cpp:260
void setFov(Angle _fov)
Set new field of view.
Definition: Projector.cpp:79
Projector & projector()
Definition: Tuning.cpp:76
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40
void setParamAsFloat(QString const &_str, double _value)
Set slider value from given value.
Definition: ParameterWidget.cpp:161
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::proj::Tuning::setGroup ( QString const &  _groupName)
private

Hide all widgets temporarily

443  {
444  this->locked([&]() {
445  /// Hide all widgets temporarily
446  setParametersVisible(false);
447  glView_->setVisible(false);
448 
449  if (groups_.count(_groupName) == 0)
450  {
451  // Show title bar only if group with that name does not
452  // exist
453  layout_->setWidgets({ { titleBar_.get(),
455  }
456  else
457  {
458  layout_->setWidgets(groups_[_groupName]);
459  }
460  });
461  }
QUniquePtr< TuningGLView > glView_
GL preview widget.
Definition: Tuning.h:206
void locked(F f)
Lock widget and execute given functor.
Definition: Locked.h:30
void setWidgets(widgetgroup_type const &_widgets)
Clears layout and inserts the given widgets.
Definition: TuningLayout.cpp:133
void setParametersVisible(bool)
Show / hide parameter widgets.
Definition: ParameterWidget.cpp:198
QUniquePtr< TitleBar > titleBar_
Title bar widget.
Definition: Tuning.h:203
std::map< QString, widgetgroup_type > groups_
Definition: Tuning.h:220
TuningLayout * layout_
Layout.
Definition: Tuning.h:218
void omni::ui::proj::Tuning::setKeyStone ( )
privateslot

Set keystone correction from slider.

237  {
238  if (!tuning() || isLocked()) return;
239 
240  tuning()->projector().setKeystone(getParamAsFloat("Keystone"));
241  updateViews();
242 
243  emit projectorSetupChanged();
244  }
double getParamAsFloat(QString const &) const
Utility method for retrieving the value from a slider with id.
Definition: ParameterWidget.cpp:152
void updateViews()
Update GL View and Fullscreen view, if there is any.
Definition: Tuning.cpp:260
Projector & projector()
Definition: Tuning.cpp:76
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40
void setKeystone(qreal)
Set new keystone correction value (0.0 = default)
Definition: Projector.cpp:97
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::proj::Tuning::setNextWindowState ( )
slot

Selects succeeding window state.

475  {
476  int _numStates = int(NUM_WINDOW_STATES);
477 
478  if (dataModel())
479  {
480  switch (dataModel()->mode())
481  {
484  _numStates = 3;
485  break;
486 
487  case Session::Mode::WARP:
489  case Session::Mode::LIVE:
491  _numStates = 2;
492  break;
493 
494  default:
495  _numStates = int(NUM_WINDOW_STATES);
496  }
497  }
498 
499  setWindowState(static_cast<WindowState>((int(windowState_) + 1) %
500  _numStates));
501  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
WindowState windowState_
Window State.
Definition: Tuning.h:212
void setWindowState(WindowState _mode)
Sets Window State which determines which elements are visible.
Definition: Tuning.cpp:468
void omni::ui::proj::Tuning::setSelected ( bool  _isSelected)
slot

Sets flag if Tuning Widget is active A tuning widget should only be active when.

504  {
505  isSelected_ = _isSelected;
506 
507  if (isSelected_ && !this->isLocked()) emit selected(index());
508 
509  updateColor();
510  }
void updateColor()
Update slider and border color.
Definition: Tuning.cpp:512
int index() const
Definition: TuningFromIndex.h:35
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40
bool isSelected_
Is true when this widgets index and current tuning index are equal.
Definition: Tuning.h:215
void omni::ui::proj::Tuning::setThrowRatio ( )
privateslot

Set Throw Ratio to projector from slider.

227  {
228  if (!tuning() || isLocked()) return;
229 
230  tuning()->projector().setThrowRatio(getParamAsFloat("Throw Ratio"));
231  setParamAsFloat("FOV", tuning()->projector().fov().degrees());
232 
233  updateViews();
234  emit projectorSetupChanged();
235  }
double getParamAsFloat(QString const &) const
Utility method for retrieving the value from a slider with id.
Definition: ParameterWidget.cpp:152
void updateViews()
Update GL View and Fullscreen view, if there is any.
Definition: Tuning.cpp:260
Projector & projector()
Definition: Tuning.cpp:76
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40
void setParamAsFloat(QString const &_str, double _value)
Set slider value from given value.
Definition: ParameterWidget.cpp:161
void setThrowRatio(qreal)
Set new throw ratio.
Definition: Projector.cpp:74
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::proj::Tuning::setup ( )
private

Setup (only called in constructor)

Setup title bar

Setup preview window

FOV view slider

Todo:
Connect this with threshold slider

Throw ratio slider

Todo:
Connect this with FOV slider

Yaw angle slider (all projector setups)

Tower height slider (PeripheralSetup only)

Distance slider (PeripheralSetup only)

Shift offset slider (PeripheralSetup only)

X offset slider (FreeSetup only)

Y offset slider (FreeSetup only)

Z offset slider (FreeSetup only)

Pitch angle slider (both setups)

Roll angle slider (both setups)

Delta yaw angle slider (PeripheralSetup only)

Make slider groups

Setup/update mode

271  {
272  this->setFocusPolicy(Qt::TabFocus);
273  this->installEventFilter(this->parent());
274  layout_ = new TuningLayout(this);
275  setLayout(layout_);
276 
277  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
278 
279  /// Setup title bar
280  titleBar_.reset(new TitleBar("Projector", this));
281  connect(titleBar_.get(), SIGNAL(
282  closeButtonClicked()), this,
283  SLOT(prepareRemove()));
284  connect(titleBar_.get(), SIGNAL(colorChanged(
285  QColor const &)), this,
286  SLOT(updateParameters()));
287  connect(titleBar_.get(), SIGNAL(
288  freeSetupSelected()), this,
289  SLOT(
290  resetToFreeSetup()));
291  connect(titleBar_.get(), SIGNAL(
292  peripheralSetupSelected()), this,
293  SLOT(resetToPeripheralSetup()));
295 
296  /// Setup preview window
297  glView_.reset(new TuningGLView(this));
298  QSizePolicy _sizePolicy(QSizePolicy::Ignored,
299  QSizePolicy::Expanding);
300  glView_->setSizePolicy(_sizePolicy);
301  glView_->setKeepAspectRatio(true);
302  glView_->setBorder(0.0);
303  glView_->setViewOnly(true);
304  glView_->setUpdateFrequency(10.0); // 10.0 fps
305  glView_->installEventFilter(this);
307 
308  fullscreen_.reset(new TuningGLView());
309  fullscreen_->setShowCursor(true);
310  fullscreen_->setFullScreenMode(true);
311  fullscreen_->hide();
312 
313  /// FOV view slider
314  /// @todo Connect this with threshold slider
315  auto *_fov = addWidget("FOV", 60.0, 10.0, 160.0);
316  _fov->setSingleStep(1.0);
317  _fov->setPageStep(5.0);
318  _fov->setSuffix("°");
319  connect(_fov, SIGNAL(valueChanged()), this, SLOT(setFov()));
320 
321  auto *_keystone = addWidget("Keystone", 0.0, -1.0, 2.0);
322  _keystone->setSingleStep(0.01);
323  _keystone->setPageStep(0.1);
324  connect(_keystone, SIGNAL(valueChanged()), this,
325  SLOT(setKeyStone()));
326 
327  /// Throw ratio slider
328  /// @todo Connect this with FOV slider
329  auto *_throwRatio = addWidget("Throw Ratio", 1.0, 0.2, 5.0);
330  _throwRatio->setSingleStep(0.01);
331  _throwRatio->setPageStep(0.05);
332 
333  // _throwRatio->setScale(RangedFloat::Scale::RECIPROCAL);
334  connect(_throwRatio, SIGNAL(valueChanged()), this,
335  SLOT(setThrowRatio()));
336 
337  /// Yaw angle slider (all projector setups)
338  auto && _yaw = addAngleWidget("Yaw", 0.0, 0.0, 360.0);
339  _yaw->setSingleStep(0.1);
340  _yaw->setPageStep(1.0);
341 
342  /// Tower height slider (PeripheralSetup only)
343  auto && _towerHeight = addOffsetWidget("Tower Height",
344  0.2,
345  -0.5,
346  1.0);
347 
348  /// Distance slider (PeripheralSetup only)
349  auto && _distance = addOffsetWidget("Distance", 0.4, 0.0, 1.0);
350 
351  /// Shift offset slider (PeripheralSetup only)
352  auto && _shift = addOffsetWidget("Shift", 0.0, -0.2, 0.2);
353 
354  /// X offset slider (FreeSetup only)
355  auto && _x = addOffsetWidget("X", 0.0, -1.0, 1.0);
356 
357  /// Y offset slider (FreeSetup only)
358  auto && _y = addOffsetWidget("Y", 0.0, -1.0, 1.0);
359 
360  /// Z offset slider (FreeSetup only)
361  auto && _z = addOffsetWidget("Z", 0.0, -1.0, 1.0);
362 
363  /// Pitch angle slider (both setups)
364  auto && _pitch = addAngleWidget("Pitch", 30.0, -180.0, 180.0);
365  _pitch->setSingleStep(0.1);
366  _pitch->setPageStep(1.0);
367  _pitch->setPivot(0.0);
368 
369  /// Roll angle slider (both setups)
370  auto && _roll = addAngleWidget("Roll", 0.0, -180.0, 180.0);
371  _roll->setSingleStep(0.1);
372  _roll->setPageStep(1.0);
373  _roll->setPivot(0.0);
374 
375  /// Delta yaw angle slider (PeripheralSetup only)
376  auto && _deltaYaw = addAngleWidget("Delta Yaw", 0.0, -45.0, 45.0);
377  _deltaYaw->setSingleStep(0.1);
378  _deltaYaw->setPageStep(1.0);
379  _deltaYaw->setPivot(0.0);
380 
381  widgetgroup_type _titleAndPreview(
382  {
385  });
386 
387  auto addParameters =
388  [&](widgetgroup_type const& _group,
389  std::vector<QWidget *>const& _widgets) -> widgetgroup_type
390  {
391  widgetgroup_type _result = _group;
392 
393  for (auto& _widget :
394  _widgets) _result.emplace_back(_widget,
396 
397 
398  return _result;
399  };
400 
401  addGroup("Minimized",
402  { { titleBar_.get(),
404 
405  /// Make slider groups
406  addGroup("PreviewOnly", _titleAndPreview);
407  addGroup("FOVSliders",
408  addParameters(_titleAndPreview,
409  { _fov, _throwRatio, _keystone }));
410  addGroup("FreeSetup",
411  addParameters(_titleAndPreview,
412  { _yaw, _pitch, _roll, _x, _y, _z, _fov,
413  _throwRatio, _keystone }));
414  addGroup("PeripheralSetup",
415  addParameters(_titleAndPreview,
416  { _yaw, _pitch, _distance, _towerHeight,
417  _shift, _deltaYaw, _roll, _fov,
418  _throwRatio, _keystone }));
419 
420  /// Setup/update mode
422 
423  for (int i = 0; i < layout_->count(); ++i) {
424  auto _widget = layout_->itemAt(i)->widget();
425 
426  if (!_widget) continue;
427  _widget->installEventFilter(this);
428  _widget->installEventFilter(this->parent());
429  }
430  }
void addWidget(QWidget *widget)
Add widget with PARAMETER Role.
Definition: TuningLayout.cpp:42
QUniquePtr< TuningGLView > glView_
GL preview widget.
Definition: Tuning.h:206
void resetToFreeSetup()
Reset to free projector setup (discards previous projector setup)
Definition: Tuning.cpp:152
QLayoutItem * itemAt(int index) const
Return item at index.
Definition: TuningLayout.cpp:70
void sessionModeChange()
Display content and widget for specific session mode.
Definition: Tuning.cpp:530
void addGroup(QString const &_groupName, widgetgroup_type const &_widgets)
Adds a new/changes a parameter group.
Definition: Tuning.cpp:433
void prepareRemove()
Clean up.
Definition: Tuning.cpp:525
void setKeyStone()
Set keystone correction from slider.
Definition: Tuning.cpp:237
void setThrowRatio()
Set Throw Ratio to projector from slider.
Definition: Tuning.cpp:226
RangedFloat * addWidget(QString const &, float, float, float)
Adds a widget with a name, a value and min-max range.
Definition: ParameterWidget.cpp:59
RangedFloat * addAngleWidget(QString const &, float, float, float)
Adds an angle widget with a name, a value and min-max range.
Definition: ParameterWidget.cpp:105
TuningLayout::widgetgroup_type widgetgroup_type
Definition: Tuning.h:64
void resetToPeripheralSetup()
Reset to peripheral projector setup (discards previous projector.
Definition: Tuning.cpp:161
void setFov()
Set FOV to projector from slider.
Definition: Tuning.cpp:213
RangedFloat * addOffsetWidget(QString const &, float, float, float)
Adds an offset widget with a name, a value and min-max range.
Definition: ParameterWidget.cpp:117
QUniquePtr< TitleBar > titleBar_
Title bar widget.
Definition: Tuning.h:203
void updateParameters()
Set parameters from sliders to tuning.
Definition: Tuning.cpp:169
TuningLayout * layout_
Layout.
Definition: Tuning.h:218
int count() const
Return number of widgets.
Definition: TuningLayout.cpp:52
QUniquePtr< TuningGLView > fullscreen_
Definition: Tuning.h:209
void omni::ui::proj::Tuning::setWindowState ( WindowState  _mode)
slot

Sets Window State which determines which elements are visible.

469  {
470  windowState_ = _windowState;
472  }
void sessionModeChange()
Display content and widget for specific session mode.
Definition: Tuning.cpp:530
WindowState windowState_
Window State.
Definition: Tuning.h:212
void omni::ui::proj::Tuning::showEvent ( QShowEvent *  )
protected

Handles proper resizing of the widget.

598  {}
void omni::ui::proj::Tuning::startDrag ( )
privateslot
635  {
636  if (!dataModel()) return;
637 
638  if (dataModel()->mode() != Session::Mode::SCREENSETUP) return;
639 
640  QDrag *drag = new QDrag(this);
641  QMimeData *mimeData = new QMimeData;
642 
643  // Generate pixmap for projector
644  QPixmap _pixmap(128, 128);
645  {
646  _pixmap.fill(tuning()->color());
647  QPainter _p(&_pixmap);
648  QRect _rect(0, 0, 128, 128);
649 
650  QFont _font("Helvetica", 32);
651  _p.setFont(_font);
652 
653  _p.drawRect(_rect.adjusted(1, 1, -2, -2));
654  _p.drawText(_rect, Qt::AlignCenter,
655  QString("%1").arg(index() + 1));
656  _p.end();
657  }
658  drag->setPixmap(_pixmap);
659 
660  mimeData->setText(QString("%1").arg(index()));
661  drag->setMimeData(mimeData);
662  drag->exec();
663  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
int index() const
Definition: TuningFromIndex.h:35
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::proj::Tuning::updateColor ( )
privateslot

Update slider and border color.

Widget color has the same color as tuning

513  {
514  /// Widget color has the same color as tuning
515  for (auto& _widget : this->parameters_)
516  {
517  QColor _color =
518  isSelected_ ? titleBar_->color().name() : "#cccccc";
519  _widget->setStyleSheet(
520  "selection-background-color : " + _color.name());
521  }
522  update();
523  }
std::vector< QUniquePtr< QWidget > > parameters_
Slider parameter widgets.
Definition: ParameterWidget.h:159
QUniquePtr< TitleBar > titleBar_
Title bar widget.
Definition: Tuning.h:203
bool isSelected_
Is true when this widgets index and current tuning index are equal.
Definition: Tuning.h:215
void omni::ui::proj::Tuning::updateParameters ( )
privateslot

Set parameters from sliders to tuning.

Handle free projector setup

Handle Peripheral projector setup

170  {
171  if (!tuning() || isLocked()) return;
172 
173  auto* _projSetup = tuning()->projector().setup();
174 
175  if (!_projSetup) return;
176 
177  /// Handle free projector setup
178  if (_projSetup->getTypeId() == "FreeSetup")
179  {
180  auto *_p = static_cast<omni::proj::FreeSetup *>(_projSetup);
181  _p->setYaw(getParamAsFloat("Yaw"));
182  _p->setPitch(getParamAsFloat("Pitch"));
183  _p->setRoll(getParamAsFloat("Roll"));
184  _p->setPos(
185  getParamAsFloat("X"),
186  getParamAsFloat("Y"),
187  getParamAsFloat("Z"));
188  }
189 
190  /// Handle Peripheral projector setup
191  if (_projSetup->getTypeId() == "PeripheralSetup")
192  {
193  auto *_p =
194  static_cast<omni::proj::PeripheralSetup *>(_projSetup);
195 
196  _p->setYaw(getParamAsFloat("Yaw"));
197  _p->setPitch(getParamAsFloat("Pitch"));
198  _p->setRoll(getParamAsFloat("Roll"));
199  _p->setDeltaYaw(getParamAsFloat("Delta Yaw"));
200  _p->setDistanceCenter(getParamAsFloat("Distance"));
201  _p->setTowerHeight(getParamAsFloat("Tower Height"));
202  _p->setShift(getParamAsFloat("Shift"));
203  }
204 
205  tuning()->projector().setup();
206  tuning()->setColor(titleBar_->color());
207 
208  glView_->update();
209  updateViews();
210  emit projectorSetupChanged();
211  }
double getParamAsFloat(QString const &) const
Utility method for retrieving the value from a slider with id.
Definition: ParameterWidget.cpp:152
QUniquePtr< TuningGLView > glView_
GL preview widget.
Definition: Tuning.h:206
void updateViews()
Update GL View and Fullscreen view, if there is any.
Definition: Tuning.cpp:260
void setColor(QColor const &)
Sets color for mapping.
Definition: Tuning.cpp:129
Projector & projector()
Definition: Tuning.cpp:76
void setDeltaYaw(Angle)
Delta yaw angle from rotating yaw angle.
Definition: PeripheralSetup.cpp:74
Free projector setup with euler angles and positioning.
Definition: FreeSetup.h:29
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40
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
Setup in which projector rotates with yaw angle around center point.
Definition: PeripheralSetup.h:29
QUniquePtr< TitleBar > titleBar_
Title bar widget.
Definition: Tuning.h:203
void setPos(QVector3D const &)
Set position from QVector3D.
Definition: FreeSetup.cpp:59
omni::proj::Tuning * tuning()
Return pointer to tuning.
Definition: TuningFromIndex.h:54
void omni::ui::proj::Tuning::updateViews ( )
slot

Update GL View and Fullscreen view, if there is any.

261  {
262  glView_->makeCurrent();
263  glView_->triggerUpdate();
264  if (fullscreen_) {
265  fullscreen_->makeCurrent();
266  fullscreen_->triggerUpdate();
267  }
268  }
QUniquePtr< TuningGLView > glView_
GL preview widget.
Definition: Tuning.h:206
QUniquePtr< TuningGLView > fullscreen_
Definition: Tuning.h:209
Tuning::WindowState omni::ui::proj::Tuning::windowState ( ) const

Return current window state.

464  {
465  return windowState_;
466  }
WindowState windowState_
Window State.
Definition: Tuning.h:212

Field Documentation

QUniquePtr<TuningGLView> omni::ui::proj::Tuning::fullscreen_
private
QUniquePtr<TuningGLView> omni::ui::proj::Tuning::glView_
private

GL preview widget.

std::map<QString, widgetgroup_type> omni::ui::proj::Tuning::groups_
private
bool omni::ui::proj::Tuning::isSelected_ = true
private

Is true when this widgets index and current tuning index are equal.

TuningLayout* omni::ui::proj::Tuning::layout_ = nullptr
private

Layout.

QUniquePtr<TitleBar> omni::ui::proj::Tuning::titleBar_
private

Title bar widget.

WindowState omni::ui::proj::Tuning::windowState_ = ADJUSTMENT_SLIDERS
private

Window State.


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