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
featurecommands.h
Go to the documentation of this file.
1
29#ifndef FEATURECOMMANDS_H
30#define FEATURECOMMANDS_H
31
32#include "map/mapundostack.h"
35#include "layers/featurelayer.h"
36
37#include <QPointer>
38#include <QString>
39#include <QVariantMap>
40#include <QVector>
41
42class MapCanvas;
43
45
49{
50 FeatureEditGeometryId = 0x4645'0001, // 'FE' 0001
51};
52
58{
59public:
61 MapCanvas *canvas, QUndoCommand *parent = nullptr);
62
63 [[nodiscard]] FeatureLayer *layer() const { return m_layer.data(); }
66 [[nodiscard]] QString lastError() const { return m_lastError; }
67
68protected:
72 void recordFailure(const QString &err) const;
73
74 QPointer<FeatureLayer> m_layer;
75 mutable QString m_lastError;
76};
77
86{
87public:
89 const openswmmvis::feature::Feature &feature,
90 MapCanvas *canvas, QUndoCommand *parent = nullptr);
91
92 void redo() override;
93 void undo() override;
94
96 [[nodiscard]] openswmmvis::feature::FeatureId featureId() const { return m_feature.id; }
97
98private:
100};
101
107{
108public:
110 const QVector<openswmmvis::feature::FeatureId> &ids,
111 MapCanvas *canvas, QUndoCommand *parent = nullptr);
112
113 void redo() override;
114 void undo() override;
115
116private:
119 QVector<openswmmvis::feature::Feature> m_removed;
120};
121
133{
134public:
139 const QString &text,
140 bool mergeable,
141 MapCanvas *canvas, QUndoCommand *parent = nullptr);
142
143 void redo() override;
144 void undo() override;
145
146 [[nodiscard]] int id() const override
147 { return m_mergeable ? FeatureEditGeometryId : -1; }
148 bool mergeWith(const QUndoCommand *other) override;
149
150private:
154 bool m_mergeable;
155};
156
165{
166public:
169 const QVariantMap &oldAttrs,
170 const QVariantMap &newAttrs,
171 MapCanvas *canvas, QUndoCommand *parent = nullptr);
172
173 void redo() override;
174 void undo() override;
175
176private:
178 QVariantMap m_old;
179 QVariantMap m_new;
180};
181
192{
193public:
196 MapCanvas *canvas, QUndoCommand *parent = nullptr);
197
198 void redo() override;
199 void undo() override;
200
201private:
203};
204
210{
211public:
212 RemoveFieldCommand(FeatureLayer *layer, const QString &fieldName,
213 MapCanvas *canvas, QUndoCommand *parent = nullptr);
214
215 void redo() override;
216 void undo() override;
217
218private:
222 QHash<openswmmvis::feature::FeatureId, QVariant> m_values;
223};
224
233{
234public:
237 const QVector<openswmmvis::feature::FeatureId> &ids,
238 MapCanvas *canvas, QUndoCommand *parent = nullptr);
239
240 void redo() override;
241 void undo() override;
242
245 [[nodiscard]] int unsampledCount() const { return m_unsampled; }
246
247private:
248 QVector<openswmmvis::feature::FeatureId> m_ids;
249 QVector<openswmmvis::feature::FeatureGeometry> m_before;
250 QVector<openswmmvis::feature::FeatureGeometry> m_after;
251 bool m_captured = false;
252 int m_unsampled = 0;
253};
254
255} // namespace openswmmvis::map
256
257#endif // FEATURECOMMANDS_H
An editable, GeoPackage-backed vector layer.
Definition featurelayer.h:127
The central map display widget — QGIS-style hybrid rendering.
Definition mapcanvas.h:63
Abstract base for all undoable commands that affect the MapCanvas.
Definition mapundostack.h:172
MapCanvas * canvas() const
Definition mapundostack.cpp:85
A complete feature geometry: a type plus zero or more parts.
Definition featuregeometry.h:205
Insert one feature; undo removes it.
Definition featurecommands.h:86
openswmmvis::feature::FeatureId featureId() const
The stored id; valid only after the first redo.
Definition featurecommands.h:96
void undo() override
Definition featurecommands.cpp:84
void redo() override
Definition featurecommands.cpp:68
Add a schema column; undo drops it.
Definition featurecommands.h:192
void redo() override
Definition featurecommands.cpp:245
void undo() override
Definition featurecommands.cpp:255
Remove one or more features; undo restores them with their ids.
Definition featurecommands.h:107
void undo() override
Definition featurecommands.cpp:130
void redo() override
Definition featurecommands.cpp:117
Replace one feature's attributes.
Definition featurecommands.h:165
void redo() override
Definition featurecommands.cpp:211
void undo() override
Definition featurecommands.cpp:222
Replace one feature's geometry.
Definition featurecommands.h:133
void undo() override
Definition featurecommands.cpp:172
bool mergeWith(const QUndoCommand *other) override
Definition featurecommands.cpp:183
int id() const override
Definition featurecommands.h:146
void redo() override
Definition featurecommands.cpp:161
Shared plumbing: a QPointer to the layer plus error reporting.
Definition featurecommands.h:58
FeatureLayer * layer() const
Definition featurecommands.h:63
QString lastError() const
The message from the last failed apply, for the caller to show. Empty when the command has not failed...
Definition featurecommands.h:66
QString m_lastError
Definition featurecommands.h:75
void recordFailure(const QString &err) const
Definition featurecommands.cpp:51
QPointer< FeatureLayer > m_layer
Definition featurecommands.h:74
Drop a schema column, snapshotting its values so undo restores them.
Definition featurecommands.h:210
void undo() override
Definition featurecommands.cpp:301
void redo() override
Definition featurecommands.cpp:291
Re-sample Z for every feature (or a subset) as ONE undo step.
Definition featurecommands.h:233
void undo() override
Definition featurecommands.cpp:370
int unsampledCount() const
Vertices left NaN by the last redo — the count the Features dock reports so an unsampled breakline is...
Definition featurecommands.h:245
void redo() override
Definition featurecommands.cpp:342
QString err
Definition inpmeshwriter.cpp:575
qint64 FeatureId
Definition featuretypes.h:33
Definition featurecommands.h:44
FeatureCommandId
Definition featurecommands.h:49
@ FeatureEditGeometryId
Definition featurecommands.h:50
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
QString text
Definition queryparser.cpp:35
One editable feature: identity, geometry, attributes.
Definition featuretypes.h:150
FeatureId id
Definition featuretypes.h:151
One user-defined attribute column.
Definition featuretypes.h:67