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 mLabel->setVisible(on);
68 mSlider->setMinimumWidth(50);
69 mSlider->setOrientation(Qt::Horizontal);
70 connect(mSlider, SIGNAL(doubleValueChanged(
double)),
this, SLOT(doubleValueChanged(
double)));
75 mDial =
new QDial(
this);
76 mDial->setMaximumWidth(50);
77 mDial->setMaximumHeight(50);
78 mDial->setNotchesVisible(
true);
79 connect(mDial, SIGNAL(valueChanged(
int)),
this, SLOT(intValueChanged(
int)));
84 QSize minBarSize = QSize(20, 20);
87 connect(mInfiniteSlider, SIGNAL(mouseMoved(QPointF)),
this, SLOT(infiniteSliderMouseMoved(QPointF)));
90 void ScalarInteractionWidget::infiniteSliderMouseMoved(QPointF delta)
92 double scale =
mData->getValueRange().range() / 2.0;
94 double factor = scale * delta.x();
95 double current =
mData->getValue();
96 mData->setValue(current + factor);
102 connect(mEdit, SIGNAL(editingFinished()),
this, SLOT(textEditedSlot()));
107 mSpinBox =
new QDoubleSpinBox(
this);
108 connect(mSpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(doubleValueChanged(
double)));
116 QHBoxLayout* topLayout =
new QHBoxLayout;
117 topLayout->setMargin(0);
118 topLayout->setSpacing(0);
119 this->setLayout(topLayout);
122 topLayout->addWidget(mLabel, 0);
124 topLayout->addWidget(mEdit, 0);
126 topLayout->addWidget(mSpinBox, 0);
128 topLayout->addWidget(mDial, 0);
130 topLayout->addWidget(mSlider, 1);
132 topLayout->addWidget(mInfiniteSlider, 1);
144 QHBoxLayout* controlsLayout =
new QHBoxLayout;
145 controlsLayout->setSpacing(0);
146 controlsLayout->setMargin(0);
147 gridLayout->addLayout(controlsLayout, row, 1);
151 controlsLayout->addWidget(mEdit);
153 controlsLayout->addWidget(mSpinBox);
155 gridLayout->addWidget(mDial, row, 2);
157 controlsLayout->addWidget(mSlider, 1);
159 controlsLayout->addWidget(mInfiniteSlider, 1);
173 void ScalarInteractionWidget::intValueChanged(
int val)
175 this->doubleValueChanged(val/100.0);
179 void ScalarInteractionWidget::doubleValueChanged(
double val)
181 val =
mData->convertDisplay2Internal(val);
186 mData->setValue(val);
189 void ScalarInteractionWidget::textEditedSlot()
194 double defVal =
mData->convertInternal2Display(
mData->getValue());
200 mData->setValue(newVal);
218 this->enableAll(
mData->getEnabled());
222 DoubleRange dRange(
mData->convertInternal2Display(range.min()),
mData->convertInternal2Display(range.max()),
223 mData->convertInternal2Display(range.step()));
227 mSlider->blockSignals(
true);
230 mSlider->setToolTip(
mData->getHelp());
231 mSlider->blockSignals(
false);
236 mEdit->blockSignals(
true);
238 mEdit->setToolTip(
mData->getHelp());
239 mEdit->blockSignals(
false);
244 mSpinBox->blockSignals(
true);
245 mSpinBox->setRange(dRange.
min(), dRange.
max());
246 mSpinBox->setSingleStep(dRange.
step());
247 mSpinBox->setDecimals(
mData->getValueDecimals());
248 mSpinBox->setValue(
mData->convertInternal2Display(
mData->getValue()));
249 mSpinBox->setToolTip(
mData->getHelp());
250 mSpinBox->blockSignals(
false);
255 mDial->blockSignals(
true);
256 mDial->setContentsMargins(0,0,0,0);
257 mDial->setRange(dRange.
min()*100, dRange.
max()*100);
258 mDial->setSingleStep(dRange.
step()*100);
259 mDial->setValue(
mData->convertInternal2Display(
mData->getValue())*100);
260 mDial->setToolTip(
mData->getHelp());
261 mDial->blockSignals(
false);
266 mLabel->setToolTip(
mData->getHelp());
270 void ScalarInteractionWidget::enableAll(
bool enable)
272 QWidget::setEnabled(enable);
275 mSlider->setEnabled(enable);
277 mSpinBox->setEnabled(enable);
279 mLabel->setEnabled(enable);
281 mEdit->setEnabled(enable);
283 mInfiniteSlider->setEnabled(enable);
295 QSize size = QLineEdit::minimumSizeHint();
296 size.setWidth(size.height() * 3);
302 QSize size = QLineEdit::minimumSizeHint();
317 this->
build(gridLayout, row);
324 QGridLayout* gridLayout,
int row) :
330 this->
build(gridLayout, row);
336 QGridLayout* gridLayout,
int row) :
343 this->
build(gridLayout, row);
347 QGridLayout* gridLayout,
int row) :
354 this->
build(gridLayout, row);
367 this->
build(gridLayout, row);
void setDoubleValue(double val)
double max() const
maximum value
Utility class for describing a bounded numeric range.
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)
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
virtual QSize minimumSizeHint() const
Namespace for all CustusX production code.