I have compared different reactions of rescaling a xy-plot:
The first is a active-plot and a call-back-function prints out some
information about the window and the pixel-borders of the rescaled
xy-plot. These output seems to be reasonable.
My program printed these lines:
cb_xyplot: obj 10029e78 win: 320x250
xb -0.50 1.50 yb -0.70 1.30
wmin 67.50 198.50 wmax 259.50 42.50
cb_xyplot: obj 10029e78 win: 663x577
xb -0.50 1.50 yb -0.70 1.30
wmin 110.50 485.50 wmax 548.50 81.50
The second is a point-plot and the same information is now printed
from a function witch should draw the data-point. The printed
information is now different and not as reliable as the first one. Is
there a difference in rescaling an active-plot and a point-plot ?
In the second case the program-output is:
drawcircle: obj 10029e78 win: 320x250
xb -0.50 1.50 yb -0.70 1.30
wmin 67.50 198.50 wmax 259.50 42.50
drawcircle: obj 10029e78 win: 663x577
xb -0.50 1.50 yb -0.70 1.30
wmin 67.50 446.50 wmax 505.50 42.50
You can easily check this behavior with the following code by changing
only the define for MY_PLOT_TYPE and trigger this bug.
Thanks for any advise in the second case,
MvdH.
------------ >8 ----------- snip ------------ 8< ------------
#include "forms.h"
#include <stdlib.h>
/* #define MY_PLOT_TYPE FL_ACTIVE_XYPLOT */
#define MY_PLOT_TYPE FL_POINTS_XYPLOT
extern void cb_xyplot(FL_OBJECT *, long);
/**** Forms and Objects ****/
typedef struct {
FL_FORM *bar;
void *vdata;
char *cdata;
long ldata;
FL_OBJECT *xyplot;
} FD_bar;
/*---------------------------------------*/
FD_bar *create_form_bar(void)
{
FL_OBJECT *obj;
FD_bar *fdui = (FD_bar *) fl_calloc(1, sizeof(*fdui));
fdui->bar = fl_bgn_form(FL_NO_BOX, 320, 250);
obj = fl_add_box(FL_UP_BOX,0,0,320,250,"");
fdui->xyplot = obj = fl_add_xyplot(MY_PLOT_TYPE,40,30,230,190,"");
fl_set_object_callback(obj,cb_xyplot,0);
fl_end_form();
fdui->bar->fdui = fdui;
return fdui;
}
/*---------------------------------------*/
void print_dim(FL_OBJECT *ob, const char* text)
{
FL_FORM *myform=ob->form;
float xbmin,xbmax; /* visible bounds */
float ybmin,ybmax;
float xbdmin,xbdmax; /* equal to data bounds */
float ybdmin,ybdmax;
fl_get_xyplot_xbounds(ob,&xbmin,&xbmax);
fl_get_xyplot_ybounds(ob,&ybmin,&ybmax);
fl_xyplot_w2s(ob,xbmin,ybmin,&xbdmin,&ybdmin);
fl_xyplot_w2s(ob,xbmax,ybmax,&xbdmax,&ybdmax);
printf("%s: obj %x win: %ix%i\n",text,ob,myform->w,myform->h);
printf("xb %5.2f %5.2f yb %5.2f %5.2f\n",xbmin,xbmax,ybmin,ybmax);
printf("wmin %5.2f %5.2f wmax %5.2f %5.2f\n",xbdmin,ybdmin,xbdmax,ybdmax);
fflush(stdout);
}
/*---------------------------------------*/
void cb_xyplot(FL_OBJECT *ob, long data)
{
print_dim(ob,"cb_xyplot");
}
/*---------------------------------------*/
void drawcircle(FL_OBJECT *ob, int id, FL_POINT *p, int n, int w, int h)
{
int r = (w+h) / 4;
FL_POINT *ps = p + n;
print_dim(ob,"drawcircle");
for (;p<ps;p++)
fl_circf(p->x,p->y,r,id);
}
/*---------------------------------------*/
int main(int argc, char *argv[])
{
FD_bar *fd_bar;
float x=.5;
float y=.3;
fl_initialize(&argc, argv, 0, 0, 0);
fd_bar = create_form_bar();
/* fill-in form initialization code */
fl_set_xyplot_symbol(fd_bar->xyplot,0,drawcircle);
fl_set_xyplot_data(fd_bar->xyplot,&x,&y,1,NULL,NULL,NULL);
/* show the first form */
fl_show_form(fd_bar->bar,FL_PLACE_CENTERFREE,FL_FULLBORDER,"bar");
fl_do_forms();
return 0;
}
------------ >8 ----------- snip ------------ 8< ------------
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bloch.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/