Skip to content

Commit

Permalink
- added possibility not to update rubberband when adding point
Browse files Browse the repository at this point in the history
- 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 10f9dbc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/gui/qgsrubberband.cpp
Expand Up @@ -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();
}
}

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

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

6 changes: 5 additions & 1 deletion src/gui/qgsrubberband.h
Expand Up @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion src/plugins/grass/qgsgrassedit.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 10f9dbc

Please sign in to comment.