LatticeAsRaster.h

Go to the documentation of this file.
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( SHARED_PTR<ImageInterface<T> > image, const uInt xAxis, const uInt yAxis, const uInt mAxis, const IPosition fixedPos, viewer::StatusSink *sink=0 );
00182                 LatticeAsRaster(SHARED_PTR<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( bool scrub=false ) const;
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() {
00216                         return Display::Raster;
00217                 }
00218 
00219                 // class name
00220                 virtual String className() const {
00221                         return String("LatticeAsRaster");
00222                 }
00223                 const static String HISTOGRAM_RANGE;
00224                 const static String COLOR_MODE;
00225 
00226         private:
00227 
00228                 // Storage for the data range parameters
00229                 Vector<Float> itsOptionsDataRange;
00230                 Vector<Float> itsOptionsDataDefault;
00231 
00232                 LatticeAsRaster<T>* rasterRed;
00233                 LatticeAsRaster<T>* rasterGreen;
00234                 LatticeAsRaster<T>* rasterBlue;
00235 
00236                 //Float itsOptionsPower;
00237 
00238                 // what colormode the raster should be drawn in, options are
00239                 // "colormap" for normal pseudo-color rasters, and "red", "green"
00240                 // and "blue" for RGB canvases, and "hue", "saturation" and "value"
00241                 // for HSV canvases.
00242                 String itsOptionsColorMode;
00243 
00244                 // pointers to scale and resampling handlers
00245                 WCPowerScaleHandler *itsPowerScaleHandler;
00246 
00247                 // allow the corresponding DisplayMethod to access this' private data.
00248                 friend class LatticePADMRaster<T>;
00249                 LatticeAsRaster<T>* getRasterRed();
00250                 LatticeAsRaster<T>* getRasterGreen();
00251                 LatticeAsRaster<T>* getRasterBlue();
00252                 virtual void setDisplayDataRed( DisplayData* dd );
00253                 virtual void setDisplayDataBlue( DisplayData* dd );
00254                 virtual void setDisplayDataGreen( DisplayData* dd );
00255                 void initializeDataMatrix( int index,
00256                                         Matrix<T>& datMatrix, Matrix<Bool>& mask, const IPosition& start,
00257                                         const IPosition& sliceShape, const IPosition& stride );
00258 
00259                 //static bool globalColors;
00260 
00261                 //# Make parent members known.
00262         public:
00263                 using LatticePADisplayData<T>::nelements;
00264                 using LatticePADisplayData<T>::nPixelAxes;
00265                 using LatticePADisplayData<T>::fixedPosition;
00266                 using LatticePADisplayData<T>::displayAxes;
00267                 using LatticePADisplayData<T>::dataShape;
00268                 using LatticePADisplayData<T>::getDataMin;
00269                 using LatticePADisplayData<T>::getDataMax;
00270                 using LatticePADisplayData<T>::readOptionRecord;
00271                 using LatticePADisplayData<T>::setAttribute;
00272                 using LatticePADisplayData<T>::getHist;
00273                 using LatticePADisplayData<T>::getBrightnessUnits;
00274         protected:
00275                 using LatticePADisplayData<T>::setNumImages;
00276                 using LatticePADisplayData<T>::DDelement;
00277         };
00278 
00279 
00280 } //# NAMESPACE CASA - END
00281 
00282 #ifndef AIPS_NO_TEMPLATE_SRC
00283 #include <display/DisplayDatas/LatticeAsRaster.tcc>
00284 #endif //# AIPS_NO_TEMPLATE_SRC
00285 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1