I'm creating a drawing program, and am using a wx,Overlay to produce rubber band drawing for ellipses/circles/rectangles etc.
My drawing code for the Rectangle is as follows:
draw is called with replay as False, as using True is used when render all the currently drawn shapes
def draw(self, dc, replay=True):
dc.SetPen(self.pen)
dc.SetBrush(wx.TRANSPARENT_BRUSH)
if not replay:
self.draw_outline(dc)
dc.DrawRectangle(self.x, self.y.....
def draw_outline(self, dc):
odc = wx.DCOverlay(self.board.overlay, dc)
odc.Clear()
def button_up(self, x, y):
"""
Clears the created overlay for rubber banding.
"""
dc = wx.ClientDC(self.board)
odc = wx.DCOverlay(self.board.overlay, dc)
odc.Clear()
self.board.overlay.Reset()
self.board.Refresh() # show self on whyteboard
Now, on my machine, Ubuntu 8.10, Nvidia 8800GT / 180.27 drivers, AMD X2-3800, 2.5GHz, 2GB low-latency DDR RAM my application runs fine. I click the button which creates an object for drawing an ellipse, left click in my drawing panel to begin the drawing and it renders instantly.
On the machines in university, Ubuntu 8.04, Nvidia 8600GT / Intel Quad core, 2.6GHz, 3GB RAM ..but I'm pretty sure there's no graphics drivers, drawing freestyle, with a pen runs smoothly, no issues there.
However, when drawing a rubber band shape like a circle or rectangle, there is a noticeable second or more lag from pressing the left mouse button and holding it, moving the mouse and the rectangle appearing on screen. If I do this like twice then it seems to snap out of the lag, and work as smoothly as on my machine. Changing shapes then, say rectangle-> circle then causes the same lag when trying to draw initially
it also seems to happen if you left click, hold down the mouse and try and drag out the outline in all directions, after 3 seconds of lag and maybe one screen update every second, the lag wears off and you can drag the outline great.
http://bazaar.launchpad.net/~sproaty/whyteboard/development/files - grab the complete code from here; of interest is whyteboard.py for the panel which can be drawn upon, and the Rectangle class in tools.py - all the other 'rubber band' classes extend from Rectangle
Thanks for your time,
Steven Sproat