Re: XForms: Problems with XYPlot

Steve Lamont (spl@szechuan.ucsd.edu)
Thu, 8 Jan 98 06:24:53 PST

To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> 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.

sleep() would definitely cause the program to block. In fact, I'd go
so far as to nominate it as the culprit.

Bear in mind, as I think I mentioned in the previous posting, that by
default X buffers your graphics commands and only sends them when
either the buffer is full or there's some interaction requiring a
round trip to the server (I forget all the rules offhand but Volume 1
of the O'Reilly X series discusses this at some length).

Since you're not returning control to XForms after you do your screen
update, as the graph becomes more complicated it requires more buffers
to fulfill. The XForms fl_check_forms() or fl_do_forms() functions
would do the appropriate cleanup to flush the buffer to the screen.

(You could probably confirm this by using the `xscope' monitor server
if you have it, though it will probably tell you much more than you
really want to know and the output is a pain to interpret.)

I made the problem go away with a call to XFlush() immediately before
the sleep() call. XFlush() causes the buffer to be flushed to the
server immediately. You can also make this happen by calling one of
the fl_*_mouse() functions to query the cursor position. The buffer
will be flushed to the server.

The reason I didn't see the results you reported the first time is
that I did my updating in a timeout callback function which, of
course, returns control to the main XForms loop (fl_do_forms()).

If the ultimate objective is to handle some device, you will probably
want to look at the fl_add_io_callback() or fl_add_signal_callback()
function to service the device as appropriate. If it's a device
that's polled, you should look at the fl_add_timeout() or
fl_set_idle_callback() [at appropriate intervals, since polling can
create a "buzz" loop that will eat your CPU alive -- refer to the
manual for the _caveats_].

spl


_________________________________________________
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/