casa
$Rev:20696$
|
00001 //# WCDataScaleHandler.h: class offering simple data scaling for WorldCanvases 00002 //# Copyright (C) 1993,1994,1995,1996,1998,1999,2000,2001 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_WCDATASCALEHANDLER_H 00029 #define TRIALDISPLAY_WCDATASCALEHANDLER_H 00030 00031 #include <casa/aips.h> 00032 #include <casa/Containers/Record.h> 00033 #include <display/Utilities/DisplayOptions.h> 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 template <class T> class Array; 00038 00039 // <summary> 00040 // Class implementing simple data scaling for the WorldCanvas. 00041 // </summary> 00042 // 00043 // <prerequisite> 00044 // <li> Understanding of pseudocolor display of single-channel graphic 00045 // primitives. 00046 // </prerequisite> 00047 // 00048 // <etymology> 00049 // WCDataScaleHandler : WorldCanvas Data Scale Handler 00050 // 00051 // This class is responsible for scaling data into a range suitable 00052 // for display. 00053 // </etymology> 00054 // 00055 // <synopsis> 00056 // WCDataScaleHandler defines a set of functions whose purpose is to 00057 // transform real data values, such as those from raster images or 00058 // contour lines, into an image whose value ranges from 0 to N-1 for 00059 // some N, normally taken to be the color resolution available for display. 00060 // 00061 // The Display library defines the following process of image display: 00062 // <ol> 00063 // <li> fitting of images to display 00064 // (<linkto class="WCResampleHandler">WCResampleHandler</linkto>) 00065 // <li> transformation of values from real values to discrete values 00066 // in the range of [0,N-1], where N is the output color resolution. 00067 // (<linkto class="WCDataScaleHandler">WCDataScaleHandler</linkto>) 00068 // <li> translating [0,N-1] into color indicies 00069 // (<linkto class="PixelCanvas">PixelCanvas</linkto>'s mapToColor() function) 00070 // </ol> 00071 // 00072 // The function suite includes all the normal scalar types. Default 00073 // implementations exist for 00074 // <ul> 00075 // <li>Bool version which maps False to 0 and True to N-1 00076 // <li>Complex version which extracts magnitude and forwards the 00077 // call to the Float version. 00078 // <li>DComplex version which extracts magnitude and forwards the 00079 // call to the Double version. 00080 // </ul> 00081 // 00082 // Each scalar implementation must scale the data according to the 00083 // domain minimum and maximum values and the N-1 value called the 00084 // rangeMax. 00085 // 00086 // This class would idealy be implemented by a templated member function, but 00087 // C++ does not yet support templated member functions in non-templated 00088 // classes. Thus the manual expansion-by-type. 00089 // </synopsis> 00090 // 00091 // <motivation> 00092 // Wanted a way for users to customize the scaling process from 00093 // real values to discrete values for color display. 00094 // </motivation> 00095 // 00096 // <example> 00097 // see <linkto class="WCLinearScaleHandler">WCLinearScaleHandler</linkto> 00098 // </example> 00099 // 00100 // <todo> 00101 // <li> add ComplexToRealMethod field to base class to allow 00102 // for extracting values other than magnitude for Complex and DComplex 00103 // variables. 00104 // <li> consider changing Matrices to Arrays to support a Vector of 00105 // transformations. 00106 // </todo> 00107 // 00108 00109 class WCDataScaleHandler : public DisplayOptions { 00110 00111 public: 00112 00113 // Default Constructor Required 00114 WCDataScaleHandler(); 00115 00116 // Destructor (does nothing) 00117 virtual ~WCDataScaleHandler(); 00118 00119 // Set min/max at construction time 00120 WCDataScaleHandler(Double min, Double max); 00121 00122 // op() returns True if the Array in was converted to the 00123 // Array out successfully. Default implentation for Bool 00124 // maps False to 0 and True to rangeMax 00125 // 00126 // Types uChar to Double not implemented (They return False). 00127 // User should override the types needed (or perhaps all 00128 // depending on your compiler. 00129 // 00130 // Default Complex and DComplex extract amplitude and call 00131 // the Float or Double version. 00132 // <group> 00133 virtual Bool operator()(Array<uInt> & out, const Array<Bool> & in); 00134 virtual Bool operator()(Array<uInt> & out, const Array<uChar> & in); 00135 virtual Bool operator()(Array<uInt> & out, const Array<Char> & in); 00136 virtual Bool operator()(Array<uInt> & out, const Array<uShort> & in); 00137 virtual Bool operator()(Array<uInt> & out, const Array<Short> & in); 00138 virtual Bool operator()(Array<uInt> & out, const Array<uInt> & in); 00139 virtual Bool operator()(Array<uInt> & out, const Array<Int> & in); 00140 virtual Bool operator()(Array<uInt> & out, const Array<uLong> & in); 00141 virtual Bool operator()(Array<uInt> & out, const Array<Long> & in); 00142 virtual Bool operator()(Array<uInt> & out, const Array<Float> & in); 00143 virtual Bool operator()(Array<uInt> & out, const Array<Double> & in); 00144 virtual Bool operator()(Array<uInt> & out, const Array<Complex> & in); 00145 virtual Bool operator()(Array<uInt> & out, const Array<DComplex> & in); 00146 // </group> 00147 00148 // set/get the min/max to use for the input Array 00149 // <group> 00150 Double domainMin() const { return domainMin_; } 00151 Double domainMax() const { return domainMax_; } 00152 void setDomainMinMax(Double min, Double max); 00153 // </group> 00154 00155 // set/get the maximum value to use for the output array 00156 // Note: the minimum value is always zero 00157 // <group> 00158 uInt rangeMax() const { return rangeMax_; } 00159 void setRangeMax(uInt max) { rangeMax_ = max; } 00160 // </group> 00161 00162 // install the default options for this DisplayData 00163 virtual void setDefaultOptions(); 00164 00165 // apply options stored in val to the DisplayData; return value 00166 // True means a refresh is needed... 00167 virtual Bool setOptions(Record &rec, Record &recOut); 00168 00169 // retrieve the current and default options and parameter types. 00170 virtual Record getOptions(); 00171 00172 private: 00173 00174 // domain limits to use 00175 Double domainMin_; 00176 Double domainMax_; 00177 00178 // range limits 00179 // rangeMin is always zero 00180 uInt rangeMax_; 00181 00182 }; 00183 00184 00185 } //# NAMESPACE CASA - END 00186 00187 #endif