casa
$Rev:20696$
|
00001 //# LatticeAsRaster.h: Class to display lattice objects as rastered images 00002 //# Copyright (C) 1996,1997,1998,1999,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 //# $Id$ 00027 00028 #ifndef TRIALDISPLAY_LATTICEASRASTER_H 00029 #define TRIALDISPLAY_LATTICEASRASTER_H 00030 00031 #include <casa/aips.h> 00032 #include <images/Images/ImageInterface.h> 00033 #include <casa/Arrays/Array.h> 00034 #include <display/DisplayDatas/LatticePADD.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 template <class T> class Array; 00039 class IPosition; 00040 class Record; 00041 template <class T> class LatticePADMRaster; 00042 class WCPowerScaleHandler; 00043 00044 // <summary>Class to manage the drawing of raster images of slices from AIPS++ Lattices</summary> 00045 // 00046 // <use visibility=export> 00047 // 00048 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00049 // </reviewed> 00050 // 00051 // <prerequisite> 00052 // <li> <linkto class="LatticePADisplayData">LatticePADisplayData</linkto> 00053 // <li> <linkto class="DisplayData">DisplayData</linkto> 00054 // </prerequisite> 00055 // 00056 // <etymology> 00057 // The purpose of this class is to draw "raster" images of data that 00058 // is "lattice"-based. 00059 // </etymology> 00060 // 00061 // <synopsis> 00062 // This class should be used to display raster images--- ie. filled, 00063 // pseudo-color pixel images where each screen (or device) pixel is 00064 // shaded with a color from a look-up table that is assigned to be 00065 // proportional in some way to the intensity of the data pixel---of 00066 // two-dimensional slices of data extracted from AIPS++ Lattices or 00067 // Arrays having two or more dimensions. Thus, this is the class to 00068 // use to display standard channel maps of position-velocity cubes, or 00069 // Digitized Sky Survey images, for example. 00070 // 00071 // At construction, any axes in the data can be mapped to the X and Y 00072 // axes of the display device (see the <linkto 00073 // class="PrincipalAxesDD">PrincipalAxesDD</linkto> class). For data 00074 // with more than two dimensions, a third axis in the dataset can be 00075 // selected for generating a sequence of images along: this is known 00076 // as the "movie" axis. Animation (see the <linkto 00077 // class="Animator">Animator</linkto> class) will cause different 00078 // slices of the data to be selected from along this axis. After 00079 // construction, the axis settings of a LatticeAsRaster object can be 00080 // modified at a later stage. 00081 // 00082 // The LatticeAsRaster object supports a number of options which can 00083 // be set or retrieved using the setOptions and getOptions functions. 00084 // These functions simply accept a Record, which can be converted from 00085 // a GlishRecord: this is done in the <linkto 00086 // class="GTkDisplayData">GTkDisplayData</linkto> class. The options 00087 // for the LatticeAsRaster class are: 00088 // <li> range: a Vector<Double> of two elements, being the minimum and 00089 // maximum data values to map to the minimum and maximum color values. 00090 // <li> power: a Float which specifies the deviation from linear of 00091 // the scaling of the data onto the colormap. Increasingly negative 00092 // values give increasingly severe logarithmic scaling: this scaling 00093 // effectively allocates more color cells to the lowest data values 00094 // (usually corresponding to the thermal noise and low surface 00095 // brightness emission) in the image. Increasing positive power 00096 // values give increasingly severe exponential scaling, thereby 00097 // allocating more and more color cells to the highest data values 00098 // (ie. signal and interference)in the image. 00099 // <li> resample: a String which is either "nearest" for nearest 00100 // neighbour pixel resampling, or "bilinear" for bilinear 00101 // interpolation between adjacent groups of four pixels. 00102 // <li> complexmode: this is a String, and is only relevant for 00103 // LatticeAsRaster<Complex> or LatticeAsRaster<DComplex> 00104 // instantantiations. One of "phase", "real", "imaginary" or 00105 // "magnitude" is appropriate for this option, and indicates how 00106 // complex data values should be translated to real pixel values. 00107 // 00108 // LatticeAsRaster is templated, and can be used to draw Complex or Real 00109 // Images or Arrays. For Complex data, the default complexmode is 00110 // "magnitude." LatticeAsRaster objects can be registered on any 00111 // WorldCanvasHolder, but will only draw on WorldCanvases having an 00112 // attribute value of Display::Index for "colormodel." 00113 // </synopsis> 00114 // 00115 // <example> 00116 // A LatticeAsRaster object could be constructed and used as follows: 00117 // <srcblock> 00118 // PagedImage<Float> *pimage = new PagedImage<Float>(String("test.im")); 00119 // DisplayData *dd; 00120 // uInt ndim = pimage->ndim(); 00121 // if (ndim < 2) { 00122 // throw(AipsError(String("Image has less than two dimensions"))); 00123 // } else if (ndim == 2) { 00124 // dd = (DisplayData *)(new LatticeAsRaster<Float>(pimage, 0, 1)); 00125 // } else { 00126 // IPosition fixedPos(ndim); 00127 // fixedPos = 0; 00128 // dd = (DisplayData *)(new LatticeAsRaster<Float>(pimage, 0, 1, 2, 00129 // fixedPos)); 00130 // } 00131 // // wcHolder is an existing WorldCanvasHolder *... 00132 // wcHolder->addDisplayData(ddata); 00133 // wcHolder->refresh(); 00134 // </srcblock> 00135 // </example> 00136 // 00137 // <motivation> 00138 // Displaying 2-dimensional slices of a lattice-based data volume is 00139 // a standard display requirement for astronomical data visualization 00140 // and presentation. 00141 // </motivation> 00142 // 00143 // <templating arg=T> 00144 // </templating> 00145 // 00146 // <thrown> 00147 // </thrown> 00148 // 00149 // <todo asof="yyyy/mm/dd"> 00150 // </todo> 00151 00152 template <class T> class LatticeAsRaster : public LatticePADisplayData<T> { 00153 00154 public: 00155 00156 // Array-based constructors: >2d and 2d. xAxis and yAxis specify 00157 // which axis in the array (0-based) should be mapped to X and Y 00158 // on the display device: ie. 2-d slices of the data to be displayed 00159 // have these axes. mAxis specifies the "movie" axis, which is the axis 00160 // along which different slices are taken. fixedPos is an IPosition 00161 // having the same length as the number of dimensions in the array, 00162 // and indicate the fixed axis values for axes in the data that are 00163 // not specified as xAxis, yAxis or mAxis. 00164 // <group> 00165 LatticeAsRaster(Array<T> *array, const uInt xAxis, 00166 const uInt yAxis, const uInt mAxis, 00167 const IPosition fixedPos); 00168 LatticeAsRaster(Array<T> *array, const uInt xAxis, 00169 const uInt yAxis); 00170 // </group> 00171 00172 // Image-based constructors: >2d and 2d. xAxis and yAxis specify 00173 // which axis in the image (0-based) should be mapped to X and Y 00174 // on the display device: ie. 2-d slices of the data to be displayed 00175 // have these axes. mAxis specifies the "movie" axis, which is the axis 00176 // along which different slices are taken. fixedPos is an IPosition 00177 // having the same length as the number of dimensions in the image, 00178 // and indicate the fixed axis values for axes in the data that are 00179 // not specified as xAxis, yAxis or mAxis. 00180 // <group> 00181 LatticeAsRaster( ImageInterface<T> *image, const uInt xAxis, const uInt yAxis, const uInt mAxis, const IPosition fixedPos, viewer::StatusSink *sink=0 ); 00182 LatticeAsRaster(ImageInterface<T> *image, const uInt xAxis, 00183 const uInt yAxis); 00184 // </group> 00185 00186 // Destructor 00187 virtual ~LatticeAsRaster(); 00188 00189 // Create the various elements in the sequence of displayable 00190 // images. This is called upon construction as well as whenever 00191 // the display and/or movie axes are changed via a call to 00192 // PrincipalAxesDD::setAxes. 00193 //virtual void setupElements(IPosition fixedPos = IPosition(uInt(2))); 00194 virtual void setupElements(); 00195 00196 // Install the default options for display. 00197 virtual void setDefaultOptions(); 00198 00199 // Apply the options stored in the provided Record to the 00200 // LatticeAsRaster object. If the return value is True, then 00201 // some options have changed, and a refresh is needed to update 00202 // the display. 00203 virtual Bool setOptions(Record &rec, Record &recOut); 00204 00205 // Retrieve the currently set options, and their types, default 00206 // values, and any help text associated with each parameter. This 00207 // information can be used to generate form-type graphical user 00208 // interfaces or command-line interfaces to set the options with 00209 // prompts. 00210 virtual Record getOptions(); 00211 //static Record getGlobalOption(); 00212 00213 // Return the DisplayData type; used by the WorldCanvasHolder to 00214 // determine the order of drawing. 00215 virtual Display::DisplayDataType classType() { return Display::Raster; } 00216 00217 // class name 00218 virtual String className() { return String("LatticeAsRaster");} 00219 const static String HISTOGRAM_RANGE; 00220 const static String COLOR_MODE; 00221 //const static String GLOBAL_COLORS; 00222 private: 00223 //Bool setGlobalOption(Record &rec); 00224 // Storage for the data range parameters 00225 Vector<Float> itsOptionsDataRange; 00226 Vector<Float> itsOptionsDataDefault; 00227 00228 //Float itsOptionsPower; 00229 00230 // what colormode the raster should be drawn in, options are 00231 // "colormap" for normal pseudo-color rasters, and "red", "green" 00232 // and "blue" for RGB canvases, and "hue", "saturation" and "value" 00233 // for HSV canvases. 00234 String itsOptionsColorMode; 00235 00236 // pointers to scale and resampling handlers 00237 WCPowerScaleHandler *itsPowerScaleHandler; 00238 00239 // allow the corresponding DisplayMethod to access this' private data. 00240 friend class LatticePADMRaster<T>; 00241 00242 //static bool globalColors; 00243 00244 //# Make parent members known. 00245 public: 00246 using LatticePADisplayData<T>::nelements; 00247 using LatticePADisplayData<T>::nPixelAxes; 00248 using LatticePADisplayData<T>::fixedPosition; 00249 using LatticePADisplayData<T>::displayAxes; 00250 using LatticePADisplayData<T>::dataShape; 00251 using LatticePADisplayData<T>::getDataMin; 00252 using LatticePADisplayData<T>::getDataMax; 00253 using LatticePADisplayData<T>::readOptionRecord; 00254 using LatticePADisplayData<T>::setAttribute; 00255 using LatticePADisplayData<T>::getHist; 00256 using LatticePADisplayData<T>::getBrightnessUnits; 00257 protected: 00258 using LatticePADisplayData<T>::setNumImages; 00259 using LatticePADisplayData<T>::DDelement; 00260 }; 00261 00262 00263 } //# NAMESPACE CASA - END 00264 00265 #ifndef AIPS_NO_TEMPLATE_SRC 00266 #include <display/DisplayDatas/LatticeAsRaster.tcc> 00267 #endif //# AIPS_NO_TEMPLATE_SRC 00268 #endif