ColorMap.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ColorMap.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_COLORMAP_H
00028 #define VDRAW_COLORMAP_H
00029 
00030 #include <algorithm>
00031 
00032 #include "Color.hpp"
00033 #include "Palette.hpp"
00034 //#include "IndexedColorMap.hpp"
00035 #include "InterpolatedColorMap.hpp"
00036 
00037 namespace vdraw
00038 {
00041 
00045   class ColorMap
00046   {
00047     public:
00049       ColorMap()
00050       {
00051         cols=rows=0;
00052         c=0;
00053       }
00054 
00056       ColorMap(const ColorMap &o);
00057 
00059       ColorMap(const InterpolatedColorMap &o);
00060 
00062       //ColorMap(const IndexedColorMap &o);
00063 
00065       ColorMap(const Palette &p, double dir=90, int num=256)
00066       {
00067         // TODO Figure out direction, initialize accordingly
00068         // For now we'll assume NORTH
00069 
00070         if(num<=0) num = 256;
00071 
00072         init(1,num);
00073         
00074         for(int row=0;row<rows;row++)
00075           for(int col=0;col<cols;col++)
00076             c[row][col] = p.getColor((1.0*row)/rows);
00077       }
00078 
00085       ColorMap(int icols, int irows, const Color &base=Color::BLACK);
00086 
00088       ~ColorMap() { reset(); }
00089 
00106       ColorMap& operator=(ColorMap o);      
00107 
00109       inline void setColor(int row, int col, const Color& color) { c[row][col]=color; }
00110 
00112       inline Color get(int row, int col) const { return c[row][col]; }
00113 
00115       inline int getCols() const { return cols; }
00116 
00118       inline int getRows() const { return rows; }
00119 
00120     protected:
00122       void init(int icols, int irows);
00123 
00125       void reset();
00126 
00128       int cols;
00129 
00131       int rows;
00132 
00134       Color **c;
00135   }; // class ColorMap
00136 
00138 
00139 } // namespace vdraw
00140 
00141 #endif // VDRAW_COLORMAP_H
00142 

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