InterpolatedColorMap.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: InterpolatedColorMap.cpp 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 #include "InterpolatedColorMap.hpp"
00028 
00029 namespace vdraw
00030 {
00031   InterpolatedColorMap::InterpolatedColorMap(int icols, int irows, const Palette &pp, double base)
00032   {
00033     init(icols,irows);
00034     p = pp;
00035 
00036     for(int row=0;row<rows;row++)
00037       for(int col=0;col<cols;col++)
00038         c[row][col] = base;
00039   }
00040 
00041   InterpolatedColorMap::InterpolatedColorMap(const InterpolatedColorMap &o)
00042   {
00043     init(o.cols,o.rows);
00044     p = o.p;
00045 
00046     for(int row=0;row<rows;row++)
00047       for(int col=0;col<cols;col++)
00048         c[row][col] = o.c[row][col];
00049   }
00050 
00051   InterpolatedColorMap& InterpolatedColorMap::operator=(InterpolatedColorMap o)
00052   {
00053     // o is a copy, swap the variables
00054     std::swap(rows,o.rows);
00055     std::swap(cols,o.cols);
00056     std::swap(p,o.p);
00057     std::swap(c,o.c);
00058     // o is destructed with the old data from this
00059     return *this;
00060   }
00061 
00062   void InterpolatedColorMap::init(int icols, int irows)
00063   {
00064     if(icols == 0 || irows == 0)
00065     {
00066       cols = rows = 0;
00067       c = 0;
00068       return;
00069     }
00070 
00071     cols = icols;
00072     rows = irows;
00073 
00074     // Initialize the color array
00075     c = new double*[rows];
00076 
00077     for(int row=0;row<rows;row++)
00078       c[row] = new double[cols];
00079   }
00080 
00081   void InterpolatedColorMap::reset()
00082   {
00083     if(c)
00084     {
00085       for(int row=0;row<rows;row++)
00086         delete[] c[row];
00087       delete[] c;
00088     }
00089     p = Palette();
00090     cols=rows=0;
00091     c=0;
00092   }
00093 
00094 }

Generated on Thu Feb 9 03:30:57 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1