ddt 1.4.0
 
Loading...
Searching...
No Matches
ddtReferenceLineDialog.hpp
Go to the documentation of this file.
1
11
12#ifndef DDT_DATAVISUALISATION_DDTDIALOGS_REFERENCELINE_HPP
13#define DDT_DATAVISUALISATION_DDTDIALOGS_REFERENCELINE_HPP
14
15#include <QGraphicsPathItem>
16#include <QGraphicsRectItem>
17#include <QtWidgets>
18#pragma GCC diagnostic push
19#pragma GCC diagnostic ignored "-Wpedantic"
20#include <boost/math/interpolators/cardinal_cubic_b_spline.hpp>
21/* ignore this boost internal warning from the file above */
22#pragma GCC diagnostic pop
23#include <boost/math/special_functions/trunc.hpp>
24
28
33 Q_OBJECT
34
35 public:
40 explicit DdtReferenceLineDialog(QWidget *parent = nullptr);
41
45 virtual ~DdtReferenceLineDialog() = default;
46
53 void SetInitialParameter(const QString parameter_id,
54 const QVariant parameter) override;
55
61 void SetChangedParameter(const QString param_id,
62 const QVariant parameter) override;
63
70 bool eventFilter(QObject *obj, QEvent *event) override;
71
76 QString GetDialogName() override;
77
78 protected:
79 virtual void CreateDialog() override;
80 virtual void RetranslateUi();
81
82 void changeEvent(QEvent *event) override;
83 void focusInEvent(QFocusEvent *event) override;
84 void closeEvent(QCloseEvent *event) override;
85
86 private:
87 static const int DIALOG_WIDTH = 850;
88 static const int DIALOG_HEIGHT = 600;
89
90 static const int CHART_SIZE_X = 500;
91 static const int CHART_SIZE_Y = 300;
92 static const int AXIS_X_HEIGHT = 30;
93 static const int AXIS_Y_WIDTH = 100;
94
95 static const int LINE_EDIT_VALUE_WIDTH = 120;
96 static const int LINE_EDIT_VALUE_HEIGHT = 10;
97
98 QVBoxLayout* vertical_layout = nullptr;
99 QHBoxLayout* horizontal_layout_up = nullptr;
100 QHBoxLayout* horizontal_layout_middle = nullptr;
101 QHBoxLayout* horizontal_layout_down = nullptr;
102 QGridLayout* chart_layout = nullptr;
103 QLabel* label_low = nullptr;
104 QLineEdit* line_edit_low = nullptr;
105 QLabel* label_high = nullptr;
106 QLineEdit* line_edit_high = nullptr;
107 QPushButton* push_button_auto = nullptr;
108 QLabel* label_x = nullptr;
109 InactiveLineEdit* line_edit_x = nullptr;
110 QLabel* label_value = nullptr;
111 InactiveLineEdit* line_edit_value = nullptr;
112 QLabel* label_smooth = nullptr;
113 QComboBox* combo_box_interpolation = nullptr;
114 QLabel* label_scaling = nullptr;
115 QComboBox* checkbox_scaling_value = nullptr;
116 QDialogButtonBox* push_buttons_box = nullptr;
117 QPushButton* push_button_cancel = nullptr;
118 QLabel* label_chart = nullptr;
119 QLabel* label_xaxis = nullptr;
120 QLabel* label_yaxis = nullptr;
121 QLabel* label_fill = nullptr;
122 QPushButton* push_button_help = nullptr;
123 QPushButton* push_button_save_plot = nullptr;
124 QCheckBox* checkbox_show_distribution = nullptr;
125 QLabel* label_distribution_low = nullptr;
126 QLabel* label_distribution_high = nullptr;
127 QSpinBox* spinbox_distribution_val_limit_low = nullptr;
128 QSpinBox* spinbox_distribution_val_limit_high = nullptr;
129 QLabel* label_distribution_mean = nullptr;
130 QLabel* label_distribution_stddev = nullptr;
131 InactiveLineEdit* line_distribution_mean_value = nullptr;
132 InactiveLineEdit* line_distribution_stddev = nullptr;
133
134 QList<QVariant> spectrum_values;
135
136 double current_range_min = 0.0;
137 double original_range_min = 0.0;
138
139 double current_range_max = 0.0;
140 double original_range_max = 0.0;
141
142 double current_value_min = 0.0;
143 double original_value_min = 0.0;
144
145 double current_value_max = 0.0;
146 double original_value_max = 0.0;
147
148 double chart_min = 0.0;
149 double chart_max = 0.0;
150
151 double intensity_low = 0.0;
152 double intensity_high = 0.0;
153
154 bool auto_mode = true;
155
156 double scaling_factor = 1.0;
157
158 QString current_interpolation;
159
160 QPointF mouse_start_pos;
161 QPointF mouse_delta_pos;
162 int x_axis_scalelines = 0;
163 int y_axis_scalelines = 0;
164 int x_axis_tickstep = 0;
165 int y_axis_tickstep = 0;
166 QPoint chart_movement;
167
168 std::unique_ptr<QPainterPath> line_path;
169
170 QList<QPointF> point_list;
171
175 QString last_image_path = "";
176
180 QImage plot;
181
182 private:
183 void ClearEditWidgets();
184
185 void SetRangeValues(const QList<QVariant> range_values);
186 void SetSpectrum(const QList<QVariant> spectrum_values);
187
188 void ShowSpectrum();
189 void DrawScaleX(const double min_value, const double max_value,
190 QPainter &painter);
191 void DrawScaleY(const double min_value, const double max_value,
192 double *chart_min_value, double *chart_max_value,
193 QPainter &painter);
194 double CalculateTickPositionLinear(const double tick, const double min_value,
195 const double width,
196 const double maxsize) const;
197 void FindRangeMinMax();
198 void FindValueMinMax();
199
200 void FillPointList(const double xfactor, const double yfactor, const int height);
201 void AddIntermediatePoints(const double xfactor, const double yfactor, const int height);
202 void AddStepPoints(const double xfactor, const double yfactor, const int height);
203 void AddQuadraticPoints(const double xfactor, const double yfactor, const int height);
204 void AddNaturalPoints(const double xfactor, const double yfactor, const int height);
205
206 void ConvertPlotToImage(const QPixmap& pixmap_xaxis, const QPixmap& pixmap_yaxis, const QPixmap& pixmap_chart );
207
211 double ComputeMean(std::size_t start_x, std::size_t end_x);
212
216 double ComputeStandardDeviation(double mean, std::size_t start_x, std::size_t end_x);
217
221 void DrawGaussianDistribution(const double x_factor, const double y_factor, const int height, QPainter &painter);
222
226 void DrawDistributionXScaleLimits(const double scale_start_x, const double scale_end_x, const double width, QPainter &painter);
227
231 void UpdateUiDistributionParameterValues(const double mean, const double stddev);
232
236 void UpdateUiDistributionLimitRange();
237
238 public slots:
242 void InterpolationChanged(const QString &text);
243
247 void AutoPressed();
248
253 void QuitPressed() override;
254
259
260 private slots:
261 void DisplayXYValuesUnderCursor(const double chart_x, const double chart_y);
262 void ScaleChanged(const QString &text);
263 void ShowHelp();
264
268 void SaveToFile();
269
273 void ShowDistribution(bool triggered);
274
278 void DistributionDataLimiterChangedValue(int i);
279
280 signals:
284 void ParameterChanged(const QString dialog_id, const QString param_id,
285 const QVariant parameter);
286};
287
288#endif // DDT_DATAVISUALISATION_DDTDIALOGS_REFERENCELINE_HPP
DdtDialog(QWidget *parent=nullptr)
Definition ddtDialog.cpp:16
DdtReferenceLineDialog(QWidget *parent=nullptr)
Definition ddtReferenceLineDialog.cpp:28
QString GetDialogName() override
Definition ddtReferenceLineDialog.cpp:33
void closeEvent(QCloseEvent *event) override
Definition ddtReferenceLineDialog.cpp:940
void changeEvent(QEvent *event) override
Definition ddtReferenceLineDialog.cpp:926
void SetChangedParameter(const QString param_id, const QVariant parameter) override
Definition ddtReferenceLineDialog.cpp:968
void AutoPressed()
Definition ddtReferenceLineDialog.cpp:1060
void focusInEvent(QFocusEvent *event) override
Definition ddtReferenceLineDialog.cpp:934
void QuitPressed() override
Definition ddtReferenceLineDialog.cpp:1068
bool eventFilter(QObject *obj, QEvent *event) override
Definition ddtReferenceLineDialog.cpp:843
virtual ~DdtReferenceLineDialog()=default
void SetInitialParameter(const QString parameter_id, const QVariant parameter) override
Definition ddtReferenceLineDialog.cpp:947
virtual void CreateDialog() override
Definition ddtReferenceLineDialog.cpp:37
void ParameterChanged(const QString dialog_id, const QString param_id, const QVariant parameter)
virtual void RetranslateUi()
Definition ddtReferenceLineDialog.cpp:294
void UpdateIntensityValues()
Definition ddtReferenceLineDialog.cpp:1094
void InterpolationChanged(const QString &text)
Definition ddtReferenceLineDialog.cpp:1075
Definition ddtDatavisualisationUtils.hpp:18
DDT Utils. Helper classes for DDT Datavisualisation. Utilities for the DDT Datavisualisation.
DDT Dialog IDs. ID values for all used dialogs. IDs for the used dialogs.
DDT Dialogs. Base class for the DDT dialogs. Base class for the DDT dialogs.