Skip to content
Permalink
Browse files
fix #5017 and fix #5024
  • Loading branch information
jef-n committed Feb 15, 2012
1 parent 474ca93 commit 6b07241f2447030bd5c9be374975d585ce0c15b2
@@ -397,17 +397,39 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
break;
}
}

if ( !mSelectAnother )
{
mMoving = true;
QgsPoint point = mCanvas->getCoordinateTransform()->toMapPoint( e->pos().x(), e->pos().y() );
mClosestVertex = closestVertex( toLayerCoordinates( vlayer, point ) );
if ( !mSelectedFeature->isSelected( snapResult.beforeVertexNr ) ||
!mSelectedFeature->isSelected( snapResult.afterVertexNr ) )

if ( mIsPoint )
{
mSelectedFeature->deselectAllVertexes();
mSelectedFeature->selectVertex( snapResult.afterVertexNr );
mSelectedFeature->selectVertex( snapResult.beforeVertexNr );
if ( !mCtrl )
{
mSelectedFeature->deselectAllVertexes();
mSelectedFeature->selectVertex( snapResult.snappedVertexNr );
}
else
{
mSelectedFeature->invertVertexSelection( snapResult.snappedVertexNr );
}
}
else if ( !mSelectedFeature->isSelected( snapResult.beforeVertexNr ) ||
!mSelectedFeature->isSelected( snapResult.afterVertexNr ) )
{
if ( !mCtrl )
{
mSelectedFeature->deselectAllVertexes();
mSelectedFeature->selectVertex( snapResult.afterVertexNr );
mSelectedFeature->selectVertex( snapResult.beforeVertexNr );
}
else
{
mSelectedFeature->invertVertexSelection( snapResult.afterVertexNr );
mSelectedFeature->invertVertexSelection( snapResult.beforeVertexNr );
}
}
}
}
@@ -428,7 +450,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
{
mSelectedFeature->invertVertexSelection( atVertex );
}
else if ( !mSelectedFeature->isSelected( atVertex ) )
else
{
mSelectedFeature->deselectAllVertexes();
mSelectedFeature->selectVertex( atVertex );
@@ -466,15 +488,15 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
mClicked = false;
mSelectionRectangle = false;
QgsPoint coords = toMapCoordinates( e->pos() );
// QgsPoint coords = mCanvas->getCoordinateTransform()->toMapPoint( e->pos().x(), e->pos().y() );
// QgsPoint firstCoords = toMapCoordinates( *mLastCoordinates );

QgsPoint firstCoords = mCanvas->getCoordinateTransform()->toMapPoint( mLastCoordinates->x(), mLastCoordinates->y() );
if ( mRubberBand )
{
mRubberBand->close();
delete mRubberBand;
mRubberBand = 0;
}

if ( mLastCoordinates->x() == e->pos().x() && mLastCoordinates->y() == e->pos().y() )
{
if ( mSelectAnother )
@@ -492,8 +514,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
QgsPoint layerFirstCoords = toLayerCoordinates( vlayer, firstCoords );

// got correct coordinates
double topX;
double bottomX;
double topX, bottomX;
if ( layerCoords.x() > layerFirstCoords.x() )
{
topX = layerFirstCoords.x();
@@ -504,8 +525,8 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
topX = layerCoords.x();
bottomX = layerFirstCoords.x();
}
double leftY;
double rightY;

double leftY, rightY;
if ( layerCoords.y() > layerFirstCoords.y() )
{
leftY = layerFirstCoords.y();
@@ -516,6 +537,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
leftY = layerCoords.y();
rightY = layerFirstCoords.y();
}

if ( mMoving )
{
mMoving = false;
@@ -537,6 +559,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
}
QgsPoint layerCoords = toLayerCoordinates( vlayer, coords );
QgsPoint layerFirstCoords = toLayerCoordinates( vlayer, firstCoords );

double changeX = layerCoords.x() - layerFirstCoords.x();
double changeY = layerCoords.y() - layerFirstCoords.y();
mSelectedFeature->beginGeometryChange();
@@ -563,6 +586,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
}
}
}

mMoving = false;

removeRubberBands();
@@ -689,10 +713,8 @@ void QgsMapToolNodeTool::keyReleaseEvent( QKeyEvent* e )

if ( mSelectedFeature && e->key() == Qt::Key_Delete )
{
mSelectedFeature->beginGeometryChange();
mSelectedFeature->deleteSelectedVertexes();
mCanvas->refresh();
mSelectedFeature->endGeometryChange();
}
}

@@ -61,14 +61,14 @@ QgsSelectedFeature::~QgsSelectedFeature()

void QgsSelectedFeature::currentLayerChanged( QgsMapLayer *layer )
{
QgsDebugMsg( "Entering. " );
QgsDebugMsg( "Entering." );
if ( layer == mVlayer )
deleteLater();
}

void QgsSelectedFeature::updateGeometry( QgsGeometry *geom )
{
QgsDebugMsg( "Entering. " );
QgsDebugMsg( "Entering." );

delete mGeometry;

@@ -100,6 +100,7 @@ void QgsSelectedFeature::setSelectedFeature( QgsFeatureId featureId, QgsVectorLa

delete mRubberBand;
mRubberBand = 0;

delete mGeometry;
mGeometry = 0;

@@ -109,13 +110,13 @@ void QgsSelectedFeature::setSelectedFeature( QgsFeatureId featureId, QgsVectorLa
// feature was deleted
connect( mVlayer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SLOT( featureDeleted( QgsFeatureId ) ) );

// geometry was changed
connect( mVlayer, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry & ) ), this, SLOT( geometryChanged( QgsFeatureId, QgsGeometry & ) ) );

// projection or extents changed
connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( updateVertexMarkersPosition() ) );
connect( canvas, SIGNAL( extentsChanged() ), this, SLOT( updateVertexMarkersPosition() ) );

// geometry was changed
connect( mVlayer, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry & ) ), this, SLOT( geometryChanged( QgsFeatureId, QgsGeometry & ) ) );

replaceVertexMap();
}

@@ -124,7 +125,6 @@ void QgsSelectedFeature::beginGeometryChange()
Q_ASSERT( !mChangingGeometry );
mChangingGeometry = true;

// geometry was changed
disconnect( mVlayer, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry & ) ), this, SLOT( geometryChanged( QgsFeatureId, QgsGeometry & ) ) );
}

@@ -133,7 +133,6 @@ void QgsSelectedFeature::endGeometryChange()
Q_ASSERT( mChangingGeometry );
mChangingGeometry = false;

// geometry was changed
connect( mVlayer, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry & ) ), this, SLOT( geometryChanged( QgsFeatureId, QgsGeometry & ) ) );
}

@@ -151,10 +150,12 @@ void QgsSelectedFeature::featureDeleted( QgsFeatureId fid )
void QgsSelectedFeature::geometryChanged( QgsFeatureId fid, QgsGeometry &geom )
{
QgsDebugMsg( "Entering." );

if ( !mVlayer || fid != mFeatureId )
return;

updateGeometry( &geom );

replaceVertexMap();
}

@@ -228,7 +229,9 @@ void QgsSelectedFeature::deleteSelectedVertexes()
{
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
QMultiMap<double, QgsSnappingResult> currentResultList;

mVlayer->beginEditCommand( QObject::tr( "Deleted vertices" ) );

int count = 0;
for ( int i = mVertexMap.size() - 1; i > -1; i-- )
{
@@ -246,12 +249,14 @@ void QgsSelectedFeature::deleteSelectedVertexes()
currentResultList.clear();
mVlayer->snapWithContext( mVertexMap[i]->point(), ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToVertex );
}

if ( !mVlayer->deleteVertex( mFeatureId, i ) )
{
count = 0;
qDebug( "Setting count 0 and calling break;" );
QgsDebugMsg( QString( "Deleting vertex %1 failed - resetting" ).arg( i ) );
break;
};
}

count++;

if ( topologicalEditing )
@@ -309,7 +314,6 @@ void QgsSelectedFeature::moveSelectedVertexes( double changeX, double changeY )
mVlayer->moveVertex( mVertexMap[i]->point().x(), mVertexMap[i]->point().y(),
resultIt.value().snappedAtGeometry, resultIt.value().snappedVertexNr );
}

}

QgsVertexEntry *entry = mVertexMap[i];
@@ -333,9 +337,6 @@ void QgsSelectedFeature::replaceVertexMap()
// delete old map
deleteVertexMap();

delete mGeometry;
mGeometry = 0;

// create new map
createVertexMap();

@@ -14,8 +14,7 @@
***************************************************************************/

#include "nodetool/qgsvertexentry.h"

#include <qgsmaprenderer.h>
#include "qgsmaprenderer.h"

QgsVertexEntry::QgsVertexEntry( QgsMapCanvas *canvas, QgsMapLayer *layer, QgsPoint p, int originalIndex, QString tooltip, QgsVertexMarker::IconType type, int penWidth )
: mSelected( false )
@@ -54,9 +54,11 @@ class QgsVertexEntry

void setCenter( QgsPoint p );
void moveCenter( double x, double y );

void setEqual( int index ) { mEquals = index; }
void setSelected( bool selected = true );
void setInRubberBand( bool inRubberBand = true ) { mInRubberBand = inRubberBand; }

int rubberBandNr() const { return mRubberBandNr; }
int rubberBandIndex() { return mRubberBandIndex; }

0 comments on commit 6b07241

Please sign in to comment.