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
meshprofileplotwidget.h
Go to the documentation of this file.
1
26#ifndef MESH_PROFILE_PLOT_WIDGET_H
27#define MESH_PROFILE_PLOT_WIDGET_H
28
31
32#include <QDateTime>
33#include <QPointer>
34#include <QString>
35#include <QVector>
36#include <QWidget>
37
38class QRubberBand;
39
40class MeshProfilePlotWidget : public QWidget
41{
42 Q_OBJECT
43public:
44 explicit MeshProfilePlotWidget(QWidget *parent = nullptr);
45
48
53 void setCurrentDepths(const QVector<double> &depthNow,
54 const QVector<bool> &cellHasSurface = {});
55
58 [[nodiscard]] MeshProfilePlotOptions *options() const { return m_options; }
59
61 void setCurrentDateTime(const QDateTime &dt);
62
63 void setAxisLabels(const QString &xLabel, const QString &yLabel);
64
65 // ── Position cursor (chart ↔ map sync) ──────────────────────────────
70 void setCursorChainage(double chainage);
71 [[nodiscard]] bool hasCursor() const { return m_hasCursor; }
72 [[nodiscard]] double cursorChainage() const { return m_cursorChainage; }
73
74 // ── Zoom / pan (driven by the dialog toolbar) ───────────────────────
75 enum class Mode { Identify = 0, Pan, ZoomIn, ZoomOut };
76 enum class AxisEdge {
77 None = 0,
82 };
83 Q_ENUM(AxisEdge)
84
85 void setMode(Mode m);
86 [[nodiscard]] Mode mode() const { return m_mode; }
87 [[nodiscard]] AxisEdge axisEdgeAt(const QPoint &widgetPos) const;
88 bool setAxisEdgeValue(AxisEdge edge, double value);
89 [[nodiscard]] QRectF visibleDataRange() const;
90 void zoomBy(double factor);
91 void fitToExtent();
92
93signals:
97 void cursorChainageChanged(double chainage);
98
99protected:
100 void paintEvent(QPaintEvent *event) override;
101 void resizeEvent(QResizeEvent *event) override;
102 void mousePressEvent(QMouseEvent *event) override;
103 void mouseMoveEvent(QMouseEvent *event) override;
104 void mouseReleaseEvent(QMouseEvent *event) override;
105 void wheelEvent(QWheelEvent *event) override;
106
107private:
108 [[nodiscard]] QRectF plotRect() const;
109 [[nodiscard]] QPointF dataToPixel(double chainage, double elev) const;
110 [[nodiscard]] double pixelToChainage(double px) const;
113 [[nodiscard]] bool sampleAtChainage(double chain, double &ground, double &wse) const;
114 void recomputeBounds();
115 bool editAxisEdge(AxisEdge edge);
116
117 void paintBackgroundAndAxes(QPainter &p) const;
118 void paintSoilFill(QPainter &p) const;
119 void paintMaxEnvelope(QPainter &p) const;
120 void paintDepthFill(QPainter &p) const;
121 void paintWseLine(QPainter &p) const;
122 void paintGroundLine(QPainter &p) const;
123 void paintCellBoundaryDots(QPainter &p) const;
124 void paintCursor(QPainter &p) const;
125 void paintLegend(QPainter &p) const;
126 void paintTimeLabel(QPainter &p) const;
127
129 QPointer<MeshProfilePlotOptions> m_options;
130 QDateTime m_currentDateTime;
131 QString m_xLabel = QStringLiteral("Distance");
132 QString m_yLabel = QStringLiteral("Elevation");
133
134 // Auto extent (data bounds) + current view bounds.
135 double m_autoXMin = 0.0, m_autoXMax = 1.0, m_autoYMin = 0.0, m_autoYMax = 1.0;
136 double m_dataXMin = 0.0, m_dataXMax = 1.0, m_dataYMin = 0.0, m_dataYMax = 1.0;
137 bool m_fitMode = true;
138
139 Mode m_mode = Mode::Identify;
140 bool m_panActive = false;
141 bool m_zoomActive = false;
142 AxisEdge m_pressedAxisEdge = AxisEdge::None;
143 QPoint m_lastMousePos;
144 QPoint m_zoomAnchor;
145 QRubberBand *m_rubberBand = nullptr;
146
147 // Last-painted overlay rects (drag hit-test).
148 mutable QRectF m_legendRect;
149 mutable QRectF m_timeLabelRect;
150 enum class OverlayDrag { None = 0, Legend, TimeLabel };
151 OverlayDrag m_overlayDrag = OverlayDrag::None;
152 QPoint m_overlayDragLastPos;
153
154 // Position cursor (a draggable vertical line synced with the map arrow).
155 bool m_hasCursor = false;
156 double m_cursorChainage = 0.0;
157 bool m_cursorDragging = false;
158};
159
160#endif // MESH_PROFILE_PLOT_WIDGET_H
Definition meshprofileplotoptions.h:28
Definition meshprofileplotwidget.h:41
bool setAxisEdgeValue(AxisEdge edge, double value)
Definition meshprofileplotwidget.cpp:274
Mode
Definition meshprofileplotwidget.h:75
void wheelEvent(QWheelEvent *event) override
Definition meshprofileplotwidget.cpp:611
bool hasCursor() const
Definition meshprofileplotwidget.h:71
void fitToExtent()
Definition meshprofileplotwidget.cpp:209
void setCursorChainage(double chainage)
Show/move the vertical position cursor at chainage (scene units along the path). Clamped to the path ...
Definition meshprofileplotwidget.cpp:152
double cursorChainage() const
Definition meshprofileplotwidget.h:72
void mousePressEvent(QMouseEvent *event) override
Definition meshprofileplotwidget.cpp:416
void resizeEvent(QResizeEvent *event) override
Definition meshprofileplotwidget.cpp:393
void paintEvent(QPaintEvent *event) override
Definition meshprofileplotwidget.cpp:395
void setAxisLabels(const QString &xLabel, const QString &yLabel)
Definition meshprofileplotwidget.cpp:145
void setMode(Mode m)
Definition meshprofileplotwidget.cpp:230
QRectF visibleDataRange() const
Definition meshprofileplotwidget.cpp:304
AxisEdge axisEdgeAt(const QPoint &widgetPos) const
Definition meshprofileplotwidget.cpp:247
void setCurrentDepths(const QVector< double > &depthNow, const QVector< bool > &cellHasSurface={})
Cheap per-frame update of the animated depth column. Size must match the current sample count; mismat...
Definition meshprofileplotwidget.cpp:113
AxisEdge
Definition meshprofileplotwidget.h:76
void setCurrentDateTime(const QDateTime &dt)
Wall-clock time shown by the timestamp overlay.
Definition meshprofileplotwidget.cpp:138
MeshProfilePlotOptions * options() const
Definition meshprofileplotwidget.h:58
Mode mode() const
Definition meshprofileplotwidget.h:86
void setOptions(MeshProfilePlotOptions *options)
Binds the styling object (connects changed() → repaint).
Definition meshprofileplotwidget.cpp:126
void mouseMoveEvent(QMouseEvent *event) override
Definition meshprofileplotwidget.cpp:481
void setProfile(const MeshProfileSampler::MeshProfile &profile)
Sets the full cross-section (recomputes bounds + repaints).
Definition meshprofileplotwidget.cpp:106
void zoomBy(double factor)
Definition meshprofileplotwidget.cpp:217
void mouseReleaseEvent(QMouseEvent *event) override
Definition meshprofileplotwidget.cpp:529
void cursorChainageChanged(double chainage)
Emitted while the user drags the position cursor on the chart. chainage is the scene-unit distance al...
ArrowPlacement p
Definition linesymbollayer.cpp:27
MaskMode m
Definition maskspec.cpp:18
Q_OBJECT facade for the user-configurable display options on the 2D mesh longitudinal profile plot....
Pure-logic sampler that turns a user-traced polyline across the 2D surface mesh into a longitudinal c...
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
The assembled cross-section: ordered samples + a results flag.
Definition profilesection.h:70