QgsMapCanvasTracer class

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).

Base classes

class QgsTracer
Utility class that construct a planar graph from the input vector layers and provides shortest path search for tracing of existing features.

Public static functions

static auto tracerForCanvas(QgsMapCanvas* canvas) -> QgsMapCanvasTracer*
Retrieve instance of this class associated with given canvas (if any).

Constructors, destructors, conversion operators

QgsMapCanvasTracer(QgsMapCanvas* canvas, QgsMessageBar* messageBar = nullptr) explicit
Create tracer associated with a particular map canvas, optionally message bar for reporting.

Public functions

auto actionEnableSnapping() const -> QAction*
Access to action that user may use to toggle snapping on/off.
auto actionEnableTracing() const -> QAction*
Access to action that user may use to toggle tracing on/off. May be null if no action was associated.
void reportError(PathError err, bool addingVertex)
Report a path finding error to the user.
void setActionEnableSnapping(QAction* action)
Assign "enable snapping" checkable action to the tracer.
void setActionEnableTracing(QAction* action)
Assign "enable tracing" checkable action to the tracer.

Protected functions

void configure() override
Sets configuration from current snapping settings and canvas settings.

Function documentation

static QgsMapCanvasTracer* QgsMapCanvasTracer::tracerForCanvas(QgsMapCanvas* canvas)

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

QAction* QgsMapCanvasTracer::actionEnableSnapping() const

Access to action that user may use to toggle snapping on/off.

May be null if no action was associated.

void QgsMapCanvasTracer::setActionEnableSnapping(QAction* action)

Assign "enable snapping" checkable action to the tracer.

The action is used to determine whether snapping is currently enabled by the user.

void QgsMapCanvasTracer::setActionEnableTracing(QAction* action)

Assign "enable tracing" checkable action to the tracer.

The action is used to determine whether tracing is currently enabled by the user