Geant4 10.7.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 35 of file G4DefaultLinearColorMap.hh.

Constructor & Destructor Documentation

◆ G4DefaultLinearColorMap()

G4DefaultLinearColorMap::G4DefaultLinearColorMap ( G4String  mName)

Definition at line 31 of file G4DefaultLinearColorMap.cc.

◆ ~G4DefaultLinearColorMap()

G4DefaultLinearColorMap::~G4DefaultLinearColorMap ( )
virtual

Definition at line 35 of file G4DefaultLinearColorMap.cc.

36{;}

Member Function Documentation

◆ GetMapColor()

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

Implements G4VScoreColorMap.

Definition at line 38 of file G4DefaultLinearColorMap.cc.

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

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