RE: XForms: XY Plot weirdness

From: Steve Lamont (spl@ncmir.ucsd.edu)
Date: Wed Sep 27 2000 - 14:46:13 EDT

  • Next message: justin.turnage@lmco.com: "RE: XForms: XY Plot weirdness"

    # To subscribers of the xforms list from Steve Lamont <spl@ncmir.ucsd.edu> :

    > I dont think the off by one error is an issue. My program just
    > grabs the data out of a shared memory block and displays the data on the
    > xyplot object.
    >
    > Here is how I set the plot up in one module:
    >
    > fdui->FIRST_PLOT = obj =
    > fl_add_xyplot(FL_NORMAL_XYPLOT,1,40,1261,432,"Plot #1");
    > fl_set_object_dblbuffer(obj,1);
    > fl_set_xyplot_data(obj,&X,&Y,1,"","");
                                               ^^^^^ missing an argument here.
                                                     shouldn't even compile

    I modified the test code to reflect the differences you describe as
    follows and I still do not see the sort of problem described. I've
    run the code on both a Solaris Sun and a Compaq Alpha (I still can't
    get used to saying Compaq instead of DEC...) XP1000

            ganesa:spl> uname -a
            OSF1 ganesa V5.0 1094 alpha

    with the XForms library

            ganesa:spl> ./try -flversion
            FORMS Library beta 0.89.6 of 2000/05/19 05:54:26 (Compiled Sep 27 2000)
            Copyright (c) 1996-2000 by T.C. Zhao and Mark Overmars
            Parts Copyright(c) 1999-2000 by T.C. Zhao and Steve Lamont

    Can you try the test code provided below and let us know what the
    result is?

                                    - - -
    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>

    #include <forms.h>

    /**** Forms and Objects ****/
    typedef struct {
            FL_FORM *try;
            void *vdata;
            char *cdata;
            long ldata;
            FL_OBJECT *xyplot;
    } FD_try;

    extern FD_try * create_form_try(void);

    FD_try *try1;
    FD_try *try2;
         
    #define M 100
    #define N 20

    FD_try *create_form_try(void)
    {
      FL_OBJECT *obj;
      FD_try *fdui = (FD_try *) fl_calloc(1, sizeof(*fdui));
      float X = 0;
      float Y = 0;

      fdui->try = fl_bgn_form(FL_NO_BOX, 310, 290);
      obj = fl_add_box(FL_FLAT_BOX,0,0,310,290,"");
      fdui->xyplot = obj = fl_add_xyplot(FL_NORMAL_XYPLOT,20,50,270,220,"");
      fl_set_object_dblbuffer(obj,1);
      fl_set_xyplot_data(obj,&X,&Y,1,"","",""); /* Changed by spl */
      fl_set_xyplot_xbounds(obj, 0.0, 20.0); /* Changed by spl */
      fl_set_xyplot_ybounds(obj,-1.0, 1.0 ); /* Changed by spl */
      fl_set_object_boxtype(obj,FL_DOWN_BOX);
      fl_set_object_color(obj,FL_CYAN,FL_BLACK);
      fl_set_object_lsize(obj,FL_MEDIUM_SIZE);
      fl_set_object_lstyle(obj,FL_TIMES_STYLE);
      fl_set_xyplot_xtics(obj, 5, 1);
      fl_set_xyplot_ytics(obj, 5, 1);
      fl_set_xyplot_xgrid(obj, FL_GRID_MAJOR);
      fl_set_xyplot_ygrid(obj, FL_GRID_MAJOR);
      fl_end_form();

      fdui->try->fdui = fdui;

      return fdui;
    }
    /*---------------------------------------*/

    int idle( XEvent *xev, void *data )

    {

        static int i = 0;
        double x = ( i * M_PI ) / N;
        double y1 = sin( x );
        double y2 = cos( x );

        fl_insert_xyplot_data( try1->xyplot, 1, i, x, y1 );
        fl_insert_xyplot_data( try2->xyplot, 1, i, x, y2 );

        i++;

        return i;

    }

    int main(int argc, char *argv[])

    {

        fl_initialize( &argc, argv, 0, 0, 0 );
         
        try1 = create_form_try();
        try2 = create_form_try();
         
        fl_set_idle_callback( idle, NULL );

        fl_set_xyplot_ybounds( try1->xyplot, -1.0, 1.0 );
        fl_set_xyplot_ybounds( try2->xyplot, -1.0, 1.0 );

        fl_show_form( try1->try, FL_PLACE_CENTERFREE, FL_FULLBORDER, "try1" );
        fl_show_form( try2->try, FL_PLACE_CENTERFREE, FL_FULLBORDER, "try2" );

        while ( 1 )
            fl_do_forms();

    }
                                    - - -

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



    This archive was generated by hypermail 2b29 : Wed Sep 27 2000 - 14:53:19 EDT