pro eit_getobs, obs, grid=grid, graphics=graphics, magnification=magnification ;+ ; Name: eit_getobs ; ; Purpose: interactive selection of EIT obsserving blocks (32x32) ; ; Input Parameters: ; NONE ; ; Output Parameters: ; obs - command blocks selected [** currently 0-1023 from lower left **] ; ; Keyword Parameters: ; magnification - image (size/1024.) - default derived from current window ; ; Calling Sequence: ; eit_getobs, obs [magnification=magnification] ; ; Method: ; read cursor postion from current X-window containing an EIT or ; EIT-aligned image - permit mouse selection of EIT command regions ; "Press LEFT button to SELECT or UNSELECT a region" ; "Press/Drag CENTER button to SELECT or UNSELECT adjacent regions" ; "Press RIGHT button to EXIT" ; ; History: ; 30-jan-1996 (S.L.Freeland) ; ; Restrictions: ; assumes EIT or (EIT co-aligned image) is in current X windows display ;- ;on_error,2 ; -------------------- verify ok to run --------------------------------- if !d.name ne 'X' then message,"X-Windows only program, returning..." if !d.window eq -1 then message,"No active X-window, returning... if n_params() eq 0 then message,/info,"Warning: No return parameter specified" ; ----------------------------------------------------------------------- ; ------------ define magnification (implies box size) if !d.x_size gt 1000 then magnification=1. ; kluge for small displays if not keyword_set(magnification) then magnification=float(!d.y_size)/1024. ff=fix(32 * magnification) ; relative cmd box size ; ----------------------------------------------------------------------- ; --------------- define instructions ------------------------------------ instruct=["Press LEFT button to SELECT or UNSELECT a region", $ "Press/Drag CENTER button to SELECT or UNSELECT adjacent regions", $ "Press RIGHT button to EXIT"] tbeep ; get users attention more,strjustify(instruct,/box) ; and print instruct. ; ------------------------------------------------------------------------- ; --------------- set graphics environmnet -------------------------------- curwin=!d.window ; current X window if keyword_set(grid) then grid,32,32,ff wdef,pixwin,!d.x_size,!d.y_size,/pixmap ; make a PIXMAP image device,copy=[0,0,!d.x_size,!d.y_size,0,0,curwin] ; copy X->Pixmap device,get_graphics=goriginal ; save graphics funct. wset,curwin ; select X window if not keyword_set(graphics) then graphics=12 device, set_graphics=graphics ; NOT source ; ------------------------------------------------------------------------- obsmap=intarr(32,32) ; obs region state map cursor,x,y,/device,/down ; get first response ;---------- All KEY LOOP (click) ---------------------; while !err ne 4 do begin ; until quit button xobs=(x/ff)*ff & yobs=(y/ff)*ff ; current obs coord lx=xobs & ly=yobs ; last set device,copy=$ [xobs, yobs, ff<(!d.x_size -xobs), ff<(!d.y_size-yobs), xobs, yobs,pixwin] obsmap(x/ff,y/ff)= 1-obsmap(x/ff,y/ff) ; toggle select state ; ----------- MIDDLE KEY LOOP (drag) ------------------; while !err eq 2 do begin ; MIDDLE key function xobs=(x/ff)*ff & yobs=(y/ff)*ff ; track obs coord if lx ne xobs or ly ne yobs then begin ; redraw if change device, copy= $ [xobs, yobs, ff<(!d.x_size -xobs), ff<(!d.y_size-yobs), xobs, yobs,pixwin] obsmap(x/ff,y/ff)= 1-obsmap(x/ff,y/ff) ; toggle select state lx=xobs & ly=yobs ; update last endif cursor,x,y,/device,/nowait ; check again... endwhile ; MIDDLE released ; -----------------------------------------------------; cursor,x,y,/device,/down ; next selection endwhile ; -----------------------------------------------------; device,set_graphics=goriginal ; restore graphics obs=where(obsmap) ; return selected obs wdelete,pixwin ; free PIXMAP memory return end
Last revised: - Wed May 9 21:45:18 2007- F. Auchère