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
profileattributetrackswidget.h
Go to the documentation of this file.
1
27#ifndef OPENSWMMVIS_PLOT_PROFILEATTRIBUTETRACKSWIDGET_H
28#define OPENSWMMVIS_PLOT_PROFILEATTRIBUTETRACKSWIDGET_H
29
30#include "plot/plotattribute.h"
32
33#include <QPen>
34#include <QPointer>
35#include <QString>
36#include <QVector>
37#include <QWidget>
38
39#include <functional>
40#include <memory>
41
43
44class ProfileAttributeTracksWidget : public QWidget
45{
46 Q_OBJECT
47
48public:
53 {
54 QString label;
55 QColor color;
56 bool primary = false;
57 std::shared_ptr<const ProfileAttributeSampler::AttributeProfile> data;
58 };
59
70
71 explicit ProfileAttributeTracksWidget(QWidget *parent = nullptr);
72
76 void setVirtualChainage(const QVector<double> &table);
77
79 void setHorizontalMargins(int leftPx, int rightPx);
80
83 void setRealChainageMapper(std::function<double(double)> fn);
84
86 void setTracks(const QVector<Track> &tracks);
87 [[nodiscard]] int trackCount() const { return m_tracks.size(); }
88
92
94 void setXLabel(const QString &label);
95
96 // ── Pixel mapping (public for the alignment unit test) ─────────────
97 [[nodiscard]] double pixelForVirtualX(double vx) const;
98 [[nodiscard]] double virtualXForPixel(double px) const;
99
100public slots:
105 void setVisibleXRange(double vxMin, double vxMax);
106
109 void setCurrentPeriod(int period);
110
111signals:
114 void visibleXRangeChanged(double vxMin, double vxMax);
115
116protected:
117 void paintEvent(QPaintEvent *event) override;
118 void wheelEvent(QWheelEvent *event) override;
119 void mousePressEvent(QMouseEvent *event) override;
120 void mouseMoveEvent(QMouseEvent *event) override;
121 void mouseReleaseEvent(QMouseEvent *event) override;
122
123private:
128 [[nodiscard]] int preferredTrackHeight() const;
131 [[nodiscard]] int trackHeight() const;
132 [[nodiscard]] int bottomAxisHeight() const;
133 [[nodiscard]] QRectF trackRect(int trackIdx) const;
134 void updateSizeHint();
135 void paintTrack(QPainter &p, int trackIdx) const;
136 void paintBottomAxis(QPainter &p) const;
137
140 struct YRange { double lo = 0.0; double hi = 1.0; };
141 [[nodiscard]] YRange yRangeFor(const Track &t) const;
142
143 QVector<Track> m_tracks;
144 QVector<YRange> m_yRanges;
145 QVector<double> m_vx;
146 std::function<double(double)> m_toRealChainage;
147 QPointer<ProfileAttributeTrackOptions> m_options;
148 QString m_xLabel;
149
150 int m_marginLeft = 64;
151 int m_marginRight = 16;
152 double m_vxMin = 0.0;
153 double m_vxMax = 1.0;
154 int m_currentPeriod = -1;
155
156 bool m_panActive = false;
157 QPoint m_lastMousePos;
158};
159
160#endif // OPENSWMMVIS_PLOT_PROFILEATTRIBUTETRACKSWIDGET_H
Definition profileattributetrackoptions.h:35
Definition profileattributetrackswidget.h:45
void setOptions(ProfileAttributeTrackOptions *options)
Definition profileattributetrackswidget.cpp:82
void mouseReleaseEvent(QMouseEvent *event) override
Definition profileattributetrackswidget.cpp:469
void wheelEvent(QWheelEvent *event) override
Definition profileattributetrackswidget.cpp:422
void setXLabel(const QString &label)
Definition profileattributetrackswidget.cpp:96
void visibleXRangeChanged(double vxMin, double vxMax)
void paintEvent(QPaintEvent *event) override
Definition profileattributetrackswidget.cpp:211
void setVisibleXRange(double vxMin, double vxMax)
Definition profileattributetrackswidget.cpp:102
double virtualXForPixel(double px) const
Definition profileattributetrackswidget.cpp:178
void setHorizontalMargins(int leftPx, int rightPx)
Definition profileattributetrackswidget.cpp:58
void mousePressEvent(QMouseEvent *event) override
Definition profileattributetrackswidget.cpp:440
double pixelForVirtualX(double vx) const
Definition profileattributetrackswidget.cpp:171
void setVirtualChainage(const QVector< double > &table)
Definition profileattributetrackswidget.cpp:52
void setRealChainageMapper(std::function< double(double)> fn)
Definition profileattributetrackswidget.cpp:65
void setTracks(const QVector< Track > &tracks)
Definition profileattributetrackswidget.cpp:72
void mouseMoveEvent(QMouseEvent *event) override
Definition profileattributetrackswidget.cpp:453
int trackCount() const
Definition profileattributetrackswidget.h:87
void setCurrentPeriod(int period)
Definition profileattributetrackswidget.cpp:116
DiagramType t
Definition diagramspec.cpp:20
const char * label
Human label for the filter entry.
Definition gdaldrivers.cpp:22
ArrowPlacement p
Definition linesymbollayer.cpp:27
PlotAttribute
What a series plots. One row per attribute in the Nx2 grid.
Definition plotattribute.h:38
Slice BL — canonical enumeration of plottable result attributes.
Attribute-tracks feature — fetches an along-the-path profile of one generic result attribute (node de...
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
Definition profileattributetrackswidget.h:53
std::shared_ptr< const ProfileAttributeSampler::AttributeProfile > data
Definition profileattributetrackswidget.h:57
QString label
Definition profileattributetrackswidget.h:54
QColor color
Definition profileattributetrackswidget.h:55
bool primary
envelope drawn for the primary only
Definition profileattributetrackswidget.h:56
Definition profileattributetrackswidget.h:62
QVector< SourceProfile > sources
Definition profileattributetrackswidget.h:68
QString title
e.g. "Velocity (ft/s)" — resolved upstream
Definition profileattributetrackswidget.h:66
bool isNodeAttribute
Definition profileattributetrackswidget.h:65
openswmmvis::plot::PlotAttribute attribute
Definition profileattributetrackswidget.h:63
QPen pen
base line style from the options object
Definition profileattributetrackswidget.h:67
double
Definition swmmpollutantpropertyadapter.cpp:50