;+------------------------------------------------------------- ; NAME: ; clickon7 ; PURPOSE: ; Allow recording of click locations on .cin files from a ; Phantom 4 or 7 camera. Also displays files from the color Miro camera. ; Also, view animations and save frames at JPEG, GIF or TIFF files. ; CATEGORY: ; Image Processing ; CALLING SEQUENCE: ; IDL> clickon7, filename ; INPUTS: ; filename - a .cin file ; (or will pop dialog box) ; KEYWORD PARAMETERS: ; nBG - number of background frames. If=0 (the default) no background subtraction is done ; bgFrame - the first frame of the background (default=0) ; ByteScale - if =0, will not byte scale image before displaying. ; box - if set, will try to handle two boxes that show up on one of Ricky's cameras ; drawXSize - the horizontal size in pixels of the image window ; INTERP - if =1, pixels will be smoothed, rather than replicated ; colorTable - default to IDL color table 3 (hot metal) ; gamma - gamma correction. ; startTime - start time in milliseconds ; maxPlayMinutes - defaults to 60 ; (optional) ; radius - 1/2 of square in pixels drawn around click point, setting the area ; to be used for the maxval calculation. ; GROUP_LEADER - Group_Leader ID ; OUTPUTS: ; none. ; COMMON BLOCKS: ; none ; ROUTINES USED: ; MK_COLOR, usingXwindows ; EXAMPLE: ; IDL> clickon7 ; you will be prompted for a .cin file ; ; or IDL> clickon7,'/p/camdata/dust/nstx121048.cin',start=200 ; or IDL> clickon7,'/p/nstxusr3/miro/MIRO_130708.cin',start=232 ; IDL> clickon7,file='/p/nstxusr2/nstxphantom7/NSTX_130389.cin',starttime=194.974,/debug ; IDL> clickon7,file='/p/nstxusr3/miro/MIRO_130708.cin',starttime=232,/power,/debug ; NOTES: ; MODIFICATION HISTORY: ; 10-Nov-2008 cleaned up incompatibility with tvimage. Added menu options for # of ; background frames to subtract, start frame for background subtraction, ; turn off/on byte scaling of image. ; 04-Aug-2008 added Frame Time slider widget ; 31-Jul-2008 Added imageproc option to Special menu & gamma setting to Edit menu. ; Also added median smoothing option. ; 16-Jul-2008 Can ungzip .gz files automatically ; 14-Jul-2008 Added support for color images. Added GAMMA keyword. ; 10-Jun-2008 Added XSectionW option. Changed default to no background subtraction ; 15-May-2008 Added maxPlayMinutes, so movie won't run for ever (Default to 1 hour) ; 12-May-2008 made advance and backup buttons more clear. Added noLoad keyword so ; color palette loading can be surpressed. ; 09-May-2008 Fixed bug when getting new file. Loop continously in movie mode ; 15-Feb-2008 Add options to save as JPEG, GIF & TIFF ; 27-Aug-2007 change Advance to Advance (so don't add one when incrementing) ; 15-Mar-2007 add animation feature ; 22-Oct-2006 fixed bug for Jump-to entry ; 26-Oct-2006 added Advance-number-of-frames box ; 19-Oct-2006 added BG subtraction and "box disquising" ; 01-Jun-2006 Written by Bill Davis, PPPL ;------------------------------------------------------------------------------ PRO gamma_sliderw_event, event, GROUP_LEADER=group_leader WIDGET_CONTROL, event.id, GET_UVALUE=info ;;;, /no_copy WIDGET_CONTROL, event.id, GET_VALUE=gamma ;;;help, info if SIZE( info, /type ) eq 8 then begin info.gamma = gamma ;;; if info.debug then stop PlotSomething, info WIDGET_CONTROL, info.baseID, SET_UVALUE=info endif else begin uvalue = info CASE uvalue of 'DISMISS': BEGIN WIDGET_CONTROL, /DESTROY, event.top END ENDCASE endelse end ;-------------------------------------------------------------- ; This routine is called when user selects "Show Signal Menu" PRO gamma_sliderw, info, GROUP_LEADER=group_leader BaseID = WIDGET_BASE( TITLE = 'Gamma Value',/COLUMN, GROUP_LEADER=group_leader, $ resource='colorbuttons' ) colID = WIDGET_BASE(BaseID, /ROW) textID = WIDGET_LABEL( colID, value=' >> Higher values of Gamma give more contrast') minSlider = .2 maxSlider = 3.0 gammaID = CW_FSLIDER( baseID, $ MIN=minSlider, $ MAX=maxSlider, $ VALUE=info.gamma, $ xsize=48*!D.X_CH_SIZE, $ scroll=(maxSlider-minSlider)/20., $ UVALUE=info, $ /drag, TITLE="Gamma" ) butID = WIDGET_BUTTON( baseID, VALUE='DISMISS', UVALUE='DISMISS',resource_name='yellow' ) WIDGET_CONTROL, BaseID, /REALIZE XMANAGER, 'gamma_sliderw', baseID, GROUP_LEADER=group_leader, $ /no_block END ;------------------------------------------------------------------------------ PRO PlotSomething, info, Advance=Advance if not info.debug then on_error, 2 IF !D.NAME NE 'PS' THEN BEGIN ; set desired x-window WSET, info.pixID ENDIF ;;; if info.debug then print,"info.interp=", info.interp title = chompfn(info.filename, max=info.maxTitleLen ) if info.frameWanted ne -1 then title = title + $ ' at '+strtrim( FLOAT(info.frameTime),2 ) + ' ms' info.title = title x = indgen(info.xsize) & y = indgen(info.ysize) if info.debug then print, info.frameWanted, info.frameTime erase position=[0.0, 0.02, 1.0, 0.95] image = *info.Image if info.nSmooth gt 1 then image = MEDIAN( image, info.nSmooth ) if info.gamma ne 1 then image = GAMMA_RAISE( image, info.gamma ) if info.ByteScale then image = BYTSCL( image, Top=Info.highColor-1) + Info.bottom ; ??? tvimage, image, x, y, $ position=position, /KEEP_ASPECT_RATIO, true=info.trueColor, axes=0 if !x.window[0] eq !x.window[1] then image_window = position $ else image_window = [ !X.window[0], !Y.window[0], !X.window[1], !Y.window[1] ] screen_title, title, logo=0 if info.powerSpectrum then begin img = *info.Image ; if true color, just use red frame if n_elements( size(img,/dim) ) eq 3 then img = reform( img[0,*,*] ) freq_img = FFT(Temporary(img), 1) powerImg = Shift( BYTSCL( Alog(Abs(freq_img)), TOP=Info.highColor ), 32, 32) endif ;;; plot,x, y, /nodata, /noerase, xstyle=1, ystyle=1, pos=image_window ;;;print, 'info.nClicks=', info.nClicks if NOT keyword_set( Advance ) and info.nClicks gt 0 then begin ; don't update table if Advanceped last frame IF !D.NAME NE 'PS' and info.StopFlag eq 0 THEN BEGIN ; set desired x-window ; draw circle around point of last click lastI = (*info.clickX)[info.nClicks] lastJ = (*info.clickY)[info.nClicks] col = !D.N_COLORS -1 DEVICE, GET_GRAPHICS_FUNCTION = old, SET_GRAPHICS_FUNCTION = 6 ;Set xor if info.debug then stop ; to set graphics coordinates for later square drawing plot, x, y, /nodata, /noerase, xstyle=1+4, ystyle=1+4, pos=image_window, $ color=col, xtickname=replicate(' ',30), $ ytickname=replicate(' ',30) drawsquare, lastI, lastJ, info.radius, color=col, /dashed ;;;, color=mk_color('white',/search) DEVICE,SET_GRAPHICS_FUNCTION = old ENDIF endif IF !D.NAME NE 'PS' THEN BEGIN ; set desired x-window WSET, info.drawWindowID Device, Copy=[0, 0, info.drawXsize, info.drawYsize, 0, 0, info.pixid] ENDIF if info.powerSpectrum then begin WSET, 17 tv,powerImg WSET, info.drawWindowID endif end ;--------------------------------------------------------------------------- PRO Write_Results_file, info, outFilename=outFilename, comment=comment IF nwords(outFileName) eq 0 then $ outFileName = DIALOG_PICKFILE( TITLE='Save to a file file', file=info.outFileName, $ FILTER='*.txt', /WRITE) IF outFileName NE '' THEN BEGIN response = 'Yes' there = file_search( outFileName ) if nwords(there) gt 0 then response = dialog_message( $ 'THAT FILE ALREADY EXISTS! OVERWRITE?', /question ) if response ne 'Yes' then return if nwords( comment ) eq 0 then $ comment = dialog_input(prompt='Enter a comment for file header', $ width=80,/RETURN_EVENTS) n = info.nClicks openw, lun, outFileName, /get_lun printf, lun, 'Output from clickon7.pro at '+systime(0)+' by '+getenv('USER') printf, lun, ' ' printf, lun, ' (last) used file '+info.lastFile printf, lun, ' ' printf, lun, 'comment= ', comment printf, lun, ' ' tab= '09'XB printf, lun, 'x', tab, 'y', tab, 'Val', tab, ' Max ', tab, 'time(ms)', $ FORMAT="(a6, a1, a6, a1, a6, a1, a6, a1, a8)" for i = 0, n do begin if (*info.clickX)[i] gt 0 and (*info.clickY)[i] gt 0 then begin fdecomp, (*info.files)[i], disk, path, shortName, ext printf, lun, (*info.clickX)[i], tab, $ (*info.clickY)[i], tab, $ (*info.clickVal)[i], tab, $ (*info.clickCircleMax)[i], tab, $ (*info.clickTime)[i], $ FORMAT="(i6, a1, i6, a1, i6, a1, i6, a1, ' ', d)" endif endfor close, lun free_lun, lun print, ' (record written to text file)' ;;; a=dialog_message( 'Data written to '+outFileName, /info) info.outFileName = outFileName ENDIF END ;-------------------------------------------------------------- FUNCTION GET_NEXT_IMAGE, filename, highColor=highColor, bottom=bottom, $ time=startTime, frameWanted=frameWanted, $ backGround=backGround, nBG=nBG, $ allTimes=allTimes, $ actualTime=actualTime, mag=mag, box=box, $ outMsg=outMsg, status=status if n_elements( bottom ) eq 0 then bottom=0 fdecomp, filename, disk, dir, name, ext if strupcase( ext ) eq 'CIN' or strupcase( ext ) eq 'CINE' THEN BEGIN shot = strmid( name, 4, 6 ) ;;;print, ' >>> from GET_NEXT_IMAGE, frameWanted=', frameWanted ; this version subtracts the first image from the frame wanted image = CINELOAD( filename, frameWanted, pps, exposure, $ outMsg=outMsg, verbose=verbose, status=status ) ;;;help,outMsg if not status then return, -1 ENDIF ELSE BEGIN if n_elements( bottom ) eq 0 then bottom=0 fullpath = file_search(filename) if nwords( fullpath ) eq 0 then begin ;;; r=dialog_message( 'Could not find file '+ filename ) return, -1 endif image = READ_GENERIC(fullpath[0],r,g,b) s = SIZE(image) IF s[0] NE 2 THEN BEGIN r= dialog_message( 'Image not 2D from file '+ fullpath[0]) outMsg = 'Image not 2D from file '+ fullpath[0] return, -1 ENDIF image = FLIP( image ) ENDELSE if n_elements( nBG ) gt 0 then begin if nBG gt 0 then begin if size( backGround, /type ) eq 10 then begin image = (image-LONG(*(background))) > 0 endif else begin image = (image-LONG(background)) > 0 endelse endif endif if keyword_set( box ) then image = SCALEBOXES( image ) ;;;if n_elements( highColor ) eq 0 then begin ;;; Image = BytScl(image) + byte(bottom) ;;;endif else begin ;;; Image = BytScl(image, Top=highColor-1) + byte(bottom) ;;;endelse frameWanted = frameWanted > 0 if n_elements( allTimes ) gt frameWanted then actualTime = allTimes[ frameWanted ] return, Image end ;-------------------------------------------------------------- PRO NEXT_FRAME_PRO, info, Advance=Advance, status=status status=1 filename = info.filename[0] fdecomp, filename, disk, dir, name, ext if strupcase( ext ) NE 'CIN' AND strupcase( ext ) NE 'CINE' THEN BEGIN filename = getnextfile( filename, numeric=info.numeric ) widget_control, info.frameID, sens=0 widget_control, info.frameID, set_value="-1" ENDIF ELSE BEGIN ;;; widget_control, info.frameID, sens=1 ; now passed in ;;; widget_control, info.frameID, get_value=frameWanted ;;; info.frameWanted = frameWanted ENDELSE ;;;print, ' >>> from GET_NEXT_FRAME, info.frameWanted=', info.frameWanted image = GET_NEXT_IMAGE( filename, backGround=info.backGroundImage, $ frameWanted=info.frameWanted, allTimes=*info.allTimes, $ highColor=info.highColor, bottom=info.bottom, $ outMsg=outMsg, actualTime=actualTime, box=info.box, $ nBG=info.nBG, $ status=status ) if not status then return if n_elements( image ) eq 1 then begin if nwords( outMsg ) gt 0 $ then r=dialog_message( outMsg, /info) $ else r=dialog_message( filename + ' not found', /info) status = 0 return endif *info.image = image if n_elements( actualTime ) gt 0 then info.frameTime = actualTime ;;; print, 'from NEXT_FRAME_PRO: info.frameTime = ',info.frameTime info.filename = filename PlotSomething, info, Advance=Advance end ;-------------------------------------------------------------- FUNCTION What_Button_Pressed, event button = ['NONE', 'LEFT', 'MIDDLE', 'NONE', 'RIGHT'] Return, button(event.press) END ;******************************************************************* ;-------------------------------------------------------------- PRO DRAW_EVENTS_PRO, event Widget_Control, event.top, Get_UValue=info possibleEventTypes = [ 'DOWN', 'UP', 'MOTION', 'SCROLL' ] thisEvent = possibleEventTypes(event.type) if info.debug then print, 'DRAW_EVENTS_PRO called with thisEvent=', thisEvent CASE thisEvent OF 'DOWN': BEGIN buttonPressed = What_Button_Pressed(event) IF buttonPressed EQ 'LEFT' THEN BEGIN coord = CONVERT_COORD(Event.x, Event.y, /device, /to_data) if coord[0] gt info.xsize then beep if coord[1] gt info.ysize then beep if info.debug then print, Event.x, Event.y, coord info.nClicks = info.nClicks + 1 xUse = 0> NINT(coord[0]) < (info.xsize-1) yUse = 0> NINT(coord[1]) < (info.ysize-1) (*info.clickX)[ info.nClicks ] = xUse (*info.clickY)[ info.nClicks ] = yUse if info.TrueColor then begin (*info.clickVal)[ info.nClicks ] = MAX((*info.image)[ *,xUse, yUse ]) endif else begin (*info.clickVal)[ info.nClicks ] = (*info.image)[ xUse, yUse ] endelse (*info.clickTime)[ info.nClicks ] = info.frameTime if info.debug then print, 'from DRAW: info.frameTime = ', info.frameTime if info.debug then print, ' info.nClicks = ', info.nClicks x1 = xUse - info.radius/2 & x2 = xUse + info.radius/2 y1 = yUse - info.radius/2 & y2 = yUse + info.radius/2 x1 = 0 > x1 < (info.xsize-1) y1 = 0 > y1 < (info.ysize-1) x2 = 0 > x2 < (info.xsize-1) y2 = 0 > y2 < (info.ysize-1) if info.trueColor then begin (*info.clickCircleMax)[ info.nClicks ] = MAX((*info.image)[ *,x1:x2, y1:y2 ]) endif else begin (*info.clickCircleMax)[ info.nClicks ] = MAX((*info.image)[ x1:x2, y1:y2 ]) endelse ;;; clickPt = Convert_Coord( [xUse, yUse], /Data, /To_Data) col = !D.N_COLORS -1 DEVICE, GET_GRAPHICS_FUNCTION = old, SET_GRAPHICS_FUNCTION = 6 ;Set xor drawsquare, xUse, yUse, info.radius, color=col ;;;, color=mk_color('white',/search) DEVICE,SET_GRAPHICS_FUNCTION = old (*info.files)[ info.nClicks ] = info.filename info.lastFile = info.filename wait, 0.2 ; pause 1/2 second info.frameWanted = info.frameWanted + info.Advance widget_control, info.frameID, set_value=strtrim(info.frameWanted,2) NEXT_FRAME_PRO, info Widget_Control, event.top, Set_UValue=info RETURN ENDIF else begin bell print, ' *** left & middle mouse buttons not implemented ' return endelse ENDCASE 'MOTION': BEGIN END 'UP': BEGIN END ENDCASE END ; of DRAW_EVENTS_PRO ****************************************************************** ;-------------------------------------------------------------------------- pro xcolors_callback, data=event !p.color=colorsearch('black') !p.background=colorsearch('white') widget_control, event.top, get_uvalue=info PlotSomething, info end ;--------------------------------------------------------------------------- pro handle_color, event widget_control,event.top,get_uvalue=info ;;;,/no_copy if info.debug then print, 'HANDLE_COLOR CALLED' thisevent=tag_names(event,/structure_name) ;for waiting for new color table to be selected device, get_visual_depth=thisdepth ;these statements allow Advanceping this stuff ;with 8bit ;color where not necessary if thisdepth gt 8 then notifyPro='xcolors_callback' case thisevent of 'WIDGET_BUTTON': begin dum = mk_color(n_nonfixed=ncolors) xcolors, $ ;calls up color table widget notifyPro=notifyPro, $ data=event, $ ncolors=ncolors, $ colorInfo=colorInfo, $ group_leader=event.top, $ ;in definition of xcolors keyword is defined as ;group_leader=group ; then xmanager,'xcolors',xc_tlb,---;,Group_leader=group makes notifyid=[event.id,event.top] ; xcolors written wth keyord notifyid=[event.id,event.top] event.id is widget to notify, event.top is parent? if n_elements( colorInfo ) gt 0 then begin if (*colorinfo).index ge 0 then begin info.ColorTable = (*colorInfo).index if sInfo.debug then print, 'info.ColorTable = ',info.ColorTable endif endif else begin beep print, 'colorInfo not defined' endelse end 'XCOLORS_LOAD': begin ; called from xcolors callback wset, info.drawWindowID ;assigns current graphics window to resized window end Endcase widget_control,event.top,$ set_uvalue=info ;;;,/no_copy ;puts info back where it should be end ;------------------------------------------------ pro img_XSection, event widget_control,event.top,get_uvalue=info ;;;,/no_copy xsectionw, *info.image, $ title=info.title, /NoLoad, $ GROUP_LEADER=event.top end ;-------------------------------------------------------------------------------------- PRO clickon7_event, event WIDGET_CONTROL, event.top, get_uvalue = info ;;;, /no_copy if not info.debug then on_error, 2 WIDGET_CONTROL, event.id, GET_UVALUE = UVALUE ; What kind of event is this? eventName = TAG_NAMES( event, /STRUCTURE_NAME ) IF info.debug NE "" THEN print,' (uvalue, eventName = ', uvalue, ' ', eventName, ')' ; handle resize event IF (eventName EQ 'WIDGET_BASE') THEN BEGIN ; (don't understand why have to mult by 0.66) drawXsize = event.x drawYsize = drawXSize/info.drawXsize * info.drawYsize WIDGET_CONTROL, UVALUE.drawID, Draw_XSize=drawXsize, Draw_YSize=drawYsize UVALUE.drawXsize = drawXsize UVALUE.drawYsize = drawYsize WIDGET_CONTROL, UVALUE.baseID, SET_UVALUE=UVALUE ;;; WIDGET_CONTROL, event.top, SET_UVALUE=info PlotSomething, info RETURN widget_control, event.top, set_uvalue = info ;;;, /no_copy ENDIF ; Code for TIMER events. IF eventName EQ 'WIDGET_TIMER' THEN BEGIN ;;;print, ' >> from '+proname()+', info.frameWanted, stopFlag=', info.frameWanted, info.stopflag IF systime(1)-info.startedPlayingSec gt info.maxPlayMinutes*60 then $ info.stopflag = 1 ; don't let play forever IF info.stopflag eq 0 THEN BEGIN ;;; print, 'In timer code' ;;; stop widget_control, info.AdvanceID, get_value=AdvanceNum WSET, info.drawWindowID info.Advance = AdvanceNum if info.Forward then $ info.frameWanted = info.frameWanted + info.Advance else $ info.frameWanted = info.frameWanted - (info.Advance) ;;; info.frameWanted = info.frameWanted MOD (n_elements( info.AllTimes )-1) info.frameWanted = info.frameWanted MOD ( info.nFrames-1) ;;; print, 'WIDGET_TIMER event for frame', info.frameWanted ;;; widget_control, info.frameID, set_value=strtrim(info.frameWanted,2) NEXT_FRAME_PRO, info, Advance=info.Advance, status=status ;;; print, 'In timer code' ;;; help,status,info.frameWanted ;;; stop if status then begin widget_control, info.frameID, set_value=strtrim(info.frameWanted,2) widget_control, info.frameTimeID, set_value=info.frameTime endif else begin info.stopflag = 1 widget_control, event.top, set_uvalue = info return endelse WIDGET_CONTROL, event.top, SET_UVALUE=info ; Set a timer event to get back into this event handler. WIDGET_CONTROL, event.ID, TIMER=0 ENDIF return ENDIF ; of TIMER code CASE UVALUE of 'AdvanceThis': begin widget_control, info.AdvanceID, get_value=AdvanceNum info.Advance = LONG( AdvanceNum ) if info.debug then print, 'AdvanceNum=',AdvanceNum info.frameWanted = info.frameWanted + (info.Advance>1) NEXT_FRAME_PRO, info, /Advance, status=status if info.debug then print, 'Status from NEXT_FRAME_PRO=', status if status then begin widget_control, info.frameID, set_value=strtrim(info.frameWanted,2) widget_control, info.frameTimeID, set_value=info.frameTime endif end 'AdvanceNumber': BEGIN widget_control, info.AdvanceID, get_value=AdvanceNum info.Advance = AdvanceNum END 'BackUp': begin widget_control, info.AdvanceID, get_value=AdvanceNum info.Advance = AdvanceNum info.frameWanted = info.frameWanted - info.Advance NEXT_FRAME_PRO, info, status=status if status then begin widget_control, info.frameID, set_value=strtrim(info.frameWanted,2) widget_control, info.frameTimeID, set_value=info.frameTime endif end 'bgFrame': BEGIN entry = DIALOG_INPUT( prompt='Frame to subtract', $ /RETURN_EVENTS, /integer, initial=info.bgFrame ) if entry EQ '' then return else bgFrame = entry if bgFrame le 0 then begin info.bgFrame = 0 endif else begin info.bgFrame = bgFrame ; get the first frame as a background for dimensions, and maybe for subtracting BackGroundImage = CINELOAD( info.filename, bgFrame, pps, exposure, status=status ) if not status then begin print, ' *** frame '+strtrim( bgFrame, 2) + ' for background subtraction not available' return endif for i=1,info.nBG-1 do begin BackGroundImage = BackGroundImage + $ CINELOAD( info.filename, bgFrame+i, pps, exposure, status=status ) endfor ptr_free, info.BackGroundImage info.BackGroundImage = ptr_new(BackGroundImage/info.nBG) endelse NEXT_FRAME_PRO, info PlotSomething, info END 'nBG': BEGIN entry = DIALOG_INPUT( prompt='Enter # of Background frames to subtract (0 for none)', $ /RETURN_EVENTS, /integer, initial=info.nBG ) if entry EQ '' then return else nBG = entry if nBG le 0 then begin info.nBG = 0 endif else begin ; get the first frame as a background for dimensions, and maybe for subtracting BackGroundImage = CINELOAD(info.filename, info.bgFrame, pps, exposure, status=status ) if not status then begin print, ' *** frame '+strtrim( info.bgFrame, 2) + ' for background subtraction not available' return endif info.nBG = nBG for i=1,nBG-1 do begin BackGroundImage = BackGroundImage + $ CINELOAD( info.filename, info.bgFrame+i, pps, exposure, status=status ) endfor ptr_free, info.BackGroundImage info.BackGroundImage = ptr_new(BackGroundImage/nBG) endelse NEXT_FRAME_PRO, info PlotSomething, info END 'Break': STOP 'ByteScale' : BEGIN ; toggle menu IF info.ByteScale eq 1 THEN BEGIN WIDGET_CONTROL, event.id, SET_VALUE='Turn on BYTE scaling' info.ByteScale = 0 ENDIF ELSE BEGIN WIDGET_CONTROL, event.id, SET_VALUE='Turn off BYTE scaling' info.ByteScale = 1 ENDELSE WIDGET_CONTROL, event.top, SET_UVALUE=info ; store back in base END 'CLEAR': BEGIN WSET, info.drawWindowID ERASE, info.sColor.white END 'Colorpalette' : XLoadCT ;;;_mk_color 'CT': BEGIN entry = DIALOG_INPUT( prompt='Enter the Color Table Number', $ /RETURN_EVENTS, /integer ) if entry EQ '' then return else info.colorTable = entry d=mk_color( table=info.colorTable ) END 'Dismiss': WIDGET_CONTROL, event.top ,/DESTROY 'FrameTime': begin widget_control, info.frameTimeID, get_value=frameTimeMSEC frameTime = frameTimeMSEC frame = nearesti( (*info.allTimes),frameTime ) image = GET_NEXT_IMAGE( info.filename, time=frameTime, allTimes=info.allTimes, $ BackGround=(*info.BackGroundImage), $ highColor=info.highColor, bottom=info.bottom, frame=frame, $ nBG=info.nBG, $ outMsg=outMsg, actualTime=actualTime, box=info.box, status=status) if n_elements( image ) eq 1 then begin if nwords( outMsg ) gt 0 $ then r=dialog_message( outMsg, /info) $ else r=dialog_message( filename + ' not found', /info) return endif if not status then return ;;; if n_elements( actualTime ) gt 0 then info.frameTime = actualTime if info.debug then print, 'after call to GET_NEXT_IMAGE, frame=', frame info.frameTime = frameTime info.frameWanted = frame widget_control, info.frameID, set_value=strtrim( frame, 2 ) widget_control, info.frameTimeID, set_value=info.frameTime (*info.image) = image PlotSomething, info end 'FrameWanted': BEGIN widget_control, info.frameID, get_value=FrameWanted info.FrameWanted = FrameWanted NEXT_FRAME_PRO, info widget_control, info.frameTimeID, set_value=info.frameTime plotSomething, info END 'Gamma': BEGIN ;;; entry = DIALOG_INPUT( prompt='Enter the Value of Gamma', $ ;;; /RETURN_EVENTS, /float ) gamma_sliderw, info, GROUP_LEADER=event.top PlotSomething, info END 'Help_Program': BEGIN XDISPLAYFILE,'/nstxusr1/util/vis/clickonw_help.txt',GROUP=event.top END 'imageproc': BEGIN img = *info.image if n_elements( size(img,/dim) ) eq 3 then img = reform( img[0,*,*] ) imageProc, img, GROUP_LEADER=event.top END 'MaxV': BEGIN entry = DIALOG_INPUT( prompt='Enter the Value of the Maximum Color', $ /RETURN_EVENTS, /integer ) if entry EQ '' then return else maxColor = entry d=mk_color( max=maxColor, table=info.colorTable ) info.highColor = maxColor END 'NewFile': begin if info.nClicks gt 0 then begin response = dialog_message( $ 'YOU HAVE NOT SAVED SOME CLICKS! CONTINUE AND LOSE THEM?', /question ) if response ne 'Yes' then return endif filename = DIALOG_PICKFILE(title='Select an Phanom file: ', $ PATH=info.path, FILTER='*.cin*', GET_PATH=path ) if filename EQ '' then return if strpos(filename,'.gz') eq strlen(filename)-3 then begin print, ' >>> (Unzipping file -- have patience!)' spawn, 'gunzip '+filename, result, Exit_Status=errors if errors then print,"*** probably don't have privileges to unzip "+filename filename = strmid( filename, 0, strlen(filename)-3 ) endif fdecomp, filename, disk, dir, name, ext if nwords( ext ) eq 0 then begin r=dialog_message('*** no extension -- file chosen must be a .cin file! ***') return endif if STRLOWCASE(ext) ne 'cin' AND STRLOWCASE(ext) ne 'cine' then begin r=dialog_message('*** file must have a .cin extention! ***') return endif info.path = path info.filename = filename info.nClicks = 0 if strupcase( ext ) eq 'CIN' or strupcase( ext ) eq 'CINE' THEN BEGIN ; get desired start time shot = strmid( name, 4, 6 ) if n_elements( startTime ) eq 0 then begin cine_time, filename, allTimes, frames, firstImage=firstFrame fr1 = MIN( frames, MAX=fr2) time1 = MIN( allTimes, MAX=time2 ) initial = DOUBLE(time1) if time2 gt 300 then time1=200.D msec1 = strtrim( string( time1*1000., format='(F16.4)'),2 ) msec2 = strtrim( string( time2*1000., format='(F16.4)'),2 ) prompt = [' Times '+msec1 + ' to '+msec2+' msec', $ ' Correspond to frames '+strtrim(LONG(fr1),2) + ' to ' $ +strtrim(LONG(fr2),2), $ ' ', $ 'Enter a start time in msec:'] startTime=DIALOG_INPUT( prompt=prompt, /double, initial=double) endif if startTime eq '' then return if startTime lt time1*1000. or startTime gt time2*1000. then begin msg = ['Times '+msec1 + ' to '+msec2+' msec in file', $ ' ', $ 'Limiting the entry to this range.'] r=DIALOG_MESSAGE( msg ) startTime = (time1*1000.) >starttime < (time2*1000.) endif startTime=double(startTime) endif if info.nBG gt 0 then begin ; get the background for subtracting BackGroundImage = CINELOAD( filename, firstFrame, pps, exposure,status=status ) if not status then return print, 'for 1st background frame:' minmax, BackGroundImage nBG = info.nBG for i=1,nBG-1 do begin BackGroundImage = BackGroundImage + $ CINELOAD( filename, firstFrame+i, pps, exposure, status=status ) endfor BackGroundImage = BackGroundImage/nBG endif CINE_TIME, filename, allTimes allTimes = allTimes*1000. if n_elements( starttime ) eq 0 then startTime = info.frametime ; for starters frameWanted = nearesti( allTimes, startTime ) image = GET_NEXT_IMAGE( filename, time=startTime, frame=frameWanted, allTimes=allTimes, $ backGround=backGroundImage, highColor=highColor, bottom=bottom, $ nBG=nBG, $ actualTime=actualTime, box=info.box, status=status ) if n_elements( actualTime ) gt 0 then info.frameTime = actualTime info.frameWanted = frameWanted IF strupcase( ext ) NE 'CIN' AND strupcase( ext ) NE 'CINE' THEN BEGIN widget_control, info.frameID, sens=0 ENDIF ELSE BEGIN widget_control, info.frameID, sens=1 widget_control, info.frameID, set_value=strtrim(info.frameWanted,2) widget_control, info.frameTimeID, set_value=info.frameTime ENDELSE s = SIZE(image) IF s[0] eq 2 THEN BEGIN info.TrueColor = 0 ENDIF ELSE IF s[0] eq 3 AND s[1] eq 3 THEN BEGIN info.TrueColor = 1 ENDIF ELSE BEGIN Message, 'Input image must be 2D' return ENDELSE info.nFrames = n_elements( allTimes ) if info.nBG gt 0 then (*info.BackGroundImage) = BackGroundImage (*info.files)[0] = filename (*info.image) = image (*info.allTimes) = allTimes PlotSomething, info end 'NewTime': begin if info.nClicks gt 0 then begin response = dialog_message( $ 'YOU HAVE NOT SAVED SOME CLICKS! CONTINUE AND LOSE THEM?', /question ) if response ne 'Yes' then return endif startTime=dialog_input( prompt='Enter a start time in msec', /double, $ initial=info.FrameTime) if startTime eq '' then return info.nClicks = 0 image = GET_NEXT_IMAGE( info.filename, time=startTime, allTimes=info.allTimes, $ BackGround=(*info.BackGroundImage), $ highColor=info.highColor, bottom=info.bottom, frame=frame, $ nBG=info.nBG, $ outMsg=outMsg, actualTime=actualTime, box=info.box, status=status) if n_elements( image ) eq 1 then begin if nwords( outMsg ) gt 0 $ then r=dialog_message( outMsg, /info) $ else r=dialog_message( filename + ' not found', /info) return endif if not status then return if n_elements( actualTime ) gt 0 then info.frameTime = actualTime if info.debug then print, 'after call to GET_NEXT_IMAGE, frame=', frame info.frameWanted = frame widget_control, info.frameID, set_value=strtrim( frame, 2 ) widget_control, info.frameTimeID, set_value=info.frameTime (*info.image) = image PlotSomething, info end 'nSmooth': BEGIN entry = DIALOG_INPUT( prompt='Enter the Value for median smoothing', $ /RETURN_EVENTS, /integer ) if entry EQ '' then return else nSmooth = entry info.nSmooth = nSmooth PlotSomething, info END 'PlayForward': begin info.stopFlag = 0 info.Forward = 1 widget_control, info.AdvanceID, get_value=AdvanceNum WSET, info.drawWindowID info.Advance = AdvanceNum ;;; info.frameWanted = info.frameWanted + info.Advance+1 ;;; info.frameWanted = info.frameWanted MOD (n_elements( info.AllTimes )-1) info.frameWanted = info.frameWanted MOD (info.nFrames-1) NEXT_FRAME_PRO, info, Advance=info.Advance, status=status ;;; help,status,info.frameWanted if status then begin widget_control, info.frameID, set_value=strtrim(info.frameWanted,2) widget_control, info.frameTimeID, set_value=info.frameTime endif else begin info.stopflag = 1 widget_control, event.top, set_uvalue = info return endelse info.startedPlayingSec = systime(1) if info.debug then print, 'Setting timer' ; Set a timer event to get back into this event handler. WIDGET_CONTROL, event.ID, TIMER=0 end 'PlayBackward': begin info.stopFlag = 0 info.Forward = 0 widget_control, info.AdvanceID, get_value=AdvanceNum WSET, info.drawWindowID info.Advance = AdvanceNum ;;; info.frameWanted = info.frameWanted - (info.Advance+1) ;;; info.frameWanted = info.frameWanted MOD (n_elements( info.AllTimes )-1) info.frameWanted = info.frameWanted MOD ( info.nFrames-1 ) NEXT_FRAME_PRO, info, Advance=info.Advance, status=status if status then begin widget_control, info.frameID, set_value=strtrim(info.frameWanted,2) widget_control, info.frameTimeID, set_value=info.frameTime endif else begin info.stopflag = 1 widget_control, event.top, set_uvalue = info return endelse info.startedPlayingSec = systime(1) if info.debug then print, 'Setting timer' ; Set a timer event to get back into this event handler. WIDGET_CONTROL, event.ID, TIMER=0 end 'print_bitmap': BEGIN ; this printing is much faster, but low-res name = 'bitmap' ; will leave a file with this name.ps print,' (printing a bitmap; this may take a minute)' IF ( (!D.NAME EQ 'X') OR (!D.NAME EQ 'MAC') ) THEN WIDGET_CONTROL,/hourglass image = TVRD() backGround = !P.BACKGROUND SETUP_PS, name, PRINTER=info.printer TV, Blank_White(*info.Image, white=backGround) UNSETUP_PS ; will print the above .ps file END 'print_plot': BEGIN name = 'clickon7' ; will leave a file with this name.ps IF ( (!D.NAME EQ 'X') OR (!D.NAME EQ 'MAC') ) THEN WIDGET_CONTROL,/hourglass SETUP_PS, name, PRINTER=info.printer PlotSomething, info UNSETUP_PS ; will print the above .ps file END 'Printer_Select': BEGIN info.printer = event.value ; strip extra stuff in SETUP_PS WIDGET_CONTROL, event.top, SET_UVALUE=info ; store back in base END 'savegif': BEGIN fileName = DIALOG_PICKFILE( TITLE='Save to a GIF file', $ FILTER='*.gif', /WRITE ) IF fileName NE '' THEN BEGIN TVLCT, r, g, b, /get ; so colors aren't expanded to 256 WRITE_GIF, filename, *Info.Image, r, g, b ENDIF END 'saveJPEG': BEGIN fileName = DIALOG_PICKFILE( TITLE='Save to a JPEG file', $ FILTER='*.jpg', /WRITE) IF fileName NE '' THEN BEGIN MK_JPEG, filename=filename, image=*Info.Image ENDIF END 'saveTIFF': BEGIN fileName = DIALOG_PICKFILE( TITLE='Save to a TIFF file', $ FILTER='*.tiff', /WRITE) IF fileName NE '' THEN BEGIN WRITE_TIFF, filename, *Info.Image ENDIF END 'saveScreengif': BEGIN fileName = DIALOG_PICKFILE( TITLE='Save Screen to a GIF file', $ FILTER='*.gif', /WRITE ) IF fileName NE '' THEN BEGIN TVLCT, r, g, b, /get ; so colors aren't expanded to 256 WRITE_GIF, filename, TVRD(), r, g, b ENDIF END 'saveScreenJPEG': BEGIN fileName = DIALOG_PICKFILE( TITLE='Save Screen to a JPEG file', $ FILTER='*.jpg', /WRITE) IF fileName NE '' THEN BEGIN MK_JPEG, filename=filename ENDIF END 'saveScreenTIFF': BEGIN fileName = DIALOG_PICKFILE( TITLE='Save Screen to a TIFF file', $ FILTER='*.tiff', /WRITE) IF fileName NE '' THEN BEGIN WRITE_TIFF, filename, tvrd() ENDIF END 'screenDump': SPAWN,'xwd -name "MDS Custom Plotter" | lpr' 'StopPlay': info.stopFlag = 1 'Write' : begin Write_Results_file, info info.nClicks = 0 end 'XaxisSettings' : xAxisw, GROUP_LEADER=event.top 'X-Section' : img_XSection, event 'YaxisSettings' : yAxisw, GROUP_LEADER=event.top ELSE: BEGIN END ;;;ELSE: print,' *** uvalue not found: ', uvalue ENDCASE ;;;print, ' >>> right before info write, info.frameWanted, stopflag=', info.frameWanted, info.stopflag IF STRUPCASE(UVALUE) NE 'DISMISS' THEN BEGIN widget_control, event.top, set_uvalue = info ;;;, /no_copy ENDIF RETURN END ;--------------------------------------------------------------- PRO clickon7, arg, filename=filename, drawXSize=drawXSize, $ INTERP=Interp, max_colors=max_colors, colorTable=colorTable, $ noLoad=noLoad, maxPlayMinutes=maxPlayMinutes, $ radius=radius, numeric=numeric, startTime=startTime, $ Advance=Advance, $ ;;; medSubtaction=medSubtaction, $ bgFrame=bgFrame, nBG=nBG, $ box=box, path=path, twindow=twindow, $ gamma=gamma, powerSpectrum=powerSpectrum, nSmooth=nSmooth, $ debug=debug, verbose=verbose, GROUP_LEADER=Group_Leader if NOT usingXwindows() THEN RETURN ; filename can be either first argument, or keyword. if n_elements( arg ) gt 0 then filename=arg ; first do (from UNIX): setenv DEBUG_IDL 1, to get debug info printed if nwords( debug ) eq 0 then debug = GETENV('DEBUG_IDL') if debug eq '' then debug = 0 if NOT debug then on_error, 2 IF N_ELEMENTS( Advance ) LE 0 THEN Advance=1 IF N_ELEMENTS( colorTable ) LE 0 THEN colorTable=0 IF N_ELEMENTS( max_colors ) LE 0 THEN max_colors=256 IF N_ELEMENTS( numeric) LE 0 THEN numeric=0 ; type of sort on Advance file (i.e. alphabetic) if n_elements( tWindow ) eq 0 then tWindow = 0.001 ; sec IF N_ELEMENTS( bgFrame ) LE 0 THEN bgFrame=0 ; first frame for background subtraction IF N_ELEMENTS( nBG ) LE 0 THEN nBG=0 IF N_ELEMENTS( box ) LE 0 THEN box=0 IF N_ELEMENTS( maxPlayMinutes ) LE 0 THEN maxPlayMinutes=60. IF N_ELEMENTS( gamma ) LE 0 THEN gamma=1 IF N_ELEMENTS( powerSpectrum ) LE 0 THEN powerSpectrum=0 IF N_ELEMENTS( nSmooth ) LE 0 THEN nSmooth=1 IF N_ELEMENTS( verbose ) LE 0 THEN verbose=0 if keyword_set( noLoad ) then begin n_nonfixed=256 sColor = { black:colorsearch('black'), white:colorsearch('white') } endif else begin sColor = MK_COLOR( table=colorTable, /SILENT, max_colors=max_colors, $ /LOAD, n_nonfixed=n_nonfixed) endelse highColor = n_nonfixed-1 !p.color = sColor.black !p.background = sColor.white IF N_ELEMENTS( Interp ) LE 0 THEN interp = 0 IF N_Elements(bottom) EQ 0 THEN bottom = 0 ; Load an image if necessary. IF nwords(filename) EQ 0 THEN BEGIN ;;; path = '.' ;;; if nwords( path ) eq 0 then path = '/p/camdata/dust' if nwords( path ) eq 0 then path = '/p/nstxusr3/miro' fileOK = 0 while NOT fileOK do begin ;;; path = '/p/camdata/' filename = DIALOG_PICKFILE(title='Select a .cin file: ', $ PATH=path, FILTER='*.cin*', GET_PATH=path ) if filename EQ '' then return if strpos(filename,'.gz') eq strlen(filename)-3 then begin print, ' >>> (Unzipping file -- have patience!)' spawn, 'gunzip '+filename, result, Exit_Status=errors if errors then print,"*** probably don't have privileges to unzip "+filename filename = strmid( filename, 0, strlen(filename)-3 ) endif fdecomp, filename, disk, dir, name, ext if nwords( ext ) eq 0 then begin r=dialog_message('*** no extension -- file chosen must be a .cin file! ***') endif else begin if STRLOWCASE(ext) ne 'cin' AND STRLOWCASE(ext) ne 'cine' $ then r=dialog_message('*** file must have a .cin extention! ***') $ else fileOK = 1 endelse endwhile ENDIF status = 0 while status eq 0 do begin fdecomp, filename, disk, path, name, ext if strupcase( ext ) eq 'CIN' or strupcase( ext ) eq 'CINE' THEN BEGIN shot = strmid( name, 4, 6 ) CINE_TIME, filename, allTimes, frames, firstImage=firstFrame, status=status if not status then begin msg = 'Sorry, file '+filename+' not readable by cine_time' r=DIALOG_MESSAGE( msg ) return endif fr1 = MIN( frames, MAX=fr2) time1 = MIN( allTimes, MAX=time2 ) initial = DOUBLE(time1) if time2 gt 300 then time1=200.D msec1 = strtrim( string( time1*1000., format='(F16.4)'),2 ) msec2 = strtrim( string( time2*1000., format='(F16.4)'),2 ) if n_elements( startTime ) eq 0 then begin prompt = [' Times '+msec1 + ' to '+msec2+' msec', $ ' Correspond to frames '+strtrim(LONG(fr1),2) + ' to ' $ +strtrim(LONG(fr2),2), $ ' ', $ 'Enter a start time in msec:'] startTime = DIALOG_INPUT( prompt=prompt, /double, initial=double) endif if startTime eq '' then return if startTime lt time1*1000. or startTime gt time2*1000. then begin msg = ['Times '+msec1 + ' to '+msec2+' msec in file', $ ' ', $ 'Limiting the entry to this range.'] r=DIALOG_MESSAGE( msg ) startTime = (time1*1000.) >starttime < (time2*1000.) endif startTime=double(startTime) endif ; get the first frame as a background for dimensions, and maybe for subtracting BackGroundImage = CINELOAD( filename, bgFrame, pps, exposure, verbose=verbose, $ debug=debug, /INIT, status=status ) if not status then begin print, ' *** frame '+strtrim( bgFrame, 2) + ' for background subtraction not available' return endif if nBG gt 0 then begin print, 'for 1st background frame:' minmax, BackGroundImage for i=1,nBG-1 do begin BackGroundImage = BackGroundImage + $ CINELOAD( filename, bgFrame+i, pps, exposure, status=status ) endfor BackGroundImage = BackGroundImage/nBG endif else begin dims = SIZE( BackGroundImage, /dim ) nBG = 0 if n_elements( aInfo ) eq 2 then begin BackGroundImage = fltarr( dims[0], dims[1] ) endif else if n_elements( aInfo ) eq 3 then begin BackGroundImage = fltarr( dims[0], dims[1], dims[2] ) endif endelse if n_elements( allTimes ) eq 0 then CINE_TIME, filename, allTimes allTimes = allTimes*1000. frameWanted = NEARESTI( allTimes, startTime ) pBackGround = ptr_new(backGroundImage) image = GET_NEXT_IMAGE( filename, time=startTime, frame=frameWanted, allTimes=allTimes, $ backGround=pBackGround, highColor=highColor, bottom=bottom, $ nBG=nBG, $ actualTime=actualTime, box=box, status=status ) aInfo = SIZE( image, /dim ) trueColor = 0 if n_elements( aInfo ) eq 2 then begin xsizeIN = aInfo[0] ysizeIN = aInfo[1] endif else if n_elements( aInfo ) eq 3 then begin xsizeIN = aInfo[1] ysizeIN = aInfo[2] trueColor = 1 endif else begin Message, 'Input image must be 2D' return endelse deltaT = (allTimes[2]-allTimes[1])/1000. ; NOT IMPLEMENTED YET !!!!!!!!!!!!!! ;;; if keyword_set( medSubtraction ) then begin ;;; nBuffLen = (NINT(tWindow/(deltaT*(Advance+1)))) > 5 ;;; circBuff = lonarr( xsizeIN , ysizeIN, nBuffLen) ;;; iFr = ( frameWanted - nBuffLen ) > 0 ; this buffer precedes the frame wanted (when time going forward) ;;; for i=0,nBuffLen-1 do begin ;;; circBuff(*,*,i) = GET_NEXT_IMAGE( filename, frame=iFr, allTimes=allTimes, $ ;;; backGround=pBackGround, highColor=highColor, bottom=bottom, $ ;;; box=box, status=status ) ;;; endfor ;;; endif else begin circBuff = 0 nBuffLen = 0 ;;; endelse endwhile xsize = xsizeIN ysize = ysizeIN if powerSpectrum then begin window, 17, xsize=xsize, ysize=ysize, title='Power Specturm' endif ; Get the screen size. DEVICE, GET_SCREEN_SIZE = screenSize ; Set up the drawing area size if n_elements( drawXsize ) eq 0 then drawXSize = (screenSize[0]*0.35)>600 ; *2 + 10 drawYSize = drawXSize*ysize/xsize ;+150 drawYsize = drawYSize + !d.y_ch_size*5 if debug then help,drawYsize maxTitleLen = drawxsize/(!d.x_ch_size*1.5) - 17 IF N_Elements(radius) EQ 0 THEN radius = NINT( drawXSize*0.01 )>2 ; radius of pixels around click point if (screenSize[0] LT 800) then begin widID = $ DIALOG_MESSAGE('This application is optimized' + $ ' for at least 800 x 640 resolution.', $ /INforMATION) endif baseID=widget_base( Title='Phantom Camera File Widget', /COLUMN, MBAR=wMBarBase , $ TLB_Size_EVENTS=1, $ ; send event on resize resource='colorbuttons' ) ; create the file pull-down menu wFileMenu = WIDGET_BUTTON( wMBarBase, VALUE='File', /MENU) dum = WIDGET_BUTTON(wFileMenu, VALUE='Get a New .cin file', $ UVALUE='NewFile' ) dum = WIDGET_BUTTON(wFileMenu, VALUE='Start at another time', $ UVALUE='NewTime' ) Printer_List = PPPL_Printers( ) printer = Printer_List(0) printer_pdmenu = MK_PDMENU( Printer_List ) ; make a submenu printer_pdmenu(0).flags = 0 tempID =WIDGET_BUTTON( wFileMenu, VALUE='Printer', /MENU) wPrintSelect = CW_PDMENU( tempID, printer_pdmenu, $ UVALUE='Printer_Select',/RETURN_NAME, /MBAR) bmid5 = WIDGET_BUTTON( wFileMenu, VALUE='Print', $ UVALUE = 'print_plot' ) dum = WIDGET_BUTTON(wFileMenu, VALUE="PRINT Bitmap", $ UVALUE="print_bitmap") dum = WIDGET_BUTTON(wFileMenu, VALUE="Save Image as GIF File...", $ UVALUE="savegif",/separator) dum = WIDGET_BUTTON(wFileMenu, VALUE="Save Image as JPEG File...", $ UVALUE="saveJPEG") dum = WIDGET_BUTTON(wFileMenu, VALUE="Save Image as TIFF File...", $ UVALUE="saveTIFF") dum = WIDGET_BUTTON(wFileMenu, VALUE="Save Screen as GIF File...", $ UVALUE="saveScreengif",/separator) dum = WIDGET_BUTTON(wFileMenu, VALUE="Save Screen as JPEG File...", $ UVALUE="saveScreenJPEG") dum = WIDGET_BUTTON(wFileMenu, VALUE="Save Screen as TIFF File...", $ UVALUE="saveScreenTIFF") IF !Version.OS_Family EQ 'unix' THEN $ bmid5 = WIDGET_BUTTON( wFileMenu, VALUE='Dump Graphics Screen to Printer', $ UVALUE = 'screenDump' ) wQuit = WIDGET_BUTTON( wFileMenu, VALUE='Quit', UVALUE='Dismiss',/separator) editMenu = WIDGET_BUTTON( wMBarBase, VALUE='Edit', /MENU) dum = WIDGET_BUTTON(EditMenu,$ value='Modify Color Table...',$ event_pro='handle_color') ;button to change color table dum = WIDGET_BUTTON( EditMenu, VALUE='Value of Max Color...', $ UVALUE='MaxV') dum = WIDGET_BUTTON( EditMenu, VALUE='Value of Gamma...', $ UVALUE='Gamma' ) dum = WIDGET_BUTTON( EditMenu, VALUE='Value of nSmooth...', $ UVALUE='nSmooth' ) ;;; dum = WIDGET_BUTTON( EditMenu, VALUE='Enter Color Table...', $ ;;; UVALUE='CT') dum = WIDGET_BUTTON( EditMenu, VALUE='X-axis Settings...', $ UVALUE='XaxisSettings',/separator) dum = WIDGET_BUTTON( EditMenu, VALUE='Y-axis Settings...', $ UVALUE='YaxisSettings') dum = WIDGET_BUTTON( editMenu, VALUE='Erase', $ UVALUE = 'CLEAR',/separator ) ;;; dum = WIDGET_BUTTON( editMenu, $ ;;; VALUE='Color Palette Selector', $ ;;; UVALUE = 'Colorpalette' ) specialMenu = WIDGET_BUTTON( wMBarBase, VALUE='Special', /MENU) dum = WIDGET_BUTTON(specialMenu,$ value='Image Proc Monochrome...',$ UVALUE='imageproc') ;button to change color table XSectionWid=widget_button(specialMenu,$ value='X-Section Widget', $ event_pro='img_XSection',/separator) dum = WIDGET_BUTTON( specialMenu, VALUE='Set 1st Frame for BG subtraction...', $ UVALUE='bgFrame',/separator ) dum = WIDGET_BUTTON( specialMenu, VALUE='Set # of frames for BG subtraction...', $ UVALUE='nBG' ) ByteScale = 1 dum = WIDGET_BUTTON( specialMenu, VALUE='Turn off BYTE scaling', $ UVALUE='ByteScale' ) ; create the Help pull-down menu wHelpMenu = WIDGET_BUTTON( wMBarBase, VALUE='Help', /HELP) wHelpButton = WIDGET_BUTTON( wHelpMenu, VALUE='Help', UVALUE='Help_Program') dum = WIDGET_BUTTON( wHelpMenu, VALUE='Break (for Programmer)', UVALUE='Break') rowID = WIDGET_BASE( baseID, /ROW ) boxID = WIDGET_BASE( rowID, /ROW , /frame ) dum = WIDGET_BUTTON( boxID, VALUE='<--Back Up', UVALUE='BackUp' ) dum = WIDGET_BUTTON( boxID, VALUE='Advance-->', UVALUE='AdvanceThis',resource_name='green' ) AdvanceID = CW_FIELD(boxID, /RETURN_EVENTS, TITLE='', /LONG, $ XSIZE=5, VALUE=Advance, UVALUE = 'AdvanceNumber', textID=frameID ) if debug then help, frameID colID = widget_base( boxID, /col) dum = widget_label( colID, value='frame(s) ') dum = widget_label( colID, value='at a time ') boxID = WIDGET_BASE( rowID, /ROW, /frame ) if n_elements( FrameWanted ) eq 0 then FrameWanted = -1L dum = CW_FIELD(boxID, /RETURN_EVENTS, TITLE='Jump to #', /LONG, $ XSIZE=8, VALUE=FrameWanted, UVALUE = 'FrameWanted', textID=frameID ) dum = widget_label( rowID, value=' ') dum = WIDGET_BUTTON( rowID, VALUE='Write Results', UVALUE='Write' ) dum = widget_label( rowID, value=' ') boxID = WIDGET_BASE( rowID, /ROW, /frame ) colID = WIDGET_BASE( boxID, /COL) rowID = WIDGET_BASE( colID, /ROW ) forwardID = WIDGET_BUTTON(rowID, VALUE=' >', UVALUE = 'PlayForward',resource_name='green' ) stopID = WIDGET_BUTTON(rowID, VALUE='||', UVALUE = 'StopPlay',resource_name='red' ) backwardID = WIDGET_BUTTON(rowID, VALUE='< ', UVALUE = 'PlayBackward' ) dum = widget_label( colID, value='VCR', /ALIGN_CENTER) rowID = WIDGET_BASE( baseID, /ROW ) dum = widget_label( rowID, value='Frame Time (msec):') minSlider = allTimes[0] maxSlider = allTimes[n_elements(allTimes)-1] scrollInc = (maxSlider-minSlider)/20. ;;; print, 'minSlider,maxSlider,scrollInc=',minSlider,maxSlider,scrollInc frameTimeID = CW_FSLIDER( rowID, /EDIT, /DRAG, $ MIN=minSlider, $ MAX=maxSlider, $ VALUE=starttime, $ xsize=80*!D.X_CH_SIZE, $ scroll=scrollInc, $ UVALUE="FrameTime", TITLE="" ) if n_elements( actualTime ) gt 0 then frameTime = actualTime else frameTime=-99. title = chompfn(filename, max=maxTitleLen ) if frameWanted ne -1 then title = title + $ ' at '+strtrim( FLOAT(frameTime),2 ) + ' ms' drawID = WIDGET_DRAW( baseID, XSIZE=drawXSize, /ALIGN_CENTER, $ YSIZE=drawYSize, RETAIN=2, UVALUE='DRAWING', $ Event_Pro='DRAW_EVENTS_PRO' ) WIDGET_CONTROL,baseID, /REALIZE if strupcase( ext ) NE 'CIN' AND strupcase( ext ) NE 'CINE' THEN BEGIN widget_control, frameID, set_value="-1" widget_control, frameID, sens=0 ENDIF Widget_Control, drawID, Draw_Button_Events=1 ; Determine the window value of plot window ; WIDGET_CONTROL, drawID, GET_VALUE=drawWindowID WSET, drawWindowID ERASE, color=sColor.black ;;;!p.position=[.1,.1,.98,.99] ;;;print,"interp=", interp ;;;th_image_cont, Image, indgen(s[1]),indgen(s[2]), /nocont,/nobar, /noload, $ ;;; bottom=bottom, Top=highColor-1, $ ;;; title=title, interp=interp, image_window=image_window ;;;, pos=pos erase if gamma ne 1 then begin tvimage, bytscl(gamma_raise(Image,gamma), Top=highColor-1 ), indgen(xsizeIn),indgen(ysizeIn), $ position=[0.0, 0.02, 1.0, 0.95], /KEEP_ASPECT_RATIO, true=trueColor endif else begin tvimage, bytscl(Image, Top=highColor-1 ), indgen(xsizeIn),indgen(ysizeIn), $ position=[0.0, 0.02, 1.0, 0.95], /KEEP_ASPECT_RATIO, true=trueColor endelse image_window = [ !X.window[0], !Y.window[0], !X.window[1], !Y.window[1] ] screen_title, title, logo=0 Window, /Free, /Pixmap, XSize=drawXsize, YSize=drawYsize pixID = !D.Window wset, drawWindowID maxpts = 1000 ; max # for each trajectory if n_elements( frameID ) eq 0 then frameID = 77 ; work around weird bug nFrames = n_elements( allTimes ) ; Save useful parameters in info structure info={ $ advanceID : AdvanceID, $ advance : LONG(Advance), $ allTimes : ptr_new(allTimes), $ BackGroundImage : pBackGround, $ backwardID : backwardID, $ ; ID of backward button.; BaseID : BaseID, $ bgFrame : bgFrame, $ ; frame for start of background subtraction ByteScale : ByteScale, $ gammaID : 0L, $ bottom : bottom, $ box: box, $ circBuff : ptr_new(circBuff), $ clickCircleMax : ptr_new(intarr(maxpts)), $ clickTime : ptr_new(dblarr(maxpts)), $ clickVal : ptr_new(intarr(maxpts)), $ clickX : ptr_new(intarr(maxpts)), $ clickY : ptr_new(intarr(maxpts)), $ colorTable : colorTable, $ debug : debug, $ drawID : drawID, $ drawWindowID : drawWindowID, $ drawXsize : drawXsize, $ drawYsize : drawYsize, $ filename : filename, $ files : ptr_new(strarr(maxpts)), $ forward : 1, $ forwardID : forwardID, $ ; ID of forward button. frameID : frameID, $ FrameTime : double(FrameTime), $ FrameTimeID : FrameTimeID, $ FrameWanted : LONG(FrameWanted), $ gamma : FLOAT(gamma), $ highColor : highColor, $ Image : ptr_new(Image), $ interp : interp, $ lastFile : '', $ maxPlayMinutes : maxPlayMinutes, $ maxpts : maxpts, $ maxTitleLen : maxTitleLen, $ nBG : nBG, $ ; number of frames to use for background subtraction nBuffLen : nBuffLen, $ nClicks : 0L, $ nFrames : LONG(n_elements( allTimes)), $ nSmooth : LONG(nSmooth), $ numeric : numeric, $ outFileName : 'clickon7.txt', $ path : path, $ pixID : pixID, $ powerSpectrum : powerSpectrum, $ printer : ' ', $ radius : radius, $ sColor : sColor, $ startedPlayingSec : systime(1), $ stopflag:0, $ ; A stop animation flag. stopID : stopID, $ ; ID of stop button. title : title, $ trueColor : trueColor, $ xsize : xsize, $ ysize : ysize $ } (*info.files)[0] = filename ; Attach info structure to top level base Widget_control,baseID, Set_uvalue=info plotSomething, info IF debug THEN XMANAGER, CATCH=0 ; want to stop if error detected XMANAGER,'clickon7', baseID, /no_block, GROUP_LEADER=Group_Leader end