##// END OF EJS Templates
Inits min/max spinboxes...
Alexandre Leroux -
r1045:26696cd83a3b
parent child
Show More
@@ -23,6 +23,10 private:
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 };
@@ -10,9 +10,20 ColorScaleEditor::ColorScaleEditor(QWidget *parent)
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);
@@ -22,6 +33,27 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) {
General Comments 0
You need to be logged in to leave comments. Login now