Class: QgsMapCanvasTracer¶
Extension of QgsTracer
that provides extra functionality:
automatic updates of own configuration based on canvas settings
reporting of issues to the user via message bar
determines whether tracing is currently enabled by the user
A simple registry of tracer instances associated to map canvas instances is kept for convenience. (Map tools do not need to create their local tracer instances and map canvas API is not “polluted” by this optional functionality).
Class Hierarchy¶
Base classes¶
Utility class that construct a planar graph from the input vector layers and provides shortest path search for tracing of existing features. |
|
Methods
Access to action that user may use to toggle snapping on/off. |
|
Access to action that user may use to toggle tracing on/off. |
|
Sets configuration from current snapping settings and canvas settings |
|
Report a path finding error to the user |
|
Assign "enable snapping" checkable action to the tracer. |
|
Assign "enable tracing" checkable action to the tracer. |
Static Methods
Retrieve instance of this class associated with given canvas (if any). |
- class qgis.gui.QgsMapCanvasTracer[source]¶
Bases:
QgsTracer
- __init__(canvas: QgsMapCanvas | None, messageBar: QgsMessageBar | None = None)
Create tracer associated with a particular map canvas, optionally message bar for reporting
- Parameters:
canvas (Optional[QgsMapCanvas])
messageBar (Optional[QgsMessageBar] = None)
- actionEnableSnapping(self) QAction | None [source]¶
Access to action that user may use to toggle snapping on/off. May be
None
if no action was associated.- Return type:
Optional[QAction]
- actionEnableTracing(self) QAction | None [source]¶
Access to action that user may use to toggle tracing on/off. May be
None
if no action was associated- Return type:
Optional[QAction]
- reportError(self, err: QgsTracer.PathError, addingVertex: bool)[source]¶
Report a path finding error to the user
- Parameters:
err (QgsTracer.PathError)
addingVertex (bool)
- setActionEnableSnapping(self, action: QAction | None)[source]¶
Assign “enable snapping” checkable action to the tracer. The action is used to determine whether snapping is currently enabled by the user.
- Parameters:
action (Optional[QAction])
- setActionEnableTracing(self, action: QAction | None)[source]¶
Assign “enable tracing” checkable action to the tracer. The action is used to determine whether tracing is currently enabled by the user
- Parameters:
action (Optional[QAction])
- static tracerForCanvas(canvas: QgsMapCanvas | None) QgsMapCanvasTracer | None [source]¶
Retrieve instance of this class associated with given canvas (if any). The class keeps a simple registry of tracers associated with map canvas instances for easier access to the common tracer by various map tools
- Parameters:
canvas (Optional[QgsMapCanvas])
- Return type:
Optional[QgsMapCanvasTracer]