00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "G4DefaultLinearColorMap.hh"
00031
00032 G4DefaultLinearColorMap::G4DefaultLinearColorMap(G4String mName)
00033 :G4VScoreColorMap(mName)
00034 {;}
00035
00036 G4DefaultLinearColorMap::~G4DefaultLinearColorMap()
00037 {;}
00038
00039 void G4DefaultLinearColorMap::GetMapColor(G4double val, G4double color[4])
00040 {
00041 G4double value;
00042 if(fMaxVal == fMinVal)
00043 value = 0.;
00044 else
00045 value = (val-fMinVal)/(fMaxVal-fMinVal);
00046
00047 if(value > 1.) {value=1.;}
00048 if(value < 0.) {value=0.;}
00049
00050
00051 const int NCOLOR = 6;
00052 struct ColorMap {
00053 G4double val;
00054 G4double rgb[4];
00055 } colormap[NCOLOR] = {{0.0, {1., 1., 1., 1.}},
00056 {0.2, {0., 0., 1., 1.}},
00057 {0.4, {0., 1., 1., 1.}},
00058 {0.6, {0., 1., 0., 1.}},
00059 {0.8, {1., 1., 0., 1.}},
00060 {1.0, {1., 0., 0., 1.}}};
00061
00062
00063 G4int during[2] = {0, 0};
00064 for(int i = 1; i < NCOLOR; i++) {
00065 if(colormap[i].val >= value) {
00066 during[0] = i-1;
00067 during[1] = i;
00068 break;
00069 }
00070 }
00071
00072
00073 G4double a = std::fabs(value - colormap[during[0]].val);
00074 G4double b = std::fabs(value - colormap[during[1]].val);
00075 for(int i = 0; i < 4; i++) {
00076 color[i] = (b*colormap[during[0]].rgb[i] + a*colormap[during[1]].rgb[i])
00077 /(colormap[during[1]].val - colormap[during[0]].val);
00078 }
00079
00080 }
00081
00082