Palette.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: Palette.hpp 1644 2009-01-27 19:26:14Z ckiesch $"
00002 
00004 
00005 //============================================================================
00006 //
00007 //  This file is part of GPSTk, the GPS Toolkit.
00008 //
00009 //  The GPSTk is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU Lesser General Public License as published
00011 //  by the Free Software Foundation; either version 2.1 of the License, or
00012 //  any later version.
00013 //
00014 //  The GPSTk is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 //  GNU Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with GPSTk; if not, write to the Free Software Foundation,
00021 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //  
00023 //  Copyright 2004, The University of Texas at Austin
00024 //
00025 //============================================================================
00026 
00027 #ifndef VDRAW_PALETTE_H
00028 #define VDRAW_PALETTE_H
00029 
00030 #include <algorithm>
00031 
00032 #include "Color.hpp"
00033 
00034 namespace vdraw
00035 {
00038 
00046   class Palette
00047   {
00048     public:
00055       Palette(const Color &base=Color::BLACK, double imin=0.0, double imax=1.0);
00056 
00058       Palette(const Palette &p);
00059 
00061       Palette& operator=(Palette p);
00062 
00064       ~Palette()
00065       {
00066       }
00067 
00070       void setRange(double imin, double imax)
00071       {
00072         if(imax<imin) 
00073         { 
00074           min = imax; 
00075           width=imin-imax; 
00076         }
00077         else
00078         {
00079           min = imin;
00080           width = imax-imin;
00081         }
00082       }
00083 
00085       void setColor(double val, const Color &c);
00086 
00088       Color getColor(double val) const;
00089 
00091       inline double getMin() const { return min; }
00092 
00094       inline double getMax() const { return min+width; }
00095 
00097       inline int getNumColors() const { return (int)palette.size(); }
00098 
00099     protected:
00101       double min;
00102       
00104       double width;
00105 
00107       std::list<std::pair<double,Color> > palette;
00108 
00110       inline void clamp(double &val) const
00111       {
00112         if(val<min)         val=getMin();
00113         if(val>(min+width)) val=getMax();
00114       }
00115   }; // class Palette
00116 
00118   
00119 } // namespace vdraw
00120 
00121 #endif // VDRAW_PALETTE_H
00122 

Generated on Wed Feb 8 03:31:01 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1