Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix digitizing features using CAD dock when layer CRS != canvas CRS #45108

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ automatically populated when user clicks with left mouse button on map canvas.
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).

.. versionadded:: 3.22
%End

QgsPoint currentPointLayerCoordinates( QgsMapLayer *layer ) const;
%Docstring
Returns the last CAD point, in a map ``layer``'s coordinates.

.. versionadded:: 3.22
%End

QgsPointXY currentPoint( bool *exists = 0 ) const /Deprecated/;
Expand Down
13 changes: 13 additions & 0 deletions src/gui/qgsadvanceddigitizingdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,19 @@ QgsPoint QgsAdvancedDigitizingDockWidget::currentPointV2( bool *exist ) const
return QgsPoint();
}

QgsPoint QgsAdvancedDigitizingDockWidget::currentPointLayerCoordinates( QgsMapLayer *layer ) const
{
if ( pointsCount() > 0 && layer )
{
QgsPoint res = mCadPointList.value( 0 );
const QgsPointXY layerCoordinates = mMapCanvas->mapSettings().mapToLayerCoordinates( layer, res );
res.setX( layerCoordinates.x() );
res.setY( layerCoordinates.y() );
return res;
}
return QgsPoint();
}

QgsPoint QgsAdvancedDigitizingDockWidget::previousPointV2( bool *exist ) const
{
if ( exist )
Expand Down
9 changes: 9 additions & 0 deletions src/gui/qgsadvanceddigitizingdockwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,18 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private
* 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).
*
* \since QGIS 3.22
*/
QgsPoint currentPointV2( bool *exists = nullptr ) const;

/**
* Returns the last CAD point, in a map \a layer's coordinates.
*
* \since QGIS 3.22
*/
QgsPoint currentPointLayerCoordinates( QgsMapLayer *layer ) const;

/**
* The last point.
* Helper for the CAD point list. The CAD point list is the list of points
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmaptoolcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ int QgsMapToolCapture::fetchLayerPoint( const QgsPointLocator::Match &match, Qgs
QgsVectorLayer *sourceLayer = match.layer();
if ( mCadDockWidget && mCadDockWidget->cadEnabled() )
{
layerPoint = mCadDockWidget->currentPointV2();
layerPoint = mCadDockWidget->currentPointLayerCoordinates( vlayer );
return 0;
}
else
Expand Down