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
maptooladdlink.h
Go to the documentation of this file.
1
8#ifndef MAPTOOLADDLINK_H
9#define MAPTOOLADDLINK_H
10
11#include "map/tools/maptool.h"
12#include "map/snapengine.h"
13
14#include <QPointF>
15#include <QString>
16#include <QVector>
17
18class GISRasterLayer;
19class SWMMModelLayer;
20
37{
38 Q_OBJECT
39
40public:
49 const QString &elementKind, QObject *parent = nullptr);
50
51 [[nodiscard]] QCursor cursor() const override;
52
53 void activate() override;
54 void deactivate() override;
55
56 void mousePressEvent (QMouseEvent *event) override;
57 void mouseMoveEvent (QMouseEvent *event) override;
58 void mouseDoubleClickEvent(QMouseEvent *event) override;
59 void keyPressEvent (QKeyEvent *event) override;
60 void paint(QPainter *painter, const MapExtent &extent,
61 const SpatialReferenceSystem *srs) override;
62
69 void setTerrain(GISRasterLayer *layer, double offset, double factor = 1.0);
70
71signals:
72 void linkAdded(const QString &name, int linkType,
73 const QString &fromNode, const QString &toNode);
74
75private:
76 enum class State { Idle, Drawing };
77
78 [[nodiscard]] SWMMModelLayer *activeModelLayer() const;
79 [[nodiscard]] QString nextAvailableName(SWMMModelLayer *layer) const;
80
82 [[nodiscard]] QString snapToNode(SWMMModelLayer *layer,
83 double mapX, double mapY,
84 double *snapX, double *snapY) const;
85
86 void cancel();
87 void commit(SWMMModelLayer *layer, const QString &toNodeName,
88 double toX, double toY);
89
90 int m_linkType;
91 QString m_elementKind;
92
93 State m_state = State::Idle;
94 QString m_fromNode;
95 QPointF m_fromPt; // map coords of from-node
96 QVector<QPointF> m_vertices; // intermediate vertices (map coords)
97 QPointF m_cursor; // current mouse map coords (for rubber-band)
98 QString m_snapTarget; // name of end-node currently snapped to (node-only)
99 QPointF m_snapPt; // map coords of node snap target
100 SnapEngine::Result m_vertexSnap; // general vertex snap for intermediate points
101
102 GISRasterLayer *m_terrainLayer = nullptr;
103 double m_terrainOffset = 0.0;
104 double m_terrainFactor = 1.0;
105};
106
107#endif // MAPTOOLADDLINK_H
A map layer backed by a GDAL raster dataset.
Definition gisrasterlayer.h:61
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
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
@ Idle
Row exists for an open model; no run yet.
Shared vertex-snapping helper for all drawing map tools.
Definition snapengine.h:38