23 #include <QHBoxLayout>
39 int toInt(
double _value)
const;
40 double fromInt(
int _value)
const;
81 q->connect(this->
Slider, SIGNAL(valueChanged(
int)), q, SLOT(onValueChanged(
int)));
82 q->connect(this->
Slider, SIGNAL(sliderMoved(
int)), q, SLOT(onSliderMoved(
int)));
83 q->connect(this->
Slider, SIGNAL(sliderPressed()), q, SIGNAL(sliderPressed()));
84 q->connect(this->
Slider, SIGNAL(sliderReleased()), q, SIGNAL(sliderReleased()));
85 q->connect(this->
Slider, SIGNAL(rangeChanged(
int,
int)),
86 q, SLOT(onRangeChanged(
int,
int)));
88 q->setSizePolicy(
QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed,
89 QSizePolicy::Slider));
96 static const double minInt = std::numeric_limits<int>::min();
97 static const double maxInt = std::numeric_limits<int>::max();
99 if (tmp < minInt || tmp > maxInt)
101 qWarning(
"ctkDoubleSliderPrivate::toInt value out of bounds !");
104 tmp = qBound(minInt, tmp, maxInt);
105 int intValue = qRound(tmp);
152 if (d->Minimum >= d->Value)
154 d->updateOffset(d->Minimum);
156 d->SettingRange =
true;
157 d->Slider->setMinimum(d->toInt(min));
158 d->SettingRange =
false;
167 if (d->Maximum <= d->Value)
169 d->updateOffset(d->Maximum);
171 d->SettingRange =
true;
172 d->Slider->setMaximum(d->toInt(max));
173 d->SettingRange =
false;
184 if (d->Minimum >= d->Value)
186 d->updateOffset(d->Minimum);
188 if (d->Maximum <= d->Value)
190 d->updateOffset(d->Maximum);
192 d->SettingRange =
true;
193 d->Slider->setRange(d->toInt(min), d->toInt(max));
194 d->SettingRange =
false;
216 return d->fromInt(d->Slider->sliderPosition());
223 d->Slider->setSliderPosition(d->toInt(newSliderPosition));
237 newValue = qBound(d->Minimum, newValue, d->Maximum);
238 d->updateOffset(newValue);
239 int newIntValue = d->toInt(newValue);
240 if (newIntValue != d->Slider->value())
244 d->Slider->setValue(newIntValue);
248 double oldValue = d->Value;
252 if (qAbs(newValue - oldValue) > (d->SingleStep * 0.000000001))
263 return d->SingleStep;
270 d->SingleStep = newStep;
272 double _value = d->Value;
273 d->updateOffset(_value);
275 this->
setRange(d->Minimum, d->Maximum);
276 d->Slider->setValue(d->toInt(_value));
285 return d->fromInt(d->Slider->tickInterval());
292 d->Slider->setTickInterval(d->toInt(newTickInterval));
299 return d->Slider->hasTracking();
306 d->Slider->setTracking(enable);
313 d->Slider->triggerAction(action);
320 return d->Slider->orientation();
327 d->Slider->setOrientation(newOrientation);
334 double doubleNewValue = d->fromInt(newValue);
340 if (d->Value == doubleNewValue)
344 d->Value = doubleNewValue;
359 if (!d->SettingRange)
361 this->
setRange(d->fromInt(min), d->fromInt(max));
void onRangeChanged(int min, int max)
ctkDoubleSlider *const q_ptr
void setSliderPosition(double)
void sliderMoved(double position)
void setContentsMargins(int left, int top, int right, int bottom)
double singleStep() const
void triggerAction(QAbstractSlider::SliderAction action)
void onSliderMoved(int position)
ctkDoubleSliderPrivate(ctkDoubleSlider &object)
double tickInterval() const
void setTickInterval(double ti)
ctkDoubleSlider(QWidget *parent=0)
void setOrientation(Qt::Orientation orientation)
void valueChanged(double value)
double sliderPosition() const
void setValue(double value)
void setSingleStep(double step)
void setMinimum(double min)
Qt::Orientation orientation() const
bool blockSignals(bool block)
void setRange(double min, double max)
Q_DECLARE_PUBLIC(ctkDoubleSlider)
void onValueChanged(int value)
double fromInt(int _value) const
void updateOffset(double value)
virtual ~ctkDoubleSlider()
Destructor.
void rangeChanged(double min, double max)
void setTracking(bool enable)
void setMaximum(double max)
int toInt(double _value) const