##// END OF EJS Templates
Implements color scale save when the editor is closed
Alexandre Leroux -
r1012:18abbd5ba9c1
parent child
Show More
@@ -24,6 +24,9 public:
24 private:
24 private:
25 /// Fills the editor fields from color scale data
25 /// Fills the editor fields from color scale data
26 void loadScale();
26 void loadScale();
27 /// Updates the color scale from editor fields
28 void saveScale();
29
27 Ui::ColorScaleEditor *ui;
30 Ui::ColorScaleEditor *ui;
28 QButtonGroup *m_ThresholdGroup;
31 QButtonGroup *m_ThresholdGroup;
29 /// Scale in editing
32 /// Scale in editing
@@ -34,6 +37,9 private:
34 QCPColorScale *m_PreviewScale;
37 QCPColorScale *m_PreviewScale;
35
38
36 private slots:
39 private slots:
40 /// @sa QDialog::accept()
41 void accept() override;
42
37 /// Slot called when max threshold value changes
43 /// Slot called when max threshold value changes
38 void onMaxChanged();
44 void onMaxChanged();
39 /// Slot called when min threshold value changes
45 /// Slot called when min threshold value changes
@@ -67,6 +67,10 ColorScaleEditor::ColorScaleEditor(SqpColorScale &scale, QWidget *parent)
67 connect(ui->minSpinBox, SIGNAL(editingFinished()), this, SLOT(onMinChanged()));
67 connect(ui->minSpinBox, SIGNAL(editingFinished()), this, SLOT(onMinChanged()));
68 connect(ui->maxSpinBox, SIGNAL(editingFinished()), this, SLOT(onMaxChanged()));
68 connect(ui->maxSpinBox, SIGNAL(editingFinished()), this, SLOT(onMaxChanged()));
69
69
70 // OK/cancel buttons
71 connect(ui->okButton, SIGNAL(clicked(bool)), this, SLOT(accept()));
72 connect(ui->cancelButton, SIGNAL(clicked(bool)), this, SLOT(reject()));
73
70 // Loads color scale
74 // Loads color scale
71 loadScale();
75 loadScale();
72 }
76 }
@@ -95,6 +99,29 void ColorScaleEditor::loadScale()
95 updatePreview();
99 updatePreview();
96 }
100 }
97
101
102 void ColorScaleEditor::saveScale()
103 {
104 auto qcpColorScale = m_Scale.m_Scale;
105
106 // Gradient
107 auto gradientPreset
108 = ui->gradientComboBox->currentData().value<QCPColorGradient::GradientPreset>();
109 qcpColorScale->setGradient(gradientPreset);
110 m_Scale.m_GradientPreset = gradientPreset;
111
112 // Threshold mode
113 m_Scale.m_AutomaticThreshold = ui->thresholdAutoButton->isChecked();
114
115 // Min/max
116 qcpColorScale->setDataRange(QCPRange{ui->minSpinBox->value(), ui->maxSpinBox->value()});
117 }
118
119 void ColorScaleEditor::accept()
120 {
121 saveScale();
122 QDialog::accept();
123 }
124
98 void ColorScaleEditor::onMaxChanged()
125 void ColorScaleEditor::onMaxChanged()
99 {
126 {
100 // Ensures that max >= min
127 // Ensures that max >= min
General Comments 0
You need to be logged in to leave comments. Login now