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;
164 isMatchPointZ =
true;
169 savePoint = fetchPoint;
171 savePoint =
QgsPoint( fetchPoint.
x(), fetchPoint.
y() );
179 savePoint =
QgsPoint( layerPoint.
x(), layerPoint.
y() );
185 emit
messageEmitted( tr(
"Cannot transform the point to the layers coordinate system" ), Qgis::MessageLevel::Warning );
199 g =
QgsGeometry( std::make_unique<QgsPoint>( savePoint ) );
218 g =
QgsGeometry( std::make_unique<QgsPoint>( savePoint ) );
247 emit
messageEmitted( tr(
"Wrong editing tool, cannot apply the 'capture line' tool on this vector layer" ), Qgis::MessageLevel::Warning );
254 emit
messageEmitted( tr(
"Wrong editing tool, cannot apply the 'capture polygon' tool on this vector layer" ), Qgis::MessageLevel::Warning );
259 if ( e->button() == Qt::LeftButton )
267 else if ( error == 2 )
270 emit
messageEmitted( tr(
"Cannot transform the point to the layers coordinate system" ), Qgis::MessageLevel::Warning );
276 else if ( e->button() == Qt::RightButton )
308 QList<QgsPointLocator::Match> snappingMatchesList;
310 if ( hasCurvedSegments && providerSupportsCurvedSegments )
328 if ( hasCurvedSegments && providerSupportsCurvedSegments )
340 QList<QgsVectorLayer *> avoidIntersectionsLayers;
344 avoidIntersectionsLayers.append( vlayer );
352 if ( avoidIntersectionsLayers.size() > 0 )
355 int avoidIntersectionsReturn = featGeom.
avoidIntersections( avoidIntersectionsLayers );
356 f->setGeometry( featGeom );
357 if ( avoidIntersectionsReturn == 3 )
359 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 );
361 if ( f->geometry().isEmpty() )
363 emit
messageEmitted( tr(
"The feature cannot be added because its geometry collapsed due to intersection avoidance" ), Qgis::MessageLevel::Critical );
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
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.
static QgsGeometry fromMultiPointXY(const QgsMultiPointXY &multipoint)
Creates a new geometry from a QgsMultiPointXY object.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
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 bool hasZ(Type type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.