casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LatticeAsContour.h
Go to the documentation of this file.
1 //# LatticeAsContour.h: Class to display lattice objects as contoured images
2 //# Copyright (C) 1996,1997,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_LATTICEASCONTOUR_H
29 #define TRIALDISPLAY_LATTICEASCONTOUR_H
30 
31 //# aips includes:
32 #include <casa/aips.h>
33 
34 //# trial includes:
36 
37 //# display library includes:
40 
41 namespace casacore{
42 
43  template <class T> class Array;
44  class IPosition;
45  class Record;
46 }
47 
48 namespace casa { //# NAMESPACE CASA - BEGIN
49 
50 //# forwards:
51  template <class T> class LatticePADMContour;
52 
53 // <summary>Class to manage the drawing of contour maps of slices from AIPS++ Lattices</summary>
54 //
55 // <use visibility=export>
56 //
57 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
58 // </reviewed>
59 //
60 // <prerequisite>
61 // <li> <linkto class="LatticePADisplayData">LatticePADisplayData</linkto>
62 // <li> <linkto class="DisplayData">DisplayData</linkto>
63 // </prerequisite>
64 //
65 // <etymology>
66 // The purpose of this class is to draw "contour" maps of data that
67 // is "lattice"-based.
68 // </etymology>
69 //
70 // <synopsis>
71 // This class should be used to display contour maps---ie. line
72 // drawings connecting data points of equal intensity (or level)---of
73 // two-dimensional slices of data extracted from AIPS++ Lattices or
74 // Arrays having two or more dimensions. Thus, this is the class to
75 // use to display standard zeroth-order moment map contour overlays
76 // for use on Digitized Sky Survey images, for example.
77 //
78 // At construction, any axes in the data can be mapped to the X and Y
79 // axes of the display device (see the <linkto
80 // class="PrincipalAxesDD">PrincipalAxesDD</linkto> class). For data
81 // with more than two dimensions, a third axis in the dataset can be
82 // selected for generating a sequence of maps along: this is known
83 // as the "movie" axis. Animation (see the <linkto
84 // class="Animator">Animator</linkto> class) will cause different
85 // slices of the data to be selected from along this axis. After
86 // construction, the axis settings of a LatticeAsContour object can be
87 // modified at a later stage.
88 //
89 // The LatticeAsContour object supports a number of options which can
90 // be set or retrieved using the setOptions and getOptions functions.
91 // These functions simply accept a casacore::Record, which can be converted from
92 // a GlishRecord: this is done in the <linkto
93 // class="GTkDisplayData">GTkDisplayData</linkto> class. The options
94 // for the LatticeAsContour class are:
95 // <li> levels: a casacore::Vector<casacore::Float> (or casacore::Vector<casacore::Double>) of one or more
96 // elements, being the data
97 // values at which the contours are drawn. Depending on type,
98 // the values in the vector are interpreted as absolute or
99 // fractions between the data minimum and maximum.
100 // <li> type: a casacore::String, one of "frac" or "abs", indicating whether the
101 // contour values in "levels" (multiplied by "scale") are fractions of the
102 // data range between the minimum and maximum, or are instead absolute
103 // contour levels in the native units of the data.
104 // <li> scale: a casacore::Float or casacore::Double which provides an additional scale
105 // factor to apply to the contour levels in "levels."
106 // <li> line: a positive Integer specifying the line width of
107 // contours.
108 // <li> dashneg: a Boolean value, which if true, will force contours
109 // at negative data values to be drawn in dashed line style.
110 // <li> dashpos: a Boolean value, which if true, will force contours
111 // at positive data values to be drawn in dashed line style.
112 // <li> color: a casacore::String which is the color with which to draw the
113 // contours. A valid X Color is required.
114 //# <li> complexmode: this is a casacore::String, and is only relevant for
115 //# LatticeAsContour<casacore::Complex> or LatticeAsContour<casacore::DComplex>
116 //# instantantiations. One of "phase", "real", "imaginary" or
117 //# "magnitude" is appropriate for this option, and indicates how
118 //# complex data values should be translated to real pixel values.
119 //#
120 //# LatticeAsContour is templated, and can be used to draw casacore::Complex or Real
121 //# Images or Arrays. For casacore::Complex data, the default complexmode is
122 //# "magnitude."
123 //# </synopsis>
124 //
125 // <example>
126 // A LatticeAsContour object could be constructed and used as follows:
127 // <srcblock>
128 // casacore::PagedImage<casacore::Float> *pimage = new casacore::PagedImage<casacore::Float>(casacore::String("test.im"));
129 // DisplayData *dd;
130 // casacore::uInt ndim = pimage->ndim();
131 // if (ndim < 2) {
132 // throw(casacore::AipsError(casacore::String("Image has less than two dimensions")));
133 // } else if (ndim == 2) {
134 // dd = (DisplayData *)(new LatticeAsContour<casacore::Float>(pimage, 0, 1));
135 // } else {
136 // casacore::IPosition fixedPos(ndim);
137 // fixedPos = 0;
138 // dd = (DisplayData *)(new LatticeAsContour<casacore::Float>(pimage, 0, 1, 2,
139 // fixedPos));
140 // }
141 // // wcHolder is an existing WorldCanvasHolder *...
142 // wcHolder->addDisplayData(ddata);
143 // wcHolder->refresh();
144 // </srcblock>
145 // </example>
146 //
147 // <motivation>
148 // Displaying 2-dimensional slices of a lattice-based data volume is
149 // a standard display requirement for astronomical data visualization
150 // and presentation.
151 // </motivation>
152 //
153 // <templating arg=T>
154 // </templating>
155 //
156 // <thrown>
157 // </thrown>
158 //
159 // <todo asof="yyyy/mm/dd">
160 // </todo>
161 
162  template <class T> class LatticeAsContour : public LatticePADisplayData<T> {
163 
164  public:
165 
166  // casacore::Array-based constructors: >2d and 2d. xAxis and yAxis specify
167  // which axis in the array (0-based) should be mapped to X and Y
168  // on the display device: ie. 2-d slices of the data to be displayed
169  // have these axes. mAxis specifies the "movie" axis, which is the axis
170  // along which different slices are taken. fixedPos is an IPosition
171  // having the same length as the number of dimensions in the array,
172  // and indicate the fixed axis values for axes in the data that are
173  // not specified as xAxis, yAxis or mAxis.
174  // <group>
176  const casacore::uInt yAxis, const casacore::uInt mAxis,
177  const casacore::IPosition fixedPos);
179  const casacore::uInt yAxis);
180  // </group>
181 
182  // Image-based constructors: >2d and 2d. xAxis and yAxis specify
183  // which axis in the image (0-based) should be mapped to X and Y
184  // on the display device: ie. 2-d slices of the data to be displayed
185  // have these axes. mAxis specifies the "movie" axis, which is the axis
186  // along which different slices are taken. fixedPos is an IPosition
187  // having the same length as the number of dimensions in the image,
188  // and indicate the fixed axis values for axes in the data that are
189  // not specified as xAxis, yAxis or mAxis.
190  // <group>
191  LatticeAsContour(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 );
192  LatticeAsContour(std::shared_ptr<casacore::ImageInterface<T> > image, const casacore::uInt xAxis,
193  const casacore::uInt yAxis);
194  // </group>
195 
196  // Destructor
197  virtual ~LatticeAsContour();
198 
199  // Create the various elements in the sequence of displayable
200  // maps. This is called upon construction as well as whenever
201  // the display and/or movie axes are changed via a call to
202  // PrincipalAxesDD::setAxes.
203  //virtual void setupElements(casacore::IPosition fixedPos = casacore::IPosition(2));
204  virtual void setupElements();
205 
206  // install the default options for display
207  virtual void setDefaultOptions();
208 
209  // Apply the options stored in the provided casacore::Record to the
210  // LatticeAsContour object. If the return value is true, then
211  // some options have changed, and a refresh is needed to update
212  // the display.
214 
215  // Retrieve the currently set options, and their types, default
216  // values, and any help text associated with each parameter. This
217  // information can be used to generate form-type graphical user
218  // interfaces or command-line interfaces to set the options with
219  // prompts.
220  virtual casacore::Record getOptions( bool scrub=false ) const;
221 
222  // Return the DisplayData type; used by the WorldCanvasHolder to
223  // determine the order of drawing.
225  return Display::Vector;
226  }
227 
228  // class name
229  virtual casacore::String className() const {
230  return casacore::String("LatticeAsContour");
231  }
232 
233  // Actual selected contour levels
235 
236  // Actual levels, in casacore::String format. If precision is unspecified,
237  // one that is low enough not to be cluttered is used.
239 
240  // Adds contour level information to the standard position tracking
241  // string from PADD.
243  const casacore::Bool &dsp);
244 
246 
247 
248  protected:
249 
250  // Construct user option DisplayParameters (for min/max contour.)
251  // (To be used by constructors only.)
252  virtual void constructParameters_();
253 
254  // Set standard limits/values for contour sliders. If recOut is provided,
255  // they will be set onto it in a manner suitable for updating gui via
256  // setOptions.
257  virtual void setStdContourLimits_(casacore::Record* recOut=0);
258 
259 
260  private:
261 
262  // Relative contour levels.
264 
265  // Min and Max actual contours. linearly scaled from itsLevels to fit these.
266  // <group>
269  // </group>
270 
275 
276  friend class LatticePADMContour<T>;
277 
278  //# Make parent members known.
279  public:
289 
290  protected:
294  };
295 
296 
297 } //# NAMESPACE CASA - END
298 
299 #ifndef AIPS_NO_TEMPLATE_SRC
300 #include <display/DisplayDatas/LatticeAsContour.tcc>
301 #endif //# AIPS_NO_TEMPLATE_SRC
302 #endif
virtual void setupElements()
Create the various elements in the sequence of displayable maps.
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
int Int
Definition: aipstype.h:50
casacore::String itsColor
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
DisplayDataType
WorldCanvasHolder - what type of DisplayData is this, need to know for drawing order.
Definition: DisplayEnums.h:355
virtual casacore::Bool setOptions(casacore::Record &rec, casacore::Record &recOut)
Apply the options stored in the provided casacore::Record to the LatticeAsContour object...
DParameterRange< casacore::Float > * itsUnitContour
virtual casacore::Record getOptions(bool scrub=false) const
Retrieve the currently set options, and their types, default values, and any help text associated wit...
virtual Display::DisplayDataType classType()
Return the DisplayData type; used by the WorldCanvasHolder to determine the order of drawing...
A base class for astronomical images.
virtual casacore::Vector< casacore::Float > levels()
Actual selected contour levels.
DParameterRange< casacore::Float > * itsBaseContour
Min and Max actual contours.
casacore::Vector< casacore::Float > itsLevels
Relative contour levels.
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type...
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
float Float
Definition: aipstype.h:54
Partial implementation of PrincipalAxesDD for casacore::Lattice-based data.
virtual casacore::String className() const
class name
virtual casacore::String showPosition(const casacore::Vector< casacore::Double > &wld, const casacore::Bool &abs, const casacore::Bool &dsp)
Adds contour level information to the standard position tracking string from PADD.
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
virtual ~LatticeAsContour()
Destructor.
virtual void constructParameters_()
Construct user option DisplayParameters (for min/max contour.) (To be used by constructors only...
virtual void setDefaultOptions()
install the default options for display
casacore::Vector data - can go next
Definition: DisplayEnums.h:359
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void setStdContourLimits_(casacore::Record *recOut=0)
Set standard limits/values for contour sliders.
virtual casacore::String levelString(casacore::Int prec=0)
Actual levels, in casacore::String format.
Class to draw a single contour map of a slice from an AIPS++ Lattice.
LatticeAsContour(casacore::Array< T > *array, const casacore::uInt xAxis, const casacore::uInt yAxis, const casacore::uInt mAxis, const casacore::IPosition fixedPos)
casacore::Array-based constructors: &gt;2d and 2d.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42