QGIS API Documentation  3.4.3-Madeira (2f64a3c)
Classes | Public Types | Public Member Functions | Properties | List of all members
QgsSnappingConfig Class Reference

This is a container for configuration of the snapping of the project. More...

#include <qgssnappingconfig.h>

Classes

class  IndividualLayerSettings
 This is a container of advanced configuration (per layer) of the snapping of the project. More...
 

Public Types

enum  SnappingMode { ActiveLayer = 1, AllLayers = 2, AdvancedConfiguration = 3 }
 SnappingMode defines on which layer the snapping is performed. More...
 
enum  SnappingType { Vertex = 1, VertexAndSegment = 2, Segment = 3 }
 SnappingType defines on what object the snapping is performed. More...
 

Public Member Functions

 QgsSnappingConfig (QgsProject *project=nullptr)
 Constructor with default parameters defined in global settings. More...
 
bool addLayers (const QList< QgsMapLayer *> &layers)
 Adds the specified layers as individual layers to the configuration with standard configuration. More...
 
bool enabled () const
 Returns if snapping is enabled. More...
 
QHash< QgsVectorLayer *, QgsSnappingConfig::IndividualLayerSettingsindividualLayerSettings () const
 Returns individual snapping settings for all layers. More...
 
QgsSnappingConfig::IndividualLayerSettings individualLayerSettings (QgsVectorLayer *vl) const
 Returns individual layer snappings settings (applied if mode is AdvancedConfiguration) More...
 
bool intersectionSnapping () const
 Returns if the snapping on intersection is enabled. More...
 
SnappingMode mode () const
 Returns the mode (all layers, active layer, per layer settings) More...
 
bool operator!= (const QgsSnappingConfig &other) const
 Compare this configuration to other. More...
 
bool operator== (const QgsSnappingConfig &other) const
 
QgsProjectproject () const
 The project from which the snapped layers should be retrieved. More...
 
void readProject (const QDomDocument &doc)
 Reads the configuration from the specified QGIS project document. More...
 
bool removeLayers (const QList< QgsMapLayer *> &layers)
 Removes the specified layers from the individual layer configuration. More...
 
void reset ()
 reset to default values More...
 
void setEnabled (bool enabled)
 enables the snapping More...
 
void setIndividualLayerSettings (QgsVectorLayer *vl, const QgsSnappingConfig::IndividualLayerSettings &individualLayerSettings)
 Sets individual layer snappings settings (applied if mode is AdvancedConfiguration) More...
 
void setIntersectionSnapping (bool enabled)
 Sets if the snapping on intersection is enabled. More...
 
void setMode (SnappingMode mode)
 define the mode of snapping More...
 
void setProject (QgsProject *project)
 The project from which the snapped layers should be retrieved. More...
 
void setTolerance (double tolerance)
 Sets the tolerance. More...
 
void setType (SnappingType type)
 define the type of snapping More...
 
void setUnits (QgsTolerance::UnitType units)
 Sets the type of units. More...
 
double tolerance () const
 Returns the tolerance. More...
 
SnappingType type () const
 Returns the type (vertices and/or segments) More...
 
QgsTolerance::UnitType units () const
 Returns the type of units. More...
 
void writeProject (QDomDocument &doc)
 Writes the configuration to the specified QGIS project document. More...
 

Properties

QgsProject project
 

Detailed Description

This is a container for configuration of the snapping of the project.

Since
QGIS 3.0

Definition at line 34 of file qgssnappingconfig.h.

Member Enumeration Documentation

◆ SnappingMode

SnappingMode defines on which layer the snapping is performed.

Enumerator
ActiveLayer 

On the active layer.

AllLayers 

On all vector layers.

AdvancedConfiguration 

On a per layer configuration basis.

Definition at line 45 of file qgssnappingconfig.h.

◆ SnappingType

SnappingType defines on what object the snapping is performed.

Enumerator
Vertex 

On vertices only.

VertexAndSegment 

Both on vertices and segments.

Segment 

On segments only.

Definition at line 56 of file qgssnappingconfig.h.

Constructor & Destructor Documentation

◆ QgsSnappingConfig()

QgsSnappingConfig::QgsSnappingConfig ( QgsProject project = nullptr)
explicit

Constructor with default parameters defined in global settings.

Definition at line 99 of file qgssnappingconfig.cpp.

Member Function Documentation

◆ addLayers()

bool QgsSnappingConfig::addLayers ( const QList< QgsMapLayer *> &  layers)

Adds the specified layers as individual layers to the configuration with standard configuration.

When implementing a long-living QgsSnappingConfig (like the one in QgsProject) it is best to directly feed this with information from the layer registry.

Returns
True if changes have been done.
Since
QGIS 3.0

Definition at line 367 of file qgssnappingconfig.cpp.

◆ enabled()

bool QgsSnappingConfig::enabled ( ) const

Returns if snapping is enabled.

Definition at line 160 of file qgssnappingconfig.cpp.

◆ individualLayerSettings() [1/2]

QHash< QgsVectorLayer *, QgsSnappingConfig::IndividualLayerSettings > QgsSnappingConfig::individualLayerSettings ( ) const

Returns individual snapping settings for all layers.

Definition at line 240 of file qgssnappingconfig.cpp.

◆ individualLayerSettings() [2/2]

QgsSnappingConfig::IndividualLayerSettings QgsSnappingConfig::individualLayerSettings ( QgsVectorLayer vl) const

Returns individual layer snappings settings (applied if mode is AdvancedConfiguration)

Definition at line 245 of file qgssnappingconfig.cpp.

◆ intersectionSnapping()

bool QgsSnappingConfig::intersectionSnapping ( ) const

Returns if the snapping on intersection is enabled.

Definition at line 230 of file qgssnappingconfig.cpp.

◆ mode()

QgsSnappingConfig::SnappingMode QgsSnappingConfig::mode ( ) const

Returns the mode (all layers, active layer, per layer settings)

Definition at line 174 of file qgssnappingconfig.cpp.

◆ operator!=()

bool QgsSnappingConfig::operator!= ( const QgsSnappingConfig other) const

Compare this configuration to other.

Definition at line 267 of file qgssnappingconfig.cpp.

◆ operator==()

bool QgsSnappingConfig::operator== ( const QgsSnappingConfig other) const

Definition at line 106 of file qgssnappingconfig.cpp.

◆ project()

QgsProject* QgsSnappingConfig::project ( ) const

The project from which the snapped layers should be retrieved.

Since
QGIS 3.0

◆ readProject()

void QgsSnappingConfig::readProject ( const QDomDocument &  doc)

Reads the configuration from the specified QGIS project document.

Since
QGIS 3.0

Definition at line 277 of file qgssnappingconfig.cpp.

◆ removeLayers()

bool QgsSnappingConfig::removeLayers ( const QList< QgsMapLayer *> &  layers)

Removes the specified layers from the individual layer configuration.

When implementing a long-living QgsSnappingConfig (like the one in QgsProject) it is best to directly feed this with information from the layer registry.

Returns
True if changes have been done.
Since
QGIS 3.0

Definition at line 387 of file qgssnappingconfig.cpp.

◆ reset()

void QgsSnappingConfig::reset ( )

reset to default values

Definition at line 117 of file qgssnappingconfig.cpp.

◆ setEnabled()

void QgsSnappingConfig::setEnabled ( bool  enabled)

enables the snapping

Definition at line 165 of file qgssnappingconfig.cpp.

◆ setIndividualLayerSettings()

void QgsSnappingConfig::setIndividualLayerSettings ( QgsVectorLayer vl,
const QgsSnappingConfig::IndividualLayerSettings individualLayerSettings 
)

Sets individual layer snappings settings (applied if mode is AdvancedConfiguration)

Definition at line 258 of file qgssnappingconfig.cpp.

◆ setIntersectionSnapping()

void QgsSnappingConfig::setIntersectionSnapping ( bool  enabled)

Sets if the snapping on intersection is enabled.

Definition at line 235 of file qgssnappingconfig.cpp.

◆ setMode()

void QgsSnappingConfig::setMode ( QgsSnappingConfig::SnappingMode  mode)

define the mode of snapping

Definition at line 179 of file qgssnappingconfig.cpp.

◆ setProject()

void QgsSnappingConfig::setProject ( QgsProject project)

The project from which the snapped layers should be retrieved.

Since
QGIS 3.0

Definition at line 476 of file qgssnappingconfig.cpp.

◆ setTolerance()

void QgsSnappingConfig::setTolerance ( double  tolerance)

Sets the tolerance.

Definition at line 207 of file qgssnappingconfig.cpp.

◆ setType()

void QgsSnappingConfig::setType ( QgsSnappingConfig::SnappingType  type)

define the type of snapping

Definition at line 193 of file qgssnappingconfig.cpp.

◆ setUnits()

void QgsSnappingConfig::setUnits ( QgsTolerance::UnitType  units)

Sets the type of units.

Definition at line 221 of file qgssnappingconfig.cpp.

◆ tolerance()

double QgsSnappingConfig::tolerance ( ) const

Returns the tolerance.

Definition at line 202 of file qgssnappingconfig.cpp.

◆ type()

QgsSnappingConfig::SnappingType QgsSnappingConfig::type ( ) const

Returns the type (vertices and/or segments)

Definition at line 188 of file qgssnappingconfig.cpp.

◆ units()

QgsTolerance::UnitType QgsSnappingConfig::units ( ) const

Returns the type of units.

Definition at line 216 of file qgssnappingconfig.cpp.

◆ writeProject()

void QgsSnappingConfig::writeProject ( QDomDocument &  doc)

Writes the configuration to the specified QGIS project document.

Since
QGIS 3.0

Definition at line 338 of file qgssnappingconfig.cpp.

Property Documentation

◆ project

QgsProject * QgsSnappingConfig::project
readwrite

Definition at line 38 of file qgssnappingconfig.h.


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