Re: pixmap plotting



[please don't create a new thread by replying to an old one -- create a new message. some mail readers allow you to hide a thread in which you're not interested, which means some people may never see this message.]

On Jan 26, 2005, at 5:44 PM, BoÅtjan ÅpetiÄ wrote:

i'm tracking an output of an external program and plotting a graph based on it.

i've got my pixmap plotting quite nicelly now... but:
a) how do i resize it properly, if the main window is resized?

The size-allocate signal tells you when the widget's size has changed. For a Gtk2::DrawingArea, there's also a configure-event signal that lets you know your GdkWindow has been resized. In the scribble and histogramplot samples, the configure handler resizes and draws the backing pixmap.

b) i'd like it to continue plotting, after the points reach it's border - maybe use a scrollbar and resize indifinetly?

This will work, but after a while, constantly resizing and redrawing your window will slow things down. If it's not acceptable, the solution is to write a smarter widget. (See below)

You could also just treat the thing as a stripchart, a la xload, that simply discards data that gets scrolled away.


should i use another technique for plotting graphs in the first place?

a) Find a plotting widget.

I've used GtkDatabox before: http://www.eudoxos.de/gtk/gtkdatabox/screenshots/index.html and even wrote some perl bindings for it: http://mail.gnome.org/archives/gtk-perl-list/2004-March/msg00077.html

GtkExtra has GtkPlot, a very full-featured plot widget. The website looks dead, as the last news entry was from 2001, but the cvs repository has gtk+ 2.x code, and some files were touched just two days ago.
http://cvs.sourceforge.net/viewcvs.py/gtkextra/gtkextra-2/
So far as i know, there are no actual releases of this "new" code, and thus no perl bindings.


b) It might be feasible to "swallow" a gnuplot window in a GtkSocket. I've not tried this.


c) Write a plotting widget.

Writing widgets isn't as hard as it sounds, and is a great exercise, and could earn you great fame in the gtk2-perl world if you make a useful one. :-) Offhand, i'd say the approach to take, if you want a dynamically scalable plot, is to do these things:

- make your widget know how to scroll itself. this involves having a couple of Gtk2::Adjustments and installing a signal to let gtk+ know that the widget is scrollable. (note to self: if this involves modifying the class structure, verify that this is actually doable from perl.)
- store all of the data for your widget, but only draw what is exposed.
that is, don't draw the whole plot, only the visible portions. this will make more sense when you go to implement scrolling. it's really just a matter of getting clipping offsets done correctly.


--
muppet <scott at asofyet dot org>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]