DrawRectangleList revisited

Where is the C++ source for DrawPointList and DrawLineList? I'm searching
around in

http://cvs.wxwindows.org/viewcvs.cgi/

but so far haven't found the files. I'm feeling a real need for a
DrawRectangleList method and even though I don't really remember much C++
programming, I figure it can't be that difficult to support a rectangle
versus a Line, so I'm willing to copy and paste ;-). So far we already have
support for drawing a list of points where internally the C++ uses
DrawPoint.

DrawPoint(wxCoord x, wxCoord y)

And DrawLineList internally uses DrawLine.

DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)

That is very close to what DrawRectangleList would need.

DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)

The wxWindows docs also say

"Please note that in addition to the versions of the methods documented
here, there are also versions which accept single wxPoint parameter instead
of two wxCoord ones or wxPoint and wxSize instead of four of them."

and I don't know if the DrawPointList and DrawLineList deal with that.

Anyway, I'm pushing for a DrawRectangleList again :slight_smile: Is the complication
that a list of brushes also needs to be supported? I guess the code that
handles the list of pens would be quite similar to what we need for the
brushes?

Finally, DrawEllipseList could be almost identical to what is done for
DrawRectangleList but at least in the docs it does list the variants for
DrawEllipse calls while DrawRectangle does not in case that matters.

"
wxDC::DrawEllipse
void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)

void DrawEllipse(const wxPoint& pt, const wxSize& size)

void DrawEllipse(const wxRect& rect)

Draws an ellipse contained in the rectangle specified either with the given
top left corner and the given size or directly. The current pen is used for
the outline and the current brush for filling the shape.
"

ka

Kevin Altis wrote:

Where is the C++ source for DrawPointList and DrawLineList? I'm searching
around in

http://cvs.wxwindows.org/viewcvs.cgi/

but so far haven't found the files.

They are in gdi.i located in wxWindows/wxPython/src. Look near the end of the wxDC class definition. They're inside a SWIG %addmethods directive, with a little bit of Python wrapper code defined just below that.

The wxWindows docs also say

"Please note that in addition to the versions of the methods documented
here, there are also versions which accept single wxPoint parameter instead
of two wxCoord ones or wxPoint and wxSize instead of four of them."

Yeah, the various wxDC Draw methods only had the wxCoord versions when they were wrapped, the overloads with wxPoint, wxRect, etc. came later. I've held off adding the other wrappers because I really wanted the new methods to be the default ones (without a name change) but that would break too much code... Maybe for 3.0...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Kevin Altis wrote:

I'm feeling a real need for a
DrawRectangleList method and even though I don't really remember much C++
programming, I figure it can't be that difficult to support a rectangle
versus a Line, so I'm willing to copy and paste ;-).

For what it's worth, this has been on my list for a LONG time, and I'd
be glad to help. Unfortunately, my C++ skills are probably worse than
yours.

Anyway, I'm pushing for a DrawRectangleList again :slight_smile: Is the complication
that a list of brushes also needs to be supported? I guess the code that
handles the list of pens would be quite similar to what we need for the
brushes?

Probably. I don't think it's a complication really, so much as that no
one has gotten around to doing it yet. When this whole idea was
initialized, a few of us talked about it, and then Robin was nice enough
to do DrawPointList and DrawLineList as a proof of concept. At the time,
I said that I would use those prototypes to help me write the rest of
them, but havn't yet gotten around to it.

One note about performance:

DrawPointList and DrawLineList are a LOT faster that looping in Python
for a lot of objects (~1000). However, I don't think we'll see the same
kind of improvement from the same approach with more complicated
objects. The reason is that it takes less time to draw a point (at the
C++ level) than it does to do a loop in Python. This isn't the case for
a complex polygon, for example. You can see this effect allready in that
DrawPointList provides more of a speed improvement that DrawLineList.
That being said, I still think it's well worth doing (and rectangles are
probably pretty fast).

Finally, DrawEllipseList could be almost identical to what is done for
DrawRectangleList

Yep. And we need DrawLinesList (note the "s"), DrawPolygonList, and are
there any others?

By the way, DrawLines() is really a confusing name for what should be
DrawPolyline(), but I suppose it's too late to change that!

-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