DSPoly.h

Go to the documentation of this file.
00001 //# DSPoly.h: Polygon implementation for "DisplayShapes"
00002 //# Copyright (C) 1998,1999,2000,2001,2002
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id:
00027 #ifndef TRIALDISPLAY_DSPOLY_H
00028 #define TRIALDISPLAY_DSPOLY_H
00029 
00030 #include <casa/aips.h>
00031 
00032 #include <display/DisplayShapes/DSClosed.h>
00033 #include <casa/Arrays/Matrix.h>
00034 #include <casa/Arrays/Vector.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 // <summary>
00039 // Implementation of a Polygon.
00040 // </summary>
00041 //
00042 // <prerequisite>
00043 // <li> <linkto class="DSClosed">DSClosed</linkto>
00044 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
00045 // </prerequisite>
00046 //
00047 // <etymology>
00048 // DSPoly is a method of managing the drawing of a polygon onto a PixelCanvas.
00049 // </etymology>
00050 //
00051 // <synopsis>
00052 // DSPoly allows for the management of a polygon, including the addition and
00053 // deletion of points.
00054 //
00055 // There are generally two ways to make DisplayShape(s); To create them in
00056 // "one hit" by providing arguments to the constructor, or by using the
00057 // default constructor and then the "setOptions" method. A simple interface
00058 // for all classes inheriting from the
00059 // <linkto class="DisplayShape">DisplayShape</linkto> class is provided
00060 // by <linkto class="DisplayShapeInterface">DisplayShapeInterface</linkto>.
00061 // </synopsis>
00062 //
00063 // <motivation>
00064 // To enable display of circles onto a pixel canvas.
00065 // </motivation>
00066 //
00067 // <example>
00068 // <srcblock>
00069 // </srcblock>
00070 // </example>
00071 
00072 
00073         class DSPoly : public DSClosed {
00074 
00075         public:
00076 
00077                 // Constructors and destructor
00078                 // <group>
00079                 DSPoly();
00080                 DSPoly(const DSPoly& other);
00081                 DSPoly(const Matrix<Float>& points, const Bool& handles = False,
00082                        const Bool& drawHandles = False);
00083 
00084                 virtual ~DSPoly();
00085                 // </group>
00086 
00087                 // General DisplayShape functions
00088                 // <group>
00089                 virtual void draw(PixelCanvas *pc);
00090                 virtual void rotate(const Float& angle);
00091                 virtual Bool inObject(const Float& xPos, const Float& yPos);
00092                 virtual void scale(const Float& scale);
00093                 virtual void move (const Float& dX, const Float& dY);
00094                 virtual void changePoint(const Vector<Float>& newLocation);
00095                 virtual void changePoint(const Vector<Float>& newLocation, const Int point);
00096                 virtual void setCenter(const Float& xPos, const Float& yPos);
00097                 virtual Vector<Float> getCenter();
00098                 virtual void rotateAbout(const Float& angle, const Float& aboutX,
00099                                          const Float& aboutY);
00100                 // </group>
00101 
00102                 // Polygon specific functions, add, delete and set points, all in pixels.
00103                 // Add point decides the best place in the array to insert the new point.
00104                 // Similarly, deletePoints(const Vector<Float>& remove) deletes the point
00105                 // closest to that provided.
00106                 // <group>
00107                 virtual void addPoint(const Vector<Float>& newPoint);
00108                 virtual void deletePoint(const Vector<Float>& removePoint);
00109                 virtual void deletePoint(const Int nPoint);
00110                 virtual void setPoints(const Matrix<Float>& newPoints);
00111                 // </group>
00112 
00113 
00114                 // Get and set options
00115                 // <group>
00116                 virtual Record getOptions();
00117                 virtual Bool setOptions(const Record& settings);
00118                 // </group>
00119 
00120         private:
00121 
00122                 // Points used to draw (with scaling + rotation)
00123                 Matrix<Float> itsPoints;
00124                 Vector<Float> itsPolyCenter;
00125                 Bool itsValidPoints;
00126                 Bool itsValidCenter;
00127 
00128                 virtual void setDefaultOptions();
00129                 virtual Float getArea();
00130 
00131         protected:
00132                 virtual Matrix<Float> getPoints();
00133 
00134         };
00135 
00136 } //# NAMESPACE CASA - END
00137 
00138 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1