casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ColormapManager.h
Go to the documentation of this file.
00001 //# ColormapManager.h: dynamic mapping of Colormaps onto ColorTables
00002 //# Copyright (C) 1994,1995,1996,1997,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_COLORMAPMANAGER_H
00029 #define TRIALDISPLAY_COLORMAPMANAGER_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/Containers/SimOrdMap.h>
00033 #include <display/Display/Colormap.h>
00034 
00035 //# Forward declarations
00036 #include <casa/iosfwd.h>
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 class ColormapInfo;
00040 class PixelCanvasColorTable;
00041 
00042 // <summary>
00043 // Class to manage registration of colormaps on PixelCanvasColorTables
00044 // </summary>
00045 
00046 // <use visibility=local>
00047 
00048 // <reviewed reviewer="None yet" date="yyyy/mm/dd" demos="">
00049 // </reviewed>
00050   
00051 // <prerequisite>
00052 // <li> <linkto class="Colormap">Colormap</linkto>
00053 // <li> <linkto class="PixelCanvasColorTable">PixelCanvasColorTable</linkto>
00054 // </prerequisite>
00055 
00056 // <etymology>
00057 // This class manages a set of colormaps and dynamically maintains
00058 // both their allocation on the colortable and the colortable's
00059 // colors.
00060 // </etymology>
00061 
00062 // <synopsis>
00063 
00064 // The colormap manager is a management tool which facilitates the
00065 // dynamic mapping of 1 or more Colormaps to a single
00066 // PixelCanvasColorTable.
00067 //
00068 // The colormap manager manages the assignment of data colormaps,
00069 // which define the function that generates the color spectrum to use,
00070 // to the hardware colormap which defines how many cells are
00071 // available.  As Colormaps are registerd and unregistered, the
00072 // manager reorganizes the colors on the colormap and reinstalls the
00073 // maps in response.  The colormap manager also registers a resize
00074 // callback with the pixel canvas colormap.  This allows the
00075 // application to resize the hardware colormap and have all colormaps
00076 // adjusted as appropriate.
00077 //
00078 // The calling program can at any time ask for the size of a given
00079 // colormap and use that size to map real-world values into a range
00080 // appropriate for display (see the <linkto
00081 // class="PixelCanvas">PixelCanvas</linkto> class' getColormapSize()
00082 // and mapToColor() functions.
00083 //
00084 // Because the colormap manager can control the distribution of its
00085 // Colormaps, application code must issue a call to redistribute if it
00086 // decides to change the size of the colortable on its own.
00087 // </synopsis>
00088 
00089 // <motivation>
00090 // Needed to have tool available to help manage more than one colormap.
00091 // </motivation>
00092 
00093 class ColormapManager {
00094 
00095  public:
00096 
00097   // Constructor requires pointer to the PixelCanvasColorTable which it
00098   // will manage.
00099   ColormapManager(PixelCanvasColorTable *pcctbl);
00100 
00101   // Destructor.
00102   virtual ~ColormapManager();
00103 
00104   // Register a Colormap with this ColormapManager, and optionally
00105   // pass a weight - colormaps are distributed proportionally
00106   // according to their weight.
00107   void registerColormap(Colormap * dcmap, Float weight = 1.0);
00108 
00109   // Register the <src>cmap</src> Colormap with this manager,
00110   // replacing the <src>cmapToReplace</src> Colormap if possible.
00111   void registerColormap(Colormap *cmap, Colormap *cmapToReplace);
00112 
00113   // Unregister a Colormap with this ColormapManager.
00114   Bool unregisterColormap(Colormap * dcmap);
00115 
00116   // Return the current size of the colormap.
00117   uInt getColormapSize(const Colormap * map) const;
00118 
00119   // Return the current offset of the colormap.
00120   uInt getColormapOffset(const Colormap * map) const;
00121 
00122   // Redistribute the available colorcells to the registered
00123   // colormaps.
00124   void redistributeColormaps();
00125 
00126   // Reinstall the colorcell values.
00127   void reinstallColormaps();
00128 
00129   // Is the given Colormap registered on this
00130   // ColormapManager/PixelCanvasColorTable combination?
00131   Bool member(const Colormap * map) const;
00132 
00133   // Return the number of registered Colormaps.
00134   uInt nMaps() const { return itsInfoMap.ndefined(); }
00135 
00136   // Return a pointer to a Colormap by number.
00137   const Colormap *getMap(const uInt mapnum) const;
00138 
00139   // Stream output operator.
00140   friend ostream & operator << (ostream & os, const ColormapManager & cm);
00141 
00142 private:
00143 
00144   // Pointer to managed PixelCanvasColorTable.
00145   PixelCanvasColorTable * itsPCColorTable;
00146 
00147   // Map which associates Colormap pointers with ColormapInfo.
00148   SimpleOrderedMap<const Colormap *, ColormapInfo *> itsInfoMap;
00149 
00150 };
00151 
00152 
00153 } //# NAMESPACE CASA - END
00154 
00155 #endif