Skip to content

Commit

Permalink
Remove some unnecessary layer casting
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 8, 2021
1 parent ecd27ae commit b6c032d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/gui/qgsmaptoolcapture.cpp
Expand Up @@ -308,7 +308,7 @@ bool QgsMapToolCapture::tracingAddVertex( const QgsPointXY &point )

// adjust last captured point
const QgsPoint lastPt = mCaptureCurve.endPoint();
mCaptureLastPoint = toMapCoordinates( qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() ), lastPt );
mCaptureLastPoint = toMapCoordinates( mCanvas->currentLayer(), lastPt );

return true;
}
Expand Down Expand Up @@ -346,8 +346,7 @@ void QgsMapToolCapture::resetRubberBand()
return;
QgsLineString *lineString = mCaptureCurve.curveToLine();
mRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry );
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
mRubberBand->addGeometry( QgsGeometry( lineString ), vlayer );
mRubberBand->addGeometry( QgsGeometry( lineString ), mCanvas->currentLayer() );
}

QgsRubberBand *QgsMapToolCapture::takeRubberBand()
Expand Down Expand Up @@ -679,8 +678,7 @@ int QgsMapToolCapture::addCurve( QgsCurve *c )
}

//transform back to layer CRS in case map CRS and layer CRS are different
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
const QgsCoordinateTransform ct = mCanvas->mapSettings().layerTransform( vlayer );
const QgsCoordinateTransform ct = mCanvas->mapSettings().layerTransform( mCanvas->currentLayer() );
if ( ct.isValid() )
{
c->transform( ct, QgsCoordinateTransform::ReverseTransform );
Expand Down Expand Up @@ -782,7 +780,7 @@ void QgsMapToolCapture::undo( bool isAutoRepeat )
if ( mCaptureCurve.numPoints() > 0 )
{
const QgsPoint lastPt = mCaptureCurve.endPoint();
mCaptureLastPoint = toMapCoordinates( qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() ), lastPt );
mCaptureLastPoint = toMapCoordinates( mCanvas->currentLayer(), lastPt );
mTempRubberBand->addPoint( lastCapturedMapPoint() );
mTempRubberBand->movePoint( lastPoint );
}
Expand Down

0 comments on commit b6c032d

Please sign in to comment.