00001 #pragma ident "$Id: InterpolatedColorMap.cpp 1644 2009-01-27 19:26:14Z ckiesch $"
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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
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
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 }