Skip to content

Commit 10f9dbc

Browse files
author
wonder
committedSep 27, 2006
- 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
1 parent e642476 commit 10f9dbc

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed
 

‎src/gui/qgsrubberband.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,15 @@ void QgsRubberBand::reset(bool isPolygon)
6565
/*!
6666
Add a point to the shape being created.
6767
*/
68-
void QgsRubberBand::addPoint(const QgsPoint & p)
68+
void QgsRubberBand::addPoint(const QgsPoint & p, bool update /* = true */)
6969
{
7070
mPoints[mPoints.size()-1] = p; // Current mouse position becomes added point
7171
mPoints.push_back(p); // Allocate new point to continue tracking current mouse position
72-
updateRect();
73-
updateCanvas();
72+
if (update)
73+
{
74+
updateRect();
75+
updateCanvas();
76+
}
7477
}
7578

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

134137
setVisible(mPoints.size() > 1);
135-
}
138+
}
139+

‎src/gui/qgsrubberband.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ class QgsRubberBand: public QgsMapCanvasItem
3333
void setWidth(int width);
3434

3535
void reset(bool isPolygon = false);
36-
void addPoint(const QgsPoint & p);
36+
37+
//! Add point to rubberband and update canvas
38+
//! If adding more points consider using update=false for better performance
39+
void addPoint(const QgsPoint & p, bool update = true);
40+
3741
void movePoint(const QgsPoint & p);
3842
void movePoint(int index, const QgsPoint& p);
3943

‎src/plugins/grass/qgsgrassedit.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,8 +1692,12 @@ void QgsGrassEdit::displayDynamic ( struct line_pnts *Points, double x, double y
16921692
point.setX(Points->x[i]);
16931693
point.setY(Points->y[i]);
16941694
point = transformLayerToMap ( point );
1695-
mRubberBandLine->addPoint(point);
1695+
mRubberBandLine->addPoint(point, false); // false = don't update now
16961696
}
1697+
// Now add the last point again and force update of rubberband.
1698+
// This should improve the performance as canvas is updated only once
1699+
// and not with every added point to rubberband.
1700+
mRubberBandLine->addPoint(point, true);
16971701
}
16981702

16991703
mRubberBandIcon->setIconType(type);

0 commit comments

Comments
 (0)
Please sign in to comment.