Help with axes in CAD type operations

Hi, I’m trying to do some CAD type things with Matplotlib.
I’m using python 2.4 with both PS and GTK backends in WinXP. Specifically,
I’m trying to find distances between objects (lines, polygons, circles),
so I’d like to extract all the elements/lines/polygons/arcs/circles in an
axis, but I don’t see how to do that.

Also, I need to draw arcs, but it seems I can only do that by
directly manipulating the renderer. I’m trying to get everything
done using only the pylab interface. I tried creating a RendererPS
directly, but it took some funny arguments (eg a StreamIO) which I wasn’t
sure what to do with.

Any suggestions would be great.

Thanks

Michael

Michael,

I'm probably not the right person to be answering, but in the absence of other responses I will try.

Michael Schwager wrote:

Hi, I’m trying to do some CAD type things with Matplotlib. I’m using python 2.4 with both PS and GTK backends in WinXP. Specifically, I’m trying to find distances between objects (lines, polygons, circles), so I’d like to extract all the elements/lines/polygons/arcs/circles in an axis, but I don’t see how to do that.

When you say "distances", do you mean distances in physical coordinates as rendered? Is that why you can't simply use the data you are plotting directly? If so, maybe the thing to do is use the same transforms that are used in rendering, but apply them to your input data yourself, and then do the calculations on your transformed data. Every Artist includes the transforms that are used in transforming the input data to physical coordinates. These physical coordinates do not get saved, but they can be reconstructed.

Also, I need to draw arcs, but it seems I can only do that by directly manipulating the renderer. I’m trying to get everything done using only the pylab interface. I tried creating a RendererPS directly, but it took some funny arguments (eg a StreamIO) which I wasn’t sure what to do with.

The matplotlib drawing model is very basic; the way to make an arc without writing your own backend is to calculate an adequate number of points and then plot them as a line. For example, you could subclass Axes and add an "arc" method that does this.

Longer term, it probably makes sense to expand the matplotlib drawing model to include more primitives such as arcs, using the native functionality to render them when possible. This could make quite a few things more efficient.

Eric