casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ColormapManager.h
Go to the documentation of this file.
1 //# ColormapManager.h: dynamic mapping of Colormaps onto ColorTables
2 //# Copyright (C) 1994,1995,1996,1997,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_COLORMAPMANAGER_H
29 #define TRIALDISPLAY_COLORMAPMANAGER_H
30 
31 #include <map>
32 #include <casa/aips.h>
34 
35 //# Forward declarations
36 #include <casa/iosfwd.h>
37 namespace casa { //# NAMESPACE CASA - BEGIN
38 
39  class ColormapInfo;
40  class PixelCanvasColorTable;
41 
42 // <summary>
43 // Class to manage registration of colormaps on PixelCanvasColorTables
44 // </summary>
45 
46 // <use visibility=local>
47 
48 // <reviewed reviewer="None yet" date="yyyy/mm/dd" demos="">
49 // </reviewed>
50 
51 // <prerequisite>
52 // <li> <linkto class="Colormap">Colormap</linkto>
53 // <li> <linkto class="PixelCanvasColorTable">PixelCanvasColorTable</linkto>
54 // </prerequisite>
55 
56 // <etymology>
57 // This class manages a set of colormaps and dynamically maintains
58 // both their allocation on the colortable and the colortable's
59 // colors.
60 // </etymology>
61 
62 // <synopsis>
63 
64 // The colormap manager is a management tool which facilitates the
65 // dynamic mapping of 1 or more Colormaps to a single
66 // PixelCanvasColorTable.
67 //
68 // The colormap manager manages the assignment of data colormaps,
69 // which define the function that generates the color spectrum to use,
70 // to the hardware colormap which defines how many cells are
71 // available. As Colormaps are registerd and unregistered, the
72 // manager reorganizes the colors on the colormap and reinstalls the
73 // maps in response. The colormap manager also registers a resize
74 // callback with the pixel canvas colormap. This allows the
75 // application to resize the hardware colormap and have all colormaps
76 // adjusted as appropriate.
77 //
78 // The calling program can at any time ask for the size of a given
79 // colormap and use that size to map real-world values into a range
80 // appropriate for display (see the <linkto
81 // class="PixelCanvas">PixelCanvas</linkto> class' getColormapSize()
82 // and mapToColor() functions.
83 //
84 // Because the colormap manager can control the distribution of its
85 // Colormaps, application code must issue a call to redistribute if it
86 // decides to change the size of the colortable on its own.
87 // </synopsis>
88 
89 // <motivation>
90 // Needed to have tool available to help manage more than one colormap.
91 // </motivation>
92 
94 
95  public:
96 
97  // Constructor requires pointer to the PixelCanvasColorTable which it
98  // will manage.
100 
101  // Destructor.
102  virtual ~ColormapManager();
103 
104  // Register a Colormap with this ColormapManager, and optionally
105  // pass a weight - colormaps are distributed proportionally
106  // according to their weight.
107  void registerColormap(Colormap * dcmap, casacore::Float weight = 1.0);
108 
109  // Register the <src>cmap</src> Colormap with this manager,
110  // replacing the <src>cmapToReplace</src> Colormap if possible.
111  void registerColormap(Colormap *cmap, Colormap *cmapToReplace);
112 
113  // Unregister a Colormap with this ColormapManager.
115 
116  // Return the current size of the colormap.
117  casacore::uInt getColormapSize(const Colormap * map) const;
118 
119  // Return the current offset of the colormap.
120  casacore::uInt getColormapOffset(const Colormap * map) const;
121 
122  // Redistribute the available colorcells to the registered
123  // colormaps.
124  void redistributeColormaps();
125 
126  // Reinstall the colorcell values.
127  void reinstallColormaps();
128 
129  // Is the given Colormap registered on this
130  // ColormapManager/PixelCanvasColorTable combination?
131  casacore::Bool member(const Colormap * map) const;
132 
133  // Return the number of registered Colormaps.
135  return itsInfoMap.size( );
136  }
137 
138  // Return a pointer to a Colormap by number.
139  const Colormap *getMap(const casacore::uInt mapnum) const;
140 
141  // Stream output operator.
142  friend std::ostream & operator << (std::ostream & os, const ColormapManager & cm);
143 
144  private:
145 
146  // Pointer to managed PixelCanvasColorTable.
148 
149  // casacore::Map which associates Colormap pointers with ColormapInfo.
150  std::map<const Colormap *, ColormapInfo *> itsInfoMap;
151 
152  };
153 
154 
155 } //# NAMESPACE CASA - END
156 
157 #endif
Class to manage registration of colormaps on PixelCanvasColorTables.
Abstract interface to underlying graphics library&#39;s colortable.
void reinstallColormaps()
Reinstall the colorcell values.
PixelCanvasColorTable * itsPCColorTable
Pointer to managed PixelCanvasColorTable.
friend std::ostream & operator<<(std::ostream &os, const ColormapManager &cm)
Stream output operator.
std::map< const Colormap *, ColormapInfo * > itsInfoMap
casacore::Map which associates Colormap pointers with ColormapInfo.
casacore::Bool member(const Colormap *map) const
Is the given Colormap registered on this ColormapManager/PixelCanvasColorTable combination?
void registerColormap(Colormap *dcmap, casacore::Float weight=1.0)
Register a Colormap with this ColormapManager, and optionally pass a weight - colormaps are distribut...
casacore::uInt nMaps() const
Return the number of registered Colormaps.
casacore::Bool unregisterColormap(Colormap *dcmap)
Unregister a Colormap with this ColormapManager.
ColormapManager(PixelCanvasColorTable *pcctbl)
Constructor requires pointer to the PixelCanvasColorTable which it will manage.
virtual ~ColormapManager()
Destructor.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
float Float
Definition: aipstype.h:54
const Colormap * getMap(const casacore::uInt mapnum) const
Return a pointer to a Colormap by number.
void redistributeColormaps()
Redistribute the available colorcells to the registered colormaps.
casacore::uInt getColormapSize(const Colormap *map) const
Return the current size of the colormap.
Describes a method of generating a table of colors.
Definition: Colormap.h:104
casacore::uInt getColormapOffset(const Colormap *map) const
Return the current offset of the colormap.
unsigned int uInt
Definition: aipstype.h:51