QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Public Slots | Public Member Functions | Protected Member Functions | List of all members
QgsSnappingUtils Class Reference

This class has all the configuration of snapping and can return answers to snapping queries. More...

#include <qgssnappingutils.h>

Inheritance diagram for QgsSnappingUtils:
Inheritance graph
[legend]

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 ()
QgsVectorLayercurrentLayer () 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< LayerConfiglayers () const
 Query layers used for snapping.
QgsPointLocatorlocatorForLayer (QgsVectorLayer *vl)
 get a point locator for the given layer.
const QgsMapSettingsmapSettings () 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.

Detailed Description

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

Note
added in 2.8

Definition at line 41 of file qgssnappingutils.h.

Member Enumeration Documentation

Enumerator:
IndexAlwaysFull 

For all layers build index of full extent. Uses more memory, but queries are faster.

IndexNeverFull 

For all layers only create temporary indexes of small extent. Low memory usage, slower queries.

IndexHybrid 

For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and memory usage.

Definition at line 86 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 74 of file qgssnappingutils.h.

Constructor & Destructor Documentation

QgsSnappingUtils::QgsSnappingUtils ( QObject *  parent = 0)

Definition at line 24 of file qgssnappingutils.cpp.

QgsSnappingUtils::~QgsSnappingUtils ( )

Definition at line 37 of file qgssnappingutils.cpp.

Member Function Documentation

QgsVectorLayer* QgsSnappingUtils::currentLayer ( ) const
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.

IndexingStrategy QgsSnappingUtils::indexingStrategy ( ) const
inline

Find out which strategy is used for indexing - by default hybrid indexing is used.

Definition at line 96 of file qgssnappingutils.h.

QList<LayerConfig> QgsSnappingUtils::layers ( ) const
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.

const QgsMapSettings& QgsSnappingUtils::mapSettings ( ) const
inline

Definition at line 64 of file qgssnappingutils.h.

virtual void QgsSnappingUtils::prepareIndexProgress ( int  index)
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.

virtual void QgsSnappingUtils::prepareIndexStarting ( int  count)
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.

void QgsSnappingUtils::readConfigFromProject ( )
slot

Read snapping configuration from the project.

Definition at line 386 of file qgssnappingutils.cpp.

void QgsSnappingUtils::setCurrentLayer ( QgsVectorLayer layer)
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.

void QgsSnappingUtils::setIndexingStrategy ( IndexingStrategy  strategy)
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.

void QgsSnappingUtils::setLayers ( const QList< LayerConfig > &  layers)
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.

void QgsSnappingUtils::setSnapOnIntersections ( bool  enabled)
inline

Set whether to consider intersections of nearby segments for snapping.

Definition at line 119 of file qgssnappingutils.h.

void QgsSnappingUtils::setSnapToMapMode ( SnapToMapMode  mode)
inline

Set how the snapping to map is done.

Definition at line 82 of file qgssnappingutils.h.

bool QgsSnappingUtils::snapOnIntersections ( ) const
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.

SnapToMapMode QgsSnappingUtils::snapToMapMode ( ) const
inline

Find out how the snapping to map is done.

Definition at line 84 of file qgssnappingutils.h.


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