casa
$Rev:20696$
|
00001 //# LatticeAsVector.h: Class to display data as a vector map 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003 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_LATTICEASVECTOR_H 00029 #define TRIALDISPLAY_LATTICEASVECTOR_H 00030 00031 //# aips includes: 00032 #include <casa/aips.h> 00033 #include <casa/Quanta/Unit.h> 00034 00035 //# trial includes: 00036 #include <images/Images/ImageInterface.h> 00037 00038 //# display library includes: 00039 #include <display/DisplayDatas/LatticePADD.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 LatticePADMVector; 00048 00049 // <summary>Class to manage the drawing of vector 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 vectors maps of data that 00063 // is lattice-based. 00064 // </etymology> 00065 // 00066 // <synopsis> 00067 // This class should be used to display vector maps---i.e. 00068 // lines with an amplitude and position angle 00069 // for two-dimensional slices of data extracted from AIPS++ Lattices or 00070 // Arrays having two or more dimensions. The data source can be Complex 00071 // or Float. If Complex, then both the amplitude and position angle 00072 // can be extracted. If Float, the data represents the position angle 00073 // (degrees) and an amplitude of unity is assumed. 00074 // I 00075 // 00076 // At construction, any axes in the data can be mapped to the X and Y 00077 // axes of the display device (see the <linkto 00078 // class="PrincipalAxesDD">PrincipalAxesDD</linkto> class). For data 00079 // with more than two dimensions, a third axis in the dataset can be 00080 // selected for generating a sequence of maps along: this is known 00081 // as the "movie" axis. Animation (see the <linkto 00082 // class="Animator">Animator</linkto> class) will cause different 00083 // slices of the data to be selected from along this axis. After 00084 // construction, the axis settings of a LatticeAsVector object can be 00085 // modified at a later stage. 00086 // 00087 //# </synopsis> 00088 // 00089 // <example> 00090 // A LatticeAsVector object could be constructed and used as follows: 00091 // <srcblock> 00092 // PagedImage<Complex> *pimage = new PagedImage<Complex>(String("test.im")); 00093 // DisplayData *dd; 00094 // uInt ndim = pimage->ndim(); 00095 // if (ndim < 2) { 00096 // throw(AipsError(String("Image has less than two dimensions"))); 00097 // } else if (ndim == 2) { 00098 // dd = (DisplayData *)(new LatticeAsVector<Complex>(pimage, 0, 1)); 00099 // } else { 00100 // IPosition fixedPos(ndim); 00101 // fixedPos = 0; 00102 // dd = (DisplayData *)(new LatticeAsVector<Complex>(pimage, 0, 1, 2,fixedPos)); 00103 // } 00104 // // wcHolder is an existing WorldCanvasHolder *... 00105 // wcHolder->addDisplayData(ddata); 00106 // wcHolder->refresh(); 00107 // </srcblock> 00108 // </example> 00109 // 00110 // <motivation> 00111 // Displaying 2-dimensional slices of a lattice-based data volume is 00112 // a standard display requirement for astronomical data visualization 00113 // and presentation. 00114 // </motivation> 00115 // 00116 // <templating arg=T> 00117 // </templating> 00118 // 00119 // <thrown> 00120 // </thrown> 00121 // 00122 // <todo asof="2000/12/16"> 00123 // </todo> 00124 00125 template <class T> class LatticeAsVector : public LatticePADisplayData<T> { 00126 00127 public: 00128 // Array-based constructors: >2d and 2d. xAxis and yAxis specify 00129 // which axis in the array (0-based) should be mapped to X and Y 00130 // on the display device: ie. 2-d slices of the data to be displayed 00131 // have these axes. mAxis specifies the "movie" axis, which is the axis 00132 // along which different slices are taken. fixedPos is an IPosition 00133 // having the same length as the number of dimensions in the array, 00134 // and indicate the fixed axis values for axes in the data that are 00135 // not specified as xAxis, yAxis or mAxis. 00136 // <group> 00137 LatticeAsVector(Array<T>* array, const uInt xAxis, 00138 const uInt yAxis, const uInt mAxis, 00139 const IPosition fixedPos); 00140 LatticeAsVector(Array<T>* array, const uInt xAxis, 00141 const uInt yAxis); 00142 // </group> 00143 00144 // Image-based constructors: >2d and 2d. xAxis and yAxis specify 00145 // which axis in the image (0-based) should be mapped to X and Y 00146 // on the display device: ie. 2-d slices of the data to be displayed 00147 // have these axes. mAxis specifies the "movie" axis, which is the axis 00148 // along which different slices are taken. fixedPos is an IPosition 00149 // having the same length as the number of dimensions in the image, 00150 // and indicate the fixed axis values for axes in the data that are 00151 // not specified as xAxis, yAxis or mAxis. 00152 // <group> 00153 LatticeAsVector(ImageInterface<T>* image, const uInt xAxis, 00154 const uInt yAxis, const uInt mAxis, 00155 const IPosition fixedPos); 00156 LatticeAsVector(ImageInterface<T>* image, const uInt xAxis, 00157 const uInt yAxis); 00158 // </group> 00159 00160 // Destructor 00161 virtual ~LatticeAsVector(); 00162 00163 // Create the various elements in the sequence of displayable 00164 // maps. This is called upon construction as well as whenever 00165 // the display and/or movie axes are changed via a call to 00166 // PrincipalAxesDD::setAxes. 00167 //virtual void setupElements(IPosition fixedPos = IPosition(2)); 00168 virtual void setupElements(); 00169 00170 // install the default options for display 00171 virtual void setDefaultOptions(); 00172 00173 // Apply the options stored in the provided Record to the 00174 // LatticeAsVector object. If the return value is True, then 00175 // some options have changed, and a refresh is needed to update 00176 // the display. 00177 virtual Bool setOptions(Record& rec, Record& recOut); 00178 00179 // Retrieve the currently set options, and their types, default 00180 // values, and any help text associated with each parameter. This 00181 // information can be used to generate form-type graphical user 00182 // interfaces or command-line interfaces to set the options with 00183 // prompts. 00184 virtual Record getOptions(); 00185 00186 // Return the DisplayData type; used by the WorldCanvasHolder to 00187 // determine the order of drawing. 00188 virtual Display::DisplayDataType classType() { return Display::Vector;} 00189 00190 // class name 00191 virtual String className() { return String("LatticeAsVector");} 00192 00193 // Value of the Lattice at a position--used by showValue(). Overrides 00194 // base version to take user-controlled addition to phase angle into account. 00195 virtual const T dataValue(IPosition pos); 00196 00197 private: 00198 00199 Float getVariance(); 00200 // 00201 Float itsScale; // Amplitude scale factor 00202 Float itsLineWidth; // Line width of vectors 00203 Int itsIncX; // Increment in X (pixels) 00204 Int itsIncY; // Increment in Y (pixels) 00205 Bool itsArrow; // Do vectors have arrow head ? 00206 Float itsBarb; // Arrow head shape 00207 String itsColor; // Color of vectors 00208 Float itsRotation; // Add extra rotation 00209 String itsPhaseType; // phase handling type (normal/polarimetric) 00210 Bool itsDebias; // Debias amplitude ? 00211 Float itsVar; // Variance of noise for debiasing 00212 Unit itsUnits; // Image brightness units 00213 Bool itsConstAmp; // SHow as constant amplitude 00214 // 00215 friend class LatticePADMVector<T>; 00216 00217 //# Make parent members known. 00218 public: 00219 using LatticePADisplayData<T>::nelements; 00220 using LatticePADisplayData<T>::nPixelAxes; 00221 using LatticePADisplayData<T>::fixedPosition; 00222 using LatticePADisplayData<T>::displayAxes; 00223 using LatticePADisplayData<T>::dataShape; 00224 using LatticePADisplayData<T>::getMinAndMax; 00225 using LatticePADisplayData<T>::readOptionRecord; 00226 protected: 00227 using LatticePADisplayData<T>::setNumImages; 00228 using LatticePADisplayData<T>::DDelement; 00229 using LatticePADisplayData<T>::datamax; 00230 }; 00231 00232 00233 //# Define template specializations. 00234 template <> Float LatticeAsVector<Complex>::getVariance(); 00235 template <> Float LatticeAsVector<Float>::getVariance(); 00236 00237 00238 00239 } //# NAMESPACE CASA - END 00240 00241 #ifndef AIPS_NO_TEMPLATE_SRC 00242 #include <display/DisplayDatas/LatticeAsVector.tcc> 00243 //#include <display/DisplayDatas/LatticeAsVector2.tcc> 00244 #endif //# AIPS_NO_TEMPLATE_SRC 00245 #endif