33 #include <QDoubleSpinBox>
41 gridLayout->addWidget(mLabel, row, 0);
42 gridLayout->addWidget(mLowerEdit, row, 1);
43 gridLayout->addWidget(mUpperEdit, row, 1);
44 gridLayout->addWidget(mSpanSlider, row, 2);
49 mData = dataInterface;
50 this->init(gridLayout, row);
53 void SliderRangeGroupWidget::init(QGridLayout *gridLayout,
int row)
55 mLabel =
new QLabel(
this);
56 mLabel->setText(mData->getDisplayName());
57 mLowerEdit =
new QDoubleSpinBox(
this);
59 mSpanSlider->setOrientation(Qt::Horizontal);
60 mSpanSlider->setHandleMovementMode(QxtSpanSlider::NoOverlapping);
61 mUpperEdit =
new QDoubleSpinBox(
this);
69 QHBoxLayout* controlsLayout =
new QHBoxLayout;
70 controlsLayout->setSpacing(0);
71 controlsLayout->setMargin(0);
72 gridLayout->addLayout(controlsLayout, row, 1);
74 controlsLayout->addWidget(mLowerEdit);
75 controlsLayout->addWidget(mSpanSlider, 1);
76 controlsLayout->addWidget(mUpperEdit);
80 QHBoxLayout* topLayout =
new QHBoxLayout;
81 topLayout->setMargin(0);
82 this->setLayout(topLayout);
84 topLayout->addWidget(mLabel);
85 topLayout->addWidget(mLowerEdit);
86 topLayout->addWidget(mSpanSlider, 1);
87 topLayout->addWidget(mUpperEdit);
90 connect(mLowerEdit, SIGNAL(
valueChanged(
double)),
this, SLOT(textEditedSlot()));
92 connect(mSpanSlider, SIGNAL(doubleSpanChanged(
double,
double)),
this, SLOT(doubleSpanChangedSlot(
double,
double)));
93 connect(mUpperEdit, SIGNAL(
valueChanged(
double)),
this, SLOT(textEditedSlot()));
96 connect(mData.get(), SIGNAL(changed()),
this, SLOT(dataChanged()));
102 mData->setValueRange(range);
103 this->updateGuiRange();
108 mLowerEdit->setDecimals(decimals);
109 mUpperEdit->setDecimals(decimals);
114 return std::make_pair(mData->getValue()[0], mData->getValue()[1]);
117 void SliderRangeGroupWidget::doubleSpanChangedSlot(
double lower,
double upper)
124 Eigen::Vector2d val = Eigen::Vector2d(lower, upper);
125 if (val == mData->getValue())
128 mData->setValue(val);
132 void SliderRangeGroupWidget::textEditedSlot()
134 this->
setValue(mLowerEdit->value(), mUpperEdit->value());
137 void SliderRangeGroupWidget::dataChanged()
139 this->updateGuiRange();
141 mSpanSlider->blockSignals(
true);
142 mLowerEdit->blockSignals(
true);
143 mUpperEdit->blockSignals(
true);
145 mSpanSlider->
setDoubleSpan(mData->getValue()[0], mData->getValue()[1]);
146 mLowerEdit->setValue(mData->getValue()[0]);
147 mUpperEdit->setValue(mData->getValue()[1]);
149 mSpanSlider->blockSignals(
false);
150 mLowerEdit->blockSignals(
false);
151 mUpperEdit->blockSignals(
false);
153 emit
valueChanged(mData->getValue()[0], mData->getValue()[1]);
157 void SliderRangeGroupWidget::updateGuiRange()
159 DoubleRange range = mData->getValueRange();
163 mLowerEdit->setRange(range.min(), range.max());
164 mLowerEdit->setSingleStep(range.step());
166 mUpperEdit->setRange(range.min(), range.max());
167 mUpperEdit->setSingleStep(range.step());
void setDoubleSpan(double lower, double upper)
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...
void setDoubleRange(const DoubleRange &range)