Skip to content
Permalink
Browse files

Only retrieve streaming tolerance once per operation, not with every …

…mouse move
  • Loading branch information
nyalldawson committed Mar 11, 2021
1 parent 4d9646b commit 27ae7cbb5795839898f7673d936d1184497e88b6
Showing with 9 additions and 4 deletions.
  1. +7 −4 src/gui/qgsmaptoolcapture.cpp
  2. +2 −0 src/gui/qgsmaptoolcapture.h
@@ -368,6 +368,11 @@ void QgsMapToolCapture::setStreamDigitizingEnabled( bool enable )
{
mStreamingEnabled = enable;
mStartNewCurve = true;
if ( enable )
{
QgsSettings settings;
mStreamingToleranceInPixels = settings.value( QStringLiteral( "/qgis/digitizing/stream_tolerance" ), 2 ).toInt();
}
}

void QgsMapToolCapture::cadCanvasMoveEvent( QgsMapMouseEvent *e )
@@ -385,12 +390,10 @@ void QgsMapToolCapture::cadCanvasMoveEvent( QgsMapMouseEvent *e )

if ( mStreamingEnabled )
{
if ( ! mCaptureCurve.isEmpty() )
if ( !mCaptureCurve.isEmpty() )
{
QgsSettings settings;
const int tolerance = settings.value( QStringLiteral( "/qgis/digitizing/stream_tolerance" ), 2 ).toInt();
QgsPoint prevPoint = mCaptureCurve.curveAt( mCaptureCurve.nCurves() - 1 )->endPoint();
if ( QgsPointXY( toCanvasCoordinates( toMapCoordinates( mCanvas->currentLayer(), prevPoint ) ) ).distance( toCanvasCoordinates( point ) ) < tolerance )
if ( QgsPointXY( toCanvasCoordinates( toMapCoordinates( mCanvas->currentLayer(), prevPoint ) ) ).distance( toCanvasCoordinates( point ) ) < mStreamingToleranceInPixels )
return;
}

@@ -469,6 +469,8 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing

bool mStreamingEnabled = false;
bool mAllowAddingStreamingPoints = false;
int mStreamingToleranceInPixels = 1;

bool mStartNewCurve = false;

bool mIgnoreSubsequentAutoRepeatUndo = false;

0 comments on commit 27ae7cb

Please sign in to comment.