casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LatticeAsRaster.h
Go to the documentation of this file.
1 //# LatticeAsRaster.h: Class to display lattice objects as rastered 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_LATTICEASRASTER_H
29 #define TRIALDISPLAY_LATTICEASRASTER_H
30 
31 #include <casa/aips.h>
33 #include <casa/Arrays/Array.h>
35 
36 namespace casacore{
37 
38  template <class T> class Array;
39  class IPosition;
40  class Record;
41 }
42 
43 namespace casa { //# NAMESPACE CASA - BEGIN
44 
45  template <class T> class LatticePADMRaster;
46  class WCPowerScaleHandler;
47 
48 // <summary>Class to manage the drawing of raster images of slices from AIPS++ Lattices</summary>
49 //
50 // <use visibility=export>
51 //
52 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
53 // </reviewed>
54 //
55 // <prerequisite>
56 // <li> <linkto class="LatticePADisplayData">LatticePADisplayData</linkto>
57 // <li> <linkto class="DisplayData">DisplayData</linkto>
58 // </prerequisite>
59 //
60 // <etymology>
61 // The purpose of this class is to draw "raster" images of data that
62 // is "lattice"-based.
63 // </etymology>
64 //
65 // <synopsis>
66 // This class should be used to display raster images--- ie. filled,
67 // pseudo-color pixel images where each screen (or device) pixel is
68 // shaded with a color from a look-up table that is assigned to be
69 // proportional in some way to the intensity of the data pixel---of
70 // two-dimensional slices of data extracted from AIPS++ Lattices or
71 // Arrays having two or more dimensions. Thus, this is the class to
72 // use to display standard channel maps of position-velocity cubes, or
73 // Digitized Sky Survey images, for example.
74 //
75 // At construction, any axes in the data can be mapped to the X and Y
76 // axes of the display device (see the <linkto
77 // class="PrincipalAxesDD">PrincipalAxesDD</linkto> class). For data
78 // with more than two dimensions, a third axis in the dataset can be
79 // selected for generating a sequence of images along: this is known
80 // as the "movie" axis. Animation (see the <linkto
81 // class="Animator">Animator</linkto> class) will cause different
82 // slices of the data to be selected from along this axis. After
83 // construction, the axis settings of a LatticeAsRaster object can be
84 // modified at a later stage.
85 //
86 // The LatticeAsRaster object supports a number of options which can
87 // be set or retrieved using the setOptions and getOptions functions.
88 // These functions simply accept a casacore::Record, which can be converted from
89 // a GlishRecord: this is done in the <linkto
90 // class="GTkDisplayData">GTkDisplayData</linkto> class. The options
91 // for the LatticeAsRaster class are:
92 // <li> range: a casacore::Vector<casacore::Double> of two elements, being the minimum and
93 // maximum data values to map to the minimum and maximum color values.
94 // <li> power: a casacore::Float which specifies the deviation from linear of
95 // the scaling of the data onto the colormap. Increasingly negative
96 // values give increasingly severe logarithmic scaling: this scaling
97 // effectively allocates more color cells to the lowest data values
98 // (usually corresponding to the thermal noise and low surface
99 // brightness emission) in the image. Increasing positive power
100 // values give increasingly severe exponential scaling, thereby
101 // allocating more and more color cells to the highest data values
102 // (ie. signal and interference)in the image.
103 // <li> resample: a casacore::String which is either "nearest" for nearest
104 // neighbour pixel resampling, or "bilinear" for bilinear
105 // interpolation between adjacent groups of four pixels.
106 // <li> complexmode: this is a casacore::String, and is only relevant for
107 // LatticeAsRaster<casacore::Complex> or LatticeAsRaster<casacore::DComplex>
108 // instantantiations. One of "phase", "real", "imaginary" or
109 // "magnitude" is appropriate for this option, and indicates how
110 // complex data values should be translated to real pixel values.
111 //
112 // LatticeAsRaster is templated, and can be used to draw casacore::Complex or Real
113 // Images or Arrays. For casacore::Complex data, the default complexmode is
114 // "magnitude." LatticeAsRaster objects can be registered on any
115 // WorldCanvasHolder, but will only draw on WorldCanvases having an
116 // attribute value of Display::Index for "colormodel."
117 // </synopsis>
118 //
119 // <example>
120 // A LatticeAsRaster object could be constructed and used as follows:
121 // <srcblock>
122 // casacore::PagedImage<casacore::Float> *pimage = new casacore::PagedImage<casacore::Float>(casacore::String("test.im"));
123 // DisplayData *dd;
124 // casacore::uInt ndim = pimage->ndim();
125 // if (ndim < 2) {
126 // throw(casacore::AipsError(casacore::String("Image has less than two dimensions")));
127 // } else if (ndim == 2) {
128 // dd = (DisplayData *)(new LatticeAsRaster<casacore::Float>(pimage, 0, 1));
129 // } else {
130 // casacore::IPosition fixedPos(ndim);
131 // fixedPos = 0;
132 // dd = (DisplayData *)(new LatticeAsRaster<casacore::Float>(pimage, 0, 1, 2,
133 // fixedPos));
134 // }
135 // // wcHolder is an existing WorldCanvasHolder *...
136 // wcHolder->addDisplayData(ddata);
137 // wcHolder->refresh();
138 // </srcblock>
139 // </example>
140 //
141 // <motivation>
142 // Displaying 2-dimensional slices of a lattice-based data volume is
143 // a standard display requirement for astronomical data visualization
144 // and presentation.
145 // </motivation>
146 //
147 // <templating arg=T>
148 // </templating>
149 //
150 // <thrown>
151 // </thrown>
152 //
153 // <todo asof="yyyy/mm/dd">
154 // </todo>
155 
156  template <class T> class LatticeAsRaster : public LatticePADisplayData<T> {
157 
158  public:
159 
160  // casacore::Array-based constructors: >2d and 2d. xAxis and yAxis specify
161  // which axis in the array (0-based) should be mapped to X and Y
162  // on the display device: ie. 2-d slices of the data to be displayed
163  // have these axes. mAxis specifies the "movie" axis, which is the axis
164  // along which different slices are taken. fixedPos is an IPosition
165  // having the same length as the number of dimensions in the array,
166  // and indicate the fixed axis values for axes in the data that are
167  // not specified as xAxis, yAxis or mAxis.
168  // <group>
170  const casacore::uInt yAxis, const casacore::uInt mAxis,
171  const casacore::IPosition fixedPos);
173  const casacore::uInt yAxis);
174  // </group>
175 
176  // Image-based constructors: >2d and 2d. xAxis and yAxis specify
177  // which axis in the image (0-based) should be mapped to X and Y
178  // on the display device: ie. 2-d slices of the data to be displayed
179  // have these axes. mAxis specifies the "movie" axis, which is the axis
180  // along which different slices are taken. fixedPos is an IPosition
181  // having the same length as the number of dimensions in the image,
182  // and indicate the fixed axis values for axes in the data that are
183  // not specified as xAxis, yAxis or mAxis.
184  // <group>
185  LatticeAsRaster( 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 );
186  LatticeAsRaster(std::shared_ptr<casacore::ImageInterface<T> > image, const casacore::uInt xAxis,
187  const casacore::uInt yAxis);
188  // </group>
189 
190  // Destructor
191  virtual ~LatticeAsRaster();
192 
193  // Create the various elements in the sequence of displayable
194  // images. This is called upon construction as well as whenever
195  // the display and/or movie axes are changed via a call to
196  // PrincipalAxesDD::setAxes.
197  //virtual void setupElements(casacore::IPosition fixedPos = casacore::IPosition(casacore::uInt(2)));
198  virtual void setupElements();
199 
200  // Install the default options for display.
201  virtual void setDefaultOptions();
202 
203  // Apply the options stored in the provided casacore::Record to the
204  // LatticeAsRaster object. If the return value is true, then
205  // some options have changed, and a refresh is needed to update
206  // the display.
208 
209  // Retrieve the currently set options, and their types, default
210  // values, and any help text associated with each parameter. This
211  // information can be used to generate form-type graphical user
212  // interfaces or command-line interfaces to set the options with
213  // prompts.
214  virtual casacore::Record getOptions( bool scrub=false ) const;
215  //static casacore::Record getGlobalOption();
216 
217  // Return the DisplayData type; used by the WorldCanvasHolder to
218  // determine the order of drawing.
220  return Display::Raster;
221  }
222 
223  // class name
224  virtual casacore::String className() const {
225  return casacore::String("LatticeAsRaster");
226  }
229 
230  private:
231 
232  // Storage for the data range parameters
235 
239 
240  //casacore::Float itsOptionsPower;
241 
242  // what colormode the raster should be drawn in, options are
243  // "colormap" for normal pseudo-color rasters, and "red", "green"
244  // and "blue" for RGB canvases, and "hue", "saturation" and "value"
245  // for HSV canvases.
247 
248  // pointers to scale and resampling handlers
250 
251  // allow the corresponding DisplayMethod to access this' private data.
252  friend class LatticePADMRaster<T>;
256  virtual void setDisplayDataRed( DisplayData* dd );
257  virtual void setDisplayDataBlue( DisplayData* dd );
258  virtual void setDisplayDataGreen( DisplayData* dd );
259  void initializeDataMatrix( int index,
261  const casacore::IPosition& sliceShape, const casacore::IPosition& stride );
262 
263  //static bool globalColors;
264 
265  //# Make parent members known.
266  public:
278  protected:
281  };
282 
283 
284 } //# NAMESPACE CASA - END
285 
286 #ifndef AIPS_NO_TEMPLATE_SRC
287 #include <display/DisplayDatas/LatticeAsRaster.tcc>
288 #endif //# AIPS_NO_TEMPLATE_SRC
289 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual Display::DisplayDataType classType()
static casacore::Record getGlobalOption();
virtual void setDisplayDataBlue(DisplayData *dd)
casacore::Vector< casacore::Float > itsOptionsDataRange
Storage for the data range parameters.
virtual ~LatticeAsRaster()
Destructor.
virtual casacore::String className() const
class name
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
void initializeDataMatrix(int index, casacore::Matrix< T > &datMatrix, casacore::Matrix< casacore::Bool > &mask, const casacore::IPosition &start, const casacore::IPosition &sliceShape, const casacore::IPosition &stride)
static const casacore::String HISTOGRAM_RANGE
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
casacore::String itsOptionsColorMode
casacore::Float itsOptionsPower;
virtual void setDisplayDataGreen(DisplayData *dd)
A 2-D Specialization of the Array class.
LatticeAsRaster< T > * getRasterRed()
WCPowerScaleHandler * itsPowerScaleHandler
pointers to scale and resampling handlers
static const casacore::String COLOR_MODE
LatticeAsRaster< T > * rasterBlue
LatticeAsRaster< T > * rasterGreen
LatticeAsRaster< T > * getRasterBlue()
A base class for astronomical images.
LatticeAsRaster< T > * rasterRed
Class to manage the drawing of raster images of slices from AIPS++ Lattices.
casacore::Vector< casacore::Float > itsOptionsDataDefault
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
Rastered data - should go first.
Definition: DisplayEnums.h:357
virtual void setDefaultOptions()
Install the default options for display.
virtual casacore::Bool setOptions(casacore::Record &rec, casacore::Record &recOut)
Apply the options stored in the provided casacore::Record to the LatticeAsRaster object.
Partial implementation of PrincipalAxesDD for casacore::Lattice-based data.
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
virtual void setDisplayDataRed(DisplayData *dd)
LatticeAsRaster< T > * getRasterGreen()
virtual casacore::Record getOptions(bool scrub=false) const
Retrieve the currently set options, and their types, default values, and any help text associated wit...
LatticeAsRaster(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.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Class to draw a raster image of a slice of an AIPS++ Lattice.
Base class for display objects.
Definition: DisplayData.h:317
Linear, logarithmic and exponential scaling of data for the WorldCanvas.
unsigned int uInt
Definition: aipstype.h:51
virtual void setupElements()
Create the various elements in the sequence of displayable images.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42