mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Instead of requiring users to enable the core c++ plugin 'Coordinate Capture' in order to copy coordinates for a map point, instead add this functionality to a map canvas right click context menu. Now, when compatible map tools are activated (pan, zoom, select by rect), right clicking on the canvas shows a context menu with a "Copy Coordinate" submenu. The submenu shows options for copying the coordinate in the map CRS, WGS84 or a custom preset CRS. Also adds API to allow 3rd party QgsMapTool subclasses to implement their own context menus which include this Copy Coordinate action.
299 lines
7.9 KiB
Plaintext
299 lines
7.9 KiB
Plaintext
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/gui/qgsmaptool.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%ModuleHeaderCode
|
|
// fix to allow compilation with sip 4.7 that for some reason
|
|
// doesn't add these includes to the file where the code from
|
|
// ConvertToSubClassCode goes.
|
|
#include <qgsmaptoolzoom.h>
|
|
#include <qgsmaptoolpan.h>
|
|
#include <qgsmaptoolemitpoint.h>
|
|
#include <qgsmaptoolidentify.h>
|
|
%End
|
|
|
|
class QgsMapTool : QObject
|
|
{
|
|
%Docstring
|
|
Abstract base class for all map tools.
|
|
Map tools are user interactive tools for manipulating the
|
|
map canvas. For example map pan and zoom features are
|
|
implemented as map tools.
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsmaptool.h"
|
|
%End
|
|
%ConvertToSubClassCode
|
|
if ( dynamic_cast<QgsMapToolZoom *>( sipCpp ) != NULL )
|
|
sipType = sipType_QgsMapToolZoom;
|
|
else if ( dynamic_cast<QgsMapToolPan *>( sipCpp ) != NULL )
|
|
sipType = sipType_QgsMapToolPan;
|
|
else if ( dynamic_cast<QgsMapToolEmitPoint *>( sipCpp ) != NULL )
|
|
sipType = sipType_QgsMapToolEmitPoint;
|
|
else if ( dynamic_cast<QgsMapToolIdentify *>( sipCpp ) != NULL )
|
|
sipType = sipType_QgsMapToolIdentify;
|
|
else
|
|
sipType = NULL;
|
|
%End
|
|
public:
|
|
|
|
enum Flag
|
|
{
|
|
Transient,
|
|
EditTool,
|
|
AllowZoomRect,
|
|
ShowContextMenu,
|
|
};
|
|
typedef QFlags<QgsMapTool::Flag> Flags;
|
|
|
|
|
|
virtual Flags flags() const;
|
|
%Docstring
|
|
Returns the flags for the map tool.
|
|
|
|
.. versionadded:: 2.16
|
|
%End
|
|
|
|
~QgsMapTool();
|
|
|
|
virtual void canvasMoveEvent( QgsMapMouseEvent *e );
|
|
%Docstring
|
|
Mouse move event for overriding. Default implementation does nothing.
|
|
%End
|
|
|
|
virtual void canvasDoubleClickEvent( QgsMapMouseEvent *e );
|
|
%Docstring
|
|
Mouse double-click event for overriding. Default implementation does nothing.
|
|
%End
|
|
|
|
virtual void canvasPressEvent( QgsMapMouseEvent *e );
|
|
%Docstring
|
|
Mouse press event for overriding. Default implementation does nothing.
|
|
%End
|
|
|
|
virtual void canvasReleaseEvent( QgsMapMouseEvent *e );
|
|
%Docstring
|
|
Mouse release event for overriding. Default implementation does nothing.
|
|
%End
|
|
|
|
virtual void wheelEvent( QWheelEvent *e );
|
|
%Docstring
|
|
Mouse wheel event for overriding. Default implementation does nothing.
|
|
%End
|
|
|
|
virtual void keyPressEvent( QKeyEvent *e );
|
|
%Docstring
|
|
Key event for overriding. Default implementation does nothing.
|
|
%End
|
|
|
|
virtual void keyReleaseEvent( QKeyEvent *e );
|
|
%Docstring
|
|
Key event for overriding. Default implementation does nothing.
|
|
%End
|
|
|
|
virtual bool gestureEvent( QGestureEvent *e );
|
|
%Docstring
|
|
gesture event for overriding. Default implementation does nothing.
|
|
%End
|
|
|
|
void setAction( QAction *action );
|
|
%Docstring
|
|
Use this to associate a QAction to this maptool. Then when the setMapTool
|
|
method of mapcanvas is called the action state will be set to on.
|
|
Usually this will cause e.g. a toolbutton to appear pressed in and
|
|
the previously used toolbutton to pop out. *
|
|
%End
|
|
|
|
QAction *action();
|
|
%Docstring
|
|
Returns associated action with map tool or ``None`` if no action is associated
|
|
%End
|
|
|
|
bool isActive() const;
|
|
%Docstring
|
|
Returns if the current map tool active on the map canvas
|
|
|
|
.. versionadded:: 3.4
|
|
%End
|
|
|
|
void setButton( QAbstractButton *button );
|
|
%Docstring
|
|
Use this to associate a button to this maptool. It has the same meaning
|
|
as setAction() function except it works with a button instead of an QAction. *
|
|
%End
|
|
|
|
QAbstractButton *button();
|
|
%Docstring
|
|
Returns associated button with map tool or ``None`` if no button is associated
|
|
%End
|
|
|
|
virtual void setCursor( const QCursor &cursor );
|
|
%Docstring
|
|
Sets a user defined cursor
|
|
%End
|
|
|
|
virtual void activate();
|
|
%Docstring
|
|
called when set as currently active map tool
|
|
%End
|
|
|
|
virtual void deactivate();
|
|
%Docstring
|
|
called when map tool is being deactivated
|
|
%End
|
|
|
|
virtual void clean();
|
|
%Docstring
|
|
convenient method to clean members
|
|
%End
|
|
|
|
QgsMapCanvas *canvas() const;
|
|
%Docstring
|
|
returns pointer to the tool's map canvas
|
|
%End
|
|
|
|
QString toolName();
|
|
%Docstring
|
|
Emit map tool changed with the old tool
|
|
|
|
.. versionadded:: 2.3
|
|
%End
|
|
|
|
static double searchRadiusMM();
|
|
%Docstring
|
|
Gets search radius in mm. Used by identify, tip etc.
|
|
The values is currently set in identify tool options (move somewhere else?)
|
|
and defaults to Qgis.DEFAULT_SEARCH_RADIUS_MM.
|
|
|
|
.. versionadded:: 2.3
|
|
%End
|
|
|
|
static double searchRadiusMU( const QgsRenderContext &context );
|
|
%Docstring
|
|
Gets search radius in map units for given context. Used by identify, tip etc.
|
|
The values is calculated from searchRadiusMM().
|
|
|
|
.. versionadded:: 2.3
|
|
%End
|
|
|
|
static double searchRadiusMU( QgsMapCanvas *canvas );
|
|
%Docstring
|
|
Gets search radius in map units for given canvas. Used by identify, tip etc.
|
|
The values is calculated from searchRadiusMM().
|
|
|
|
.. versionadded:: 2.3
|
|
%End
|
|
|
|
virtual void populateContextMenu( QMenu *menu );
|
|
%Docstring
|
|
Allows the tool to populate and customize the given ``menu``,
|
|
prior to showing it in response to a right-mouse button click.
|
|
|
|
``menu`` will be initially populated with a set of default, generic actions.
|
|
Any new actions added to the menu should be correctly parented to ``menu``.
|
|
|
|
The default implementation does nothing.
|
|
|
|
.. note::
|
|
|
|
The context menu is only shown when the ShowContextMenu flag
|
|
is present in flags().
|
|
|
|
.. versionadded:: 3.14
|
|
%End
|
|
|
|
signals:
|
|
void messageEmitted( const QString &message, Qgis::MessageLevel = Qgis::Info );
|
|
%Docstring
|
|
emit a message
|
|
%End
|
|
|
|
void messageDiscarded();
|
|
%Docstring
|
|
emit signal to clear previous message
|
|
%End
|
|
|
|
void activated();
|
|
%Docstring
|
|
signal emitted once the map tool is activated
|
|
%End
|
|
|
|
void deactivated();
|
|
%Docstring
|
|
signal emitted once the map tool is deactivated
|
|
%End
|
|
|
|
protected:
|
|
|
|
QgsMapTool( QgsMapCanvas *canvas /TransferThis/ );
|
|
%Docstring
|
|
constructor takes map canvas as a parameter
|
|
%End
|
|
|
|
QgsPointXY toMapCoordinates( QPoint point );
|
|
%Docstring
|
|
transformation from screen coordinates to map coordinates
|
|
%End
|
|
|
|
QgsPointXY toLayerCoordinates( const QgsMapLayer *layer, QPoint point );
|
|
%Docstring
|
|
transformation from screen coordinates to layer's coordinates
|
|
%End
|
|
|
|
QgsPointXY toLayerCoordinates( const QgsMapLayer *layer, const QgsPointXY &point );
|
|
%Docstring
|
|
transformation from map coordinates to layer's coordinates
|
|
%End
|
|
|
|
QgsPointXY toMapCoordinates( const QgsMapLayer *layer, const QgsPointXY &point );
|
|
%Docstring
|
|
transformation from layer's coordinates to map coordinates (which is different in case reprojection is used)
|
|
%End
|
|
|
|
QgsPoint toMapCoordinates( const QgsMapLayer *layer, const QgsPoint &point ) /PyName=toMapCoordinatesV2/;
|
|
%Docstring
|
|
transformation from layer's coordinates to map coordinates (which is different in case reprojection is used)
|
|
|
|
.. note::
|
|
|
|
available in Python bindings as toMapCoordinatesV2
|
|
%End
|
|
|
|
QgsRectangle toLayerCoordinates( const QgsMapLayer *layer, const QgsRectangle &rect );
|
|
%Docstring
|
|
trnasformation of the rect from map coordinates to layer's coordinates
|
|
%End
|
|
|
|
QPoint toCanvasCoordinates( const QgsPointXY &point ) const;
|
|
%Docstring
|
|
transformation from map coordinates to screen coordinates
|
|
%End
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
QFlags<QgsMapTool::Flag> operator|(QgsMapTool::Flag f1, QFlags<QgsMapTool::Flag> f2);
|
|
|
|
|
|
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/gui/qgsmaptool.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|