QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
Classes | Public Types | Public Member Functions | Static 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  ScaleDependencyMode { Disabled = 0, Global = 1, PerLayer = 2 }
 ScaleDependencyMode the scale dependency mode of snapping. More...
 
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...
 
enum  SnappingTypes {
  NoSnapFlag = 0, VertexFlag = 1, SegmentFlag = 2, AreaFlag = 4,
  CentroidFlag = 8, MiddleOfSegmentFlag = 16
}
 SnappingTypeFlag 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...
 
void clearIndividualLayerSettings ()
 Removes all individual layer snapping settings. 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...
 
double maximumScale () const
 Returns the max scale (i.e. More...
 
double minimumScale () const
 Returns the min scale (i.e. 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...
 
ScaleDependencyMode scaleDependencyMode () const
 Returns the scale dependency mode. More...
 
bool selfSnapping () const
 Returns if self snapping (snapping to the currently digitized feature) is enabled. 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 setMaximumScale (double maxScale)
 Set the max scale on which snapping is enabled, 0.0 disable scale limit. More...
 
void setMinimumScale (double minScale)
 Sets the min scale on which snapping is enabled, 0.0 disable scale limit. 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 setScaleDependencyMode (ScaleDependencyMode mode)
 Set the scale dependency mode. More...
 
void setSelfSnapping (bool enabled)
 Sets if self snapping (snapping to the currently digitized feature) is enabled. More...
 
void setTolerance (double tolerance)
 Sets the tolerance. More...
 
Q_DECL_DEPRECATED void setType (QgsSnappingConfig::SnappingType type)
 define the type of snapping More...
 
void setTypeFlag (QgsSnappingConfig::SnappingTypeFlag 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...
 
Q_DECL_DEPRECATED QgsSnappingConfig::SnappingType type () const
 Returns the flags type (vertices | segments | area | centroid | middle) More...
 
QgsSnappingConfig::SnappingTypeFlag typeFlag () const
 Returns the flags type (vertices | segments | area | centroid | middle) 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...
 

Static Public Member Functions

static const QString snappingTypeFlagToString (SnappingTypeFlag type)
 Convenient method to returns the translated name of the enum type QgsSnappingConfig::SnappingTypeFlag. More...
 

Properties

Q_GADGET QgsProjectproject
 

Detailed Description

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

Since
QGIS 3.0

Definition at line 33 of file qgssnappingconfig.h.

Member Enumeration Documentation

◆ ScaleDependencyMode

ScaleDependencyMode the scale dependency mode of snapping.

Since
QGIS 3.14
Enumerator
Disabled 

No scale dependency.

Global 

Scale dependency using global min max range.

PerLayer 

Scale dependency using min max range per layer.

Definition at line 87 of file qgssnappingconfig.h.

◆ 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 44 of file qgssnappingconfig.h.

◆ SnappingType

SnappingType defines on what object the snapping is performed.

Deprecated:
since QGIS 3.12 use SnappingTypeFlag instead.
Enumerator
Vertex 

On vertices only.

VertexAndSegment 

Both on vertices and segments.

Segment 

On segments only.

Definition at line 56 of file qgssnappingconfig.h.

◆ SnappingTypes

SnappingTypeFlag defines on what object the snapping is performed.

Since
QGIS 3.12
Enumerator
NoSnapFlag 

No snapping.

VertexFlag 

On vertices.

SegmentFlag 

On segments.

AreaFlag 

On Area.

CentroidFlag 

On centroid.

MiddleOfSegmentFlag 

On Middle segment.

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

◆ clearIndividualLayerSettings()

void QgsSnappingConfig::clearIndividualLayerSettings ( )

Removes all individual layer snapping settings.

Since
QGIS 3.16

Definition at line 376 of file qgssnappingconfig.cpp.

◆ enabled()

bool QgsSnappingConfig::enabled ( ) const

Returns if snapping is enabled.

Definition at line 240 of file qgssnappingconfig.cpp.

◆ individualLayerSettings() [1/2]

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

Returns individual snapping settings for all layers.

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

◆ intersectionSnapping()

bool QgsSnappingConfig::intersectionSnapping ( ) const

Returns if the snapping on intersection is enabled.

Definition at line 338 of file qgssnappingconfig.cpp.

◆ maximumScale()

double QgsSnappingConfig::maximumScale ( ) const

Returns the max scale (i.e.

most "zoomed in" scale)

Since
QGIS 3.14

Definition at line 682 of file qgssnappingconfig.cpp.

◆ minimumScale()

double QgsSnappingConfig::minimumScale ( ) const

Returns the min scale (i.e.

most "zoomed out" scale)

Since
QGIS 3.14

Definition at line 672 of file qgssnappingconfig.cpp.

◆ mode()

QgsSnappingConfig::SnappingMode QgsSnappingConfig::mode ( ) const

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

Definition at line 254 of file qgssnappingconfig.cpp.

◆ operator!=()

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

Compare this configuration to other.

Definition at line 390 of file qgssnappingconfig.cpp.

◆ operator==()

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

Definition at line 174 of file qgssnappingconfig.cpp.

◆ project()

QgsProject * QgsSnappingConfig::project ( ) const

The project from which the snapped layers should be retrieved.

Since
QGIS 3.0

Definition at line 659 of file qgssnappingconfig.cpp.

◆ readProject()

void QgsSnappingConfig::readProject ( const QDomDocument &  doc)

Reads the configuration from the specified QGIS project document.

Since
QGIS 3.0

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

◆ reset()

void QgsSnappingConfig::reset ( )

reset to default values

Definition at line 189 of file qgssnappingconfig.cpp.

◆ scaleDependencyMode()

QgsSnappingConfig::ScaleDependencyMode QgsSnappingConfig::scaleDependencyMode ( ) const

Returns the scale dependency mode.

Since
QGIS 3.14

Definition at line 697 of file qgssnappingconfig.cpp.

◆ selfSnapping()

bool QgsSnappingConfig::selfSnapping ( ) const

Returns if self snapping (snapping to the currently digitized feature) is enabled.

Since
QGIS 3.14

Definition at line 348 of file qgssnappingconfig.cpp.

◆ setEnabled()

void QgsSnappingConfig::setEnabled ( bool  enabled)

enables the snapping

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

◆ setIntersectionSnapping()

void QgsSnappingConfig::setIntersectionSnapping ( bool  enabled)

Sets if the snapping on intersection is enabled.

Definition at line 343 of file qgssnappingconfig.cpp.

◆ setMaximumScale()

void QgsSnappingConfig::setMaximumScale ( double  maxScale)

Set the max scale on which snapping is enabled, 0.0 disable scale limit.

Since
QGIS 3.14

Definition at line 687 of file qgssnappingconfig.cpp.

◆ setMinimumScale()

void QgsSnappingConfig::setMinimumScale ( double  minScale)

Sets the min scale on which snapping is enabled, 0.0 disable scale limit.

Since
QGIS 3.14

Definition at line 677 of file qgssnappingconfig.cpp.

◆ setMode()

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

define the mode of snapping

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

◆ setScaleDependencyMode()

void QgsSnappingConfig::setScaleDependencyMode ( QgsSnappingConfig::ScaleDependencyMode  mode)

Set the scale dependency mode.

Since
QGIS 3.14

Definition at line 692 of file qgssnappingconfig.cpp.

◆ setSelfSnapping()

void QgsSnappingConfig::setSelfSnapping ( bool  enabled)

Sets if self snapping (snapping to the currently digitized feature) is enabled.

Since
QGIS 3.14

Definition at line 353 of file qgssnappingconfig.cpp.

◆ setTolerance()

void QgsSnappingConfig::setTolerance ( double  tolerance)

Sets the tolerance.

Definition at line 315 of file qgssnappingconfig.cpp.

◆ setType()

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

define the type of snapping

Deprecated:
since QGIS 3.12 use setTypeFlag instead.

Definition at line 283 of file qgssnappingconfig.cpp.

◆ setTypeFlag()

void QgsSnappingConfig::setTypeFlag ( QgsSnappingConfig::SnappingTypeFlag  type)

define the type of snapping

Since
QGIS 3.12

Definition at line 301 of file qgssnappingconfig.cpp.

◆ setUnits()

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

Sets the type of units.

Definition at line 329 of file qgssnappingconfig.cpp.

◆ snappingTypeFlagToString()

static const QString QgsSnappingConfig::snappingTypeFlagToString ( SnappingTypeFlag  type)
inlinestatic

Convenient method to returns the translated name of the enum type QgsSnappingConfig::SnappingTypeFlag.

Since
QGIS 3.12

Definition at line 101 of file qgssnappingconfig.h.

◆ tolerance()

double QgsSnappingConfig::tolerance ( ) const

Returns the tolerance.

Definition at line 310 of file qgssnappingconfig.cpp.

◆ type()

QgsSnappingConfig::SnappingType QgsSnappingConfig::type ( ) const

Returns the flags type (vertices | segments | area | centroid | middle)

Deprecated:
since QGIS 3.12 use typeFlag instead.

Definition at line 273 of file qgssnappingconfig.cpp.

◆ typeFlag()

QgsSnappingConfig::SnappingTypeFlag QgsSnappingConfig::typeFlag ( ) const

Returns the flags type (vertices | segments | area | centroid | middle)

Since
QGIS 3.12

Definition at line 268 of file qgssnappingconfig.cpp.

◆ units()

QgsTolerance::UnitType QgsSnappingConfig::units ( ) const

Returns the type of units.

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

Property Documentation

◆ project

Q_GADGET QgsProject * QgsSnappingConfig::project
readwrite

Definition at line 35 of file qgssnappingconfig.h.


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