[QGIS Commit] r14679 - trunk/qgis/src/gui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Nov 15 04:31:10 EST 2010
Author: jef
Date: 2010-11-15 01:31:10 -0800 (Mon, 15 Nov 2010)
New Revision: 14679
Modified:
trunk/qgis/src/gui/qgsrubberband.cpp
Log:
fix starting point duplication in rubberband when using addPoint thought the API
Modified: trunk/qgis/src/gui/qgsrubberband.cpp
===================================================================
--- trunk/qgis/src/gui/qgsrubberband.cpp 2010-11-15 00:33:57 UTC (rev 14678)
+++ trunk/qgis/src/gui/qgsrubberband.cpp 2010-11-15 09:31:10 UTC (rev 14679)
@@ -29,17 +29,22 @@
for tracking the mouse while drawing polylines or polygons.
*/
QgsRubberBand::QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon )
- : QgsMapCanvasItem( mapCanvas ), mIsPolygon( isPolygon ), mTranslationOffsetX( 0.0 ), mTranslationOffsetY( 0.0 )
+ : QgsMapCanvasItem( mapCanvas )
+ , mIsPolygon( isPolygon )
+ , mTranslationOffsetX( 0.0 )
+ , mTranslationOffsetY( 0.0 )
{
reset( isPolygon );
setColor( QColor( Qt::lightGray ) );
}
QgsRubberBand::QgsRubberBand(): QgsMapCanvasItem( 0 )
-{}
+{
+}
QgsRubberBand::~QgsRubberBand()
-{}
+{
+}
/*!
Set the outline and fill color.
@@ -88,16 +93,20 @@
if ( geometryIndex == mPoints.size() )
{
- mPoints.push_back( QList<QgsPoint>() );
+ mPoints.push_back( QList<QgsPoint>() << p );
}
- //we need to set two points at the begin of the rubber band for operations that move the last point
- if ( mPoints[geometryIndex].size() == 0 )
+ if ( mPoints[geometryIndex].size() == 2 &&
+ mPoints[geometryIndex][0] == mPoints[geometryIndex][1] )
{
- mPoints[geometryIndex].push_back( p );
+ mPoints[geometryIndex].last() = p;
}
- mPoints[geometryIndex].push_back( p );
+ else
+ {
+ mPoints[geometryIndex] << p;
+ }
+
if ( do_update )
{
updateRect();
@@ -136,7 +145,7 @@
return;
}
- mPoints[geometryIndex][mPoints.at( geometryIndex ).size() - 1] = p;
+ mPoints[geometryIndex].last() = p;
updateRect();
update();
@@ -349,7 +358,6 @@
QList<QgsPoint>::const_iterator it = mPoints.at( i ).constBegin();
for ( ; it != mPoints.at( i ).constEnd(); ++it )
{
- //QgsDebugMsg("Drawing rubberband vertex: " + QString::number(it->x() + mTranslationOffsetX) + "//" + QString::number(it->y() + mTranslationOffsetY));
pts.append( toCanvasCoordinates( QgsPoint( it->x() + mTranslationOffsetX, it->y() + mTranslationOffsetY ) ) - pos() );
}
@@ -384,9 +392,7 @@
for ( ; it != mPoints.at( i ).constEnd(); ++it )
{
r.combineExtentWith( it->x() + mTranslationOffsetX, it->y() + mTranslationOffsetY );
- //QgsDebugMsg("Combining extent with: " + QString::number(it->x()) + "//" + QString::number(it->y()));
}
- //QgsDebugMsg("r: " + r.toString());
}
setRect( r );
}
More information about the QGIS-commit
mailing list