Skip to content

Commit

Permalink
remove useless private methods (#46680)
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jan 3, 2022
1 parent a64443f commit 867d72a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
36 changes: 13 additions & 23 deletions src/gui/qgsmaptoolcapture.cpp
Expand Up @@ -170,7 +170,7 @@ QgsPointXY QgsMapToolCapture::tracingStartPoint()
if ( mTracingStartPoint != QgsPointXY() )
return mTracingStartPoint;

return lastCapturedMapPoint();
return mCaptureLastPoint;
}


Expand All @@ -195,14 +195,14 @@ bool QgsMapToolCapture::tracingMouseMove( QgsMapMouseEvent *e )
return false;
}

mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, QgsWkbTypes::LineString, firstCapturedMapPoint() );
mTempRubberBand->addPoint( lastCapturedMapPoint() );
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, QgsWkbTypes::LineString, mCaptureFirstPoint );
mTempRubberBand->addPoint( mCaptureLastPoint );

// if there is offset, we need to fix the rubber bands to make sure they are aligned correctly.
// There are two cases we need to sort out:
// 1. the last point of mRubberBand may need to be moved off the traced curve to respect the offset
// 2. first point of mTempRubberBand may be needed to be moved to the beginning of the offset trace
const QgsPoint lastPoint = lastCapturedMapPoint();
const QgsPoint lastPoint = mCaptureLastPoint;
QgsPointXY lastPointXY( lastPoint );
if ( lastPointXY == pt0 && points[0] != lastPointXY )
{
Expand Down Expand Up @@ -331,16 +331,6 @@ QgsMapToolCaptureRubberBand *QgsMapToolCapture::createCurveRubberBand() const
return rb;
}

QgsPoint QgsMapToolCapture::firstCapturedMapPoint()
{
return mCaptureFirstPoint;
}

QgsPoint QgsMapToolCapture::lastCapturedMapPoint()
{
return mCaptureLastPoint;
}

void QgsMapToolCapture::resetRubberBand()
{
if ( !mRubberBand )
Expand Down Expand Up @@ -416,8 +406,8 @@ void QgsMapToolCapture::cadCanvasMoveEvent( QgsMapMouseEvent *e )
if ( !hasTrace )
{
// Restore the temp rubber band
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, firstCapturedMapPoint() );
mTempRubberBand->addPoint( lastCapturedMapPoint() );
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, mCaptureFirstPoint );
mTempRubberBand->addPoint( mCaptureLastPoint );
if ( !mCircularItermediatePoint.isEmpty() )
{
mTempRubberBand->movePoint( mCircularItermediatePoint );
Expand All @@ -430,7 +420,7 @@ void QgsMapToolCapture::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
if ( mCaptureCurve.numPoints() > 0 )
{
const QgsPoint mapPt = lastCapturedMapPoint();
const QgsPoint mapPt = mCaptureLastPoint;

if ( mTempRubberBand )
{
Expand Down Expand Up @@ -642,7 +632,7 @@ int QgsMapToolCapture::addVertex( const QgsPointXY &point, const QgsPointLocator
}
}
mCaptureLastPoint = mapPoint;
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, firstCapturedMapPoint() );
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, mCaptureFirstPoint );
}
else if ( mTempRubberBand->pointsCount() == 0 )
{
Expand All @@ -662,8 +652,8 @@ int QgsMapToolCapture::addVertex( const QgsPointXY &point, const QgsPointLocator
}
else
{
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, firstCapturedMapPoint() );
mTempRubberBand->addPoint( lastCapturedMapPoint() );
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, mCaptureFirstPoint );
mTempRubberBand->addPoint( mCaptureLastPoint );
}
}

Expand All @@ -687,7 +677,7 @@ int QgsMapToolCapture::addCurve( QgsCurve *c )

if ( mTempRubberBand )
{
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, firstCapturedMapPoint() );
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, mCaptureFirstPoint );
const QgsPoint endPt = c->endPoint();
mTempRubberBand->addPoint( endPt ); //add last point of c
}
Expand Down Expand Up @@ -790,13 +780,13 @@ void QgsMapToolCapture::undo( bool isAutoRepeat )

resetRubberBand();

mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, firstCapturedMapPoint() );
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, mCaptureFirstPoint );

if ( mCaptureCurve.numPoints() > 0 )
{
const QgsPoint lastPt = mCaptureCurve.endPoint();
mCaptureLastPoint = toMapCoordinates( layer(), lastPt );
mTempRubberBand->addPoint( lastCapturedMapPoint() );
mTempRubberBand->addPoint( mCaptureLastPoint );
mTempRubberBand->movePoint( lastPoint );
}

Expand Down
7 changes: 1 addition & 6 deletions src/gui/qgsmaptoolcapture.h
Expand Up @@ -411,22 +411,17 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
//! create a curve rubber band
QgsMapToolCaptureRubberBand *createCurveRubberBand() const;

//! Returns extemity point of the captured curve in map coordinates
QgsPoint firstCapturedMapPoint();
QgsPoint lastCapturedMapPoint();

//! Reset the
void resetRubberBand();

private:
//! The capture mode in which this tool operates
CaptureMode mCaptureMode;



//! Flag to indicate a map canvas capture operation is taking place
bool mCapturing = false;

//! extremity point of the captured curve in map coordinates
QgsPoint mCaptureFirstPoint;
QgsPoint mCaptureLastPoint;

Expand Down

0 comments on commit 867d72a

Please sign in to comment.