casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WCDataScaleHandler.h
Go to the documentation of this file.
1 //# WCDataScaleHandler.h: class offering simple data scaling for WorldCanvases
2 //# Copyright (C) 1993,1994,1995,1996,1998,1999,2000,2001
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_WCDATASCALEHANDLER_H
29 #define TRIALDISPLAY_WCDATASCALEHANDLER_H
30 
31 #include <casa/aips.h>
32 #include <casa/Containers/Record.h>
34 
35 namespace casacore{
36 
37  template <class T> class Array;
38 }
39 
40 namespace casa { //# NAMESPACE CASA - BEGIN
41 
42 
43 // <summary>
44 // Class implementing simple data scaling for the WorldCanvas.
45 // </summary>
46 //
47 // <prerequisite>
48 // <li> Understanding of pseudocolor display of single-channel graphic
49 // primitives.
50 // </prerequisite>
51 //
52 // <etymology>
53 // WCDataScaleHandler : WorldCanvas casacore::Data Scale Handler
54 //
55 // This class is responsible for scaling data into a range suitable
56 // for display.
57 // </etymology>
58 //
59 // <synopsis>
60 // WCDataScaleHandler defines a set of functions whose purpose is to
61 // transform real data values, such as those from raster images or
62 // contour lines, into an image whose value ranges from 0 to N-1 for
63 // some N, normally taken to be the color resolution available for display.
64 //
65 // The Display library defines the following process of image display:
66 // <ol>
67 // <li> fitting of images to display
68 // (<linkto class="WCResampleHandler">WCResampleHandler</linkto>)
69 // <li> transformation of values from real values to discrete values
70 // in the range of [0,N-1], where N is the output color resolution.
71 // (<linkto class="WCDataScaleHandler">WCDataScaleHandler</linkto>)
72 // <li> translating [0,N-1] into color indicies
73 // (<linkto class="PixelCanvas">PixelCanvas</linkto>'s mapToColor() function)
74 // </ol>
75 //
76 // The function suite includes all the normal scalar types. Default
77 // implementations exist for
78 // <ul>
79 // <li>casacore::Bool version which maps false to 0 and true to N-1
80 // <li>casacore::Complex version which extracts magnitude and forwards the
81 // call to the casacore::Float version.
82 // <li>casacore::DComplex version which extracts magnitude and forwards the
83 // call to the casacore::Double version.
84 // </ul>
85 //
86 // Each scalar implementation must scale the data according to the
87 // domain minimum and maximum values and the N-1 value called the
88 // rangeMax.
89 //
90 // This class would idealy be implemented by a templated member function, but
91 // C++ does not yet support templated member functions in non-templated
92 // classes. Thus the manual expansion-by-type.
93 // </synopsis>
94 //
95 // <motivation>
96 // Wanted a way for users to customize the scaling process from
97 // real values to discrete values for color display.
98 // </motivation>
99 //
100 // <example>
101 // see <linkto class="WCLinearScaleHandler">WCLinearScaleHandler</linkto>
102 // </example>
103 //
104 // <todo>
105 // <li> add ComplexToRealMethod field to base class to allow
106 // for extracting values other than magnitude for casacore::Complex and DComplex
107 // variables.
108 // <li> consider changing Matrices to Arrays to support a casacore::Vector of
109 // transformations.
110 // </todo>
111 //
112 
114 
115  public:
116 
117  // Default Constructor Required
119 
120  // Destructor (does nothing)
121  virtual ~WCDataScaleHandler();
122 
123  // Set min/max at construction time
125 
126  // op() returns true if the casacore::Array in was converted to the
127  // casacore::Array out successfully. Default implentation for Bool
128  // maps false to 0 and true to rangeMax
129  //
130  // Types casacore::uChar to casacore::Double not implemented (They return false).
131  // User should override the types needed (or perhaps all
132  // depending on your compiler.
133  //
134  // Default casacore::Complex and casacore::DComplex extract amplitude and call
135  // the casacore::Float or casacore::Double version.
136  // <group>
150  // </group>
151 
152  // set/get the min/max to use for the input Array
153  // <group>
155  return domainMin_;
156  }
158  return domainMax_;
159  }
161  // </group>
162 
163  // set/get the maximum value to use for the output array
164  // Note: the minimum value is always zero
165  // <group>
167  return rangeMax_;
168  }
170  rangeMax_ = max;
171  }
172  // </group>
173 
174  // install the default options for this DisplayData
175  virtual void setDefaultOptions();
176 
177  // apply options stored in val to the DisplayData; return value
178  // true means a refresh is needed...
180 
181  // retrieve the current and default options and parameter types.
182  virtual casacore::Record getOptions( bool scrub=false ) const;
183 
184  private:
185 
186  // domain limits to use
189 
190  // range limits
191  // rangeMin is always zero
193 
194  };
195 
196 
197 } //# NAMESPACE CASA - END
198 
199 #endif
Class to provide option parsing routines for display classes.
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...
#define max(a, b)
Definition: hio.h:44
#define min(a, b)
Definition: hio.h:45
casacore::uInt rangeMax_
range limits rangeMin is always zero
virtual casacore::Record getOptions(bool scrub=false) const
retrieve the current and default options and parameter types.
void setDomainMinMax(casacore::Double min, casacore::Double max)
void setRangeMax(casacore::uInt max)
WCDataScaleHandler()
Default Constructor Required.
double Double
Definition: aipstype.h:55
casacore::Double domainMin_
domain limits to use
virtual casacore::Bool operator()(casacore::Array< casacore::uInt > &out, const casacore::Array< casacore::Bool > &in)
op() returns true if the casacore::Array in was converted to the casacore::Array out successfully...
virtual ~WCDataScaleHandler()
Destructor (does nothing)
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
virtual void setDefaultOptions()
install the default options for this DisplayData
casacore::uInt rangeMax() const
set/get the maximum value to use for the output array Note: the minimum value is always zero ...
casacore::Double domainMax() const
casacore::Double domainMin() const
set/get the min/max to use for the input Array
unsigned int uInt
Definition: aipstype.h:51
Class implementing simple data scaling for the WorldCanvas.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42