; ; NAME mouse_cyl ; ; FUNCTION Determine pixel coordinates of a cylindrical wedge vertices ; using the mouse. ; ; HISTORY Andrew L. Stanger HAO/NCAR 8 February 1999 ; 18 Feb 1999: Write min/max radii & angles into log file. ;- PRO mouse_cyl5, xdim, ydim, xcen, ycen, pixrs, roll, $ aoinum, logfile, pvfile, xv, yv, nver, polypix rxmin = xcen rxmax = xdim - 1 axmin = xcen axmax = xdim - 1 rymin = ycen rymax = ydim - 1 aymin = ycen aymax = ydim - 1 angle = 0.0 radius = 0.0 TVCRS, xcen, ycen ; Enable cursor PRINT, 'Using the mouse to define a cylindrical wedge-shaped area.' PRINT, 'Position mouse at minimum radius & click left button : ' CURSOR, rxmin, rymin, /DEVICE, WAIT=3 ierr=rcoord (rmin, angle, rxmin, rymin, -1, roll, xcen, ycen, pixrs) PRINT, 'rxmin, rymin, rmin: ', rxmin, rymin, rmin WAIT, 0.5 PRINT, 'Position mouse at maximum radius & click left button : ' CURSOR, rxmax, rymax, /DEVICE, WAIT=3 ierr=rcoord (rmax, angle , rxmax, rymax, -1, roll, xcen, ycen, pixrs) PRINT, 'rxmax, rymax, rmax: ', rxmax, rymax, rmax WAIT, 0.5 PRINT, 'Position mouse at minimum angle & click left button : ' CURSOR, axmin, aymin, /DEVICE, WAIT=3 ierr=rcoord (radius, angmin, axmin, aymin, -1, roll, xcen, ycen, pixrs) PRINT, 'axmin, aymin, angmin: ', rxmin, rymin, angmin WAIT, 0.5 PRINT, 'Position mouse at maximum angle & click left button : ' CURSOR, axmax, aymax, /DEVICE, WAIT=3 ierr=rcoord (radius, angmax, axmax, aymax, -1, roll, xcen, ycen, pixrs) PRINT, 'axmax, aymax, angmax: ', rxmax, rymax, angmax WAIT, 0.5 ierr=rcoord (rmin, angle, rxmin, rymin, -1, roll, xcen, ycen, pixrs) ierr=rcoord (rmax, angle , rxmax, rymax, -1, roll, xcen, ycen, pixrs) ierr=rcoord (radius, angmin, axmin, aymin, -1, roll, xcen, ycen, pixrs) ierr=rcoord (radius, angmax, axmax, aymax, -1, roll, xcen, ycen, pixrs) ;--- Write Region information into log file. OPENW, lulog, logfile, /GET_LUN PRINTF, lulog, 'Mouse-Defined Curved Wedge Region: ', $ STRING (aoinum, FORMAT='(i3)') PRINTF, lulog, STRING (rmin, FORMAT='(F7.2)'), ' --> ', $ STRING (rmax, FORMAT='(F7.2)'), ' Rsun ', $ STRING (angmin, FORMAT='(F7.2)'), ' --> ', $ STRING (angmax, FORMAT='(F7.2)'), ' degrees' PRINTF, lulog, 'polygon vertices file: ', pvfile CLOSE, lulog FREE_LUN, lulog ;--- Write info to screen. PRINT, STRING (rmin, FORMAT='(F7.2)'), ' --> ', $ STRING (rmax, FORMAT='(F7.2)'), ' Rsun ', $ STRING (angmin, FORMAT='(F7.2)'), ' --> ', $ STRING (angmax, FORMAT='(F7.2)'), ' degrees' ; print, 'rmin, rmax: ', rmin, rmax IF (angmin GT angmax) THEN angmax = angmax + 360.0 ; print, 'angmin, angmax: ', angmin, angmax nang = 12 nver = (nang + 1) * 2 + 1 anginc = (angmax - angmin) / nang ; print, 'anginc: ', anginc ; print, 'nver: ', nver xv = fltarr (nver) yv = fltarr (nver) ;--- Starting vertex. iv = 0 ierr=rcoord (rmin, angmin, xx, yy, 1, roll, xcen, ycen, pixrs) xv [iv] = xx yv [iv] = yy iv = iv + 1 ;--- Vertices of outer curve. FOR i = 0, nang DO $ BEGIN angle = angmin + anginc * i ierr=rcoord (rmax, angle, xx, yy, 1, roll, xcen, ycen, pixrs) xv [iv] = xx yv [iv] = yy ; print, 'iv, rmax, angle, xv, yv: ', iv, rmax, angle, xv [iv], yv [iv] iv = iv + 1 END ;--- Vertices of inner curve. FOR i = 0, nang DO $ BEGIN angle = angmax - anginc * i ierr=rcoord (rmin, angle, xx, yy, 1, roll, xcen, ycen, pixrs) xv [iv] = xx yv [iv] = yy ; print, 'iv, rmin, angle, xv, yv: ', iv, rmin, angle, xv [iv], yv [iv] iv = iv + 1 END ; print, 'i: ', i ; FOR i = 0, nver-1 DO print, 'i, xv, yv: ', i, xv [i], yv [i] ;--- Write vertices into a disk file. store_poly, pvfile, xv, yv, nver ;--- Determine coordinates of all pixels within polygon area. polypix = POLYFILLV (xv, yv, xdim, ydim) ;--- pixels in polygon. size_poly = SIZE (polypix) ; print, 'size (polypix): ', size_poly ;--- Draw polygon perimeter. PLOTS, xv, yv, color=253, /DEVICE PLOTS, xv [0], yv [0], color=253, /DEVICE, /CONTINUE END