SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
chartproperties.h
Go to the documentation of this file.
1
22#ifndef OPENSWMMVIS_PLOT_CHARTPROPERTIES_H
23#define OPENSWMMVIS_PLOT_CHARTPROPERTIES_H
24
25#include "plot/numberformat.h"
26
27#include <QChart>
28#include <QColor>
29#include <QFont>
30#include <QObject>
31#include <QPointer>
32#include <QString>
33
35
36class ChartProperties : public QObject
37{
38 Q_OBJECT
39
40public:
46 Q_ENUM(LabelFormatMode)
47
48
72 Q_ENUM(AxisNumberFormat)
73
74 Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged)
75 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged)
76
77 Q_PROPERTY(bool yAutoRange READ yAutoRange WRITE setYAutoRange NOTIFY yAutoRangeChanged)
78 Q_PROPERTY(qreal yMin READ yMin WRITE setYMin NOTIFY yMinChanged)
79 Q_PROPERTY(qreal yMax READ yMax WRITE setYMax NOTIFY yMaxChanged)
82
85
88 Q_PROPERTY(QColor gridColor READ gridColor WRITE setGridColor NOTIFY gridColorChanged)
89
90 Q_PROPERTY(int chartTheme READ chartTheme WRITE setChartTheme NOTIFY chartThemeChanged)
91
93 Q_PROPERTY(QString xLabelFormat READ xLabelFormat WRITE setXLabelFormat NOTIFY xLabelFormatChanged)
95 Q_PROPERTY(QString yLabelFormat READ yLabelFormat WRITE setYLabelFormat NOTIFY yLabelFormatChanged)
98
99public:
100 explicit ChartProperties(QChart *chart, QObject *parent = nullptr);
101 ~ChartProperties() override = default;
102
103 QChart *chart() const noexcept { return m_chart.data(); }
104
108 Q_INVOKABLE QString displayLabelFor(const QString &propertyName) const;
109
110signals:
112public:
113
114 QString titleText() const;
115 QFont titleFont() const;
116 bool yAutoRange() const noexcept { return m_yAutoRange; }
117 qreal yMin() const;
118 qreal yMax() const;
119 bool yGridVisible() const;
120 bool xGridVisible() const;
121 QFont axisLabelFont() const;
122 QFont tickLabelFont() const;
123 QColor backgroundColor() const;
124 QColor plotAreaColor() const;
125 QColor gridColor() const noexcept { return m_gridColor; }
126 int chartTheme() const;
127
133
134 LabelFormatMode xLabelFormatMode() const noexcept { return m_xLabelMode; }
135 int xLabelPrecision() const noexcept { return m_xLabelPrecision; }
136 QString xLabelFormat() const { return m_xLabelFormatStr; }
137 LabelFormatMode yLabelFormatMode() const noexcept { return m_yLabelMode; }
138 int yLabelPrecision() const noexcept { return m_yLabelPrecision; }
139 QString yLabelFormat() const { return m_yLabelFormatStr; }
140 LabelFormatMode statisticsFormatMode() const noexcept { return m_statisticsMode; }
141 int statisticsPrecision() const noexcept { return m_statisticsPrecision; }
142 QString statisticsFormat() const { return m_statisticsFormatStr; }
143
145 NumberFormat xFormat() const noexcept;
146 NumberFormat yFormat() const noexcept;
147 NumberFormat statisticsNumberFormat() const noexcept;
148
149public slots:
150 void setTitleText(const QString &text);
151 void setTitleFont(const QFont &font);
152 void setYAutoRange(bool on);
153 void setYMin(qreal v);
154 void setYMax(qreal v);
155 void setYGridVisible(bool on);
156 void setXGridVisible(bool on);
157 void setAxisLabelFont(const QFont &font);
158 void setTickLabelFont(const QFont &font);
159 void setBackgroundColor(const QColor &c);
160 void setPlotAreaColor(const QColor &c);
161 void setGridColor(const QColor &c);
162 void setChartTheme(int theme);
163
168 void setXLabelPrecision(int count);
169 void setXLabelFormat(const QString &spec);
171 void setYLabelPrecision(int count);
172 void setYLabelFormat(const QString &spec);
175 void setStatisticsFormat(const QString &spec);
176 void setStatisticsNumberFormat(const NumberFormat &format);
177
178signals:
179 void titleTextChanged(const QString &);
180 void titleFontChanged(const QFont &);
182 void yMinChanged(qreal);
183 void yMaxChanged(qreal);
186 void axisLabelFontChanged(const QFont &);
187 void tickLabelFontChanged(const QFont &);
188 void backgroundColorChanged(const QColor &);
189 void plotAreaColorChanged(const QColor &);
190 void gridColorChanged(const QColor &);
192
195 void xLabelFormatChanged(const QString &);
198 void yLabelFormatChanged(const QString &);
201 // Fired alongside the mode/precision signals above, so the combined
202 // property notifies no matter which path changed the underlying pair.
206 void statisticsFormatChanged(const QString &);
207
208private:
209 // Push the cached X/Y label formats onto the chart's value axes
210 // (QDateTimeAxis/QCategoryAxis are skipped — only QValueAxis honours it).
211 void applyLabelFormats_();
212
213 QPointer<QChart> m_chart;
214
215 // Cached values for QChart configuration that's awkward to read back
216 // (grid colour isn't a first-class QChart attribute; it's per-axis pen).
217 bool m_yAutoRange = true;
218 QColor m_gridColor = QColor("#cccccc");
219
220 // Axis label number formats. Seeded from the global Preferences default
221 // in the constructor; per-chart edits override them (cached because a
222 // printf format string can't be reliably parsed back to mode+count).
223 LabelFormatMode m_xLabelMode = Decimals;
224 int m_xLabelPrecision = 0;
225 QString m_xLabelFormatStr; // optional printf override; empty = use mode+precision
226 LabelFormatMode m_yLabelMode = Decimals;
227 int m_yLabelPrecision = 2;
228 QString m_yLabelFormatStr; // optional printf override; empty = use mode+precision
229
230 // Statistics summary value format. Exposed through the same properties
231 // dialog so the stats panel does not need its own formatting controls.
232 LabelFormatMode m_statisticsMode = Decimals;
233 int m_statisticsPrecision = 2;
234 QString m_statisticsFormatStr;
235};
236
237} // namespace openswmmvis::plot
238
239#endif // OPENSWMMVIS_PLOT_CHARTPROPERTIES_H
Definition chartproperties.h:37
void yAxisNumberFormatChanged(ChartProperties::AxisNumberFormat)
int yLabelPrecision() const noexcept
Definition chartproperties.h:138
void titleFontChanged(const QFont &)
NumberFormat statisticsNumberFormat() const noexcept
Definition chartproperties.cpp:65
void setTitleFont(const QFont &font)
Definition chartproperties.cpp:193
void xAxisNumberFormatChanged(ChartProperties::AxisNumberFormat)
void setYLabelFormat(const QString &spec)
Definition chartproperties.cpp:388
QFont titleFont
Definition chartproperties.h:75
QFont tickLabelFont
Definition chartproperties.h:84
bool xGridVisible
Definition chartproperties.h:81
void setYLabelFormatMode(ChartProperties::LabelFormatMode mode)
Definition chartproperties.cpp:369
AxisNumberFormat
Definition chartproperties.h:53
@ Scientific4
Definition chartproperties.h:65
@ ThousandsInteger
Definition chartproperties.h:68
@ Decimals1
Definition chartproperties.h:55
@ SigFigs6
Definition chartproperties.h:62
@ Thousands1
Definition chartproperties.h:69
@ Decimals2
Definition chartproperties.h:56
@ Decimals6
Definition chartproperties.h:59
@ SigFigs4
Definition chartproperties.h:61
@ Integer
Definition chartproperties.h:54
@ Decimals4
Definition chartproperties.h:58
@ Decimals3
Definition chartproperties.h:57
@ Scientific3
Definition chartproperties.h:64
@ Engineering3
Definition chartproperties.h:67
@ Scientific2
Definition chartproperties.h:63
@ SigFigs3
Definition chartproperties.h:60
@ Engineering2
Definition chartproperties.h:66
@ Thousands2
Definition chartproperties.h:70
void setYMax(qreal v)
Definition chartproperties.cpp:219
QColor backgroundColor
Definition chartproperties.h:86
Q_INVOKABLE QString displayLabelFor(const QString &propertyName) const
AT.3 polish — QPropertyModel hook for human-friendly, group-prefixed display labels in the Chart Prop...
Definition chartproperties.cpp:94
LabelFormatMode
Axis label number mode; values mirror openswmmvis::plot::NumberFormatMode (0=Decimals,...
Definition chartproperties.h:44
@ Thousands
Definition chartproperties.h:45
@ Scientific
Definition chartproperties.h:45
@ SignificantFigures
Definition chartproperties.h:44
@ Decimals
Definition chartproperties.h:44
@ Engineering
Definition chartproperties.h:45
QString statisticsFormat
Definition chartproperties.h:97
QString xLabelFormat() const
Definition chartproperties.h:136
int chartTheme
Definition chartproperties.h:90
QColor plotAreaColor
Definition chartproperties.h:87
void statisticsFormatPresetChanged(ChartProperties::AxisNumberFormat)
void setAxisLabelFont(const QFont &font)
Definition chartproperties.cpp:244
QColor gridColor
Definition chartproperties.h:88
qreal yMax
Definition chartproperties.h:79
void statisticsFormatModeChanged(ChartProperties::LabelFormatMode)
bool yGridVisible
Definition chartproperties.h:80
LabelFormatMode statisticsFormatMode() const noexcept
Definition chartproperties.h:140
void setStatisticsFormat(const QString &spec)
Definition chartproperties.cpp:413
void yLabelFormatModeChanged(ChartProperties::LabelFormatMode)
void setXLabelFormatMode(ChartProperties::LabelFormatMode mode)
Definition chartproperties.cpp:342
void xLabelFormatModeChanged(ChartProperties::LabelFormatMode)
void setYLabelPrecision(int count)
Definition chartproperties.cpp:378
QString titleText
Definition chartproperties.h:74
void setStatisticsPrecision(int count)
Definition chartproperties.cpp:404
void setBackgroundColor(const QColor &c)
Definition chartproperties.cpp:260
QChart * chart() const noexcept
Definition chartproperties.h:103
void setYAxisNumberFormat(ChartProperties::AxisNumberFormat f)
Definition chartproperties.cpp:328
QString statisticsFormat() const
Definition chartproperties.h:142
void xLabelFormatChanged(const QString &)
void backgroundColorChanged(const QColor &)
ChartProperties::AxisNumberFormat xAxisNumberFormat
Definition chartproperties.h:92
void tickLabelFontChanged(const QFont &)
void setStatisticsFormatPreset(ChartProperties::AxisNumberFormat f)
Definition chartproperties.cpp:335
int statisticsPrecision() const noexcept
Definition chartproperties.h:141
void setYMin(qreal v)
Definition chartproperties.cpp:210
void setTickLabelFont(const QFont &font)
Definition chartproperties.cpp:252
QColor gridColor() const noexcept
Definition chartproperties.h:125
void setPlotAreaColor(const QColor &c)
Definition chartproperties.cpp:267
void plotAreaColorChanged(const QColor &)
void yLabelFormatChanged(const QString &)
NumberFormat xFormat() const noexcept
Current X/Y/statistics number format as the shared value type.
Definition chartproperties.cpp:55
void setXAxisNumberFormat(ChartProperties::AxisNumberFormat f)
Definition chartproperties.cpp:319
void setYGridVisible(bool on)
Definition chartproperties.cpp:228
void statisticsFormatChanged(const QString &)
bool yAutoRange() const noexcept
Definition chartproperties.h:116
void gridColorChanged(const QColor &)
void setXGridVisible(bool on)
Definition chartproperties.cpp:236
LabelFormatMode xLabelFormatMode() const noexcept
Definition chartproperties.h:134
void setTitleText(const QString &text)
Definition chartproperties.cpp:186
ChartProperties::AxisNumberFormat yAxisNumberFormat
Definition chartproperties.h:94
QString xLabelFormat
Definition chartproperties.h:93
void setXLabelPrecision(int count)
Definition chartproperties.cpp:351
void setXLabelFormat(const QString &spec)
Definition chartproperties.cpp:361
void titleTextChanged(const QString &)
bool yAutoRange
Definition chartproperties.h:77
qreal yMin
Definition chartproperties.h:78
LabelFormatMode yLabelFormatMode() const noexcept
Definition chartproperties.h:137
void setStatisticsFormatMode(ChartProperties::LabelFormatMode mode)
Definition chartproperties.cpp:396
void setGridColor(const QColor &c)
Definition chartproperties.cpp:275
ChartProperties::AxisNumberFormat statisticsFormatPreset
Definition chartproperties.h:96
void setStatisticsNumberFormat(const NumberFormat &format)
Definition chartproperties.cpp:420
void setChartTheme(int theme)
Definition chartproperties.cpp:287
void axisLabelFontChanged(const QFont &)
void setYAutoRange(bool on)
Definition chartproperties.cpp:200
QFont axisLabelFont
Definition chartproperties.h:83
QString yLabelFormat
Definition chartproperties.h:95
int xLabelPrecision() const noexcept
Definition chartproperties.h:135
NumberFormat yFormat() const noexcept
Definition chartproperties.cpp:60
QString yLabelFormat() const
Definition chartproperties.h:139
InletTheme theme
Definition inletdrawingview.cpp:79
QuadRegionMode mode
Resolved mode.
Definition meshgenerator.cpp:154
Definition chartproperties.h:34
int count
Definition numberformat.cpp:101
Single source of truth for how chart plots render numeric values.
QVector< int > v
pool vertex indices
Definition pslgminsize.cpp:159
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
QString text
Definition queryparser.cpp:35
A mode + count describing how to render a double.
Definition numberformat.h:41