Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add QgsMapTool::toLayerCoordinates which acepts QgsPoint
  • Loading branch information
lbartoletti committed Oct 1, 2021
1 parent 97884ad commit bf745b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/gui/auto_generated/qgsmaptool.sip.in
Expand Up @@ -281,6 +281,15 @@ Constructor takes a map canvas as a parameter.
Transforms a ``point`` from screen coordinates to map coordinates.
%End

QgsPoint toLayerCoordinates( const QgsMapLayer *layer, const QgsPoint &point ) /PyName=toLayerCoordinatesV2/;
%Docstring
Transforms a ``point`` from map coordinates to ``layer`` coordinates.

.. note::

This method is available in the Python bindings as toLayerCoordinatesV2.
%End

QgsPointXY toLayerCoordinates( const QgsMapLayer *layer, QPoint point );
%Docstring
Transforms a ``point`` from screen coordinates to ``layer`` coordinates.
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsmaptool.cpp
Expand Up @@ -59,6 +59,11 @@ QgsPointXY QgsMapTool::toLayerCoordinates( const QgsMapLayer *layer, const QgsPo
return mCanvas->mapSettings().mapToLayerCoordinates( layer, point );
}

QgsPoint QgsMapTool::toLayerCoordinates( const QgsMapLayer *layer, const QgsPoint &point )
{
return mCanvas->mapSettings().mapToLayerCoordinates( layer, point );
}

QgsPointXY QgsMapTool::toMapCoordinates( const QgsMapLayer *layer, const QgsPointXY &point )
{
return mCanvas->mapSettings().layerToMapCoordinates( layer, point );
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsmaptool.h
Expand Up @@ -271,6 +271,12 @@ class GUI_EXPORT QgsMapTool : public QObject
//! Transforms a \a point from screen coordinates to map coordinates.
QgsPointXY toMapCoordinates( QPoint point );

/**
* Transforms a \a point from map coordinates to \a layer coordinates.
* \note This method is available in the Python bindings as toLayerCoordinatesV2.
*/
QgsPoint toLayerCoordinates( const QgsMapLayer *layer, const QgsPoint &point ) SIP_PYNAME( toLayerCoordinatesV2 );

//! Transforms a \a point from screen coordinates to \a layer coordinates.
QgsPointXY toLayerCoordinates( const QgsMapLayer *layer, QPoint point );

Expand Down

0 comments on commit bf745b7

Please sign in to comment.