On Wed, Jun 17, 2009 at 3:08 PM, Dmitri Gribenko<griboz...@gmail.com> wrote:
> Hi all,
>
> I'm thinking about writing an interactive data plotting application
> with plplot.  Data is ngspice simulation results.  I want it to be an
> easy-to-use application tailored for ngspice with features useful when
> exploring circuit simulation results.

I have some research tools I have written using Gtk + Cairo + PLplot
using the extcairo driver which cover most, though perhaps not all, of
the capabilities you've discussed.  I have been fairly happy with this
combination, though I have not tried Qt + the extqt driver largely
because I do most of my programming in OCaml and OCaml does not have
usable bindings for Qt4 yet.

There are a few point-by-point comments below.

> I'm writing to the list to get some advice about implementation
> details of the features.
>
> Some of the features I want to implement are easy with plplot
> (multiple subpages, Bode plots).  But I want to ask your advice about
> implementing some other features, specifically:
> * zoom in/out;
> * scrolling when zoomed plot doesn't fit into the window.
>
> As far as I have found from documentation, there is no built-in
> support for zoom.  (Well, there is plsdiplt(), but it zooms the whole
> plot.  I want to zoom into data, leaving axes where they were.)
> Nevertheless, zoom should be easy to implement with just re-plotting
> the "visible" part of the data array.

This is likely the simplest method.  Define the new region you want
plotted and then replot the data within that domain.

One additional method I have used it to show the full plot in one
portion of the application window, with a zoomed-in view of a specific
region of the plot in another portion of the app window.  This can be
done using multiple plot streams or by simply showing a zoomed-in view
of the plot driver's surface (in my case, a Cairo surface).  Both Gtk
+ Cairo and Qt should provide the means to do this.

> The most important feature that I miss in other data plotting
> applications (and the reason to write my own) is the ability to make
> measurements on the plot.  That is, I want the user to be able to pick
> data points on the plot to implement the following features:
> * place a label on the plot with the actual data for the point;
> * find the distance on X and Y axes between two points.
>
> Here's a quick mockup of what I want:
> http://img29.imageshack.us/img29/5403/plplot.png

PLplot does not provide the means to retrieve data points directly,
given a set of coordinates.  However, it is possible to capture user
input (for example, mouse clicks) at the GUI toolkit level, feed those
coordinates to PLplot to get plot-world coordinates and then have the
application check the raw data for the appropriate value.  I've used
this to add markers and annotations to plots/diagrams made with
PLplot.

> The problem with plGetCursor() is that it receives the event itself.
> If I create the window myself with GTK or Qt, then my code will
> receive the event.  After reading the source, it seems that
> plTranslateCursor() should do the task.

For Gtk + Cairo + extcairo, I use a function which uses the following
steps to get the plot-world coordinate information from a mouse click:

1. Gtk captures the mouse click
2. Cairo translates the Gtk-provided click coordinate to Cairo coordinates
3. The dimensions of the Cairo surface are used to convert these to
normalized coordinates (0.0 - 1.0 in x and y)
4. Finally, give these normalized coordinates to PLplot (plcalc_world)
to retrieve the plot-world coordinate of the mouse click

This code is written in OCaml, but the function calls are quite
similar to what you would use in C or another language using these
tools.  I imagine the process would be rather similar using Qt rather
than Cairo.

I am in the process of a rather significant refactoring of this
application's code, but I would be happy to share what I can.

> Can you suggest what driver should I use?  I think about using GTK and
> extcairo.  But in future I want to port the application to Windows.
> Should a Qt application be easier to port than a GTK one?

The QSAS folks who contributed the Qt plot driver for PLplot use
PLplot and Qt in their development
(http://www.sp.ph.ic.ac.uk/csc-web/QSAS/).  They provide binaries for
(at least) Linux, Windows and OSX.  I have not tried to port any of my
code to non-Linux systems yet, so I can not comment on the relative
ease of porting Gtk vs Qt applications.

Best of luck with your efforts in this!

Hez

-- 
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to