QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
This class has all the configuration of snapping and can return answers to snapping queries. More...
#include <qgssnappingutils.h>
Classes | |
struct | LayerConfig |
Configures how a certain layer should be handled in a snapping operation. More... | |
Public Types | |
enum | IndexingStrategy { IndexAlwaysFull , IndexNeverFull , IndexHybrid , IndexExtent } |
Public Slots | |
void | setConfig (const QgsSnappingConfig &snappingConfig) |
The snapping configuration controls the behavior of this object. | |
void | toggleEnabled () |
Toggles the state of snapping. | |
Signals | |
void | configChanged (const QgsSnappingConfig &snappingConfig) |
Emitted when the snapping settings object changes. | |
Public Member Functions | |
QgsSnappingUtils (QObject *parent=nullptr, bool enableSnappingForInvisibleFeature=true) | |
Constructor for QgsSnappingUtils. | |
~QgsSnappingUtils () override | |
void | addExtraSnapLayer (QgsVectorLayer *vl) |
Supply an extra snapping layer (typically a memory layer). | |
QgsSnappingConfig | config () const |
The snapping configuration controls the behavior of this object. | |
QgsVectorLayer * | currentLayer () const |
The current layer used if mode is SnapCurrentLayer. | |
QString | dump () |
Gets extra information about the instance. | |
QSet< QgsVectorLayer * > | getExtraSnapLayers () |
Returns the list of extra snapping layers. | |
IndexingStrategy | indexingStrategy () const |
Find out which strategy is used for indexing - by default hybrid indexing is used. | |
QList< QgsSnappingUtils::LayerConfig > | layers () const |
Query layers used for snapping. | |
QgsPointLocator * | locatorForLayer (QgsVectorLayer *vl) |
Gets a point locator for the given layer. | |
QgsMapSettings | mapSettings () const |
void | removeExtraSnapLayer (QgsVectorLayer *vl) |
Removes an extra snapping layer. | |
void | setCurrentLayer (QgsVectorLayer *layer) |
Sets current layer so that if mode is SnapCurrentLayer we know which layer to use. | |
void | setEnableSnappingForInvisibleFeature (bool enable) |
Set if invisible features must be snapped or not. | |
void | setIndexingStrategy (IndexingStrategy strategy) |
Sets a strategy for indexing geometry data - determines how fast and memory consuming the data structures will be. | |
void | setMapSettings (const QgsMapSettings &settings) |
Assign current map settings to the utils - used for conversion between screen coords to map coords. | |
QgsPointLocator::Match | snapToCurrentLayer (QPoint point, QgsPointLocator::Types type, QgsPointLocator::MatchFilter *filter=nullptr) |
Snap to current layer. | |
QgsPointLocator::Match | snapToMap (const QgsPointXY &pointMap, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Snap to map according to the current configuration. | |
QgsPointLocator::Match | snapToMap (QPoint point, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Snap to map according to the current configuration. | |
Protected Member Functions | |
void | clearAllLocators () |
Deletes all existing locators (e.g. when destination CRS has changed and we need to reindex) | |
virtual void | prepareIndexProgress (int index) |
Called when finished indexing a layer with snapToMap. When index == count the indexing is complete. | |
virtual void | prepareIndexStarting (int count) |
Called when starting to index with snapToMap - can be overridden and e.g. progress dialog can be provided. | |
Properties | |
QgsSnappingConfig | config |
This class has all the configuration of snapping and can return answers to snapping queries.
Internally, it keeps a cache of QgsPointLocator instances for multiple layers.
Currently it supports the following queries:
For more complex queries it is possible to use locatorForLayer() method that returns point locator instance with layer's indexed data.
Indexing strategy determines how fast the queries will be and how much memory will be used.
When working with map canvas, it may be useful to use derived class QgsMapCanvasSnappingUtils which keeps the configuration in sync with map canvas (e.g. current view, active layer).
Definition at line 49 of file qgssnappingutils.h.
Definition at line 105 of file qgssnappingutils.h.
QgsSnappingUtils::QgsSnappingUtils | ( | QObject * | parent = nullptr , |
bool | enableSnappingForInvisibleFeature = true |
||
) |
Constructor for QgsSnappingUtils.
parent | parent object |
enableSnappingForInvisibleFeature | true if we want to snap feature even if there are not visible |
Definition at line 24 of file qgssnappingutils.cpp.
|
override |
Definition at line 31 of file qgssnappingutils.cpp.
|
inline |
Supply an extra snapping layer (typically a memory layer).
This can be used by map tools to provide additional snappings points.
Definition at line 200 of file qgssnappingutils.h.
|
protected |
Deletes all existing locators (e.g. when destination CRS has changed and we need to reindex)
Definition at line 51 of file qgssnappingutils.cpp.
QgsSnappingConfig QgsSnappingUtils::config | ( | ) | const |
The snapping configuration controls the behavior of this object.
Definition at line 541 of file qgssnappingutils.cpp.
|
signal |
Emitted when the snapping settings object changes.
|
inline |
The current layer used if mode is SnapCurrentLayer.
Definition at line 101 of file qgssnappingutils.h.
QString QgsSnappingUtils::dump | ( | ) |
Gets extra information about the instance.
Definition at line 602 of file qgssnappingutils.cpp.
|
inline |
Returns the list of extra snapping layers.
Definition at line 226 of file qgssnappingutils.h.
|
inline |
Find out which strategy is used for indexing - by default hybrid indexing is used.
Definition at line 116 of file qgssnappingutils.h.
|
inline |
Query layers used for snapping.
Definition at line 169 of file qgssnappingutils.h.
QgsPointLocator * QgsSnappingUtils::locatorForLayer | ( | QgsVectorLayer * | vl | ) |
Gets a point locator for the given layer.
If such locator does not exist, it will be created
vl | the vector layer |
Definition at line 37 of file qgssnappingutils.cpp.
|
inline |
Definition at line 96 of file qgssnappingutils.h.
|
inlineprotectedvirtual |
Called when finished indexing a layer with snapToMap. When index == count the indexing is complete.
Reimplemented in QgsMapCanvasSnappingUtils.
Definition at line 257 of file qgssnappingutils.h.
|
inlineprotectedvirtual |
Called when starting to index with snapToMap - can be overridden and e.g. progress dialog can be provided.
Reimplemented in QgsMapCanvasSnappingUtils.
Definition at line 255 of file qgssnappingutils.h.
|
inline |
|
slot |
The snapping configuration controls the behavior of this object.
Definition at line 551 of file qgssnappingutils.cpp.
void QgsSnappingUtils::setCurrentLayer | ( | QgsVectorLayer * | layer | ) |
Sets current layer so that if mode is SnapCurrentLayer we know which layer to use.
Definition at line 597 of file qgssnappingutils.cpp.
void QgsSnappingUtils::setEnableSnappingForInvisibleFeature | ( | bool | enable | ) |
Set if invisible features must be snapped or not.
enable | Enable or not this feature |
Definition at line 546 of file qgssnappingutils.cpp.
|
inline |
Sets a strategy for indexing geometry data - determines how fast and memory consuming the data structures will be.
Definition at line 114 of file qgssnappingutils.h.
void QgsSnappingUtils::setMapSettings | ( | const QgsMapSettings & | settings | ) |
Assign current map settings to the utils - used for conversion between screen coords to map coords.
Definition at line 587 of file qgssnappingutils.cpp.
QgsPointLocator::Match QgsSnappingUtils::snapToCurrentLayer | ( | QPoint | point, |
QgsPointLocator::Types | type, | ||
QgsPointLocator::MatchFilter * | filter = nullptr |
||
) |
Snap to current layer.
Definition at line 570 of file qgssnappingutils.cpp.
QgsPointLocator::Match QgsSnappingUtils::snapToMap | ( | const QgsPointXY & | pointMap, |
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Snap to map according to the current configuration.
pointMap | point in map coordinates |
filter | allows discarding unwanted matches. |
relaxed | true if this method is non blocking and the matching result can be invalid while indexing |
Definition at line 268 of file qgssnappingutils.cpp.
QgsPointLocator::Match QgsSnappingUtils::snapToMap | ( | QPoint | point, |
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Snap to map according to the current configuration.
point | point in canvas coordinates |
filter | allows discarding unwanted matches. |
relaxed | true if this method is non blocking and the matching result can be invalid while indexing |
Definition at line 257 of file qgssnappingutils.cpp.
|
slot |
Toggles the state of snapping.
Definition at line 564 of file qgssnappingutils.cpp.
|
readwrite |
Definition at line 53 of file qgssnappingutils.h.