# To subscribers of the xforms list from Steve Lamont <spl@ncmir.ucsd.edu> :
> I have an aplication in which I capture a image from a camera, and i
> put the image in a canvas object. I use an iddle callback to refresh
> the image.
>
> I have some fors to calculate some positions to move the camera,
> then while the camera is moving, the image doesn't refresh, I think
> because into the fors there isn't time to execute iddle callback.
>
> is it True?
The idle callback mechanism is not completely asynchronous -- it
doesn't run in a separate thread or anything like that -- but is under
control of the XForms "main loop" (executed when you call
fl_do_forms()).
If you don't return control to XForms, the idle callback will not be
called. You may also note that other parts of the form seem to
"freeze up" while the camera is moving.
> How can i "put time" to execute the iddle callback?
You can call the function fl_check_forms() anywhere in your loop to
momentarily hand control back to XForms. fl_check_forms() is
basically the "guts" of the XForms main loop and does everything that
the main loop does except that it doesn't loop -- it returns control
to the calling function.
If there is nothing for XForms to do, that is, no user interaction to
process or no pending idle callback or timeout, then control is
immediately handed back to your function.
One caveat: I don't recommend calling fl_check_forms() in an inner
loop that is executed thousands of times per second, since that will
slow your program down badly and eat a lot of CPU time for nothing.
For example, don't do this:
for ( i = 0; i < some_outer_loop_limit; i++ ) {
for ( j = 0; j < some_inner_loop_limit; j++ ) {
do_your_inner_loop_stuff();
fl_check_forms(); /* A bad idea to put it here */
}
}
do this:
for ( i = 0; i < some_outer_loop_limit; i++ ) {
for ( j = 0; j < some_inner_loop_limit; j++ ) {
do_your_inner_loop_stuff();
}
fl_check_forms(); /* A better idea to put it here */
}
Assuming that the inner loop takes only a few milliseconds to execute,
you will return control to XForms frequently enough to maintain
interaction and call the idle callback.
> How can i refresh the image without iddle callback?
You can, of course, simply call the functions directly to update your
Canvas display whenever you have new image data, rather than use the
idle callback mechanism.
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 : Thu Jul 27 2000 - 05:55:07 EDT