Martin Landa wrote:
I need to draw to DC huge number (> 1e6) of objects
That's a LOT of objects -- can you really see them all at the same time?
You might want to do a bounding box check or something first. You might
also want to see if you can change what you draw depending on scale.
Also, is all this stuff changing? you could perhaps buffer some of it.
(GIS application,
tool for editing vector maps).
Cool -- I"d love to see what you come up with. Also, be sure to check
out FloatCanvas (wx.lib.floatcanvas, or newer version at:
http://morticia.cs.dal.ca/FloatCanvas/
It takes care of a lot of this for you. I'm also hoping to add more
GISey stuff with it -- I'd love help!
There is simplified OnPaint fn.
dc = wx.BufferedPaintDC(self, self._Buffer)
import time
start = time.clock()
nlines = 1000000
for i in range(nlines):
dc.DrawLine(0, 0, 100, 100)
stop = time.clock()
print >> sys.stderr, "time=%f" % (stop-start)
Maybe this is just a test, but the point of a bufferedDC is that you can
just blit the buffer in the OnPaint -- you only want to draw when
something changes (again, see FloatCanvas)
For example for 1e6 objects time needed for drawing is 3.4s on my
machine. But the applications is frozen for 10s and more.
The time for the Draw calls to return isn't necessarily how long it
really takes to draw. At least with GTK, X is asynchronous, so it's hard
to time the drawing.
Also, calling DrawLine a bunch of times is going to be slower than
DrawLines() or DrawLineList()
I hope some of this helps.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (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