1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgssnappingutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsSnappingUtils : QObject
{
%Docstring(signature="appended")
This class has all the configuration of snapping and can return answers
to snapping queries.
Internally, it keeps a cache of :py:class:`QgsPointLocator` instances
for multiple layers.
Currently it supports the following queries:
- :py:func:`~snapToMap` - has multiple modes of operation
- :py:func:`~snapToCurrentLayer`
For more complex queries it is possible to use
:py:func:`~locatorForLayer` method that returns point locator instance
with layer's indexed data.
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
:py:class:`QgsMapCanvasSnappingUtils` which keeps the configuration in
sync with map canvas (e.g. current view, active layer).
%End
%TypeHeaderCode
#include "qgssnappingutils.h"
%End
public:
QgsSnappingUtils( QObject *parent /TransferThis/ = 0, bool enableSnappingForInvisibleFeature = true );
%Docstring
Constructor for QgsSnappingUtils
:param parent: parent object
:param enableSnappingForInvisibleFeature: ``True`` if we want to snap
feature even if there are not
visible
%End
~QgsSnappingUtils();
QgsPointLocator *locatorForLayer( QgsVectorLayer *vl );
%Docstring
Gets a point locator for the given layer. If such locator does not
exist, it will be created
:param vl: the vector layer
%End
QgsPointLocator::Match snapToMap( QPoint point, QgsPointLocator::MatchFilter *filter = 0, bool relaxed = false );
%Docstring
Snap to map according to the current configuration.
:param point: point in canvas coordinates
:param filter: allows discarding unwanted matches.
:param relaxed: ``True`` if this method is non blocking and the matching
result can be invalid while indexing
%End
QgsPointLocator::Match snapToMap( const QgsPointXY &pointMap, QgsPointLocator::MatchFilter *filter = 0, bool relaxed = false );
%Docstring
Snap to map according to the current configuration.
:param pointMap: point in map coordinates
:param filter: allows discarding unwanted matches.
:param relaxed: ``True`` if this method is non blocking and the matching
result can be invalid while indexing
%End
QgsPointLocator::Match snapToCurrentLayer( QPoint point, QgsPointLocator::Types type, QgsPointLocator::MatchFilter *filter = 0 );
%Docstring
Snap to current layer
%End
void setMapSettings( const QgsMapSettings &settings );
%Docstring
Assign current map settings to the utils - used for conversion between
screen coords to map coords
%End
QgsMapSettings mapSettings() const;
void setCurrentLayer( QgsVectorLayer *layer );
%Docstring
Sets current layer so that if mode is SnapCurrentLayer we know which
layer to use
%End
QgsVectorLayer *currentLayer() const;
%Docstring
The current layer used if mode is SnapCurrentLayer
%End
enum IndexingStrategy
{
IndexAlwaysFull,
IndexNeverFull,
IndexHybrid,
IndexExtent
};
void setIndexingStrategy( IndexingStrategy strategy );
%Docstring
Sets a strategy for indexing geometry data - determines how fast and
memory consuming the data structures will be
%End
IndexingStrategy indexingStrategy() const;
%Docstring
Find out which strategy is used for indexing - by default hybrid
indexing is used
%End
struct LayerConfig
{
LayerConfig( QgsVectorLayer *l, QgsPointLocator::Types t, double tol, Qgis::MapToolUnit u );
%Docstring
Create a new configuration for a snapping layer.
.. code-block:: python
snapper = QgsMapCanvasSnappingUtils(mapCanvas)
snapping_layer1 = QgsSnappingUtils.LayerConfig(layer1, QgsPointLocator.Vertex, 10, Qgis::MapToolUnit::Pixels)
snapping_layer2 = QgsSnappingUtils.LayerConfig(layer2, QgsPointLocator.Vertex and QgsPointLocator.Edge, 10, Qgis::MapToolUnit::Pixels)
snapper.setLayers([snapping_layer1, snapping_layer2])
:param l: The vector layer for which this configuration is
:param t: Which parts of the geometry should be snappable
:param tol: The tolerance radius in which the snapping will trigger
:param u: The unit in which the tolerance is specified
%End
bool operator==( const QgsSnappingUtils::LayerConfig &other ) const;
bool operator!=( const QgsSnappingUtils::LayerConfig &other ) const;
QgsVectorLayer *layer;
QgsPointLocator::Types type;
double tolerance;
Qgis::MapToolUnit unit;
};
QList<QgsSnappingUtils::LayerConfig> layers() const;
%Docstring
Query layers used for snapping
%End
QString dump();
%Docstring
Gets extra information about the instance
%End
QgsSnappingConfig config() const;
%Docstring
The snapping configuration controls the behavior of this object
%End
void setEnableSnappingForInvisibleFeature( bool enable );
%Docstring
Set if invisible features must be snapped or not.
:param enable: Enable or not this feature
.. versionadded:: 3.2
%End
void addExtraSnapLayer( QgsVectorLayer *vl );
%Docstring
Supply an extra snapping layer (typically a memory layer). This can be
used by map tools to provide additional snappings points.
.. seealso:: :py:func:`removeExtraSnapLayer`
.. seealso:: :py:func:`getExtraSnapLayers`
.. versionadded:: 3.14
%End
void removeExtraSnapLayer( QgsVectorLayer *vl );
%Docstring
Removes an extra snapping layer
.. seealso:: :py:func:`addExtraSnapLayer`
.. seealso:: :py:func:`getExtraSnapLayers`
.. versionadded:: 3.14
%End
QSet<QgsVectorLayer *> getExtraSnapLayers();
%Docstring
Returns the list of extra snapping layers
.. seealso:: :py:func:`addExtraSnapLayer`
.. seealso:: :py:func:`removeExtraSnapLayer`
.. versionadded:: 3.14
%End
public slots:
void setConfig( const QgsSnappingConfig &snappingConfig );
%Docstring
The snapping configuration controls the behavior of this object
%End
void toggleEnabled();
%Docstring
Toggles the state of snapping
%End
signals:
void configChanged( const QgsSnappingConfig &snappingConfig );
%Docstring
Emitted when the snapping settings object changes.
%End
protected:
virtual void prepareIndexStarting( int count );
%Docstring
Called when starting to index with snapToMap - can be overridden and
e.g. progress dialog can be provided
%End
virtual void prepareIndexProgress( int index );
%Docstring
Called when finished indexing a layer with snapToMap. When index ==
count the indexing is complete
%End
void clearAllLocators();
%Docstring
Deletes all existing locators (e.g. when destination CRS has changed and
we need to reindex)
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgssnappingutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|