Skip to content
Permalink
Browse files

Rename snapToGridEnabled to snapToLayerGridEnabled

  • Loading branch information
m-kuhn committed Sep 7, 2018
1 parent 790c367 commit d57c1842b728ae71c958977d0f57d377160859d2
@@ -151,16 +151,18 @@ construction mode.
:param e: Mouse events prepared by the cad system
%End

bool snapToGridEnabled() const;
bool snapToLayerGridEnabled() const;
%Docstring
Enables or disables snap to grid of mouse events.
The snapping will occur in the layer's CRS.

.. versionadded:: 3.4
%End

void setSnapToGridEnabled( bool snapToGridEnabled );
void setSnapToLayerGridEnabled( bool snapToLayerGridEnabled );
%Docstring
Enables or disables snap to grid of mouse events.
The snapping will occur in the layer's CRS.

.. versionadded:: 3.4
%End
@@ -27,7 +27,7 @@ QgsMapToolSplitFeatures::QgsMapToolSplitFeatures( QgsMapCanvas *canvas )
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CaptureLine )
{
mToolName = tr( "Split features" );
setSnapToGridEnabled( false );
setSnapToLayerGridEnabled( false );
}

void QgsMapToolSplitFeatures::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
@@ -27,7 +27,7 @@ QgsMapToolSplitParts::QgsMapToolSplitParts( QgsMapCanvas *canvas )
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CaptureLine )
{
mToolName = tr( "Split parts" );
setSnapToGridEnabled( false );
setSnapToLayerGridEnabled( false );
}

void QgsMapToolSplitParts::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
@@ -43,7 +43,7 @@ void QgsMapToolAdvancedDigitizing::canvasPressEvent( QgsMapMouseEvent *e )
}

QgsVectorLayer *layer = currentVectorLayer();
if ( mSnapToGridEnabled && layer )
if ( mSnapToLayerGridEnabled && layer )
{
e->snapToGrid( layer->geometryFixes()->geometryPrecision(), layer->crs() );
}
@@ -83,7 +83,7 @@ void QgsMapToolAdvancedDigitizing::canvasReleaseEvent( QgsMapMouseEvent *e )
}

QgsVectorLayer *layer = currentVectorLayer();
if ( mSnapToGridEnabled && layer )
if ( mSnapToLayerGridEnabled && layer )
{
e->snapToGrid( layer->geometryFixes()->geometryPrecision(), layer->crs() );
}
@@ -108,7 +108,7 @@ void QgsMapToolAdvancedDigitizing::canvasMoveEvent( QgsMapMouseEvent *e )
}

QgsVectorLayer *layer = currentVectorLayer();
if ( mSnapToGridEnabled && layer )
if ( mSnapToLayerGridEnabled && layer )
{
e->snapToGrid( layer->geometryFixes()->geometryPrecision(), layer->crs() );
mSnapToGridCanvasItem->setPoint( e->mapPoint() );
@@ -129,7 +129,7 @@ void QgsMapToolAdvancedDigitizing::activate()
mSnapToGridCanvasItem->setCrs( currentVectorLayer()->crs() );
mSnapToGridCanvasItem->setPrecision( currentVectorLayer()->geometryFixes()->geometryPrecision() );
}
mSnapToGridCanvasItem->setEnabled( mSnapToGridEnabled );
mSnapToGridCanvasItem->setEnabled( mSnapToLayerGridEnabled );
}

void QgsMapToolAdvancedDigitizing::deactivate()
@@ -153,7 +153,7 @@ void QgsMapToolAdvancedDigitizing::onCurrentLayerChanged()
if ( mSnapToGridCanvasItem )
{
QgsVectorLayer *layer = currentVectorLayer();
if ( layer && mSnapToGridEnabled )
if ( layer && mSnapToLayerGridEnabled )
{
mSnapToGridCanvasItem->setPrecision( layer->geometryFixes()->geometryPrecision() );
mSnapToGridCanvasItem->setCrs( layer->crs() );
@@ -162,18 +162,18 @@ void QgsMapToolAdvancedDigitizing::onCurrentLayerChanged()
if ( !layer )
mSnapToGridCanvasItem->setEnabled( false );
else
mSnapToGridCanvasItem->setEnabled( mSnapToGridEnabled );
mSnapToGridCanvasItem->setEnabled( mSnapToLayerGridEnabled );
}
}

bool QgsMapToolAdvancedDigitizing::snapToGridEnabled() const
bool QgsMapToolAdvancedDigitizing::snapToLayerGridEnabled() const
{
return mSnapToGridEnabled;
return mSnapToLayerGridEnabled;
}

void QgsMapToolAdvancedDigitizing::setSnapToGridEnabled( bool snapToGridEnabled )
void QgsMapToolAdvancedDigitizing::setSnapToLayerGridEnabled( bool snapToGridEnabled )
{
mSnapToGridEnabled = snapToGridEnabled;
mSnapToLayerGridEnabled = snapToGridEnabled;

if ( mSnapToGridCanvasItem )
{
@@ -143,17 +143,19 @@ class GUI_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapToolEdit

/**
* Enables or disables snap to grid of mouse events.
* The snapping will occur in the layer's CRS.
*
* \since QGIS 3.4
*/
bool snapToGridEnabled() const;
bool snapToLayerGridEnabled() const;

/**
* Enables or disables snap to grid of mouse events.
* The snapping will occur in the layer's CRS.
*
* \since QGIS 3.4
*/
void setSnapToGridEnabled( bool snapToGridEnabled );
void setSnapToLayerGridEnabled( bool snapToLayerGridEnabled );

private slots:

@@ -177,7 +179,7 @@ class GUI_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapToolEdit
//! Whether to snap mouse cursor to map before passing coordinates to cadCanvas*Event()
bool mAutoSnapEnabled = true;
//! Whether to snap to grid before passing coordinates to cadCanvas*Event()
bool mSnapToGridEnabled = true;
bool mSnapToLayerGridEnabled = true;
QgsSnapToGridCanvasItem *mSnapToGridCanvasItem = nullptr;
};

0 comments on commit d57c184

Please sign in to comment.
You can’t perform that action at this time.