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
maptoolpick2dcells.h
Go to the documentation of this file.
1
25#ifndef OPENSWMMVIS_MAP_TOOLS_MAPTOOLPICK2DCELLS_H
26#define OPENSWMMVIS_MAP_TOOLS_MAPTOOLPICK2DCELLS_H
27
28#include "map/tools/maptool.h"
29#include "plot/plotattribute.h"
30
31#include <QPoint>
32#include <QPolygon>
33#include <QPolygonF>
34#include <QPointer>
35#include <QRectF>
36#include <QVector>
37
39class SWMM2DMeshLayer;
41
43{
44 Q_OBJECT
45public:
46 enum class Mode { Box, Lasso };
47
49 SelectionManager *selection,
50 QObject *parent = nullptr);
51 ~MapToolPick2DCells() override = default;
52
53 void setMode(Mode m);
54 [[nodiscard]] Mode mode() const noexcept { return m_mode; }
55
61
62 void activate() override;
63 void deactivate() override;
64
65 void mousePressEvent(QMouseEvent *event) override;
66 void mouseMoveEvent(QMouseEvent *event) override;
67 void mouseReleaseEvent(QMouseEvent *event) override;
68 void mouseDoubleClickEvent(QMouseEvent *event) override;
69 void keyPressEvent(QKeyEvent *event) override;
70
71 void paint(QPainter *painter,
72 const MapExtent &canvasExtent,
73 const SpatialReferenceSystem *canvasSRS) override;
74
75signals:
81 void cellsPicked(SWMM2DResultsLayer *layer, const QVector<int> &triIdxList,
82 const QVector<openswmmvis::plot::PlotAttribute> &attrs);
83
84private:
86 SWMM2DResultsLayer *findResultsLayer_() const;
87
90 SWMM2DMeshLayer *findMeshLayer_() const;
91
96 void applySelection_(const QVector<int> &hits, Qt::KeyboardModifiers mods);
97
100 [[nodiscard]] QVector<int> selectedCells_() const;
101
105 void requestPlotAt_(const QPoint &pixel, const QPoint &globalPos);
106
109 QPointF pixelToScene_(int px, int py) const;
110
115 int pickCellAtScene_(const QPointF &scenePt);
116
118 QVector<int> pickCellsInRectScene_(const QRectF &sceneRect);
119
121 QVector<int> pickCellsInPolygonScene_(const QPolygonF &scenePoly);
122
123 Mode m_mode = Mode::Box;
124
125 // Box state.
126 bool m_dragging = false;
127 QPoint m_startPixel;
128 QPoint m_currentPixel;
129 static constexpr int kDragThreshPx = 8;
130
131 // Lasso state.
132 bool m_drawing = false;
133 QVector<QPointF> m_lassoMapPts; // map coords
134 QPoint m_cursorPixel;
135
136 // Right-click plot is armed on press but fired on RELEASE: the handler
137 // exec()s the context menu, and starting a modal session while the
138 // physical button is still down makes AppKit discard the pending
139 // mouse-up for the (now modally blocked) canvas window — Qt's per-view
140 // button state then latches RightButton forever and its implicit grab
141 // redirects every later click app-wide (whole-UI input freeze).
142 bool m_pendingRightPlot = false;
143
144 QPointer<SWMM2DResultsLayer> m_targetLayer;
145 QPointer<SWMM2DMeshLayer> m_meshLayer;
146 QPointer<SelectionManager> m_selection;
147};
148
149#endif // OPENSWMMVIS_MAP_TOOLS_MAPTOOLPICK2DCELLS_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 maptoolpick2dcells.h:43
void keyPressEvent(QKeyEvent *event) override
Definition maptoolpick2dcells.cpp:362
void activate() override
Called by the canvas when this tool becomes the active tool.
Definition maptoolpick2dcells.cpp:54
void mouseDoubleClickEvent(QMouseEvent *event) override
Definition maptoolpick2dcells.cpp:314
void setTargetLayer(SWMM2DResultsLayer *layer)
Definition maptoolpick2dcells.cpp:49
void mouseMoveEvent(QMouseEvent *event) override
Definition maptoolpick2dcells.cpp:246
void deactivate() override
Called by the canvas when another tool replaces this one.
Definition maptoolpick2dcells.cpp:67
void cellsPicked(SWMM2DResultsLayer *layer, const QVector< int > &triIdxList, const QVector< openswmmvis::plot::PlotAttribute > &attrs)
Emitted when the user picks an entry from the right-click "plot" context menu.
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 maptoolpick2dcells.cpp:385
Mode
Definition maptoolpick2dcells.h:46
void setMode(Mode m)
Definition maptoolpick2dcells.cpp:37
void mouseReleaseEvent(QMouseEvent *event) override
Definition maptoolpick2dcells.cpp:267
void mousePressEvent(QMouseEvent *event) override
Definition maptoolpick2dcells.cpp:209
~MapToolPick2DCells() override=default
Mode mode() const noexcept
Definition maptoolpick2dcells.h:54
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
Definition swmm2dresultslayer.h:550
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.
MaskMode m
Definition maskspec.cpp:18
Slice BL — canonical enumeration of plottable result attributes.
QVector< int > parent
union-find
Definition pslgminsize.cpp:176