AnnPolygon.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_ANNPOLYGON_H
00018 #define ANNOTATIONS_ANNPOLYGON_H
00019 
00020 #include <casa/aips.h>
00021 #include <imageanalysis/Annotations/AnnRegion.h>
00022 
00023 namespace casa {
00024 
00025 // <summary>
00026 // This class represents a single polygon (in position coordinates) annotation specified
00027 // in an ascii region file as proposed in CAS-2285
00028 // </summary>
00029 // <author>Dave Mehringer</author>
00030 // <use visibility=export>
00031 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00032 // </reviewed>
00033 // <prerequisite>
00034 
00035 // </prerequisite>
00036 
00037 // <etymology>
00038 // Holds the specification of a polygon annotation.
00039 // </etymology>
00040 
00041 // <synopsis>
00042 // This class represents a polygon annotation.
00043 // </synopsis>
00044 
00045 
00046 class AnnPolygon: public AnnRegion {
00047 
00048 public:
00049 
00050         AnnPolygon(
00051                 const Vector<Quantity>& xPositions,
00052                 const Vector<Quantity>& yPositions,
00053                 const String& dirRefFrameString,
00054                 const CoordinateSystem& csys,
00055                 const IPosition& imShape,
00056                 const Quantity& beginFreq,
00057                 const Quantity& endFreq,
00058                 const String& freqRefFrameString,
00059                 const String& dopplerString,
00060                 const Quantity& restfreq,
00061                 const Vector<Stokes::StokesTypes> stokes,
00062                 const Bool annotationOnly
00063         );
00064 
00065         // Simplified constructor.
00066         // all frequencies are used (these can be set after construction).
00067         // xPositions and yPositions
00068         // must be in the same frame as the csys direction coordinate.
00069         // is a region (not just an annotation), although this value can be changed after
00070         // construction.
00071         AnnPolygon(
00072                 const Vector<Quantity>& xPositions,
00073                 const Vector<Quantity>& yPositions,
00074                 const CoordinateSystem& csys,
00075                 const IPosition& imShape,
00076                 const Vector<Stokes::StokesTypes>& stokes
00077         );
00078 
00079         // implicit copy constructor and destructor are fine
00080 
00081         AnnPolygon& operator=(const AnnPolygon& other);
00082 
00083         // get the vertices converted to the coordinate system used at construction.
00084         Vector<MDirection> getCorners() const;
00085 
00086         // get the world coordinates of the polygon vertices
00087         void worldVertices(vector<Quantity>& x, vector<Quantity>& y) const;
00088 
00089         // get the pixel coordinates of the polygon vertices
00090         void pixelVertices(vector<Double>& x, vector<Double>& y) const;
00091 
00092 
00093         virtual ostream& print(ostream &os) const;
00094 
00095 protected:
00096         // for rectangle subclasses
00097         AnnPolygon(
00098                 AnnotationBase::Type shape,
00099                 const Quantity& blcx,
00100                 const Quantity& blcy,
00101                 const Quantity& trcx,
00102                 const Quantity& trcy,
00103                 const String& dirRefFrameString,
00104                 const CoordinateSystem& csys,
00105                 const IPosition& imShape,
00106                 const Quantity& beginFreq,
00107                 const Quantity& endFreq,
00108                 const String& freqRefFrameString,
00109                 const String& dopplerString,
00110                 const Quantity& restfreq,
00111                 const Vector<Stokes::StokesTypes> stokes,
00112                 const Bool annotationOnly
00113         );
00114 
00115         // Simplified constructor.
00116         // all frequencies are used (these can be set after construction).
00117         // blcx, blcy, trcx, and trcy
00118         // must be in the same frame as the csys direction coordinate.
00119         // is a region (not just an annotation), although this value can be changed after
00120         // construction.
00121         AnnPolygon(
00122                 AnnotationBase::Type shape,
00123                 const Quantity& blcx,
00124                 const Quantity& blcy,
00125                 const Quantity& trcx,
00126                 const Quantity& trcy,
00127                 const CoordinateSystem& csys,
00128                 const IPosition& imShape,
00129                 const Vector<Stokes::StokesTypes>& stokes
00130         );
00131 
00132         // For centered rectangles
00133         AnnPolygon(
00134                 AnnotationBase::Type shape,
00135                 const Quantity& centerx,
00136                 const Quantity& centery,
00137                 const Quantity& widthx,
00138                 const Quantity& widthy,
00139                 const Quantity& positionAngle,
00140                 const String& dirRefFrameString,
00141                 const CoordinateSystem& csys,
00142                 const IPosition& imShape,
00143                 const Quantity& beginFreq,
00144                 const Quantity& endFreq,
00145                 const String& freqRefFrameString,
00146                 const String& dopplerString,
00147                 const Quantity& restfreq,
00148                 const Vector<Stokes::StokesTypes> stokes,
00149                 const Bool annotationOnly
00150         );
00151 
00152                 // Simplified constructor.
00153                 // all frequencies are used (these can be set after construction).
00154                 // centerx and centery
00155                 // must be in the same frame as the csys direction coordinate.
00156                 // is a region (not just an annotation), although this value can be changed after
00157                 // construction.
00158                 AnnPolygon(
00159                         AnnotationBase::Type shape,
00160                         const Quantity& centerx,
00161                         const Quantity& centery,
00162                         const Quantity& widthx,
00163                         const Quantity& widthy,
00164                         const Quantity& positionAngle,
00165                         const CoordinateSystem& csys,
00166                         const IPosition& imShape,
00167                         const Vector<Stokes::StokesTypes>& stokes
00168                 );
00169 
00170 private:
00171         Vector<Quantity> _origXPos, _origYPos;
00172 
00173         void _init();
00174 
00175         void _initCorners(
00176                 const Quantity& blcx,
00177                 const Quantity& blcy,
00178                 const Quantity& trcx,
00179                 const Quantity& trcy
00180         );
00181 
00182         void _initCorners(
00183                 const MDirection& blc,
00184                 const MDirection& corner2,
00185                 const MDirection& trc,
00186                 const MDirection& corner4
00187         );
00188 
00189         void _initCenterRectCorners(
00190                 const Quantity& centerx,
00191                 const Quantity& centery,
00192                 const Quantity& widthx,
00193                 const Quantity& widthy,
00194                 const Quantity& positionAngle
00195         );
00196 
00197         void _doCorners(const Quantity& widthx, const Quantity widthy);
00198 
00199 };
00200 
00201 }
00202 
00203 #endif /* ASCIIPOLYGONREGION_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1