48#include "moc_qgsmaptoolcapture.cpp"
52 , mCaptureMode(
mode )
55 mTempRubberBand.setParentOwner(
canvas );
57 mSnapIndicator = std::make_unique<QgsSnapIndicator>(
canvas );
66 mExtraSnapLayer =
new QgsVectorLayer( QStringLiteral(
"LineString?crs=" ), QStringLiteral(
"extra snap" ), QStringLiteral(
"memory" ), layerOptions );
67 mExtraSnapLayer->startEditing();
69 mExtraSnapLayer->addFeature( f );
70 mExtraSnapFeatureId = f.
id();
74 currentLayerChanged(
canvas->currentLayer() );
85 mCanvas->snappingUtils()->removeExtraSnapLayer( mExtraSnapLayer );
87 mExtraSnapLayer->deleteLater();
88 mExtraSnapLayer =
nullptr;
94 mValidator->deleteLater();
120 if ( mTempRubberBand )
121 mTempRubberBand->show();
123 mCanvas->snappingUtils()->addExtraSnapLayer( mExtraSnapLayer );
127 mCurrentShapeMapTool->activate( mCaptureMode, mCaptureLastPoint );
132 if ( mTempRubberBand )
133 mTempRubberBand->hide();
137 mCanvas->snappingUtils()->removeExtraSnapLayer( mExtraSnapLayer );
140 mCurrentShapeMapTool->deactivate();
145void QgsMapToolCapture::currentLayerChanged(
QgsMapLayer *layer )
147 if ( !mCaptureModeFromLayer )
183 if ( mTempRubberBand )
191bool QgsMapToolCapture::tracingEnabled()
199QgsPointXY QgsMapToolCapture::tracingStartPoint()
203 if ( mTracingStartPoint != QgsPointXY() )
204 return mTracingStartPoint;
206 return mCaptureLastPoint;
215 QgsPointXY pt0 = tracingStartPoint();
216 if ( pt0 == QgsPointXY() )
232 mTempRubberBand->addPoint( mCaptureLastPoint );
238 const QgsPoint lastPoint = mCaptureLastPoint;
239 QgsPointXY lastPointXY( lastPoint );
240 if ( lastPointXY == pt0 &&
points[0] != lastPointXY )
242 if ( mRubberBand->numberOfVertices() != 0 )
246 if ( mRubberBand->numberOfVertices() > 2 || ( mRubberBand->numberOfVertices() == 2 && *mRubberBand->getPoint( 0, 0 ) != *mRubberBand->getPoint( 0, 1 ) ) )
247 mRubberBand->movePoint(
points[0] );
250 mTempRubberBand->movePoint( 0, QgsPoint(
points[0] ) );
253 mTempRubberBand->movePoint( QgsPoint(
points[0] ) );
256 for (
int i = 1; i <
points.count(); ++i )
257 mTempRubberBand->addPoint( QgsPoint(
points.at( i ) ), i ==
points.count() - 1 );
260 mTempRubberBand->addPoint( QgsPoint(
points[
points.size() - 1] ) );
267bool QgsMapToolCapture::tracingAddVertex(
const QgsPointXY &point )
273 if ( mTempRubberBand->pointsCount() == 0 )
275 if ( !tracer->
init() )
285 mTracingStartPoint = point;
290 QgsPointXY pt0 = tracingStartPoint();
291 if ( pt0 == QgsPointXY() )
295 const QVector<QgsPointXY> tracedPointsInMapCrs = tracer->
findShortestPath( pt0, point, &err );
296 if ( tracedPointsInMapCrs.isEmpty() )
301 layerPoints.reserve( tracedPointsInMapCrs.size() );
303 mapPoints.reserve( tracedPointsInMapCrs.size() );
304 for (
const QgsPointXY &tracedPointMapCrs : tracedPointsInMapCrs )
306 QgsPoint
mapPoint( tracedPointMapCrs );
324 const QgsVertexId lastVertexId( 0, 0, mCaptureCurve.numPoints() - 1 );
325 mCaptureCurve.moveVertex( lastVertexId, layerPoints.first() );
326 mSnappingMatches.removeLast();
327 mSnappingMatches.append( QgsPointLocator::Match() );
329 addCurve(
new QgsLineString( mapPoints ) );
336#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
337 int pointBefore = mCaptureCurve.numPoints();
341 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>(
layer() );
344 const QgsGeometry linear = QgsGeometry( mCaptureCurve.segmentize() );
351 mCaptureCurve.clear();
360#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
362 const int pointAfter = mCaptureCurve.numPoints();
364 for ( ; pointBefore < pointAfter; ++pointBefore )
365 mSnappingMatches.append( QgsPointLocator::Match() );
367 for ( ; pointBefore > pointAfter; --pointBefore )
368 mSnappingMatches.removeLast();
370 mSnappingMatches.resize( mCaptureCurve.numPoints() );
377 const QgsPoint lastPt = mCaptureCurve.endPoint();
383QgsMapToolCaptureRubberBand *QgsMapToolCapture::createCurveRubberBand()
const
385 QgsMapToolCaptureRubberBand *rb =
new QgsMapToolCaptureRubberBand(
mCanvas );
390 color.setAlphaF( color.alphaF() * alphaScale );
391 rb->setLineStyle( Qt::DotLine );
392 rb->setStrokeColor( color );
395 rb->setFillColor( fillColor );
400void QgsMapToolCapture::resetRubberBand()
404 QgsLineString *lineString = mCaptureCurve.curveToLine();
407 mRubberBand->addGeometry( QgsGeometry( lineString ),
layer() );
412 return mRubberBand.release();
433 if ( mCurrentCaptureTechnique == technique )
436 mStartNewCurve =
true;
440 mCurrentShapeMapTool->deactivate();
461 if ( mTempRubberBand )
462 mTempRubberBand->setStringType( mLineDigitizingType );
464 mCurrentCaptureTechnique = technique;
469 mCurrentShapeMapTool->activate( mCaptureMode, mCaptureLastPoint );
475 if ( mCurrentShapeMapTool )
477 if ( shapeMapToolMetadata && mCurrentShapeMapTool->
id() == shapeMapToolMetadata->
id() )
480 mCurrentShapeMapTool->deactivate();
481 mCurrentShapeMapTool->deleteLater();
484 mCurrentShapeMapTool.reset( shapeMapToolMetadata ? shapeMapToolMetadata->
factory(
this ) :
nullptr );
489 if ( mCurrentShapeMapTool )
490 mCurrentShapeMapTool->activate( mCaptureMode, mCaptureLastPoint );
497 if ( mCaptureModeFromLayer && ( !
canvas()->currentLayer() || !
canvas()->currentLayer()->isSpatial() ) )
508 if ( !mCurrentShapeMapTool )
514 if ( !mTempRubberBand )
516 mTempRubberBand.reset( createCurveRubberBand() );
517 mTempRubberBand->setStringType( mLineDigitizingType );
521 mCurrentShapeMapTool->cadCanvasMoveEvent( e, mCaptureMode );
529 if ( mCaptureMode !=
CapturePoint && mTempRubberBand && mCapturing )
531 bool hasTrace =
false;
535 if ( !mCaptureCurve.isEmpty() )
537 const QgsPoint prevPoint = mCaptureCurve.curveAt( mCaptureCurve.nCurves() - 1 )->endPoint();
542 mAllowAddingStreamingPoints =
true;
544 mAllowAddingStreamingPoints =
false;
546 else if ( tracingEnabled() && mCaptureCurve.numPoints() != 0 )
552 mCircularItermediatePoint = mTempRubberBand->pointFromEnd( 1 );
554 mCircularItermediatePoint =
QgsPoint();
556 hasTrace = tracingMouseMove( e );
562 mTempRubberBand->addPoint( mCaptureLastPoint );
563 if ( !mCircularItermediatePoint.isEmpty() )
565 mTempRubberBand->movePoint( mCircularItermediatePoint );
566 mTempRubberBand->addPoint( mCircularItermediatePoint );
573 if ( mCaptureCurve.numPoints() > 0 )
575 const QgsPoint mapPt = mCaptureLastPoint;
577 if ( mTempRubberBand )
579 mTempRubberBand->movePoint(
mapPoint );
580 mTempRubberBand->movePoint( 0, mapPt );
584 if ( mRubberBand->numberOfVertices() )
585 mRubberBand->movePoint( mapPt );
587 else if ( mTempRubberBand )
588 mTempRubberBand->movePoint(
mapPoint );
602 const bool is3D = layerPoint.
is3D();
603 const bool isMeasure = layerPoint.
isMeasure();
605 layerPoint =
QgsPoint( layerPoint.
wkbType(), mapP.
x(), mapP.
y(), layerPoint.
z(), layerPoint.
m() );
613 QgsDebugError( QStringLiteral(
"transformation to layer coordinate failed" ) );
645 if ( match.
isValid() && sourceLayer )
649 if ( sourceLayer->
crs() != vlayer->
crs() )
732 mCaptureCurve.addVertex( layerPoint );
733 mSnappingMatches.append( match );
737 if ( mCaptureFirstPoint.isEmpty() )
745 if ( !mTempRubberBand )
747 mTempRubberBand.reset( createCurveRubberBand() );
748 mTempRubberBand->setStringType( mLineDigitizingType );
752 bool traceCreated =
false;
753 if ( tracingEnabled() )
755 traceCreated = tracingAddVertex(
mapPoint );
760 mTracingStartPoint = traceCreated ? point :
QgsPointXY();
765 mTempRubberBand->movePoint(
mapPoint );
766 if ( mTempRubberBand->curveIsComplete() )
768 if (
QgsCurve *curve = mTempRubberBand->curve() )
773 if ( match.
isValid() && mSnappingMatches.count() > 0 && !mSnappingMatches.last().isValid() )
775 mSnappingMatches.removeLast();
779 mSnappingMatches.removeLast();
780 mSnappingMatches.append( mCircularIntermediateMatch );
782 mSnappingMatches.append( match );
788 else if ( mTempRubberBand->pointsCount() == 0 )
791 mCaptureCurve.addVertex( layerPoint );
792 mSnappingMatches.append( match );
798 mCircularIntermediateMatch = match;
802 mTempRubberBand->addPoint(
mapPoint );
807 mTempRubberBand->addPoint( mCaptureLastPoint );
811 updateExtraSnapLayer();
829 if ( mTempRubberBand )
833 mTempRubberBand->addPoint( endPt );
836 const int countBefore = mCaptureCurve.vertexCount();
838 if ( mCaptureCurve.numPoints() == 1 )
839 mCaptureCurve.removeCurve( 0 );
849 mCaptureCurve.addCurve( segmented,
false );
856 mCaptureCurve.addCurve(
c, !mStartNewCurve );
859 mStartNewCurve =
false;
861 const int countAfter = mCaptureCurve.vertexCount();
862 const int addedPoint = countAfter - countBefore;
864 updateExtraSnapLayer();
866 for (
int i = 0; i < addedPoint; ++i )
876 mCaptureCurve.clear();
877 updateExtraSnapLayer();
882 return mSnappingMatches;
889 if ( mTempRubberBand )
891 if (
size() <= 1 && mTempRubberBand->pointsCount() != 0 )
894 if ( isAutoRepeat && mIgnoreSubsequentAutoRepeatUndo )
896 mIgnoreSubsequentAutoRepeatUndo =
false;
898 const QgsPoint lastPoint = mTempRubberBand->lastPoint();
902 mTempRubberBand->removeLastPoint();
903 mTempRubberBand->movePoint( lastPoint );
908 vertexToRemove.
part = 0;
909 vertexToRemove.
ring = 0;
916 mCaptureCurve.removeCurve( mCaptureCurve.nCurves() - 1 );
918 if ( mCaptureCurve.numPoints() == 2 && mCaptureCurve.nCurves() == 1 )
922 const QgsPoint fp = mCaptureCurve.startPoint();
924 mCaptureCurve.addVertex( fp );
928 const int curvesBefore = mCaptureCurve.nCurves();
931 const int pointsCountBefore = mCaptureCurve.numPoints();
932 mCaptureCurve.deleteVertex( vertexToRemove );
933 int pointsCountAfter = mCaptureCurve.numPoints();
934 for ( ; pointsCountAfter < pointsCountBefore; pointsCountAfter++ )
935 if ( !mSnappingMatches.empty() )
936 mSnappingMatches.removeLast();
942 if ( mCaptureCurve.nCurves() < curvesBefore && lastCurveIsLineString )
943 mIgnoreSubsequentAutoRepeatUndo =
true;
946 updateExtraSnapLayer();
952 if ( mCaptureCurve.numPoints() > 0 )
954 const QgsPoint lastPt = mCaptureCurve.endPoint();
956 mTempRubberBand->addPoint( mCaptureLastPoint );
957 mTempRubberBand->movePoint( lastPoint );
969 mCurrentShapeMapTool->keyPressEvent( e );
970 if ( e->isAccepted() )
981 if ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete )
985 if ( !e->isAutoRepeat() )
987 mCurrentShapeMapTool->undo();
992 undo( e->isAutoRepeat() );
998 else if ( e->key() == Qt::Key_Escape )
1000 if ( mCurrentShapeMapTool )
1001 mCurrentShapeMapTool->clean();
1022 mRubberBand.reset();
1026 qDeleteAll( mGeomErrorMarkers );
1027 mGeomErrorMarkers.clear();
1028 mGeomErrors.clear();
1036 mCaptureCurve.clear();
1037 updateExtraSnapLayer();
1038 mSnappingMatches.clear();
1040 lCurrentVectorLayer->triggerRepaint();
1045 mTempRubberBand.reset();
1052 mCurrentShapeMapTool->clean();
1059 mCaptureCurve.close();
1060 updateExtraSnapLayer();
1063void QgsMapToolCapture::validateGeometry()
1071 mValidator->deleteLater();
1072 mValidator =
nullptr;
1075 mGeomErrors.clear();
1076 while ( !mGeomErrorMarkers.isEmpty() )
1078 delete mGeomErrorMarkers.takeFirst();
1083 switch ( mCaptureMode )
1091 geom = QgsGeometry( mCaptureCurve.curveToLine() );
1096 QgsLineString *exteriorRing = mCaptureCurve.curveToLine();
1097 exteriorRing->
close();
1098 QgsPolygon *polygon =
new QgsPolygon();
1100 geom = QgsGeometry( polygon );
1110 mValidator =
new QgsGeometryValidator( geom,
nullptr, method );
1112 mValidator->start();
1119 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>(
layer() );
1125 QgsVertexMarker *vm =
new QgsVertexMarker(
mCanvas );
1129 vm->setToolTip( e.
what() );
1131 vm->setZValue( vm->zValue() + 1 );
1132 mGeomErrorMarkers << vm;
1138 return mCaptureCurve.numPoints();
1143 QVector<QgsPointXY> pointsXY;
1152 mCaptureCurve.points( pts );
1159 mCaptureCurve.clear();
1160 mCaptureCurve.addCurve( line );
1161 updateExtraSnapLayer();
1162 mSnappingMatches.clear();
1163 for (
int i = 0; i < line->
length(); ++i )
1171 mCaptureCurve.clear();
1172 mCaptureCurve.addCurve( line );
1173 updateExtraSnapLayer();
1174 mSnappingMatches.clear();
1175 for (
int i = 0; i < line->
length(); ++i )
1232 if ( match.
layer() )
1250void QgsMapToolCapture::updateExtraSnapLayer()
1252 if ( !mExtraSnapLayer )
1255 if (
canvas()->snappingUtils()->config().selfSnapping() &&
layer() && mCaptureCurve.
numPoints() >= 2 )
1265 mExtraSnapLayer->changeGeometry( mExtraSnapFeatureId, geom );
1270 mExtraSnapLayer->changeGeometry( mExtraSnapFeatureId, geom );
1280 if ( e->button() != Qt::LeftButton )
1284 bool isMatchPointZ =
false;
1285 bool isMatchPointM =
false;
1296 if ( isMatchPointM && isMatchPointZ )
1300 else if ( isMatchPointM )
1304 else if ( isMatchPointZ )
1308 savePoint =
QgsPoint( geomType, fetchPoint.
x(), fetchPoint.
y(), fetchPoint.
z(), fetchPoint.
m() );
1314 savePoint =
QgsPoint( point.
x(), point.
y(), fetchPoint.
z(), fetchPoint.
m() );
1324 QgsGeometry g( std::make_unique<QgsPoint>( savePoint ) );
1341 bool digitizingFinished =
false;
1345 if ( !mCurrentShapeMapTool )
1352 if ( !mTempRubberBand )
1354 mTempRubberBand.reset( createCurveRubberBand() );
1355 mTempRubberBand->setStringType( mLineDigitizingType );
1359 digitizingFinished = mCurrentShapeMapTool->cadCanvasReleaseEvent( e, mCaptureMode );
1360 if ( digitizingFinished )
1361 mCurrentShapeMapTool->clean();
1367 if ( e->button() == Qt::LeftButton )
1379 else if ( e->button() == Qt::RightButton )
1403 digitizingFinished =
true;
1407 if ( digitizingFinished )
1410 std::unique_ptr<QgsCurve> curveToAdd(
captureCurve()->clone() );
1427 if ( hasCurvedSegments && providerSupportsCurvedSegments )
1441 poly->setExteriorRing( curveToAdd.release() );
@ CircularGeometries
Supports circular geometry types (circularstring, compoundcurve, curvepolygon).
CaptureTechnique
Capture technique.
@ StraightSegments
Default capture mode - capture occurs with straight line segments.
@ CircularString
Capture in circular strings.
@ Streaming
Streaming points digitizing mode (points are automatically added as the mouse cursor moves).
GeometryValidationEngine
Available engines for validating geometries.
@ QgisInternal
Use internal QgsGeometryValidator method.
@ Geos
Use GEOS validation methods.
@ Warning
Warning message.
WkbType
The WKB type describes the number of dimensions a geometry has.
@ CompoundCurve
CompoundCurve.
@ CircularString
CircularString.
@ Reverse
Reverse/inverse transform (from destination to source).
bool isMeasure() const
Returns true if the geometry contains m values.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
@ CapturePoint
Select and capture a point or a feature.
QgsCompoundCurve * clone() const override
Clones the geometry by performing a deep copy.
bool hasCurvedSegments() const override
Returns true if the geometry contains curved segments.
int numPoints() const override
Returns the number of points in the curve.
Custom exception class for Coordinate Reference System related exceptions.
Curve polygon geometry type.
Abstract base class for curved geometry type.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
Wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets the feature ID that should be fetched.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void errorFound(const QgsGeometry::Error &error)
Sent when an error has been found during the validation process.
bool hasWhere() const
true if the location available from
QgsPointXY where() const
The coordinates at which the error is located and should be visualized.
QString what() const
A human readable error message containing details about the error.
A geometry is the spatial representation of a feature.
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsGeometry convertToCurves(double distanceTolerance=1e-8, double angleTolerance=1e-8) const
Attempts to convert a non-curved geometry into a curved geometry type (e.g.
static void convertPointList(const QVector< QgsPointXY > &input, QgsPointSequence &output)
Upgrades a point list from QgsPointXY to QgsPoint.
Qgis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.).
Line string geometry type, with support for z-dimension and m-values.
double length() const override
Returns the planar, 2-dimensional length of the geometry.
void transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection d=Qgis::TransformDirection::Forward, bool transformZ=false) override
Transforms the geometry using a coordinate transform.
void close()
Closes the line string by appending the first point to the end of the line, if it is not already clos...
QAction * actionEnableSnapping() const
Access to action that user may use to toggle snapping on/off.
void reportError(PathError err, bool addingVertex)
Report a path finding error to the user.
QAction * actionEnableTracing() const
Access to action that user may use to toggle tracing on/off. May be nullptr if no action was associat...
static QgsMapCanvasTracer * tracerForCanvas(QgsMapCanvas *canvas)
Retrieve instance of this class associated with given canvas (if any).
void currentLayerChanged(QgsMapLayer *layer)
Emitted when the current layer is changed.
Base class for all map layer types.
QgsCoordinateReferenceSystem crs
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
A mouse event which is the result of a user interaction with a QgsMapCanvas.
bool isSnapped() const
Returns true if there is a snapped point cached.
QgsPointXY mapPoint() const
mapPoint returns the point in coordinates
QgsPointLocator::Match mapPointMatch() const
Returns the matching data from the most recently snapped point.
Point geometry type, with support for z-dimension and m-values.
bool addMValue(double mValue=0) override
Adds a measure to the geometry, initialized to a preset value.
bool dropMValue() override
Drops any measure values which exist in the geometry.
bool addZValue(double zValue=0) override
Adds a z-dimension to the geometry, initialized to a preset value.
bool deleteVertex(QgsVertexId position) override
Deletes a vertex within the geometry.
void setM(double m)
Sets the point's m-value.
bool convertTo(Qgis::WkbType type) override
Converts the geometry to a specified type.
void setZ(double z)
Sets the point's z-coordinate.
bool dropZValue() override
Drops any z-dimensions which exist in the geometry.
void setExteriorRing(QgsCurve *ring) override
Sets the exterior ring of the polygon.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void snappingConfigChanged(const QgsSnappingConfig &config)
Emitted whenever the configuration for snapping has changed.
Responsible for drawing transient features (e.g.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
static const QgsSettingsEntryInteger * settingsDigitizingStreamTolerance
Settings entry digitizing stream tolerance.
static const QgsSettingsEntryDouble * settingsDigitizingLineColorAlphaScale
Settings entry digitizing line color alpha scale.
static const QgsSettingsEntryDouble * settingsDigitizingConvertToCurveAngleTolerance
Settings entry digitizing convert to curve angle tolerance.
static const QgsSettingsEntryDouble * settingsDigitizingConvertToCurveDistanceTolerance
Settings entry digitizing convert to curve distance tolerance.
static const QgsSettingsEntryInteger * settingsDigitizingValidateGeometries
Settings entry digitizing validate geometries.
static const QgsSettingsEntryBool * settingsDigitizingConvertToCurve
Settings entry digitizing convert to curve.
bool isPointSnapped(const QgsPointXY &pt)
Find out whether the point is snapped to a vertex or edge (i.e. it can be used for tracing start/stop...
QVector< QgsPointXY > findShortestPath(const QgsPointXY &p1, const QgsPointXY &p2, PathError *error=nullptr)
Given two points, find the shortest path and return points on the way.
PathError
Possible errors that may happen when calling findShortestPath().
@ ErrTooManyFeatures
Max feature count threshold was reached while reading features.
bool init()
Build the internal data structures.
virtual Q_INVOKABLE Qgis::VectorProviderCapabilities capabilities() const
Returns flags containing the supported capabilities.
Represents a vector layer which manages a vector based dataset.
bool isSpatial() const final
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
Q_INVOKABLE Qgis::WkbType wkbType() const final
Returns the WKBType or WKBUnknown in case of error.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const final
Queries the layer for features specified in request.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
Q_INVOKABLE QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id.
QgsVectorDataProvider * dataProvider() final
Returns the layer's data provider, it may be nullptr.
void setPenWidth(int width)
void setCenter(const QgsPointXY &point)
Sets the center point of the marker, in map coordinates.
void setIconType(int iconType)
void setColor(const QColor &color)
Sets the stroke color for the marker.
static Q_INVOKABLE bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static Q_INVOKABLE bool hasM(Qgis::WkbType type)
Tests whether a WKB type contains m values.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define BUILTIN_UNREACHABLE
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsPoint > QgsPointSequence
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QgsFeatureId featureId() const
The id of the feature to which the snapped geometry belongs.
QgsVectorLayer * layer() const
The vector layer where the snap occurred.
QgsPoint interpolatedPoint(const QgsCoordinateReferenceSystem &destinationCrs=QgsCoordinateReferenceSystem()) const
Convenient method to return a point on an edge with linear interpolation of the Z value.
bool hasEdge() const
Returns true if the Match is an edge.
bool hasLineEndpoint() const
Returns true if the Match is a line endpoint (start or end vertex).
bool hasMiddleSegment() const
Returns true if the Match is the middle of a segment.
int vertexIndex() const
for vertex / edge match (first vertex of the edge)
bool hasVertex() const
Returns true if the Match is a vertex.
Setting options for loading vector layers.
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
bool loadDefaultStyle
Set to true if the default layer style should be loaded.
Utility class for identifying a unique vertex within a geometry.