QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsMapCanvasTracer Class Reference

Extension of QgsTracer that provides extra functionality: More...

#include <qgsmapcanvastracer.h>

Inheritance diagram for QgsMapCanvasTracer:
Inheritance graph
[legend]

Public Member Functions

 QgsMapCanvasTracer (QgsMapCanvas *canvas, QgsMessageBar *messageBar=nullptr)
 Create tracer associated with a particular map canvas, optionally message bar for reporting.
 
 ~QgsMapCanvasTracer () override
 
QAction * actionEnableSnapping () const
 Access to action that user may use to toggle snapping on/off.
 
QAction * actionEnableTracing () const
 Access to action that user may use to toggle tracing on/off. May be nullptr 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.
 
- Public Member Functions inherited from QgsTracer
 QgsTracer ()
 Constructor for QgsTracer.
 
 ~QgsTracer () override
 
bool addPointsOnIntersectionsEnabled () const
 Returns whether the shortest path's straight segments will include vertices where the input layers intersect, even if no such vertex existed on the input layers.
 
QgsCoordinateReferenceSystem destinationCrs () const
 Returns the CRS used for tracing.
 
QgsRectangle extent () const
 Gets extent to which graph's features will be limited (empty extent means no limit)
 
QVector< QgsPointXYfindShortestPath (const QgsPointXY &p1, const QgsPointXY &p2, PathError *error=nullptr)
 Given two points, find the shortest path and return points on the way.
 
bool hasTopologyProblem () const
 Whether there was an error during graph creation due to noding exception, indicating some input data topology problems.
 
bool init ()
 Build the internal data structures.
 
bool isInitialized () const
 Whether the internal data structures have been initialized.
 
bool isPointSnapped (const QgsPointXY &pt)
 Find out whether the point is snapped to a vertex or edge (i.e. it can be used for tracing start/stop)
 
QList< QgsVectorLayer * > layers () const
 Gets layers used for tracing.
 
int maxFeatureCount () const
 Gets maximum possible number of features in graph. If the number is exceeded, graph is not created.
 
double offset () const
 Gets offset in map units that should be applied to the traced paths returned from findShortestPath().
 
void offsetParameters (int &quadSegments, int &joinStyle, double &miterLimit)
 Gets extra parameters for offset curve algorithm (used when offset is non-zero)
 
void setAddPointsOnIntersectionsEnabled (bool enable)
 When enable is true, the shortest path's straight segments will include vertices where the input layers intersect, even if no such vertex existed on the input layers.
 
void setDestinationCrs (const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
 Sets the crs and transform context used for tracing.
 
void setExtent (const QgsRectangle &extent)
 Sets extent to which graph's features will be limited (empty extent means no limit)
 
void setLayers (const QList< QgsVectorLayer * > &layers)
 Sets layers used for tracing.
 
void setMaxFeatureCount (int count)
 Gets maximum possible number of features in graph. If the number is exceeded, graph is not created.
 
void setOffset (double offset)
 Set offset in map units that should be applied to the traced paths returned from findShortestPath().
 
void setOffsetParameters (int quadSegments, int joinStyle, double miterLimit)
 Set extra parameters for offset curve algorithm (used when offset is non-zero)
 
void setRenderContext (const QgsRenderContext *renderContext)
 Sets the renderContext used for tracing only on visible features.
 

Static Public Member Functions

static QgsMapCanvasTracertracerForCanvas (QgsMapCanvas *canvas)
 Retrieve instance of this class associated with given canvas (if any).
 

Protected Member Functions

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

Additional Inherited Members

- Public Types inherited from QgsTracer
enum  PathError {
  ErrNone , ErrTooManyFeatures , ErrPoint1 , ErrPoint2 ,
  ErrNoPath
}
 Possible errors that may happen when calling findShortestPath() More...
 
- Protected Slots inherited from QgsTracer
void invalidateGraph ()
 Destroy the existing graph structure if any (de-initialize)
 

Detailed Description

Extension of QgsTracer that provides extra functionality:

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

Definition at line 40 of file qgsmapcanvastracer.h.

Constructor & Destructor Documentation

◆ QgsMapCanvasTracer()

QgsMapCanvasTracer::QgsMapCanvasTracer ( QgsMapCanvas canvas,
QgsMessageBar messageBar = nullptr 
)
explicit

Create tracer associated with a particular map canvas, optionally message bar for reporting.

Definition at line 36 of file qgsmapcanvastracer.cpp.

◆ ~QgsMapCanvasTracer()

QgsMapCanvasTracer::~QgsMapCanvasTracer ( )
override

Definition at line 57 of file qgsmapcanvastracer.cpp.

Member Function Documentation

◆ actionEnableSnapping()

QAction * QgsMapCanvasTracer::actionEnableSnapping ( ) const
inline

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

May be nullptr if no action was associated.

Definition at line 61 of file qgsmapcanvastracer.h.

◆ actionEnableTracing()

QAction * QgsMapCanvasTracer::actionEnableTracing ( ) const
inline

Access to action that user may use to toggle tracing on/off. May be nullptr if no action was associated.

Definition at line 50 of file qgsmapcanvastracer.h.

◆ configure()

void QgsMapCanvasTracer::configure ( )
overrideprotectedvirtual

Sets configuration from current snapping settings and canvas settings.

Reimplemented from QgsTracer.

Definition at line 101 of file qgsmapcanvastracer.cpp.

◆ reportError()

void QgsMapCanvasTracer::reportError ( QgsTracer::PathError  err,
bool  addingVertex 
)

Report a path finding error to the user.

Definition at line 67 of file qgsmapcanvastracer.cpp.

◆ setActionEnableSnapping()

void QgsMapCanvasTracer::setActionEnableSnapping ( QAction *  action)
inline

Assign "enable snapping" checkable action to the tracer.

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

Definition at line 67 of file qgsmapcanvastracer.h.

◆ setActionEnableTracing()

void QgsMapCanvasTracer::setActionEnableTracing ( QAction *  action)
inline

Assign "enable tracing" checkable action to the tracer.

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

Definition at line 56 of file qgsmapcanvastracer.h.

◆ tracerForCanvas()

QgsMapCanvasTracer * QgsMapCanvasTracer::tracerForCanvas ( QgsMapCanvas canvas)
static

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

Definition at line 62 of file qgsmapcanvastracer.cpp.


The documentation for this class was generated from the following files: