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
maptoolmeshselectedge.h
Go to the documentation of this file.
1
32#ifndef OPENSWMMVIS_MAP_TOOLS_MAPTOOLMESHSELECTEDGE_H
33#define OPENSWMMVIS_MAP_TOOLS_MAPTOOLMESHSELECTEDGE_H
34
35#include "map/tools/maptool.h"
36#include "plot/plotattribute.h" // PlotAttribute (edge flow vs flux)
37
38#include <QPoint>
39#include <QPointer>
40
42class SWMM2DMeshLayer;
43
45{
46 Q_OBJECT
47public:
49 SelectionManager *selection,
50 QObject *parent = nullptr);
51
52 [[nodiscard]] bool boundaryOnly() const { return m_boundaryOnly; }
53 void setBoundaryOnly(bool on);
54
55 void activate() override;
56 void deactivate() override;
57
58 void mousePressEvent(QMouseEvent *event) override;
59 void mouseMoveEvent(QMouseEvent *event) override;
60 void mouseReleaseEvent(QMouseEvent *event) override;
61 void keyPressEvent(QKeyEvent *event) override;
62
63 void paint(QPainter *painter,
64 const MapExtent &canvasExtent,
65 const SpatialReferenceSystem *canvasSRS) override;
66
67signals:
72 void plotEdgeFluxRequested(SWMM2DMeshLayer *mesh, int triIdx, int edgeLocal,
74
77 void statusMessageChanged(const QString &message);
78
79private:
80 SWMM2DMeshLayer *findActiveMeshLayer_() const;
81 QPointF pixelToScene_(int px, int py) const;
82
84 int pickEdgeAtPixel_(const QPoint &pos, bool boundaryOnly) const;
86 void handlePathClick_(const QPoint &pos);
89 int pathStartFromSelection_() const;
91 void clearPathAnchor_();
93 void onMeshGeometryReady_();
95 void retargetMeshLayer_();
96
97 QPointer<SelectionManager> m_selection;
98 QPointer<SWMM2DMeshLayer> m_target;
99
100 // Default to selecting ANY edge (interior + boundary): interior edges
101 // are selectable so their flux time series can be plotted. Boundary
102 // conditions are still restricted to boundary edges by the toolbar's
103 // commitBCParam. Press B to restrict picking to boundary edges, A to
104 // include interior again.
105 bool m_boundaryOnly = false;
106 bool m_dragging = false;
107 QPoint m_startPixel;
108 QPoint m_currentPixel;
109
110 // Ctrl/⌘ path picking. m_pathAnchorSlot is the flat edge slot of the
111 // first Ctrl-clicked boundary edge (-1 = no anchor); it is dropped on
112 // deactivate, on a target-layer change, and when the layer republishes
113 // its scene geometry (the slot numbering would no longer mean the same
114 // edge). m_pathClickHandled swallows the release that follows the
115 // Ctrl-press so it doesn't also run a normal single-click select.
116 int m_pathAnchorSlot = -1;
117 bool m_pathClickHandled = false;
118
119 // The single edge this tool last put in the selection (plain click,
120 // right-click, or the far end of the last committed path), or -1 after
121 // a box-select / a miss, where "the selected edge" is ambiguous. Only
122 // honoured while it is still in the selection.
123 int m_lastEdgeSlot = -1;
124 static constexpr int kDragThreshPx = 6;
125 static constexpr double kPickTolPx = 8.0;
126};
127
128#endif // OPENSWMMVIS_MAP_TOOLS_MAPTOOLMESHSELECTEDGE_H
The central map display widget — QGIS-style hybrid rendering.
Definition mapcanvas.h:63
An axis-aligned bounding box in the coordinate space of a given CRS.
Definition mapextent.h:26
Definition maptoolmeshselectedge.h:45
bool boundaryOnly() const
Definition maptoolmeshselectedge.h:52
void activate() override
Called by the canvas when this tool becomes the active tool.
Definition maptoolmeshselectedge.cpp:42
void mouseReleaseEvent(QMouseEvent *event) override
Definition maptoolmeshselectedge.cpp:281
void plotEdgeFluxRequested(SWMM2DMeshLayer *mesh, int triIdx, int edgeLocal, openswmmvis::plot::PlotAttribute attr)
Emitted when the user right-clicks an edge and chooses "Plot edge flow" or "Plot edge flux"....
void mouseMoveEvent(QMouseEvent *event) override
Definition maptoolmeshselectedge.cpp:266
void setBoundaryOnly(bool on)
Definition maptoolmeshselectedge.cpp:37
void mousePressEvent(QMouseEvent *event) override
Definition maptoolmeshselectedge.cpp:212
void paint(QPainter *painter, const MapExtent &canvasExtent, const SpatialReferenceSystem *canvasSRS) override
Called by the canvas in drawForeground() so the tool can draw transient overlay graphics (rubber-band...
Definition maptoolmeshselectedge.cpp:391
void deactivate() override
Called by the canvas when another tool replaces this one.
Definition maptoolmeshselectedge.cpp:49
void statusMessageChanged(const QString &message)
Path-picking feedback for the host's status bar (anchor set, chain added, "requires boundary edges",...
void keyPressEvent(QKeyEvent *event) override
Definition maptoolmeshselectedge.cpp:362
Abstract base class for interactive map tools used in the MapCanvas.
Definition maptool.h:43
MapCanvas * canvas() const
Returns the MapCanvas this tool is attached to.
Definition maptool.cpp:29
Definition swmm2dmeshlayer.h:64
Owner of the canonical selection set for one SWMM project.
Definition selectionmanager.h:112
Represents a coordinate reference system backed by a GDAL OGRSpatialReference.
Definition spatialreferencesystem.h:28
Abstract base class for all interactive tools attached to a MapCanvas.
Definition meshcommands.h:302
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.
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
int pos
Definition queryparser.cpp:36
QString message
Definition queryparser.cpp:150