casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LatticePADD.h
Go to the documentation of this file.
1 //# LatticePADD.h: Class for displaying lattices along principal axes
2 //# Copyright (C) 1998,1999,2000,2001,2002
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef TRIALDISPLAY_LATTICEPADD_H
29 #define TRIALDISPLAY_LATTICEPADD_H
30 
31 #include <casa/aips.h>
32 #include <casa/Quanta/Unit.h>
35 #include <casa/Containers/Record.h>
38 
39 namespace casacore{
40 
41  class IPosition;
42  class ImageRegion;
43  class WCLELMask;
44  template <class T> class Array;
45  template <class T> class Lattice;
46  template <class T> class MaskedLattice;
47  template <class T> class LatticeStatistics;
48 }
49 
50 namespace casa { //# NAMESPACE CASA - BEGIN
51 
52  class WCResampleHandler;
53  class WorldCanvas;
54 
55 // <summary>
56 // Partial implementation of PrincipalAxesDD for casacore::Lattice-based data.
57 // </summary>
58 //
59 // <synopsis>
60 // This class is a partial (ie. base) implementation of PrincipalAxesDD
61 // which adds methods particular to handling casacore::Lattice-based data.
62 // </synopsis>
63 
64  template <class T> class LatticePADisplayData : public PrincipalAxesDD {
65 
66  public:
67  // Constructors (no default)
68  //LatticePADisplayData();
69 
70  // casacore::Array-based constructors: >2d and 2d
71  // <group>
73  const casacore::uInt yAxis, const casacore::uInt mAxis,
74  const casacore::IPosition fixedPos);
76  const casacore::uInt yAxis);
77  // </group>
78 
79  // Image-based constructors: >2d and 2d
80  // <group>
81  LatticePADisplayData( std::shared_ptr<casacore::ImageInterface<T> > image, const casacore::uInt xAxis, const casacore::uInt yAxis, const casacore::uInt mAxis, const casacore::IPosition fixedPos, viewer::StatusSink *sink=0 );
82  LatticePADisplayData(std::shared_ptr<casacore::ImageInterface<T> > image, const casacore::uInt xAxis,
83  const casacore::uInt yAxis);
84  // </group>
85 
86  // Destructor
87  virtual ~LatticePADisplayData();
88 
89  // casacore::Format a string containing value information at the
90  // given world coordinate
92 
93  // required functions to help inherited "setup" amongst other things
94  virtual const casacore::IPosition dataShape() const;
95  virtual casacore::uInt dataDim() const;
96  virtual /*const*/ T dataValue(casacore::IPosition pos);
97  virtual const casacore::Unit dataUnit() const;
98 
99  // Pure virtual function from DisplayData...
101  return "image";
102  }
103  std::shared_ptr<casacore::ImageInterface<casacore::Float> > imageinterface( );
104 
105 
106  // left as pure virtual for implementation in concrete class
107  virtual void setupElements() = 0;
108  virtual void getMinAndMax();
109 
110  // return mask value at given position
111  virtual casacore::Bool maskValue(const casacore::IPosition &pos);
112 
113  // install the default options for this DisplayData
114  virtual void setDefaultOptions();
115 
116  // apply options stored in val to the DisplayData; return value
117  // true means a refresh is needed...
119 
120 
121 
122  // retrieve the current and default options and parameter types.
123  virtual casacore::Record getOptions( bool scrub=false ) const;
124 
125  // Return the class name of this DisplayData; useful mostly for
126  // debugging purposes, and perhaps future use in the glish widget
127  // interface.
128  virtual casacore::String className() const {
129  return casacore::String("LatticePADisplayData");
130  }
132  return itsBaseImagePtr ? itsBaseImagePtr->name( ) : "none available";
133  }
134 
136  return itsResampleHandler;
137  }
138 
139 
140 
142  return itsComplexToRealMethod;
143  }
145  itsComplexToRealMethod = method;
146  }
147 
148  virtual std::shared_ptr<casacore::MaskedLattice<T> > maskedLattice() {
149  return itsMaskedLatticePtr;
150  }
151 
152 
153  // Insert an array into a Record. The array is insert into a "value" field, eg
154  // somerecord.fieldname.value
156  virtual casacore::Bool insertFloat(casacore::Record& toGoInto, casacore::Float toInsert, const casacore::String fieldname);
157 
158  // Return the last calculated histogram
159  virtual casacore::Record getHist() const;
160 
161  // Return the brightness unit as a string
162  virtual casacore::String getBrightnessUnits() const;
163 
164  // Aids updateHistogram() by computing a stride to use for efficiency
165  // when computing histograms (could be used elsewhere too).
166  // casacore::Input parameter 'shape' is the shape of the original lattice or array.
167  // Return value indicates whether striding should be used; if so, the
168  // recommended stride is returned in the 'stride' parameter.
169  // maxPixels is the desired maximum number of elements in the sub-lattice
170  // that would result from using the returned stride (may be exceeded
171  // because of minPerAxis requirements, or in any case by a few percent).
172  // A stride greater than 1 will not be returned for an axis if it
173  // would make the length of that axis in the strided sub-lattice
174  // less than minPerAxis.
176  casacore::uInt maxPixels=1000000u, casacore::uInt minPerAxis=20u);
177 
178 
179  protected:
180 
181  // Called by constructors: set up data for beam drawing, if applicable.
182  virtual void SetUpBeamData_();
183 
184 
185  // Will draw the beam ellipse if applicable (i.e., the LatticePADD
186  // has an image with beam data, beam drawing is turned on, and the
187  // WC's casacore::CoordinateSystem is set to sky coordinates).
188  virtual void drawBeamEllipse_(WorldCanvas* wc);
189 
190 
191 
192  private:
193 
194  // The base image cloned at construction.
195  std::shared_ptr<casacore::ImageInterface<T> > itsBaseImagePtr;
196 
197  // The base array cloned at construction.
199 
200  // The image histogram
202 
203  // Whether to always calculate the histogram or not
205 
206  // The masked lattice, effectively referencing one of itsBaseImagePtr
207  // or itsBaseArray, or some sub-region of said.
208  std::shared_ptr<casacore::MaskedLattice<T> > itsMaskedLatticePtr;
209 
210  // Says whether the destructor should delete itsMaskedLattice or not
212 
213  // Object to use for calculating statistics.
215 
216  // Is itsLattice a casacore::SubImage?
218 
219  // OTF mask
221 
222  // The data unit
224 
225  // the complex to real method
227 
228  // storage for the display parameters
231 
232  // beam-drawing state
233  // </group>
234 
235  std::vector<std::vector<double> > beams_;
236  casacore::String majorunit_; //# units of above (should be angular
237  casacore::String minorunit_; //# (relative world sky coordinates).
238  casacore::String paunit_; //# angular units of posangle_.
239 
240  DParameterChoice* beamOnOff_; //# User-selectable parameters.
241  DParameterChoice* beamStyle_; //# "Outline", "Filled"
244  DParameterRange<casacore::Float>* beamXCenter_; //# 0=left edge, 1=right edge
245  DParameterRange<casacore::Float>* beamYCenter_; //# 0=bottom edge, 1=top edge
246  // </group>
247 
248 
249 
250  // pointer to resampler
251  WCResampleHandler *itsResampleHandler;
252 
253  // update itsLatticeStatistics
255 
256  // Update the histogram, and attach it to the supplied record
261 
266 
267  // Transfer preferences between CoordinateSystems
268  casacore::Bool transferPreferences (DisplayCoordinateSystem& cSysInOut,
269  const DisplayCoordinateSystem& cSysIn) const;
270 
271  // Delete temporary image data
272  void delTmpImage();
273  };
274 
275 
276 } //# NAMESPACE CASA - END
277 
278 #ifndef AIPS_NO_TEMPLATE_SRC
279 #include <display/DisplayDatas/LatticePADD.tcc>
280 //#include <display/DisplayDatas/LatticePADD2.tcc>
281 #endif //# AIPS_NO_TEMPLATE_SRC
282 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual Display::ComplexToRealMethod complexMode()
Definition: LatticePADD.h:141
casacore::ImageRegion * itsRegionPtr
Is itsLattice a casacore::SubImage?
Definition: LatticePADD.h:217
virtual casacore::Bool insertFloat(casacore::Record &toGoInto, casacore::Float toInsert, const casacore::String fieldname)
virtual casacore::Bool insertArray(casacore::Record &toGoInto, casacore::Vector< casacore::Float > toInsert, const casacore::String fieldname)
Insert an array into a Record.
casacore::Bool updateHistogram(casacore::Record &rec, casacore::MaskedLattice< casacore::Complex > &pImage)
Update the histogram, and attach it to the supplied record.
casacore::WCLELMask * itsMaskPtr
OTF mask.
Definition: LatticePADD.h:220
virtual casacore::String getBrightnessUnits() const
Return the brightness unit as a string.
DParameterChoice * beamColor_
Definition: LatticePADD.h:242
virtual T dataValue(casacore::IPosition pos)
virtual casacore::String showValue(const casacore::Vector< casacore::Double > &world)
casacore::Format a string containing value information at the given world coordinate ...
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
WCResampleHandler * itsResampleHandler
pointer to resampler
Definition: LatticePADD.h:246
virtual casacore::String className() const
Return the class name of this DisplayData; useful mostly for debugging purposes, and perhaps future u...
Definition: LatticePADD.h:128
virtual casacore::Record getOptions(bool scrub=false) const
retrieve the current and default options and parameter types.
casacore::String itsResample
storage for the display parameters
Definition: LatticePADD.h:229
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1886
casacore::Bool transferPreferences(DisplayCoordinateSystem &cSysInOut, const DisplayCoordinateSystem &cSysIn) const
Transfer preferences between CoordinateSystems.
virtual void getMinAndMax()
A templated, abstract base class for array-like objects with masks.
casacore::String majorunit_
Definition: LatticePADD.h:236
ComplexToRealMethod
WorldCanvas - what to do with complex data if it is presented to WorldCanvas::drawImage() ...
Definition: DisplayEnums.h:342
std::shared_ptr< casacore::MaskedLattice< T > > itsMaskedLatticePtr
The masked lattice, effectively referencing one of itsBaseImagePtr or itsBaseArray, or some sub-region of said.
Definition: LatticePADD.h:208
casacore::String description() const
Definition: LatticePADD.h:131
virtual void setComplexMode(Display::ComplexToRealMethod method)
Definition: LatticePADD.h:144
void delTmpImage()
Delete temporary image data.
casacore::String itsComplexMode
Definition: LatticePADD.h:230
virtual void drawBeamEllipse_(WorldCanvas *wc)
Will draw the beam ellipse if applicable (i.e., the LatticePADD has an image with beam data...
casacore::ImageRegion * makeRegion(const casacore::RecordInterface &region)
casacore::WCLELMask * makeMask(const casacore::RecordInterface &mask)
casacore::String dataType() const
Pure virtual function from DisplayData...
Definition: LatticePADD.h:100
virtual const casacore::Unit dataUnit() const
std::shared_ptr< casacore::ImageInterface< T > > itsBaseImagePtr
The base image cloned at construction.
Definition: LatticePADD.h:195
casacore::Bool isRegionDifferent(casacore::ImageRegion *&pRegion)
DParameterRange< casacore::Float > * beamXCenter_
Definition: LatticePADD.h:244
defines physical units
Definition: Unit.h:189
casacore::Array< T > * itsBaseArrayPtr
The base array cloned at construction.
Definition: LatticePADD.h:198
virtual casacore::Bool maskValue(const casacore::IPosition &pos)
return mask value at given position
A base class for astronomical images.
casacore::Unit itsDataUnit
The data unit.
Definition: LatticePADD.h:223
std::vector< std::vector< double > > beams_
Definition: LatticePADD.h:235
Class to define a mask as a LEL expression.
Definition: WCLELMask.h:92
Compute and display various statistics from a lattice.
Definition: LatticePADD.h:47
virtual casacore::uInt dataDim() const
virtual WCResampleHandler * resampleHandler()
Definition: LatticePADD.h:135
virtual void SetUpBeamData_()
Called by constructors: set up data for beam drawing, if applicable.
casacore::String minorunit_
Definition: LatticePADD.h:237
casacore::LatticeStatistics< casacore::Float > * itsLatticeStatisticsPtr
Object to use for calculating statistics.
Definition: LatticePADD.h:214
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool itsDeleteMLPointer
Says whether the destructor should delete itsMaskedLattice or not.
Definition: LatticePADD.h:211
virtual void setupElements()=0
left as pure virtual for implementation in concrete class
float Float
Definition: aipstype.h:54
DParameterChoice * beamOnOff_
Definition: LatticePADD.h:240
virtual void setDefaultOptions()
install the default options for this DisplayData
Display::ComplexToRealMethod itsComplexToRealMethod
the complex to real method
Definition: LatticePADD.h:226
DParameterRange< casacore::Float > * beamYCenter_
Definition: LatticePADD.h:245
void updateLatticeStatistics()
update itsLatticeStatistics
Implementation of DisplayParameter to store choice parameters.
casacore::Bool isMaskDifferent(casacore::WCLELMask *&pMask)
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
virtual const casacore::IPosition dataShape() const
required functions to help inherited &quot;setup&quot; amongst other things
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
LatticePADisplayData(casacore::Array< T > *array, const casacore::uInt xAxis, const casacore::uInt yAxis, const casacore::uInt mAxis, const casacore::IPosition fixedPos)
Constructors (no default) LatticePADisplayData();
casacore::Record imageHistogram
The image histogram.
Definition: LatticePADD.h:201
Base class for resampling data pixels to World/PixelCanvas pixels.
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
virtual ~LatticePADisplayData()
Destructor.
std::shared_ptr< casacore::ImageInterface< casacore::Float > > imageinterface()
Returns a pointer that should not be deleted...
DParameterRange< casacore::Int > * beamLineWidth_
Definition: LatticePADD.h:243
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual casacore::Bool setOptions(casacore::Record &rec, casacore::Record &recOut)
apply options stored in val to the DisplayData; return value true means a refresh is needed...
casacore::String paunit_
Definition: LatticePADD.h:238
DParameterChoice * beamStyle_
Definition: LatticePADD.h:241
Abstract base class for Record classes.
static casacore::Bool useStriding(const casacore::IPosition &shape, casacore::IPosition &stride, casacore::uInt maxPixels=1000000u, casacore::uInt minPerAxis=20u)
Aids updateHistogram() by computing a stride to use for efficiency when computing histograms (could b...
casacore::Bool calcHist
Whether to always calculate the histogram or not.
Definition: LatticePADD.h:204
unsigned int uInt
Definition: aipstype.h:51
virtual std::shared_ptr< casacore::MaskedLattice< T > > maskedLattice()
Definition: LatticePADD.h:148
virtual casacore::Record getHist() const
Return the last calculated histogram.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42