casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DSEllipse.h
Go to the documentation of this file.
00001 //# DSEllipse.h: Ellipse 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_DSELLIPSE_H
00029 #define TRIALDISPLAY_DSELLIPSE_H
00030 
00031 #include <casa/aips.h>
00032 
00033 #include <display/DisplayShapes/DSClosed.h>
00034 #include <casa/Arrays/Matrix.h>
00035 #include <casa/Arrays/Vector.h>
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 // <summary>
00039 // Implementation of a ellipse.
00040 // </summary>
00041 //
00042 // <prerequisite>
00043 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
00044 // </prerequisite>
00045 //
00046 // <etymology>
00047 // DSEllipse is a method of managing the drawing of a ellipse onto a 
00048 // PixelCanvas.
00049 // </etymology>
00050 //
00051 // <synopsis>
00052 // DSEllipse is the DisplayShape implementation of the primitive ellipse. 
00053 //
00054 // There are generally two ways to make DisplayShape(s); To create them in 
00055 // "one hit" by providing arguments to the constructor, or by using the 
00056 // default constructor and then the "setOptions" method. A simple interface 
00057 // for all classes inheriting from the 
00058 // <linkto class="DisplayShape">DisplayShape</linkto> class is provided by 
00059 // <linkto class="DisplayShapeInterface">DisplayShapeInterface</linkto>.
00060 // </synopsis>
00061 //
00062 // <motivation>
00063 // To allow the management of ellipses being draw to a pixel canvas.
00064 // </motivation>
00065 //
00066 // <example>
00067 // </example>
00068 
00069 
00070 
00071 class DSEllipse : public DSClosed {
00072 
00073 public:
00074   // Constructors and destructors. the 'onlyShowOneHandle' flag is primarily 
00075   // for use if the ellipse is intended to remain symmetrical i.e. a circle.
00076   // <group>
00077   DSEllipse(const Bool& onlyShowOneHandle = False);
00078   DSEllipse(const DSEllipse& other);
00079   DSEllipse(const Float& xPos, const Float& yPos, const Float& major, 
00080             const Float& minor,
00081             const Bool& hasHandles = False, const Bool& drawHandles = False, 
00082             const Bool& onlyShowOneHandle = False);
00083   virtual ~DSEllipse();
00084   // </group>
00085 
00086   // General DisplayShape functions.
00087   // <group>
00088   virtual void draw(PixelCanvas *pix);
00089   virtual void move(const Float& dX, const Float& dY);
00090   virtual Bool inObject(const Float& xPos, const Float& yPos);
00091   virtual void rotate(const Float& angle);
00092   virtual void rotateAbout(const Float& angle, const Float& aboutX, 
00093                              const Float& aboutY);
00094   virtual void setCenter(const Float& xPos, const Float& yPos);
00095   virtual Vector<Float> getCenter();
00096   virtual void changePoint(const Vector<Float>& newPoint);
00097   virtual void changePoint(const Vector<Float>& newPoint, const Int nPoint);
00098   virtual void scale(const Float& scaleFactor);
00099   // </group>
00100 
00101   // Functions to set / get the minor and major axis of the ellipse 
00102   // (in pixels). 
00103   // <group>
00104   virtual Float getMinorAxis();
00105   virtual Float getMajorAxis();
00106   virtual void setMajorAxis(const Float& newMajor);
00107   virtual void setMinorAxis(const Float& newMinor);
00108   // </group>
00109 
00110   // Get and set options
00111   // <group>
00112   virtual Record getOptions();
00113   virtual Bool setOptions(const Record& settings);
00114   // </group>
00115 
00116 protected: 
00117   // Required on update
00118   virtual void calculateHandlePositions();
00119 private:
00120 
00121   Vector<Float> itsCenter;
00122   Float itsAngle;
00123   Float itsMajorAxis, itsMinorAxis;
00124   Bool itsValid, itsOneHandle;
00125   
00126   Matrix<Float> itsHandleLocation;
00127 
00128   // Called when def. constructor used
00129   virtual void setDefaultOptions();
00130 
00131 
00132 };
00133 
00134 
00135 } //# NAMESPACE CASA - END
00136 
00137 #endif
00138 
00139