Subgroup: Map
Class: QgsMapTool¶
-
class
qgis.gui.
QgsMapTool
(canvas: QgsMapCanvas)¶ Bases:
PyQt5.QtCore.QObject
constructor takes map canvas as a parameter
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.
Methods
action
Returns associated action with map tool or NULL if no action is associated activate
called when set as currently active map tool button
Returns associated button with map tool or NULL if no button is associated canvas
returns pointer to the tool’s map canvas canvasDoubleClickEvent
Mouse double-click event for overriding. canvasMoveEvent
Mouse move event for overriding. canvasPressEvent
Mouse press event for overriding. canvasReleaseEvent
Mouse release event for overriding. childEvent
clean
convenient method to clean members connectNotify
customEvent
deactivate
called when map tool is being deactivated disconnectNotify
flags
Returns the flags for the map tool. gestureEvent
gesture event for overriding. isSignalConnected
keyPressEvent
Key event for overriding. keyReleaseEvent
Key event for overriding. receivers
searchRadiusMM
Gets search radius in mm. searchRadiusMU
Gets search radius in map units for given context. sender
senderSignalIndex
setAction
Use this to associate a QAction to this maptool. setButton
Use this to associate a button to this maptool. setCursor
Sets a user defined cursor timerEvent
toCanvasCoordinates
transformation from map coordinates to screen coordinates toLayerCoordinates
transformation from screen coordinates to layer’s coordinates toMapCoordinates
transformation from screen coordinates to map coordinates toMapCoordinatesV2
transformation from layer’s coordinates to map coordinates (which is different in case reprojection is used) toolName
Emit map tool changed with the old tool wheelEvent
Mouse wheel event for overriding. Signals
activated
signal emitted once the map tool is activated [signal] deactivated
signal emitted once the map tool is deactivated [signal] messageDiscarded
emit signal to clear previous message [signal] messageEmitted
emit a message [signal] Attributes
AllowZoomRect
EditTool
Transient
-
AllowZoomRect
= 8¶
-
EditTool
= 4¶
-
class
Flag
¶ Bases:
int
-
class
Flags
¶ Bases:
sip.wrapper
QgsMapTool.Flags(Union[QgsMapTool.Flags, QgsMapTool.Flag]) QgsMapTool.Flags(QgsMapTool.Flags)
-
Transient
= 2¶
-
action
(self) → QAction¶ Returns associated action with map tool or NULL if no action is associated
-
activate
(self)¶ called when set as currently active map tool
-
activated
¶ signal emitted once the map tool is activated [signal]
Returns associated button with map tool or NULL if no button is associated
-
canvas
(self) → QgsMapCanvas¶ returns pointer to the tool’s map canvas
-
canvasDoubleClickEvent
(self, e: QgsMapMouseEvent)¶ Mouse double-click event for overriding. Default implementation does nothing.
-
canvasMoveEvent
(self, e: QgsMapMouseEvent)¶ Mouse move event for overriding. Default implementation does nothing.
-
canvasPressEvent
(self, e: QgsMapMouseEvent)¶ Mouse press event for overriding. Default implementation does nothing.
-
canvasReleaseEvent
(self, e: QgsMapMouseEvent)¶ Mouse release event for overriding. Default implementation does nothing.
-
childEvent
()¶
-
clean
(self)¶ convenient method to clean members
-
connectNotify
()¶
-
customEvent
()¶
-
deactivate
(self)¶ called when map tool is being deactivated
-
deactivated
¶ signal emitted once the map tool is deactivated [signal]
-
disconnectNotify
()¶
-
flags
(self) → QgsMapTool.Flags¶ Returns the flags for the map tool.
New in version 2.16.
-
gestureEvent
(self, e: QGestureEvent) → bool¶ gesture event for overriding. Default implementation does nothing.
-
isSignalConnected
()¶
-
keyPressEvent
(self, e: QKeyEvent)¶ Key event for overriding. Default implementation does nothing.
-
keyReleaseEvent
(self, e: QKeyEvent)¶ Key event for overriding. Default implementation does nothing.
-
messageDiscarded
¶ emit signal to clear previous message [signal]
-
messageEmitted
¶ emit a message [signal]
-
receivers
()¶
-
searchRadiusMM
() → float¶ 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.
New in version 2.3.
-
searchRadiusMU
(context: QgsRenderContext) → float¶ Gets search radius in map units for given context. Used by identify, tip etc. The values is calculated from searchRadiusMM().
New in version 2.3.
searchRadiusMU(canvas: QgsMapCanvas) -> float Gets search radius in map units for given canvas. Used by identify, tip etc. The values is calculated from searchRadiusMM().
New in version 2.3.
-
sender
()¶
-
senderSignalIndex
()¶
-
setAction
(self, action: QAction)¶ 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. *
-
setButton
(self, button: QAbstractButton)¶ 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. *
-
setCursor
(self, cursor: Union[QCursor, Qt.CursorShape])¶ Sets a user defined cursor
-
timerEvent
()¶
-
toCanvasCoordinates
(self, point: QgsPointXY) → QPoint¶ transformation from map coordinates to screen coordinates
-
toLayerCoordinates
(self, layer: QgsMapLayer, point: QPoint) → QgsPointXY¶ transformation from screen coordinates to layer’s coordinates
toLayerCoordinates(self, layer: QgsMapLayer, point: QgsPointXY) -> QgsPointXY transformation from map coordinates to layer’s coordinates
toLayerCoordinates(self, layer: QgsMapLayer, rect: QgsRectangle) -> QgsRectangle trnasformation of the rect from map coordinates to layer’s coordinates
-
toMapCoordinates
(self, point: QPoint) → QgsPointXY¶ transformation from screen coordinates to map coordinates
toMapCoordinates(self, layer: QgsMapLayer, point: QgsPointXY) -> QgsPointXY transformation from layer’s coordinates to map coordinates (which is different in case reprojection is used)
-
toMapCoordinatesV2
(self, layer: QgsMapLayer, point: QgsPoint) → QgsPoint¶ transformation from layer’s coordinates to map coordinates (which is different in case reprojection is used)
Note
available in Python bindings as toMapCoordinatesV2
-
toolName
(self) → str¶ Emit map tool changed with the old tool
New in version 2.3.
-
wheelEvent
(self, e: QWheelEvent)¶ Mouse wheel event for overriding. Default implementation does nothing.
-