Viewing contents of file '../idllib/uit/pro/cwarplist.pro'
pro cwarplist,ch,chref,oldim,refim,x,y,xref,yref,fwhm=fwhm
;+
; NAME:
;    CWARPLIST
; PURPOSE:
;    Allows user to cursor-select corresponding sources as shown on two
;    different display channels.  Lists of corresponding X, Y coordinates
;    returned.  Source located at centroid in image array, in box surrounding
;    cursor position.
; CALLING SEQUENCE:
;    cwarplist, ch, chref, refim, x, y, xref, yref, FWHM = fwhm
; INPUT PARAMETERS:
;    ch     = channel containing one of the images ('object image')
;    chref  = channel containing other image ('reference image')
;    oldim  = array containing object image
;    refim  = array containing reference image
;    fwhm [keyword] passed to CNTRD (centroid) function; default=1.5
; OUTPUT PARAMETERS:
;    x, y   = coordinates of sources on object image
;    xref, yref = corresponding coordinates on reference image
;         If x,y and xref,yref already contain values upon calling CWARPLIST,
;         then the new coordinates will be appended to the vectors.    This
;         allows one to accumulate the vectors with multiple calls to 
;         CWARPLIST
; COMMON BLOCKS: none
; SIDE EFFECTS:
;    Displays boxes around selected sources.
; MODIFICATION HISTORY:
;    Written by R. S. Hill, ST Systems Corp., 10 April 1991
;    Changed from WARPLIST to CWARPLIST to do centroiding.
;       RSH, STX, 17 April 1991
;    Final computed points plotted, not initially chosen ones.  Also,
;       fwhm keyword substituted for boxrad.  RSH, STX, 2 May 1991
;    User can reject a mistake.  Symbol size increase.  RSH, STX, 5/13/91
;    Work on zoomed, offset images  WBL         April 1992
;-
On_error,2
qsave = !quiet & !quiet = 1
if N_params() LE 0 then begin
   print,'Syntax: cwarplist,ch,chref,oldim,refim,x,y,xref,yref, [ FWHM = ]'
   return
endif
if not keyword_set(fwhm) then fwhm=1.5
key = '0'
if N_elements(x) EQ 0 then x = 0
if N_elements(y) EQ 0 then y = 0
if N_elements(xref) EQ 0 then xref = 0
if N_elements(yref) EQ 0 then yref = 0

WHILE (key NE 'q') AND (key NE 'Q') DO BEGIN
   chan,ch
   print,'Select source on channel ',ch
   cursor, xx0, yy0, /down, /device
   unzoom_xy,xx0,yy0
   cntrd,oldim,xx0,yy0,xx,yy,fwhm
   if xx(0) NE -1 then begin
       zoom_xy,xx,yy,xxtv,yytv
       plots,xxtv,yytv,/device,psym=1,symsize=2.0
   endif
   wait,1.0
   chan,chref
   print,'Select source on channel ',chref
   cursor, xx0r, yy0r, /down, /device   
   unzoom_xy,xx0r,yy0r
   cntrd,refim,xx0r,yy0r,xxref,yyref,fwhm
   if xxref(0) NE -1 then begin
        zoom_xy,xxref,yyref,xxreftv,yyreftv
        plots,xxreftv,yyreftv,/device,psym=1,symsize=2.0
   endif
   print,'Current match:  (ref) = ',xxref,yyref,'   (object) = ',xx,yy, $
         format='$(A,2F7.2,A,2F7.2)'
   key = '0'
   WHILE (key NE 'y') AND (key NE 'Y') AND $
         (key NE 'n') AND (key NE 'N') DO BEGIN
      print,'OK?  (Y/N)'
      key = get_kbrd(1)
   ENDWHILE
   IF (key eq 'y') OR (key eq 'Y') THEN BEGIN
      x = [x,xx] & y = [y,yy] & xref = [xref,xxref] & yref = [yref,yyref]
   ENDIF
   print,'Enter Q to quit or anything else to continue'
   key = get_kbrd(1)
ENDWHILE
x = x(1:*) & y = y(1:*) & xref = xref(1:*) & yref = yref(1:*)
!quiet = qsave
return
end