DSRectangle.h

Go to the documentation of this file.
00001 //# DSRectangle.h: Rectangle 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 
00028 #ifndef TRIALDISPLAY_DSRECTANGLE_H
00029 #define TRIALDISPLAY_DSRECTANGLE_H
00030 
00031 #include <casa/aips.h>
00032 
00033 #include <display/DisplayShapes/DSPoly.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 // <summary>
00038 // Implementation of a rectangle.
00039 // </summary>
00040 //
00041 // <prerequisite>
00042 // <li> <linkto class="DSPoly">DSPoly</linkto>
00043 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
00044 // </prerequisite>
00045 //
00046 // <etymology>
00047 // DSRectangle is a method of managing the drawing of a rectangle onto a
00048 // PixelCanvas.
00049 // </etymology>
00050 //
00051 // <synopsis>
00052 // DSRectangle is simply a DSPoly with only four points. It has overloaded
00053 // certain functions however, which cause it to behave as a rectangle when
00054 // having its points moved etc. It calculates its width and height from
00055 // points returned from DSPoly when needed.
00056 //
00057 // There are generally two ways to make DisplayShape(s); To create them in
00058 // "one hit" by providing arguments to the constructor, or by using the
00059 // default constructor and then the "setOptions" method. A simple interface
00060 // for all classes inheriting from the
00061 // <linkto class="DisplayShape">DisplayShape</linkto> class is provided by
00062 // <linkto class="DisplayShapeInterface">DisplayShapeInterface</linkto>.
00063 // </synopsis>
00064 //
00065 // <motivation>
00066 // The need to draw rectangles on screen.
00067 // </motivation>
00068 //
00069 // <example>
00070 // <srcblock>
00071 // </srcblock>
00072 // </example>
00073 //
00074 // <todo asof="2002/05/13">
00075 // <li> Modify functions like 'changePoint' to allow a special case when
00076 // angle = 0 for speed reasons.
00077 // </todo>
00078 
00079 
00080         class DSRectangle : public DSPoly {
00081 
00082         public:
00083 
00084                 // Constructors and Destructors
00085                 // <group>
00086                 DSRectangle();
00087                 DSRectangle(const Float& xPos, const Float& yPos, const Float& width,
00088                             const Float& height, const Bool& handles = False,
00089                             const Bool& drawHandles = False);
00090                 DSRectangle(const DSRectangle& other);
00091                 virtual ~DSRectangle();
00092                 // </group>
00093 
00094                 // Standard DisplayShape functions
00095                 // <group>
00096                 virtual void move(const Float& dX, const Float& dY);
00097                 virtual void rotate(const Float& angle);
00098                 virtual void rotateAbout(const Float& angle, const Float& aboutX,
00099                                          const Float& aboutY);
00100                 virtual void setCenter(const Float& xPos, const Float& yPos);
00101                 virtual void changePoint(const Vector<Float>& pos);
00102                 virtual void changePoint(const Vector<Float>& newPoints, const Int whichOne);
00103                 virtual void addPoint(const Vector<Float>& toAdd);
00104                 // </group>
00105 
00106 
00107                 // Rectangle specific. Get / set width and height in pixels.
00108                 // <group>
00109                 virtual void setHeight(const Float& height);
00110                 virtual void setWidth(const Float& width);
00111                 virtual Float getHeight();
00112                 virtual Float getWidth();
00113                 // </group>
00114 
00115                 // Get and set options
00116                 // <group>
00117                 virtual Bool setOptions(const Record& settings);
00118                 virtual Record getOptions();
00119                 // </group>
00120 
00121                 // Using supplied parameters, make a polygon of four points representing the
00122                 // rectangle. This can then be used to create / alter a DSPoly.
00123                 virtual Matrix<Float> makeAsPoly(const Float& xPos, const Float& yPos,
00124                                                  const Float& width, const Float& height);
00125 
00126         private:
00127 
00128                 // Always valid
00129                 Float itsAngle;
00130                 Bool itsValid;
00131 
00132                 //Ony used during the set-up period
00133                 Float itsCenter, itsWidth, itsHeight;
00134 
00135                 virtual void setDefaultOptions();
00136                 virtual void setAngle(const Float& newAngle);
00137 
00138         protected:
00139                 virtual Float getAngle();
00140         };
00141 
00142 
00143 } //# NAMESPACE CASA - END
00144 
00145 #endif
00146 
00147 
00148 
00149 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1