16#ifndef QGSSNAPPINGUTILS_H
17#define QGSSNAPPINGUTILS_H
161 QList<QgsSnappingUtils::LayerConfig>
layers()
const {
return mLayers; }
180 void setEnableSnappingForInvisibleFeature(
bool enable );
226 void toggleEnabled();
242 void clearAllLocators();
247 void onInitFinished(
bool ok );
250 void onIndividualLayerSettingsChanged(
const QHash<QgsVectorLayer *, QgsSnappingConfig::IndividualLayerSettings> &layerSettings );
259 typedef QPair< QgsVectorLayer *, QgsRectangle > LayerAndAreaOfInterest;
264 void prepareIndex(
const QList<LayerAndAreaOfInterest> &layers,
bool relaxed );
274 IndexingStrategy mStrategy = IndexHybrid;
275 QList<LayerConfig> mLayers;
278 typedef QMap<QgsVectorLayer *, QgsPointLocator *> LocatorsMap;
280 LocatorsMap mLocators;
282 LocatorsMap mTemporaryLocators;
284 QSet<QString> mHybridNonindexableLayers;
286 QSet<QgsVectorLayer *> mExtraSnapLayers;
300 QHash<QString, double> mHybridMaxAreaPerLayer;
302 int mHybridPerLayerFeatureLimit = 50000;
305 bool mEnableSnappingForInvisibleFeature =
true;
MapToolUnit
Type of unit of tolerance value from settings.
Represents a coordinate reference system (CRS).
Contains configuration for rendering maps.
Defines the interface for querying point locations.
A rectangle specified with double values.
Stores configuration of snapping settings for the project.
QgsPointLocator::Match snapToCurrentLayer(QPoint point, QgsPointLocator::Types type, QgsPointLocator::MatchFilter *filter=nullptr)
Snap to current layer.
void setMapSettings(const QgsMapSettings &settings)
Assign current map settings to the utils - used for conversion between screen coords to map coords.
friend class TestQgsSnappingUtils
@ IndexAlwaysFull
For all layers build index of full extent. Uses more memory, but queries are faster.
@ IndexHybrid
For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and mem...
@ IndexExtent
For all layer build index of extent given in map settings.
@ IndexNeverFull
For all layers only create temporary indexes of small extent. Low memory usage, slower queries.
QgsMapSettings mapSettings() const
QgsPointLocator * locatorForLayer(QgsVectorLayer *vl)
Gets a point locator for the given layer.
QSet< QgsVectorLayer * > getExtraSnapLayers()
Returns the list of extra snapping layers.
void addExtraSnapLayer(QgsVectorLayer *vl)
Supply an extra snapping layer (typically a memory layer).
virtual void prepareIndexProgress(int index)
Called when finished indexing a layer with snapToMap. When index == count the indexing is complete.
IndexingStrategy indexingStrategy() const
Find out which strategy is used for indexing - by default hybrid indexing is used.
void configChanged(const QgsSnappingConfig &snappingConfig)
Emitted when the snapping settings object changes.
void removeExtraSnapLayer(QgsVectorLayer *vl)
Removes an extra snapping layer.
void setIndexingStrategy(IndexingStrategy strategy)
Sets a strategy for indexing geometry data - determines how fast and memory consuming the data struct...
QgsVectorLayer * currentLayer() const
The current layer used if mode is SnapCurrentLayer.
QgsPointLocator::Match snapToMap(QPoint point, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false)
Snap to map according to the current configuration.
QgsSnappingUtils(QObject *parent=nullptr, bool enableSnappingForInvisibleFeature=true)
Constructor for QgsSnappingUtils.
void setConfig(const QgsSnappingConfig &snappingConfig)
The snapping configuration controls the behavior of this object.
QList< QgsSnappingUtils::LayerConfig > layers() const
Query layers used for snapping.
virtual void prepareIndexStarting(int count)
Called when starting to index with snapToMap - can be overridden and e.g. progress dialog can be prov...
Represents a vector layer which manages a vector based dataset.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Interface that allows rejection of some matches in intersection queries (e.g.
Configures how a certain layer should be handled in a snapping operation.
bool operator!=(const QgsSnappingUtils::LayerConfig &other) const
double tolerance
The range around snapping targets in which snapping should occur.
LayerConfig(QgsVectorLayer *l, QgsPointLocator::Types t, double tol, Qgis::MapToolUnit u)
Create a new configuration for a snapping layer.
QgsPointLocator::Types type
To which geometry properties of this layers a snapping should happen.
QgsVectorLayer * layer
The layer to configure.
Qgis::MapToolUnit unit
The units in which the tolerance is specified.
bool operator==(const QgsSnappingUtils::LayerConfig &other) const