QGIS API Documentation
2.8.2-Wien
|
This class has all the configuration of snapping and can return answers to snapping queries. More...
#include <qgssnappingutils.h>
Classes | |
struct | LayerConfig |
Public Types | |
enum | IndexingStrategy { IndexAlwaysFull, IndexNeverFull, IndexHybrid } |
enum | SnapToMapMode { SnapCurrentLayer, SnapAllLayers, SnapAdvanced } |
modes for "snap to background" More... |
Public Slots | |
void | readConfigFromProject () |
Read snapping configuration from the project. |
Public Member Functions | |
QgsSnappingUtils (QObject *parent=0) | |
~QgsSnappingUtils () | |
QgsVectorLayer * | currentLayer () const |
void | defaultSettings (int &type, double &tolerance, QgsTolerance::UnitType &unit) |
query options used when the mode is snap to current layer | |
IndexingStrategy | indexingStrategy () const |
Find out which strategy is used for indexing - by default hybrid indexing is used. | |
QList< LayerConfig > | layers () const |
Query layers used for snapping. | |
QgsPointLocator * | locatorForLayer (QgsVectorLayer *vl) |
get a point locator for the given layer. | |
const QgsMapSettings & | mapSettings () const |
void | setCurrentLayer (QgsVectorLayer *layer) |
set current layer so that if mode is SnapCurrentLayer we know which layer to use | |
void | setDefaultSettings (int type, double tolerance, QgsTolerance::UnitType unit) |
configure options used when the mode is snap to current layer | |
void | setIndexingStrategy (IndexingStrategy strategy) |
Set a strategy for indexing geometry data - determines how fast and memory consuming the data structures will be. | |
void | setLayers (const QList< LayerConfig > &layers) |
Set layers which will be used for snapping. | |
void | setMapSettings (const QgsMapSettings &settings) |
assign current map settings to the utils - used for conversion between screen coords to map coords | |
void | setSnapOnIntersections (bool enabled) |
Set whether to consider intersections of nearby segments for snapping. | |
void | setSnapToMapMode (SnapToMapMode mode) |
Set how the snapping to map is done. | |
bool | snapOnIntersections () const |
Query whether to consider intersections of nearby segments for snapping. | |
QgsPointLocator::Match | snapToCurrentLayer (const QPoint &point, int type, QgsPointLocator::MatchFilter *filter=0) |
snap to current layer | |
QgsPointLocator::Match | snapToMap (const QPoint &point, QgsPointLocator::MatchFilter *filter=0) |
snap to map according to the current configuration (mode). | |
QgsPointLocator::Match | snapToMap (const QgsPoint &pointMap, QgsPointLocator::MatchFilter *filter=0) |
SnapToMapMode | snapToMapMode () const |
Find out how the snapping to map is done. |
Protected Member Functions | |
virtual void | prepareIndexProgress (int index) |
Called when finished indexing a layer. When index == count the indexing is complete. | |
virtual void | prepareIndexStarting (int count) |
Called when starting to index - can be overridden and e.g. progress dialog can be provided. |
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 86 of file qgssnappingutils.h.
modes for "snap to background"
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 74 of file qgssnappingutils.h.
QgsSnappingUtils::QgsSnappingUtils | ( | QObject * | parent = 0 | ) |
Definition at line 24 of file qgssnappingutils.cpp.
QgsSnappingUtils::~QgsSnappingUtils | ( | ) |
Definition at line 37 of file qgssnappingutils.cpp.
|
inline |
Definition at line 68 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
Definition at line 373 of file qgssnappingutils.cpp.
|
inline |
Find out which strategy is used for indexing - by default hybrid indexing is used.
Definition at line 96 of file qgssnappingutils.h.
|
inline |
Query layers used for snapping.
Definition at line 116 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 43 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 131 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 129 of file qgssnappingutils.h.
|
slot |
Read snapping configuration from the project.
Definition at line 386 of file qgssnappingutils.cpp.
|
inline |
set current layer so that if mode is SnapCurrentLayer we know which layer to use
Definition at line 67 of file qgssnappingutils.h.
void QgsSnappingUtils::setDefaultSettings | ( | int | type, |
double | tolerance, | ||
QgsTolerance::UnitType | unit | ||
) |
configure options used when the mode is snap to current layer
Definition at line 362 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 94 of file qgssnappingutils.h.
|
inline |
Set layers which will be used for snapping.
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 352 of file qgssnappingutils.cpp.
|
inline |
Set whether to consider intersections of nearby segments for snapping.
Definition at line 119 of file qgssnappingutils.h.
|
inline |
Set how the snapping to map is done.
Definition at line 82 of file qgssnappingutils.h.
|
inline |
Query whether to consider intersections of nearby segments for snapping.
Definition at line 121 of file qgssnappingutils.h.
QgsPointLocator::Match QgsSnappingUtils::snapToCurrentLayer | ( | const QPoint & | point, |
int | type, | ||
QgsPointLocator::MatchFilter * | filter = 0 |
||
) |
snap to current layer
Definition at line 335 of file qgssnappingutils.cpp.
QgsPointLocator::Match QgsSnappingUtils::snapToMap | ( | const QPoint & | point, |
QgsPointLocator::MatchFilter * | filter = 0 |
||
) |
snap to map according to the current configuration (mode).
Optional filter allows to discard unwanted matches.
Definition at line 202 of file qgssnappingutils.cpp.
QgsPointLocator::Match QgsSnappingUtils::snapToMap | ( | const QgsPoint & | pointMap, |
QgsPointLocator::MatchFilter * | filter = 0 |
||
) |
Definition at line 207 of file qgssnappingutils.cpp.
|
inline |
Find out how the snapping to map is done.
Definition at line 84 of file qgssnappingutils.h.