Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkColorTable.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkColorTable.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-25 12:24:02 $
00007   Version:   $Revision: 1.20 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkColorTable_h
00018 #define __itkColorTable_h
00019 
00020 #include <itkObject.h>
00021 #include <itkRGBPixel.h>
00022 #include <itkObjectFactory.h>
00023 
00024 namespace itk 
00025 {
00032 template<class TPixel>
00033 class ITK_EXPORT ColorTable : public Object
00034 {
00035 public:
00037   typedef ColorTable                Self;
00038   typedef Object                    Superclass;
00039   typedef SmartPointer<Self>        Pointer;
00040   typedef SmartPointer<const Self>  ConstPointer;
00041 
00043   itkNewMacro(Self);
00044 
00046   itkTypeMacro(ColorTable,Object);
00047 
00051   void    UseDiscreteColors(void);
00052 
00056   void    UseGrayColors(unsigned int n=256);
00057   void    UseHeatColors(unsigned int n=256);
00058   void    UseRandomColors(unsigned int n=256);
00060 
00062   void    useDiscrete(void){UseDiscreteColors();};
00063   void    useGray(unsigned int n=256){UseGrayColors(n);}
00064   void    useHeat(unsigned int n=256){UseHeatColors(n);}
00066 
00067   itkGetConstMacro(NumberOfColors, unsigned int);
00068   unsigned int     size(void);
00069 
00070   RGBPixel<TPixel>*          GetColor(unsigned int colorId);
00071   RGBPixel<TPixel>*          color(unsigned int c);
00072 
00073   bool    SetColor(unsigned int c, TPixel r, TPixel g, TPixel b,
00074                    const char * name="UserDefined");
00075   
00078   TPixel  GetColorComponent(unsigned int colorId, char rgb);
00079   TPixel  color(unsigned int c, char rgb);
00080   char *  GetColorName(unsigned int colorId);
00081   char *  colorName(unsigned int c);
00083 
00084   unsigned int GetClosestColorTableId(TPixel r, TPixel g, TPixel b);
00085    
00086 protected:
00087   ColorTable();
00088   void PrintSelf(std::ostream & os, Indent indent) const;
00089   virtual ~ColorTable();
00090 
00091   unsigned int         m_NumberOfColors;
00092   RGBPixel<TPixel> *   m_Color;
00093   char **              m_ColorName;
00094 
00095 private:
00096   ColorTable(const Self&); //purposely not implemented
00097   void operator=(const Self&); //purposely not implemented
00098   void DeleteColors();
00099 };
00100 
00101 
00102 }// namespace itk
00103 
00104 // Define instantiation macro for this template.
00105 #define ITK_TEMPLATE_ColorTable(_, EXPORT, x, y) namespace itk { \
00106   _(1(class EXPORT ColorTable< ITK_TEMPLATE_1 x >)) \
00107   namespace Templates { typedef ColorTable< ITK_TEMPLATE_1 x > \
00108                                             ColorTable##y; } \
00109   }
00110 
00111 #if ITK_TEMPLATE_EXPLICIT
00112 # include "Templates/itkColorTable+-.h"
00113 #endif
00114 
00115 #if ITK_TEMPLATE_TXX
00116 # include "itkColorTable.txx"
00117 #endif
00118 
00119 #endif
00120 

Generated at Thu May 28 09:37:34 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000