casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DSLine.h
Go to the documentation of this file.
00001 //# DSLine.h: Line 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_DSLINE_H
00029 #define TRIALDISPLAY_DSLINE_H
00030 
00031 #include <casa/aips.h>
00032 
00033 #include <display/DisplayShapes/DSPolyLine.h>
00034 #include <casa/Arrays/Matrix.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 template <class T> class Vector;
00039 
00040 // <summary>
00041 // Implementation of a line.
00042 // </summary>
00043 //
00044 // <prerequisite>
00045 // <li> <linkto class="DSPolyLine">DSPoly</linkto>
00046 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
00047 // </prerequisite>
00048 //
00049 // <etymology>
00050 // DSLine is a method of managing the drawing of a line onto a PixelCanvas.
00051 // </etymology>
00052 //
00053 // <synopsis>
00054 // DSLine simply extends from DSPolyLine, and adds specific functions to a 
00055 // line with only two points (e.g. setStartPoint) 
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 for a basic line drawing tool. 
00067 // </motivation>
00068 //
00069 // <example>
00070 // <srcblock>
00071 // Vector<Float> startPoint(2); startPoint[0] = 100; startPoint[1] = 100;
00072 // Vector<Float> endPoint(2);   endPoint[0] = 200;   endPoint[1] = 200;
00073 //
00074 // DSLine* myLine = new DSLine(startPoint, endPoint, True, True);
00075 //
00076 // myLine->move(10,10);
00077 //
00078 // Vector<Float> newStart(2); newStart[0] = 50; newStart[1] = 50;
00079 // myLine->setStartPoint(newStart);
00080 //
00081 // Record newLineOpt;
00082 // newLineOpt.define("linewidth", 3);
00083 //
00084 // myLine->setOptions(newLineOpt);
00085 // myLine->draw(myPixelCanvas);
00086 // etc..
00087 // </srcblock>
00088 // </example>
00089 
00090 class DSLine : public DSPolyLine {
00091 
00092 public:
00093 
00094   // Constructors and Destructors
00095   // <group>
00096   DSLine();
00097   DSLine(const DSLine &other);
00098   DSLine(const Vector<Float>& startPos, const Vector<Float>& endPos, 
00099          const Bool& handles = True, const Bool& drawHandles = True);
00100   virtual ~DSLine();
00101   // </group>
00102 
00103   // This does nothing, it's so arrow and other inheriting classes can 
00104   // take note of new centers
00105   virtual void setCenter(const Float& xPos, const Float& yPos);
00106 
00107   // Does this line have a valid start and a valid end?
00108   virtual Bool isValid();
00109 
00110   // Line specific functions for ease of use
00111   // <group>
00112   virtual void setStartPoint(const Vector<Float>& start);
00113   virtual void setEndPoint(const Vector<Float>& end);
00114   // </group>
00115 
00116   // Set and get options
00117   // <group>
00118   virtual Record getOptions();
00119   virtual Bool setOptions(const Record& newSettings);
00120   // </group>
00121 
00122 private:
00123 
00124 
00125   Bool itsValidStart, itsValidEnd;
00126 
00127   // These are to hold the points while line is being made (line is invalid).
00128   Vector<Float> itsStart;
00129   Vector<Float> itsEnd;
00130 
00131 protected: 
00132   
00133   virtual Bool validStart() {
00134     return itsValidStart;
00135   }
00136 
00137   virtual Bool validEnd() {
00138     return itsValidEnd;
00139   }
00140 
00141   virtual void make();
00142   // General utility functions. 
00143   // <group>
00144   virtual Matrix<Float> getEnds();
00145   virtual Matrix<Float> asPolyLine(const Vector<Float>& startPos, const Vector<Float>& endPos);
00146   // </group>
00147 };
00148 
00149 
00150 } //# NAMESPACE CASA - END
00151 
00152 #endif
00153 
00154 
00155