casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
AnnRotBox.h
Go to the documentation of this file.
00001 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00002 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00003 //# License for more details.
00004 //#
00005 //# You should have received a copy of the GNU Library General Public License
00006 //# along with this library; if not, write to the Free Software Foundation,
00007 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00008 //#
00009 //# Correspondence concerning AIPS++ should be addressed as follows:
00010 //#        Internet email: aips2-request@nrao.edu.
00011 //#        Postal address: AIPS++ Project Office
00012 //#                        National Radio Astronomy Observatory
00013 //#                        520 Edgemont Road
00014 //#                        Charlottesville, VA 22903-2475 USA
00015 //#
00016 
00017 #ifndef ANNOTATIONS_ANNROTBOX_H
00018 #define ANNOTATIONS_ANNROTBOX_H
00019 
00020 #include <casa/aips.h>
00021 #include <imageanalysis/Annotations/AnnRegion.h>
00022 
00023 namespace casa {
00024 
00025 // <summary>
00026 // This class represents an annotation for rectangular (in position coordinates) region specified
00027 // in an ascii region file as proposed in CAS-2285. It is specified by its center position
00028 // and side widths and a position angle.
00029 // </summary>
00030 // <author>Dave Mehringer</author>
00031 // <use visibility=export>
00032 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00033 // </reviewed>
00034 // <prerequisite>
00035 
00036 // </prerequisite>
00037 
00038 // <etymology>
00039 // Holds the specification of an annotation for a rectangular region as specified in ASCII format.
00040 // Specified by center position and widths of sides and a position angle
00041 // </etymology>
00042 
00043 // <synopsis>
00044 // This class represents an annotation for a rectangular region in coordinate space specified by
00045 // center and widths of sides and a position angle.
00046 // </synopsis>
00047 
00048 
00049 class AnnRotBox: public AnnRegion {
00050 
00051 public:
00052 
00053         // <src>positionAngle</src> is measured in the usual astronomical
00054         // way; starting at north through east (counterclockwise)
00055         AnnRotBox(
00056                 const Quantity& xcenter,
00057                 const Quantity& ycenter,
00058                 const Quantity& xwidth,
00059                 const Quantity& ywidth, const Quantity& positionAngle,
00060                 const String& dirRefFrameString,
00061                 const CoordinateSystem& csys,
00062                 const IPosition& imShape,
00063                 const Quantity& beginFreq,
00064                 const Quantity& endFreq,
00065                 const String& freqRefFrameString,
00066                 const String& dopplerString,
00067                 const Quantity& restfreq,
00068                 const Vector<Stokes::StokesTypes> stokes,
00069                 const Bool annotationOnly
00070         );
00071 
00072         // Simplified constructor.
00073         // all frequencies are used (these can be set after construction).
00074         // xcenter and ycenter
00075         // must be in the same frame as the csys direction coordinate.
00076         // is a region (not just an annotation), although this value can be changed after
00077         // construction.
00078         AnnRotBox(
00079                 const Quantity& xcenter,
00080                 const Quantity& ycenter,
00081                 const Quantity& xwidth,
00082                 const Quantity& ywidth, const Quantity& positionAngle,
00083                 const CoordinateSystem& csys,
00084                 const IPosition& imShape,
00085                 const Vector<Stokes::StokesTypes>& stokes
00086         );
00087 
00088         // implicit copy constructor and destructor are fine
00089 
00090         AnnRotBox& operator=(const AnnRotBox& other);
00091 
00092         // get the four corners of the box in direction space.
00093         // These will have been converted to the frame of the
00094         // coordinate system if necessary. The only thing about
00095         // the order of the vector that is garaunteed is that
00096         // adjacent entries in the returned Vector will not be
00097         // diagonally opposite corners.
00098         Vector<MDirection> getCorners() const;
00099 
00100         void worldBoundingBox(vector<Quantity>& blc, vector<Quantity>& trc) const;
00101 
00102         // get the world coordinates of the polygon vertices
00103         void worldCorners(vector<Quantity>& x, vector<Quantity>& y) const;
00104 
00105         // get the pixel coordinates of the polygon vertices
00106         void pixelCorners(vector<Double>& x, vector<Double>& y) const;
00107 
00108         virtual ostream& print(ostream &os) const;
00109 
00110 private:
00111         AnnotationBase::Direction _inputCenter;
00112         Vector<Quantity> _inputWidths;
00113         Vector<Quantity> _widths;
00114         Quantity _positionAngle;
00115         Vector<MDirection> _corners;
00116 
00117         void _init(
00118                 const Quantity& xcenter, const Quantity& ycenter,
00119                 const Quantity& xwidth, const Quantity& ywidth
00120         );
00121 
00122         void _doCorners();
00123 };
00124 
00125 }
00126 
00127 #endif