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( SHARED_PTR<ImageInterface<T> > image, const uInt xAxis, const uInt yAxis, const uInt mAxis, const IPosition fixedPos, viewer::StatusSink *sink=0 );
00078                 LatticePADisplayData(SHARED_PTR<ImageInterface<T> > image, const uInt xAxis,
00079                                      const uInt yAxis);
00080                 // </group>
00081 
00082                 // Destructor
00083                 virtual ~LatticePADisplayData();
00084 
00085                 // Format a string containing value information at the
00086                 // given world coordinate
00087                 virtual String showValue(const Vector<Double> &world);
00088 
00089                 // required functions to help inherited "setup" amongst other things
00090                 virtual const IPosition dataShape() const;
00091                 virtual uInt dataDim() const;
00092                 virtual /*const*/ T dataValue(IPosition pos);
00093                 virtual const Unit dataUnit() const;
00094 
00095                 // Pure virtual function from DisplayData...
00096                 String dataType() const {
00097                         return "image";
00098                 }
00099                 // Get image analyis about object...
00100                 virtual ImageAnalysis *imageanalysis( ) const;
00101                 SHARED_PTR<ImageInterface<Float> > imageinterface( );
00102 
00103 
00104                 // left as pure virtual for implementation in concrete class
00105                 virtual void setupElements() = 0;
00106                 virtual void getMinAndMax();
00107 
00108                 // return mask value at given position
00109                 virtual Bool maskValue(const IPosition &pos);
00110 
00111                 // install the default options for this DisplayData
00112                 virtual void setDefaultOptions();
00113 
00114                 // apply options stored in val to the DisplayData; return value
00115                 // True means a refresh is needed...
00116                 virtual Bool setOptions(Record &rec, Record &recOut);
00117 
00118 
00119 
00120                 // retrieve the current and default options and parameter types.
00121                 virtual Record getOptions( bool scrub=false ) const;
00122 
00123                 // Return the class name of this DisplayData; useful mostly for
00124                 // debugging purposes, and perhaps future use in the glish widget
00125                 // interface.
00126                 virtual String className() const {
00127                         return String("LatticePADisplayData");
00128                 }
00129                 String description( ) const {
00130                         return itsBaseImagePtr ? itsBaseImagePtr->name( ) : "none available";
00131                 }
00132 
00133                 virtual WCResampleHandler *resampleHandler() {
00134                         return itsResampleHandler;
00135                 }
00136 
00137 
00138 
00139                 virtual Display::ComplexToRealMethod complexMode() {
00140                         return itsComplexToRealMethod;
00141                 }
00142                 virtual void setComplexMode(Display::ComplexToRealMethod method) {
00143                         itsComplexToRealMethod = method;
00144                 }
00145 
00146                 virtual SHARED_PTR<MaskedLattice<T> > maskedLattice() {
00147                         return itsMaskedLatticePtr;
00148                 }
00149 
00150 
00151                 // Insert an array into a Record. The array is insert into a "value" field, eg
00152                 // somerecord.fieldname.value
00153                 virtual Bool insertArray(Record& toGoInto, Vector<Float> toInsert, const String fieldname);
00154                 virtual Bool insertFloat(Record& toGoInto, Float toInsert, const String fieldname);
00155 
00156                 // Return the last calculated histogram
00157                 virtual Record getHist() const;
00158 
00159                 // Return the brightness unit as a string
00160                 virtual String getBrightnessUnits() const;
00161 
00162                 // Aids updateHistogram() by computing a stride to use for efficiency
00163                 // when computing histograms (could be used elsewhere too).
00164                 // Input parameter 'shape' is the shape of the original lattice or array.
00165                 // Return value indicates whether striding should be used; if so, the
00166                 // recommended stride is returned in the 'stride' parameter.
00167                 // maxPixels is the desired maximum number of elements in the sub-lattice
00168                 // that would result from using the returned stride (may be exceeded
00169                 // because of minPerAxis requirements, or in any case by a few percent).
00170                 // A stride greater than 1 will not be returned for an axis if it
00171                 // would make the length of that axis in the strided sub-lattice
00172                 // less than minPerAxis.
00173                 static Bool useStriding(const IPosition& shape, IPosition& stride,
00174                                         uInt maxPixels=1000000u, uInt minPerAxis=20u);
00175 
00176 
00177         protected:
00178 
00179                 // Called by constructors: set up data for beam drawing, if applicable.
00180                 virtual void SetUpBeamData_();
00181 
00182 
00183                 // Will draw the beam ellipse if applicable (i.e., the LatticePADD
00184                 // has an image with beam data, beam drawing is turned on, and the
00185                 // WC's CoordinateSystem is set to sky coordinates).
00186                 virtual void drawBeamEllipse_(WorldCanvas* wc);
00187 
00188 
00189 
00190         private:
00191 
00192                 // The base image cloned at construction.
00193                 SHARED_PTR<ImageInterface<T> > itsBaseImagePtr;
00194 
00195                 // The base array cloned at construction.
00196                 Array<T>* itsBaseArrayPtr;
00197 
00198                 // The image histogram
00199                 Record imageHistogram;
00200 
00201                 // Whether to always calculate the histogram or not
00202                 Bool calcHist;
00203 
00204                 // The masked lattice, effectively referencing one of itsBaseImagePtr
00205                 // or itsBaseArray, or some sub-region of said.
00206                 SHARED_PTR<MaskedLattice<T> > itsMaskedLatticePtr;
00207 
00208                 // Says whether the destructor should delete itsMaskedLattice or not
00209                 Bool itsDeleteMLPointer;
00210 
00211                 // Object to use for calculating statistics.
00212                 LatticeStatistics<Float>* itsLatticeStatisticsPtr;
00213 
00214                 // Is itsLattice a SubImage?
00215                 ImageRegion* itsRegionPtr;
00216 
00217                 // OTF mask
00218                 WCLELMask* itsMaskPtr;
00219 
00220                 // The data unit
00221                 Unit itsDataUnit;
00222 
00223                 // the complex to real method
00224                 Display::ComplexToRealMethod itsComplexToRealMethod;
00225 
00226                 // storage for the display parameters
00227                 String itsResample;
00228                 String itsComplexMode;
00229 
00230                 // beam-drawing state
00231                 // </group>
00232 
00233                 std::vector<std::vector<double> > beams_;
00234                 String majorunit_;      //# units of above (should be angular
00235                 String minorunit_;      //# (relative world sky coordinates).
00236                 String paunit_; //# angular units of posangle_.
00237 
00238                 DParameterChoice* beamOnOff_;           //# User-selectable parameters.
00239                 DParameterChoice* beamStyle_;           //# "Outline", "Filled"
00240                 DParameterChoice* beamColor_;
00241                 DParameterRange<Int>* beamLineWidth_;
00242                 DParameterRange<Float>* beamXCenter_;           //# 0=left edge, 1=right edge
00243                 DParameterRange<Float>* beamYCenter_;           //# 0=bottom edge, 1=top edge
00244                 // </group>
00245 
00246 
00247 
00248                 // pointer to resampler
00249                 WCResampleHandler *itsResampleHandler;
00250 
00251                 // update itsLatticeStatistics
00252                 void updateLatticeStatistics();
00253 
00254                 // Update the histogram, and attach it to the supplied record
00255                 Bool updateHistogram(Record &rec, MaskedLattice<Complex> &pImage);
00256                 Bool updateHistogram(Record &rec, ImageInterface<Float> &pImage);
00257                 Bool updateHistogram(Record &rec, const Array<Complex>*);
00258                 Bool updateHistogram(Record &rec, const Array<Float>*);
00259 
00260                 WCLELMask* makeMask (const RecordInterface& mask);
00261                 ImageRegion* makeRegion (const RecordInterface& region);
00262                 Bool isMaskDifferent (WCLELMask*& pMask);
00263                 Bool isRegionDifferent (ImageRegion*& pRegion);
00264 
00265                 // Transfer preferences between CoordinateSystems
00266                 Bool transferPreferences (DisplayCoordinateSystem& cSysInOut,
00267                                           const DisplayCoordinateSystem& cSysIn) const;
00268 
00269                 // Delete temporary image data
00270                 void delTmpImage();
00271         };
00272 
00273 
00274 } //# NAMESPACE CASA - END
00275 
00276 #ifndef AIPS_NO_TEMPLATE_SRC
00277 #include <display/DisplayDatas/LatticePADD.tcc>
00278 //#include <display/DisplayDatas/LatticePADD2.tcc>
00279 #endif //# AIPS_NO_TEMPLATE_SRC
00280 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1