Skip to content

Commit

Permalink
fix api break for current,previous,penultimatepoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti authored and nyalldawson committed Sep 12, 2021
1 parent 4279428 commit 99af22b
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 19 deletions.
33 changes: 30 additions & 3 deletions python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in
Expand Up @@ -304,27 +304,54 @@ automatically populated when user clicks with left mouse button on map canvas.
.. versionadded:: 3.0
%End

QgsPoint currentPoint( bool *exists = 0 ) const;
QgsPoint currentPointV2( bool *exists = 0 ) const;
%Docstring
The last point.
Helper for the CAD point list. The CAD point list is the list of points
currently digitized. It contains both "normal" points and intermediate points (construction mode).
%End

QgsPoint previousPoint( bool *exists = 0 ) const;
QgsPointXY currentPoint( bool *exists = 0 ) const /Deprecated/;
%Docstring
The last point.
Helper for the CAD point list. The CAD point list is the list of points
currently digitized. It contains both "normal" points and intermediate points (construction mode).

.. deprecated:: QGIS 3.22
- will be removed in QGIS 4.0. Use the variant which returns :py:class:`QgsPoint` object instead of :py:class:`QgsPointXY`.
%End
QgsPoint previousPointV2( bool *exists = 0 ) const;
%Docstring
The previous point.
Helper for the CAD point list. The CAD point list is the list of points
currently digitized. It contains both "normal" points and intermediate points (construction mode).
%End

QgsPoint penultimatePoint( bool *exists = 0 ) const;
QgsPointXY previousPoint( bool *exists = 0 ) const /Deprecated/;
%Docstring
The previous point.
Helper for the CAD point list. The CAD point list is the list of points
currently digitized. It contains both "normal" points and intermediate points (construction mode).

.. deprecated:: QGIS 3.22
- will be removed in QGIS 4.0. Use the variant which returns :py:class:`QgsPoint` object instead of :py:class:`QgsPointXY`.
%End
QgsPoint penultimatePointV2( bool *exists = 0 ) const;
%Docstring
The penultimate point.
Helper for the CAD point list. The CAD point list is the list of points
currently digitized. It contains both "normal" points and intermediate points (construction mode).
%End

QgsPointXY penultimatePoint( bool *exists = 0 ) const /Deprecated/;
%Docstring
The penultimate point.
Helper for the CAD point list. The CAD point list is the list of points
currently digitized. It contains both "normal" points and intermediate points (construction mode).

.. deprecated:: QGIS 3.22
- will be removed in QGIS 4.0. Use the variant which returns :py:class:`QgsPoint` object instead of :py:class:`QgsPointXY`.
%End
int pointsCount() const;
%Docstring
The number of points in the CAD point helper list
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsadvanceddigitizingcanvasitem.cpp
Expand Up @@ -55,9 +55,9 @@ void QgsAdvancedDigitizingCanvasItem::paint( QPainter *painter )
return;

bool previousPointExist, penulPointExist;
const QgsPointXY curPoint = mAdvancedDigitizingDockWidget->currentPoint();
const QgsPointXY prevPoint = mAdvancedDigitizingDockWidget->previousPoint( &previousPointExist );
const QgsPointXY penulPoint = mAdvancedDigitizingDockWidget->penultimatePoint( &penulPointExist );
const QgsPointXY curPoint = mAdvancedDigitizingDockWidget->currentPointV2();
const QgsPointXY prevPoint = mAdvancedDigitizingDockWidget->previousPointV2( &previousPointExist );
const QgsPointXY penulPoint = mAdvancedDigitizingDockWidget->penultimatePointV2( &penulPointExist );
const bool snappedToVertex = mAdvancedDigitizingDockWidget->snappedToVertex();
const QList<QgsPointXY> snappedSegment = mAdvancedDigitizingDockWidget->snappedSegment();
const bool hasSnappedSegment = snappedSegment.count() == 2;
Expand Down
14 changes: 7 additions & 7 deletions src/gui/qgsadvanceddigitizingdockwidget.cpp
Expand Up @@ -898,8 +898,8 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent *e )
void QgsAdvancedDigitizingDockWidget::updateUnlockedConstraintValues( const QgsPoint &point )
{
bool previousPointExist, penulPointExist;
const QgsPoint previousPt = previousPoint( &previousPointExist );
const QgsPoint penultimatePt = penultimatePoint( &penulPointExist );
const QgsPoint previousPt = previousPointV2( &previousPointExist );
const QgsPoint penultimatePt = penultimatePointV2( &penulPointExist );

// --- angle
if ( !mAngleConstraint->isLocked() && previousPointExist )
Expand Down Expand Up @@ -1015,8 +1015,8 @@ bool QgsAdvancedDigitizingDockWidget::alignToSegment( QgsMapMouseEvent *e, CadCo
}

bool previousPointExist, penulPointExist, snappedSegmentExist;
const QgsPoint previousPt = previousPoint( &previousPointExist );
const QgsPoint penultimatePt = penultimatePoint( &penulPointExist );
const QgsPoint previousPt = previousPointV2( &previousPointExist );
const QgsPoint penultimatePt = penultimatePointV2( &penulPointExist );
mSnappedSegment = snapSegmentToAllLayers( e->originalMapPoint(), &snappedSegmentExist );

if ( !previousPointExist || !snappedSegmentExist )
Expand Down Expand Up @@ -1527,7 +1527,7 @@ void QgsAdvancedDigitizingDockWidget::CadConstraint::toggleRelative()
setRelative( !mRelative );
}

QgsPoint QgsAdvancedDigitizingDockWidget::currentPoint( bool *exist ) const
QgsPoint QgsAdvancedDigitizingDockWidget::currentPointV2( bool *exist ) const
{
if ( exist )
*exist = pointsCount() > 0;
Expand All @@ -1537,7 +1537,7 @@ QgsPoint QgsAdvancedDigitizingDockWidget::currentPoint( bool *exist ) const
return QgsPoint();
}

QgsPoint QgsAdvancedDigitizingDockWidget::previousPoint( bool *exist ) const
QgsPoint QgsAdvancedDigitizingDockWidget::previousPointV2( bool *exist ) const
{
if ( exist )
*exist = pointsCount() > 1;
Expand All @@ -1547,7 +1547,7 @@ QgsPoint QgsAdvancedDigitizingDockWidget::previousPoint( bool *exist ) const
return QgsPoint();
}

QgsPoint QgsAdvancedDigitizingDockWidget::penultimatePoint( bool *exist ) const
QgsPoint QgsAdvancedDigitizingDockWidget::penultimatePointV2( bool *exist ) const
{
if ( exist )
*exist = pointsCount() > 2;
Expand Down
30 changes: 27 additions & 3 deletions src/gui/qgsadvanceddigitizingdockwidget.h
Expand Up @@ -325,21 +325,45 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private
* Helper for the CAD point list. The CAD point list is the list of points
* currently digitized. It contains both "normal" points and intermediate points (construction mode).
*/
QgsPoint currentPoint( bool *exists = nullptr ) const;
QgsPoint currentPointV2( bool *exists = nullptr ) const;

/**
* The last point.
* Helper for the CAD point list. The CAD point list is the list of points
* currently digitized. It contains both "normal" points and intermediate points (construction mode).
* \deprecated since QGIS 3.22 - will be removed in QGIS 4.0. Use the variant which returns QgsPoint object instead of QgsPointXY.
*/
Q_DECL_DEPRECATED QgsPointXY currentPoint( bool *exists = nullptr ) const SIP_DEPRECATED { return currentPointV2( exists ); };

/**
* The previous point.
* Helper for the CAD point list. The CAD point list is the list of points
* currently digitized. It contains both "normal" points and intermediate points (construction mode).
*/
QgsPoint previousPointV2( bool *exists = nullptr ) const;

/**
* The previous point.
* Helper for the CAD point list. The CAD point list is the list of points
* currently digitized. It contains both "normal" points and intermediate points (construction mode).
* \deprecated since QGIS 3.22 - will be removed in QGIS 4.0. Use the variant which returns QgsPoint object instead of QgsPointXY.
*/
Q_DECL_DEPRECATED QgsPointXY previousPoint( bool *exists = nullptr ) const SIP_DEPRECATED { return previousPointV2( exists ); };

/**
* The penultimate point.
* Helper for the CAD point list. The CAD point list is the list of points
* currently digitized. It contains both "normal" points and intermediate points (construction mode).
*/
QgsPoint previousPoint( bool *exists = nullptr ) const;
QgsPoint penultimatePointV2( bool *exists = nullptr ) const;

/**
* The penultimate point.
* Helper for the CAD point list. The CAD point list is the list of points
* currently digitized. It contains both "normal" points and intermediate points (construction mode).
* \deprecated since QGIS 3.22 - will be removed in QGIS 4.0. Use the variant which returns QgsPoint object instead of QgsPointXY.
*/
QgsPoint penultimatePoint( bool *exists = nullptr ) const;
Q_DECL_DEPRECATED QgsPointXY penultimatePoint( bool *exists = nullptr ) const SIP_DEPRECATED { return penultimatePointV2( exists ); };

/**
* The number of points in the CAD point helper list
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsmaptoolcapture.cpp
Expand Up @@ -458,9 +458,9 @@ int QgsMapToolCapture::nextPoint( const QgsPoint &mapPoint, QgsPoint &layerPoint
const QgsPointXY mapP( mapPoint.x(), mapPoint.y() ); //#spellok
layerPoint = QgsPoint( toLayerCoordinates( vlayer, mapP ) ); //transform snapped point back to layer crs //#spellok
if ( QgsWkbTypes::hasZ( vlayer->wkbType() ) && !layerPoint.is3D() )
layerPoint.addZValue( mCadDockWidget && mCadDockWidget->cadEnabled() ? mCadDockWidget->currentPoint().z() : defaultZValue() );
layerPoint.addZValue( mCadDockWidget && mCadDockWidget->cadEnabled() ? mCadDockWidget->currentPointV2().z() : defaultZValue() );
if ( QgsWkbTypes::hasM( vlayer->wkbType() ) && !layerPoint.isMeasure() )
layerPoint.addMValue( mCadDockWidget && mCadDockWidget->cadEnabled() ? mCadDockWidget->currentPoint().m() : defaultMValue() );
layerPoint.addMValue( mCadDockWidget && mCadDockWidget->cadEnabled() ? mCadDockWidget->currentPointV2().m() : defaultMValue() );
}
catch ( QgsCsException & )
{
Expand Down Expand Up @@ -488,7 +488,7 @@ int QgsMapToolCapture::fetchLayerPoint( const QgsPointLocator::Match &match, Qgs
QgsVectorLayer *sourceLayer = match.layer();
if ( mCadDockWidget && mCadDockWidget->cadEnabled() )
{
layerPoint = mCadDockWidget->currentPoint();
layerPoint = mCadDockWidget->currentPointV2();
return 0;
}
else
Expand Down

0 comments on commit 99af22b

Please sign in to comment.