##// END OF EJS Templates
Inits min/max spinboxes...
Alexandre Leroux -
r1045:26696cd83a3b
parent child
Show More
@@ -1,30 +1,34
1 #ifndef SCIQLOP_COLORSCALEEDITOR_H
1 #ifndef SCIQLOP_COLORSCALEEDITOR_H
2 #define SCIQLOP_COLORSCALEEDITOR_H
2 #define SCIQLOP_COLORSCALEEDITOR_H
3
3
4 #include <QButtonGroup>
4 #include <QButtonGroup>
5 #include <QDialog>
5 #include <QDialog>
6
6
7 namespace Ui {
7 namespace Ui {
8 class ColorScaleEditor;
8 class ColorScaleEditor;
9 } // Ui
9 } // Ui
10
10
11 /**
11 /**
12 * @brief The ColorScaleEditor class represents the widget to set properties of color scale's graphs
12 * @brief The ColorScaleEditor class represents the widget to set properties of color scale's graphs
13 */
13 */
14 class ColorScaleEditor : public QDialog {
14 class ColorScaleEditor : public QDialog {
15 Q_OBJECT
15 Q_OBJECT
16
16
17 public:
17 public:
18 explicit ColorScaleEditor(QWidget *parent = 0);
18 explicit ColorScaleEditor(QWidget *parent = 0);
19 virtual ~ColorScaleEditor() noexcept;
19 virtual ~ColorScaleEditor() noexcept;
20
20
21 private:
21 private:
22 Ui::ColorScaleEditor *ui;
22 Ui::ColorScaleEditor *ui;
23 QButtonGroup *m_ThresholdGroup;
23 QButtonGroup *m_ThresholdGroup;
24
24
25 private slots:
25 private slots:
26 /// Slot called when max threshold value changes
27 void onMaxChanged();
28 /// Slot called when min threshold value changes
29 void onMinChanged();
26 /// Slot called when the threshold mode (auto or manual) changes
30 /// Slot called when the threshold mode (auto or manual) changes
27 void onThresholdChanged(bool checked);
31 void onThresholdChanged(bool checked);
28 };
32 };
29
33
30 #endif // SCIQLOP_COLORSCALEEDITOR_H
34 #endif // SCIQLOP_COLORSCALEEDITOR_H
@@ -1,34 +1,66
1 #include "Visualization/ColorScaleEditor.h"
1 #include "Visualization/ColorScaleEditor.h"
2
2
3 #include "ui_ColorScaleEditor.h"
3 #include "ui_ColorScaleEditor.h"
4
4
5 ColorScaleEditor::ColorScaleEditor(QWidget *parent)
5 ColorScaleEditor::ColorScaleEditor(QWidget *parent)
6 : QDialog{parent}, ui{new Ui::ColorScaleEditor}, m_ThresholdGroup{new QButtonGroup{this}}
6 : QDialog{parent}, ui{new Ui::ColorScaleEditor}, m_ThresholdGroup{new QButtonGroup{this}}
7 {
7 {
8 ui->setupUi(this);
8 ui->setupUi(this);
9 // Creates threshold group
9 // Creates threshold group
10 m_ThresholdGroup->addButton(ui->thresholdAutoButton);
10 m_ThresholdGroup->addButton(ui->thresholdAutoButton);
11 m_ThresholdGroup->addButton(ui->thresholdManualButton);
11 m_ThresholdGroup->addButton(ui->thresholdManualButton);
12
12
13 // Inits min/max spinboxes' properties
14 auto setSpinBoxProperties = [](auto &spinBox) {
15 spinBox.setDecimals(3);
16 spinBox.setMinimum(-std::numeric_limits<double>::max());
17 spinBox.setMaximum(std::numeric_limits<double>::max());
18 };
19 setSpinBoxProperties(*ui->minSpinBox);
20 setSpinBoxProperties(*ui->maxSpinBox);
21
13 // Inits connections
22 // Inits connections
14 connect(ui->thresholdAutoButton, SIGNAL(toggled(bool)), this, SLOT(onThresholdChanged(bool)));
23 connect(ui->thresholdAutoButton, SIGNAL(toggled(bool)), this, SLOT(onThresholdChanged(bool)));
15 connect(ui->thresholdManualButton, SIGNAL(toggled(bool)), this, SLOT(onThresholdChanged(bool)));
24 connect(ui->thresholdManualButton, SIGNAL(toggled(bool)), this, SLOT(onThresholdChanged(bool)));
25 connect(ui->minSpinBox, SIGNAL(editingFinished()), this, SLOT(onMinChanged()));
26 connect(ui->maxSpinBox, SIGNAL(editingFinished()), this, SLOT(onMaxChanged()));
16
27
17 // First update
28 // First update
18 onThresholdChanged(true);
29 onThresholdChanged(true);
19 }
30 }
20
31
21 ColorScaleEditor::~ColorScaleEditor() noexcept
32 ColorScaleEditor::~ColorScaleEditor() noexcept
22 {
33 {
23 delete ui;
34 delete ui;
24 }
35 }
36
37 void ColorScaleEditor::onMaxChanged()
38 {
39 // Ensures that max >= min
40 auto maxValue = ui->maxSpinBox->value();
41 if (maxValue < ui->minSpinBox->value()) {
42 ui->minSpinBox->setValue(maxValue);
43 }
44
45 }
46
47 void ColorScaleEditor::onMinChanged()
48 {
49 // Ensures that min <= max
50 auto minValue = ui->minSpinBox->value();
51 if (minValue > ui->maxSpinBox->value()) {
52 ui->maxSpinBox->setValue(minValue);
53 }
54
55 }
56
25 void ColorScaleEditor::onThresholdChanged(bool checked)
57 void ColorScaleEditor::onThresholdChanged(bool checked)
26 {
58 {
27 if (checked) {
59 if (checked) {
28 auto isAutomatic = ui->thresholdAutoButton == m_ThresholdGroup->checkedButton();
60 auto isAutomatic = ui->thresholdAutoButton == m_ThresholdGroup->checkedButton();
29
61
30 ui->minSpinBox->setEnabled(!isAutomatic);
62 ui->minSpinBox->setEnabled(!isAutomatic);
31 ui->maxSpinBox->setEnabled(!isAutomatic);
63 ui->maxSpinBox->setEnabled(!isAutomatic);
32 }
64 }
33 }
65 }
34
66
General Comments 0
You need to be logged in to leave comments. Login now