mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
QgsPointLocator::Type : Type safety
This commit is contained in:
parent
dd9b37b4c9
commit
3613ba5701
@ -16,6 +16,8 @@ class QgsPointLocator : QObject
|
|||||||
|
|
||||||
enum Type { Invalid, Vertex, Edge, Area, All };
|
enum Type { Invalid, Vertex, Edge, Area, All };
|
||||||
|
|
||||||
|
typedef QFlags<QgsPointLocator::Type> Types;
|
||||||
|
|
||||||
/** Prepare the index for queries. Does nothing if the index already exists.
|
/** Prepare the index for queries. Does nothing if the index already exists.
|
||||||
* If the number of features is greater than the value of maxFeaturesToIndex, creation of index is stopped
|
* If the number of features is greater than the value of maxFeaturesToIndex, creation of index is stopped
|
||||||
* to make sure we do not run out of memory. If maxFeaturesToIndex is -1, no limits are used. Returns
|
* to make sure we do not run out of memory. If maxFeaturesToIndex is -1, no limits are used. Returns
|
||||||
|
@ -66,10 +66,10 @@ class QgsSnappingUtils : QObject
|
|||||||
|
|
||||||
struct LayerConfig
|
struct LayerConfig
|
||||||
{
|
{
|
||||||
LayerConfig( QgsVectorLayer* l, int t, double tol, QgsTolerance::UnitType u );
|
LayerConfig( QgsVectorLayer* l, QgsPointLocator::Types t, double tol, QgsTolerance::UnitType u );
|
||||||
|
|
||||||
QgsVectorLayer* layer;
|
QgsVectorLayer* layer;
|
||||||
int type;
|
QgsPointLocator::Types type;
|
||||||
double tolerance;
|
double tolerance;
|
||||||
QgsTolerance::UnitType unit;
|
QgsTolerance::UnitType unit;
|
||||||
};
|
};
|
||||||
|
@ -57,7 +57,16 @@ class CORE_EXPORT QgsPointLocator : public QObject
|
|||||||
|
|
||||||
~QgsPointLocator();
|
~QgsPointLocator();
|
||||||
|
|
||||||
enum Type { Invalid = 0, Vertex = 1, Edge = 2, Area = 4, All = Vertex | Edge | Area };
|
enum Type
|
||||||
|
{
|
||||||
|
Invalid = 0,
|
||||||
|
Vertex = 1,
|
||||||
|
Edge = 2,
|
||||||
|
Area = 4,
|
||||||
|
All = Vertex | Edge | Area
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_FLAGS( Types, Type )
|
||||||
|
|
||||||
/** Prepare the index for queries. Does nothing if the index already exists.
|
/** Prepare the index for queries. Does nothing if the index already exists.
|
||||||
* If the number of features is greater than the value of maxFeaturesToIndex, creation of index is stopped
|
* If the number of features is greater than the value of maxFeaturesToIndex, creation of index is stopped
|
||||||
|
@ -455,9 +455,11 @@ void QgsSnappingUtils::readConfigFromProject()
|
|||||||
if ( !vlayer || !vlayer->hasGeometryType() )
|
if ( !vlayer || !vlayer->hasGeometryType() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int t = ( *snapIt == "to_vertex" ? QgsPointLocator::Vertex :
|
QgsPointLocator::Types t( *snapIt == "to_vertex" ? QgsPointLocator::Vertex :
|
||||||
( *snapIt == "to_segment" ? QgsPointLocator::Edge :
|
( *snapIt == "to_segment" ? QgsPointLocator::Edge :
|
||||||
QgsPointLocator::Vertex | QgsPointLocator::Edge ) );
|
QgsPointLocator::Vertex | QgsPointLocator::Edge
|
||||||
|
)
|
||||||
|
);
|
||||||
mLayers.append( LayerConfig( vlayer, t, tolIt->toDouble(), ( QgsTolerance::UnitType ) tolUnitIt->toInt() ) );
|
mLayers.append( LayerConfig( vlayer, t, tolIt->toDouble(), ( QgsTolerance::UnitType ) tolUnitIt->toInt() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,13 +100,20 @@ class CORE_EXPORT QgsSnappingUtils : public QObject
|
|||||||
/** Query options used when the mode is snap to current layer */
|
/** Query options used when the mode is snap to current layer */
|
||||||
void defaultSettings( int& type, double& tolerance, QgsTolerance::UnitType& unit );
|
void defaultSettings( int& type, double& tolerance, QgsTolerance::UnitType& unit );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures how a certain layer should be handled in a snapping operation
|
||||||
|
*/
|
||||||
struct LayerConfig
|
struct LayerConfig
|
||||||
{
|
{
|
||||||
LayerConfig( QgsVectorLayer* l, int t, double tol, QgsTolerance::UnitType u ) : layer( l ), type( t ), tolerance( tol ), unit( u ) {}
|
LayerConfig( QgsVectorLayer* l, QgsPointLocator::Types t, double tol, QgsTolerance::UnitType u ) : layer( l ), type( t ), tolerance( tol ), unit( u ) {}
|
||||||
|
|
||||||
|
//! The layer to configure.
|
||||||
QgsVectorLayer* layer;
|
QgsVectorLayer* layer;
|
||||||
int type;
|
//! To which geometry properties of this layers a snapping should happen.
|
||||||
|
QgsPointLocator::Types type;
|
||||||
|
//! The range around snapping targets in which snapping should occur.
|
||||||
double tolerance;
|
double tolerance;
|
||||||
|
//! The units in which the tolerance is specified.
|
||||||
QgsTolerance::UnitType unit;
|
QgsTolerance::UnitType unit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user