Re: XForms: Problems with XYPlot

Timo Laitinen (timolai@utu.fi)
Thu, 08 Jan 1998 12:14:04 +0200 (EET)

To subscribers of the xforms list from Timo Laitinen <timolai@utu.fi> :

This message is in MIME format
--_=XFMail.1.2.p0.Linux:980108121404:30851=_
Content-Type: text/plain; charset=iso-8859-1

On 05-Jan-98 Steve Lamont wrote:
> To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont)
>:

OK, I tried to make my question short and managed to make it _too_ short...
so let's try again :-)

>
> Is that flashing just momentary? I did a quick test and observed a
> bit of that when the update rate was fairly high (say faster than
> about 250 milliseconds).

Flashing may be a wrong word. On update the axis etc appear normally for a
VERY short time and then disappear for the rest of the second (a part of the
axislabels, axistitles, titles and/or tickmarks) so that it would seem as if
the correct figure is drawn first and a faulty one is drawn on top of it.

The situation was better without the usage of sleep(1). Could sleep() cause
something? Probably not.

> I expect this is just an artifact of the
> speed of your X server more than an XForms problem, per se. A faster
> server or a faster connection to that server if you're running over a
> network would probably cause most of that to go away.

I've tried it now on linux and decosf 3.0, both on consoles.

>> Using fl_redraw_form(form) produced REALLY weird results. About every
>> other
>> second either or both of the plots and a button on the form disappeared!

I tried this a bit more and it happens only if dblbuffer is set for plots.
Could it be that somehow the drawing order of objects gets messed up and the
background box is drawn on the plots. Without the background box it worked
fine.

> My suggestion is to go back and use fl_set_object_dblbuffer(), since
> this seems to give the best results.

Most of these problems occured _with_ dblbuffer.

> I guess I don't completely understand what you're doing.
>
> Do you mean that you're displaying the number of seconds since the
> Unix epoch along the abscissa? Does 884011456 (the current number of
> seconds since the Unix epoch at the moment I wrote this) tell you
> anything meaningful

Sorry, I should have told you what I was doing/planning. Yes, you're right of
course, current time in seconds is useless. My plan was to use
fl_set_xyplot_alphaxtics(obj,asctime(gmtime(time))). This however is
currently useless because the "use *my* tick marks, *dammit*." -option
someone suggested isn't there yet (soon, hopefully :-) )

I'll attach a little test program that shows all my problems. There are five
macros to define what is to be used, namely DBLBUF, REDRAW_FORM,
REDRAW_OBJ, FREEZE, INS_TEXT and TWO_PLOTS. Here is a short summary of
combinations and their effects as I saw them:

One xyplot:
No additional fine
Redraw_form: axis labels etc disappear occasionally
Dblbuf: Fine
Redraw&Dblbuf: plot vanishes occasionally. Reason:
background box possibly
comes to front.
Redraw_obj labels etc
Redraw_obj&Dblbuf: Misses updates
Freeze Fine
text labels etc
text&dblbuf Text vanishes occasionally
text&others More or less the same

Two xyplots:
No additional labels etc
Redraw_form: plot vanishes occasionally, labels etc
Dblbuf: Updates not in sync (one plot occasionally a
second behind)
Redraw&Dblbuf: plot vanishes occasionally
Redraw_obj labels etc
Redraw_obj&Dblbuf: Seems fine
Freeze+RedrObj+Dbl Updates not in sync
text&dblbuf Occasionally stable
text&dblbuf&RedrObj Flashes and disappears

If you don't experience same kinds of problems please let me know. Also if
I've done something completely wrong I'd like to know about it :-)

For now I'll probably use Redraw_obj&Dblbuff and put axislabels outside of
the plot as text.

----------------
Timo FABRICATI DIEM, PVNK.
email:timolai@utu.fi

--_=XFMail.1.2.p0.Linux:980108121404:30851=_
Content-Disposition: attachment; filename="plottest.c"
Content-Transfer-Encoding: none
Content-Description: plottest.c
Content-Type: text/plain; charset=us-ascii; name=plottest.c; SizeOnDisk=2415

#include <math.h>
#include <forms.h>
#include <string.h>

/* #define DBLBUF */
/* #define REDRAW_FORM */
/* #define REDRAW_OBJ */
/* #define FREEZE */
/* #define INS_TEXT */
/* #define TWO_PLOTS */

int main(int argc, char *argv[])
{
int i,nelem=0;
float t=0.,data[2][100],a,b;

char *string1="Some text",*string;

FL_OBJECT *ok,*xypl1,*xypl2,*back;
FL_FORM *xyform;

fl_initialize(&argc, argv, 0, 0, 0);

/* Create form */

xyform = fl_bgn_form(FL_NO_BOX, 630, 500);
back=fl_add_box(FL_UP_BOX,0,0,630,500,"");
ok = fl_add_button(FL_NORMAL_BUTTON,490,460,120,30,"OK");
xypl1 = fl_add_xyplot(FL_NORMAL_XYPLOT,40,60,250,230,"");
fl_set_object_boxtype(xypl1,FL_DOWN_BOX);
fl_set_object_color(xypl1,FL_BLACK,FL_YELLOW);
#ifdef TWO_PLOTS
xypl2 = fl_add_xyplot(FL_NORMAL_XYPLOT,330,60,250,230,"");
fl_set_object_boxtype(xypl2,FL_DOWN_BOX);
fl_set_object_color(xypl2,FL_BLACK,FL_YELLOW);
#endif
fl_end_form();

#ifdef DBLBUF
fl_set_object_dblbuffer(ok,1);
fl_set_object_dblbuffer(xypl1,1);
#ifdef TWO_PLOTS
fl_set_object_dblbuffer(xypl2,1);
#endif
#endif

#ifdef INS_TEXT
fl_add_xyplot_text(xypl1,data[0][99],data[1][99],string1,FL_ALIGN_LEFT,F
L_GREEN);
#endif

fl_show_form(xyform,FL_PLACE_CENTERFREE,FL_FULLBORDER,"xypl");

while ((fl_check_forms()!=ok)&&(nelem<99))
{

/* Shift data and add a new element */

for(i=99-nelem;i<99;i++)
{
data[0][i]=data[0][i+1];
data[1][i]=data[1][i+1];
}
data[0][i]=sin(t*M_PI/100.);
data[1][i]=cos(t*M_PI/100.);

nelem++;
t+=1.;

#ifdef FREEZE
fl_freeze_form(xyform);
#endif

fl_set_xyplot_data(xypl1,&data[0][100-nelem],&data[1][100-nelem],nelem,
"Stuff1","","y");

#ifdef TWO_PLOTS
fl_set_xyplot_data(xypl2,&data[0][100-nelem],&data[1][100-nelem],nelem,
"Stuff2","x","y");
#endif

#ifdef INS_TEXT
/* positioning doesn't work well, doesn't matter... */

fl_get_xyplot_ymapping(xypl1,&a,&b);
fl_delete_xyplot_text(xypl1,string1);
fl_add_xyplot_text(xypl1,data[0][99],data[1][99]+10./a,string1,FL_ALIGN_L
EFT,FL_GREEN);
#endif

#ifdef REDRAW_OBJ
fl_redraw_object(xypl1);
#ifdef TWO_PLOTS
fl_redraw_object(xypl2);
#endif
#endif

#ifdef REDRAW_FORM
fl_redraw_form(xyform);
#endif

#ifdef FREEZE
fl_unfreeze_form(xyform);
#endif

sleep(1);

}

return 0;
}

--_=XFMail.1.2.p0.Linux:980108121404:30851=_--
End of MIME message
_________________________________________________
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/