|
From: Allin C. <cot...@wf...> - 2007-11-24 00:05:29
|
On Thu, 22 Nov 2007, Ethan A Merritt wrote:
> On Thursday 22 November 2007 08:19, Allin Cottrell wrote:
> >
> > I'm attaching a small patch to eval.c that implements
> > GPVAL_GRAPH_XMIN, GPVAL_GRAPH_XMAX, GPVAL_GRAPH_YMIN and
> > GPVAL_GRAPH_YMAX. In the context of bitmapped output, these values
> > should represent the pixel coordinates of the actual graph area.
> >
> > Those more familiar than I with the gnuplot architecture will no
> > doubt be able to see if there's a better way of doing this.
>
> >--- eval.c.orig 2007-11-22 10:16:05.000000000 -0500
> >+++ eval.c 2007-11-22 11:05:46.000000000 -0500
> >@@ -733,6 +733,39 @@
> > Gstring(&v->udv_value, gp_strdup(stringvalue));
> > }
> >
> >+static void update_plot_bounds (void)
> >+{
> >+ int xl = plot_bounds.xleft;
> >+ int xr = plot_bounds.xright;
> >+ int yb = plot_bounds.ybot;
> >+ int yt = plot_bounds.ytop;
>
> I think that has to be
>
> unsigned int xl, xr, yb, yt;
> struct position bottom_left = {graph, graph, graph, 0., 0., 0.};
> struct position upper_right = {graph, graph, graph, 1., 1., 1.};
>
> map_position(&bottom_left, &xl, &yb, "");
> map_position(&upper_right, &xr, &yt, "");
OK, I'll take your word for that!
> >+ if (term != NULL && !strcmp(term->name, "pngcairo")) {
> >+ /* convert to pixels */
> >+ xl /= 20;
> >+ xr /= 20;
> >+ yb /= 20;
> >+ yt /= 20;
>
> Where did the magic number 20 come from?
The cairo code seems to deal in units of 1/20 of a pixel. Note
that in mouse.c we have, e.g.:
mv_mouse_x = term->xmax / 20;
However, if something like the above assignment to
GPVAL_GRAPH_XMIN et al is acceptable, I'd be happy even if no
conversion to pixels is done -- that is, if the numbers are just
whatever comes out of map_position().
Allin Cottrell
|