# To subscribers of the xforms list from Steve Lamont <spl@ncmir.ucsd.edu> :
> ... One
> form plots the data perfectly real-time. The other form plots the data
> perfectly as well but has this trailing straight line that starts at the
> begin point and follows the end point precisely while the data is plotting
> real-time. I can't seem to find anything in the documentation that explains
> this behavior. Can anyone help?
Are you sure it's not an off by one error of some kind?
I do similar things in at least one of my applications and don't see
anything similar.
Here's a silly little example program which displays two moving
sinusoids in two separate XYPlots in two separate Forms.
- - -
#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));
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_end_form();
fdui->try->fdui = fdui;
return fdui;
}
/*---------------------------------------*/
int idle( XEvent *xev, void *data )
{
static float x[M];
static float y1[M];
static float y2[M];
static int i = 0;
static int j = 0;
int first = j - ( N - 1 );
float xmax;
x[j] = ( i * M_PI ) / N;
y1[j] = sin( x[j] );
y2[j] = cos( x[j] );
if ( first < 0 )
first = 0;
if ( i < N )
xmax = ( ( N - 1 ) * M_PI ) / N;
else
xmax = x[j];
fl_set_xyplot_xbounds( try1->xyplot, x[first], xmax );
fl_set_xyplot_data( try1->xyplot, &x[first], &y1[first],
( j - first ) + 1,
"plot 1", "x", "y" );
fl_set_xyplot_xbounds( try2->xyplot, x[first], xmax );
fl_set_xyplot_data( try2->xyplot, &x[first], &y2[first],
( j - first ) + 1,
"plot 2", "x", "y" );
if ( ++j == M ) {
bcopy( &x[first + 1], &x[0], sizeof( float ) * ( N - 1 ) );
bcopy( &y1[first + 1], &y1[0], sizeof( float ) * ( N - 1 ) );
bcopy( &y2[first + 1], &y2[0], sizeof( float ) * ( N - 1 ) );
j = N - 1;
}
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 : Tue Sep 26 2000 - 21:05:24 EDT