Skip to content
Permalink
Browse files

Add snapindicator to shape tools (#8292)

  • Loading branch information
lbartoletti authored and 3nids committed Oct 26, 2018
1 parent 547fdb8 commit 40e9406670fcd43913f0d111bbe130293580d260
@@ -22,10 +22,12 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgisapp.h"
#include "qgssnapindicator.h"

QgsMapToolAddCircle::QgsMapToolAddCircle( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode )
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), mode )
, mParentTool( parentTool )
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator>( canvas ) )
{
clean();
connect( QgisApp::instance(), &QgisApp::newProject, this, &QgsMapToolAddCircle::stopCapturing );
@@ -21,6 +21,7 @@
#include "qgis_app.h"

class QgsGeometryRubberBand;
class QgsSnapIndicator;

struct EdgesOnlyFilter : public QgsPointLocator::MatchFilter
{
@@ -59,6 +60,9 @@ class APP_EXPORT QgsMapToolAddCircle: public QgsMapToolCapture
//! Layer type which will be used for rubberband
QgsWkbTypes::GeometryType mLayerType = QgsWkbTypes::LineGeometry;

//! Snapping indicators
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;

};

#endif // QGSMAPTOOLADDCIRCLE_H
@@ -23,11 +23,13 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgisapp.h"
#include "qgssnapindicator.h"

QgsMapToolAddCircularString::QgsMapToolAddCircularString( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode )
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), mode )
, mParentTool( parentTool )
, mShowCenterPointRubberBand( false )
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator>( canvas ) )
{
connect( QgisApp::instance(), &QgisApp::newProject, this, &QgsMapToolAddCircularString::stopCapturing );
connect( QgisApp::instance(), &QgisApp::projectRead, this, &QgsMapToolAddCircularString::stopCapturing );
@@ -20,6 +20,7 @@
#include "qgis_app.h"

class QgsGeometryRubberBand;
class QgsSnapIndicator;

class APP_EXPORT QgsMapToolAddCircularString: public QgsMapToolCapture
{
@@ -61,6 +62,9 @@ class APP_EXPORT QgsMapToolAddCircularString: public QgsMapToolCapture
void removeCenterPointRubberBand();
//! Layer type which will be used for rubberband
QgsWkbTypes::GeometryType mLayerType = QgsWkbTypes::LineGeometry;

//! Snapping indicators
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
};

#endif // QGSMAPTOOLADDCIRCULARSTRING_H
@@ -22,10 +22,12 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgisapp.h"
#include "qgssnapindicator.h"

QgsMapToolAddEllipse::QgsMapToolAddEllipse( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode )
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), mode )
, mParentTool( parentTool )
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator>( canvas ) )
{
clean();
connect( QgisApp::instance(), &QgisApp::newProject, this, &QgsMapToolAddEllipse::stopCapturing );
@@ -22,6 +22,7 @@
#include "qgis_app.h"

class QgsGeometryRubberBand;
class QgsSnapIndicator;

class APP_EXPORT QgsMapToolAddEllipse: public QgsMapToolCapture
{
@@ -57,6 +58,9 @@ class APP_EXPORT QgsMapToolAddEllipse: public QgsMapToolCapture
//! Layer type which will be used for rubberband
QgsWkbTypes::GeometryType mLayerType = QgsWkbTypes::LineGeometry;

//! Snapping indicators
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;

};

#endif // QGSMAPTOOLADDELLIPSE_H
@@ -23,10 +23,12 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgisapp.h"
#include "qgssnapindicator.h"

QgsMapToolAddRectangle::QgsMapToolAddRectangle( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode )
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), mode )
, mParentTool( parentTool )
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator>( canvas ) )
{
clean();
connect( QgisApp::instance(), &QgisApp::newProject, this, &QgsMapToolAddRectangle::stopCapturing );
@@ -22,6 +22,7 @@
#include "qgis_app.h"

class QgsPolygon;
class QgsSnapIndicator;

class APP_EXPORT QgsMapToolAddRectangle: public QgsMapToolCapture
{
@@ -80,6 +81,9 @@ class APP_EXPORT QgsMapToolAddRectangle: public QgsMapToolCapture
//! Layer type which will be used for rubberband
QgsWkbTypes::GeometryType mLayerType = QgsWkbTypes::LineGeometry;

//! Snapping indicators
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;

private:
//! Convenient member for the azimuth of the rotated rectangle or when map is rotated.
double mAzimuth = 0.0;
@@ -22,10 +22,12 @@
#include "qgspoint.h"
#include "qgisapp.h"
#include "qgsstatusbar.h"
#include "qgssnapindicator.h"

QgsMapToolAddRegularPolygon::QgsMapToolAddRegularPolygon( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode )
: QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), mode )
, mParentTool( parentTool )
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator>( canvas ) )
{
clean();
connect( QgisApp::instance(), &QgisApp::newProject, this, &QgsMapToolAddRegularPolygon::stopCapturing );
@@ -22,6 +22,7 @@
#include "qgis_app.h"

class QSpinBox;
class QgsSnapIndicator;

class APP_EXPORT QgsMapToolAddRegularPolygon: public QgsMapToolCapture
{
@@ -65,6 +66,9 @@ class APP_EXPORT QgsMapToolAddRegularPolygon: public QgsMapToolCapture
//! Layer type which will be used for rubberband
QgsWkbTypes::GeometryType mLayerType = QgsWkbTypes::LineGeometry;

//! Snapping indicators
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;

};

#endif // QGSMAPTOOLADDREGULARPOLYGON_H
@@ -19,6 +19,7 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgsmapmouseevent.h"
#include "qgssnapindicator.h"


QgsMapToolCircle2Points::QgsMapToolCircle2Points( QgsMapToolCapture *parentTool,
@@ -56,6 +57,9 @@ void QgsMapToolCircle2Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
void QgsMapToolCircle2Points::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint point = mapPoint( *e );

mSnapIndicator->setMatch( e->mapPointMatch() );

if ( mTempRubberBand )
{
mCircle = QgsCircle().from2Points( mPoints.at( 0 ), point );
@@ -29,6 +29,7 @@
#include <memory>
#include "qgsmapmouseevent.h"
#include "qgsmessagebar.h"
#include "qgssnapindicator.h"

QgsMapToolCircle2TangentsPoint::QgsMapToolCircle2TangentsPoint( QgsMapToolCapture *parentTool,
QgsMapCanvas *canvas, CaptureMode mode )
@@ -102,6 +103,9 @@ void QgsMapToolCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e
void QgsMapToolCircle2TangentsPoint::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint mapPoint( e->mapPoint() );

mSnapIndicator->setMatch( e->mapPointMatch() );

EdgesOnlyFilter filter;
QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToMap( mapPoint, &filter );

@@ -20,6 +20,7 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgsmapmouseevent.h"
#include "qgssnapindicator.h"

QgsMapToolCircle3Points::QgsMapToolCircle3Points( QgsMapToolCapture *parentTool,
QgsMapCanvas *canvas, CaptureMode mode )
@@ -55,6 +56,8 @@ void QgsMapToolCircle3Points::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint point = mapPoint( *e );

mSnapIndicator->setMatch( e->mapPointMatch() );

if ( mTempRubberBand )
{
switch ( mPoints.size() )
@@ -24,6 +24,7 @@
#include "qgisapp.h"
#include "qgsmapmouseevent.h"
#include "qgsmessagebar.h"
#include "qgssnapindicator.h"


QgsMapToolCircle3Tangents::QgsMapToolCircle3Tangents( QgsMapToolCapture *parentTool,
@@ -76,6 +77,9 @@ void QgsMapToolCircle3Tangents::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
void QgsMapToolCircle3Tangents::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint point = mapPoint( *e );

mSnapIndicator->setMatch( e->mapPointMatch() );

EdgesOnlyFilter filter;
QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToMap( point, &filter );

@@ -19,6 +19,7 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgsmapmouseevent.h"
#include "qgssnapindicator.h"


QgsMapToolCircleCenterPoint::QgsMapToolCircleCenterPoint( QgsMapToolCapture *parentTool,
@@ -57,6 +58,9 @@ void QgsMapToolCircleCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
void QgsMapToolCircleCenterPoint::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint point = mapPoint( *e );

mSnapIndicator->setMatch( e->mapPointMatch() );

if ( mTempRubberBand )
{
mCircle = QgsCircle().fromCenterPoint( mPoints.at( 0 ), point );
@@ -19,6 +19,7 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgsmapmouseevent.h"
#include "qgssnapindicator.h"


QgsMapToolCircularStringCurvePoint::QgsMapToolCircularStringCurvePoint( QgsMapToolCapture *parentTool,
@@ -83,6 +84,9 @@ void QgsMapToolCircularStringCurvePoint::cadCanvasReleaseEvent( QgsMapMouseEvent
void QgsMapToolCircularStringCurvePoint::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint mapPoint( e->mapPoint() );

mSnapIndicator->setMatch( e->mapPointMatch() );

QgsVertexId idx( 0, 0, 1 + ( mPoints.size() + 1 ) % 2 );
if ( mTempRubberBand )
{
@@ -23,6 +23,7 @@
#include "qgspoint.h"
#include "qgsstatusbar.h"
#include "qgsmapmouseevent.h"
#include "qgssnapindicator.h"

#include <QDoubleSpinBox>
#include <cmath>
@@ -96,6 +97,9 @@ void QgsMapToolCircularStringRadius::cadCanvasReleaseEvent( QgsMapMouseEvent *e

void QgsMapToolCircularStringRadius::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{

mSnapIndicator->setMatch( e->mapPointMatch() );

if ( !mPoints.isEmpty() )
{
recalculateTempRubberBand( e->mapPoint() );
@@ -20,6 +20,7 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgsmapmouseevent.h"
#include "qgssnapindicator.h"
#include <memory>

QgsMapToolEllipseCenter2Points::QgsMapToolEllipseCenter2Points( QgsMapToolCapture *parentTool,
@@ -58,6 +59,8 @@ void QgsMapToolEllipseCenter2Points::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint point = mapPoint( *e );

mSnapIndicator->setMatch( e->mapPointMatch() );

if ( mTempRubberBand )
{
switch ( mPoints.size() )
@@ -19,6 +19,7 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgsmapmouseevent.h"
#include "qgssnapindicator.h"


QgsMapToolEllipseCenterPoint::QgsMapToolEllipseCenterPoint( QgsMapToolCapture *parentTool,
@@ -54,6 +55,9 @@ void QgsMapToolEllipseCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
void QgsMapToolEllipseCenterPoint::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint point = mapPoint( *e );

mSnapIndicator->setMatch( e->mapPointMatch() );

if ( mTempRubberBand )
{
mEllipse = QgsEllipse().fromCenterPoint( mPoints.at( 0 ), point );
@@ -21,6 +21,7 @@
#include "qgsgeometryutils.h"
#include "qgslinestring.h"
#include "qgsmapmouseevent.h"
#include "qgssnapindicator.h"


QgsMapToolEllipseExtent::QgsMapToolEllipseExtent( QgsMapToolCapture *parentTool,
@@ -57,6 +58,8 @@ void QgsMapToolEllipseExtent::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint point = mapPoint( *e );

mSnapIndicator->setMatch( e->mapPointMatch() );

if ( mTempRubberBand )
{
switch ( mPoints.size() )
@@ -20,6 +20,7 @@
#include "qgsmapcanvas.h"
#include "qgspoint.h"
#include "qgsmapmouseevent.h"
#include "qgssnapindicator.h"
#include <memory>

QgsMapToolEllipseFoci::QgsMapToolEllipseFoci( QgsMapToolCapture *parentTool,
@@ -56,6 +57,8 @@ void QgsMapToolEllipseFoci::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint point = mapPoint( *e );

mSnapIndicator->setMatch( e->mapPointMatch() );

if ( mTempRubberBand )
{
switch ( mPoints.size() )
@@ -22,6 +22,7 @@
#include "qgspoint.h"
#include "qgsmapmouseevent.h"
#include <memory>
#include "qgssnapindicator.h"

QgsMapToolRectangle3Points::QgsMapToolRectangle3Points( QgsMapToolCapture *parentTool,
QgsMapCanvas *canvas, CaptureMode mode )
@@ -58,6 +59,8 @@ void QgsMapToolRectangle3Points::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint point = mapPoint( *e );

mSnapIndicator->setMatch( e->mapPointMatch() );

if ( mTempRubberBand )
{
switch ( mPoints.size() )
@@ -21,6 +21,7 @@
#include "qgslinestring.h"
#include "qgspoint.h"
#include "qgsmapmouseevent.h"
#include "qgssnapindicator.h"

#include <memory>

@@ -60,6 +61,8 @@ void QgsMapToolRectangleCenter::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint point = mapPoint( *e );

mSnapIndicator->setMatch( e->mapPointMatch() );

if ( mTempRubberBand )
{
switch ( mPoints.size() )

0 comments on commit 40e9406

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