casa
$Rev:20696$
|
00001 //# LatticeAsContour.h: Class to display lattice objects as contoured 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_LATTICEASCONTOUR_H 00029 #define TRIALDISPLAY_LATTICEASCONTOUR_H 00030 00031 //# aips includes: 00032 #include <casa/aips.h> 00033 00034 //# trial includes: 00035 #include <images/Images/ImageInterface.h> 00036 00037 //# display library includes: 00038 #include <display/DisplayDatas/LatticePADD.h> 00039 #include <display/Display/DParameterRange.h> 00040 00041 namespace casa { //# NAMESPACE CASA - BEGIN 00042 00043 //# forwards: 00044 template <class T> class Array; 00045 class IPosition; 00046 class Record; 00047 template <class T> class LatticePADMContour; 00048 00049 // <summary>Class to manage the drawing of contour maps of slices from AIPS++ Lattices</summary> 00050 // 00051 // <use visibility=export> 00052 // 00053 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00054 // </reviewed> 00055 // 00056 // <prerequisite> 00057 // <li> <linkto class="LatticePADisplayData">LatticePADisplayData</linkto> 00058 // <li> <linkto class="DisplayData">DisplayData</linkto> 00059 // </prerequisite> 00060 // 00061 // <etymology> 00062 // The purpose of this class is to draw "contour" maps of data that 00063 // is "lattice"-based. 00064 // </etymology> 00065 // 00066 // <synopsis> 00067 // This class should be used to display contour maps---ie. line 00068 // drawings connecting data points of equal intensity (or level)---of 00069 // two-dimensional slices of data extracted from AIPS++ Lattices or 00070 // Arrays having two or more dimensions. Thus, this is the class to 00071 // use to display standard zeroth-order moment map contour overlays 00072 // for use on Digitized Sky Survey images, for example. 00073 // 00074 // At construction, any axes in the data can be mapped to the X and Y 00075 // axes of the display device (see the <linkto 00076 // class="PrincipalAxesDD">PrincipalAxesDD</linkto> class). For data 00077 // with more than two dimensions, a third axis in the dataset can be 00078 // selected for generating a sequence of maps along: this is known 00079 // as the "movie" axis. Animation (see the <linkto 00080 // class="Animator">Animator</linkto> class) will cause different 00081 // slices of the data to be selected from along this axis. After 00082 // construction, the axis settings of a LatticeAsContour object can be 00083 // modified at a later stage. 00084 // 00085 // The LatticeAsContour object supports a number of options which can 00086 // be set or retrieved using the setOptions and getOptions functions. 00087 // These functions simply accept a Record, which can be converted from 00088 // a GlishRecord: this is done in the <linkto 00089 // class="GTkDisplayData">GTkDisplayData</linkto> class. The options 00090 // for the LatticeAsContour class are: 00091 // <li> levels: a Vector<Float> (or Vector<Double>) of one or more 00092 // elements, being the data 00093 // values at which the contours are drawn. Depending on type, 00094 // the values in the vector are interpreted as absolute or 00095 // fractions between the data minimum and maximum. 00096 // <li> type: a String, one of "frac" or "abs", indicating whether the 00097 // contour values in "levels" (multiplied by "scale") are fractions of the 00098 // data range between the minimum and maximum, or are instead absolute 00099 // contour levels in the native units of the data. 00100 // <li> scale: a Float or Double which provides an additional scale 00101 // factor to apply to the contour levels in "levels." 00102 // <li> line: a positive Integer specifying the line width of 00103 // contours. 00104 // <li> dashneg: a Boolean value, which if True, will force contours 00105 // at negative data values to be drawn in dashed line style. 00106 // <li> dashpos: a Boolean value, which if True, will force contours 00107 // at positive data values to be drawn in dashed line style. 00108 // <li> color: a String which is the color with which to draw the 00109 // contours. A valid X Color is required. 00110 //# <li> complexmode: this is a String, and is only relevant for 00111 //# LatticeAsContour<Complex> or LatticeAsContour<DComplex> 00112 //# instantantiations. One of "phase", "real", "imaginary" or 00113 //# "magnitude" is appropriate for this option, and indicates how 00114 //# complex data values should be translated to real pixel values. 00115 //# 00116 //# LatticeAsContour is templated, and can be used to draw Complex or Real 00117 //# Images or Arrays. For Complex data, the default complexmode is 00118 //# "magnitude." 00119 //# </synopsis> 00120 // 00121 // <example> 00122 // A LatticeAsContour object could be constructed and used as follows: 00123 // <srcblock> 00124 // PagedImage<Float> *pimage = new PagedImage<Float>(String("test.im")); 00125 // DisplayData *dd; 00126 // uInt ndim = pimage->ndim(); 00127 // if (ndim < 2) { 00128 // throw(AipsError(String("Image has less than two dimensions"))); 00129 // } else if (ndim == 2) { 00130 // dd = (DisplayData *)(new LatticeAsContour<Float>(pimage, 0, 1)); 00131 // } else { 00132 // IPosition fixedPos(ndim); 00133 // fixedPos = 0; 00134 // dd = (DisplayData *)(new LatticeAsContour<Float>(pimage, 0, 1, 2, 00135 // fixedPos)); 00136 // } 00137 // // wcHolder is an existing WorldCanvasHolder *... 00138 // wcHolder->addDisplayData(ddata); 00139 // wcHolder->refresh(); 00140 // </srcblock> 00141 // </example> 00142 // 00143 // <motivation> 00144 // Displaying 2-dimensional slices of a lattice-based data volume is 00145 // a standard display requirement for astronomical data visualization 00146 // and presentation. 00147 // </motivation> 00148 // 00149 // <templating arg=T> 00150 // </templating> 00151 // 00152 // <thrown> 00153 // </thrown> 00154 // 00155 // <todo asof="yyyy/mm/dd"> 00156 // </todo> 00157 00158 template <class T> class LatticeAsContour : public LatticePADisplayData<T> { 00159 00160 public: 00161 00162 // Array-based constructors: >2d and 2d. xAxis and yAxis specify 00163 // which axis in the array (0-based) should be mapped to X and Y 00164 // on the display device: ie. 2-d slices of the data to be displayed 00165 // have these axes. mAxis specifies the "movie" axis, which is the axis 00166 // along which different slices are taken. fixedPos is an IPosition 00167 // having the same length as the number of dimensions in the array, 00168 // and indicate the fixed axis values for axes in the data that are 00169 // not specified as xAxis, yAxis or mAxis. 00170 // <group> 00171 LatticeAsContour(Array<T> *array, const uInt xAxis, 00172 const uInt yAxis, const uInt mAxis, 00173 const IPosition fixedPos); 00174 LatticeAsContour(Array<T> *array, const uInt xAxis, 00175 const uInt yAxis); 00176 // </group> 00177 00178 // Image-based constructors: >2d and 2d. xAxis and yAxis specify 00179 // which axis in the image (0-based) should be mapped to X and Y 00180 // on the display device: ie. 2-d slices of the data to be displayed 00181 // have these axes. mAxis specifies the "movie" axis, which is the axis 00182 // along which different slices are taken. fixedPos is an IPosition 00183 // having the same length as the number of dimensions in the image, 00184 // and indicate the fixed axis values for axes in the data that are 00185 // not specified as xAxis, yAxis or mAxis. 00186 // <group> 00187 LatticeAsContour( ImageInterface<T> *image, const uInt xAxis, const uInt yAxis, const uInt mAxis, const IPosition fixedPos, viewer::StatusSink *sink=0 ); 00188 LatticeAsContour(ImageInterface<T> *image, const uInt xAxis, 00189 const uInt yAxis); 00190 // </group> 00191 00192 // Destructor 00193 virtual ~LatticeAsContour(); 00194 00195 // Create the various elements in the sequence of displayable 00196 // maps. This is called upon construction as well as whenever 00197 // the display and/or movie axes are changed via a call to 00198 // PrincipalAxesDD::setAxes. 00199 //virtual void setupElements(IPosition fixedPos = IPosition(2)); 00200 virtual void setupElements(); 00201 00202 // install the default options for display 00203 virtual void setDefaultOptions(); 00204 00205 // Apply the options stored in the provided Record to the 00206 // LatticeAsContour object. If the return value is True, then 00207 // some options have changed, and a refresh is needed to update 00208 // the display. 00209 virtual Bool setOptions(Record &rec, Record &recOut); 00210 00211 // Retrieve the currently set options, and their types, default 00212 // values, and any help text associated with each parameter. This 00213 // information can be used to generate form-type graphical user 00214 // interfaces or command-line interfaces to set the options with 00215 // prompts. 00216 virtual Record getOptions(); 00217 00218 // Return the DisplayData type; used by the WorldCanvasHolder to 00219 // determine the order of drawing. 00220 virtual Display::DisplayDataType classType() { return Display::Vector; } 00221 00222 // class name 00223 virtual String className() { return String("LatticeAsContour");} 00224 00225 // Actual selected contour levels 00226 virtual Vector<Float> levels(); 00227 00228 // Actual levels, in String format. If precision is unspecified, 00229 // one that is low enough not to be cluttered is used. 00230 virtual String levelString(Int prec=0); 00231 00232 // Adds contour level information to the standard position tracking 00233 // string from PADD. 00234 virtual String showPosition(const Vector<Double> &wld, const Bool &abs, 00235 const Bool &dsp); 00236 00237 using LatticePADisplayData<T>::dataUnit; 00238 00239 00240 protected: 00241 00242 // Construct user option DisplayParameters (for min/max contour.) 00243 // (To be used by constructors only.) 00244 virtual void constructParameters_(); 00245 00246 // Set standard limits/values for contour sliders. If recOut is provided, 00247 // they will be set onto it in a manner suitable for updating gui via 00248 // setOptions. 00249 virtual void setStdContourLimits_(Record* recOut=0); 00250 00251 00252 private: 00253 00254 // Relative contour levels. 00255 Vector<Float> itsLevels; 00256 00257 // Min and Max actual contours. linearly scaled from itsLevels to fit these. 00258 // <group> 00259 DParameterRange<Float> *itsBaseContour; 00260 DParameterRange<Float> *itsUnitContour; 00261 // </group> 00262 00263 Float itsLine; 00264 Bool itsDashNeg; 00265 Bool itsDashPos; 00266 String itsColor; 00267 00268 friend class LatticePADMContour<T>; 00269 00270 //# Make parent members known. 00271 public: 00272 using LatticePADisplayData<T>::nelements; 00273 using LatticePADisplayData<T>::nPixelAxes; 00274 using LatticePADisplayData<T>::fixedPosition; 00275 using LatticePADisplayData<T>::displayAxes; 00276 using LatticePADisplayData<T>::dataShape; 00277 using LatticePADisplayData<T>::getMinAndMax; 00278 using LatticePADisplayData<T>::readOptionRecord; 00279 using LatticePADisplayData<T>::getDataMin; 00280 using LatticePADisplayData<T>::getDataMax; 00281 00282 protected: 00283 using LatticePADisplayData<T>::setNumImages; 00284 using LatticePADisplayData<T>::DDelement; 00285 using LatticePADisplayData<T>::datamax; 00286 }; 00287 00288 00289 } //# NAMESPACE CASA - END 00290 00291 #ifndef AIPS_NO_TEMPLATE_SRC 00292 #include <display/DisplayDatas/LatticeAsContour.tcc> 00293 #endif //# AIPS_NO_TEMPLATE_SRC 00294 #endif