Partridge Michael-A13286 wrote:
My first go at the display uses a PlotCanvas, basically following the wxPlotCanvas demo code, which was all very simple.
The trick comes when I try to implement a couple of "interactive" requirements:
1) adding two cursors (i.e. vertical lines that the user can drag across the waveform so they can figure out the timing of events on the wave).
2) adding a zoom feature, esp. to zoom between the two cursors.
Make sure you have the latest version of wxPyPlot, which may or may not be what's in the wxPython library...which version of wxPython are you using? I think 2.5.1 has a recent wxPyPlot, but I'm not sure about older releases
http://www.cyberus.ca/~g_will/wxPython/wxpyplot.html
Zoom should be easy, adding the cursors should be doable, you should be able to access the wxClientDC directly, or alter wxPyPlot.
You might also want to check out an alternative plotting Canvas, posted a while back:
Arnd Baecker wrote:
in our work with wxPython/python we came across the
problem of plotting many thousand points quickly and
dynamically (i.e. one after another).
None of the present packages fully fitted our needs
and thus we starting coding our own.
The resulting PlottingCanvas for wxPython can be found under
http://www.physik.tu-dresden.de/~baecker/python/plot.html
It is not a fully-featured plotting tool,
even though zooming has been added recently
(However, of course not when plotting many points quickly,
see eg. the StandardMap.py demo).
In particular we feel that it would be nice if an integration
into existing efforts (wxPyPlot, FloatCanvas, matplotlib)
was possible, though some of the approaches in design
are quite different. Still maybe some of the ideas
of the PlottingCanvas can be used.
1) use the wxOGL package.
I'm not sure this is such a good idea, it doesn't natively deal with floating point coords for you, it's kind of a dying package, and it's written in C++, so reading, fixing or modifying the code requires C++. It was designed specifically for CASE style diagrams, so might not be as well suited to plotting.
2) use FloatCanvas. This seems to give pretty fine control over placement of shapes and comes with zoom. Haven't experiemented with a draggable object, but I assume would be possible.
The version in the wxPython lib is old, and does not have any mouse interaction. There is a newer one here:
http://home.comcast.net/~chrishbarker/FloatCanvas/
I'm doing all future work with wxPython 2.5.* If that's not an option for you, you'll need to do a little back porting, but probably not much.
I have done more with it since the release on that page, that I hope to post there soon, but it needs a bit more testing first. I'd be glad to send it to you if you like, including a demo that does dragging of shapes--a VERY simple polygon editor.
The limitation I see with FloatCanvas is that it is designed to present data, but not plotting per say. What this means is there is nothing in there to create axes, etc. It's not hard to add them as regular old FloatCanvas objects, but then zooming in and out will zoom the axes too, not just what's in them. If that would work for you, FloatCanvas could work well. If not, I think an axes feature could be added, but I haven't done anything with that yet. I would like to be able to so this in the future, so I'll help if you want to do it.
-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