QGIS/python/core/qgssnappingutils.sip

115 lines
4.3 KiB
Plaintext
Raw Normal View History

class QgsSnappingUtils : QObject
{
%TypeHeaderCode
#include <qgssnappingutils.h>
%End
public:
QgsSnappingUtils( QObject* parent /TransferThis/ = 0 );
~QgsSnappingUtils();
// main actions
2015-07-29 11:52:14 +02:00
/** Get a point locator for the given layer. If such locator does not exist, it will be created */
QgsPointLocator* locatorForLayer( QgsVectorLayer* vl );
2016-01-21 10:39:47 +01:00
/** Snap to map according to the current configuration (mode). Optional filter allows discarding unwanted matches. */
QgsPointLocator::Match snapToMap( QPoint point, QgsPointLocator::MatchFilter* filter = 0 );
QgsPointLocator::Match snapToMap( const QgsPoint& pointMap, QgsPointLocator::MatchFilter* filter = 0 );
2015-07-29 11:52:14 +02:00
/** Snap to current layer */
QgsPointLocator::Match snapToCurrentLayer( QPoint point, int type, QgsPointLocator::MatchFilter* filter = 0 );
// environment setup
2015-07-29 11:52:14 +02:00
/** Assign current map settings to the utils - used for conversion between screen coords to map coords */
void setMapSettings( const QgsMapSettings& settings );
QgsMapSettings mapSettings() const;
2015-07-29 11:52:14 +02:00
/** Set current layer so that if mode is SnapCurrentLayer we know which layer to use */
void setCurrentLayer( QgsVectorLayer* layer );
/** The current layer used if mode is SnapCurrentLayer */
QgsVectorLayer* currentLayer() const;
// configuration
//! modes for "snap to background"
enum SnapToMapMode
{
SnapCurrentLayer, //!< snap just to current layer (tolerance and type from defaultSettings())
SnapAllLayers, //!< snap to all rendered layers (tolerance and type from defaultSettings())
SnapAdvanced, //!< snap according to the configuration set in setLayers()
};
enum IndexingStrategy
{
IndexAlwaysFull, //!< For all layers build index of full extent. Uses more memory, but queries are faster.
IndexNeverFull, //!< For all layers only create temporary indexes of small extent. Low memory usage, slower queries.
IndexHybrid, //!< For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and memory usage.
IndexExtent //!< For all layer build index of extent given in map settings
};
/** Set a strategy for indexing geometry data - determines how fast and memory consuming the data structures will be */
void setIndexingStrategy( IndexingStrategy strategy );
/** Find out which strategy is used for indexing - by default hybrid indexing is used */
IndexingStrategy indexingStrategy() const;
2016-02-14 03:50:23 +01:00
/**
* Configures how a certain layer should be handled in a snapping operation
*/
struct LayerConfig
{
LayerConfig( QgsVectorLayer* l, QgsPointLocator::Types t, double tol, QgsTolerance::UnitType u );
2016-01-11 20:57:28 +01:00
bool operator==( const QgsSnappingUtils::LayerConfig& other ) const;
bool operator!=( const QgsSnappingUtils::LayerConfig& other ) const;
2016-02-14 03:50:23 +01:00
//! The layer to configure.
QgsVectorLayer* layer;
2016-02-14 03:50:23 +01:00
//! To which geometry properties of this layers a snapping should happen.
2015-09-26 13:21:56 +02:00
QgsPointLocator::Types type;
2016-02-14 03:50:23 +01:00
//! The range around snapping targets in which snapping should occur.
double tolerance;
2016-02-14 03:50:23 +01:00
//! The units in which the tolerance is specified.
QgsTolerance::UnitType unit;
};
/** Query layers used for snapping */
QList<QgsSnappingUtils::LayerConfig> layers() const;
/** Get extra information about the instance
* @note added in QGIS 2.14
*/
QString dump();
/**
* The snapping configuration controls the behavior of this object
*/
QgsSnappingConfig config() const;
public slots:
/**
* The snapping configuration controls the behavior of this object
*/
void setConfig( const QgsSnappingConfig& snappingConfig );
/**
* Toggles the state of snapping
*/
void toggleEnabled();
2016-01-11 20:57:28 +01:00
signals:
/**
* Emitted when the snapping settings object changes.
2016-01-11 20:57:28 +01:00
*/
void configChanged( const QgsSnappingConfig& snappingConfig );
2016-01-11 20:57:28 +01:00
protected:
//! Called when starting to index - can be overridden and e.g. progress dialog can be provided
virtual void prepareIndexStarting( int count );
//! Called when finished indexing a layer. When index == count the indexing is complete
virtual void prepareIndexProgress( int index );
};