function clickOnImage, image, win=win, title=title ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden ;--I.1-- Test Input Image ---------------------------------------------------------------- if not keyword_set(image) then begin message, /IOERROR, 'Syntax: xy = clickOnFrame( image [, xy=, /peak2D, subframe=, win=, /auto])' return, -1 endif dims = size(image) if dims(dims(0)+1) eq 7 then begin image = readfits(image,/silent) dims = size(image) endif ;--I.2-- Widget Window Size, Title & Position -------------------------------------------- ;--I.2.1-- Default Size and Title if not keyword_set(title) then title='Click on choosen location' if keyword_set(win) then winSizeY = win else winSizeY = 768 winSizeX = winSizeY * 1.*dims[1]/dims[2] ; if not keyword_set(win) then win = 768 ;--I.2.2-- Histogram Window wHxy = win*[0.6, 0.5] wHoff= win*[1.05, 0.1] ;--I.2.3-- Parameter Window wPxy = win*[0.6, 0.5] wPoff= win*[1.05, 0.5] ;--I.3-- Image Color Scale --------------------------------------------------------------- if not keyword_set(scale) then scale='linear' if not keyword_set(color) then color='gray' if not keyword_set(range) then range='minmax' borderPIX = 2 histo = histogram( image, loc=hArr, nbin=256 ) ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Define Widget Windows -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Main Window: Image -------------------------------------------------------------- base = widget_base( title=title ) drawIM = widget_draw(base, xsize=winSizeX, ysize=winSizeY, /motion_events, /button_events) ;--II.2-- Histogram Window ---------------------------------------------------------------- baseH = widget_base(group_leader=base, xoff=wHoff(0), yoff=wHoff(1), title='Value distribution') drawH = widget_draw(baseH, xsize=wHxy(0), ysize=wHxy(1)) ;--II.3-- Color, Scale, Range Window ------------------------------------------------------ baseP = widget_base(group_leader=base, xoff=wPoff(0), yoff=wPoff(1), title='Scale parameters') ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Realize Widgets and Set Main Structures -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--III.1-- Realization WIDGET_CONTROL, base, /REALIZE WIDGET_CONTROL, baseH, /REALIZE WIDGET_CONTROL, baseP, /REALIZE ;--III.2-- WIDGET_CONTROL, drawIM, GET_VALUE=idDrawImage WIDGET_CONTROL, drawH, GET_VALUE=idDrawHisto ciPlotHistogram, idDrawHisto, hArr, histo, 1,2 imagePtr=PTR_NEW(image, /NO_COPY) imgMed = median(*imagePtr) imgStd = stddev(*imagePtr,/NAN) fsShowImage, idDrawImage, *imagePtr, bottom=(imgMed-imgStd), top=(imgMed+imgStd) ;--III.1-- Define Pop-Up Window ------------------------------------------------------------ ; cgDisplay, xsize=xsize, ysize=xsize, title='Click on choosen location' ; ; ;--III.2-- Brightness Cuts ----------------------------------------------------------------- ; cutMin = 0 ; cutMax = max(image,/NAN) ; ; ;--III.3-- Display image ------------------------------------------------------------------- ; cgImage, congrid(image, xsize, ysize), minvalue=cutMin, maxvalue=cutMax*0.15 ; ; ;--III.1-- Define Pop-Up Window ------------------------------------------------------------ ; cursor, xObj, yObj, 3, /device ; xObj *= ( float(dims(1)) / xsize ) ; yObj *= ( float(dims(2)) / ysize ) ; cgCleanup ; stop return, [xObj, yObj] end