Skip to content

Commit

Permalink
Fix rubberband issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Aug 28, 2015
1 parent ebf3bac commit 8b82584
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/core/geometry/qgscircularstringv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ bool QgsCircularStringV2::insertVertex( const QgsVertexId& position, const QgsPo
{
insertVertexBetween( position.vertex, position.vertex + 1, position.vertex - 1 );
}
mBoundingBox = QgsRectangle(); //set bounding box invalid
return true;
}

Expand Down Expand Up @@ -749,6 +750,7 @@ bool QgsCircularStringV2::deleteVertex( const QgsVertexId& position )
deleteVertex( position.vertex - 1 );
}

mBoundingBox = QgsRectangle(); //set bounding box invalid
return true;
}

Expand Down
25 changes: 21 additions & 4 deletions src/core/geometry/qgscompoundcurvev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,13 @@ bool QgsCompoundCurveV2::insertVertex( const QgsVertexId& position, const QgsPoi
{
return false;
}
return mCurves[curveId]->insertVertex( curveIds.at( 0 ).second, vertex );

bool success = mCurves[curveId]->insertVertex( curveIds.at( 0 ).second, vertex );
if ( success )
{
mBoundingBox = QgsRectangle(); //bbox changed
}
return success;
}

bool QgsCompoundCurveV2::moveVertex( const QgsVertexId& position, const QgsPointV2& newPos )
Expand All @@ -478,8 +484,13 @@ bool QgsCompoundCurveV2::moveVertex( const QgsVertexId& position, const QgsPoint
{
mCurves[idIt->first]->moveVertex( idIt->second, newPos );
}
mBoundingBox = QgsRectangle(); //bbox changed
return curveIds.size() > 0;

bool success = curveIds.size() > 0;
if ( success )
{
mBoundingBox = QgsRectangle(); //bbox changed
}
return success;
}

bool QgsCompoundCurveV2::deleteVertex( const QgsVertexId& position )
Expand All @@ -490,7 +501,13 @@ bool QgsCompoundCurveV2::deleteVertex( const QgsVertexId& position )
{
mCurves[idIt->first]->deleteVertex( idIt->second );
}
return curveIds.size() > 0;

bool success = curveIds.size() > 0;
if ( success )
{
mBoundingBox = QgsRectangle(); //bbox changed
}
return success;
}

QList< QPair<int, QgsVertexId> > QgsCompoundCurveV2::curveVertexId( const QgsVertexId& id ) const
Expand Down
8 changes: 7 additions & 1 deletion src/core/geometry/qgscurvepolygonv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,19 @@ bool QgsCurvePolygonV2::insertVertex( const QgsVertexId& vId, const QgsPointV2&
QgsCurveV2* ring = vId.ring == 0 ? mExteriorRing : mInteriorRings[vId.ring - 1];
int n = ring->numPoints();
bool success = ring->insertVertex( QgsVertexId( 0, 0, vId.vertex ), vertex );
if ( !success )
{
return false;
}

// If first or last vertex is inserted, re-sync the last/first vertex
if ( vId.vertex == 0 )
ring->moveVertex( QgsVertexId( 0, 0, n ), vertex );
else if ( vId.vertex == n )
ring->moveVertex( QgsVertexId( 0, 0, 0 ), vertex );

return success;
mBoundingBox = QgsRectangle();
return true;
}

bool QgsCurvePolygonV2::moveVertex( const QgsVertexId& vId, const QgsPointV2& newPos )
Expand Down
18 changes: 16 additions & 2 deletions src/core/geometry/qgsgeometrycollectionv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,12 @@ bool QgsGeometryCollectionV2::insertVertex( const QgsVertexId& position, const Q
return false;
}

return mGeometries[position.part]->insertVertex( position, vertex );
bool success = mGeometries[position.part]->insertVertex( position, vertex );
if ( success )
{
mBoundingBox = QgsRectangle(); //set bounding box invalid
}
return success;
}

bool QgsGeometryCollectionV2::moveVertex( const QgsVertexId& position, const QgsPointV2& newPos )
Expand All @@ -377,7 +382,12 @@ bool QgsGeometryCollectionV2::moveVertex( const QgsVertexId& position, const Qgs
return false;
}

return mGeometries[position.part]->moveVertex( position, newPos );
bool success = mGeometries[position.part]->moveVertex( position, newPos );
if ( success )
{
mBoundingBox = QgsRectangle(); //set bounding box invalid
}
return success;
}

bool QgsGeometryCollectionV2::deleteVertex( const QgsVertexId& position )
Expand All @@ -401,6 +411,10 @@ bool QgsGeometryCollectionV2::deleteVertex( const QgsVertexId& position )
removeGeometry( position.part );
}

if ( success )
{
mBoundingBox = QgsRectangle(); //set bounding box invalid
}
return success;
}

Expand Down
3 changes: 3 additions & 0 deletions src/core/geometry/qgslinestringv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ bool QgsLineStringV2::insertVertex( const QgsVertexId& position, const QgsPointV
{
mM.insert( position.vertex, vertex.m() );
}
mBoundingBox = QgsRectangle(); //set bounding box invalid
return true;
}

Expand Down Expand Up @@ -397,6 +398,7 @@ bool QgsLineStringV2::deleteVertex( const QgsVertexId& position )
{
mM.remove( position.vertex );
}
mBoundingBox = QgsRectangle(); //set bounding box invalid
return true;
}

Expand All @@ -416,6 +418,7 @@ void QgsLineStringV2::addVertex( const QgsPointV2& pt )
{
mM.append( pt.m() );
}
mBoundingBox = QgsRectangle(); //set bounding box invalid
}

double QgsLineStringV2::closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsgeometryrubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <QPainter>

QgsGeometryRubberBand::QgsGeometryRubberBand( QgsMapCanvas* mapCanvas, QGis::GeometryType geomType ): QgsMapCanvasItem( mapCanvas ),
mGeometry( 0 ), mIconSize( 5 ), mIconType( ICON_CIRCLE ), mGeometryType( geomType )
mGeometry( 0 ), mIconSize( 5 ), mIconType( ICON_BOX ), mGeometryType( geomType )
{
mPen = QPen( QColor( 255, 0, 0 ) );
mBrush = QBrush( QColor( 255, 0, 0 ) );
Expand Down

0 comments on commit 8b82584

Please sign in to comment.