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
maptoolmovenode.h
Go to the documentation of this file.
1
8#ifndef MAPTOOLMOVENODE_H
9#define MAPTOOLMOVENODE_H
10
11#include "map/tools/maptool.h"
12
13#include <QPoint>
14#include <QPointF>
15#include <QString>
16
17class SWMMModelLayer;
18
39{
40 Q_OBJECT
41
42public:
43 explicit OpenSWMMVisMapToolMoveNode(MapCanvas *canvas, QObject *parent = nullptr);
44
45 [[nodiscard]] QCursor cursor() const override;
46
47 void activate() override;
48 void deactivate() override;
49
50 void mousePressEvent(QMouseEvent *event) override;
51 void mouseMoveEvent(QMouseEvent *event) override;
52 void mouseReleaseEvent(QMouseEvent *event) override;
53 void keyPressEvent(QKeyEvent *event) override;
54
55signals:
61 void nodeMoved(const QString &nodeName, double newX, double newY,
62 int autoLengthedCount);
63
64private:
68 struct NodeHit {
69 SWMMModelLayer *layer = nullptr;
70 int nodeIdx = -1;
71 QString nodeName;
72 bool isGage = false;
73 bool valid() const { return layer && nodeIdx >= 0; }
74 };
75
80 NodeHit pickNode(const QPoint &pixel) const;
81
85 void applyDragPreview(double mapX, double mapY);
86
88 void cancelDragPreview();
89
90 bool m_dragging = false;
91 SWMMModelLayer *m_layer = nullptr;
92 int m_nodeIdx = -1;
93 QString m_nodeName;
94 bool m_isGage = false;
95
96 // Pre-drag map-CRS coord (for Escape / cancel rollback).
97 double m_originalMapX = 0.0;
98 double m_originalMapY = 0.0;
99};
100
101#endif // MAPTOOLMOVENODE_H
The central map display widget — QGIS-style hybrid rendering.
Definition mapcanvas.h:63
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
Drag a SWMM node or rain gage to a new location.
Definition maptoolmovenode.h:39
void mouseMoveEvent(QMouseEvent *event) override
Definition maptoolmovenode.cpp:148
void mousePressEvent(QMouseEvent *event) override
Definition maptoolmovenode.cpp:89
void deactivate() override
Called by the canvas when another tool replaces this one.
Definition maptoolmovenode.cpp:32
QCursor cursor() const override
Returns the mouse cursor to display while this tool is active.
Definition maptoolmovenode.cpp:21
void keyPressEvent(QKeyEvent *event) override
Definition maptoolmovenode.cpp:259
void nodeMoved(const QString &nodeName, double newX, double newY, int autoLengthedCount)
Emitted after a successful node move. Carries the node's name, new map-CRS coord, and the count of co...
void activate() override
Called by the canvas when this tool becomes the active tool.
Definition maptoolmovenode.cpp:26
void mouseReleaseEvent(QMouseEvent *event) override
Definition maptoolmovenode.cpp:157
Renders the SWMM network elements (nodes, links, subcatchments, rain gages) for one OpenSWMMEngine mo...
Definition swmmmodellayer.h:133
QString nodeName
Definition importplanning.cpp:95
Abstract base class for all interactive tools attached to a MapCanvas.
QVector< int > parent
union-find
Definition pslgminsize.cpp:176