QGIS API Documentation
2.0.1-Dufour
|
#include <qgsvectorlayereditutils.h>
Public Member Functions | |
QgsVectorLayerEditUtils (QgsVectorLayer *layer) | |
QgsGeometryCache * | cache () |
bool | insertVertex (double x, double y, QgsFeatureId atFeatureId, int beforeVertex) |
Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries. | |
bool | moveVertex (double x, double y, QgsFeatureId atFeatureId, int atVertex) |
Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates. | |
bool | deleteVertex (QgsFeatureId atFeatureId, int atVertex) |
Deletes a vertex from a feature. | |
int | addRing (const QList< QgsPoint > &ring) |
Adds a ring to polygon/multipolygon features. | |
int | addPart (const QList< QgsPoint > &ring, QgsFeatureId featureId) |
Adds a new part polygon to a multipart feature. | |
int | translateFeature (QgsFeatureId featureId, double dx, double dy) |
Translates feature by dx, dy. | |
int | splitFeatures (const QList< QgsPoint > &splitLine, bool topologicalEditing=false) |
Splits features cut by the given line. | |
int | addTopologicalPoints (QgsGeometry *geom) |
Adds topological points for every vertex of the geometry. | |
int | addTopologicalPoints (const QgsPoint &p) |
Adds a vertex to segments which intersect point p but don't already have a vertex there. | |
int | insertSegmentVerticesForSnap (const QList< QgsSnappingResult > &snapResults) |
Inserts vertices to the snapped segments. |
Protected Member Functions | |
int | boundingBoxFromPointList (const QList< QgsPoint > &list, double &xmin, double &ymin, double &xmax, double &ymax) const |
Little helper function that gives bounding box from a list of points. |
Protected Attributes | |
QgsVectorLayer * | L |
Definition at line 25 of file qgsvectorlayereditutils.h.
QgsVectorLayerEditUtils::QgsVectorLayerEditUtils | ( | QgsVectorLayer * | layer | ) |
Definition at line 24 of file qgsvectorlayereditutils.cpp.
int QgsVectorLayerEditUtils::addPart | ( | const QList< QgsPoint > & | ring, |
QgsFeatureId | featureId | ||
) |
Adds a new part polygon to a multipart feature.
Definition at line 116 of file qgsvectorlayereditutils.cpp.
References QgsGeometry::addPart(), cache(), QgsVectorLayerEditBuffer::changeGeometry(), QgsVectorLayer::editBuffer(), QgsGeometryCache::geometry(), QgsFeature::geometry(), QgsVectorLayer::getFeatures(), QgsVectorLayer::hasGeometryType(), L, and QgsFeatureIterator::nextFeature().
Referenced by QgsVectorLayer::addPart().
int QgsVectorLayerEditUtils::addRing | ( | const QList< QgsPoint > & | ring | ) |
Adds a ring to polygon/multipolygon features.
Definition at line 78 of file qgsvectorlayereditutils.cpp.
References QgsGeometry::addRing(), boundingBoxFromPointList(), QgsVectorLayerEditBuffer::changeGeometry(), QgsVectorLayer::editBuffer(), QgsFeatureRequest::ExactIntersect, QgsFeature::geometry(), QgsVectorLayer::getFeatures(), QgsVectorLayer::hasGeometryType(), QgsFeature::id(), L, QgsFeatureIterator::nextFeature(), QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), and QgsRectangle::setYMinimum().
Referenced by QgsVectorLayer::addRing().
int QgsVectorLayerEditUtils::addTopologicalPoints | ( | QgsGeometry * | geom | ) |
Adds topological points for every vertex of the geometry.
geom | the geometry where each vertex is added to segments of other features |
Definition at line 300 of file qgsvectorlayereditutils.cpp.
References QgsGeometry::asMultiPolygon(), QgsGeometry::asMultiPolyline(), QgsGeometry::asPolygon(), QgsGeometry::asPolyline(), QgsVectorLayer::hasGeometryType(), L, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and QgsGeometry::wkbType().
Referenced by QgsVectorLayer::addTopologicalPoints(), and splitFeatures().
int QgsVectorLayerEditUtils::addTopologicalPoints | ( | const QgsPoint & | p | ) |
Adds a vertex to segments which intersect point p but don't already have a vertex there.
If a feature already has a vertex at position p, no additional vertex is inserted. This method is useful for topological editing.
p | position of the vertex |
Definition at line 408 of file qgsvectorlayereditutils.cpp.
References QgsMapLayer::crs(), QGis::Feet, QgsVectorLayer::hasGeometryType(), insertSegmentVerticesForSnap(), L, QgsCoordinateReferenceSystem::mapUnits(), QGis::Meters, QgsSnapper::SnapToSegment, QgsSnapper::SnapToVertex, and QgsVectorLayer::snapWithContext().
|
protected |
Little helper function that gives bounding box from a list of points.
Definition at line 492 of file qgsvectorlayereditutils.cpp.
References MathUtils::max().
Referenced by addRing(), and splitFeatures().
|
inline |
Definition at line 30 of file qgsvectorlayereditutils.h.
Referenced by addPart(), deleteVertex(), insertVertex(), moveVertex(), and translateFeature().
bool QgsVectorLayerEditUtils::deleteVertex | ( | QgsFeatureId | atFeatureId, |
int | atVertex | ||
) |
Deletes a vertex from a feature.
Definition at line 61 of file qgsvectorlayereditutils.cpp.
References cache(), QgsVectorLayerEditBuffer::changeGeometry(), QgsGeometry::deleteVertex(), QgsVectorLayer::editBuffer(), QgsGeometryCache::geometry(), QgsVectorLayer::hasGeometryType(), and L.
Referenced by QgsVectorLayer::deleteVertex().
int QgsVectorLayerEditUtils::insertSegmentVerticesForSnap | ( | const QList< QgsSnappingResult > & | snapResults | ) |
Inserts vertices to the snapped segments.
This is useful for topological editing if snap to segment is enabled.
snapResults | results collected from the snapping operation |
Definition at line 466 of file qgsvectorlayereditutils.cpp.
References QgsVectorLayer::hasGeometryType(), insertVertex(), L, QgsPoint::x(), and QgsPoint::y().
Referenced by addTopologicalPoints(), and QgsVectorLayer::insertSegmentVerticesForSnap().
bool QgsVectorLayerEditUtils::insertVertex | ( | double | x, |
double | y, | ||
QgsFeatureId | atFeatureId, | ||
int | beforeVertex | ||
) |
Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries.
Definition at line 29 of file qgsvectorlayereditutils.cpp.
References cache(), QgsVectorLayerEditBuffer::changeGeometry(), QgsVectorLayer::editBuffer(), QgsGeometryCache::geometry(), QgsVectorLayer::hasGeometryType(), QgsGeometry::insertVertex(), and L.
Referenced by insertSegmentVerticesForSnap(), and QgsVectorLayer::insertVertex().
bool QgsVectorLayerEditUtils::moveVertex | ( | double | x, |
double | y, | ||
QgsFeatureId | atFeatureId, | ||
int | atVertex | ||
) |
Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates.
Definition at line 45 of file qgsvectorlayereditutils.cpp.
References cache(), QgsVectorLayerEditBuffer::changeGeometry(), QgsVectorLayer::editBuffer(), QgsGeometryCache::geometry(), QgsVectorLayer::hasGeometryType(), L, and QgsGeometry::moveVertex().
Referenced by QgsVectorLayer::moveVertex().
int QgsVectorLayerEditUtils::splitFeatures | ( | const QList< QgsPoint > & | splitLine, |
bool | topologicalEditing = false |
||
) |
Splits features cut by the given line.
splitLine | line that splits the layer features |
topologicalEditing | true if topological editing is enabled |
Definition at line 167 of file qgsvectorlayereditutils.cpp.
References QgsVectorLayerEditBuffer::addFeatures(), addTopologicalPoints(), boundingBoxFromPointList(), QgsVectorLayerEditBuffer::changeGeometry(), QgsVectorLayer::dataProvider(), QgsVectorDataProvider::defaultValue(), QgsVectorLayer::editBuffer(), QgsFeatureRequest::ExactIntersect, QgsVectorLayer::getFeatures(), QgsVectorLayer::hasGeometryType(), QgsRectangle::height(), QgsRectangle::isEmpty(), L, QgsFeatureIterator::nextFeature(), QgsVectorDataProvider::pkAttributeIndexes(), QgsVectorLayer::selectedFeatures(), QgsVectorLayer::selectedFeaturesIds(), QgsFeature::setAttributes(), QgsFeature::setGeometry(), QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), QgsRectangle::setYMinimum(), QgsGeometry::splitGeometry(), QgsRectangle::width(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
Referenced by QgsVectorLayer::splitFeatures().
int QgsVectorLayerEditUtils::translateFeature | ( | QgsFeatureId | featureId, |
double | dx, | ||
double | dy | ||
) |
Translates feature by dx, dy.
featureId | id of the feature to translate |
dx | translation of x-coordinate |
dy | translation of y-coordinate |
Definition at line 142 of file qgsvectorlayereditutils.cpp.
References cache(), QgsVectorLayerEditBuffer::changeGeometry(), QgsVectorLayer::editBuffer(), QgsGeometryCache::geometry(), QgsFeature::geometry(), QgsVectorLayer::getFeatures(), QgsVectorLayer::hasGeometryType(), L, QgsFeatureIterator::nextFeature(), and QgsGeometry::translate().
Referenced by QgsVectorLayer::translateFeature().
|
protected |
Definition at line 115 of file qgsvectorlayereditutils.h.
Referenced by addPart(), addRing(), addTopologicalPoints(), deleteVertex(), insertSegmentVerticesForSnap(), insertVertex(), moveVertex(), splitFeatures(), and translateFeature().