casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ActiveCaching2dDD.h
Go to the documentation of this file.
00001 //# ActiveCaching2dDD.h: active 2d implementation of a CachingDisplayData
00002 //# Copyright (C) 1999,2000,2001,2002,2003,2004
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_ACTIVECACHING2DDD_H
00029 #define TRIALDISPLAY_ACTIVECACHING2DDD_H
00030 
00031 #include <casa/aips.h>
00032 #include <coordinates/Coordinates/CoordinateSystem.h>
00033 #include <display/DisplayDatas/CachingDisplayData.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 // <summary>
00038 // Class providing active behaviour for 2d CachingDisplayDatas.
00039 // </summary>
00040 
00041 // <synopsis> 
00042 // An "active" DisplayData is one which is able to negotiate
00043 // coordinates on a WorldCanvas, and subsequently provide coordinate
00044 // conversion facilities.  This particular implementation is 
00045 // of a two-dimensional (2d) active DisplayData.
00046 // </synopsis>
00047 
00048 class ActiveCaching2dDD : public CachingDisplayData {
00049 
00050  public:
00051 
00052   // Constructor.  Caller must provide a CoordinateSystem, and the
00053   // pixel range (via <src>pixelblc</src> and <src>pixeltrc</src>)
00054   // over which the DisplayData is expected to function.  The primary
00055   // use of <src>pixelblc</src> and <src>pixeltrc</src> is to provide
00056   // limits for the unzoomed WorldCanvas.  <src>coordsys</src> must
00057   // have only two world and pixel axes, otherwise an exception is
00058   // thrown, and likewise, <src>pixblc</src> and <src>pixtrc</src>
00059   // must both be of length two.
00060   ActiveCaching2dDD(const CoordinateSystem &coordsys,
00061                     const Vector<Double> &pixblc,
00062                     const Vector<Double> &pixtrc);
00063 
00064   // Destructor.
00065   virtual ~ActiveCaching2dDD();
00066 
00067   // Coordinate transformation handlers, called by WorldCanvasHolder.
00068   // <group>
00069   virtual Bool linToWorld(Vector<Double> &world, const Vector<Double> &lin);
00070   virtual Bool worldToLin(Vector<Double> &lin, const Vector<Double> &world);
00071   // </group>
00072 
00073   // Format a string containing coordinate information at the given
00074   // world coordinate.
00075   virtual String showPosition(const Vector<Double> &world, 
00076                               const Bool &displayAxesOnly = False);
00077 
00078   // World axis information suppliers.
00079   // <group>
00080   virtual Vector<String> worldAxisNames() const;
00081   virtual Vector<String> worldAxisUnits() const;
00082   // </group>
00083   
00084   // Return the number of display elements (ie. drawable images) in
00085   // this DisplayData.  Both return 1 because this is defined to be a
00086   // two-dimensional DisplayData, and can only have one view.  That
00087   // is, there is no third axis to iterate over for multiple views.
00088   // <group>
00089   virtual const uInt nelements(const WorldCanvasHolder &/*wcHolder*/) const
00090     { return nelements(); }
00091   virtual const uInt nelements() const
00092     { return 1; }
00093   // </group>
00094 
00095   // Install the default options for this DisplayData.
00096   virtual void setDefaultOptions();
00097 
00098   // Apply options stored in <src>rec</src> to the DisplayData.  A
00099   // return value of <src>True</src> means a refresh is needed.
00100   // <src>recOut</src> contains any fields which were implicitly 
00101   // changed as a result of the call to this function.
00102   virtual Bool setOptions(Record &rec, Record &recOut);
00103 
00104   // Retrieve the current and default options and parameter types.
00105   virtual Record getOptions();
00106 
00107   // Negotiatiate WorldCanvas linear coordinate system when asked to
00108   // do so by the WorldCanvasHolder.
00109   virtual Bool sizeControl(WorldCanvasHolder &wcHolder, 
00110                            AttributeBuffer &holderBuf);
00111   
00112   // Determine whether DD can draw on the current coordinate system
00113   // of the given WC[H].
00114   virtual Bool conformsToCS(const WorldCanvas& wc);
00115 
00116   // Tidy up the elements of this DisplayData.
00117   virtual void cleanup();  
00118 
00119  protected:
00120 
00121   // Return the current options of this DisplayData as an
00122   // AttributeBuffer.  The caller must delete the returned buffer.
00123   virtual AttributeBuffer optionsAsAttributes();
00124 
00125   // (Required) default constructor.
00126   ActiveCaching2dDD();
00127 
00128   // (Required) copy constructor.
00129   ActiveCaching2dDD(const ActiveCaching2dDD &other);
00130 
00131   // (Required) copy assignment.
00132   void operator=(const ActiveCaching2dDD &other);
00133 
00134   // Install a CoordinateSystem and limits.
00135   void setCoordinateSystem(const CoordinateSystem &coordsys,
00136                            const Vector<Double> &pixblc,
00137                            const Vector<Double> &pixtrc);
00138 
00139   // Identify a specified world axis by its Coordinate type, number,
00140   // and axis in that coordinate.
00141   void identifyWorldAxis(Coordinate::Type &type, Int &coordinate,
00142                          Int &axisincoord, const uInt worldaxisnum);
00143 
00144   // Generate a String code for the specified world axis, describing
00145   // the coordinate type, number and axis in that coordinate.
00146   String codeWorldAxis(const uInt worldaxisnum);
00147 
00148   // Return the world axis increments.
00149   Vector<Double> worldAxisIncrements() const;
00150 
00151   // Return whether tracking is currently world (T) or pixel (F) coordinates.
00152   virtual Bool worldCoordTracking() const { return itsShowWorldCoordinate;  }
00153 
00154   // Store the 2d CoordinateSystem here.
00155   CoordinateSystem itsCoordinateSystem;
00156 
00157   // Store the 2d pixel corners here.
00158   Vector<Double> itsPixelBlc, itsPixelTrc;
00159 
00160  private:
00161 
00162   // Option: aspect ratio for pixels.
00163   String itsOptionsAspect;
00164 
00165   // Position tracking
00166   String itsSpectralUnit;
00167   String itsVelocityType;
00168   Bool itsAbsolute;
00169   Bool itsShowWorldCoordinate;
00170   Bool itsFractionalPixels;
00171 
00172   // Set Spectral formatting
00173   void setSpectralFormatting (CoordinateSystem& cSys,
00174                               const String& velTypeString,
00175                               const String& unitString);
00176 
00177 
00178 };
00179 
00180 
00181 } //# NAMESPACE CASA - END
00182 
00183 #endif