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
maptoolfeaturedraw.h
Go to the documentation of this file.
1
34#ifndef MAPTOOLFEATUREDRAW_H
35#define MAPTOOLFEATUREDRAW_H
36
37#include "map/tools/maptool.h"
38#include "map/snapengine.h"
41
42#include <QPointF>
43#include <QPointer>
44#include <QVector>
45
46class FeatureLayer;
47
56{
57 Q_OBJECT
58
59public:
62 QObject *parent = nullptr);
63
66 void setTargetLayer(FeatureLayer *layer);
67 [[nodiscard]] FeatureLayer *targetLayer() const { return m_target.data(); }
68
69 [[nodiscard]] QCursor cursor() const override;
70
71 void activate() override;
72 void deactivate() override;
73
74 void mousePressEvent(QMouseEvent *event) override;
75 void mouseMoveEvent(QMouseEvent *event) override;
76 void mouseDoubleClickEvent(QMouseEvent *event) override;
77 void keyPressEvent(QKeyEvent *event) override;
78
79 void paint(QPainter *painter,
80 const MapExtent &canvasExtent,
81 const SpatialReferenceSystem *canvasSRS) override;
82
83signals:
85 void featureDrawn(qint64 featureId);
88 void drawRejected(const QString &reason);
89
90protected:
92 [[nodiscard]] virtual int minimumVertices() const = 0;
94 [[nodiscard]] virtual bool isClosed() const { return false; }
96 [[nodiscard]] virtual openswmmvis::feature::FeatureGeometry
98
99 void cancel();
100 void commit();
101
105 [[nodiscard]] QPointF canvasToLayer(const QPointF &canvasPt) const;
106
107 QPointer<FeatureLayer> m_target;
108 QVector<QPointF> m_vertices;
109 QPointF m_cursor;
110 bool m_drawing = false;
112};
113
116{
117 Q_OBJECT
118public:
119 explicit OpenSWMMVisMapToolDrawPoint(MapCanvas *canvas, QObject *parent = nullptr);
120 void mousePressEvent(QMouseEvent *event) override;
121
122protected:
123 [[nodiscard]] int minimumVertices() const override { return 1; }
125 buildGeometry(const openswmmvis::feature::Ring &ring) const override;
126};
127
130{
131 Q_OBJECT
132public:
133 explicit OpenSWMMVisMapToolDrawLine(MapCanvas *canvas, QObject *parent = nullptr);
134
135protected:
136 [[nodiscard]] int minimumVertices() const override { return 2; }
138 buildGeometry(const openswmmvis::feature::Ring &ring) const override;
139};
140
143{
144 Q_OBJECT
145public:
146 explicit OpenSWMMVisMapToolDrawPolygon(MapCanvas *canvas, QObject *parent = nullptr);
147
148protected:
149 [[nodiscard]] int minimumVertices() const override { return 3; }
150 [[nodiscard]] bool isClosed() const override { return true; }
152 buildGeometry(const openswmmvis::feature::Ring &ring) const override;
153};
154
155#endif // MAPTOOLFEATUREDRAW_H
An editable, GeoPackage-backed vector layer.
Definition featurelayer.h:127
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
Click to add vertices, double-click or Enter to finish a polyline.
Definition maptoolfeaturedraw.h:130
openswmmvis::feature::FeatureGeometry buildGeometry(const openswmmvis::feature::Ring &ring) const override
Definition maptoolfeaturedraw.cpp:333
int minimumVertices() const override
Definition maptoolfeaturedraw.h:136
Click once to place a point feature.
Definition maptoolfeaturedraw.h:116
void mousePressEvent(QMouseEvent *event) override
Definition maptoolfeaturedraw.cpp:302
int minimumVertices() const override
Definition maptoolfeaturedraw.h:123
openswmmvis::feature::FeatureGeometry buildGeometry(const openswmmvis::feature::Ring &ring) const override
Definition maptoolfeaturedraw.cpp:310
Click to add vertices, double-click or Enter to close a polygon.
Definition maptoolfeaturedraw.h:143
int minimumVertices() const override
Definition maptoolfeaturedraw.h:149
bool isClosed() const override
Definition maptoolfeaturedraw.h:150
openswmmvis::feature::FeatureGeometry buildGeometry(const openswmmvis::feature::Ring &ring) const override
Definition maptoolfeaturedraw.cpp:357
Shared vertex accumulation, rubber band, snapping and commit.
Definition maptoolfeaturedraw.h:56
QCursor cursor() const override
Returns the mouse cursor to display while this tool is active.
Definition maptoolfeaturedraw.cpp:64
QPointer< FeatureLayer > m_target
Definition maptoolfeaturedraw.h:107
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 maptoolfeaturedraw.cpp:191
void mouseDoubleClickEvent(QMouseEvent *event) override
Definition maptoolfeaturedraw.cpp:154
void drawRejected(const QString &reason)
Emitted when a commit is refused, with the reason from FeatureGeometry::validate. The Features dock s...
void mousePressEvent(QMouseEvent *event) override
Definition maptoolfeaturedraw.cpp:102
void commit()
Definition maptoolfeaturedraw.cpp:245
QPointF canvasToLayer(const QPointF &canvasPt) const
Definition maptoolfeaturedraw.cpp:81
FeatureLayer * targetLayer() const
Definition maptoolfeaturedraw.h:67
void mouseMoveEvent(QMouseEvent *event) override
Definition maptoolfeaturedraw.cpp:136
void cancel()
Definition maptoolfeaturedraw.cpp:236
void featureDrawn(qint64 featureId)
Emitted after a successful commit, with the new feature's id.
QPointF m_cursor
canvas CRS
Definition maptoolfeaturedraw.h:109
void activate() override
Called by the canvas when this tool becomes the active tool.
Definition maptoolfeaturedraw.cpp:69
void setTargetLayer(FeatureLayer *layer)
The layer being drawn into. Set by the Features dock; when it is null or not editable the tool ignore...
Definition maptoolfeaturedraw.cpp:57
virtual int minimumVertices() const =0
bool m_drawing
Definition maptoolfeaturedraw.h:110
void keyPressEvent(QKeyEvent *event) override
Definition maptoolfeaturedraw.cpp:183
SnapEngine::Result m_snap
Definition maptoolfeaturedraw.h:111
virtual openswmmvis::feature::FeatureGeometry buildGeometry(const openswmmvis::feature::Ring &ring) const =0
void deactivate() override
Called by the canvas when another tool replaces this one.
Definition maptoolfeaturedraw.cpp:75
QVector< QPointF > m_vertices
canvas CRS
Definition maptoolfeaturedraw.h:108
virtual bool isClosed() const
Definition maptoolfeaturedraw.h:94
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
QString toolName
Definition maptool.h:45
Represents a coordinate reference system backed by a GDAL OGRSpatialReference.
Definition spatialreferencesystem.h:28
A complete feature geometry: a type plus zero or more parts.
Definition featuregeometry.h:205
Abstract base class for all interactive tools attached to a MapCanvas.
QPolygonF ring
normalizeRingCCW(r.ring).
Definition meshgenerator.cpp:156
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
Shared vertex-snapping helper for all drawing map tools.
Definition snapengine.h:38
One ordered run of vertices, with optional per-vertex Z.
Definition featuregeometry.h:90