casa
$Rev:20696$
|
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(); 00148 00149 // Return the type of this DisplayData. 00150 virtual Display::DisplayDataType classType() 00151 { return Display::Vector; } 00152 00153 // Create a new TblAsXyDM for drawing on the given 00154 // WorldCanvas when the AttributeBuffers are suitably matched to the 00155 // current state of this DisplayData and of the WorldCanvas/Holder. 00156 // The tag is a unique number used to identify the age of the newly 00157 // constructed CachingDisplayMethod. 00158 virtual CachingDisplayMethod *newDisplayMethod(WorldCanvas *worldCanvas, 00159 AttributeBuffer *wchAttributes, 00160 AttributeBuffer *ddAttributes, 00161 CachingDisplayData *dd); 00162 00163 // Return the current options of this DisplayData as an 00164 // AttributeBuffer. 00165 virtual AttributeBuffer optionsAsAttributes(); 00166 00167 //provide read-only access to the table 00168 Table *table(); 00169 00170 // Clean up (ie. delete any existing cached display list). 00171 virtual void cleanup(); 00172 00173 protected: 00174 00175 // (Required) default constructor. 00176 TblAsXYDD(); 00177 00178 // (Required) copy constructor. 00179 TblAsXYDD(const TblAsXYDD &other); 00180 00181 // (Required) copy assignment. 00182 void operator=(const TblAsXYDD &other); 00183 00184 // Get the value of the named keyword, or the first keyword matching 00185 // <src>regex</src>, and return it in <src>value</src>. The return 00186 // value is <src>True</src> for success, and <src>False</src> for 00187 // failure, which is the result if the wrong type <src>T</src> is 00188 // requested. 00189 // <group> 00190 template <class T> Bool getTableKeyword(T &value, 00191 const String keyword) const; 00192 template <class T> Bool getTableKeyword(T &value, const Regex ®ex) const; 00193 // </group> 00194 00195 // Get the value of the named keyword, or the first keyword matching 00196 // <src>regex</src> for the named column, and return it in 00197 // <src>value</src>. The return value is <src>True</src> for 00198 // success, and <src>False</src> for failure, which is the result if // the wrong type <src>T</src> is requested, or if the keyword 00199 // doesn't exist. 00200 // <group> 00201 template <class T> Bool getColumnKeyword(T &value, const String column, 00202 const String keyword) const; 00203 template <class T> Bool getColumnKeyword(T &value, const String column, 00204 const Regex ®ex) const; 00205 // </group> 00206 private: 00207 00208 friend class TblAsXYDM; 00209 00210 // The table to be displayed 00211 Table *itsTable; 00212 00213 // The result from a table query 00214 Table *itsQueryTable; 00215 00216 // store all the table column names 00217 Vector<String> itsColumnNames; 00218 00219 // what columns are we displaying and do we have a movie axis available 00220 DParameterChoice *itsXColumnName; 00221 DParameterChoice *itsYColumnName; 00222 DParameterChoice *itsMColumnName; 00223 DParameterChoice *itsMColumnSet; 00224 00225 // options - what is the query string and is it unset? 00226 String itsOptQueryString; 00227 Bool itsOptQueryStringUnset; 00228 00229 // set the default options for this display data 00230 void installDefaultOptions(); 00231 00232 // Arrange the query table (called after changing an option). 00233 Bool arrangeQueryTable(); 00234 00235 // holder for the current coordinate system 00236 CoordinateSystem itsCoord; 00237 Vector<Double> itsLinblc, itsLintrc; 00238 00239 // update/set the coordinate system 00240 void getCoordinateSystem(); 00241 void setCoordinateSystem(); 00242 00243 // get all of the table columnNames 00244 void getTableColumnNames(); 00245 00246 // get the table column world coordinate range 00247 Vector<double> columnStatistics(const String& columnName); 00248 00249 // get all of the table columnNames with a certain data type 00250 Vector<String> getColumnNamesOfType(); 00251 00252 // Construct and destruct the parameter set. 00253 // <group> 00254 void constructParameters(); 00255 void destructParameters(); 00256 // </group> 00257 00258 }; 00259 00260 00261 00262 } //# NAMESPACE CASA - END 00263 00264 #ifndef AIPS_NO_TEMPLATE_SRC 00265 #include <display/DisplayDatas/TblAsXYDDTemplates.tcc> 00266 #endif //# AIPS_NO_TEMPLATE_SRC 00267 #endif 00268 00269