QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 100 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 369 of file qgssnappingconfig.cpp.

◆ enabled()

bool QgsSnappingConfig::enabled ( ) const

Returns if snapping is enabled.

Definition at line 162 of file qgssnappingconfig.cpp.

◆ individualLayerSettings() [1/2]

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

Returns individual snapping settings for all layers.

Definition at line 242 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 247 of file qgssnappingconfig.cpp.

◆ intersectionSnapping()

bool QgsSnappingConfig::intersectionSnapping ( ) const

Returns if the snapping on intersection is enabled.

Definition at line 232 of file qgssnappingconfig.cpp.

◆ mode()

QgsSnappingConfig::SnappingMode QgsSnappingConfig::mode ( ) const

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

Definition at line 176 of file qgssnappingconfig.cpp.

◆ operator!=()

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

Compare this configuration to other.

Definition at line 269 of file qgssnappingconfig.cpp.

◆ operator==()

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

Definition at line 107 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 279 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 390 of file qgssnappingconfig.cpp.

◆ reset()

void QgsSnappingConfig::reset ( )

reset to default values

Definition at line 118 of file qgssnappingconfig.cpp.

◆ setEnabled()

void QgsSnappingConfig::setEnabled ( bool  enabled)

enables the snapping

Definition at line 167 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 260 of file qgssnappingconfig.cpp.

◆ setIntersectionSnapping()

void QgsSnappingConfig::setIntersectionSnapping ( bool  enabled)

Sets if the snapping on intersection is enabled.

Definition at line 237 of file qgssnappingconfig.cpp.

◆ setMode()

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

define the mode of snapping

Definition at line 181 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 480 of file qgssnappingconfig.cpp.

◆ setTolerance()

void QgsSnappingConfig::setTolerance ( double  tolerance)

Sets the tolerance.

Definition at line 209 of file qgssnappingconfig.cpp.

◆ setType()

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

define the type of snapping

Definition at line 195 of file qgssnappingconfig.cpp.

◆ setUnits()

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

Sets the type of units.

Definition at line 223 of file qgssnappingconfig.cpp.

◆ tolerance()

double QgsSnappingConfig::tolerance ( ) const

Returns the tolerance.

Definition at line 204 of file qgssnappingconfig.cpp.

◆ type()

QgsSnappingConfig::SnappingType QgsSnappingConfig::type ( ) const

Returns the type (vertices and/or segments)

Definition at line 190 of file qgssnappingconfig.cpp.

◆ units()

QgsTolerance::UnitType QgsSnappingConfig::units ( ) const

Returns the type of units.

Definition at line 218 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 340 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: