casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DSMarker.h
Go to the documentation of this file.
00001 //# DSMarker.h: Marker 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_DSMARKER_H
00029 #define TRIALDISPLAY_DSMARKER_H
00030 
00031 #include <casa/aips.h>
00032 #include <display/DisplayShapes/DSBasic.h>
00033 #include <display/Display/DisplayEnums.h>
00034 
00035 #include <casa/Arrays/Vector.h> 
00036 #include <casa/Arrays/Matrix.h>
00037 
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 class PixelCanvas;
00042 class DSPCMarker;
00043 class DSWCMarker;
00044 
00045 template <class T> class DParameterRange;
00046 
00047 // <summary>
00048 // Implementation of a marker.
00049 // </summary>
00050 //
00051 // <prerequisite>
00052 // <li> <linkto class="DSBasic">DSBasic</linkto>
00053 // <li> <linkto class="Display">Display</linkto>
00054 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
00055 // </prerequisite>
00056 //
00057 // <etymology>
00058 // DSMarker is a method of managind the drawing of a marker onto a pixel 
00059 // canvas.
00060 // </etymology>
00061 //
00062 // <synopsis>
00063 // DSArrow simply extends from DSLine, and adds the management of a polygon
00064 // to it. The polygon is used to represent the arrow head, and various options
00065 // regarding its apppearance can be changed.
00066 //
00067 // There are generally two ways to make DisplayShape(s); To create them in 
00068 // "one hit" by providing arguments to the constructor, or by using the 
00069 // default constructor and then the "setOptions" method. A simple interface 
00070 // for all classes inheriting from the 
00071 // <linkto class="DisplayShape">DisplayShape</linkto> class is provided by 
00072 // <linkto class="DisplayShapeInterface">DisplayShapeInterface</linkto>.
00073 // </synopsis>
00074 //
00075 // <motivation>
00076 // A desire to have markers, similar to those used by PGPlot available as an
00077 // annotation object. This wrapper is designed to make the management of 
00078 // drawing markers as primitives easier.
00079 // </motivation>
00080 //
00081 // <example>
00082 // <srcblock>
00083 // </srcblock>
00084 // </example>
00085 
00086 
00087 class DSMarker : public DSBasic {
00088 
00089 public:
00090 
00091   // Constructors and destructor. See 
00092   // <linkto class="Display">Display</linkto> for a list of avaiable 
00093   // markers. Currently, all pixelHeights are changed to an even number,
00094   // as odd sized markers tend to look funny. The pixelSize corresponds
00095   // to the height of the marker in pixels.
00096   // <group>
00097   DSMarker();
00098   DSMarker(const Float& xPos, const Float& yPos, 
00099            const Display::Marker& marker = Display::Square, 
00100            const uInt pixelSize = 10);
00101   DSMarker(const Record& settings);
00102 
00103   DSMarker(const DSPCMarker& other);
00104   DSMarker(const DSWCMarker& other);  
00105   DSMarker(const DSMarker& other);
00106 
00107   virtual ~DSMarker();
00108   // </group>
00109 
00110   // Standard DisplayShape functions.
00111   // <group>
00112   virtual void move(const Float& dX, const Float& dY);
00113   virtual void setCenter(const Float& xPos, const Float& yPos);
00114   virtual Vector<Float> getCenter();
00115   virtual void scale(const Float& scaleFactor);
00116   virtual void draw(PixelCanvas* pc);
00117   virtual Bool inObject(const Float& xPos, const Float& yPos);
00118   // </group>
00119 
00120   virtual void setSize(const uInt newSize);
00121 
00122   // Get and set options.
00123   // <group>
00124   virtual Bool setOptions(const Record& settings);
00125   virtual Record getOptions();
00126   // </group>
00127 
00128   // Overload, since we never want to click on a marker (Well actually
00129   // we might, but as yet we have no use, and sometimes people think that 
00130   // have clicked on a marker when actually they are on a handle. This 
00131   // makes it appear as though the marker isn't moving. 
00132   virtual Bool whichHandle(const Float& /*xPos*/, const Float& /*yPos*/,
00133                            Int& /*active*/) {
00134     return False;
00135   }
00136 
00137   // These functions do not apply for DSMarkers. They are here to ensure
00138   // no strange behavior
00139   // <group>
00140   virtual void rotate(const Float& /*angle*/) {};
00141   virtual void changePoint(const Vector<Float>& /*newPos*/) {};
00142   virtual void changePoint(const Vector<Float>& /*newPoint*/,
00143                            const Int /*nPoint*/) {};
00144   // </group>
00145 
00146   //  virtual void recalculateScreenPosition();
00147 
00148 private:
00149   // Set the default options. Called by default constructor.
00150   virtual void setDefaultOptions();
00151 
00152   // Update location of single handle
00153   void updateHandle();
00154 
00155   Vector<Float> itsCenter;
00156   Matrix<Float> itsHandle;
00157   Bool itsBuiltHandle;
00158   DParameterRange<Int>* itsSize;
00159 
00160   Display::Marker itsMarkerStyle;
00161   Bool itsValid;
00162 
00163 };
00164 
00165 } //# NAMESPACE CASA - END
00166 
00167 #endif
00168