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