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 Member Functions | Private Attributes
omni::ui::RangedFloat Class Reference

A slider with float value within a minimum and maximum. More...

#include <RangedFloat.h>

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

Public Types

enum  Scale { Scale::LINEAR, Scale::RECIPROCAL }
 
typedef mixin::RangedValue
< RangedFloat, double > 
mixin_range_type
 
typedef QDoubleSpinBox editor_type
 
- Public Types inherited from omni::ui::AbstractInputWidget
typedef mixin::Editor
< AbstractInputWidget, QWidget > 
mixin_editor_type
 

Public Slots

void setValue (double)
 Set value, valueChanged() signal will be emitted. More...
 
void setMinimum (double)
 Set minimal value, rangeChanged() signal will be emitted. More...
 
void setMaximum (double)
 Set maximum value, rangeChanged() signal will be emitted. More...
 
void setRange (double, double)
 Set range (minimum/maximum), rangeChanged() signel will be emitted. More...
 
void setEditorVisible (bool)
 Show/hide editor. More...
 
void setSnap (bool)
 Toggle value snap on/off. More...
 
void setGripSize (int)
 
void setUseDefaultValue (bool)
 Use Default Value and show it. More...
 
void setDrawTicks (bool)
 
void setPrecision (int)
 Set precision. More...
 
void setSuffix (QString const &)
 Set Suffix. More...
 
void setPivot (double)
 Set pivot. More...
 
void setDefaultValue (double)
 
void setSingleStep (double)
 
void setPageStep (double)
 
void setScale (Scale)
 
- Public Slots inherited from omni::ui::AbstractInputWidget
virtual void setEditorVisible (bool)
 Set editor visible. More...
 
void showEditor ()
 Show editor. More...
 
void hideEditor ()
 Hide editor. More...
 

Signals

void valueChanged ()
 
void rangeChanged ()
 
- Signals inherited from omni::ui::AbstractInputWidget
void valueChanged ()
 Value changed event. More...
 

Public Member Functions

 RangedFloat (QWidget *=nullptr)
 Construct from parent widget. More...
 
 RangedFloat (QString const &_label, double _value, double _min, double _max, QWidget *=nullptr)
 Construct with input parameters. More...
 
virtual ~RangedFloat ()
 
QString suffix () const
 Return suffix. More...
 
int precision () const
 Return precision. More...
 
int gripSize () const
 Return grip size. More...
 
bool useDefaultValue () const
 Return flag if default value is used. More...
 
bool drawTicks () const
 
Scale scale () const
 
- Public Member Functions inherited from omni::ui::AbstractInputWidget
 AbstractInputWidget (QWidget *=nullptr)
 
virtual ~AbstractInputWidget ()
 
- Public Member Functions inherited from omni::ui::Widget
 Widget (QWidget *=nullptr)
 
 Widget (QString const &_label, QWidget *=nullptr)
 
virtual ~Widget ()
 
QString label () const
 Return label text of widget. More...
 
void setLabel (QString const &)
 Set label text of widget. More...
 
ColorSet const & colorSet () const
 
double zoomFactor () const
 Zoom factor of widget. More...
 

Protected Member Functions

void paintEvent (QPaintEvent *)
 
void keyPressEvent (QKeyEvent *)
 Show editor when enter key is pressed. More...
 
void mouseMoveEvent (QMouseEvent *)
 
void mousePressEvent (QMouseEvent *)
 Hide editor and set focus on click. More...
 
void mouseReleaseEvent (QMouseEvent *)
 
void mouseDoubleClickEvent (QMouseEvent *)
 Show editor on double click. More...
 
void wheelEvent (QWheelEvent *)
 
void valueChangedEvent ()
 Value changed event which is emitted on changed value. More...
 
void rangeChangedEvent ()
 Handler to emit rangeChanged signal in derived widgets. More...
 
- Protected Member Functions inherited from omni::ui::AbstractInputWidget
void drawHandle (QPainter &_p, double _pos, double _heightFactor=1.0) const
 Draw slider handle. More...
 
void drawTrack (QPainter &_p, double _pos) const
 
void drawTrack (QPainter &_p, double _left, double _right) const
 
void init ()
 
- Protected Member Functions inherited from omni::ui::Widget
void drawBorder (QPainter &)
 
void drawBorder (QPainter &, bool _focus)
 
- Protected Member Functions inherited from omni::ui::mixin::Editor< AbstractInputWidget, QWidget >
 Editor (widget_type *_widget)
 
T * createEditor ()
 Create editor with type. More...
 
editor_type const * editor () const
 Return pointer editor (const version) More...
 
editor_typeeditor ()
 Return pointer editor. More...
 
T * editorAs ()
 Return editor as type T. More...
 
T const * editorAs () const
 Return editor as type T (const version) More...
 
virtual void setEditorVisible (bool _visible)
 Set editor visibility and set focus. More...
 
void showEditor ()
 Show editor and set focus. More...
 
void hideEditor ()
 Hide editor. More...
 

Private Member Functions

void init ()
 
void editorSetup ()
 
double valueFromPos (double) const
 Get value from x mouse position. More...
 
double valueToPos () const
 Calculate position from value. More...
 
double valueToPos (double) const
 Calculate position from value. More...
 
- Private Member Functions inherited from omni::ui::mixin::RangedValue< RangedFloat, double >
 RangedValue ()
 Default constructor. More...
 
 RangedValue (value_type _value, value_type _minimum, value_type _maximum, value_type _singleStep=1.0, value_type _pageStep=10.0)
 Constructor from user defined value and range. More...
 
qreal ratio () const
 Returns ratio of current value. More...
 
value_type value () const
 Return value. More...
 
value_type defaultValue () const
 Return default value. More...
 
value_type pivot () const
 Return pivot value. More...
 
void increase ()
 Increate value by single step value. More...
 
void decrease ()
 Decrease value by single step value. More...
 
void setValue (value_type _value)
 Set new value and emit value changed event. More...
 
void reset ()
 Reset value to default value. More...
 
void setDefaultValue (value_type _value)
 Set new default value. More...
 
void setPivot (value_type _pivot)
 Set pivot value (0.0 by default) More...
 
void apply (WIDGET *_widget) const
 Apply ranged value to widget. More...
 
void for_each_step (F f)
 Functor to apply for each step. More...
 
void validate ()
 Validate minimum, maximum and value. More...
 
- Private Member Functions inherited from omni::ui::mixin::Range< double >
 Range (value_type _minimum=0.0, value_type _maximum=100.0)
 
qreal ratio (value_type _v) const
 Return ratio of value v. More...
 
value_type range () const
 Return range (difference between maximum and minimum) More...
 
value_type minimum () const
 Return minimum value. More...
 
value_type maximum () const
 Return maximum value. More...
 
void setMinimum (value_type _minimum)
 Set new minimum value and value and emit rangeChanged event. More...
 
void disableMinimum ()
 Disable minimum by setting the value to infinite. More...
 
void setMaximum (value_type _maximum)
 Set new maximum value and value and emit rangeChanged event. More...
 
void disableMaximum ()
 Disable maximum by setting maximum to infinite value. More...
 
void setRange (value_type _minimum, value_type _maximum)
 Set range and validate. More...
 
void disableRange ()
 Disable range by setting minimum and maximum to infinite value. More...
 
bool minimumUsed () const
 
bool maximumUsed () const
 
void apply (WIDGET *_widget) const
 Apply range to widget. More...
 
void apply (WIDGET *_widget, V _value) const
 Applay range to widget and set value. More...
 
- Private Member Functions inherited from omni::ui::mixin::Step< double >
 Step (value_type _singleStep=1.0, value_type _pageStep=10.0, bool _snap=false)
 Construct with a single step, page step value. More...
 
qreal snapped (value_type _v) const
 Return snapped value. More...
 
bool snap () const
 Snap value (align to single step value) More...
 
void setSnap (bool _snap)
 Set boolean if value is to be snapped. More...
 
value_type singleStep () const
 Return value for single step. More...
 
value_type pageStep () const
 Return value for page step. More...
 
void setSingleStep (value_type _singleStep)
 Set new single step value. More...
 
void setPageStep (value_type _pageStep)
 Set new value for page step. More...
 
void for_each_step (MIN _min, MAX _max, F f)
 Functor to be applied for each step between min and maximum. More...
 

Private Attributes

Scale scale_ = Scale::LINEAR
 
bool moving_ = false
 
bool drawTicks_ = false
 
bool useDefaultValue_ = false
 
QString suffix_
 
int gripSize_ = 0
 
int precision_ = 2
 

Additional Inherited Members

- Protected Types inherited from omni::ui::mixin::Editor< AbstractInputWidget, QWidget >
typedef AbstractInputWidget widget_type
 Widget type. More...
 
typedef QWidget editor_type
 Editor widget type, e.g. QDoubleSpinBox. More...
 
- Protected Attributes inherited from omni::ui::AbstractInputWidget
QLabel * valueLabel_ = nullptr
 
- Protected Attributes inherited from omni::ui::Widget
QLabel * label_
 
- Private Types inherited from omni::ui::mixin::RangedValue< RangedFloat, double >
typedef Range< double > range_type
 
typedef Step< double > step_type
 
typedef double value_type
 
- Private Types inherited from omni::ui::mixin::Range< double >
typedef double value_type
 
- Private Types inherited from omni::ui::mixin::Step< double >
typedef double value_type
 

Detailed Description

A slider with float value within a minimum and maximum.

Member Typedef Documentation

typedef QDoubleSpinBox omni::ui::RangedFloat::editor_type

Member Enumeration Documentation

Enumerator
LINEAR 
RECIPROCAL 
35  {
36  LINEAR,
37  RECIPROCAL
38  };

Constructor & Destructor Documentation

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

Construct from parent widget.

29  :
30  AbstractInputWidget(_parent)
31  {
32  init();
33  }
void init()
Definition: RangedFloat.cpp:340
AbstractInputWidget(QWidget *=nullptr)
Definition: AbstractInputWidget.cpp:28
omni::ui::RangedFloat::RangedFloat ( QString const &  _label,
double  _value,
double  _min,
double  _max,
QWidget *  _parent = nullptr 
)

Construct with input parameters.

Parameters
_labelLabel of widget
_valueInitial value
_minMinimal value
_maxMaximal value
39  :
40  AbstractInputWidget(_parent),
41  mixin_range_type(_value, _min, _max)
42  {
43  init();
44  setLabel(_label);
45  }
void init()
Definition: RangedFloat.cpp:340
void setLabel(QString const &)
Set label text of widget.
Definition: Widget.cpp:50
AbstractInputWidget(QWidget *=nullptr)
Definition: AbstractInputWidget.cpp:28
mixin::RangedValue< RangedFloat, double > mixin_range_type
Definition: RangedFloat.h:40
omni::ui::RangedFloat::~RangedFloat ( )
virtual
48  {}

Member Function Documentation

bool omni::ui::RangedFloat::drawTicks ( ) const
145  {
146  return drawTicks_;
147  }
bool drawTicks_
Definition: RangedFloat.h:159
void omni::ui::RangedFloat::editorSetup ( )
privatevirtual

Implements omni::ui::mixin::Editor< AbstractInputWidget, QWidget >.

355  {
356  auto _editor = this->editorAs<editor_type>();
357 
358  connect(_editor, SIGNAL(valueChanged(double)), this,
359  SLOT(setValue(double)));
360  _editor->setFrame(false);
361  _editor->setAlignment(Qt::AlignRight);
362  _editor->setButtonSymbols(QAbstractSpinBox::PlusMinus);
363  mixin_range_type::apply(_editor);
365  }
void valueChangedEvent()
Value changed event which is emitted on changed value.
Definition: RangedFloat.cpp:60
void setValue(double)
Set value, valueChanged() signal will be emitted.
Definition: RangedFloat.cpp:80
void apply(WIDGET *_widget) const
Apply ranged value to widget.
Definition: RangedValue.h:136
int omni::ui::RangedFloat::gripSize ( ) const

Return grip size.

367  {
368  return gripSize_;
369  }
int gripSize_
Definition: RangedFloat.h:162
void omni::ui::RangedFloat::init ( )
private
341  {
342  setSingleStep(1.0);
343  AbstractInputWidget::createEditor<editor_type>();
344  }
void setSingleStep(double)
Definition: RangedFloat.cpp:119
void omni::ui::RangedFloat::keyPressEvent ( QKeyEvent *  e)
protectedvirtual

Show editor when enter key is pressed.

Reimplemented from omni::ui::AbstractInputWidget.

271  {
273  float _step = pageStep();
274 
275  if (_event->modifiers() & Qt::ShiftModifier) {
276  _step = singleStep();
277  }
278  if (_event->modifiers() & Qt::ControlModifier) {
279  _step *= 10.0;
280  }
281 
282  if (_event->key() == Qt::Key_Left) {
283  setValue(value() - _step);
284  }
285  if (_event->key() == Qt::Key_Right) {
286  setValue(value() + _step);
287  }
288  }
value_type value() const
Return value.
Definition: RangedValue.h:65
value_type pageStep() const
Return value for page step.
Definition: Step.h:73
void setValue(double)
Set value, valueChanged() signal will be emitted.
Definition: RangedFloat.cpp:80
value_type singleStep() const
Return value for single step.
Definition: Step.h:67
virtual void keyPressEvent(QKeyEvent *)
Show editor when enter key is pressed.
Definition: AbstractInputWidget.cpp:79
void omni::ui::RangedFloat::mouseDoubleClickEvent ( QMouseEvent *  )
protectedvirtual

Show editor on double click.

Reimplemented from omni::ui::AbstractInputWidget.

315  {
316  if (useDefaultValue())
317  {
318  if (std::abs(e->pos().x() - valueToPos(defaultValue())) <= 4)
319  {
321  return;
322  }
323  }
324 
326  }
virtual void mouseDoubleClickEvent(QMouseEvent *)
Show editor on double click.
Definition: AbstractInputWidget.cpp:74
void reset()
Reset value to default value.
Definition: RangedValue.h:116
bool useDefaultValue() const
Return flag if default value is used.
Definition: RangedFloat.cpp:133
value_type defaultValue() const
Return default value.
Definition: RangedValue.h:71
double valueToPos() const
Calculate position from value.
Definition: RangedFloat.cpp:208
void omni::ui::RangedFloat::mouseMoveEvent ( QMouseEvent *  e)
protected
291  {
292  if (moving_)
293  {
294  setValue(valueFromPos(e->pos().x()));
295  }
296  }
void setValue(double)
Set value, valueChanged() signal will be emitted.
Definition: RangedFloat.cpp:80
bool moving_
Definition: RangedFloat.h:158
double valueFromPos(double) const
Get value from x mouse position.
Definition: RangedFloat.cpp:169
void omni::ui::RangedFloat::mousePressEvent ( QMouseEvent *  )
protectedvirtual

Hide editor and set focus on click.

Reimplemented from omni::ui::AbstractInputWidget.

299  {
301 
302  if (std::abs(e->pos().x() - valueToPos()) <= gripSize_ || !gripSize_)
303  {
304  moving_ = true;
305  setValue(valueFromPos(e->pos().x()));
306  }
307  }
virtual void mousePressEvent(QMouseEvent *)
Hide editor and set focus on click.
Definition: AbstractInputWidget.cpp:68
void setValue(double)
Set value, valueChanged() signal will be emitted.
Definition: RangedFloat.cpp:80
bool moving_
Definition: RangedFloat.h:158
double valueToPos() const
Calculate position from value.
Definition: RangedFloat.cpp:208
double valueFromPos(double) const
Get value from x mouse position.
Definition: RangedFloat.cpp:169
int gripSize_
Definition: RangedFloat.h:162
void omni::ui::RangedFloat::mouseReleaseEvent ( QMouseEvent *  e)
protected
310  {
311  moving_ = false;
312  }
bool moving_
Definition: RangedFloat.h:158
void omni::ui::RangedFloat::paintEvent ( QPaintEvent *  _paintEvent)
protected
236  {
237  if (!isVisible()) return;
238 
239  QPainter _p(this);
240  _p.setRenderHint(QPainter::Antialiasing);
241  double _pos = valueToPos();
242 
244 
246  valueToPos(
247  defaultValue()),
248  0.5);
249 
250  if (drawTicks())
251  {
252  mixin_range_type::for_each_step([&](int _step, double i,
253  bool _isPage)
254  {
255  _p.setPen(QPen(i >= mixin_range_type::value() ?
256  colorSet().shadow() :
257  colorSet().windowText(), 1));
258 
259  double _pos = valueToPos(i);
260  double _sizeFactor = _isPage ? 0.3 : 0.15;
261  _p.drawLine(
262  QPointF(_pos,
263  rect().bottom() - rect().height() * _sizeFactor),
264  QPointF(_pos, rect().bottom()));
265  });
266  }
268  hasFocus() || editor()->hasFocus());
269  }
editor_type const * editor() const
Return pointer editor (const version)
Definition: Editor.h:58
value_type value() const
Return value.
Definition: RangedValue.h:65
void drawBorder(QPainter &)
Definition: Widget.cpp:79
void drawHandle(QPainter &_p, double _pos, double _heightFactor=1.0) const
Draw slider handle.
Definition: AbstractInputWidget.cpp:87
bool useDefaultValue() const
Return flag if default value is used.
Definition: RangedFloat.cpp:133
ColorSet const & colorSet() const
Definition: Widget.cpp:56
value_type defaultValue() const
Return default value.
Definition: RangedValue.h:71
double valueToPos() const
Calculate position from value.
Definition: RangedFloat.cpp:208
value_type pivot() const
Return pivot value.
Definition: RangedValue.h:77
bool drawTicks() const
Definition: RangedFloat.cpp:144
void for_each_step(F f)
Functor to apply for each step.
Definition: RangedValue.h:145
void drawTrack(QPainter &_p, double _pos) const
Definition: AbstractInputWidget.cpp:119
int omni::ui::RangedFloat::precision ( ) const

Return precision.

56  {
57  return precision_;
58  }
int precision_
Definition: RangedFloat.h:163
void omni::ui::RangedFloat::rangeChanged ( )
signal
void omni::ui::RangedFloat::rangeChangedEvent ( )
protectedvirtual

Handler to emit rangeChanged signal in derived widgets.

Reimplemented from omni::ui::mixin::Range< double >.

75  {
76  mixin_range_type::apply(editorAs<editor_type>());
77  emit rangeChanged();
78  }
void apply(WIDGET *_widget) const
Apply ranged value to widget.
Definition: RangedValue.h:136
RangedFloat::Scale omni::ui::RangedFloat::scale ( ) const
346  {
347  return scale_;
348  }
Scale scale_
Definition: RangedFloat.h:157
void omni::ui::RangedFloat::setDefaultValue ( double  _defaultValue)
slot
113  {
114  mixin_range_type::setDefaultValue(_defaultValue);
115 
116  update();
117  }
void setDefaultValue(value_type _value)
Set new default value.
Definition: RangedValue.h:122
void omni::ui::RangedFloat::setDrawTicks ( bool  _ticks)
slot
150  {
151  drawTicks_ = _ticks;
152  update();
153  }
bool drawTicks_
Definition: RangedFloat.h:159
void omni::ui::RangedFloat::setEditorVisible ( bool  _visible)
slot

Show/hide editor.

335  {
337  mixin_range_type::apply(editorAs<editor_type>());
338  }
virtual void setEditorVisible(bool)
Set editor visible.
Definition: AbstractInputWidget.cpp:45
void apply(WIDGET *_widget) const
Apply ranged value to widget.
Definition: RangedValue.h:136
void omni::ui::RangedFloat::setGripSize ( int  _gripSize)
slot
371  {
372  gripSize_ = _gripSize;
373  }
int gripSize_
Definition: RangedFloat.h:162
void omni::ui::RangedFloat::setMaximum ( double  _max)
slot

Set maximum value, rangeChanged() signal will be emitted.

91  {
93  }
void setMaximum(value_type _maximum)
Set new maximum value and value and emit rangeChanged event.
Definition: Range.h:80
void omni::ui::RangedFloat::setMinimum ( double  _min)
slot

Set minimal value, rangeChanged() signal will be emitted.

86  {
88  }
void setMinimum(value_type _minimum)
Set new minimum value and value and emit rangeChanged event.
Definition: Range.h:66
void omni::ui::RangedFloat::setPageStep ( double  _pageStep)
slot
127  {
129 
130  update();
131  }
void setPageStep(value_type _pageStep)
Set new value for page step.
Definition: Step.h:85
void omni::ui::RangedFloat::setPivot ( double  _pivot)
slot

Set pivot.

106  {
108 
109  update();
110  }
void setPivot(value_type _pivot)
Set pivot value (0.0 by default)
Definition: RangedValue.h:128
void omni::ui::RangedFloat::setPrecision ( int  _precision)
slot

Set precision.

156  {
157  precision_ = _precision;
158  editorAs<editor_type>()->setDecimals(_precision);
160  }
void valueChangedEvent()
Value changed event which is emitted on changed value.
Definition: RangedFloat.cpp:60
int precision_
Definition: RangedFloat.h:163
void omni::ui::RangedFloat::setRange ( double  _min,
double  _max 
)
slot

Set range (minimum/maximum), rangeChanged() signel will be emitted.

96  {
97  mixin_range_type::setRange(_min, _max);
98  }
void setRange(value_type _minimum, value_type _maximum)
Set range and validate.
Definition: Range.h:94
void omni::ui::RangedFloat::setScale ( Scale  _scale)
slot
350  {
351  scale_ = _scale;
352  update();
353  }
Scale scale_
Definition: RangedFloat.h:157
void omni::ui::RangedFloat::setSingleStep ( double  _singleStep)
slot
120  {
121  mixin_range_type::setSingleStep(_singleStep);
122 
123  update();
124  }
void setSingleStep(value_type _singleStep)
Set new single step value.
Definition: Step.h:79
void omni::ui::RangedFloat::setSnap ( bool  _snap)
slot

Toggle value snap on/off.

101  {
103  }
void setSnap(bool _snap)
Set boolean if value is to be snapped.
Definition: Step.h:61
void omni::ui::RangedFloat::setSuffix ( QString const &  _suffix)
slot

Set Suffix.

163  {
164  suffix_ = _suffix;
165  editorAs<editor_type>()->setSuffix(_suffix);
167  }
void valueChangedEvent()
Value changed event which is emitted on changed value.
Definition: RangedFloat.cpp:60
QString suffix_
Definition: RangedFloat.h:161
void setSuffix(QString const &)
Set Suffix.
Definition: RangedFloat.cpp:162
void omni::ui::RangedFloat::setUseDefaultValue ( bool  _defaultValue)
slot

Use Default Value and show it.

139  {
140  useDefaultValue_ = _defaultValue;
141  update();
142  }
bool useDefaultValue_
Definition: RangedFloat.h:160
void omni::ui::RangedFloat::setValue ( double  _value)
slot

Set value, valueChanged() signal will be emitted.

81  {
83  }
void setValue(value_type _value)
Set new value and emit value changed event.
Definition: RangedValue.h:105
QString omni::ui::RangedFloat::suffix ( ) const

Return suffix.

51  {
52  return suffix_;
53  }
QString suffix_
Definition: RangedFloat.h:161
bool omni::ui::RangedFloat::useDefaultValue ( ) const

Return flag if default value is used.

134  {
135  return useDefaultValue_;
136  }
bool useDefaultValue_
Definition: RangedFloat.h:160
void omni::ui::RangedFloat::valueChanged ( )
signal
void omni::ui::RangedFloat::valueChangedEvent ( )
protectedvirtual

Value changed event which is emitted on changed value.

Reimplemented from omni::ui::mixin::RangedValue< RangedFloat, double >.

61  {
62  mixin_range_type::apply(editorAs<editor_type>());
63  AbstractInputWidget::valueLabel_->setText(QString("%1%2")
64  .arg(QString::number(
65  value(),
66  'f',
67  precision_))
68  .arg(suffix()));
69 
70  update();
71  emit valueChanged();
72  }
value_type value() const
Return value.
Definition: RangedValue.h:65
int precision_
Definition: RangedFloat.h:163
void apply(WIDGET *_widget) const
Apply ranged value to widget.
Definition: RangedValue.h:136
QString suffix() const
Return suffix.
Definition: RangedFloat.cpp:50
QLabel * valueLabel_
Definition: AbstractInputWidget.h:78
double omni::ui::RangedFloat::valueFromPos ( double  _pos) const
private

Get value from x mouse position.

Todo:
Handle RECIPROCAL mode
170  {
171  auto && _rect = rect();
172  if (scale_ == Scale::RECIPROCAL) {
173  if (minimum() <= 1.0 && maximum() >= 1.0 && minimum() > 0.0) {
174 
175  double _recMinimum = - 1.0 / minimum();
176  double _max = maximum();
177  double _posOne = valueToPos(1.0);
178 
179  double _v = (_pos - _rect.left()) / _rect.width() *
180  (maximum() - _recMinimum) + _recMinimum;
181 
182  qDebug() << "valueFromPos: "<< _v;
183 
184  if (_v < 0.0) {
185  _v = (_v - minimum()) * (1.0 / minimum() + maximum() /
186  (1.0 / minimum() - 1.0) ) - 1.0 / minimum();
187  } else {
188  _v = (_v + 1.0) / (_max - minimum() + 1.0) * (_max - minimum());
189  }
190  return _v;
191 
192  qDebug() << "valueFromPos: " << _recMinimum << " " << _max << " " << _posOne << " " << _pos;
193  if (_pos < _posOne) {
194  return - 1.0 / (_pos - _rect.left()) / _rect.width() *
195  (_max - _recMinimum) + _recMinimum;
196  } else {
197  return ((_pos - _posOne) - _rect.left()) / (_rect.width() - _posOne) *
198  (maximum() - minimum()) + minimum();
199  }
200  ///@todo Handle RECIPROCAL mode
201  }
202  }
203 
204  return (_pos - _rect.left()) / _rect.width() *
205  (maximum() - minimum()) + minimum();
206  }
Scale scale_
Definition: RangedFloat.h:157
value_type maximum() const
Return maximum value.
Definition: Range.h:60
value_type minimum() const
Return minimum value.
Definition: Range.h:54
double valueToPos() const
Calculate position from value.
Definition: RangedFloat.cpp:208
double omni::ui::RangedFloat::valueToPos ( ) const
private

Calculate position from value.

209  {
210  return valueToPos(value());
211  }
value_type value() const
Return value.
Definition: RangedValue.h:65
double valueToPos() const
Calculate position from value.
Definition: RangedFloat.cpp:208
double omni::ui::RangedFloat::valueToPos ( double  _value) const
private

Calculate position from value.

215  {
216  auto && _rect = rect();
217  double _ratio = mixin::Range<double>::ratio(_value);
218 
219  if (scale_ == Scale::RECIPROCAL) {
220  if (minimum() <= 1.0 && maximum() >= 1.0 && minimum() > 0.0) {
221  double _recMinimum = - 1.0 / minimum();
222  double _max = maximum();
223  double _v = (_value - 1) / (_max -1) * _max;
224  if (_value <= 1.0) {
225  _v *= 1.0 / minimum();
226  }
227  _ratio = (_v - _recMinimum) / (_max - _recMinimum);
228  }
229  }
230 
231  return _rect.left() + _ratio *
232  double(_rect.width());
233  }
Scale scale_
Definition: RangedFloat.h:157
qreal ratio(value_type _v) const
Return ratio of value v.
Definition: Range.h:43
value_type maximum() const
Return maximum value.
Definition: Range.h:60
value_type minimum() const
Return minimum value.
Definition: Range.h:54
void omni::ui::RangedFloat::wheelEvent ( QWheelEvent *  e)
protected
329  {
330  if (hasFocus()) setValue(
331  value() + e->delta() / 15.0 / 8.0 * singleStep());
332  }
value_type value() const
Return value.
Definition: RangedValue.h:65
void setValue(double)
Set value, valueChanged() signal will be emitted.
Definition: RangedFloat.cpp:80
value_type singleStep() const
Return value for single step.
Definition: Step.h:67

Field Documentation

bool omni::ui::RangedFloat::drawTicks_ = false
private
int omni::ui::RangedFloat::gripSize_ = 0
private
bool omni::ui::RangedFloat::moving_ = false
private
int omni::ui::RangedFloat::precision_ = 2
private
Scale omni::ui::RangedFloat::scale_ = Scale::LINEAR
private
QString omni::ui::RangedFloat::suffix_
private
bool omni::ui::RangedFloat::useDefaultValue_ = false
private

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