46 OptimizedUpdateWidget(parent), mSlider(NULL), mDial(NULL), mSpinBox(NULL), mLabel(NULL), mEdit(NULL), mInfiniteSlider(NULL)
48 mData = dataInterface;
50 this->enableAll(
mData->getEnabled());
55 mLabel =
new QLabel(
this);
56 mLabel->setText(
mData->getDisplayName());
62 mSlider->setMinimumWidth(50);
63 mSlider->setOrientation(Qt::Horizontal);
64 connect(mSlider, SIGNAL(doubleValueChanged(
double)),
this, SLOT(doubleValueChanged(
double)));
69 mDial =
new QDial(
this);
70 mDial->setMaximumWidth(50);
71 mDial->setMaximumHeight(50);
72 mDial->setNotchesVisible(
true);
73 connect(mDial, SIGNAL(valueChanged(
int)),
this, SLOT(intValueChanged(
int)));
78 QSize minBarSize = QSize(20, 20);
81 connect(mInfiniteSlider, SIGNAL(mouseMoved(QPointF)),
this, SLOT(infiniteSliderMouseMoved(QPointF)));
84 void ScalarInteractionWidget::infiniteSliderMouseMoved(QPointF delta)
86 double scale =
mData->getValueRange().range() / 2.0;
88 double factor = scale * delta.x();
89 double current =
mData->getValue();
90 mData->setValue(current + factor);
96 connect(mEdit, SIGNAL(editingFinished()),
this, SLOT(textEditedSlot()));
101 mSpinBox =
new QDoubleSpinBox(
this);
102 connect(mSpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(doubleValueChanged(
double)));
110 QHBoxLayout* topLayout =
new QHBoxLayout;
111 topLayout->setMargin(0);
112 this->setLayout(topLayout);
115 topLayout->addWidget(mLabel, 0);
117 topLayout->addWidget(mEdit, 0);
119 topLayout->addWidget(mSpinBox, 0);
121 topLayout->addWidget(mDial, 0);
123 topLayout->addWidget(mSlider, 1);
125 topLayout->addWidget(mInfiniteSlider, 1);
137 QHBoxLayout* controlsLayout =
new QHBoxLayout;
138 controlsLayout->setSpacing(0);
139 controlsLayout->setMargin(0);
140 gridLayout->addLayout(controlsLayout, row, 1);
144 controlsLayout->addWidget(mEdit);
146 controlsLayout->addWidget(mSpinBox);
148 gridLayout->addWidget(mDial, row, 2);
150 controlsLayout->addWidget(mSlider, 1);
152 controlsLayout->addWidget(mInfiniteSlider, 1);
166 void ScalarInteractionWidget::intValueChanged(
int val)
168 this->doubleValueChanged(val/100.0);
172 void ScalarInteractionWidget::doubleValueChanged(
double val)
174 val =
mData->convertDisplay2Internal(val);
179 mData->setValue(val);
182 void ScalarInteractionWidget::textEditedSlot()
187 double defVal =
mData->convertInternal2Display(
mData->getValue());
193 mData->setValue(newVal);
211 this->enableAll(
mData->getEnabled());
215 DoubleRange dRange(
mData->convertInternal2Display(range.min()),
mData->convertInternal2Display(range.max()),
216 mData->convertInternal2Display(range.step()));
220 mSlider->blockSignals(
true);
223 mSlider->setToolTip(
mData->getHelp());
224 mSlider->blockSignals(
false);
229 mEdit->blockSignals(
true);
231 mEdit->setToolTip(
mData->getHelp());
232 mEdit->blockSignals(
false);
237 mSpinBox->blockSignals(
true);
238 mSpinBox->setRange(dRange.
min(), dRange.
max());
239 mSpinBox->setSingleStep(dRange.
step());
240 mSpinBox->setDecimals(
mData->getValueDecimals());
241 mSpinBox->setValue(
mData->convertInternal2Display(
mData->getValue()));
242 mSpinBox->setToolTip(
mData->getHelp());
243 mSpinBox->blockSignals(
false);
248 mDial->blockSignals(
true);
249 mDial->setContentsMargins(0,0,0,0);
250 mDial->setRange(dRange.
min()*100, dRange.
max()*100);
251 mDial->setSingleStep(dRange.
step()*100);
252 mDial->setValue(
mData->convertInternal2Display(
mData->getValue())*100);
253 mDial->setToolTip(
mData->getHelp());
254 mDial->blockSignals(
false);
259 mLabel->setToolTip(
mData->getHelp());
263 void ScalarInteractionWidget::enableAll(
bool enable)
266 QWidget::setEnabled(enable);
268 mSlider->setEnabled(enable);
270 mSpinBox->setEnabled(enable);
272 mLabel->setEnabled(enable);
274 mEdit->setEnabled(enable);
276 mInfiniteSlider->setEnabled(enable);
288 QSize size = QLineEdit::minimumSizeHint();
289 size.setWidth(size.height() * 3);
295 QSize size = QLineEdit::minimumSizeHint();
310 this->
build(gridLayout, row);
317 QGridLayout* gridLayout,
int row) :
323 this->
build(gridLayout, row);
329 QGridLayout* gridLayout,
int row) :
336 this->
build(gridLayout, row);
340 QGridLayout* gridLayout,
int row) :
347 this->
build(gridLayout, row);
360 this->
build(gridLayout, row);
void setDoubleValue(double val)
double max() const
maximum value
Utility class for describing a bounded numeric range.
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
virtual QSize sizeHint() const
double getDoubleValue(double defVal=0.0) const
void setDoubleRange(const DoubleRange &range)
double min() const
minimum value
Custom widget for display of double-valued data.
boost::shared_ptr< class DoublePropertyBase > DoublePropertyBasePtr
double step() const
smallest reasonable increment
A QLineEdit specialized to deal with double data.
void setDoubleValue(double val)
virtual QSize minimumSizeHint() const