wxDC and Refresh()??

Stefan Holmgren wrote:

is it possible to speed up the refresh for a dc?
my python code looks like this,
(created on a wxScrolledWindow:).

----------------
def onPaint(self, event):
    self.doDraw(wxPaintDC(self))

def doDraw(self, dc):
    self.dc.SetUserScale(self.scale, self.scale)

    alot of this.....
    self.dc.DrawPolygon(drawlist)
    .....
---------------

when I change 'self.scale' or a color for an
object I have to make a Refresh().

you need to re-draw the DC, but you may not need to call Refresh(). You
can change the image on the screen by creating and drawing to a
wxClientDC.

With lot of drawing object, the update for the dc
take time.

How many is a LOT? if it is hundreds, you shouldn't have a problem
(depending on hardware) if it is thousands, it just might take a long
time to do the drawing. If so, you have a few options:

1) make sure to use DC.DrawLineList and DC.DrawPointList() if you can.
See the demo under Miscellaneous.

2) Double buffer. This is usually used to speed refreshes if the drawing
hasn't changed, but if the drdawing has changed, it may be that only
part of the drawing is changing regularly, and the rest is a background
of sorts. In this case, you could store the background in a buffer, and
only re-draw the foreground.

3) Perhaps using DC.SetClippingRegion can help you here

If the problem is not the time it takes to do the drawing itself, you
may be caling your doDraw method too many times. Put a print statement
in your doDraw method, and see how often it gets called.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov