QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
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 } |
enum | SnapToMapMode { SnapCurrentLayer, SnapAllLayers, SnapAdvanced } |
modes for "snap to background" More... | |
Public Slots | |
void | readConfigFromProject () |
Read snapping configuration from the project. More... | |
Signals | |
void | configChanged () |
Emitted when snapping configuration has been changed. More... | |
Public Member Functions | |
QgsSnappingUtils (QObject *parent=nullptr) | |
~QgsSnappingUtils () | |
QgsVectorLayer * | currentLayer () const |
The current layer used if mode is SnapCurrentLayer. More... | |
void | defaultSettings (int &type, double &tolerance, QgsTolerance::UnitType &unit) |
Query options used when the mode is snap to current layer or to all layers. More... | |
QString | dump () |
Get extra information about the instance. More... | |
IndexingStrategy | indexingStrategy () const |
Find out which strategy is used for indexing - by default hybrid indexing is used. More... | |
QList< LayerConfig > | layers () const |
Query layers used for snapping. More... | |
QgsPointLocator * | locatorForLayer (QgsVectorLayer *vl) |
Get a point locator for the given layer. More... | |
const QgsMapSettings & | mapSettings () const |
void | setCurrentLayer (QgsVectorLayer *layer) |
Set current layer so that if mode is SnapCurrentLayer we know which layer to use. More... | |
void | setDefaultSettings (int type, double tolerance, QgsTolerance::UnitType unit) |
Configure options used when the mode is snap to current layer or to all layers. More... | |
void | setIndexingStrategy (IndexingStrategy strategy) |
Set a strategy for indexing geometry data - determines how fast and memory consuming the data structures will be. More... | |
void | setLayers (const QList< LayerConfig > &layers) |
Set layers which will be used for snapping. More... | |
void | setMapSettings (const QgsMapSettings &settings) |
Assign current map settings to the utils - used for conversion between screen coords to map coords. More... | |
void | setSnapOnIntersections (bool enabled) |
Set whether to consider intersections of nearby segments for snapping. More... | |
void | setSnapToMapMode (SnapToMapMode mode) |
Set how the snapping to map is done. More... | |
bool | snapOnIntersections () const |
Query whether to consider intersections of nearby segments for snapping. More... | |
QgsPointLocator::Match | snapToCurrentLayer (QPoint point, int type, QgsPointLocator::MatchFilter *filter=nullptr) |
Snap to current layer. More... | |
QgsPointLocator::Match | snapToMap (QPoint point, QgsPointLocator::MatchFilter *filter=nullptr) |
Snap to map according to the current configuration (mode). More... | |
QgsPointLocator::Match | snapToMap (const QgsPoint &pointMap, QgsPointLocator::MatchFilter *filter=nullptr) |
SnapToMapMode | snapToMapMode () const |
Find out how the snapping to map is done. More... | |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Protected Member Functions | |
virtual void | prepareIndexProgress (int index) |
Called when finished indexing a layer. When index == count the indexing is complete. More... | |
virtual void | prepareIndexStarting (int count) |
Called when starting to index - can be overridden and e.g. progress dialog can be provided. More... | |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Additional Inherited Members | |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Properties inherited from QObject | |
objectName | |
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:
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 41 of file qgssnappingutils.h.
Definition at line 87 of file qgssnappingutils.h.
modes for "snap to background"
Enumerator | |
---|---|
SnapCurrentLayer | snap just to current layer (tolerance and type from defaultSettings()) |
SnapAllLayers | snap to all rendered layers (tolerance and type from defaultSettings()) |
SnapAdvanced | snap according to the configuration set in setLayers() |
Definition at line 75 of file qgssnappingutils.h.
QgsSnappingUtils::QgsSnappingUtils | ( | QObject * | parent = nullptr | ) |
Definition at line 24 of file qgssnappingutils.cpp.
QgsSnappingUtils::~QgsSnappingUtils | ( | ) |
Definition at line 39 of file qgssnappingutils.cpp.
|
signal |
Emitted when snapping configuration has been changed.
|
inline |
The current layer used if mode is SnapCurrentLayer.
Definition at line 69 of file qgssnappingutils.h.
void QgsSnappingUtils::defaultSettings | ( | int & | type, |
double & | tolerance, | ||
QgsTolerance::UnitType & | unit | ||
) |
Query options used when the mode is snap to current layer or to all layers.
Definition at line 476 of file qgssnappingutils.cpp.
QString QgsSnappingUtils::dump | ( | ) |
Get extra information about the instance.
Definition at line 502 of file qgssnappingutils.cpp.
|
inline |
Find out which strategy is used for indexing - by default hybrid indexing is used.
Definition at line 98 of file qgssnappingutils.h.
|
inline |
Query layers used for snapping.
Definition at line 157 of file qgssnappingutils.h.
QgsPointLocator * QgsSnappingUtils::locatorForLayer | ( | QgsVectorLayer * | vl | ) |
Get a point locator for the given layer.
If such locator does not exist, it will be created
Definition at line 45 of file qgssnappingutils.cpp.
|
inline |
Definition at line 64 of file qgssnappingutils.h.
|
inlineprotectedvirtual |
Called when finished indexing a layer. When index == count the indexing is complete.
Reimplemented in QgsMapCanvasSnappingUtils.
Definition at line 183 of file qgssnappingutils.h.
|
inlineprotectedvirtual |
Called when starting to index - can be overridden and e.g. progress dialog can be provided.
Reimplemented in QgsMapCanvasSnappingUtils.
Definition at line 181 of file qgssnappingutils.h.
|
slot |
Read snapping configuration from the project.
Definition at line 589 of file qgssnappingutils.cpp.
void QgsSnappingUtils::setCurrentLayer | ( | QgsVectorLayer * | layer | ) |
Set current layer so that if mode is SnapCurrentLayer we know which layer to use.
Definition at line 445 of file qgssnappingutils.cpp.
void QgsSnappingUtils::setDefaultSettings | ( | int | type, |
double | tolerance, | ||
QgsTolerance::UnitType | unit | ||
) |
Configure options used when the mode is snap to current layer or to all layers.
Definition at line 459 of file qgssnappingutils.cpp.
|
inline |
Set a strategy for indexing geometry data - determines how fast and memory consuming the data structures will be.
Definition at line 96 of file qgssnappingutils.h.
void QgsSnappingUtils::setLayers | ( | const QList< LayerConfig > & | layers | ) |
Set layers which will be used for snapping.
Definition at line 483 of file qgssnappingutils.cpp.
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 435 of file qgssnappingutils.cpp.
void QgsSnappingUtils::setSnapOnIntersections | ( | bool | enabled | ) |
Set whether to consider intersections of nearby segments for snapping.
Definition at line 493 of file qgssnappingutils.cpp.
void QgsSnappingUtils::setSnapToMapMode | ( | QgsSnappingUtils::SnapToMapMode | mode | ) |
Set how the snapping to map is done.
Definition at line 450 of file qgssnappingutils.cpp.
|
inline |
Query whether to consider intersections of nearby segments for snapping.
Definition at line 162 of file qgssnappingutils.h.
QgsPointLocator::Match QgsSnappingUtils::snapToCurrentLayer | ( | QPoint | point, |
int | type, | ||
QgsPointLocator::MatchFilter * | filter = nullptr |
||
) |
Snap to current layer.
Definition at line 418 of file qgssnappingutils.cpp.
QgsPointLocator::Match QgsSnappingUtils::snapToMap | ( | QPoint | point, |
QgsPointLocator::MatchFilter * | filter = nullptr |
||
) |
Snap to map according to the current configuration (mode).
Optional filter allows discarding unwanted matches.
Definition at line 208 of file qgssnappingutils.cpp.
QgsPointLocator::Match QgsSnappingUtils::snapToMap | ( | const QgsPoint & | pointMap, |
QgsPointLocator::MatchFilter * | filter = nullptr |
||
) |
Definition at line 219 of file qgssnappingutils.cpp.
|
inline |
Find out how the snapping to map is done.
Definition at line 85 of file qgssnappingutils.h.