QGIS API Documentation  2.99.0-Master (314842d)
qgsvectorlayereditutils.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayereditutils.h
3  ---------------------
4  begin : Dezember 2012
5  copyright : (C) 2012 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSVECTORLAYEREDITUTILS_H
16 #define QGSVECTORLAYEREDITUTILS_H
17 
18 
19 #include "qgis_core.h"
20 #include "qgsfeature.h"
21 
22 #include "qgsvectorlayer.h"
23 #include "qgsgeometry.h"
24 
25 class QgsGeometryCache;
26 class QgsCurve;
27 
31 class CORE_EXPORT QgsVectorLayerEditUtils
32 {
33  public:
35 
36  inline QgsGeometryCache *cache() { return L->cache(); }
37 
38 
43  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
44 
49  bool insertVertex( const QgsPointV2 &point, QgsFeatureId atFeatureId, int beforeVertex );
50 
55  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
56 
62  bool moveVertex( const QgsPointV2 &p, QgsFeatureId atFeatureId, int atVertex );
63 
69  QgsVectorLayer::EditResult deleteVertex( QgsFeatureId featureId, int vertex );
70 
84  // TODO QGIS 3.0 returns an enum instead of a magic constant
85  int addRing( const QList<QgsPoint> &ring, const QgsFeatureIds &targetFeatureIds = QgsFeatureIds(), QgsFeatureId *modifiedFeatureId = nullptr );
86 
101  // TODO QGIS 3.0 returns an enum instead of a magic constant
102  int addRing( QgsCurve *ring, const QgsFeatureIds &targetFeatureIds = QgsFeatureIds(), QgsFeatureId *modifiedFeatureId = nullptr );
103 
114  // TODO QGIS 3.0 returns an enum instead of a magic constant
115  int addPart( const QList<QgsPoint> &ring, QgsFeatureId featureId );
116 
128  // TODO QGIS 3.0 returns an enum instead of a magic constant
129  int addPart( const QgsPointSequence &ring, QgsFeatureId featureId );
130 
131  // @note available in python bindings as addCurvedPart
132  // TODO QGIS 3.0 returns an enum instead of a magic constant
133  int addPart( QgsCurve *ring, QgsFeatureId featureId );
134 
141  int translateFeature( QgsFeatureId featureId, double dx, double dy );
142 
150  // TODO QGIS 3.0 returns an enum instead of a magic constant
151  int splitParts( const QList<QgsPoint> &splitLine, bool topologicalEditing = false );
152 
160  // TODO QGIS 3.0 returns an enum instead of a magic constant
161  int splitFeatures( const QList<QgsPoint> &splitLine, bool topologicalEditing = false );
162 
168  int addTopologicalPoints( const QgsGeometry &geom );
169 
177  int addTopologicalPoints( const QgsPoint &p );
178 
184  int insertSegmentVerticesForSnap( const QList<QgsSnappingResult> &snapResults );
185 
186  protected:
187 
190  int boundingBoxFromPointList( const QList<QgsPoint> &list, double &xmin, double &ymin, double &xmax, double &ymax ) const;
191 
192  QgsVectorLayer *L = nullptr;
193 };
194 
195 #endif // QGSVECTORLAYEREDITUTILS_H
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:358
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:79
Point geometry type, with support for z-dimension and m-values.
Definition: qgspointv2.h:36
Abstract base class for curved geometry type.
Definition: qgscurve.h:33
A class to represent a point.
Definition: qgspoint.h:37
qint64 QgsFeatureId
Definition: qgsfeature.h:33
QList< QgsPointV2 > QgsPointSequence
Represents a vector layer which manages a vector based data sets.
EditResult
Result of an edit operation.