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
transectchartview.h
Go to the documentation of this file.
1
35#ifndef OPENSWMMVIS_UI_WIDGETS_TRANSECTCHARTVIEW_H
36#define OPENSWMMVIS_UI_WIDGETS_TRANSECTCHARTVIEW_H
37
38#include <QChartView>
39#include <QPointer>
40#include <QPointF>
41
42class QChart;
43class QAreaSeries;
44class QLineSeries;
45class QScatterSeries;
46class QValueAxis;
47
48namespace openswmmvis::transect { class TransectProvider; }
49
50namespace openswmmvis::ui {
51
52class TransectChartView : public QChartView
53{
54 Q_OBJECT
55
56 // Q_PROPERTY surface so the right-click context-menu's QPropertyModel-backed
57 // editor can drive the chart styling directly.
59 Q_PROPERTY(QColor channelColor READ channelColor WRITE setChannelColor NOTIFY channelColorChanged)
61 Q_PROPERTY(int handleSize READ handleSize WRITE setHandleSize NOTIFY handleSizeChanged)
63
64 // Axis number format — same surface as plot::ChartProperties: one combined
65 // dropdown per axis, plus an optional printf override.
67 Q_PROPERTY(QString xLabelFormat READ xLabelFormat WRITE setXLabelFormat NOTIFY xLabelFormatChanged)
69 Q_PROPERTY(QString yLabelFormat READ yLabelFormat WRITE setYLabelFormat NOTIFY yLabelFormatChanged)
70
71public:
74 Q_ENUM(LabelFormatMode)
75
76
92 Q_ENUM(AxisNumberFormat)
93
94
95 enum class Mode {
96 Select = 0,
97 Pan,
101 };
102 Q_ENUM(Mode)
103
104 Q_INVOKABLE QString displayLabelFor(const QString &property) const;
105
106 explicit TransectChartView(QWidget *parent = nullptr);
108
111
112 Mode mode() const noexcept { return m_mode; }
113 void setMode(Mode m);
114
115 void zoomToExtent();
116 void resetZoom();
117
118 // Style accessors — exposed so the right-click context menu's
119 // QPropertyModel-backed editor can drive them.
120 QColor overbankColor() const noexcept { return m_overbankColor; }
121 QColor channelColor() const noexcept { return m_channelColor; }
122 QColor groundFillColor() const noexcept { return m_groundFillColor; }
123 int handleSize() const noexcept { return m_handleSize; }
124 bool handlesVisible() const noexcept { return m_handlesVisible; }
125
126 void setOverbankColor(const QColor &c);
127 void setChannelColor(const QColor &c);
128 void setGroundFillColor(const QColor &c);
129 void setHandleSize(int px);
130 void setHandlesVisible(bool on);
131
132 // Axis number format accessors (driven via the QPropertyModel editor).
137
138 LabelFormatMode xLabelFormatMode() const noexcept { return m_xLabelMode; }
139 int xLabelPrecision() const noexcept { return m_xLabelPrecision; }
140 QString xLabelFormat() const { return m_xLabelFormatStr; }
141 LabelFormatMode yLabelFormatMode() const noexcept { return m_yLabelMode; }
142 int yLabelPrecision() const noexcept { return m_yLabelPrecision; }
143 QString yLabelFormat() const { return m_yLabelFormatStr; }
146
148 void setXLabelPrecision(int n);
149 void setXLabelFormat(const QString &spec);
151 void setYLabelPrecision(int n);
152 void setYLabelFormat(const QString &spec);
153
157 void setSelectedIndices(const QVector<int> &indices);
158 QVector<int> selectedIndices() const noexcept { return m_selectedIndices; }
159
160 // Test hooks
161 QLineSeries *leftOverbankLine() const noexcept { return m_leftOverbankLine; }
162 QLineSeries *rightOverbankLine() const noexcept { return m_rightOverbankLine; }
164 QLineSeries *overbankLine() const noexcept { return m_leftOverbankLine; }
165 QLineSeries *channelLine() const noexcept { return m_channelLine; }
166 QScatterSeries *handles() const noexcept { return m_handles; }
167 QAreaSeries *groundFill() const noexcept { return m_groundFill; }
168 QChart *chart() const noexcept;
169
170signals:
172 void contextMenuRequestedAt(const QPoint &globalPos);
173
174 void overbankColorChanged(const QColor &);
175 void channelColorChanged(const QColor &);
176 void groundFillColorChanged(const QColor &);
179
182 void xLabelFormatChanged(const QString &);
185 void yLabelFormatChanged(const QString &);
186
192 double oldStation, double oldElevation,
193 double newStation, double newElevation);
194
198 void handleClicked(int index, Qt::KeyboardModifiers mods);
199
203 void insertVertexRequested(double station, double elevation);
204
207
208protected:
209 void mousePressEvent(QMouseEvent *e) override;
210 void mouseMoveEvent(QMouseEvent *e) override;
211 void mouseReleaseEvent(QMouseEvent *e) override;
212 void wheelEvent(QWheelEvent *e) override;
213 void contextMenuEvent(QContextMenuEvent *e) override;
214 void keyPressEvent(QKeyEvent *e) override;
215
216private slots:
217 void onPointsChanged_();
218 void onBankStationsChanged_();
219 void onModifiersChanged_();
220 void onEncroachmentStationsChanged_();
221
222private:
223 void rebuildSeriesFromProvider_();
224 void rebuildBankOverlays_();
226 void applyAxisLabelFormats_();
229 int hitTestHandle_(const QPoint &viewportPx) const;
230 void applyModeCursor_();
231 void zoomAroundViewportPoint_(const QPoint &viewportPx, qreal factor);
232
233 QPointer<openswmmvis::transect::TransectProvider> m_provider;
234 Mode m_mode = Mode::Select;
235
236 QChart *m_chart = nullptr;
237 // Earth fill split per-zone — left overbank / channel / right overbank.
238 // m_groundFill keeps its name (and Q_PROPERTY `groundFillColor` keeps its
239 // semantics) but now paints only the CHANNEL zone; the two overbank
240 // shoulders are tinted with a derived `overbankColor` wash.
241 QAreaSeries *m_groundFill = nullptr;
242 QLineSeries *m_groundFillUpper = nullptr;
243 QLineSeries *m_groundFillLower = nullptr;
244 QAreaSeries *m_leftOverbankFill = nullptr;
245 QLineSeries *m_leftOverbankFillUpper = nullptr;
246 QLineSeries *m_leftOverbankFillLower = nullptr;
247 QAreaSeries *m_rightOverbankFill = nullptr;
248 QLineSeries *m_rightOverbankFillUpper = nullptr;
249 QLineSeries *m_rightOverbankFillLower = nullptr;
250 QLineSeries *m_leftOverbankLine = nullptr;
251 QLineSeries *m_rightOverbankLine = nullptr;
252 QLineSeries *m_channelLine = nullptr;
253 QScatterSeries *m_handles = nullptr;
256 QScatterSeries *m_selectedOverlay = nullptr;
257 QVector<int> m_selectedIndices;
258 QLineSeries *m_leftBankMark = nullptr;
259 QLineSeries *m_rightBankMark = nullptr;
260 // Horizontal bankfull lines: at the elevation of each bank station,
261 // extended across the corresponding overbank shoulder — HEC-RAS
262 // convention for visualising bankfull water surface.
263 QLineSeries *m_leftBankfullLine = nullptr;
264 QLineSeries *m_rightBankfullLine = nullptr;
265 // Encroachment-station markers (dashed). Hidden when value == 0.
266 QLineSeries *m_leftEncMark = nullptr;
267 QLineSeries *m_rightEncMark = nullptr;
268 QValueAxis *m_xAxis = nullptr;
269 QValueAxis *m_yAxis = nullptr;
270
271 // Drag state.
272 int m_dragIndex = -1;
273 bool m_dragging = false;
274 bool m_middlePanning = false;
275 QPoint m_lastPos;
276 double m_dragStartStation = 0.0;
277 double m_dragStartElev = 0.0;
278
279 // Pan state for left-button Pan mode.
280 bool m_leftPanning = false;
281
282 // Style.
283 QColor m_overbankColor = QColor(0xFF, 0x40, 0x40); // legacy clr 16512
284 QColor m_channelColor = QColor(0x00, 0x00, 0xC0); // clBlue
285 QColor m_groundFillColor = QColor(0xCC, 0xA0, 0x60, 0x70);
286 int m_handleSize = 6; // smaller default since markers are
287 // now always on (was 9 = drag handle).
288 bool m_handlesVisible = true; // points are visible by default;
289 // edit-mode adds drag affordance only.
290
291 // Axis number format — seeded from the global Preferences default in the
292 // constructor; per-chart edits override (cached because a printf format
293 // string can't be reliably parsed back to mode+count).
294 LabelFormatMode m_xLabelMode = Decimals;
295 int m_xLabelPrecision = 0;
296 QString m_xLabelFormatStr;
297 LabelFormatMode m_yLabelMode = Decimals;
298 int m_yLabelPrecision = 2;
299 QString m_yLabelFormatStr;
300};
301
302} // namespace openswmmvis::ui
303
304#endif // OPENSWMMVIS_UI_WIDGETS_TRANSECTCHARTVIEW_H
Definition transectprovider.h:42
Definition transectchartview.h:53
void setXLabelPrecision(int n)
Definition transectchartview.cpp:366
QString xLabelFormat
Definition transectchartview.h:67
void contextMenuEvent(QContextMenuEvent *e) override
Definition transectchartview.cpp:915
void yLabelFormatChanged(const QString &)
void mousePressEvent(QMouseEvent *e) override
Definition transectchartview.cpp:762
QColor groundFillColor() const noexcept
Definition transectchartview.h:122
void setProvider(openswmmvis::transect::TransectProvider *p)
Definition transectchartview.cpp:194
QVector< int > selectedIndices() const noexcept
Definition transectchartview.h:158
void setYLabelFormatMode(LabelFormatMode m)
Definition transectchartview.cpp:383
void setOverbankColor(const QColor &c)
Definition transectchartview.cpp:261
QLineSeries * overbankLine() const noexcept
Backward-compat alias for tests — returns the LEFT overbank.
Definition transectchartview.h:164
QChart * chart() const noexcept
Definition transectchartview.cpp:189
QString yLabelFormat() const
Definition transectchartview.h:143
void xLabelFormatChanged(const QString &)
void deleteVertexRequested(int index)
Left-click on a handle in DeleteVertex mode.
void resetZoom()
Definition transectchartview.cpp:700
void handleClicked(int index, Qt::KeyboardModifiers mods)
Left-click on a handle in Select/EditPoints mode. The dialog uses this to drive the table's selection...
bool handlesVisible() const noexcept
Definition transectchartview.h:124
void setYLabelPrecision(int n)
Definition transectchartview.cpp:391
QAreaSeries * groundFill() const noexcept
Definition transectchartview.h:167
void mouseMoveEvent(QMouseEvent *e) override
Definition transectchartview.cpp:839
Mode mode() const noexcept
Definition transectchartview.h:112
Q_INVOKABLE QString displayLabelFor(const QString &property) const
Definition transectchartview.cpp:408
QColor groundFillColor
Definition transectchartview.h:60
void contextMenuRequestedAt(const QPoint &globalPos)
QString yLabelFormat
Definition transectchartview.h:69
QLineSeries * channelLine() const noexcept
Definition transectchartview.h:165
void wheelEvent(QWheelEvent *e) override
Definition transectchartview.cpp:734
TransectChartView::AxisNumberFormat xAxisNumberFormat
Definition transectchartview.h:66
QScatterSeries * handles() const noexcept
Definition transectchartview.h:166
LabelFormatMode xLabelFormatMode() const noexcept
Definition transectchartview.h:138
AxisNumberFormat
Definition transectchartview.h:81
@ SigFigs4
Definition transectchartview.h:89
@ Decimals3
Definition transectchartview.h:85
@ Decimals1
Definition transectchartview.h:83
@ SigFigs6
Definition transectchartview.h:90
@ Decimals4
Definition transectchartview.h:86
@ Decimals6
Definition transectchartview.h:87
@ Integer
Definition transectchartview.h:82
@ Decimals2
Definition transectchartview.h:84
@ SigFigs3
Definition transectchartview.h:88
QColor channelColor
Definition transectchartview.h:59
void xLabelFormatModeChanged(TransectChartView::LabelFormatMode)
void stationDragFinished(int index, double oldStation, double oldElevation, double newStation, double newElevation)
Emitted on left-button release after an EditPoints drag. Carries the original (pre-drag) and final (p...
void setXLabelFormat(const QString &spec)
Definition transectchartview.cpp:375
QLineSeries * leftOverbankLine() const noexcept
Definition transectchartview.h:161
void setXAxisNumberFormat(TransectChartView::AxisNumberFormat f)
Definition transectchartview.cpp:342
int yLabelPrecision() const noexcept
Definition transectchartview.h:142
void groundFillColorChanged(const QColor &)
int handleSize
Definition transectchartview.h:61
QColor overbankColor() const noexcept
Definition transectchartview.h:120
void mouseReleaseEvent(QMouseEvent *e) override
Definition transectchartview.cpp:869
QColor overbankColor
Definition transectchartview.h:58
Mode
Definition transectchartview.h:95
@ DeleteVertex
Left-button click on a handle removes it.
@ EditPoints
Left-button drag on a handle moves a station.
@ Select
Default — middle-button pan + wheel zoom only.
@ InsertVertex
Left-button click inserts a station at click point.
QColor channelColor() const noexcept
Definition transectchartview.h:121
void overbankColorChanged(const QColor &)
void setGroundFillColor(const QColor &c)
Definition transectchartview.cpp:291
LabelFormatMode yLabelFormatMode() const noexcept
Definition transectchartview.h:141
void setSelectedIndices(const QVector< int > &indices)
Highlight the given station indices on the chart. Pass an empty vector to clear. Implemented as a sec...
Definition transectchartview.cpp:243
void zoomToExtent()
Definition transectchartview.cpp:706
void setYAxisNumberFormat(TransectChartView::AxisNumberFormat f)
Definition transectchartview.cpp:351
void channelColorChanged(const QColor &)
void setChannelColor(const QColor &c)
Definition transectchartview.cpp:275
TransectChartView::AxisNumberFormat yAxisNumberFormat
Definition transectchartview.h:68
void setHandlesVisible(bool on)
Definition transectchartview.cpp:308
void insertVertexRequested(double station, double elevation)
Left-click on empty space in InsertVertex mode (or Shift+click on empty space in EditPoints mode)....
void setXLabelFormatMode(LabelFormatMode m)
Definition transectchartview.cpp:358
int handleSize() const noexcept
Definition transectchartview.h:123
void yLabelFormatModeChanged(TransectChartView::LabelFormatMode)
QLineSeries * rightOverbankLine() const noexcept
Definition transectchartview.h:162
void keyPressEvent(QKeyEvent *e) override
Definition transectchartview.cpp:921
int xLabelPrecision() const noexcept
Definition transectchartview.h:139
openswmmvis::transect::TransectProvider * provider() const noexcept
Definition transectchartview.cpp:216
void setYLabelFormat(const QString &spec)
Definition transectchartview.cpp:400
LabelFormatMode
Axis label number mode (mirrors plot::NumberFormatMode).
Definition transectchartview.h:73
@ Decimals
Definition transectchartview.h:73
@ SignificantFigures
Definition transectchartview.h:73
void setMode(Mode m)
Definition transectchartview.cpp:221
QString xLabelFormat() const
Definition transectchartview.h:140
bool handlesVisible
Definition transectchartview.h:62
void setHandleSize(int px)
Definition transectchartview.cpp:299
int e
Definition inpmeshreader.cpp:41
ArrowPlacement p
Definition linesymbollayer.cpp:27
MaskMode m
Definition maskspec.cpp:18
std::size_t n
Definition mesh2dresultsexport.cpp:426
int index
Position in m_quadRegions / m_quadReports.
Definition meshgenerator.cpp:153
Definition transectprovider.h:33
Definition openswmmvislayer.h:43
Definition aquiferprovider.h:21
QVector< int > parent
union-find
Definition pslgminsize.cpp:176