XForms: fl_get_xyplot grief II: an example

From: jprinos@dehavilland.ca
Date: Thu Mar 01 2001 - 12:24:29 EST

  • Next message: Steve Lamont: "Re: XForms: what is the proper directory for forms.h?"

    # To subscribers of the xforms list from jprinos@dehavilland.ca :

    I know that there has been some conversation concerning the fact that
    fl_get_xyplot() returns incorrect data, but I'm wondering if my problem is the
    same as the one being discussed. I ran into this while trying to port an old app
    from Ver0.75 XForms to Ver0.89

    I have an xyplot on a form displaying data. If I click on a point in the xyplot
    while the entire dataset is shown, I can see that the correct point was found
    visually. No problem sofar...

    If I zoom in on the data using fl_set_xyplot_xbounds and I click somewhere deep
    in the dataset (using a handy scrollbar), the wrong point gets chosen. In fact,
    it looks like the point relative to the screen start is being mistaken for the
    first datapoint of the entire array.

    Here's an example which demonstrates the problem: Just click on the xyplot when
    the xyplot is zoomed and then unzoomed.


    ps: Any chance of getting a fix? SPL described a manual fl_get_xyplot() but it
    would take time.


    #include "forms.h"
    #include <stdlib.h>
    /**** Forms and Objects ****/

    typedef struct {
         FL_FORM *axypform;
         void *vdata;
         long ldata;
         FL_OBJECT *xyplot;
         FL_OBJECT *status;
    } FD_axypform;

    extern FD_axypform * create_form_axypform(void);

    FD_axypform *xypui;

    /* callbacks for form axypform */
    void xyplot_cb(FL_OBJECT *ob, long data)
        float x, y;
        int i;
        char buf[64];
        fl_get_xyplot(ob, &x, &y, &i);
        if(i < 0)
           return ;
        sprintf(buf,"X=%f Y=%f",x,y);
        fl_set_object_label(xypui->status, buf);

    void alwaysreturn_cb(FL_OBJECT *ob, long data)
       fl_set_xyplot_return(xypui->xyplot, fl_get_button(ob));

    void interpolate_cb(FL_OBJECT *ob, long data)
              fl_set_xyplot_xbounds(xypui->xyplot, 4, 6);
              fl_set_xyplot_xbounds(xypui->xyplot, 0, 0);

    void inspect_cb(FL_OBJECT *ob, long data)
       fl_set_xyplot_inspect(xypui->xyplot, fl_get_button(ob));

    void notic_cb(FL_OBJECT *ob, long data)
       int notic = fl_get_button(ob);

          fl_set_xyplot_xtics(xypui->xyplot, -1, -1);
          fl_set_xyplot_ytics(xypui->xyplot, -1, -1);
          fl_set_xyplot_xtics(xypui->xyplot, 0, 0);
          fl_set_xyplot_ytics(xypui->xyplot, 0, 0);

    int main(int argc, char *argv[])
       float x[25], y[25];
       int i;

       fl_initialize(&argc, argv, "FormDemo", 0, 0);
       xypui = create_form_axypform();

       /* fill-in form initialization code */
       fl_set_object_dblbuffer(xypui->status, 1);
       for (i = 0; i <= 10; i++)
          x[i] = y[i] = i;
       fl_set_xyplot_data(xypui->xyplot, x, y, 11, "","","");
       fl_set_xyplot_linewidth(xypui->xyplot, 0, 2);

       /* show the first form */


       return 0;

    FD_axypform *create_form_axypform(void)
      FL_OBJECT *obj;
      FD_axypform *fdui = (FD_axypform *) fl_calloc(1, sizeof(*fdui));

      fdui->axypform = fl_bgn_form(FL_NO_BOX, 431, 301);
      obj = fl_add_box(FL_UP_BOX,0,0,431,301,"");
      fdui->xyplot = obj = fl_add_xyplot(FL_ACTIVE_XYPLOT,20,50,285,235,"");
      obj = fl_add_checkbutton(FL_PUSH_BUTTON,315,40,80,25,"AlwaysReturn");
      obj = fl_add_checkbutton(FL_PUSH_BUTTON,315,65,80,25,"zoom/unzoom");
      obj = fl_add_checkbutton(FL_PUSH_BUTTON,315,90,85,25,"InspectOnly");
      fdui->status = obj = fl_add_box(FL_BORDER_BOX,45,15,170,25,"");
      obj = fl_add_button(FL_NORMAL_BUTTON,325,250,90,30,"Done");
      obj = fl_add_checkbutton(FL_PUSH_BUTTON,315,120,85,25,"NoTics");

      return fdui;

    To unsubscribe, send the message "unsubscribe" to
    xforms-request@bob.usuhs.mil or see
    XForms Home Page: http://world.std.com/~xforms
    List Archive: http://bob.usuhs.mil/mailserv/list-archives/

    This archive was generated by hypermail 2b29 : Thu Mar 01 2001 - 07:36:03 EST