Aw: Re: [wxPython] drawing too slow

I have to draw a Starchart with a lot of circles and lines (vectors), text
for each object (the circles) and a grid.
These are Python objects with a Draw() method. This method sets the color
and draws the circles and lines and text.
All I have to do is to iterate the list of objects and call the Draw()
method for the whole chart.
I tried to calculate the boxes to redraw but this takes longer than just
redrawing everything.
The drawn objects are fairly easy, nothing like tetraeder or weird polygons
:slight_smile:

What I try to avoid is using customized versions of standard modules. I
have to make sure that others can install the result themselves
without a compiler or programming knowledge.
Thats why I can't use weave though I think it would work for me.

Thanks,
Mike

Chris Barker <Chris.Barker@noaa.gov>@lists.wxwindows.org on 12.03.2002
18:19:41

Bitte antworten an wxpython-users@lists.wxwindows.org

Gesendet von: wxpython-users-admin@lists.wxwindows.org

Kopie:
Blindkopie:
Mit der Bitte um:
Wiedervorlage:
Titel: Re: [wxPython] drawing too slow

Michael_Perkonigg@uniquare.com wrote:

I have a chart to draw which is too slow in Python and would like to draw
it in a C++ extension.
I would have to use the dc and a list of python objects as parameters, is
that possible?

Give us a little more detail about what it is you want to draw, there
may be a Python solution.

Have you chaecked out or used the new DC.DrawPointList() and
DC.DrawLineList() methods? They speed things up a lot for drawing a lot
of points and lines. by moving the lopp into C++. Robin put them in as a
demo, and it was discussed to add a full set of DrawObjectList methods
for rectangles, polygons etc. I think the speed up will be less
substantial for more complex objects, but I'd love to have them anyway.
I have been using the two existing methods with good results, and I
intend to delve into the C++ to add the other eventually. If they would
work for you ,it would be a great contribution to the wxPython project.

-Chris

···

An: wxpython-users@lists.wxwindows.org
Datum: 12.03.2002 18:25:48

--
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

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

Michael_Perkonigg@uniquare.com wrote:

I have to draw a Starchart with a lot of circles and lines (vectors), text
for each object (the circles) and a grid.
These are Python objects with a Draw() method. This method sets the color
and draws the circles and lines and text.
All I have to do is to iterate the list of objects and call the Draw()
method for the whole chart.

You must have a lot of stuff to draw. I am doing this, and I don't have
any problems until I get into thousands of objects. One thing that might
help is to double buffer your image. That way you will only have to draw
when the image changes, and not on every OnPaint event. It will still be
just as slow when you do change the image, but it may be more tolerable
that way. I t really drives me crazy to have to wait for a screen to
re-draw when it gets uncovered.

If double buffering isn't good enough, you could do what I have just
implimented in a project: triple buffering. Each object has a
"foreground" flag that indicates it is in the foreground. I put the
objects in the foreground that change a lot, so I can keep the
background in a buffer, and just do a quick blit of the background, and
then re-draw only the foreground objects. The result is then blitted to
the screen. In my first test, I can now draw 1000 points on top of the
complex image, and have a them move around with a frame rate of about 50
fps. It would probably be faster if I didnt have to re-calculate the
positions of the points each time as well. This is on a 1Ghz PIII laptop
running Linux and wxGTK.

Let me know if you want to see my code, and I'll send you a copy.

What I try to avoid is using customized versions of standard modules. I
have to make sure that others can install the result themselves
without a compiler or programming knowledge.
Thats why I can't use weave though I think it would work for me.

It sounds like you are considering writting some C++ code, so I don't
see how you can avoid this...

Robin Dunn wrote:

Look at the Python docs about Extending Python.

Your extension will have to include export.h from wxPython and call
wxPyCoreAPI_IMPORT() in it's init function. Then look at the extension
functions that SWIG generates in the wxPython sources and use similar code
for your drawing function.

Be sure to look at the DrawPointList() and DrawLineList() code. You may
be able to use these, and then add a set of DrawCircleList(), etc.
methods. Using these would require you to re-structure your Python code,
so that your Python objects were sequences of individual objects, rather
than jsut individual objects. The advantage of this approach is that you
would have made a general purpose performance enhancement to wxDC, and
Robin could include it in future version of wxPython. This would avoid
your "custom version" problem, and give you something you and others can
use for other things. This is a selfish suggestion, as I'm someone who
would use it!

I'd like to know what you come up with. I'm working on a Floating Point
coordinate canvas that is zoomable and scalable, and I could use a fast
way to call the draw() method on them too. At the moment, I am making
use of DrawPointList, and intend to add DrawLinelist and hopefully other
DrawStuffLists, if I can get the chance to write the C++.

-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