Skip to content
Permalink
Browse files
Show snap vertex marker for offset curve
  • Loading branch information
mhugent committed Feb 21, 2012
1 parent 41dd81b commit 802dda1953aa18960fecb6965715c453d67b5954
Showing with 15 additions and 2 deletions.
  1. +12 −2 src/app/qgsmaptooloffsetcurve.cpp
  2. +3 −0 src/app/qgsmaptooloffsetcurve.h
@@ -18,20 +18,22 @@
#include "qgsmaplayerregistry.h"
#include "qgsrubberband.h"
#include "qgsvectorlayer.h"
#include "qgsvertexmarker.h"
#include <QDoubleSpinBox>
#include <QGraphicsProxyWidget>
#include <QMouseEvent>
#include "qgisapp.h"

QgsMapToolOffsetCurve::QgsMapToolOffsetCurve( QgsMapCanvas* canvas ): QgsMapToolEdit( canvas ), mRubberBand( 0 ),
mOriginalGeometry( 0 ), mGeometryModified( false ), mDistanceItem( 0 ), mDistanceSpinBox( 0 )
mOriginalGeometry( 0 ), mGeometryModified( false ), mDistanceItem( 0 ), mDistanceSpinBox( 0 ), mSnapVertexMarker( 0 )
{
}

QgsMapToolOffsetCurve::~QgsMapToolOffsetCurve()
{
deleteRubberBandAndGeometry();
deleteDistanceItem();
delete mSnapVertexMarker;
}

void QgsMapToolOffsetCurve::canvasPressEvent( QMouseEvent * e )
@@ -111,6 +113,7 @@ void QgsMapToolOffsetCurve::canvasReleaseEvent( QMouseEvent * e )

deleteRubberBandAndGeometry();
deleteDistanceItem();
delete mSnapVertexMarker; mSnapVertexMarker = 0;
mCanvas->refresh();
}

@@ -133,6 +136,9 @@ void QgsMapToolOffsetCurve::placeOffsetCurveToValue()

void QgsMapToolOffsetCurve::canvasMoveEvent( QMouseEvent * e )
{
delete mSnapVertexMarker;
mSnapVertexMarker = 0;

if ( !mOriginalGeometry || !mRubberBand )
{
return;
@@ -166,8 +172,12 @@ void QgsMapToolOffsetCurve::canvasMoveEvent( QMouseEvent * e )
if ( snap.layer && snap.layer->id() != mSourceLayerId && snap.snappedAtGeometry != mModifiedFeature )
{
layerCoords = results.at( 0 ).snappedVertex;
mSnapVertexMarker = new QgsVertexMarker( mCanvas );
mSnapVertexMarker->setIconType( QgsVertexMarker::ICON_CROSS );
mSnapVertexMarker->setColor( Qt::green );
mSnapVertexMarker->setPenWidth( 1 );
mSnapVertexMarker->setCenter( layerCoords );
}
//todo: add vertex marker item
}
}

@@ -20,6 +20,7 @@
#include "qgsgeometry.h"
#include "qgssnapper.h"

class QgsVertexMarker;
class QDoubleSpinBox;
class QGraphicsProxyWidget;

@@ -56,6 +57,8 @@ class QgsMapToolOffsetCurve: public QgsMapToolEdit
QGraphicsProxyWidget* mDistanceItem;
/**Shows current distance value and allows numerical editing*/
QDoubleSpinBox* mDistanceSpinBox;
/**Marker to show the cursor was snapped to another location*/
QgsVertexMarker* mSnapVertexMarker;


void deleteRubberBandAndGeometry();

0 comments on commit 802dda1

Please sign in to comment.