diff --git a/gui/include/Visualization/ColorScaleEditor.h b/gui/include/Visualization/ColorScaleEditor.h index a0d2c7a..2569d2b 100644 --- a/gui/include/Visualization/ColorScaleEditor.h +++ b/gui/include/Visualization/ColorScaleEditor.h @@ -1,6 +1,7 @@ #ifndef SCIQLOP_COLORSCALEEDITOR_H #define SCIQLOP_COLORSCALEEDITOR_H +#include #include namespace Ui { @@ -19,6 +20,11 @@ public: private: Ui::ColorScaleEditor *ui; + QButtonGroup *m_ThresholdGroup; + +private slots: + /// Slot called when the threshold mode (auto or manual) changes + void onThresholdChanged(bool checked); }; #endif // SCIQLOP_COLORSCALEEDITOR_H diff --git a/gui/src/Visualization/ColorScaleEditor.cpp b/gui/src/Visualization/ColorScaleEditor.cpp index 8009d36..2ef8043 100644 --- a/gui/src/Visualization/ColorScaleEditor.cpp +++ b/gui/src/Visualization/ColorScaleEditor.cpp @@ -2,12 +2,33 @@ #include "ui_ColorScaleEditor.h" -ColorScaleEditor::ColorScaleEditor(QWidget *parent) : QDialog{parent}, ui{new Ui::ColorScaleEditor} +ColorScaleEditor::ColorScaleEditor(QWidget *parent) + : QDialog{parent}, ui{new Ui::ColorScaleEditor}, m_ThresholdGroup{new QButtonGroup{this}} { ui->setupUi(this); + // Creates threshold group + m_ThresholdGroup->addButton(ui->thresholdAutoButton); + m_ThresholdGroup->addButton(ui->thresholdManualButton); + + // Inits connections + connect(ui->thresholdAutoButton, SIGNAL(toggled(bool)), this, SLOT(onThresholdChanged(bool))); + connect(ui->thresholdManualButton, SIGNAL(toggled(bool)), this, SLOT(onThresholdChanged(bool))); + + // First update + onThresholdChanged(true); } ColorScaleEditor::~ColorScaleEditor() noexcept { delete ui; } +void ColorScaleEditor::onThresholdChanged(bool checked) +{ + if (checked) { + auto isAutomatic = ui->thresholdAutoButton == m_ThresholdGroup->checkedButton(); + + ui->minSpinBox->setEnabled(!isAutomatic); + ui->maxSpinBox->setEnabled(!isAutomatic); + } +} +