casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Colormap.h
Go to the documentation of this file.
1 //# Colormap.h: generating and selecting colors from a look-up map
2 //# Copyright (C) 1993,1994,1995,1996,1998,1999,2000,2002,2005
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_COLORMAP_H
29 #define TRIALDISPLAY_COLORMAP_H
30 
31 //# Includes
32 
33 #include <map>
34 #include <casa/aips.h>
36 #include <casa/BasicSL/String.h>
37 
38 namespace casacore{
39 
40  template <class T> class Vector;
41  template <class T, class U> class Function1D;
42  class LogIO;
43 }
44 
45 namespace casa { //# NAMESPACE CASA - BEGIN
46 
47 //# Forward declarations
48 
49  class ColormapDefinition;
50  class PixelCanvasColorTable;
51 
52 // <summary>
53 // Describes a method of generating a table of colors.
54 // </summary>
55 //
56 // <etymology>
57 // The name of Colormap comes from ...
58 // </etymology>
59 //
60 // <synopsis>
61 // A Colormap is a class which is capable of generating a table
62 // of colormaps for the ColormapManager. The Colormap's duties
63 // are to fill a casacore::Vector of colors of a specific size.
64 //
65 // A Colormap can operate in two modes:
66 // <ul>
67 // <li>Dynamic - The Colormap is treated as a function which
68 // can be arbitrarily descretized into some number of cells.
69 // <dd>Static - The Colormap is treated as a rigid table of colors and
70 // may not be resized by, for example, the ColormapManager.
71 //
72 // The Colormap generates colors by composing a ColormapShapeFunc
73 // with a ColormapDefinition to provide the colors for the
74 // ColormapManager.
75 //
76 // Typically the ColormapDefinition is selected from a menu,
77 // and the ColormapShapeFunc what is changed by a gui.
78 //
79 // The ColormapDefinition and ColormapShapeFunc may be derived from
80 // to provide specialized colortable treatment.
81 //
82 // </synopsis>
83 //
84 // <motivation>
85 // Needed to satisfy many simultaneous wishes:
86 // <ol>
87 // <li> Wanted to increase application portability by providing for
88 // dynamic resize of the colortable(s) used by the application.
89 // <li> Needed a way to specialize colormaps (e.g. Ron & Renzo map
90 // which requires knowledge of the dataset being viewed).
91 // <li> Needed a colormap to be sharable across multiple displays. This
92 // implies its existence can vary from colortable to colortable.
93 // </ol>
94 // </motivation>
95 //
96 // <example>
97 // see the Display test directory
98 // </example>
99 //
100 // <todo>
101 // </todo>
102 //
103 
104  class Colormap {
105 
106  public:
107 
108  // Default Constructor Required
109  Colormap();
110 
111  // User Constructor
112  explicit Colormap(const casacore::String& name);
113 
114  // Destructor.
115  virtual ~Colormap();
116 
117  // If rigid is true, the colormap must be installed at a
118  // specific size.
119  // <group>
121  return itsIsRigid;
122  }
124  itsIsRigid = b;
125  }
126  // </group>
127 
128  // What is the size enforced by the rigid requirement?
129  // <group>
131  const {
132  return itsRigidSize;
133  }
135  itsRigidSize = s;
136  }
137  // </group>
138 
139  // Compute RGB values using the definition and shape function
140  virtual casacore::Bool calcRGBMaps(casacore::uInt reqSize,
144  casacore::Vector<casacore::Float> & alphaMap) const;
145 
146  // return the name of the map
147  const casacore::String & name() const {
148  return itsName;
149  }
150  void setName( const casacore::String& mapName ) {
151  itsName = mapName;
152  }
153 
154  // Register/Unregister a PixelCanvasColorTable that uses this Colormap
155  // <group>
158  // </group>
159 
160  // set/get the colormap brightness level in range 0 to 1
161  // <group>
162  void setBrightness(const casacore::Float &brightness, const casacore::Bool &doReinstall = true);
164  return itsBrightness;
165  };
166  // </group>
167 
168  // set/get the colormap alpha level in range 0 to 1
169  // <group>
170  void setAlpha(const casacore::Float &brightness, const casacore::Bool &doReinstall = true);
172  return itsAlpha;
173  };
174  // </group>
175 
176  // set/get the colormap contrast level
177  // <group>
178  void setContrast(const casacore::Float &contrast, const casacore::Bool &doReinstall = true);
180  return itsContrast;
181  };
182  // </group>
183 
184  // set/get the inverse flags
185  // <group>
186  void setInvertFlags(const casacore::Bool &red, const casacore::Bool &green, const casacore::Bool &blue,
187  const casacore::Bool &doReinstall = true);
188  void getInvertFlags(casacore::Bool &red, casacore::Bool &green, casacore::Bool &blue) const;
189  // </group>
190 
191  // Set whether or not the colormap should use a log scale.
192  void setLogScale( const casacore::Int & logScale, const casacore::Bool & doReinstall = true);
193 
194  // Do resizeCallbacks on the PixelCanvasColorTables that use this
195  // Colormap
196  void doResizeCallbacks();
197 
198  // Set the Colormap shaping function. If the argument is 0, then
199  // resort to using the default shaping function, which happens to
200  // be a polynomial of order 1.
202 
203  // Set and retrieve the coefficients of the shaping function.
204  // <group>
206  const casacore::Bool &doReinstall = true);
208  // </group>
209 
210  // Write a Colormap to an ostream in a simple text form.
211  friend std::ostream & operator << (std::ostream & os, const Colormap & c);
212 
213  // Write a Colormap to an casacore::AipsIO stream in a binary format.
214  friend casacore::AipsIO &operator<<(casacore::AipsIO &aio, const Colormap & c);
215 
216  // Write a Colormap to a casacore::LogIO stream.
217  friend casacore::LogIO &operator<<(casacore::LogIO &lio, const Colormap & c);
218 
219  // Read a Colormap from an casacore::AipsIO stream in a binary format.
220  // Will throw an casacore::AipsError if the current Colormap Version does not match
221  // that of the one on disk.
223 
224  // Provide access to the colormap definition.
226  return itsColormapDefinition;
227  }
229 
230  protected:
231 
232  // reinstall this Colormap on the registered PixelCanvasColorTables
233  void reinstall();
234 
235  private:
236 
237  // name of this Colormap.
239 
240  // is this Colormap rigid?
242 
243  // what is its rigid size?
245  //Transparency
247 
248  // levels
251  // invert flags
254 
256 
257  // function for shaping the colormap
260 
261  std::map<PixelCanvasColorTable *, casacore::uInt> itsPCColorTables;
262 
263  enum { ColormapVersion = 1 };
264  };
265 
266 
267 } //# NAMESPACE CASA - END
268 
269 #endif
270 
271 
void setColormapDefinition(ColormapDefinition *definition)
casacore::Bool itsOwnShapingFunction
Definition: Colormap.h:259
int Int
Definition: aipstype.h:50
void setInvertFlags(const casacore::Bool &red, const casacore::Bool &green, const casacore::Bool &blue, const casacore::Bool &doReinstall=true)
set/get the inverse flags
virtual casacore::Bool calcRGBMaps(casacore::uInt reqSize, casacore::Vector< casacore::Float > &redMap, casacore::Vector< casacore::Float > &greenMap, casacore::Vector< casacore::Float > &blueMap, casacore::Vector< casacore::Float > &alphaMap) const
Compute RGB values using the definition and shape function.
std::vector< double > Vector
Definition: ds9context.h:24
Abstract interface to underlying graphics library&#39;s colortable.
const casacore::String & name() const
return the name of the map
Definition: Colormap.h:147
casacore::Float getContrast() const
Definition: Colormap.h:179
void doResizeCallbacks()
Do resizeCallbacks on the PixelCanvasColorTables that use this Colormap.
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
casacore::String itsName
name of this Colormap.
Definition: Colormap.h:238
casacore::Int itsLogScale
Definition: Colormap.h:253
casacore::Float itsContrastScale
Definition: Colormap.h:250
void registerPCColorTable(PixelCanvasColorTable *pcctbl)
Register/Unregister a PixelCanvasColorTable that uses this Colormap.
casacore::Bool rigid() const
If rigid is true, the colormap must be installed at a specific size.
Definition: Colormap.h:120
Colormap()
Default Constructor Required.
casacore::Float itsAlpha
Transparency.
Definition: Colormap.h:246
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::uInt rigidSize() const
What is the size enforced by the rigid requirement?
Definition: Colormap.h:130
casacore::Float getAlpha() const
Definition: Colormap.h:171
void getInvertFlags(casacore::Bool &red, casacore::Bool &green, casacore::Bool &blue) const
casacore::Bool itsInvertBlue
Definition: Colormap.h:252
void unregisterPCColorTable(PixelCanvasColorTable *pcctbl)
void reinstall()
reinstall this Colormap on the registered PixelCanvasColorTables
void setAlpha(const casacore::Float &brightness, const casacore::Bool &doReinstall=true)
set/get the colormap alpha level in range 0 to 1
void setRigid(casacore::Bool b)
Definition: Colormap.h:123
ColormapDefinition * itsColormapDefinition
Definition: Colormap.h:255
void setLogScale(const casacore::Int &logScale, const casacore::Bool &doReinstall=true)
Set whether or not the colormap should use a log scale.
casacore::uInt itsRigidSize
what is its rigid size?
Definition: Colormap.h:244
void setContrast(const casacore::Float &contrast, const casacore::Bool &doReinstall=true)
set/get the colormap contrast level
casacore::Bool itsInvertGreen
Definition: Colormap.h:252
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Function1D< casacore::Float, casacore::Float > * itsShapingFunction
function for shaping the colormap
Definition: Colormap.h:258
float Float
Definition: aipstype.h:54
casacore::Float itsBrightnessScale
Definition: Colormap.h:249
casacore::Float itsContrast
Definition: Colormap.h:250
casacore::Bool itsIsRigid
is this Colormap rigid?
Definition: Colormap.h:241
casacore::Float getBrightness() const
Definition: Colormap.h:163
virtual ~Colormap()
Destructor.
Describes a method of generating a table of colors.
Definition: Colormap.h:104
ColormapDefinition * definition()
Provide access to the colormap definition.
Definition: Colormap.h:225
casacore::Bool itsInvertRed
invert flags
Definition: Colormap.h:252
const Double c
Fundamental physical constants (SI units):
void setBrightness(const casacore::Float &brightness, const casacore::Bool &doReinstall=true)
set/get the colormap brightness level in range 0 to 1
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void setShapingFunction(casacore::Function1D< casacore::Float, casacore::Float > *shapingfunc=0)
Set the Colormap shaping function.
std::map< PixelCanvasColorTable *, casacore::uInt > itsPCColorTables
Definition: Colormap.h:261
void setName(const casacore::String &mapName)
Definition: Colormap.h:150
const casacore::Vector< casacore::Float > getShapingCoefficients() const
casacore::Float itsBrightness
levels
Definition: Colormap.h:249
friend casacore::AipsIO & operator>>(casacore::AipsIO &aio, Colormap &c)
Read a Colormap from an casacore::AipsIO stream in a binary format.
void setShapingCoefficients(const casacore::Vector< casacore::Float > &params, const casacore::Bool &doReinstall=true)
Set and retrieve the coefficients of the shaping function.
friend std::ostream & operator<<(std::ostream &os, const Colormap &c)
Write a Colormap to an ostream in a simple text form.
void setRigidSize(casacore::uInt s)
Definition: Colormap.h:134
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