TblAsXYDD.h

Go to the documentation of this file.
00001 //# TblAsXYDD.h: Display Data for xy 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_TBLASXYDD_H
00030 #define TRIALDISPLAY_TBLASXYDD_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 TblAsXYDM;
00044         class Regex;
00045 
00046 //# Forward Declarations
00047 
00048 // <summary>
00049 //Class for displaying data within a table as a xy 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 // "TblAsXYDD" 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 xy 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 data from a <linkto class=Table>Table</linkto>
00074 // column as a xy 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 the data in a scalar table column.
00080 // </synopsis>
00081 //
00082 // <example>
00083 // A TblAsXYDD object could be construed and used as follows:
00084 // <srcblock>
00085 //    TblAsXYDD *tardd1 = 0;
00086 //    tardd1 = new TblAsXYDD("tablename");
00087 //    Colormap cmap1("Hot Metal 2");
00088 //    tardd1->setColormap(&cmap1, 1.0);
00089 //    wcHolder->addDisplayData((DisplayData *)tardd1);
00090 // </srcblock>
00091 // </example>
00092 //
00093 // <motivation>
00094 // To allow the display of data from a table as a xy image.
00095 // </motivation>
00096 //
00097 // <templating arg=T>
00098 // </templating>
00099 //
00100 // <thrown>
00101 // </thrown>
00102 //
00103 // <todo asof="2000/10/30">
00104 //   <li> make sure complex data are handled correctly
00105 //   <li> make sure table column units can be determined properly
00106 //   <li> make sure a scalar table column can be used for y axis
00107 //   <li> extend to n-dimensional arrays in table column
00108 //   <li> when constructed with *table we need to keep table from being deleted
00109 //   <li> handle movie axis once ActiveCachingNDim exists
00110 //   <li> implement showValue()
00111 //   <li> be able to derive xy plot data from columns with arrays
00112 //   <li> choose whether to draw points, lines or both
00113 // </todo>
00114 
00115         class TblAsXYDD : public ActiveCaching2dDD {
00116 
00117         public:
00118 
00119                 // constructors
00120                 // given an already constructed table
00121                 TblAsXYDD(Table *table);
00122 
00123                 // given a string which gives the full pathname and filename of a table
00124                 // on disk
00125                 TblAsXYDD(const String tablename);
00126 
00127                 // Destructor
00128                 virtual ~TblAsXYDD();
00129 
00130                 // format the table value at the give world position
00131                 virtual String showValue(const Vector<Double> &world);
00132 
00133                 // get the data unit
00134                 virtual const Unit dataUnit(const String column);
00135                 virtual const Unit dataUnit();
00136 
00137                 // install the default options for this DisplayData
00138                 virtual void setDefaultOptions();
00139 
00140                 // Apply options stored in <src>rec</src> to the DisplayData.  A
00141                 // return value of <src>True</src> means a refresh is needed.
00142                 // <src>recOut</src> contains any fields which were implicitly
00143                 // changed as a result of the call to this function.
00144                 virtual Bool setOptions(Record &rec, Record &recOut);
00145 
00146                 // Retrieve the current and default options and parameter types.
00147                 virtual Record getOptions( bool scrub=false ) const;
00148 
00149                 // Return the type of this DisplayData.
00150                 virtual Display::DisplayDataType classType() {
00151                         return Display::Vector;
00152                 }
00153 
00154                 // Create a new TblAsXyDM 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                 TblAsXYDD();
00178 
00179                 // (Required) copy constructor.
00180                 TblAsXYDD(const TblAsXYDD &other);
00181 
00182                 // (Required) copy assignment.
00183                 void operator=(const TblAsXYDD &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 TblAsXYDM;
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                 DisplayCoordinateSystem 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();
00252 
00253                 // Construct and destruct the parameter set.
00254                 // <group>
00255                 void constructParameters();
00256                 void destructParameters();
00257                 // </group>
00258 
00259         };
00260 
00261 
00262 
00263 } //# NAMESPACE CASA - END
00264 
00265 #ifndef AIPS_NO_TEMPLATE_SRC
00266 #include <display/DisplayDatas/TblAsXYDDTemplates.tcc>
00267 #endif //# AIPS_NO_TEMPLATE_SRC
00268 #endif
00269 
00270 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1