# To subscribers of the xforms list from justin.turnage@lmco.com :
Steve,
I've been able to change your source code that you supplied to reflect what
was happening on my end. I also found the reason why it happened and have
corrected it in my program. See if you can tell what I did wrong.
My next question is:
Is this an undocumented feature? Or is this something that I just happened
to come across? 8-)
Here is the updated source:
----------------
#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, 30.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;
static int nocnt;
double x = ( i * M_PI ) / N;
double y1 = sin( x );
double y2 = cos( x );
fl_insert_xyplot_data( try1->xyplot, 1, nocnt, 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();
}
--------
End of source
Thanks for your help!
Justin
_________________________________________________
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 : Thu Sep 28 2000 - 09:49:23 EDT