|
From: Allin C. <cot...@wf...> - 2009-09-09 14:22:55
|
On Wed, 9 Sep 2009, Richard Henwood wrote: > On Tue, 2009-09-08 at 09:27 -0700, Ethan Merritt wrote: > > On Tuesday 08 September 2009 01:44:25 Richard Henwood wrote: > > > On Mon, 2009-09-07 at 17:49 -0400, Allin Cottrell wrote: > > > > > > > > I think what Richard was asking is whether the "cairo drawing > > > > context" struct, or "cairo_t", that is used internally by gnuplot > > > > could somehow be exposed programmatically... > > > > > > This is indeed what I am curious about... > > [...] This mode of operation is already supported by the qt, > > tkcanvas, and x11 terminal drivers. You initialize the > > context, invoke gnuplot, and tell it to draw into your > > existing context rather than creating a new one. Of course > > the details are different in each case. > > Ah! This is good news. So presumably if a 'cairo' terminal driver > existed, this would provide me a way to get nice gnuplot plots into my > GTK/cairo application? In the meantime a good option, I find, is to get gnuplot to create a PNG file (e.g. using the pngcairo terminal), then load that file into your GTK window using gdk_pixbuf_new_from_file() or perhaps cairo_image_surface_create_from_png(). Of course, you don't get a vector graphic that way. I'm not quite sure how a "cairo term" would work. You couldn't actually pass a cairo drawing context to gnuplot, could you? With the x11 term, for example, you can say "window <XID>", passing the X11 ID of the window you want to draw into, in string form. I don't offhand see what a cairo counterpart would look like. Here's something I haven't tried, but that might be nice. Since gnuplot already does SVG, one could get gnuplot to write an SVG file, create a cairo context using gdk, then call librsvg to read the SVG file into your cairo context. This would not require any modifications to gnuplot. Allin Cottrell |