#include #include /* Forms and Objects */ typedef struct { FL_FORM * plot; void * vdata; char * cdata; long ldata; FL_OBJECT * xy; } FD_plot; FD_plot * create_form_plot( void ); FD_plot *fd_plot; void makeplot(int); /****************************************/ FD_plot * create_form_plot( void ) { FL_OBJECT *obj; FD_plot *fdui = ( FD_plot * ) fl_malloc( sizeof *fdui ); fdui->vdata = fdui->cdata = NULL; fdui->ldata = 0; fdui->plot = fl_bgn_form( FL_NO_BOX, 577, 390 ); obj = fl_add_box( FL_FLAT_BOX, 0, 0, 577, 390, "" ); fdui->xy = obj = fl_add_xyplot( FL_POINTS_XYPLOT, 40, 30, 500, 330, "" ); fl_set_object_boxtype( obj, FL_BORDER_BOX ); fl_end_form( ); fdui->plot->fdui = fdui; return fdui; } /* Callbacks and freeobj handlers for form plot */ void makeplot(int set_type) { float x[]={0.1,0.2,0.3,0.4}; float y[]={0.1,0.2,0.3,0.4}; int np; np = sizeof(x)/sizeof(float); printf("np=%d\n",np); fl_set_xyplot_data(fd_plot->xy,x,y,np,"PLOT","X","Y"); fl_set_xyplot_ybounds(fd_plot->xy, 0.0, 1.0); fl_set_xyplot_xbounds(fd_plot->xy, 0.0, 1.0); fl_add_xyplot_overlay(fd_plot->xy, 1, x+1, y+1, 2, FL_RED); if (set_type) fl_set_xyplot_overlay_type(fd_plot->xy, 1, FL_POINTS_XYPLOT); } /*************************************** ***************************************/ int main( int argc, char * argv[ ] ) { int set_type=0; fl_initialize( &argc, argv, 0, 0, 0 ); if (argc > 1) set_type=1; fd_plot = create_form_plot( ); /* Fill-in form initialization code */ makeplot(set_type); /* Show the first form */ fl_show_form( fd_plot->plot, FL_PLACE_CENTERFREE, FL_FULLBORDER, "plot" ); fl_do_forms( ); if ( fl_form_is_visible( fd_plot->plot ) ) fl_hide_form( fd_plot->plot ); fl_free( fd_plot ); fl_finish( ); return 0; }