Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DefaultLinearColorMap Class Reference

#include <G4DefaultLinearColorMap.hh>

+ Inheritance diagram for G4DefaultLinearColorMap:

Public Member Functions

 G4DefaultLinearColorMap (G4String mName)
 
virtual ~G4DefaultLinearColorMap ()
 
virtual void GetMapColor (G4double val, G4double color[4])
 
- Public Member Functions inherited from G4VScoreColorMap
 G4VScoreColorMap (G4String mName)
 
virtual ~G4VScoreColorMap ()
 
virtual void GetMapColor (G4double val, G4double color[4])=0
 
G4String GetName () const
 
void SetFloatingMinMax (G4bool vl=true)
 
G4bool IfFloatMinMax () const
 
void SetMinMax (G4double minVal, G4double maxVal)
 
G4double GetMin () const
 
G4double GetMax () const
 
virtual void DrawColorChart (G4int nPoint=5)
 
virtual void DrawColorChartBar (G4int nPoint)
 
virtual void DrawColorChartText (G4int nPoint)
 
void SetPSUnit (G4String &unit)
 
void SetPSName (G4String &psName)
 

Additional Inherited Members

- Protected Attributes inherited from G4VScoreColorMap
G4String fName
 
G4bool ifFloat
 
G4double fMinVal
 
G4double fMaxVal
 
G4VVisManagerfVisManager
 
G4String fPSUnit
 
G4String fPSName
 

Detailed Description

Definition at line 36 of file G4DefaultLinearColorMap.hh.

Constructor & Destructor Documentation

◆ G4DefaultLinearColorMap()

G4DefaultLinearColorMap::G4DefaultLinearColorMap ( G4String  mName)

Definition at line 32 of file G4DefaultLinearColorMap.cc.

◆ ~G4DefaultLinearColorMap()

G4DefaultLinearColorMap::~G4DefaultLinearColorMap ( )
virtual

Definition at line 36 of file G4DefaultLinearColorMap.cc.

37{;}

Member Function Documentation

◆ GetMapColor()

void G4DefaultLinearColorMap::GetMapColor ( G4double  val,
G4double  color[4] 
)
virtual

Implements G4VScoreColorMap.

Definition at line 39 of file G4DefaultLinearColorMap.cc.

40{
41 G4double value;
42 if(fMaxVal == fMinVal)
43 value = 0.;
44 else
45 value = (val-fMinVal)/(fMaxVal-fMinVal);
46
47 if(value > 1.) {value=1.;}
48 if(value < 0.) {value=0.;}
49
50 // color map
51 const int NCOLOR = 6;
52 struct ColorMap {
53 G4double val;
54 G4double rgb[4];
55 } colormap[NCOLOR] = {{0.0, {1., 1., 1., 1.}}, // value, r, g, b, alpha
56 {0.2, {0., 0., 1., 1.}},
57 {0.4, {0., 1., 1., 1.}},
58 {0.6, {0., 1., 0., 1.}},
59 {0.8, {1., 1., 0., 1.}},
60 {1.0, {1., 0., 0., 1.}}};
61
62 // search
63 G4int during[2] = {0, 0};
64 for(int i = 1; i < NCOLOR; i++) {
65 if(colormap[i].val >= value) {
66 during[0] = i-1;
67 during[1] = i;
68 break;
69 }
70 }
71
72 // interpolate
73 G4double a = std::fabs(value - colormap[during[0]].val);
74 G4double b = std::fabs(value - colormap[during[1]].val);
75 for(int i = 0; i < 4; i++) {
76 color[i] = (b*colormap[during[0]].rgb[i] + a*colormap[during[1]].rgb[i])
77 /(colormap[during[1]].val - colormap[during[0]].val);
78 }
79
80}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66

The documentation for this class was generated from the following files: