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::proj::TuningList Class Reference

#include <TuningList.h>

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

Public Slots

void sessionModeChange ()
 Change current mode for all tuning widgets. More...
 
void addTuning ()
 Add a new tuning and tuning widget, with automatically detected settings. More...
 
void addTuning (QString const &_projSetupId)
 Add tuning with specific projector setup. More...
 
void removeTuning (int _index)
 Remove tuning. More...
 
void setCurrentTuning ()
 Set current tuning from currently selected widget. More...
 
void setTuningIndex (int)
 Set current tuning index manually (currentIndexChanged signal is emitted) More...
 
void clear ()
 Remove all tunings from session and all associated widgets. More...
 
void updateViews ()
 Updates/Repaints GL Views of all tunings widgets. More...
 
void updateSceneSize (bool _rescaleValues)
 Adjust sliders to scene scale. More...
 
void updateUnits ()
 Set unit of sliders. More...
 
void disableAllTunings ()
 Disable all tunings and fullscreen. More...
 
void enableAllTunings ()
 Enable all tunings and fullscreen. More...
 
void enableSelectedTuningOnly ()
 Enable selected tuning and show only this in fullscreen. More...
 

Signals

void currentIndexChanged (int)
 Signal which is emitted when the current tuning has changed. More...
 
void dataModelChanged ()
 Signal which is emitted when parameters of one tuning have changed. More...
 
void tuningAdded ()
 Signal is emitted when a tuning was added. More...
 
void tuningRemoved ()
 Signal is emitted when a tuning was removed. More...
 
void tuningChanged ()
 Emitted when a single tuning has changed. More...
 

Public Member Functions

 TuningList (QWidget *=nullptr)
 
 ~TuningList ()
 
std::set< TuningGLView * > getViews (int _index) const
 Return fullscreen and preview widget from index. More...
 
Tuningwidget (int _index)
 Return tuning widget at index, nullptr if index is not valid. More...
 
Tuning const * widget (int _index) const
 Return tuning widget at index, nullptr if index is not valid (const) More...
 
TuningwidgetFromTuning (omni::proj::Tuning *)
 
- 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...
 

Protected Member Functions

void resizeEvent (QResizeEvent *)
 
void keyPressEvent (QKeyEvent *)
 
bool eventFilter (QObject *obj, QEvent *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 Member Functions

void dataToFrontend ()
 Update sliders from current session. More...
 
bool frontendToData ()
 Assign slider values to current session. More...
 
void addTuning (omni::proj::Tuning *_tuning)
 Add widget from existing tuning. More...
 
void removeWidgets ()
 Removes all widgets in the scroll area Unlike clear() it does not remove tunings from session. More...
 
QColor getTuningColor ()
 Get most differing color for a new tuning. More...
 

Private Attributes

QWidget * contents_
 
QLayout * layout_
 
std::vector< QUniquePtr< Tuning > > widgets_
 

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...
 

Constructor & Destructor Documentation

omni::ui::proj::TuningList::TuningList ( QWidget *  _parent = nullptr)
37  :
38  QScrollArea(_parent),
39  layout_(new QVBoxLayout())
40  {
41  // Set contents and layout, so tuning widgets can be placed
42  // vertically using
43  // QScrollArea funcionality
44  layout_->setSizeConstraint(QLayout::SetMinAndMaxSize);
45  layout_->setSpacing(3);
46  layout_->setContentsMargins(0, 0, 16, 0);
47 
48  this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
49 
50  contents_ = new QWidget(this);
51  contents_->setLayout(layout_);
52  this->setWidget(contents_);
53  contents_->show();
54 
55  this->setWidgetResizable(true);
56  }
QWidget * contents_
Definition: TuningList.h:142
QLayout * layout_
Definition: TuningList.h:143
omni::ui::proj::TuningList::~TuningList ( )
59  {
60  }

Member Function Documentation

void omni::ui::proj::TuningList::addTuning ( )
slot

Add a new tuning and tuning widget, with automatically detected settings.

103  {
104 
105  QString _setupId = "PeripheralSetup";
106 
107  if (!dataModel()->tunings().empty())
108  {
109  // Set setup id from last tuning
110  auto *_setup =
111  dataModel()->tunings()[dataModel()->tunings().size() -
112  1]->projector().setup();
113 
114  if (_setup) _setupId = _setup->getTypeId();
115  }
116  addTuning(_setupId);
117  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void addTuning()
Add a new tuning and tuning widget, with automatically detected settings.
Definition: TuningList.cpp:102
void omni::ui::proj::TuningList::addTuning ( QString const &  _projSetupId)
slot

Add tuning with specific projector setup.

121  {
122  if (dataModel()->tunings().size() >= OMNI_MAX_NUMBER_TUNINGS)
123  {
124  QMessageBox::information(this, "Information",
125  QString(
126  "You have reached the maximum of %1 projectors.").arg(
128  return;
129  }
130 
131  auto *_tuning = dataModel()->tunings().add(false);
132 
133  if (!_tuning) return;
134 
135  _tuning->setColor(getTuningColor());
136  _tuning->projector().setup(_projSetupId,dataModel()->scene().size());
137  addTuning(_tuning);
138 
139  // Select this tuning index
140  setTuningIndex(dataModel()->tunings().size() - 1);
141  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
QColor getTuningColor()
Get most differing color for a new tuning.
Definition: TuningList.cpp:179
#define OMNI_MAX_NUMBER_TUNINGS
Definition: TuningList.cpp:31
void addTuning()
Add a new tuning and tuning widget, with automatically detected settings.
Definition: TuningList.cpp:102
void setTuningIndex(int)
Set current tuning index manually (currentIndexChanged signal is emitted)
Definition: TuningList.cpp:395
void omni::ui::proj::TuningList::addTuning ( omni::proj::Tuning _tuning)
private

Add widget from existing tuning.

144  {
145 
146  int _index = 0;
147 
148  for (auto& _sessionTuning : dataModel()->tunings())
149  {
150  if (_sessionTuning.get() == _tuning)
151  {
152  break;
153  }
154  ++_index;
155  }
156 
157  widgets_.emplace_back(new ui::proj::Tuning(_index, dataModel(),
158  this));
159  auto _widget = widgets_.back().get();
160  contents_->layout()->addWidget(_widget);
161 
162  _widget->connect(_widget, SIGNAL(selected(
163  int)), this,
164  SLOT(setTuningIndex(int)));
165  _widget->connect(_widget, SIGNAL(closed(
166  int)), this,
167  SLOT(removeTuning(int)));
168  _widget->connect(_widget, SIGNAL(
169  projectorSetupChanged()), this,
170  SIGNAL(tuningChanged()));
171  _widget->connect(_widget, SIGNAL(
172  dataModelChanged()), this,
173  SIGNAL(tuningChanged()));
174  _widget->sessionModeChange();
175 
176  emit tuningAdded();
177  }
void dataModelChanged()
Signal which is emitted when parameters of one tuning have changed.
void removeTuning(int _index)
Remove tuning.
Definition: TuningList.cpp:236
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
QWidget * contents_
Definition: TuningList.h:142
void tuningAdded()
Signal is emitted when a tuning was added.
void setTuningIndex(int)
Set current tuning index manually (currentIndexChanged signal is emitted)
Definition: TuningList.cpp:395
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void tuningChanged()
Emitted when a single tuning has changed.
void omni::ui::proj::TuningList::clear ( )
slot

Remove all tunings from session and all associated widgets.

276  {
277  removeWidgets();
278  if (dataModel()) {
279  dataModel()->tunings().clear();
280  }
281  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void removeWidgets()
Removes all widgets in the scroll area Unlike clear() it does not remove tunings from session...
Definition: TuningList.cpp:283
void omni::ui::proj::TuningList::currentIndexChanged ( int  )
signal

Signal which is emitted when the current tuning has changed.

void omni::ui::proj::TuningList::dataModelChanged ( )
signal

Signal which is emitted when parameters of one tuning have changed.

void omni::ui::proj::TuningList::dataToFrontend ( )
privatevirtual

Update sliders from current session.

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

79  {
80  removeWidgets();
81 
82  for (auto& _tuning : dataModel()->tunings()) addTuning(
83  _tuning.get());
84 
86  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void removeWidgets()
Removes all widgets in the scroll area Unlike clear() it does not remove tunings from session...
Definition: TuningList.cpp:283
void sessionModeChange()
Change current mode for all tuning widgets.
Definition: TuningList.cpp:260
void addTuning()
Add a new tuning and tuning widget, with automatically detected settings.
Definition: TuningList.cpp:102
void omni::ui::proj::TuningList::disableAllTunings ( )
slot

Disable all tunings and fullscreen.

318  {
319  for (auto& _widget : widgets_) {
320  _widget->fullscreenToggle(false);
321  }
322  }
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void omni::ui::proj::TuningList::enableAllTunings ( )
slot

Enable all tunings and fullscreen.

325  {
326  for (auto& _widget : widgets_) {
327  _widget->fullscreenToggle(true);
328  }
329  }
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void omni::ui::proj::TuningList::enableSelectedTuningOnly ( )
slot

Enable selected tuning and show only this in fullscreen.

332  {
333  for (auto& _widget : widgets_) {
334  _widget->fullscreenToggle(_widget->index() == dataModel()->tunings().currentIndex());
335  }
336  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
bool omni::ui::proj::TuningList::eventFilter ( QObject *  obj,
QEvent *  event 
)
protected
369  {
370  if (event->type() == QEvent::KeyPress) {
371  auto *keyEvent = static_cast<QKeyEvent *>(event);
372  keyPressEvent(keyEvent);
373  }
374  return QWidget::eventFilter(obj, event);
375  }
void keyPressEvent(QKeyEvent *)
Definition: TuningList.cpp:345
bool omni::ui::proj::TuningList::frontendToData ( )
inlineprivatevirtual

Assign slider values to current session.

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

127  {
128  return false;
129  }
QColor omni::ui::proj::TuningList::getTuningColor ( )
private

Get most differing color for a new tuning.

Find first color in spectrum that is not already used

Compare R,G,B channels for both colors, alpha can be

Return the first color which is not equal to an existing

180  {
181  // Generate standard colors, for tuning
182  static std::vector<QColor> _colors;
183 
184  if (_colors.empty())
185  {
186  _colors.reserve(OMNI_MAX_NUMBER_TUNINGS);
187 
188  int _hue = 0;
189  int _hueDiff = 120;
190 
191  for (int i = 0; i < OMNI_MAX_NUMBER_TUNINGS; ++i)
192  {
193  int _saturation = float(OMNI_MAX_NUMBER_TUNINGS / 2 - i / 2) /
194  OMNI_MAX_NUMBER_TUNINGS * 2.0 * 255.0;
195  _colors.push_back(QColor::fromHsv(_hue, _saturation,
196  255));
197 
198  _hue += 120;
199 
200  if (_hue >= 360)
201  {
202  _hueDiff /= 2;
203  _hue += _hueDiff;
204  _hue %= 360;
205  }
206  }
207  }
208  int _numTunings = dataModel()->tunings().size();
209 
210  if (dataModel()->tunings().size() > OMNI_MAX_NUMBER_TUNINGS) return QColor("#000000");
211 
212  /// Find first color in spectrum that is not already used
213  for (int j = 0; j < OMNI_MAX_NUMBER_TUNINGS; ++j)
214  {
215  auto _color = _colors[j];
216  bool _colorsEqual = false;
217 
218  for (int i = 0; i < _numTunings; ++i)
219  {
220  auto _tuningColor = dataModel()->tunings()[i]->color();
221 
222  /// Compare R,G,B channels for both colors, alpha can be
223  // ignored
224  _colorsEqual |= _color.red() == _tuningColor.red() &&
225  _color.green() == _tuningColor.green() &&
226  _color.blue() == _tuningColor.blue();
227  }
228 
229  /// Return the first color which is not equal to an existing
230  if (!_colorsEqual) return _color;
231  }
232 
233  return _colors[_numTunings - 1];
234  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
#define OMNI_MAX_NUMBER_TUNINGS
Definition: TuningList.cpp:31
std::set< TuningGLView * > omni::ui::proj::TuningList::getViews ( int  _index) const

Return fullscreen and preview widget from index.

90  {
91  std::set<TuningGLView *> _views;
92 
93  if ((_index < 0) || (_index >= widgets_.size())) return _views;
94 
95  auto *_widget = widgets_[_index].get();
96  _views.insert(_widget->fullscreenWidget());
97  _views.insert(_widget->previewWidget());
98 
99  return _views;
100  }
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void omni::ui::proj::TuningList::keyPressEvent ( QKeyEvent *  _event)
protected
345  {
346  int _tuningIndex = dataModel()->tunings().currentIndex();
347  auto *_widget = widget(_tuningIndex);
348 
349  if (!_widget) return;
350 
351  if (_widget->hasFocus() && !_widget->isSelected()) return;
352 
353  if (_event->key() == Qt::Key_Up) {
354  if (!_widget->focusPrev(false) && (_tuningIndex > 0)) {
355  setTuningIndex(_tuningIndex - 1);
356  widget(_tuningIndex - 1)->focusLast();
357  }
358  }
359 
360  if (_event->key() == Qt::Key_Down) {
361  if (!_widget->focusNext(false) &&
362  (_tuningIndex < dataModel()->tunings().size() - 1)) {
363  setTuningIndex(_tuningIndex + 1);
364  widget(_tuningIndex + 1)->focusFirst();
365  }
366  }
367  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void setTuningIndex(int)
Set current tuning index manually (currentIndexChanged signal is emitted)
Definition: TuningList.cpp:395
void focusLast()
Set focus on last widget in parameter list.
Definition: ParameterWidget.cpp:226
Tuning * widget(int _index)
Return tuning widget at index, nullptr if index is not valid.
Definition: TuningList.cpp:62
void focusFirst()
Set focus on first widget in parameter list.
Definition: ParameterWidget.cpp:222
void omni::ui::proj::TuningList::removeTuning ( int  _index)
slot

Remove tuning.

237  {
238  if ((_index < 0) || (_index >= widgets_.size())) return;
239 
240  auto& _widget = widgets_[_index];
241  contents_->layout()->removeWidget(_widget.get());
242  _widget->setParent(nullptr);
243  widgets_.erase(widgets_.begin() + _index);
244 
245  dataModel()->tunings().remove(_index);
246 
247  // Re assign tuning indices to remaining widgets
248  for (int i = 0; i < dataModel()->tunings().size(); ++i)
249  {
250  dataModel()->tunings()[i]->makeVisualizer();
251  widgets_[i]->setIndex(i);
252  widgets_[i]->setDataModel(dataModel());
253  }
254  setTuningIndex(std::max(_index - 1, 0));
255 
256  emit tuningRemoved();
257  emit dataModelChanged();
258  }
void dataModelChanged()
Signal which is emitted when parameters of one tuning have changed.
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
QWidget * contents_
Definition: TuningList.h:142
void setTuningIndex(int)
Set current tuning index manually (currentIndexChanged signal is emitted)
Definition: TuningList.cpp:395
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void tuningRemoved()
Signal is emitted when a tuning was removed.
void omni::ui::proj::TuningList::removeWidgets ( )
private

Removes all widgets in the scroll area Unlike clear() it does not remove tunings from session.

284  {
285  for (auto& _widget : widgets_)
286  {
287  contents_->layout()->removeWidget(_widget.get());
288  _widget->setParent(nullptr);
289  }
290  widgets_.clear();
291  }
QWidget * contents_
Definition: TuningList.h:142
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void omni::ui::proj::TuningList::resizeEvent ( QResizeEvent *  event)
protected
339  {
340  for (auto& _widget : widgets_) _widget->layout()->update();
341 
342  QScrollArea::resizeEvent(event);
343  }
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void omni::ui::proj::TuningList::sessionModeChange ( )
slot

Change current mode for all tuning widgets.

261  {
262  if (!dataModel()) return;
263 
264  auto _currentIndex = dataModel()->tunings().currentIndex();
265 
266  for (auto& _widget : widgets_) {
267  _widget->sessionModeChange();
268  }
269 
270  if ((_currentIndex >= 0) && (_currentIndex < widgets_.size())) {
271  widgets_[_currentIndex]->setFocus();
272  }
273  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void omni::ui::proj::TuningList::setCurrentTuning ( )
slot

Set current tuning from currently selected widget.

378  {
379  if (!dataModel()) return;
380 
381  int _index = 0;
382 
383  for (auto& _widget : widgets_)
384  {
385  if (_widget->isSelected())
386  {
387  setTuningIndex(_index);
388  } else {
389  _widget->setSelected(false);
390  }
391  ++_index;
392  }
393  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void setTuningIndex(int)
Set current tuning index manually (currentIndexChanged signal is emitted)
Definition: TuningList.cpp:395
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void omni::ui::proj::TuningList::setTuningIndex ( int  _index)
slot

Set current tuning index manually (currentIndexChanged signal is emitted)

396  {
397  int _oldIndex = dataModel()->tunings().currentIndex();
398 
399  dataModel()->tunings().setCurrentIndex(_index);
400 
401  for (auto& _widget : widgets_) {
402  if ((_widget->index() != _index) && _widget->isSelected()) {
403  _widget->setSelected(false);
404  }
405  }
406 
407  if (_index != _oldIndex) emit currentIndexChanged(_index);
408 
409  emit dataModelChanged();
410  }
void dataModelChanged()
Signal which is emitted when parameters of one tuning have changed.
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void currentIndexChanged(int)
Signal which is emitted when the current tuning has changed.
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void omni::ui::proj::TuningList::tuningAdded ( )
signal

Signal is emitted when a tuning was added.

void omni::ui::proj::TuningList::tuningChanged ( )
signal

Emitted when a single tuning has changed.

void omni::ui::proj::TuningList::tuningRemoved ( )
signal

Signal is emitted when a tuning was removed.

void omni::ui::proj::TuningList::updateSceneSize ( bool  _rescaleValues)
slot

Adjust sliders to scene scale.

300  {
301  if (!dataModel() || isLocked()) return;
302 
303  for (auto& _widget : widgets_) {
304  _widget->setRescaleValues(_rescaleValues);
305  _widget->setScale(dataModel()->scene().size());
306  }
307  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void omni::ui::proj::TuningList::updateUnits ( )
slot

Set unit of sliders.

309  {
310  if (!dataModel() || isLocked()) return;
311 
312  for (auto& _widget : widgets_) {
313  _widget->setUnit(dataModel()->scene().unit().abbreviation());
314  }
315  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void omni::ui::proj::TuningList::updateViews ( )
slot

Updates/Repaints GL Views of all tunings widgets.

295  {
296  for (auto& _widget : widgets_) _widget->updateViews();
297  }
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
Tuning * omni::ui::proj::TuningList::widget ( int  _index)

Return tuning widget at index, nullptr if index is not valid.

62  {
63  return (_index >= 0) && (_index < widgets_.size()) ?
64  widgets_[_index].get() : nullptr;
65  }
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
Tuning const * omni::ui::proj::TuningList::widget ( int  _index) const

Return tuning widget at index, nullptr if index is not valid (const)

67  {
68  return (_index >= 0) && (_index < widgets_.size()) ?
69  widgets_[_index].get() : nullptr;
70  }
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
Tuning * omni::ui::proj::TuningList::widgetFromTuning ( omni::proj::Tuning _tuning)
72  {
73  for (auto& _widget : widgets_) {
74  if (_widget->tuning() == _tuning) return _widget.get();
75  }
76  return nullptr;
77  }
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145

Field Documentation

QWidget* omni::ui::proj::TuningList::contents_
private
QLayout* omni::ui::proj::TuningList::layout_
private
std::vector<QUniquePtr<Tuning> > omni::ui::proj::TuningList::widgets_
private

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