Skip to content
Permalink
Browse files
remove useless private methods (#46680)
  • Loading branch information
3nids committed Jan 3, 2022
1 parent a64443f commit 867d72a5a13741864f5c1788a229da9de835defd
Showing with 14 additions and 29 deletions.
  1. +13 −23 src/gui/qgsmaptoolcapture.cpp
  2. +1 −6 src/gui/qgsmaptoolcapture.h
@@ -170,7 +170,7 @@ QgsPointXY QgsMapToolCapture::tracingStartPoint()
if ( mTracingStartPoint != QgsPointXY() )
return mTracingStartPoint;

return lastCapturedMapPoint();
return mCaptureLastPoint;
}


@@ -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 )
{
@@ -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 )
@@ -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 );
@@ -430,7 +420,7 @@ void QgsMapToolCapture::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
if ( mCaptureCurve.numPoints() > 0 )
{
const QgsPoint mapPt = lastCapturedMapPoint();
const QgsPoint mapPt = mCaptureLastPoint;

if ( mTempRubberBand )
{
@@ -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 )
{
@@ -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 );
}
}

@@ -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
}
@@ -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 );
}

@@ -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;

0 comments on commit 867d72a

Please sign in to comment.