FUNCTION qImage_cw_Wedge, state, p_box, wedge=wedge, box=box, noupdate=noupdate, img_center=img_center ;+ ; NAME: ; qImage_cw_Wedge ; PURPOSE: ; Calculate boundary and bounding box for a wedge specified as two points ; in polar coordinates ; CATEGORY: ; Compound widget qImage_cw ; CALLING SEQUENCE: ; Result = qImage_cw_Wedge(state, p_box, /noupdate, wedge-wedge, box-box) ; INPUTS: ; state array[1]; type: structure ; qImage_cw state structure ; OPTIONAL INPUT PARAMETERS: ; p_box array[2,2]; type: float ; limiting values in phase angle and radius of the wedge ; in the form [[angle1,radius1],[angle2,radius2]]. ; Angle1 and angle2 are in radians between [-!pi,+!pi]. ; The wedge runs counterclockwise from 'angle1' to 'angle2' ; over less than 180 degrees: either angle2 > angle1 with ; angle2-angle1 < !pi or angle2 < angle1 with ; angle+2*!pi-angle1 < !pi. Always radius1 < radius2. ; ; If p_box is not specified then the wedge specified in ; the qImage_cw widget is used. ; ; If p_box is specified then the value is processed by qImage_cw_Box. ; This will update the qImage_cw widget, but will also slightly modify ; p_box in such a way that the two corners of the wedge coincide with ; integer pixel locations (the values returned in 'box') ; (set /noupdate to bypass this step) ; /noupdate Only used if p_box is specified. Bypasses a call to ; qImage_cw_Box (which updates the position widgets). ; OUTPUTS: ; result array[2,2]; type: integer ; corners of the smallest square in the image that completely encloses ; the wedge in pixel coordinates in the form [[x1,y1],[x2,y2]. ; Always x1 <= x2, y1 <= y2. ; OPTIONAL OUTPUT PARAMETERS: ; wedge array[2,n]; type: float ; boundary of wedge as a closed array (first=last point) ; in rectangular (pixel) coordinates. ; box array[2,2]; type: float; default: content of X,Y position widgets in ; qImage_cw. Two points in the image plane, specified as pixel coordinate ; values in the same form as the bounding box. ; 'box' is obtained by a call to qImage_cw_Box, and is not modified. ; If /noupdate is set then qImage_cw_Box is not called and 'box' will be undefined. ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, IsType, qImage_cw_Box, wedge_bounding_box ; PROCEDURE: ; The origin of the rectangular to polar transformation is the value of ; the state.wid_center widgets ; If p_box is specified, and keywords /noupdate and img_center are used then the state structure ; is not accessed. ; STATE INFO USED: ; STATE INFO MODIFIED: ; (none) ; MODIFICATION HISTORY: ; FEB-2000, Paul Hick (UCSD/CASS) ; FEB-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Split off the bounding box calculation into separate routine (wedge_bounding_box) ;- InitVar, noupdate, /key CASE 1 OF IsType(p_box, /undef): qImage_cw_Box, state, box, /get, p_box=p_box 1-noupdate : qImage_cw_Box, state, box, /polar, /put, p_box=p_box ; this will modify p_box slightly ELSE: ENDCASE IF IsType(img_center, /undefined) THEN $ qImage_cw_Box, state, img_center, /center RETURN, wedge_bounding_box(p_box, center=img_center, wedge=wedge) & END