25 OptimizedUpdateWidget(parent), mSlider(NULL), mDial(NULL), mSpinBox(NULL), mLabel(NULL), mEdit(NULL), mInfiniteSlider(NULL)
27 mData = dataInterface;
29 this->enableAll(
mData->getEnabled());
34 mLabel =
new QLabel(
this);
35 mLabel->setText(
mData->getDisplayName());
41 mLabel->setVisible(on);
47 mSlider->setMinimumWidth(50);
48 mSlider->setOrientation(Qt::Horizontal);
49 connect(mSlider, SIGNAL(doubleValueChanged(
double)),
this, SLOT(doubleValueChanged(
double)));
54 mDial =
new QDial(
this);
55 mDial->setMaximumWidth(50);
56 mDial->setMaximumHeight(50);
57 mDial->setNotchesVisible(
true);
58 connect(mDial, SIGNAL(valueChanged(
int)),
this, SLOT(intValueChanged(
int)));
63 QSize minBarSize = QSize(20, 20);
66 connect(mInfiniteSlider, SIGNAL(mouseMoved(QPointF)),
this, SLOT(infiniteSliderMouseMoved(QPointF)));
69 void ScalarInteractionWidget::infiniteSliderMouseMoved(QPointF delta)
71 double scale =
mData->getValueRange().range() / 2.0;
73 double factor = scale * delta.x();
74 double current =
mData->getValue();
75 mData->setValue(current + factor);
81 connect(mEdit, SIGNAL(editingFinished()),
this, SLOT(textEditedSlot()));
86 mSpinBox =
new QDoubleSpinBox(
this);
87 connect(mSpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(doubleValueChanged(
double)));
95 QHBoxLayout* topLayout =
new QHBoxLayout;
96 topLayout->setMargin(0);
97 topLayout->setSpacing(0);
98 this->setLayout(topLayout);
101 topLayout->addWidget(mLabel, 0);
103 topLayout->addWidget(mEdit, 0);
105 topLayout->addWidget(mSpinBox, 0);
107 topLayout->addWidget(mDial, 0);
109 topLayout->addWidget(mSlider, 1);
111 topLayout->addWidget(mInfiniteSlider, 1);
123 QHBoxLayout* controlsLayout =
new QHBoxLayout;
124 controlsLayout->setSpacing(0);
125 controlsLayout->setMargin(0);
126 gridLayout->addLayout(controlsLayout, row, 1);
130 controlsLayout->addWidget(mEdit);
132 controlsLayout->addWidget(mSpinBox);
134 gridLayout->addWidget(mDial, row, 2);
136 controlsLayout->addWidget(mSlider, 1);
138 controlsLayout->addWidget(mInfiniteSlider, 1);
152 void ScalarInteractionWidget::intValueChanged(
int val)
154 this->doubleValueChanged(val/100.0);
158 void ScalarInteractionWidget::doubleValueChanged(
double val)
160 val =
mData->convertDisplay2Internal(val);
165 mData->setValue(val);
168 void ScalarInteractionWidget::textEditedSlot()
173 double defVal =
mData->convertInternal2Display(
mData->getValue());
179 mData->setValue(newVal);
197 this->enableAll(
mData->getEnabled());
201 DoubleRange dRange(
mData->convertInternal2Display(range.min()),
mData->convertInternal2Display(range.max()),
202 mData->convertInternal2Display(range.step()));
206 mSlider->blockSignals(
true);
209 mSlider->setToolTip(
mData->getHelp());
210 mSlider->blockSignals(
false);
215 mEdit->blockSignals(
true);
217 mEdit->setToolTip(
mData->getHelp());
218 mEdit->blockSignals(
false);
223 mSpinBox->blockSignals(
true);
224 mSpinBox->setRange(dRange.min(), dRange.max());
225 mSpinBox->setSingleStep(dRange.step());
226 mSpinBox->setDecimals(
mData->getValueDecimals());
227 mSpinBox->setValue(
mData->convertInternal2Display(
mData->getValue()));
228 mSpinBox->setToolTip(
mData->getHelp());
229 mSpinBox->blockSignals(
false);
234 mDial->blockSignals(
true);
235 mDial->setContentsMargins(0,0,0,0);
236 mDial->setRange(dRange.min()*100, dRange.max()*100);
237 mDial->setSingleStep(dRange.step()*100);
238 mDial->setValue(
mData->convertInternal2Display(
mData->getValue())*100);
239 mDial->setToolTip(
mData->getHelp());
240 mDial->blockSignals(
false);
245 mLabel->setToolTip(
mData->getHelp());
249 void ScalarInteractionWidget::enableAll(
bool enable)
251 QWidget::setEnabled(enable);
254 mSlider->setEnabled(enable);
256 mSpinBox->setEnabled(enable);
258 mLabel->setEnabled(enable);
260 mEdit->setEnabled(enable);
262 mInfiniteSlider->setEnabled(enable);
274 QSize size = QLineEdit::minimumSizeHint();
275 size.setWidth(size.height() * 3);
281 QSize size = QLineEdit::minimumSizeHint();
296 this->
build(gridLayout, row);
303 QGridLayout* gridLayout,
int row) :
309 this->
build(gridLayout, row);
315 QGridLayout* gridLayout,
int row) :
322 this->
build(gridLayout, row);
326 QGridLayout* gridLayout,
int row) :
333 this->
build(gridLayout, row);
346 this->
build(gridLayout, row);