diff --git a/python/gui/auto_generated/qgsmaptoolcapture.sip.in b/python/gui/auto_generated/qgsmaptoolcapture.sip.in index 889029f3b0a..92a6cec9eb2 100644 --- a/python/gui/auto_generated/qgsmaptoolcapture.sip.in +++ b/python/gui/auto_generated/qgsmaptoolcapture.sip.in @@ -213,13 +213,32 @@ Number of points digitized :return: Number of points %End - QgsPointSequence points() const; + QVector<QgsPointXY> points() const /Deprecated/; %Docstring List of digitized points :return: List of points -.. versionadded:: 3.10 +.. deprecated:: in QGIS 3.12 - will be removed in QGIS 4.0 +%End + + + QgsPointSequence pointsZM() const; +%Docstring +List of digitized points + +:return: List of points + +.. versionadded:: 3.12 +%End + + void setPoints( const QVector<QgsPointXY> &pointList ) /Deprecated/; +%Docstring +Set the points on which to work + +:param pointList: A list of points + +.. deprecated:: in QGIS 3.12 - will be removed in QGIS 4.0 %End void setPoints( const QgsPointSequence &pointList ); @@ -227,6 +246,8 @@ List of digitized points Set the points on which to work :param pointList: A list of points + +.. versionadded:: 3.12 %End void closePolygon(); diff --git a/src/app/qgsmaptooladdpart.cpp b/src/app/qgsmaptooladdpart.cpp index c3f181cf5a6..e931289e069 100644 --- a/src/app/qgsmaptooladdpart.cpp +++ b/src/app/qgsmaptooladdpart.cpp @@ -198,7 +198,7 @@ void QgsMapToolAddPart::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) bool topologicalEditing = QgsProject::instance()->topologicalEditing(); if ( topologicalEditing ) { - addTopologicalPoints( points() ); + addTopologicalPoints( pointsZM() ); } vlayer->endEditCommand(); diff --git a/src/app/qgsmaptoolfillring.cpp b/src/app/qgsmaptoolfillring.cpp index d96df7fa3f3..c4a72b4202d 100644 --- a/src/app/qgsmaptoolfillring.cpp +++ b/src/app/qgsmaptoolfillring.cpp @@ -89,7 +89,7 @@ void QgsMapToolFillRing::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) vlayer->beginEditCommand( tr( "Ring added and filled" ) ); - QgsPointSequence pointList = points(); + QgsPointSequence pointList = pointsZM(); QgsGeometry::OperationResult addRingReturnCode = vlayer->addRing( pointList, &fid ); diff --git a/src/app/qgsmaptoolreshape.cpp b/src/app/qgsmaptoolreshape.cpp index e0e1f8495be..df4a07574d2 100644 --- a/src/app/qgsmaptoolreshape.cpp +++ b/src/app/qgsmaptoolreshape.cpp @@ -88,8 +88,8 @@ bool QgsMapToolReshape::isBindingLine( QgsVectorLayer *vlayer, const QgsRectangl bool begin = false; bool end = false; - const QgsPointXY beginPoint = points().first(); - const QgsPointXY endPoint = points().last(); + const QgsPointXY beginPoint = pointsZM().first(); + const QgsPointXY endPoint = pointsZM().last(); QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( bbox ).setNoAttributes() ); QgsFeature f; @@ -114,11 +114,11 @@ bool QgsMapToolReshape::isBindingLine( QgsVectorLayer *vlayer, const QgsRectangl void QgsMapToolReshape::reshape( QgsVectorLayer *vlayer ) { - QgsPointXY firstPoint = points().at( 0 ); + QgsPointXY firstPoint = pointsZM().at( 0 ); QgsRectangle bbox( firstPoint.x(), firstPoint.y(), firstPoint.x(), firstPoint.y() ); for ( int i = 1; i < size(); ++i ) { - bbox.combineExtentWith( points().at( i ).x(), points().at( i ).y() ); + bbox.combineExtentWith( pointsZM().at( i ).x(), pointsZM().at( i ).y() ); } diff --git a/src/app/qgsmaptoolsplitfeatures.cpp b/src/app/qgsmaptoolsplitfeatures.cpp index 48a445d084f..3da22ac7765 100644 --- a/src/app/qgsmaptoolsplitfeatures.cpp +++ b/src/app/qgsmaptoolsplitfeatures.cpp @@ -54,7 +54,7 @@ void QgsMapToolSplitFeatures::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) if ( e->button() == Qt::LeftButton ) { //If we snap the first point on a vertex of a line layer, we directly split the feature at this point - if ( vlayer->geometryType() == QgsWkbTypes::LineGeometry && points().isEmpty() ) + if ( vlayer->geometryType() == QgsWkbTypes::LineGeometry && pointsZM().isEmpty() ) { QgsPointLocator::Match m = mCanvas->snappingUtils()->snapToCurrentLayer( e->pos(), QgsPointLocator::Vertex ); if ( m.isValid() ) @@ -94,7 +94,7 @@ void QgsMapToolSplitFeatures::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) //bring up dialog if a split was not possible (polygon) or only done once (line) int topologicalEditing = QgsProject::instance()->topologicalEditing(); vlayer->beginEditCommand( tr( "Features split" ) ); - QgsGeometry::OperationResult returnCode = vlayer->splitFeatures( points(), topologicalEditing ); + QgsGeometry::OperationResult returnCode = vlayer->splitFeatures( pointsZM(), topologicalEditing ); vlayer->endEditCommand(); if ( returnCode == QgsGeometry::OperationResult::NothingHappened ) { diff --git a/src/app/qgsmaptoolsplitparts.cpp b/src/app/qgsmaptoolsplitparts.cpp index c02f093efdf..848f7377034 100644 --- a/src/app/qgsmaptoolsplitparts.cpp +++ b/src/app/qgsmaptoolsplitparts.cpp @@ -53,7 +53,7 @@ void QgsMapToolSplitParts::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) if ( e->button() == Qt::LeftButton ) { //If we snap the first point on a vertex of a line layer, we directly split the feature at this point - if ( vlayer->geometryType() == QgsWkbTypes::LineGeometry && points().isEmpty() ) + if ( vlayer->geometryType() == QgsWkbTypes::LineGeometry && pointsZM().isEmpty() ) { QgsPointLocator::Match m = mCanvas->snappingUtils()->snapToCurrentLayer( e->pos(), QgsPointLocator::Vertex ); if ( m.isValid() ) @@ -92,7 +92,7 @@ void QgsMapToolSplitParts::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) //bring up dialog if a split was not possible (polygon) or only done once (line) bool topologicalEditing = QgsProject::instance()->topologicalEditing(); vlayer->beginEditCommand( tr( "Parts split" ) ); - QgsGeometry::OperationResult returnCode = vlayer->splitParts( points(), topologicalEditing ); + QgsGeometry::OperationResult returnCode = vlayer->splitParts( pointsZM(), topologicalEditing ); vlayer->endEditCommand(); if ( returnCode == QgsGeometry::OperationResult::NothingHappened ) { diff --git a/src/gui/qgsmaptoolcapture.cpp b/src/gui/qgsmaptoolcapture.cpp index 6b8693dc0dd..0c82a1ada8d 100644 --- a/src/gui/qgsmaptoolcapture.cpp +++ b/src/gui/qgsmaptoolcapture.cpp @@ -738,13 +738,31 @@ int QgsMapToolCapture::size() return mCaptureCurve.numPoints(); } -QgsPointSequence QgsMapToolCapture::points() const +QVector<QgsPointXY> QgsMapToolCapture::points() const +{ + QVector<QgsPointXY> pointsXY; + QgsGeometry::convertPointList( pointsZM(), pointsXY ); + + return pointsXY; +} + +QgsPointSequence QgsMapToolCapture::pointsZM() const { QgsPointSequence pts; mCaptureCurve.points( pts ); return pts; } +void QgsMapToolCapture::setPoints( const QVector<QgsPointXY> &pointList ) +{ + QgsLineString *line = new QgsLineString( pointList ); + mCaptureCurve.clear(); + mCaptureCurve.addCurve( line ); + mSnappingMatches.clear(); + for ( int i = 0; i < line->length(); ++i ) + mSnappingMatches.append( QgsPointLocator::Match() ); +} + void QgsMapToolCapture::setPoints( const QgsPointSequence &pointList ) { QgsLineString *line = new QgsLineString( pointList ); diff --git a/src/gui/qgsmaptoolcapture.h b/src/gui/qgsmaptoolcapture.h index 1e7eda14a24..1dd402ff80f 100644 --- a/src/gui/qgsmaptoolcapture.h +++ b/src/gui/qgsmaptoolcapture.h @@ -224,14 +224,32 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing /** * List of digitized points * \returns List of points - * \since 3.10 + * \deprecated in QGIS 3.12 - will be removed in QGIS 4.0 */ - QgsPointSequence points() const; + Q_DECL_DEPRECATED QVector<QgsPointXY> points() const SIP_DEPRECATED; + + // TODO QGIS 4.0 rename it to points() + + /** + * List of digitized points + * \returns List of points + * \since 3.12 + */ + QgsPointSequence pointsZM() const; /** * Set the points on which to work * * \param pointList A list of points + * \deprecated in QGIS 3.12 - will be removed in QGIS 4.0 + */ + Q_DECL_DEPRECATED void setPoints( const QVector<QgsPointXY> &pointList ) SIP_DEPRECATED; + + /** + * Set the points on which to work + * + * \param pointList A list of points + * \since 3.12 */ void setPoints( const QgsPointSequence &pointList );