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
maptooleditvertex.h
Go to the documentation of this file.
1
13#ifndef MAPTOOLEDITVERTEX_H
14#define MAPTOOLEDITVERTEX_H
15
16#include "map/tools/maptool.h"
17
18#include <QPoint>
19#include <QPointF>
20#include <QString>
21#include <QVector>
22
23class SWMMModelLayer;
24
42{
43 Q_OBJECT
44
45public:
46 explicit OpenSWMMVisMapToolEditVertex(MapCanvas *canvas, QObject *parent = nullptr);
47
48 [[nodiscard]] QCursor cursor() const override;
49
50 void activate() override;
51 void deactivate() override;
52
53 void mousePressEvent(QMouseEvent *event) override;
54 void mouseMoveEvent(QMouseEvent *event) override;
55 void mouseReleaseEvent(QMouseEvent *event) override;
56 void mouseDoubleClickEvent(QMouseEvent *event) override;
57 void keyPressEvent(QKeyEvent *event) override;
58
59 void paint(QPainter *painter,
60 const MapExtent &canvasExtent,
61 const SpatialReferenceSystem *canvasSRS) override;
62
63signals:
64 void verticesEdited(const QString &linkName, int interiorVertexCount);
65
66private:
72 struct LinkHit {
73 SWMMModelLayer *layer = nullptr;
74 int linkIdx = -1;
75 QString name;
76 bool valid() const { return layer && linkIdx >= 0; }
77 };
78
79 void clearActiveLink();
80 LinkHit pickLink(const QPoint &pixel) const;
81 int hitTestInteriorHandle(const QPoint &pixel) const;
82 void commitInterior(QVector<QPointF> newInterior);
83
84 SWMMModelLayer *m_layer = nullptr;
85 int m_linkIdx = -1;
86 QString m_linkName;
87
88 // The cached interior vertices for the current link in LAYER coords.
89 QVector<QPointF> m_interior;
90
91 // Drag state
92 bool m_dragging = false;
93 int m_dragVertex = -1; // index into m_interior
94 QPointF m_dragOrigPt; // pre-drag map position of dragged vertex
95 int m_pickTol = 8; // pixels for handle hit
96
97 // Snap state (set each mouseMoveEvent during drag, cleared on release)
98 bool m_snapping = false;
99 QPointF m_snapPt;
100
101 static constexpr int kSnapRadiusPx = 15; // pixel radius for snap detection
102};
103
104#endif // MAPTOOLEDITVERTEX_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
Edit the interior polyline vertices of a SWMM link.
Definition maptooleditvertex.h:42
void mouseDoubleClickEvent(QMouseEvent *event) override
Definition maptooleditvertex.cpp:236
void mouseMoveEvent(QMouseEvent *event) override
Definition maptooleditvertex.cpp:188
void mousePressEvent(QMouseEvent *event) override
Definition maptooleditvertex.cpp:108
void deactivate() override
Called by the canvas when another tool replaces this one.
Definition maptooleditvertex.cpp:36
void mouseReleaseEvent(QMouseEvent *event) override
Definition maptooleditvertex.cpp:219
void keyPressEvent(QKeyEvent *event) override
Definition maptooleditvertex.cpp:243
QCursor cursor() const override
Returns the mouse cursor to display while this tool is active.
Definition maptooleditvertex.cpp:25
void verticesEdited(const QString &linkName, int interiorVertexCount)
void activate() override
Called by the canvas when this tool becomes the active tool.
Definition maptooleditvertex.cpp:30
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 maptooleditvertex.cpp:302
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
Renders the SWMM network elements (nodes, links, subcatchments, rain gages) for one OpenSWMMEngine mo...
Definition swmmmodellayer.h:133
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.
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
QString name
Definition sectionmodelbuilders.cpp:474