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 | Protected Attributes
omni::ui::ParameterWidget Class Reference

A widget which holds sub-widgets for manipulating parameters. More...

#include <ParameterWidget.h>

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

Public Slots

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 parametersUpdated ()
 

Public Member Functions

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

Protected Member Functions

virtual int firstFocusId () const
 Id of first focussed widget. More...
 
void keyPressEvent (QKeyEvent *_event)
 

Protected Attributes

std::vector< QUniquePtr
< QWidget > > 
parameters_
 Slider parameter widgets. More...
 
std::map< QString, QWidget * > parameterMap_
 Slider widgets, sorted by their label. More...
 

Additional Inherited Members

- Public Types inherited from omni::ui::mixin::Scale< omni::ui::RangedFloat >
typedef omni::ui::RangedFloat slider_type
 
typedef float scalar_type
 
- Static Public Member Functions inherited from omni::ui::mixin::Scale< omni::ui::RangedFloat >
static int getPrecision (float _scale)
 Return precesion by scale. More...
 

Detailed Description

A widget which holds sub-widgets for manipulating parameters.

Constructor & Destructor Documentation

omni::ui::ParameterWidget::ParameterWidget ( QWidget *  _parent = nullptr)

Default constructor.

28  :
29  QWidget(_parent)
30  {
31  }
omni::ui::ParameterWidget::~ParameterWidget ( )
virtual

Default Constructor.

34  {
35  }

Member Function Documentation

omni::ui::AffineTransform * omni::ui::ParameterWidget::addAffineTransformWidget ( QString const &  _id,
omni::AffineTransform *  _transform 
)

Add a new affine transform widget with an id.

Install event filter to pipe through focus event to parent widget

Signal-slot connection for updating the data model

301  {
302  if (getWidget(_id)) {
303  return static_cast<omni::ui::AffineTransform*>(getWidget(_id));
304  }
305 
306  auto* _widget = ui::makeWidget<omni::ui::AffineTransform>(_transform);
307 
308  if (layout())
309  layout()->addWidget(_widget);
310 
311  /// Install event filter to pipe through focus event to parent widget
312  _widget->installEventFilter(this);
313 
314  /// Signal-slot connection for updating the data model
315  connect(_widget,SIGNAL(dataModelChanged()),this,SLOT(updateParameters()));
316 
317  parameterMap_[_id] = _widget;
318  parameters_.emplace_back(_widget);
319  return _widget;
320  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
QWidget * getWidget(QString const &)
Get parameter widget from parameter map with Id.
Definition: ParameterWidget.cpp:192
A widget for editing an affine transformation.
Definition: AffineTransform.h:37
std::vector< QUniquePtr< QWidget > > parameters_
Slider parameter widgets.
Definition: ParameterWidget.h:159
virtual void updateParameters()
Definition: ParameterWidget.cpp:54
RangedFloat * omni::ui::ParameterWidget::addAngleWidget ( QString const &  _str,
float  _value,
float  _min,
float  _max 
)

Adds an angle widget with a name, a value and min-max range.

106  {
107  if (getWidget(_str)) {
108  return static_cast<RangedFloat*>(getWidget(_str));
109  }
110  auto* _angle = addWidget(_str,_value,_min,_max);
111  _angle->setSuffix("°");
112  _angle->setSingleStep(5.0);
113  _angle->setPageStep(45.0);
114  return _angle;
115  }
QWidget * getWidget(QString const &)
Get parameter widget from parameter map with Id.
Definition: ParameterWidget.cpp:192
RangedFloat * addWidget(QString const &, float, float, float)
Adds a widget with a name, a value and min-max range.
Definition: ParameterWidget.cpp:59
QCheckBox * omni::ui::ParameterWidget::addCheckBox ( QString const &  _text,
bool  _checked = false 
)

Adds a checkbox.

Signal-slot connection for updating the data model

132  {
133  if (getWidget(_text)) {
134  auto* _checkbox = static_cast<QCheckBox*>(getWidget(_text));
135  return _checkbox;
136  }
137 
138  auto* _checkbox = new QCheckBox(_text, this);
139  if (layout())
140  layout()->addWidget(_checkbox);
141 
142  _checkbox->setChecked(_checked);
143 
144  /// Signal-slot connection for updating the data model
145  connect(_checkbox,SIGNAL(clicked()),this,SLOT(updateParameters()));
146  parameterMap_[_text] = _checkbox;
147  parameters_.emplace_back(_checkbox);
148  return _checkbox;
149 
150  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
QWidget * getWidget(QString const &)
Get parameter widget from parameter map with Id.
Definition: ParameterWidget.cpp:192
std::vector< QUniquePtr< QWidget > > parameters_
Slider parameter widgets.
Definition: ParameterWidget.h:159
virtual void updateParameters()
Definition: ParameterWidget.cpp:54
RangedInt * omni::ui::ParameterWidget::addIntegerWidget ( QString const &  _str,
int  _value,
int  _min,
int  _max 
)

Adds a integer widget with a name, a value and min-max range.

Install event filter to pipe through focus event to parent widget

Signal-slot connection for updating the data model

81  {
82  if (getWidget(_str)) {
83  return static_cast<RangedInt*>(getWidget(_str));
84  }
85  auto* _widget = new RangedInt(_str,_value,_min,_max,this);
86  if (layout())
87  layout()->addWidget(_widget);
88 
89  _widget->setRange(_min,_max);
90  _widget->setSingleStep(1);
91  _widget->setPageStep(2);
92  _widget->setDefaultValue(_value);
93  _widget->setUseDefaultValue(true);
94 
95  /// Install event filter to pipe through focus event to parent widget
96  _widget->installEventFilter(this);
97 
98  /// Signal-slot connection for updating the data model
99  connect(_widget,SIGNAL(valueChanged()),this,SLOT(updateParameters()));
100  parameterMap_[_str] = _widget;
101  parameters_.emplace_back(_widget);
102  return _widget;
103  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
QWidget * getWidget(QString const &)
Get parameter widget from parameter map with Id.
Definition: ParameterWidget.cpp:192
std::vector< QUniquePtr< QWidget > > parameters_
Slider parameter widgets.
Definition: ParameterWidget.h:159
virtual void updateParameters()
Definition: ParameterWidget.cpp:54
RangedFloat * omni::ui::ParameterWidget::addOffsetWidget ( QString const &  _str,
float  _value,
float  _min,
float  _max 
)

Adds an offset widget with a name, a value and min-max range.

118  {
119  if (getWidget(_str)) {
120  return static_cast<RangedFloat*>(getWidget(_str));
121  }
122  auto* _offset = addWidget(_str,_value,_min,_max);
123  _offset->setSuffix("m");
124  _offset->setSingleStep(0.001);
125  _offset->setPageStep(0.01);
126  _offset->setPivot(0.0);
127  this->registerScaledSlider(_offset);
128  return _offset;
129  }
void registerScaledSlider(slider_type *_slider)
Register slider to be scaled.
Definition: Scale.h:89
QWidget * getWidget(QString const &)
Get parameter widget from parameter map with Id.
Definition: ParameterWidget.cpp:192
RangedFloat * addWidget(QString const &, float, float, float)
Adds a widget with a name, a value and min-max range.
Definition: ParameterWidget.cpp:59
Rotation * omni::ui::ParameterWidget::addRotationWidget ( QString const &  _str)

Adds an Rotation widget with three dials for X,Y and Z axis.

Install event filter to pipe through focus event to parent widget

Signal-slot connection for updating the data model

278  {
279  if (getWidget(_str)) {
280  return static_cast<Rotation*>(getWidget(_str));
281  }
282  auto* _widget = new Rotation(0.0,0.0,0.0,this);
283 
284  if (layout())
285  layout()->addWidget(_widget);
286 
287  /// Install event filter to pipe through focus event to parent widget
288  _widget->installEventFilter(this);
289 
290  /// Signal-slot connection for updating the data model
291  connect(_widget,SIGNAL(xChanged()),this,SLOT(updateParameters()));
292  connect(_widget,SIGNAL(yChanged()),this,SLOT(updateParameters()));
293  connect(_widget,SIGNAL(zChanged()),this,SLOT(updateParameters()));
294 
295  parameterMap_[_str] = _widget;
296  parameters_.emplace_back(_widget);
297  return _widget;
298  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
QWidget * getWidget(QString const &)
Get parameter widget from parameter map with Id.
Definition: ParameterWidget.cpp:192
std::vector< QUniquePtr< QWidget > > parameters_
Slider parameter widgets.
Definition: ParameterWidget.h:159
virtual void updateParameters()
Definition: ParameterWidget.cpp:54
RangedFloat * omni::ui::ParameterWidget::addWidget ( QString const &  _str,
float  _value,
float  _min,
float  _max 
)

Adds a widget with a name, a value and min-max range.

Install event filter to pipe through focus event to parent widget

Signal-slot connection for updating the data model

60  {
61  auto* _widget = new RangedFloat(_str,_value,_min,_max,this);
62  if (layout())
63  layout()->addWidget(_widget);
64 
65  this->installEventFilter(_widget);
66 
67  _widget->setUseDefaultValue(true);
68 
69  /// Install event filter to pipe through focus event to parent widget
70  _widget->installEventFilter(this);
71 
72  /// Signal-slot connection for updating the data model
73  connect(_widget,SIGNAL(valueChanged()),this,SLOT(updateParameters()));
74  parameterMap_[_str] = _widget;
75  parameters_.emplace_back(_widget);
76  return _widget;
77  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
std::vector< QUniquePtr< QWidget > > parameters_
Slider parameter widgets.
Definition: ParameterWidget.h:159
virtual void updateParameters()
Definition: ParameterWidget.cpp:54
void omni::ui::ParameterWidget::clear ( )
slot

Removes all parameter widgets.

39  {
40  parameters_.clear();
41  parameterMap_.clear();
42 
43  if (layout())
44  {
45  QLayoutItem *item = nullptr;
46  while ((item = layout()->takeAt(0)))
47  {
48  delete item->widget();
49  delete item;
50  }
51  }
52  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
std::vector< QUniquePtr< QWidget > > parameters_
Slider parameter widgets.
Definition: ParameterWidget.h:159
virtual int omni::ui::ParameterWidget::firstFocusId ( ) const
inlineprotectedvirtual

Id of first focussed widget.

Reimplemented in omni::ui::proj::Tuning.

152  {
153  return 0;
154  }
void omni::ui::ParameterWidget::focus ( int  _index)
slot

Focus item in layout with index.

216  {
217  if (!layout()->itemAt(_index)) return;
218 
219  layout()->itemAt(_index)->widget()->setFocus();
220  }
void omni::ui::ParameterWidget::focusFirst ( )
slot

Set focus on first widget in parameter list.

222  {
223  focus(firstFocusId());
224  }
virtual int firstFocusId() const
Id of first focussed widget.
Definition: ParameterWidget.h:152
void focus(int _index)
Focus item in layout with index.
Definition: ParameterWidget.cpp:216
int omni::ui::ParameterWidget::focusId ( ) const

Return id of focused parameter, -1 if no parameter is focused.

204  {
205  int _id = 0;
206  for (int i = 0; i < layout()->count(); ++i) {
207  auto _param = layout()->itemAt(i)->widget();
208  if (_param->hasFocus()) {
209  return _id;
210  }
211  ++_id;
212  }
213  return -1;
214  }
void omni::ui::ParameterWidget::focusLast ( )
slot

Set focus on last widget in parameter list.

226  {
227  focus(layout()->count()-1);
228  }
void focus(int _index)
Focus item in layout with index.
Definition: ParameterWidget.cpp:216
bool omni::ui::ParameterWidget::focusNext ( bool  _circular = false)
slot

Put focus on next element.

Parameters
_circularSelects first parameter when last parameter has been reached
Returns
True if last parameter has been reached, always returns true when in circular mode
247  {
248  int _focusId = focusId();
249 
250  if (_focusId != -1) {
251  int _nextFocusId = _focusId + 1;
252  if (_nextFocusId >= layout()->count()) {
253  _nextFocusId = _circular ? firstFocusId() : layout()->count() - 1;
254  }
255  auto _param = layout()->itemAt(_nextFocusId)->widget();
256  _param->setFocus();
257  return _focusId != _nextFocusId;
258  }
259  return false;
260  }
virtual int firstFocusId() const
Id of first focussed widget.
Definition: ParameterWidget.h:152
int focusId() const
Return id of focused parameter, -1 if no parameter is focused.
Definition: ParameterWidget.cpp:204
bool omni::ui::ParameterWidget::focusPrev ( bool  _circular = false)
slot

Put focus on prev element.

Parameters
_circularSelects last parameter when first parameter has been reached
Returns
True if first parameter has been reached, always returns true when in circular mode
262  {
263  int _focusId = focusId();
264 
265  if (_focusId != -1) {
266  int _prevFocus = _focusId - 1;
267  if (_prevFocus < firstFocusId()) {
268  _prevFocus = _circular ? layout()->count() - 1 : firstFocusId();
269  }
270  auto _param = layout()->itemAt(_prevFocus)->widget();
271  _param->setFocus();
272  return _focusId != _prevFocus;
273  }
274  return false;
275  }
virtual int firstFocusId() const
Id of first focussed widget.
Definition: ParameterWidget.h:152
int focusId() const
Return id of focused parameter, -1 if no parameter is focused.
Definition: ParameterWidget.cpp:204
bool omni::ui::ParameterWidget::getParamAsBool ( QString const &  _str) const
slot

Utility method for retrieving the value from checkbox with id.

185  {
186  auto* _widget = static_cast<QCheckBox*>(this->parameterMap_.at(_str));
187  if (!_widget) return false;
188  return _widget->isChecked();
189  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
double omni::ui::ParameterWidget::getParamAsFloat ( QString const &  _str) const
slot

Utility method for retrieving the value from a slider with id.

153  {
154  auto* _widget = static_cast<RangedFloat*>(this->parameterMap_.at(_str));
155  if (!_widget) return 0.0;
156 
157 
158  return _widget->value();
159  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
int omni::ui::ParameterWidget::getParamAsInt ( QString const &  _str) const
slot

Utility method for retrieving the value from a slider with id.

170  {
171  auto* _widget = static_cast<RangedInt*>(this->parameterMap_.at(_str));
172  if (!_widget) return 0;
173  return _widget->value();
174  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
QWidget * omni::ui::ParameterWidget::getWidget ( QString const &  _id)
slot

Get parameter widget from parameter map with Id.

193  {
194  if (!parameterMap_.count(_id)) return nullptr;
195  return parameterMap_[_id];
196  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
void omni::ui::ParameterWidget::keyPressEvent ( QKeyEvent *  _event)
protected
238  {
239  if (_event->key() == Qt::Key_Up) {
240  focusPrev(false);
241  }
242  if (_event->key() == Qt::Key_Down) {
243  focusNext(false);
244  }
245  }
bool focusNext(bool _circular=false)
Put focus on next element.
Definition: ParameterWidget.cpp:247
bool focusPrev(bool _circular=false)
Put focus on prev element.
Definition: ParameterWidget.cpp:262
void omni::ui::ParameterWidget::parametersUpdated ( )
signal
void omni::ui::ParameterWidget::setParamAsFloat ( QString const &  _str,
double  _value 
)
slot

Set slider value from given value.

162  {
163  auto* _widget = static_cast<RangedFloat*>(this->parameterMap_.at(_str));
164  if (!_widget) return;
165 
166  _widget->setValue(_value);
167  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
void omni::ui::ParameterWidget::setParamAsInt ( QString const &  _str,
int  _value 
)
slot

Set slider value from given value.

177  {
178  auto* _widget = static_cast<RangedInt*>(this->parameterMap_.at(_str));
179  if (!_widget) return;
180 
181  _widget->setValue(_value);
182  }
std::map< QString, QWidget * > parameterMap_
Slider widgets, sorted by their label.
Definition: ParameterWidget.h:162
void omni::ui::ParameterWidget::setParametersVisible ( bool  _visible)
slot

Show / hide parameter widgets.

199  {
200  for (auto& _parameter : parameters_)
201  _parameter->setVisible(_visible);
202  }
std::vector< QUniquePtr< QWidget > > parameters_
Slider parameter widgets.
Definition: ParameterWidget.h:159
void omni::ui::ParameterWidget::setScale ( float  _scale)
virtualslot

Set slider ranges.

230  {
232  }
virtual void setScale(float _scale)
Set scale and apply to sliders.
Definition: Scale.h:38
void omni::ui::ParameterWidget::setUnit ( QString const &  _unitAbbr)
virtualslot

Set slider ranges.

234  {
236  }
void setSuffix(QString const &_suffix)
Set suffix (unit) of slider.
Definition: Scale.h:80
void omni::ui::ParameterWidget::updateParameters ( )
virtualslot
55  {
56  emit parametersUpdated();
57  }

Field Documentation

std::map<QString, QWidget *> omni::ui::ParameterWidget::parameterMap_
protected

Slider widgets, sorted by their label.

std::vector<QUniquePtr<QWidget> > omni::ui::ParameterWidget::parameters_
protected

Slider parameter widgets.


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