diff --git a/gui/include/Visualization/ColorScaleEditor.h b/gui/include/Visualization/ColorScaleEditor.h index 2569d2b..48814b6 100644 --- a/gui/include/Visualization/ColorScaleEditor.h +++ b/gui/include/Visualization/ColorScaleEditor.h @@ -23,6 +23,10 @@ private: QButtonGroup *m_ThresholdGroup; private slots: + /// Slot called when max threshold value changes + void onMaxChanged(); + /// Slot called when min threshold value changes + void onMinChanged(); /// Slot called when the threshold mode (auto or manual) changes void onThresholdChanged(bool checked); }; diff --git a/gui/src/Visualization/ColorScaleEditor.cpp b/gui/src/Visualization/ColorScaleEditor.cpp index 2ef8043..546043d 100644 --- a/gui/src/Visualization/ColorScaleEditor.cpp +++ b/gui/src/Visualization/ColorScaleEditor.cpp @@ -10,9 +10,20 @@ ColorScaleEditor::ColorScaleEditor(QWidget *parent) m_ThresholdGroup->addButton(ui->thresholdAutoButton); m_ThresholdGroup->addButton(ui->thresholdManualButton); + // Inits min/max spinboxes' properties + auto setSpinBoxProperties = [](auto &spinBox) { + spinBox.setDecimals(3); + spinBox.setMinimum(-std::numeric_limits::max()); + spinBox.setMaximum(std::numeric_limits::max()); + }; + setSpinBoxProperties(*ui->minSpinBox); + setSpinBoxProperties(*ui->maxSpinBox); + // Inits connections connect(ui->thresholdAutoButton, SIGNAL(toggled(bool)), this, SLOT(onThresholdChanged(bool))); connect(ui->thresholdManualButton, SIGNAL(toggled(bool)), this, SLOT(onThresholdChanged(bool))); + connect(ui->minSpinBox, SIGNAL(editingFinished()), this, SLOT(onMinChanged())); + connect(ui->maxSpinBox, SIGNAL(editingFinished()), this, SLOT(onMaxChanged())); // First update onThresholdChanged(true); @@ -22,6 +33,27 @@ ColorScaleEditor::~ColorScaleEditor() noexcept { delete ui; } + +void ColorScaleEditor::onMaxChanged() +{ + // Ensures that max >= min + auto maxValue = ui->maxSpinBox->value(); + if (maxValue < ui->minSpinBox->value()) { + ui->minSpinBox->setValue(maxValue); + } + +} + +void ColorScaleEditor::onMinChanged() +{ + // Ensures that min <= max + auto minValue = ui->minSpinBox->value(); + if (minValue > ui->maxSpinBox->value()) { + ui->maxSpinBox->setValue(minValue); + } + +} + void ColorScaleEditor::onThresholdChanged(bool checked) { if (checked) {