Re: widget_control from call_external [message #24009] |
Thu, 01 March 2001 08:55  |
John-David T. Smith
Messages: 384 Registered: January 2000
|
Senior Member |
|
|
David Fanning wrote:
>
> dominic@work.com (dominic@work.com) writes:
>
>> I have a c/c++ programme that is called from within a
>> widget hierachy via call_external.
>>
>> As the computations made take fairly long, I want to update
>> a status bar with a 'Percentage complete' from the C-routine,
>> so the user doesn't get upset and thinks the programme died
>> on him/her.
>>
>> How do I go about that???
>
> Well, this will be difficult unless your can call your
> C program in "chunks", or in some other way interrupt
> it. It might be easier if you just know, in general,
> how long it takes. Then you can set a "kitchen timer"
> sort of progress indicator. As long as the cake is
> baked by the time the timer goes off, no one seems
> to care. :-)
>
> You can see several ways to build such a progress
> indicator here:
>
> http://www.dfanning.com/tips/show_progress.html
I would use alarm() to throw a SIGALRM every 1 second, say, then update
a percent complete counter, based on some innate knowledge of the
calculation. To get this to IDL under call_external is more difficult.
You *could* then just print it to the terminal, ala:
printf("\r%02d%% complete",percent_complete);
Make sure to:
setbuf(stdout,(char *)NULL);
first, so the updates will appear.
Of course, RSI would frown on this, but if it gets the job done...
If you'd like to do it full blown way, with a snazzy graphical update
slider, you might have to make a full DLM, and use IDL_Execute to force
the progress update from the C side. That's a lot of work for a bit of
eye candy. But everybody likes candy.
Good luck,
JD
|
|
|
Re: widget_control from call_external [message #24010 is a reply to message #24009] |
Thu, 01 March 2001 08:05   |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
dominic@work.com (dominic@work.com) writes:
> I have a c/c++ programme that is called from within a
> widget hierachy via call_external.
>
> As the computations made take fairly long, I want to update
> a status bar with a 'Percentage complete' from the C-routine,
> so the user doesn't get upset and thinks the programme died
> on him/her.
>
> How do I go about that???
Well, this will be difficult unless your can call your
C program in "chunks", or in some other way interrupt
it. It might be easier if you just know, in general,
how long it takes. Then you can set a "kitchen timer"
sort of progress indicator. As long as the cake is
baked by the time the timer goes off, no one seems
to care. :-)
You can see several ways to build such a progress
indicator here:
http://www.dfanning.com/tips/show_progress.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
sec : U Re: widget_control from call_external [message #24045 is a reply to message #24009] |
Mon, 05 March 2001 16:48  |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
JD Smith wrote:
>
> David Fanning wrote:
>>
>> dominic@work.com (dominic@work.com) writes:
>>
>>> I have a c/c++ programme that is called from within a
>>> widget hierachy via call_external.
>>>
>>> As the computations made take fairly long, I want to update
>>> a status bar with a 'Percentage complete' from the C-routine,
>>> so the user doesn't get upset and thinks the programme died
>>> on him/her.
>>>
>>> How do I go about that???
>>
>> Well, this will be difficult unless your can call your
>> C program in "chunks", or in some other way interrupt
>> it. It might be easier if you just know, in general,
>> how long it takes. Then you can set a "kitchen timer"
>> sort of progress indicator. As long as the cake is
>> baked by the time the timer goes off, no one seems
>> to care. :-)
>>
>> You can see several ways to build such a progress
>> indicator here:
>>
>> http://www.dfanning.com/tips/show_progress.html
>
> I would use alarm() to throw a SIGALRM every 1 second, say, then update
> a percent complete counter, based on some innate knowledge of the
> calculation. To get this to IDL under call_external is more difficult.
> You *could* then just print it to the terminal, ala:
>
> printf("\r%02d%% complete",percent_complete);
>
> Make sure to:
>
> setbuf(stdout,(char *)NULL);
>
> first, so the updates will appear.
>
> Of course, RSI would frown on this, but if it gets the job done...
>
> If you'd like to do it full blown way, with a snazzy graphical update
> slider, you might have to make a full DLM, and use IDL_Execute to force
> the progress update from the C side. That's a lot of work for a bit of
> eye candy. But everybody likes candy.
>
> Good luck,
>
> JD
How about using the Widget_Stub functionality to pass an event from the
C
routine to a widget?
Under OpenVMS (at least) in IDL_DIR:[External.widstub] there are simple
examples of how to create your own widget type in C, and how to send
events
to it from C.
Comments in the file Widget_ArrowB.pro say :-
"While this code is VMS-centric, the principles apply across
platforms..."
Just another example of VMS leading the way.
I can't find the above directory or the example files in my Windows IDL
54
however do a Find in the Online Help for Widget Stub and everything you
need is there.
I've used Widget Stub to animate aircraft positions on a draw widget as
the C code fires off an event.
If a C-dunderhead like me can manage that, anyone can... ;-)
Andrew
------------------------------------------------------------ ---------
Andrew D. Cool .->-.
Electromagnetics & Propagation Group `-<-'
Surveillance Systems Division Transmitted on
Defence Science & Technology Organisation 100% recycled
PO Box 1500, Salisbury electrons
South Australia 5108
Phone : 061 8 8259 5740 Fax : 061 8 8259 6673
Email : andrew.cool@dsto.defence.gov.au
--------- * Never trust what a man with half a brain says *-----------
|
|
|