Skip to content
Permalink
Browse files

fix #4858

  • Loading branch information
jef-n committed Jan 23, 2012
1 parent 32f3690 commit b4f7a612ca420f5ff8912c1efe5bea4bbee11c84
@@ -289,8 +289,8 @@ void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )
double x = mapCoords.x() + posMapCoord.x() - firstCoords.x();
double y = mapCoords.y() + posMapCoord.y() - firstCoords.y();

mRubberBands[vertexMap[i]->rubberBandNr()]->movePoint( vertexMap[i]->index(), QgsPoint( x, y ) );
if ( vertexMap[i]->index() == 0 )
mRubberBands[vertexMap[i]->rubberBandNr()]->movePoint( vertexMap[i]->rubberBandIndex(), QgsPoint( x, y ) );
if ( vertexMap[i]->rubberBandIndex() == 0 )
{
mRubberBands[vertexMap[i]->rubberBandNr()]->movePoint( 0, QgsPoint( x, y ) );
}
@@ -374,18 +374,12 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
dist = sqrt( dist );

mSnapper.snapToCurrentLayer( e->pos(), snapResults, QgsSnapper::SnapToVertex, tol );
// if (snapResults.size() < 1)
if ( dist > tol )
{
// for points only selecting another feature
// no vertexes found (selecting or inverting selection) if move
// or select another feature if clicked there
QgsSnapper::SnappingType snapType = QgsSnapper::SnapToSegment;
if ( mIsPoint )
{
snapType = QgsSnapper::SnapToVertex;
}
mSnapper.snapToCurrentLayer( e->pos(), snapResults, snapType, tol );
mSnapper.snapToCurrentLayer( e->pos(), snapResults, mIsPoint ? QgsSnapper::SnapToVertex : QgsSnapper::SnapToSegment, tol );
if ( snapResults.size() > 0 )
{
// need to check all if there is a point in my selected feature
@@ -646,7 +640,6 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
}

vlayer->beginEditCommand( tr( "Inserted vertex" ) );
mSelectedFeature->beginGeometryChange();

// add vertex
vlayer->insertVertex( layerCoords.x(), layerCoords.y(), mSelectedFeature->featureId(), snapResults.first().afterVertexNr );
@@ -667,8 +660,6 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )

// make sure that new node gets its vertex marker
mCanvas->refresh();

mSelectedFeature->endGeometryChange();
}

QgsPoint QgsMapToolNodeTool::closestVertex( QgsPoint point )
@@ -374,13 +374,12 @@ void QgsSelectedFeature::createVertexMapPolygon()
for ( int i2 = 0; i2 < polygon.size(); i2++ )
{
const QgsPolyline& poly = polygon[i2];
int i;
for ( i = 0; i < poly.size(); i++ )
for ( int i = 0; i < poly.size(); i++ )
{
mVertexMap.insert( y + i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], i, tr( "ring %1, vertex %2" ).arg( i2 ).arg( i ) ) );
}
mVertexMap[y + i - 1 ]->setEqual( y );
mVertexMap[y]->setEqual( y + i - 1 );
mVertexMap[y + poly.size() - 1 ]->setEqual( y );
mVertexMap[y]->setEqual( y + poly.size() - 1 );
y += poly.size();
}
}
@@ -395,13 +394,12 @@ void QgsSelectedFeature::createVertexMapPolygon()
{
// iterating through polygon rings
const QgsPolyline& poly = poly2[i3];
int i;
for ( i = 0; i < poly.size(); i++ )
for ( int i = 0; i < poly.size(); i++ )
{
mVertexMap.insert( y + i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], y + i - 1, tr( "polygon %1, ring %2, vertex %3" ).arg( i2 ).arg( i3 ).arg( i ) ) );
}
mVertexMap[y + i - 1]->setEqual( y );
mVertexMap[y]->setEqual( y + i - 1 );
mVertexMap[y + poly.size() - 1]->setEqual( y );
mVertexMap[y]->setEqual( y + poly.size() - 1 );
y += poly.size();
}
}
@@ -420,8 +418,7 @@ void QgsSelectedFeature::createVertexMapLine()
{
// iterating through polylines
QgsPolyline poly = mLine[i2];
int i;
for ( i = 0; i < poly.size(); i++ )
for ( int i = 0; i < poly.size(); i++ )
{
mVertexMap.insert( y + i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], i, tr( "polyline %1, vertex %2" ).arg( i2 ).arg( i ) ) );
}
@@ -431,8 +428,7 @@ void QgsSelectedFeature::createVertexMapLine()
else
{
QgsPolyline poly = mGeometry->asPolyline();
int i;
for ( i = 0; i < poly.size(); i++ )
for ( int i = 0; i < poly.size(); i++ )
{
mVertexMap.insert( i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], i, tr( "vertex %1" ).arg( i ) ) );
}
@@ -447,10 +443,9 @@ void QgsSelectedFeature::createVertexMapPoint()
{
// multipoint
QgsMultiPoint poly = mGeometry->asMultiPoint();
int i;
for ( i = 0; i < poly.size(); i++ )
for ( int i = 0; i < poly.size(); i++ )
{
mVertexMap.insert( i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], 1, tr( "point %1" ).arg( i ) ) );
mVertexMap.insert( i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], 1, tr( "point %1" ).arg( i ) ) );
}
}
else
@@ -86,9 +86,9 @@ void QgsVertexEntry::setSelected( bool selected )

void QgsVertexEntry::setRubberBandValues( bool inRubberBand, int rubberBandNr, int indexInRubberBand )
{
mIndex = indexInRubberBand;
mInRubberBand = inRubberBand;
mRubberBandNr = rubberBandNr;
mRubberBandIndex = indexInRubberBand;
mInRubberBand = inRubberBand;
mRubberBandNr = rubberBandNr;
}

void QgsVertexEntry::update()
@@ -28,7 +28,7 @@ class QgsVertexEntry
int mEquals;
bool mInRubberBand;
int mRubberBandNr;
int mIndex;
int mRubberBandIndex;
int mOriginalIndex;
int mPenWidth;
QString mToolTip;
@@ -58,7 +58,7 @@ class QgsVertexEntry
void setSelected( bool selected = true );
void setInRubberBand( bool inRubberBand = true ) { mInRubberBand = inRubberBand; }
int rubberBandNr() const { return mRubberBandNr; }
int index() { return mIndex; }
int rubberBandIndex() { return mRubberBandIndex; }

void setRubberBandValues( bool inRubberBand, int rubberBandNr, int indexInRubberBand );
void update();

0 comments on commit b4f7a61

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