;fitsview.pro is a very basic GUI that will display a fits image and allow ;you to change the transfer function (scaling of the image). This is ;so basic because we will adapt this later to display our spectral ;data from the Greenbank telescope. pro farspec, event ;Get state information widget_control, event.top, get_uvalue=infoptr info=*infoptr xn=float(event.x)/float(info.xsize) yn=float(event.y)/float(info.ysize) xn=(xn > 0) < 1 yn=(yn > 0) < 1 xi=fix(xn*info.xpix) yi=fix(yn*info.ypix) if (event.press gt 1) then begin widget_control, event.id,draw_motion_events=1 info.pen=1 endif if (event.release gt 0) then begin widget_control,event.id,draw_motion_events=0 info.pen=0 endif if (info.pen eq 1) then begin wset, info.winid1 ;device, copy=[0,0,xsize=info.xsize*3/4,ysize=info.ysize*3/4,0,0,info.pixwin] ;Re-display the next image low=info.minpix high=info.maxpix q=info.image q=congrid(q,info.xsize*3/4,info.ysize*3/4, /interp) tv, bytscl(q,min=(xn*high-yn*high+low),max=(xn*high+yn*high+low)),info.xsize/8,info.ysize/8 ;plots,[info.xsize/8,info.xsize*5/8],[info.ysize/8,info.ysize*5/8] ;plot,[0],/nodata,xrange=[-1,1],yrange=[-1,1] endif *infoptr=info end pro fitsview, image ;Read in the fits file and header. f=readfits(image,h) ;Create the base widget and name it. base=widget_base(column=1, title='FITS View', $ tlb_frame_attr=1,/tlb_size_events) imagebase=widget_base(base, column=1) ;Get the number of pixels in each direction xsize=fxpar(h,'NAXIS1') ysize=fxpar(h,'NAXIS2') ;Open a window that has the right aspect ratio for the fits image. device, get_screen_size=screen_size draw_xsize=(0.7*screen_size[1]) draw_ysize=((0.7*screen_size[1]*ysize)/xsize) ;Create a draw widget where we can display the image. We also tell it to ;use the program 'farspec' (shown above) when it detects events inside the draw widget. draw1=widget_draw(imagebase, xsize=draw_xsize, $ ysize=draw_ysize,event_pro='farspec',/button_events,/motion_events) widget_control, base, /realize widget_control, base, tlb_get_size=base_size widget_control, draw1, get_value=winid1 ;Tell IDL that we want our draw widget to be the active window where everything will be ;displayed. wset, winid1 ;Get the maximum and minimum pixel in the image for the initial display. maxpix=max(f) minpix=min(f) ;Resize the image to fit the inner 3/4 of the draw widget. q=congrid(f,draw_xsize*3/4,draw_ysize*3/4) ;Display the image with the scale set by the max and min pixels. We also are telling 'tv' to put ;the lower left-hand corner of the image 1/8th of the way up and over (centering it). tv, bytscl(f,min=minpix,max=maxpix),draw_xsize/8,draw_ysize/8 ;Here we are plotting basic axis, not related to the coordinates of the image. plot,[0],/nodata,xrange=[-1,1],yrange=[-1,1],pos=[0.12,0.12,0.88,0.88] ;Here we are creating a structure that will hold all the information about the current state of ;the GUI. We turn this into a pointer variable that we then store as the user value of the top ;level base widget, just so the procedure 'farspec' get get to it and modify it as we interact ;with the draw widget. info={winid1:winid1,base_size:base_size,xsize:draw_xsize,xpix:xsize,$ ysize:draw_ysize,ypix:ysize,image:q,arr:f,pen:0,minpix:minpix,maxpix:maxpix} infoptr=ptr_new(info) widget_control, base, set_uvalue=infoptr ;Tell the IDL widget manager to start tracking events. xmanager, 'fitsview', base, /no_block end