Skip to content
Permalink
Browse files
Allow QgsMapToolCapture subclasses to bypass geometry validation
  • Loading branch information
nyalldawson committed Sep 8, 2021
1 parent e7ce050 commit ec9d5268f996524ba2a7b0c3681e9e224a3ccfd8
@@ -40,6 +40,7 @@ class QgsMapToolCapture : QgsMapToolAdvancedDigitizing
{
NoCapabilities,
SupportsCurves,
ValidateGeometries,
};

typedef QFlags<QgsMapToolCapture::Capability> Capabilities;
@@ -37,7 +37,7 @@ QgsMapToolAddPart::QgsMapToolAddPart( QgsMapCanvas *canvas )

QgsMapToolCapture::Capabilities QgsMapToolAddPart::capabilities() const
{
return QgsMapToolCapture::SupportsCurves;
return QgsMapToolCapture::SupportsCurves | QgsMapToolCapture::ValidateGeometries;
}

bool QgsMapToolAddPart::supportsTechnique( QgsMapToolCapture::CaptureTechnique technique ) const
@@ -90,7 +90,7 @@ QgsMapToolCapture::~QgsMapToolCapture()

QgsMapToolCapture::Capabilities QgsMapToolCapture::capabilities() const
{
return QgsMapToolCapture::NoCapabilities;
return QgsMapToolCapture::ValidateGeometries;
}

bool QgsMapToolCapture::supportsTechnique( QgsMapToolCapture::CaptureTechnique technique ) const
@@ -872,7 +872,9 @@ QgsMapLayer *QgsMapToolCapture::layer() const

void QgsMapToolCapture::validateGeometry()
{
if ( QgsSettingsRegistryCore::settingsDigitizingValidateGeometries.value() == 0 )
if ( QgsSettingsRegistryCore::settingsDigitizingValidateGeometries.value() == 0
|| !( capabilities() & ValidateGeometries )
)
return;

if ( mValidator )
@@ -149,8 +149,9 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
//! Specific capabilities of the tool
enum Capability
{
NoCapabilities = 0, //!< No specific capabilities
SupportsCurves = 1, //!< Supports curved geometries input
NoCapabilities = 1 << 0, //!< No specific capabilities
SupportsCurves = 1 << 1, //!< Supports curved geometries input
ValidateGeometries = 1 << 2, //!< Tool supports geometry validation (since QGIS 3.22)
};

Q_DECLARE_FLAGS( Capabilities, Capability )
@@ -45,7 +45,7 @@ QgsMapToolDigitizeFeature::QgsMapToolDigitizeFeature( QgsMapCanvas *canvas, QgsA

QgsMapToolCapture::Capabilities QgsMapToolDigitizeFeature::capabilities() const
{
return QgsMapToolCapture::SupportsCurves;
return QgsMapToolCapture::SupportsCurves | QgsMapToolCapture::ValidateGeometries;
}

bool QgsMapToolDigitizeFeature::supportsTechnique( QgsMapToolCapture::CaptureTechnique technique ) const

0 comments on commit ec9d526

Please sign in to comment.