xforms-development
[Top][All Lists]
Advanced

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

Re: [XForms] axes coords in XYPlot


From: Jens Thoms Toerring
Subject: Re: [XForms] axes coords in XYPlot
Date: Thu, 19 May 2011 20:28:44 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

On Thu, May 19, 2011 at 04:42:54PM +0200, Michal Szymanski wrote:
> On Thu, May 19, 2011 at 02:23:47PM +0200, Jens Thoms Toerring wrote:
> > Hi Michael,
> > 
> > On Wed, May 18, 2011 at 05:11:52PM +0200, Michal Szymanski wrote:
> > > I thought it should be trivial but it seems not to be so. Unless I am
> > > missing something hidden.
> > > 
> > > set/get x/ybounds routines deal with data clipping. Surely, the XYPlot 
> > > axes
> > > do change then also but due to tic rounding (which is mentioned in the
> > > manual) the clipping values are not the same as axes coords.
> > > 
> > > Is there a way to get X,Y coords of the XYPlot axes? With the 
> > > auto-adjusted
> > > margins this seems to be a tricky thing to get without digging into some
> > > internals. And, obviously, the library must have these values. 
> > 
> > Sorry for not being able to answer yet, the xyplot object is
> > really not one of the easiest to understand;-) There are that
> > many scale factors and cases involved that I haven't yet un-
> > derstood what's going on in there yet (and there also seem
> > to luk some bugs someone else has reported). I'm still in
> > the process of trying to find my way through the whole mess.
> > 
> > So, due to my lack of understanding of what's going on in there
> > (and perhaps also misunderstanding your question): did you try
> > to use fl_get_xyplot_xmapping() and fl_get_xyplot_ymapping()
> > and use just the last argument? As far as I understand it at
> > the moment, these should be the x and y screen coordinates of
> > the origin of the axes system.
> 
> Not really, I am afraid. These functions return a and b coeffs for
> 
>   screenCoord = a * data + b    or, after small rearrangement
>   data = (screenCoord - b) / a
> 
> But the screenCoord is the standard X11 coordinate of a point in the
> current form window, measured from the top left corner. Even if the XYPlot
> were the only object in the form window (and it is usually not), the (0,0)
> screenCoords would not be the coordinates of the upper left corner of the
> XYPlot axes (due to the presence of margins for ticks and axes labels).
> 
> What I want to get are the coordinates (be it screen or "world" - the above
> mentioned routines allow to convert between the two systems) of the corners
> of the plot where the axes cross (well, they do not actuall cross, but
> contact each other).

Mmm, another idea: when I do

    float llc_x, llc_y, urc_x, urc_y;
    float min_x, max_x, min_y, max_y;

    fl_get_xyplot_xbounds( obj, &min_x, &max_x );
    fl_get_xyplot_ybounds( obj, &min_y, &max_y );

    fl_xyplot_w2s( obj, min_x, min_y, &llc_x, &llc_y );
    fl_xyplot_w2s( obj, max_x, max_y, &urc_x, &urc_y );

    printf( "llc: %f %f, urc: %f %f\n", llc_x, llc_y, urc_x, urc_y );

(where "llc" stands for lower left hand corner and "urc" for upper
right hand corner) the result look rather like the screen coordi-
nates of these points, i.e. the corners of the axes-systems in the
coordinate system of the xyplot object. And I get the same results
when I do instead

    float ax, bx, ay, by;

    fl_get_xyplot_xmapping( obj, &ax, &bx );
    fl_get_xyplot_ymapping( obj, &ay, &by );

    printf( "llc: %f %f, urc: %f %f\n", bx, by,
            ax * ( max_x - min_x ) + bx,
            ay * ( max_y - min_y ) + by );

And if you just want the "world" coordinates of the "edges"
fl_get_xyplot_xbounds() and fl_get_xyplot_ybounds() alone
should do the job.

Is this what you are looking for or am I still misunderstanding
your question?
                             Best regards, Jens
-- 
  \   Jens Thoms Toerring  ________      address@hidden
   \_______________________________      http://toerring.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]