12 #include <QDoubleSpinBox> 20 gridLayout->addWidget(mLabel, row, 0);
21 gridLayout->addWidget(mLowerEdit, row, 1);
22 gridLayout->addWidget(mUpperEdit, row, 1);
23 gridLayout->addWidget(mSpanSlider, row, 2);
28 mData = dataInterface;
29 this->init(gridLayout, row);
32 void SliderRangeGroupWidget::init(QGridLayout *gridLayout,
int row)
34 mLabel =
new QLabel(
this);
35 mLabel->setText(mData->getDisplayName());
36 mLowerEdit =
new QDoubleSpinBox(
this);
38 mSpanSlider->setOrientation(Qt::Horizontal);
39 mSpanSlider->setHandleMovementMode(QxtSpanSlider::NoOverlapping);
40 mUpperEdit =
new QDoubleSpinBox(
this);
48 QHBoxLayout* controlsLayout =
new QHBoxLayout;
49 controlsLayout->setSpacing(0);
50 controlsLayout->setMargin(0);
51 gridLayout->addLayout(controlsLayout, row, 1);
53 controlsLayout->addWidget(mLowerEdit);
54 controlsLayout->addWidget(mSpanSlider, 1);
55 controlsLayout->addWidget(mUpperEdit);
59 QHBoxLayout* topLayout =
new QHBoxLayout;
60 topLayout->setMargin(0);
61 this->setLayout(topLayout);
63 topLayout->addWidget(mLabel);
64 topLayout->addWidget(mLowerEdit);
65 topLayout->addWidget(mSpanSlider, 1);
66 topLayout->addWidget(mUpperEdit);
69 connect(mLowerEdit, SIGNAL(
valueChanged(
double)),
this, SLOT(textEditedSlot()));
71 connect(mSpanSlider, SIGNAL(doubleSpanChanged(
double,
double)),
this, SLOT(doubleSpanChangedSlot(
double,
double)));
72 connect(mUpperEdit, SIGNAL(
valueChanged(
double)),
this, SLOT(textEditedSlot()));
75 connect(mData.get(), SIGNAL(changed()),
this, SLOT(dataChanged()));
81 mData->setValueRange(range);
82 this->updateGuiRange();
87 mLowerEdit->setDecimals(decimals);
88 mUpperEdit->setDecimals(decimals);
93 return std::make_pair(mData->getValue()[0], mData->getValue()[1]);
96 void SliderRangeGroupWidget::doubleSpanChangedSlot(
double lower,
double upper)
103 Eigen::Vector2d val = Eigen::Vector2d(lower, upper);
104 if (val == mData->getValue())
107 mData->setValue(val);
111 void SliderRangeGroupWidget::textEditedSlot()
113 this->
setValue(mLowerEdit->value(), mUpperEdit->value());
116 void SliderRangeGroupWidget::dataChanged()
118 this->updateGuiRange();
120 mSpanSlider->blockSignals(
true);
121 mLowerEdit->blockSignals(
true);
122 mUpperEdit->blockSignals(
true);
124 mSpanSlider->
setDoubleSpan(mData->getValue()[0], mData->getValue()[1]);
125 mLowerEdit->setValue(mData->getValue()[0]);
126 mUpperEdit->setValue(mData->getValue()[1]);
128 mSpanSlider->blockSignals(
false);
129 mLowerEdit->blockSignals(
false);
130 mUpperEdit->blockSignals(
false);
132 emit
valueChanged(mData->getValue()[0], mData->getValue()[1]);
136 void SliderRangeGroupWidget::updateGuiRange()
142 mLowerEdit->setRange(range.
min(), range.
max());
143 mLowerEdit->setSingleStep(range.
step());
145 mUpperEdit->setRange(range.
min(), range.
max());
146 mUpperEdit->setSingleStep(range.
step());
void setDoubleSpan(double lower, double upper)
double max() const
maximum value
Utility class for describing a bounded numeric range.
boost::shared_ptr< DoublePairPropertyBase > DoublePairPropertyBasePtr
Custom widget for display of double-valued data.Use the double-named methods instead of qslider's int...
double min() const
minimum value
double step() const
smallest reasonable increment
void setDoubleRange(const DoubleRange &range)
Namespace for all CustusX production code.