LatticePADD.h

Go to the documentation of this file.
00001 //# LatticePADD.h: Class for displaying lattices along principal axes
00002 //# Copyright (C) 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_LATTICEPADD_H
00029 #define TRIALDISPLAY_LATTICEPADD_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/Quanta/Unit.h>
00033 #include <images/Images/ImageInterface.h>
00034 #include <display/DisplayDatas/PrincipalAxesDD.h>
00035 #include <casa/Containers/Record.h>
00036 #include <display/Display/DParameterChoice.h>
00037 #include <display/Display/DParameterRange.h>
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 class IPosition;
00042 class WCResampleHandler;
00043 class ImageRegion;
00044 class WCLELMask;
00045 class WorldCanvas;
00046 template <class T> class Array;
00047 template <class T> class Lattice;
00048 template <class T> class MaskedLattice;
00049 template <class T> class LatticeStatistics;
00050 
00051 // <summary>
00052 // Partial implementation of PrincipalAxesDD for Lattice-based data.
00053 // </summary>
00054 //
00055 // <synopsis>
00056 // This class is a partial (ie. base) implementation of PrincipalAxesDD
00057 // which adds methods particular to handling Lattice-based data.
00058 // </synopsis>
00059 
00060 template <class T> class LatticePADisplayData : public PrincipalAxesDD {
00061 
00062  public:
00063   // Constructors (no default)
00064   //LatticePADisplayData();
00065 
00066   // Array-based constructors: >2d and 2d
00067   // <group>
00068   LatticePADisplayData(Array<T> *array, const uInt xAxis,
00069                        const uInt yAxis, const uInt mAxis,
00070                        const IPosition fixedPos);
00071   LatticePADisplayData(Array<T> *array, const uInt xAxis,
00072                        const uInt yAxis);
00073   // </group>
00074 
00075   // Image-based constructors: >2d and 2d
00076   // <group>
00077   LatticePADisplayData(ImageInterface<T> *image, const uInt xAxis,
00078                        const uInt yAxis, const uInt mAxis,
00079                        const IPosition fixedPos);
00080   LatticePADisplayData(ImageInterface<T> *image, const uInt xAxis,
00081                        const uInt yAxis);
00082   // </group>
00083 
00084   // Destructor
00085   virtual ~LatticePADisplayData();
00086 
00087   // Format a string containing value information at the 
00088   // given world coordinate
00089   virtual String showValue(const Vector<Double> &world);
00090 
00091   // required functions to help inherited "setup" amongst other things
00092   virtual const IPosition dataShape();
00093   virtual const uInt dataDim();
00094   virtual const T dataValue(IPosition pos);
00095   virtual const Unit dataUnit();
00096   // left as pure virtual for implementation in concrete class
00097   virtual void setupElements() = 0;
00098   virtual void getMinAndMax();
00099 
00100   // return mask value at given position
00101   virtual const Bool maskValue(const IPosition &pos);
00102 
00103   // install the default options for this DisplayData
00104   virtual void setDefaultOptions();
00105 
00106   // apply options stored in val to the DisplayData; return value
00107   // True means a refresh is needed...
00108   virtual Bool setOptions(Record &rec, Record &recOut);
00109 
00110 
00111 
00112   // retrieve the current and default options and parameter types.
00113   virtual Record getOptions();
00114 
00115   // Return the class name of this DisplayData; useful mostly for
00116   // debugging purposes, and perhaps future use in the glish widget
00117   // interface.
00118   virtual String className() { return String("LatticePADisplayData"); }  
00119 
00120   virtual WCResampleHandler *resampleHandler() { return itsResampleHandler; }
00121 
00122   
00123 
00124   virtual Display::ComplexToRealMethod complexMode() 
00125     { return itsComplexToRealMethod; }
00126   virtual void setComplexMode(Display::ComplexToRealMethod method) 
00127     { itsComplexToRealMethod = method; }
00128 
00129   virtual MaskedLattice<T> *maskedLattice() 
00130     { return itsMaskedLatticePtr; }
00131 
00132 
00133    // Insert an array into a Record. The array is insert into a "value" field, eg
00134   // somerecord.fieldname.value
00135   virtual Bool insertArray(Record& toGoInto, Vector<Float> toInsert, const String fieldname);
00136   virtual Bool insertFloat(Record& toGoInto, Float toInsert, const String fieldname);
00137 
00138   // Return the last calculated histogram
00139   virtual Record getHist();
00140   
00141   // Return the brightness unit as a string
00142   virtual String getBrightnessUnits();
00143   
00144   // Aids updateHistogram() by computing a stride to use for efficiency
00145   // when computing histograms (could be used elsewhere too).
00146   // Input parameter 'shape' is the shape of the original lattice or array.
00147   // Return value indicates whether striding should be used; if so, the
00148   // recommended stride is returned in the 'stride' parameter.
00149   // maxPixels is the desired maximum number of elements in the sub-lattice
00150   // that would result from using the returned stride (may be exceeded
00151   // because of minPerAxis requirements, or in any case by a few percent).
00152   // A stride greater than 1 will not be returned for an axis if it
00153   // would make the length of that axis in the strided sub-lattice
00154   // less than minPerAxis.
00155   static Bool useStriding(const IPosition& shape, IPosition& stride,
00156                           uInt maxPixels=1000000u, uInt minPerAxis=20u);
00157 
00158 
00159  protected:
00160 
00161   // Called by constructors: set up data for beam drawing, if applicable.
00162   virtual void SetUpBeamData_();
00163   
00164   
00165   // Will draw the beam ellipse if applicable (i.e., the LatticePADD
00166   // has an image with beam data, beam drawing is turned on, and the
00167   // WC's CoordinateSystem is set to sky coordinates).
00168   virtual void drawBeamEllipse_(WorldCanvas* wc);
00169   
00170 
00171   
00172  private:
00173 
00174   // The base image cloned at construction.
00175   ImageInterface<T>* itsBaseImagePtr;
00176 
00177   // The base array cloned at construction.
00178   Array<T>* itsBaseArrayPtr;
00179 
00180   // The image histogram
00181   Record imageHistogram;
00182 
00183   // Whether to always calculate the histogram or not
00184   Bool calcHist;
00185   
00186   // The masked lattice, effectively referencing one of itsBaseImagePtr
00187   // or itsBaseArray, or some sub-region of said.
00188   MaskedLattice<T>* itsMaskedLatticePtr;
00189 
00190   // Says whether the destructor should delete itsMaskedLattice or not
00191   Bool itsDeleteMLPointer;
00192   
00193   // Object to use for calculating statistics.
00194   LatticeStatistics<Float>* itsLatticeStatisticsPtr;
00195 
00196   // Is itsLattice a SubImage?
00197   ImageRegion* itsRegionPtr;
00198 
00199   // OTF mask
00200   WCLELMask* itsMaskPtr;
00201 
00202   // The data unit
00203   Unit itsDataUnit;
00204 
00205   // the complex to real method
00206   Display::ComplexToRealMethod itsComplexToRealMethod;
00207 
00208   // storage for the display parameters
00209   String itsResample;
00210   String itsComplexMode;
00211 
00212   // beam-drawing state
00213   // </group>
00214   Bool hasBeam_;        //# means the following data were found in the Image.
00215   
00216   Double majoraxis_;    //# (Full) ellipse axis sizes.
00217   Double minoraxis_;
00218   String majorunit_;    //# units of above (should be angular
00219   String minorunit_;    //# (relative world sky coordinates).
00220   Double posangle_;     //# (0 is CS "North", 90(deg) is CS "East").
00221   String paunit_;       //# angular units of posangle_.
00222   
00223   DParameterChoice* beamOnOff_;         //# User-selectable parameters.
00224   DParameterChoice* beamStyle_;         //# "Outline", "Filled"
00225   DParameterChoice* beamColor_;
00226   DParameterRange<Int>* beamLineWidth_;
00227   DParameterRange<Float>* beamXCenter_;         //# 0=left edge, 1=right edge
00228   DParameterRange<Float>* beamYCenter_;         //# 0=bottom edge, 1=top edge
00229   // </group>
00230   
00231   
00232   
00233   // pointer to resampler
00234   WCResampleHandler *itsResampleHandler;
00235 
00236   // update itsLatticeStatistics
00237   void updateLatticeStatistics();
00238 
00239   // Update the histogram, and attach it to the supplied record 
00240   Bool updateHistogram(Record &rec, MaskedLattice<Complex> &pImage);
00241   Bool updateHistogram(Record &rec, ImageInterface<Float> &pImage);
00242   Bool updateHistogram(Record &rec, const Array<Complex>*);
00243   Bool updateHistogram(Record &rec, const Array<Float>*);
00244   
00245   WCLELMask* makeMask (const RecordInterface& mask);
00246   ImageRegion* makeRegion (const RecordInterface& region);
00247   Bool isMaskDifferent (WCLELMask*& pMask);
00248   Bool isRegionDifferent (ImageRegion*& pRegion);
00249 
00250    // Transfer preferences between CoordinateSystems
00251   Bool transferPreferences (CoordinateSystem& cSysInOut,
00252                              const CoordinateSystem& cSysIn) const;
00253 };
00254 
00255 
00256 } //# NAMESPACE CASA - END
00257 
00258 #ifndef AIPS_NO_TEMPLATE_SRC
00259 #include <display/DisplayDatas/LatticePADD.tcc>
00260 //#include <display/DisplayDatas/LatticePADD2.tcc>
00261 #endif //# AIPS_NO_TEMPLATE_SRC
00262 #endif

Generated on Thu Aug 27 21:08:43 2009 for NRAOCASA by  doxygen 1.5.1