FUNCTION qView_UpdateActive, state, step=step, noloop=noloop, $ new=new, old=old, first=first, value=value, time=time, force=force ;+ ; NAME: ; qView_UpdateActive ; PURPOSE: ; Update the widget value indicating the current active image file ; CATEGORY: ; Widget qView ; CALLING SEQUENCE: ; Result = qView_UpdateActive(state[, step=step, /noloop, new=new, old=old]) ; INPUTS: ; state array[1]; type: structure ; qView state structure ; OPTIONAL INPUT PARAMETERS: ; step=step scalar; type: integer; default: 0 ; only values -1,0,1 should be used. ; -1 indicates going to the previous image in the loaded sequence ; +1 indicates going to the next image in the loaded sequence ; 0 indicates staying at the current image ; /first scalar; type: integer ; if set the first image is made the active image ; /noloop by default, if step=+/-1 is used the next/previous image is passed the end of ; of the sequence then the first/last image of the sequence is used. ; This can be prevented from happening by setting /noloop (in this case new=-1 ; is returned when stepping beyond the image sequence). ; OUTPUTS: ; Result scalar; type: byte ; 0B if the new active image is the same as the one on display ; 1B if this is not the case. ; (this can be used by the caller to call qView_Image if this routine returns 1B. ; OPTIONAL OUTPUT PARAMETERS: ; old=old scalar; type: integer ; the file index for the active image before the update ; new=new scalar; type: integer ; the file index after the update ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, qView_ImageInfo ; PROCEDURE: ; STATE INFO MODIFIED: ; widget_control, state.wid_active, set_value =new ; MODIFICATION HISTORY: ; FEB-2000, Paul Hick (UCSD/CASS) ; MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Added value and time keywords ;- InitVar, step, 0 InitVar, noloop, /key InitVar, first , /key InitVar, force , /key tmp = qView_ImageInfo(state, /first, /last, /incr, /active, /display) frst = tmp[0] last = tmp[1] incr = tmp[2] old = tmp[3] display = tmp[4] IF IsType(value, /defined) THEN new = value ELSE IF first THEN new = frst ELSE new = old+step*incr IF new GT last THEN IF noloop THEN new = -1 ELSE new = frst IF new LT frst THEN IF noloop THEN new = -1 ELSE new = last IF new NE -1 THEN BEGIN tmp = qView_ImageInfo(state, file=new) ; Make sure 'new' is valid IF new NE old OR force THEN BEGIN widget_control, state.wid_active, set_value=new IF IsType(time, /undefined) THEN BEGIN widget_control, state.wid_pick, get_uvalue=files, /no_copy time = files[new,2] widget_control, state.wid_pick, set_uvalue=files, /no_copy ENDIF IF time NE '' THEN widget_control, state.wid_time, set_value=time ENDIF ENDIF RETURN, new NE display & END