Skip to content

Commit

Permalink
fix #4858
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jan 23, 2012
1 parent 32f3690 commit b4f7a61
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 32 deletions.
15 changes: 3 additions & 12 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand All @@ -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 )
Expand Down
25 changes: 10 additions & 15 deletions src/app/nodetool/qgsselectedfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -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();
}
}
Expand All @@ -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 ) ) );
}
Expand All @@ -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 ) ) );
}
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/app/nodetool/qgsvertexentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/app/nodetool/qgsvertexentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class QgsVertexEntry
int mEquals;
bool mInRubberBand;
int mRubberBandNr;
int mIndex;
int mRubberBandIndex;
int mOriginalIndex;
int mPenWidth;
QString mToolTip;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b4f7a61

Please sign in to comment.