Trying to understand GraphicsPath

Christopher Barker wrote:

sure about FC2 -- it's brand new). The best way to check it out is to take a look at the demos in the source (I don't think all the little ones are distributed with wxPython right now):

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/Demos/

MovingElements.py

Should get you started.

Make sure to check out Tree.py too.

-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

Christopher Barker wrote:

Frank Millman wrote:

1. This is my first attempt at drawing, so I am definitely feeling my way. I
have looked at OGL and OGLLike, but a lack of documentation meant that I
could not be sure that they would give me all the functionality I need, and
I did not want to spend a lot of time only to find that it was wasted.

Well, it's more fun to write code than docs!

I don't know anything about OGL, but it sure looks like it was made for this sort of thing! Did you ask on the list? Do we know if the author (of the python version) is actively maintaining it or at least answering questions?

He still answers questions now and then, and I've been applying patches that have been submitted. Since it's all Python code now it's much easier for the people using OGL to be able to fix bugs or create enhancements for it, and there's been a few instances of that happening over the past few years.

···

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

Bryan Cole wrote:

Very nice! This could be just what we're looking for! Have you contributed that code to the pyCairo project?

No, but this would indeed be the best home for it.

I agree -- I encourage you to contribute.

I'm kinda rusty on the
full details of defining python types in C.

I don't know how the Cairo bindings are developed, bu the types are defined, you'd just need to add a method or two.

It should be doable without requiring any numpy headers (like was done for PIL, for instance). Using the array interface for transferring bitmaps to/from Cairo would be nice, too.

What interface does PIL use? buffer or array?

It uses the new array interface (I think)

I just used the numpy API
directly. I hope to maintain compatibility with py-2.4.

The goal is to avoid using the numpy API, 'cause then you need to include the numpy headers to built it, and then it only works with numpy. the goal of the new nd-array interface is that multiple packages can all provide the same interface, and therefor exchange data.

It's really an extension of the buffer interface -- it's a buffer with some description of the what the data represents -- i.e. a NX100 array of doubles, rather than just 1600 bytes of who knows what.

You can get all the details, and help, from the numpy list.

* Is there a way to manipulate just part of a path once it is constructed? i.e. you make a path for a 1000pt polygon, and you want to change the location of the 564th point -- can you do that, or do you need to create a whole new path?

This is a bit tricky. The path data structure is a "ragged" C-array.
Adding extra points in would require recreating the array. Editing
existing points would be possible (probably) but accessing a point in
the middle of the array requires iteration over each item to get there
(because elements may have different lengths). Pycairo doesn't provide
any sort of access to the internal data, so this would need a new API.

It doesn't sound like this is what Cairo is designed for at all. Particularly in the special case of a simple polygon, you could do it, but it's probably not worth it.

In any case, I think the overhead of recreating each path
from a python data structure is dwarfed by the cost of antialiased
rendering, so there's not too much value in attempting to maintain
direct access to the path internal data.

well, with wxGraphicsContext, it take a long time to create a path - longer than rendering it, I think. I thought that was because of python overhead in the LineTo function calls, but I think wxGCDC is pretty slow at drawing polygons too, so maybe not.

Everything in cairo is specified in floating point "user units" and is
designed to by fully scalable.

nice.

This should also be true for wxGraphics*, for that matter.

Should be, but it's not. I think mostly due to the legacy of wx -- wx.Pen, and wxFont are specified in integers, and pre-date GraphicsContext.

Robins "Tease" is a recent post suggests there's cross-platform
cairo-integration coming in a future wxPython release. I'd like know
what new features this will include.

Me too -- we'll see!

-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

Christopher Barker wrote:

From a quick look, this would be pretty easy to do in FC1
(I'm not as sure about FC2 -- it's brand new). The best way
to check it out is to take a look at the demos in the source
(I don't think all the little ones are distributed with
wxPython right now):

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/Demos/

MovingElements.py

Should get you started. You can ask specific questions on the
floatcanvas mailing list.

Ok, I installed numpy, so now I can run the wxPython demo.

I downloaded MovingElements.py and tried to run it, but it failed because
FC.Arc does not exist. Looking at svn, I see it was added in August 2007. I
am using wxPython 2.8.7.1, so it looks as if the version of FC bundled with
that is too old.

I tried to download the latest version of FC using Tortoise svn. I gave it
this repository -

  http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/

It failed with the message 'Error: Repository moved permanently to
'/viewvc/wx/wxPython/3rdParty/FloatCanvas/';please relocate'

I'm not sure what to do next - can you give some assistance please.

Thanks

Frank

Replace viewvc with svn, i.e. use

http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/FloatCanvas/

I think viewvc is just the svn front-end on the webserver which allows you to browse the sources with your browser.

-Matthias

···

Am 09.09.2008, 09:13 Uhr, schrieb Frank Millman <frank@chagford.com>:

Christopher Barker wrote:

From a quick look, this would be pretty easy to do in FC1
(I'm not as sure about FC2 -- it's brand new). The best way
to check it out is to take a look at the demos in the source
(I don't think all the little ones are distributed with
wxPython right now):

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/Demos/

MovingElements.py

Should get you started. You can ask specific questions on the
floatcanvas mailing list.

Ok, I installed numpy, so now I can run the wxPython demo.

I downloaded MovingElements.py and tried to run it, but it failed because
FC.Arc does not exist. Looking at svn, I see it was added in August 2007. I
am using wxPython 2.8.7.1, so it looks as if the version of FC bundled with
that is too old.

I tried to download the latest version of FC using Tortoise svn. I gave it
this repository -

  http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/

>
> I tried to download the latest version of FC using Tortoise svn. I
> gave it this repository -
>
> http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/

Replace viewvc with svn, i.e. use

http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/FloatCanvas/

I think viewvc is just the svn front-end on the webserver
which allows you to browse the sources with your browser.

-Matthias

It worked! Thanks, Matthias

Frank

Robin Dunn <robin@alldunn.com> writes:

> He still answers questions now and then, and I've been applying patches
> that have been submitted. Since it's all Python code now it's much
> easier for the people using OGL to be able to fix bugs or create
> enhancements for it, and there's been a few instances of that happening
> over the past few years.

That would be me. Unfortunately I no longer work on my project where I
used OGL so my grasp of it is quickly fading.
But from time to time I do answer questions.
I tend to at least read all threads with "OGL" in the subject.

···

--
  Pierre Hjälm, OGL - less and less

Christopher Barker wrote:

From a quick look, this would be pretty easy to do in FC1
(I'm not as sure about FC2 -- it's brand new). The best way
to check it out is to take a look at the demos in the source
(I don't think all the little ones are distributed with
wxPython right now):

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanv
as/Demos/

MovingElements.py

Should get you started. You can ask specific questions on the
floatcanvas mailing list.

It may be quite doable with FC2 as well -- ask on the list.
I'm not yet up to speed with that.

Hi Chris

I installed numpy, downloaded the latest FC1, and ran a couple of the demos.
They do look nice.

However, and I really don't want to appear ungrateful, I will stick with my
own for now -

- it is working, and I have got a mountain of other stuff to tackle
- I don't need any of the extra features of FC, such as zooming and handling
thousands of objects
- I have even got rid of the flicker on msw - see a separate post reporting
a small oddity on gtk2

I will definitely look at FC again, when I have more time, and when FC2 is
more stable. I assume you will report progress to this list, so I will keep
an eye open.

Many thanks for all your input - I really do appreciate it.

Frank

Frank Millman wrote:

I installed numpy, downloaded the latest FC1, and ran a couple of the demos.
They do look nice.

thanks.

However, and I really don't want to appear ungrateful,

no gratitude expected!

- it is working, and I have got a mountain of other stuff to tackle

working code is working code -- there is a lot to be said for that!

I will definitely look at FC again, when I have more time, and when FC2 is
more stable. I assume you will report progress to this list,

we will.

But for the record, FC1 is pretty stable, if it does what you need now.

-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