Viewing contents of file '../idllib/uit/pro/arcbar.pro'
Pro arcbar, hdr, arcmins, LABEL = label, SIZE = size, THICK = thick, $
COLOR = color, POSITION = position
;+
; NAME:
; ARCBAR
; PURPOSE:
; Create and display a bar of a specified input size in arcminutes
;
; CALLING SEQUENCE:
; arcbar, hdr, arcmins,[ LABEL= , SIZE =, THICK =, POSITION = ]
;
; INPUTS:
; hdr - image FITS header, string array
; arcmins - length in arcminutes of bar, scalar
;
; OPTIONAL KEYWORD INPUTS:
; LABEL - string giving user defined label for bar. Default label is size
; of bar in arcminutes
; SIZE - size of label, default = 1.0
; THICK - Character thickness of the annotation, default = !P.THICK
; POS - 2 element vector giving the (X,Y) position in device units at
; which to begin the scale bar. If not supplied, then the user
; will be prompted to place the cursor at the desired position
;
; EXAMPLE:
; Place a 3' arc minute scale bar, at position 300,200 of the current
; image display, (which is associated with a FITS header, HDR)
;
; IDL> arcbar, HDR, 3, pos = [300,200]
;
; REVISON HISTORY:
; written by L. Taylor (STX) from ARCBOX (Boothman)
; modified for Version 2 IDL, B. Pfarr, STX, 4/91
; Updated to use ASTROMETRY structures J.Offenberg, HSTX, 31 Dec 92
; New ASTROMETRY structures W.Landsman, HSTX, Jan 94
;-
; The following code is from ARCBOX
;
On_error,2 ;Return to caller
common tv,chan,zoom,xroam,yroam
if N_params() LT 1 then begin
print,"Syntax - ARCBAR, hdr,[ arcmins, LABEL=, SIZE=, THICK =, POS = ]
return
endif
;
extast, hdr, bastr, noparams ;extract astrom params in deg.
;
if N_params() LT 2 then arcmins=1 ;default size = 1 arcmin
;
if not keyword_set( SIZE ) then size = 1.0
if not keyword_set( THICK ) then thick = !P.THICK
if not keyword_set( COLOR ) then color = !P.COLOR
a = bastr.crval(0)
d = bastr.crval(1)
proj = strmid(bastr.ctype(0),5,3)
if proj EQ 'UIT' then uit_ad2xy,a,d,bastr,x1,y1 else $
ad2xy,a,d,bastr,x1,y1
a = bastr.crval(0) ;compute x,y of crval + 1 arcmin
d = bastr.crval(1) + (1/60.)
if proj EQ 'UIT' then uit_ad2xy,a,d,bastr,x,y else $
ad2xy,a,d,bastr,x,y
dmin = sqrt( (abs(x-x1))^2 + (abs(y-y1))^2 ) ;det. size in pixels of 1 arcmin
dmini = nint(dmin)
newval:
dmini2 = nint( dmin * arcmins ) ; size of bar
;
; the following code is not from ARCBOX
;
if not keyword_set( POSITION) then begin
chan,chan
tvcursor,1
print,'Position the cursor where you want the bar to begin'
print,'Hit right mouse button when ready'
cursor,xi,yi,1,/device
endif else begin
xi = position(0) & yi = position(1)
endelse
xf = xi + dmini2
dmini3 = dmini2/10
yf = yi
plots,[xi,xf],[yi,yf], COLOR=color, /DEV, THICK=thick
plots,[xf,xf],[ yf+dmini3, yf-dmini3 ], COLOR=color, /DEV, THICK=thick
plots,[xi,xi],[ yi+dmini3, yi-dmini3 ], COLOR=color, /DEV, THICK=thick
if not keyword_set( LABEL) then begin
if (arcmins LT 1) then arcstr = string(arcmins,format='(f4.2)')+"'" $
else arcstr = string(arcmins) + "'"
label = strtrim(arcstr,2)
endif
xyouts,(xi+xf)/2, yi+2, label, SIZE = size,COLOR=color,/DEV, alignment=.5, $
CHARTHICK=thick
return
end