Skip to content
Permalink
Browse files
- added possibility not to update rubberband when adding point
- improved performance of GRASS digitizing - canvas is updated only once instead of [number of points]-times


git-svn-id: http://svn.osgeo.org/qgis/trunk@5878 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Sep 27, 2006
1 parent e642476 commit 10f9dbc460e234e6d2bbbfec6193aad87a1cbb2f
Showing with 18 additions and 6 deletions.
  1. +8 −4 src/gui/qgsrubberband.cpp
  2. +5 −1 src/gui/qgsrubberband.h
  3. +5 −1 src/plugins/grass/qgsgrassedit.cpp
@@ -65,12 +65,15 @@ void QgsRubberBand::reset(bool isPolygon)
/*!
Add a point to the shape being created.
*/
void QgsRubberBand::addPoint(const QgsPoint & p)
void QgsRubberBand::addPoint(const QgsPoint & p, bool update /* = true */)
{
mPoints[mPoints.size()-1] = p; // Current mouse position becomes added point
mPoints.push_back(p); // Allocate new point to continue tracking current mouse position
updateRect();
updateCanvas();
if (update)
{
updateRect();
updateCanvas();
}
}

/*!
@@ -132,4 +135,5 @@ void QgsRubberBand::updateRect()
}

setVisible(mPoints.size() > 1);
}
}

@@ -33,7 +33,11 @@ class QgsRubberBand: public QgsMapCanvasItem
void setWidth(int width);

void reset(bool isPolygon = false);
void addPoint(const QgsPoint & p);

//! Add point to rubberband and update canvas
//! If adding more points consider using update=false for better performance
void addPoint(const QgsPoint & p, bool update = true);

void movePoint(const QgsPoint & p);
void movePoint(int index, const QgsPoint& p);

@@ -1692,8 +1692,12 @@ void QgsGrassEdit::displayDynamic ( struct line_pnts *Points, double x, double y
point.setX(Points->x[i]);
point.setY(Points->y[i]);
point = transformLayerToMap ( point );
mRubberBandLine->addPoint(point);
mRubberBandLine->addPoint(point, false); // false = don't update now
}
// Now add the last point again and force update of rubberband.
// This should improve the performance as canvas is updated only once
// and not with every added point to rubberband.
mRubberBandLine->addPoint(point, true);
}

mRubberBandIcon->setIconType(type);

0 comments on commit 10f9dbc

Please sign in to comment.