39 , mCheckGeometryType( true )
64 void QgsMapToolDigitizeFeature::digitized(
const QgsFeature &f )
105 return mCheckGeometryType;
115 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mLayer );
133 emit
messageEmitted( tr(
"The data provider for this layer does not support the addition of features." ), Qgis::MessageLevel::Warning );
146 if ( e->button() != Qt::LeftButton )
152 emit
messageEmitted( tr(
"Wrong editing tool, cannot apply the 'capture point' tool on this vector layer" ), Qgis::MessageLevel::Warning );
157 bool isMatchPointZ =
false;
158 bool isMatchPointM =
false;
180 emit
messageEmitted( tr(
"Cannot transform the point to the layers coordinate system" ), Qgis::MessageLevel::Warning );
193 if ( mCheckGeometryType ==
false )
196 g =
QgsGeometry( std::make_unique<QgsPoint>( savePoint ) );
202 g =
QgsGeometry( std::make_unique<QgsPoint>( result ) );
233 emit
messageEmitted( tr(
"Wrong editing tool, cannot apply the 'capture line' tool on this vector layer" ), Qgis::MessageLevel::Warning );
240 emit
messageEmitted( tr(
"Wrong editing tool, cannot apply the 'capture polygon' tool on this vector layer" ), Qgis::MessageLevel::Warning );
245 if ( e->button() == Qt::LeftButton )
251 emit
messageEmitted( tr(
"Cannot transform the point to the layers coordinate system" ), Qgis::MessageLevel::Warning );
257 else if ( e->button() == Qt::RightButton )
289 QList<QgsPointLocator::Match> snappingMatchesList;
291 if ( hasCurvedSegments && providerSupportsCurvedSegments )
309 if ( hasCurvedSegments && providerSupportsCurvedSegments )
321 QList<QgsVectorLayer *> avoidIntersectionsLayers;
325 avoidIntersectionsLayers.append( vlayer );
333 if ( avoidIntersectionsLayers.size() > 0 )
336 const int avoidIntersectionsReturn = featGeom.
avoidIntersections( avoidIntersectionsLayers );
337 f->setGeometry( featGeom );
338 if ( avoidIntersectionsReturn == 3 )
340 emit
messageEmitted( tr(
"The feature has been added, but at least one geometry intersected is invalid. These geometries must be manually repaired." ), Qgis::MessageLevel::Warning );
342 if ( f->geometry().isEmpty() )
344 emit
messageEmitted( tr(
"The feature cannot be added because its geometry collapsed due to intersection avoidance" ), Qgis::MessageLevel::Critical );
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
QgsLineString * curveToLine(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a new line string geometry corresponding to a segmentized approximation of the curve.
QgsCompoundCurve * clone() const override
Clones the geometry by performing a deep copy.
bool hasCurvedSegments() const override
Returns true if the geometry contains curved segments.
Custom exception class for Coordinate Reference System related exceptions.
Curve polygon geometry type.
virtual void setExteriorRing(QgsCurve *ring)
Sets the exterior ring of the polygon.
Abstract base class for curved geometry type.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setValid(bool validity)
Sets the validity of the feature.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A geometry is the spatial representation of a feature.
void set(QgsAbstractGeometry *geometry)
Sets the underlying geometry store.
int avoidIntersections(const QList< QgsVectorLayer * > &avoidIntersectionsLayers, const QHash< QgsVectorLayer *, QSet< QgsFeatureId > > &ignoreFeatures=(QHash< QgsVectorLayer *, QSet< QgsFeatureId > >()))
Modifies geometry to avoid intersections with the layers specified in project properties.
Map canvas is a class for displaying all GIS data types on a canvas.
void setCurrentLayer(QgsMapLayer *layer)
QgsMapLayer * currentLayer()
returns current layer (set by legend widget)
Base class for all map layer types.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
QgsPointXY mapPoint() const
mapPoint returns the point in coordinates
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
Multi point geometry collection.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
A class to represent a 2D point.
Point geometry type, with support for z-dimension and m-values.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void cleared()
Emitted when the project is cleared (and additionally when an open project is cleared just before a n...
QList< QgsVectorLayer * > avoidIntersectionsLayers
@ AvoidIntersectionsLayers
Overlap with features from a specified list of layers when digitizing new features not allowed.
@ AllowIntersections
Overlap with any feature allowed when digitizing new features.
@ AvoidIntersectionsCurrentLayer
Overlap with features from the active layer when digitizing new features not allowed.
void readProject(const QDomDocument &)
Emitted when a project is being read.
This is the base class for vector data providers.
@ CircularGeometries
Supports circular geometry types (circularstring, compoundcurve, curvepolygon)
@ AddFeatures
Allows adding features.
virtual Q_INVOKABLE QgsVectorDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
static bool isMultiType(Type type) SIP_HOLDGIL
Returns true if the WKB type is a multi type.
static bool hasM(Type type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
Type
The WKB type describes the number of dimensions a geometry has.
static Type singleType(Type type) SIP_HOLDGIL
Returns the single type for a WKB type.
static bool hasZ(Type type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.