casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DSText.h
Go to the documentation of this file.
00001 //# Text.h: Text 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_DSTEXT_H
00029 #define TRIALDISPLAY_DSTEXT_H
00030 
00031 #include <casa/aips.h>
00032 
00033 #include <display/DisplayShapes/DisplayShape.h>
00034 #include <display/Display/DisplayEnums.h>
00035 
00036 #include <casa/Arrays/Matrix.h>
00037 #include <casa/Arrays/Vector.h> 
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 class DParameterString;
00042 class DParameterFontChoice;
00043 class DParameterMapKeyChoice;
00044 template <class T> class DParameterRange;
00045 
00046 // <summary>
00047 // Implementation of text. 
00048 // </summary>
00049 //
00050 // <prerequisite>
00051 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
00052 // </prerequisite>
00053 //
00054 // <etymology>
00055 // DSText is a method of managing the drawing of text onto a PixelCanvas.
00056 // </etymology>
00057 //
00058 // <synopsis>
00059 // DSText is designed to have the same interface as any other 'shape' 
00060 // extending DisplayShape. Much of the functionality is exactly the same, 
00061 // and hence provides a usefull wrapper for text in an 'annotations' context.
00062 //
00063 // There are generally two ways to make DisplayShape(s); To create them in 
00064 // "one hit" by providing arguments to the constructor, or by using the 
00065 // default constructor and then the "setOptions" method. A simple interface 
00066 // for all classes inheriting from the 
00067 // <linkto class="DisplayShape">DisplayShape</linkto> class is provided 
00068 // by <linkto class="DisplayShapeInterface">DisplayShapeInterface</linkto>.
00069 // </synopsis>
00070 //
00071 // <motivation>
00072 // To create a text wrapper which behaved in the same was as any other 
00073 // DisplayShape
00074 // </motivation>
00075 //
00076 // <example>
00077 // <srcblock>
00078 // </srcblock>
00079 // </example>
00080 
00081 
00082 class DSText : public DisplayShape {
00083 
00084 public:
00085 
00086   // Constructors and destructors
00087   // <group>
00088   DSText();
00089   DSText(const DSText& other);
00090   DSText(const Float& xPos, const Float& yPos, const String& text = "Label", 
00091          const Bool& hasHandles = True, const Bool& drawHandles = True);
00092   
00093   virtual ~DSText();
00094   // </group>
00095 
00096   // Functions to ensure consistancy with the "DisplayShape" interface.
00097   // <group>
00098   virtual void draw(PixelCanvas* pix);
00099   virtual void move(const Float& dX, const Float& dY);
00100   virtual void rotate(const Float& angle);
00101   virtual Bool inObject(const Float& xPos, const Float& yPos);
00102   virtual void changePoint(const Vector<Float>& newPos);
00103   virtual void changePoint(const Vector<Float>& newPos, const Int nPoint);
00104   virtual void scale(const Float& scaleFactor);
00105   virtual void setCenter(const Float& xPos, const Float& yPos);
00106   virtual Vector<Float> getCenter();
00107   // </group>
00108 
00109   // Get and set options
00110   // <group>
00111   virtual Record getOptions();
00112   virtual Bool setOptions(const Record& settings);
00113   // </group>
00114 
00115 
00116 private:
00117   // This is a bit messy, so seperate it out
00118   void makeAlignmentChoice();
00119 
00120   // Update handle positions
00121   virtual void calculateHandlePositions();
00122 
00123   // Cast from int to enum
00124   Display::TextAlign toEnum(const Int fromInt);
00125   
00126   // Text Parameter
00127   DParameterString* itsString;
00128 
00129   // Angle Param
00130   DParameterRange<Float>* itsAngle;
00131   DParameterMapKeyChoice* itsAlignment;
00132   DParameterFontChoice* itsFont;
00133   DParameterRange<Int>* itsFontSize;
00134 
00135   // Rotate about a point.. overloaded but not used
00136   Vector<Float> itsCenter;
00137   Int itsPixHeight, itsPixWidth;
00138   Bool itsValid;
00139   Bool itsHandlesMade, itsValidPositions;
00140   Float itsStringLength;
00141   Float itsStringHeight;
00142   Matrix<Float> itsHandleLocation;
00143   Display::TextAlign itsAlign;
00144   virtual void setDefaultOptions();
00145 
00146 
00147 };
00148 
00149 } //# NAMESPACE CASA - END
00150 
00151 #endif
00152 
00153 
00154