pro big_cursor, ix, iy, ix0, iy0 device, get_graphics_function=g_fnc ;save graphics function device, set_graphics_function=10 ;Use XOR writing mode if (ix0 GT -1) then begin ;Erase old mark plots, [0, ix0-3], [iy0,iy0],/dev plots, [ix0-1, ix0+1], [iy0,iy0],/dev plots, [ix0+3, !d.x_size-1], [iy0,iy0],/dev plots,[ix0,ix0],[0, iy0-3],/dev plots, [ix0, ix0], [iy0-1,iy0+1],/dev plots,[ix0,ix0],[iy0+3, !d.y_size-1],/dev endif plots, [0, ix-3], [iy,iy],/dev plots, [ix-1, ix+1], [iy,iy],/dev plots, [ix+3, !d.x_size-1], [iy,iy],/dev plots,[ix,ix],[0, iy-3],/dev plots, [ix, ix], [iy-1,iy+1],/dev plots,[ix,ix],[iy+3, !d.y_size-1],/dev device, set_graphics_function=g_fnc end pro pp,print=print common sdwcom,c_image,c_extver,c_extnam,c_zoom,c_size,c_printer,doexit,pressed common sdwcom1, im, him, ptr, drawfield_id, maxdim, mask, maskim, newimage common sdwcom2, ixdim, iydim, plotmin, plotmax, goodmaskval, fix0, fiy0 common sdwcom3, logscale, oldplotmin, oldplotmax, immin, immax, boxx0, boxy0 common sdwcom4, tempxbox, tempybox, g_fnc, wcstype, aaa, newlog,iminp,imaxp common sdwcom5, intmask common sdwsave1, maskfile, maskext, maskeori, maskgoodval if (not keyword_set(print)) then begin print = 'no' endif fix0 = -1 fiy0 = -1 if (logscale eq 1) then begin if newlog eq 1 then begin newlog = 0 c = imscale(alog10(im-min(im)+1.0),10.0) plotmin = float(c(0)) plotmax = float(c(1)) WIDGET_CONTROL, iminp, Set_VALUE = plotmin WIDGET_CONTROL, imaxp, Set_VALUE = plotmax endif if (c_zoom ne 1) then begin tv,congrid(bytscl(alog10(float(im-min(im)+1.0)), $ top=!d.n_colors-1, $ min=plotmin,max=plotmax), ixdim*c_zoom,iydim*c_zoom) endif else begin tv,bytscl(alog10(float(im-min(im)+1.0)),top=!d.n_colors-1, $ min=plotmin,max=plotmax) endelse endif else begin tt = size(im) if tt(3) eq 2 and intmask ne -1 then begin tempim = ptr_new(im and intmask) endif else begin tempim = ptr_new(im) endelse if (c_zoom ne 1) then begin tv,congrid(bytscl(*tempim,top=!d.n_colors-1,min=plotmin,max=plotmax), $ ixdim*c_zoom,iydim*c_zoom) endif else begin tv,bytscl(*tempim,top=!d.n_colors-1,min=plotmin,max=plotmax) endelse ptr_free,tempim endelse newimage = 0 end PRO sdw_widgetEventHdlr, event common sdwcom,c_image,c_extver,c_extnam,c_zoom,c_size,c_printer,doexit,pressed common sdwcom1, im, him, ptr, drawfield_id, maxdim, mask, maskim, newimage common sdwcom2, ixdim, iydim, plotmin, plotmax, goodmaskval, fix0, fiy0 common sdwcom3, logscale, oldplotmin, oldplotmax, immin, immax, boxx0, boxy0 common sdwcom4, tempxbox, tempybox, g_fnc, wcstype, aaa, newlog,iminp,imaxp common sdwcom5, intmask common sdwsave1, maskfile, maskext, maskeori, maskgoodval common wcscom,textra,textdec,wcson ; Get the state structure stored in the user value of the window WIDGET_CONTROL, GET_UVALUE = state, event.top, /NO_COPY CASE event.id OF state.wExitButton: BEGIN ; Exit the sdw window. device, cursor_standard=30 WIDGET_CONTROL, event.top, /DESTROY doexit = 1 return end state.iminpField: begin WIDGET_CONTROL, state.iminpField, GET_VALUE = plotmin pp end state.imaxpField: begin WIDGET_CONTROL, state.imaxpField, GET_VALUE = plotmax pp end ; state.iextverField: begin ; WIDGET_CONTROL, state.iextverField, GET_VALUE = c_extver ; doexit = 0 ; device, cursor_standard=30 ; WIDGET_CONTROL, event.top, /DESTROY ; newimage = 1 ; return ; end ; state.iextnamField: begin ; WIDGET_CONTROL, state.iextnamField, GET_VALUE = temp ; c_extnam = temp(0) ; doexit = 0 ; device, cursor_standard=30 ; WIDGET_CONTROL, event.top, /DESTROY ; newimage = 1 ; return ; end state.izoomField: begin WIDGET_CONTROL, state.izoomField, GET_VALUE = c_zoom doexit = 0 device, cursor_standard=30 WIDGET_CONTROL, event.top, /DESTROY return end state.browseButton: BEGIN ; tempfile = pickfile(/read,filter='/export/home/ext_disk/iss/images/*') tempfile = pickfile(/read,filter='*.IMG') test = findfile (tempfile, COUNT = fcount) if (strlen(tempfile) gt 0 and fcount ne 0) then begin c_image = tempfile c_extver = -1 c_extnam = 'xyzzx' doexit = 0 device, cursor_standard=30 WIDGET_CONTROL, event.top, /DESTROY newimage = 1 return endif else begin if (fcount eq 0) then begin nosuchfile,tempfile endif endelse end ; state.maskButton: BEGIN ; WIDGET_CONTROL, state.maskButton, get_value = barray ; if barray(0) eq 1 then begin ; ; Bad pixel masking has been turned on, try to find a mask. ; mask = 1 ; maskim = sdw_getmaskim(c_image,c_extver) ; b = size(maskim) ; if (b(0) eq 0) then begin ; sdw_nomask,c_image ; mask=0 ; WIDGET_CONTROL, state.maskButton, set_value = [mask] ; endif else begin ; badindex = where(maskim ne goodmaskval, numbad) ; goodindex = where(maskim eq goodmaskval) ; if (numbad gt 0) then begin ; md = median(im(goodindex)) ; im(badindex) = md ; endif ; pp ; endelse ; endif else begin ; ; Bad pixel masking has been turned off, redraw. ; mask = 0 ; doexit = 0 ; device, cursor_standard=30 ; WIDGET_CONTROL, event.top, /DESTROY ; return ; endelse ; end state.logButton: begin WIDGET_CONTROL, state.logButton, get_value = barray if barray(0) eq 0 then begin logscale = 0 c = imscale(im,10.0) plotmin = c[0] plotmax = c[1] doexit = 0 device, cursor_standard=30 WIDGET_CONTROL, event.top, /DESTROY return endif else begin logscale = 1 newlog = 1 oldplotmin = plotmin oldplotmax = plotmax doexit = 0 device, cursor_standard=30 WIDGET_CONTROL, event.top, /DESTROY return endelse end state.tiffbutton: BEGIN widget_control,/hourglass if (logscale eq 1) then begin if newlog eq 1 then begin newlog = 0 c = imscale(alog10(im-min(im)+1.0),10.0) plotmin = float(c(0)) plotmax = float(c(1)) WIDGET_CONTROL, iminp, Set_VALUE = plotmin WIDGET_CONTROL, imaxp, Set_VALUE = plotmax endif if (c_zoom ne 1) then begin write_tiff,'sdw.tiff',congrid(bytscl(alog10(float(im-min(im)+1.0)), $ top=!d.n_colors-1, $ min=plotmin,max=plotmax), ixdim*c_zoom,iydim*c_zoom) endif else begin write_tiff,'sdw.tiff',bytscl(alog10(float(im-min(im)+1.0)), $ top=!d.n_colors-1, min=plotmin,max=plotmax) endelse endif else begin if (c_zoom ne 1) then begin write_tiff,'sdw.tiff',congrid(bytscl(im,top=!d.n_colors-1, $ min=plotmin,max=plotmax), ixdim*c_zoom,iydim*c_zoom) endif else begin write_tiff,'sdw.tiff',bytscl(im,top=!d.n_colors-1,min=plotmin, $ max=plotmax) endelse endelse end state.printbutton: BEGIN widget_control,/hourglass set_plot,'ps',/copy if ixdim gt iydim then begin sizzx = 7.0 sizzy = (float(iydim)/float(ixdim)) * 7.0 endif else begin sizzy = 7.0 sizzx = (float(ixdim)/float(iydim)) * 7.0 endelse device,/inches,yoffset=2.0,xsize=sizzx,ysize=sizzy, $ file='sdw.ps',/color,bits=8 pp,print='yes' zstring = ' Z1 = '+string(plotmin)+' Z2 = '+string(plotmax) xyouts,.01,1.05,c_image+zstring,/normal,color=0 device,/close set_plot,'x' spawn,'lp -d'+ptr+' sdw.ps' end state.drawfield: begin wset, drawfield_id x = event.x y = event.y if (pressed eq 1) then begin ; Erase the old one. device, get_graphics_function=g_fnc ;save graphics function device, set_graphics_function=10 ;Use XOR writing mode if tempxbox ne -1 then begin plots, boxx0, boxy0, /device plots, boxx0, tempybox, /device, /continue plots, tempxbox, tempybox, /device, /continue plots, tempxbox, boxy0, /device, /continue plots, boxx0, boxy0, /device, /continue endif ; Plot the new one. plots, boxx0, boxy0, /device plots, boxx0, y, /device, /continue plots, x, y, /device, /continue plots, x, boxy0, /device, /continue plots, boxx0, boxy0, /device, /continue device, set_graphics_function=g_fnc ; Now, remember where we are tempxbox = x tempybox = y endif else begin big_cursor, x, y, fix0, fiy0 fix0 = x fiy0 = y xp = fix((event.x)/c_zoom) + 1 yp = fix((event.y)/c_zoom) + 1 xstr = string(format='(I4)',xp-1) ystr = string(format='(I4)',yp-1) z = im(xp-1,yp-1) zstr = string(format='(E13.3)',z) widget_control,state.xLabel,set_value=xstr widget_control,state.yLabel,set_value=ystr widget_control,state.zLabel,set_value=zstr if (wcson eq 1 and c_image ne 'default') then begin xyad, him, xp, yp, xra, xdec sdw_conra,xra/15.0,rastr sdw_condec,xdec,decstr widget_control,textra,set_value=rastr widget_control,textdec,set_value=decstr endif endelse ; if(event.press eq 2) then begin ; widget_control,/hourglass ; xp = xp - 1 ; yp = yp - 1 ; thexmin = max([xp-2,0]) ; thexmax = min([xp+2,ixdim-1]) ; theymin = max([yp-2,0]) ; theymax = min([yp+2,iydim-1]) ; divby = ((thexmax-thexmin+1) * (theymax-theymin+1)) - 1 ; total1 =total(double(im(thexmin:max([xp-1,0]),theymin:theymax))) ; total2 =total(double(im(min([xp+1,ixdim-1]):thexmax,theymin:theymax))) ; total3 =total(double(im(xp,theymin:max([yp-1,0])))) ; total4 =total(double(im(xp,min([yp+1,iydim-1]):theymax))) ; im(xp,yp) = (total1+total2+total3+total4) / divby ; pp ; endif if(event.press eq 1) then begin ; Remember this corner. boxx0 = x boxy0 = y tempxbox = x tempybox = y pressed = 1 ; Erase the big cursor. device, get_graphics_function=g_fnc ;save graphics function device, set_graphics_function=10 ;Use XOR writing mode plots, [0, fix0-3], [fiy0,fiy0],/dev plots, [fix0-1, fix0+1], [fiy0,fiy0],/dev plots, [fix0+3, !d.x_size-1], [fiy0,fiy0],/dev plots,[fix0,fix0],[0, fiy0-3],/dev plots, [fix0, fix0], [fiy0-1,fiy0+1],/dev plots,[fix0,fix0],[fiy0+3, !d.y_size-1],/dev device, set_graphics_function=g_fnc endif if(event.release eq 1) then begin pressed = 0 pp ; Draw the big cursor. device, get_graphics_function=g_fnc ;save graphics function device, set_graphics_function=10 ;Use XOR writing mode plots, [0, x-3], [y,y],/dev plots, [x-1, x+1], [y,y],/dev plots, [x+3, !d.x_size-1], [y,y],/dev plots,[x,x],[0, y-3],/dev plots, [x, x], [y-1,y+1],/dev plots,[x,x],[y+3, !d.y_size-1],/dev device, set_graphics_function=g_fnc fix0 = x fiy0 = y xp = fix((event.x)/c_zoom) yp = fix((event.y)/c_zoom) xp2 = fix((boxx0)/c_zoom) yp2 = fix((boxy0)/c_zoom) if xp gt xp2 then begin temp = xp2 xp2 = xp xp = temp endif if yp gt yp2 then begin temp = yp2 yp2 = yp yp = temp endif sdw_spreadsheet,im[xp:xp2,yp:yp2],him,xp,xp2,yp,yp2,group=event.top tempxbox = -1 tempybox = -1 endif end state.wlctButton: begin xloadct,group=event.top end ; state.savebutton: begin ; sdw_saveim,im,him ; end state.wHeadButton: begin sdw_showhead,him,event.top end ; state.wWCSButton: begin ; sdw_wcs,group=event.top ; wcson = 1 ; end ; state.intmaskButton: begin ; sdw_intmask,group=event.top ; end ; state.wSorigButton: begin ; spawnstring = string (format='("rm ",a80)',c_image) ; spawn, spawnstring ; ua_fits_write,c_image,im,him ; end ; state.propButton: begin ; sdw_parameters ; end else: test = WIDGET_MESSAGE("An event occurred for a non-existent widget") endcase ; Reset the windows user value to the updated state structure WIDGET_CONTROL, SET_UVALUE = state, event.top, /NO_COPY end pro sdw_widget,GROUP=group common sdwcom,c_image,c_extver,c_extnam,c_zoom,c_size,c_printer,doexit,pressed common sdwcom1, im, him, ptr, drawfield_id, maxdim, mask, maskim, newimage common sdwcom2, ixdim, iydim, plotmin, plotmax, goodmaskval, fix0, fiy0 common sdwcom3, logscale, oldplotmin, oldplotmax, immin, immax, boxx0, boxy0 common sdwcom4, tempxbox, tempybox, g_fnc, wcstype, aaa, newlog,iminp,imaxp common sdwcom5, intmask common sdwsave1, maskfile, maskext, maskeori, maskgoodval common wcscom,textra,textdec,wcson @VERSION.sdw ; Read image file. if c_image ne 'default' then begin if c_extver ne -1 then begin if c_extnam ne 'xyzzx' then begin ua_fits_read, c_image, im, him, extver = c_extver, extname = c_extnam endif else begin ua_fits_read, c_image, im, him, extver = c_extver endelse endif else begin if c_extnam ne 'xyzzx' then begin ua_fits_read, c_image, im, him, extname = c_extnam endif else begin im = read_vicar(c_image,temp) im = reverse(im);im = reverse(im,0);Changed to match IDL for win him = str_sep(temp, ' ') him = him(uniq(him)) ; ua_fits_read, c_image, im, him endelse endelse ; Hack double precision arrays down to single precision. temp = size(im) if temp(3) eq 5 then im = float(im) endif else begin im = fltarr(19,9) im(*,7) = [0,0,1,1,1,0,0,1,1,1,1,0,0,1,0,0,0,1,0] im(*,6) = [0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0] im(*,5) = [0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0] im(*,4) = [0,0,1,1,1,0,0,1,0,0,0,1,0,1,0,1,0,1,0] im(*,3) = [0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,1,0,1,0] im(*,2) = [0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,0,1,1,0] im(*,1) = [0,0,1,1,1,0,0,1,1,1,1,0,0,1,0,0,0,1,0] im = congrid(im,512,256) anim = smooth(im,20) newim = fltarr(512,512) newim(*,0:127) = anim(*,0:127) newim(*,383:511) = anim(*,127:255) im = newim him = ' ' endelse if (mask eq 1) then begin maskim = sdw_getmaskim(c_image,c_extver) b = size(maskim) if (b(0) eq 0) then begin sdw_nomask,c_image endif else begin badindex = where(maskim ne goodmaskval, numbad) goodindex = where(maskim eq goodmaskval) if (numbad gt 0) then begin md = median(im(goodindex)) im(badindex) = md endif endelse endif pressed = 0 tempxbox = -1 tempybox = -1 boxx0 = 0 boxy0 = 0 wcson = 0 intmask = -1 ptr = c_printer zz = size(im) ixdim = zz(1) iydim = zz(2) if (ixdim ne iydim) then begin maxdim = max([ixdim,iydim]) endif else begin maxdim = ixdim endelse if (ixdim le 2 and iydim le 2) then begin print,'Image size is <= 2! Substituting 2 by 2 array of 0.0!' im = fltarr(2,2) ixdim = 2 iydim = 2 maxdim = 2 endif ; Display window size is c_size. ; Scrollable image window is (ixdim*c_zoom, iydim*c_zoom) ; First check to see how big the image is going to be. ; If it is too big, reset the zoom factor. if maxdim*c_zoom gt 5000 then c_zoom = 5000.0/maxdim old_size = c_size xx = maxdim*c_zoom atest = min([c_size,xx]) c_size = atest wShowemWindow = $ WIDGET_BASE(TITLE = "Super Display Widget, version "+UAVersion,/row) funkyBase1 = widget_base(wShowemWindow, title = 'funky1', /column) wshowembase1 = WIDGET_BASE(funkyBase1, TITLE = "Base 1", /COLUMN) wdfileLabel = widget_label(wshowembase1, value=c_image, /ALIGN_CENTER, $ /dynamic_resize) if (maxdim*c_zoom gt c_size) then begin drawfield = widget_draw(wshowembase1, retain=2, uvalue='drawfield', $ frame=1, xsize=ixdim*c_zoom, ysize=iydim*c_zoom, button_events=1, $ /motion_events, /scroll, x_scroll_size = c_size, y_scroll_size = c_size) endif else begin drawfield = widget_draw(wshowembase1, retain=2, uvalue='drawfield', $ frame=1, xsize=ixdim*c_zoom, ysize=iydim*c_zoom, button_events=1, $ /motion_events) endelse c_size = old_size ; Second main column. if (newimage eq 1 and logscale eq 0) then begin immin = float(min(im)) immax = float(max(im)) temp = imscale(im,10.0) plotmin = float(temp(0)) plotmax = float(temp(1)) endif funkyBase2 = WIDGET_BASE(wShowemWindow, TITLE = "Base 2", /COLUMN) tmpstr = string(format='("image min,max: ",E13.3,", ",E13.3)',immin,immax) minmaxlab = widget_label(funkybase2,value=tmpstr) iminpField = cw_field(funkyBase2,value=plotmin, $ title='Z1:', $ uvalue='minplot', xsize=15, /RETURN_EVENTS, /FLOATING) iminp = iminpField imaxpField = cw_field(funkyBase2,value=plotmax, $ title='Z2:', $ uvalue='maxplot', xsize=15, /RETURN_EVENTS, /FLOATING) imaxp = imaxpField ; if c_extver eq -1 then begin ; iextverField = cw_field(funkyBase2,value=1, $ ; title='extver: ', $ ; uvalue='extver', xsize=5, /RETURN_EVENTS, /INTEGER) ; endif else begin ; iextverField = cw_field(funkyBase2,value=c_extver, $ ; title='extver: ', $ ; uvalue='extver', xsize=5, /RETURN_EVENTS, /INTEGER) ; endelse ; if c_extnam eq 'xyzzx' then begin ; iextnamField = cw_field(funkyBase2,value='', $ ; title='extname: ', $ ; uvalue='extnam', xsize=10, /RETURN_EVENTS) ; endif else begin ; iextnamField = cw_field(funkyBase2,value=c_extnam, $ ; title='extname: ', $ ; uvalue='extnam', xsize=10, /RETURN_EVENTS) ; endelse izoomField = cw_field(funkyBase2,value=c_zoom, $ title='zoom: ', $ uvalue='zoom', xsize=10, /RETURN_EVENTS, /FLOATING) browseButton = widget_button(funkybase2,uvalue='browse', $ value='Browse for a file') yowbase = widget_base(funkyBase2, TITLE = "Yow Base", /row) ; maskButton = cw_bgroup(yowbase,['Mask bad pixels'], row = 1, $ ; set_value = [mask], /nonexclusive) logButton = cw_bgroup(yowbase,['Log Scale'], row = 1, $ set_value = [logscale], /nonexclusive) xyzbase = widget_base(funkybase2, TITLE = "xyzbase", /ROW) xxlabel = widget_label(xyzbase,value='X:') xLabel = widget_text(xyzbase, xsize = 4, value='0',/ALIGN_CENTER) yylabel = widget_label(xyzbase,value='Y:') yLabel = widget_text(xyzbase, xsize = 4, value='0',/ALIGN_CENTER) zzlabel = widget_label(xyzbase,value='Val:') zLabel = widget_text(xyzbase, xsize = 15, value='0.0',/ALIGN_CENTER) wshowembase2 = WIDGET_BASE(funkyBase2, TITLE = "Base 2", /ROW) ; propButton = widget_button(wshowembase2,uvalue='prop', $ ; value='Parameters') wlctButton = widget_button(wshowembase2,uvalue='lct', $ value='Colors') printbutton = widget_button(wshowembase2,uvalue='print', $ value='Print', /ALIGN_CENTER) tiffbutton = widget_button(wshowembase2,uvalue='tiff', $ value='Tiff', /ALIGN_CENTER) ; savebutton = widget_button(wshowembase2,uvalue='save', $ ; value='S', /ALIGN_CENTER) ; extsbutton = widget_button(wshowembase2,uvalue='exts', $ ; value='Exts', /ALIGN_CENTER, $ ; Event_Pro='sdw_exts') wshowembase3 = WIDGET_BASE(funkyBase2, TITLE = "Base 3", /ROW) ; wSorigButton = widget_button(wshowembase3,uvalue='sorig', value='SaveOrig') wHeadButton = widget_button(wshowembase3,uvalue='head', value='ViewHead') ; wWCSButton = widget_button(wshowembase3,uvalue='wcs', value='WCS') ; intmaskButton = widget_button(wshowembase3,uvalue='intmask', value='intmask') wExitButton = widget_button(wshowembase3,uvalue='exit', value='Exit') state = { $ wShowemWindow : wShowemWindow, $ wshowembase1 : wshowembase1, $ wdfilelabel : wdfileLabel, $ drawfield : drawfield, $ iminpField : iminpField, $ imaxpField : imaxpField, $ izoomField : izoomField, $ ; iextverField : iextverField, $ ; iextnamField : iextnamField, $ printbutton : printbutton, $ tiffbutton : tiffbutton, $ browseButton : browseButton, $ xLabel : xLabel, $ yLabel : yLabel, $ zLabel : zLabel, $ ; maskButton : maskButton, $ logButton : logButton, $ ; propButton : propButton, $ wlctButton : wlctButton, $ ; savebutton : savebutton, $ ; wSorigButton : wSorigButton, $ wHeadButton : wHeadButton, $ ; wWCSButton : wWCSButton, $ ; intmaskButton : intmaskButton, $ minmaxlab : minmaxlab, $ wExitButton : wExitButton $ } ; Make the window visible. WIDGET_CONTROL, wShowemWindow, /REALIZE WIDGET_CONTROL, drawfield, GET_VALUE=drawfield_id wset, drawfield_id image = intarr(16) ; all zero for all blank device, cursor_image=image ;device, cursor_standard=30 if (c_image eq 'default') then begin if c_zoom eq 1 then begin pp for i = 1, 128 do begin j = 383-i device,copy=[0,i-1,171,128,0,i,drawfield_id] device,copy=[0,j,171,128,0,j-1,drawfield_id] endfor for i = 1, 128 do begin j = 383-i device,copy=[171,i-1,171,128,171,i,drawfield_id] device,copy=[171,j,171,128,171,j-1,drawfield_id] endfor for i = 1, 128 do begin j = 383-i device,copy=[342,i-1,170,128,342,i,drawfield_id] device,copy=[342,j,170,128,342,j-1,drawfield_id] endfor endif else begin pp endelse endif else begin pp endelse ; Save the state structure in the window's user value. WIDGET_CONTROL, wShowemWindow, SET_UVALUE=state ; Register this widget application with the widget manager. Xmanager, "sdw_widget", wShowemWindow, GROUP_LEADER=group, $ EVENT_HANDLER="sdw_widgetEventHdlr" end