comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Widget to play and pause image stack display
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Widget to play and pause image stack display [message #80194 is a reply to message #80192] Thu, 10 May 2012 09:35 Go to previous message
Russell Ryan is currently offline  Russell Ryan
Messages: 122
Registered: May 2012
Senior Member
On May 10, 10:24 am, Helder <hel...@marchetto.de> wrote:
> Hi,
> I would like to have a base widget with a draw widget where I play a movie (as in displaying a series of images from a stack).
> I would like to have the typical two buttons that start the play of the movie and the pause button.
> I'm not that good with widgets, but I can't thick of how I would be able to interrupt a loop that displays the images.
> I would have had something like:
>
> PauseButtonPressed = 0
> ImgNr = 0
> LoopInterval = 0.2
> WHILE ~PauseButtonPressed THEN
>    TV, Image[ImgNr,*,*]
>    ImgNr++
>    IF ImgNr GT nImages THEN ImgNr = 0
>    WAIT, LoopInterval
> ENDWHILE
>
> Is there a way to check if the user has clicked something in the loop?
>
> Thanks,
> Helder

Hi Helder
Yeah, there is a way to do this....
Here's a little example:

pro timer_event,event
widget_control,event.id,get_uval=uval

case uval of
'START': begin
widget_control,event.top,get_uval=state
(*state).stop=0b
widget_control,(*state).wtime,timer=(*state).time
end
'RESTART': begin
widget_control,event.top,get_uval=state
(*state).iter=0L
(*state).stop=0b
widget_control,(*state).wtime,timer=(*state).time
end
'STOP': begin
widget_control,event.top,get_uval=state
(*state).stop=1b
end
'TIME': begin
widget_control,event.top,get_uval=state

;your movie stuff here:
n=50
x=findgen(n)/(n-1)*2*!PI
x+=(*state).iter*2*!PI/10.
plot,x,sin(x)
;end of movie stuff




;more to end the loop
if (*state).stop then return
if ++(*state).iter gt (*state).maxiter then return
widget_control,event.id,timer=(*state).time
end

'DRAW':
else:
endcase
end

pro timer


base=widget_base(/col)
wtime=widget_base(base,uval='TIME')
wdraw=widget_draw(base,xsize=200,ysize=200,uval='DRAW')
wstart=widget_button(base,value='Start',uval='START')
wrestart=widget_button(base,value='Restart',uval='RESTART')
wstop=widget_button(base,value='Stop',uval='STOP')

state={wdraw:wdraw,$
wtime:wtime,$
wstart:wstart,$
wstop:wstop,$
time:0.1,$
stop:0b,$
maxiter:100l,$
iter:0l}
state=ptr_new(state,/no_copy)
widget_control,base,/realize,set_uval=state
xmanager,'timer',base,/no_block


end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: modifying geotiff without opening file
Next Topic: Re: Pan/Zoom Line Plots with Coyote Graphics

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 00:05:05 PDT 2025

Total time taken to generate the page: 0.95901 seconds