Re: Newbie questin regarding Widget timers [message #62176 is a reply to message #62174] |
Thu, 28 August 2008 19:36   |
Mike Potter
Messages: 19 Registered: August 2008
|
Junior Member |
|
|
Hi David:
Yes - I'm sure. I even exited the idlde, restarted IDL, reloaded
the changed version, compiled and ran it, and it ran fine. I even
added a print statement in the middle of the main procedure so that it
would produce something on the console to identify that it was the
altered version that was running. I saved the altered version to my
DEFAULT directory and de-selected all other directories in
Window>Preferences...>IDL>Path to be sure it wasn't picking up a
version from someplace else.
The reason the WIDGET timer stuff seemed superfluous was:
1) the line:
oWindow->SetEventMask, TIMER_EVENTS=1
appears in the branch of the case statement that handles play_button
events in the event procedure
2) the line:
oWindow->AddWindowEventObserver, oObserver
(oObserver is an instance of the custom-defined "timer_observer"
class) appears in the main "animation_doc" procedure,
and
3) there is a timer_observer::OnTimer method defined with oWindow as
it's only argument containing code that sets the ACTIVE_POSITION
within the oImages IDLgrMODEL instance, tnen calls oWindow->Draw.
It's all part of the standard IDL distribution, so if you have
that set up you should be able to try it yourself. I just commented
out the "WIDGET_CONTROL, wBase, TIMER=1" line in the main procedure,
and commented out the lines in the event procedure that checked to see
if the event received was a WIDGET_TIMER event (beginning with "IF
TAG_NAMES(sEvent, /STRUC) eq .......", running from lines 107-111, at
the top of the event procedure).
So, in essence, to these inexperienced eyes, there seems to be two
timer schemes operating simultaneously, one which just fires off a
timer event every one second no matter what, and the other which
drives the animation at a rate that are user-selectable.
Mike
On Aug 28, 3:23 pm, David Fanning <n...@dfanning.com> wrote:
> Mike Potter writes:
>> It looks to me that this just continuously fires timer events every
>> second that do nothing. I commented out the lines mentioned and the
>> application still runs just fine. So what is the utility of this?
>
> Uh, you sure!? TIMERs are one-shot events, so if the
> next timer event isn't fired off, things grind to a
> halt. Well, they don't exactly grind, they just stop.
> It seems unlikely to me that if this line is commented
> out, the program just works. Unless you forgot to compile
> the program after you made the change, of course. :-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|