casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TblAsContourDD.h
Go to the documentation of this file.
00001 //# TblAsContourDD.h: Display Data for contour displays of data from a table
00002 //# Copyright (C) 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 //#
00027 //# $Id$
00028 
00029 #ifndef TRIALDISPLAY_TBLASCONTOURDD_H
00030 #define TRIALDISPLAY_TBLASCONTOURDD_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/Vector.h> 
00034 #include <display/Display/DParameterRange.h>
00035 #include <display/Display/DParameterChoice.h>
00036 #include <display/Display/DParameterString.h>   
00037 #include <coordinates/Coordinates/LinearCoordinate.h>
00038 #include <display/DisplayDatas/ActiveCaching2dDD.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 class Table;
00043 class TblAsContourDM;
00044 class Regex;
00045 
00046 //# Forward Declarations
00047 
00048 // <summary>
00049 //Class for displaying data within a table as a contour image.
00050 // </summary>
00051 
00052 // <use visibility=local>   or   <use visibility=export>
00053 
00054 // <reviewed reviewer="" date="" tests="" demos="">
00055 // </reviewed>
00056 
00057 // <prerequisite>
00058 //   <li> ActiveCaching2dDD
00059 //   <li> CachingDisplayData
00060 //   <li> Table
00061 // </prerequisite>
00062 //
00063 // <etymology>
00064 // "TblAsContourDD" is a implementation of a <linkto class=ActiveCaching2dDD>
00065 // ActiveCaching2dDD </linkto> which provides for the display of data held 
00066 // within a table to be displayed as a contour image in an environment where
00067 // individual depictions of the data are automatically cached.
00068 // </etymology>
00069 //
00070 // <synopsis>
00071 // This class adds to the interface defined in <linkto
00072 // class=DisplayData>DisplayData </linkto>.  It adds the capability to 
00073 // display vector/array data from a <linkto class=Table>Table</linkto>
00074 // column as a contour image.  It is assumed that the Y axis is defined 
00075 // to be either the row number of the table column being displayed or
00076 // the scalar value from the same row number in a different table 
00077 // column (e.g. plotting intensity as a function of frequency against
00078 // row number or time determined from a different column of the table).
00079 // The X axis is assumed to be a one dimensional array or vector of
00080 // of data for each row in the column being displayed.  It is assumed
00081 // that the length of this array/vector does not change throughout the
00082 // column of the table.
00083 // </synopsis>
00084 //
00085 // <example>
00086 // A TblAsContourDD object could be construed and used as follows:
00087 // <srcblock>
00088 //    TblAsContourDD *tardd1 = 0;
00089 //    tardd1 = new TblAsContourDD("tablename");
00090 //    Colormap cmap1("Hot Metal 2");
00091 //    tardd1->setColormap(&cmap1, 1.0);
00092 //    wcHolder->addDisplayData((DisplayData *)tardd1);
00093 // </srcblock>
00094 // </example>
00095 //
00096 // <motivation>
00097 // To allow the display of data from a table as a contour image.
00098 // </motivation>
00099 //
00100 // <templating arg=T>
00101 // </templating>
00102 //
00103 // <thrown>
00104 // </thrown>
00105 //
00106 // <todo asof="2000/10/30">
00107 //   <li> make sure complex data are handled correctly
00108 //   <li> make sure table column units can be determined properly
00109 //   <li> make sure a scalar table column can be used for y axis
00110 //   <li> extend to n-dimensional arrays in table column
00111 //   <li> when constructed with *table we need to keep table from being deleted
00112 //   <li> handle movie axis once ActiveCachingNDim exists
00113 //   <li> implement showValue()
00114 // </todo>
00115 
00116 class TblAsContourDD : public ActiveCaching2dDD {
00117 
00118  public:
00119 
00120   // constructors
00121   // given an already constructed table
00122   TblAsContourDD(Table *table);
00123 
00124   // given a string which gives the full pathname and filename of a table 
00125   // on disk
00126   TblAsContourDD(const String tablename);
00127 
00128   // Destructor
00129   virtual ~TblAsContourDD();
00130 
00131   // format the table value at the give world position 
00132   virtual String showValue(const Vector<Double> &world);
00133 
00134   // get the data unit 
00135   virtual const Unit dataUnit(const String column);
00136   virtual const Unit dataUnit();
00137 
00138   // install the default options for this DisplayData
00139   virtual void setDefaultOptions();
00140 
00141   // Apply options stored in <src>rec</src> to the DisplayData.  A
00142   // return value of <src>True</src> means a refresh is needed.
00143   // <src>recOut</src> contains any fields which were implicitly 
00144   // changed as a result of the call to this function.  
00145   virtual Bool setOptions(Record &rec, Record &recOut);
00146 
00147   // Retrieve the current and default options and parameter types.
00148   virtual Record getOptions();
00149 
00150   // Return the type of this DisplayData.
00151   virtual Display::DisplayDataType classType()
00152     { return Display::Vector; }     
00153 
00154   // Create a new TblAsContourDM for drawing on the given
00155   // WorldCanvas when the AttributeBuffers are suitably matched to the
00156   // current state of this DisplayData and of the WorldCanvas/Holder.
00157   // The tag is a unique number used to identify the age of the newly
00158   // constructed CachingDisplayMethod.
00159   virtual CachingDisplayMethod *newDisplayMethod(WorldCanvas *worldCanvas,
00160                                          AttributeBuffer *wchAttributes,
00161                                          AttributeBuffer *ddAttributes,
00162                                          CachingDisplayData *dd);
00163  
00164   // Return the current options of this DisplayData as an
00165   // AttributeBuffer.
00166   virtual AttributeBuffer optionsAsAttributes();
00167 
00168   //provide read-only access to the table
00169   Table *table();
00170 
00171   // Clean up (ie. delete any existing cached display list).
00172   virtual void cleanup();
00173 
00174  protected:
00175 
00176   // (Required) default constructor.
00177   TblAsContourDD();
00178 
00179   // (Required) copy constructor.
00180   TblAsContourDD(const TblAsContourDD &other);
00181 
00182   // (Required) copy assignment.
00183   void operator=(const TblAsContourDD &other);
00184 
00185  // Get the value of the named keyword, or the first keyword matching
00186   // <src>regex</src>, and return it in <src>value</src>.  The return
00187   // value is <src>True</src> for success, and <src>False</src> for
00188   // failure, which is the result if the wrong type <src>T</src> is
00189   // requested.
00190   // <group>
00191   template <class T> Bool getTableKeyword(T &value,
00192                                           const String keyword) const;
00193   template <class T> Bool getTableKeyword(T &value, const Regex &regex) const;
00194   // </group>
00195  
00196   // Get the value of the named keyword, or the first keyword matching
00197   // <src>regex</src> for the named column, and return it in
00198   // <src>value</src>. The return value is <src>True</src> for
00199   // success, and <src>False</src> for failure, which is the result if           // the wrong type <src>T</src> is requested, or if the keyword
00200   // doesn't exist.
00201   // <group>
00202   template <class T> Bool getColumnKeyword(T &value, const String column,
00203                                            const String keyword) const;
00204   template <class T> Bool getColumnKeyword(T &value, const String column,
00205                                            const Regex &regex) const;
00206   // </group>                                                                    
00207 private:
00208 
00209   friend class TblAsContourDM;
00210 
00211   // The table to be displayed
00212   Table *itsTable;
00213 
00214   // The result from a table query
00215   Table *itsQueryTable;
00216 
00217   // store all the table column names
00218   Vector<String> itsColumnNames;
00219 
00220   // what columns are we displaying and do we have a movie axis available
00221   DParameterChoice *itsXColumnName;
00222   DParameterChoice *itsYColumnName;
00223   DParameterChoice *itsMColumnName;
00224   DParameterChoice *itsMColumnSet;
00225 
00226   // options - what is the query string and is it unset?
00227   String itsOptQueryString;
00228   Bool itsOptQueryStringUnset;
00229 
00230   // set the default options for this display data
00231   void installDefaultOptions();
00232 
00233   // Arrange the query table (called after changing an option).
00234   Bool arrangeQueryTable();
00235  
00236   // holder for the current coordinate system
00237   CoordinateSystem itsCoord;
00238   Vector<Double> itsLinblc, itsLintrc;
00239 
00240   // update/set the coordinate system 
00241   void getCoordinateSystem();
00242   void setCoordinateSystem();
00243 
00244   // get all of the table columnNames
00245   void getTableColumnNames();
00246 
00247   // get the table column world coordinate range
00248   Vector<double> columnStatistics(const String& columnName);
00249 
00250   // get all of the table columnNames with a certain data type
00251   Vector<String> getColumnNamesOfType(const Bool isarray);
00252 
00253   // Construct and destruct the parameter set.
00254   // <group>
00255   void constructParameters();
00256   void destructParameters();
00257   // </group>
00258                    
00259   // parameters for the control of the contour's apperance
00260   Vector<Float> itsLevels;
00261   Float itsScale;
00262   Float itsLine;
00263   Bool itsDash;
00264   String itsColor;
00265   String itsType;
00266 
00267 };
00268 
00269 
00270 
00271 } //# NAMESPACE CASA - END
00272 
00273 #ifndef AIPS_NO_TEMPLATE_SRC
00274 #include <display/DisplayDatas/TblAsContourDDTemplates.tcc>
00275 #endif //# AIPS_NO_TEMPLATE_SRC
00276 #endif
00277 
00278