Geant4 11.4.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 () override=default
void GetMapColor (G4double val, G4double color[4]) override
 G4VScoreColorMap (const G4String &mName)
Public Member Functions inherited from G4VScoreColorMap
 G4VScoreColorMap (const G4String &mName)
virtual ~G4VScoreColorMap ()=default
const G4StringGetName () 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 (const G4String &unit)
void SetPSName (const G4String &psName)

Additional Inherited Members

Protected Attributes inherited from G4VScoreColorMap
G4String fName
G4bool ifFloat = true
G4double fMinVal = 0.0
G4double fMaxVal = DBL_MAX
G4VVisManagerfVisManager = nullptr
G4String fPSUnit = ""
G4String fPSName = ""

Detailed Description

Definition at line 36 of file G4DefaultLinearColorMap.hh.

Constructor & Destructor Documentation

◆ ~G4DefaultLinearColorMap()

G4DefaultLinearColorMap::~G4DefaultLinearColorMap ( )
overridedefault

Member Function Documentation

◆ G4VScoreColorMap()

Definition at line 41 of file G4VScoreColorMap.cc.

43 : fName(mName)
44{}

◆ GetMapColor()

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

Implements G4VScoreColorMap.

Definition at line 31 of file G4DefaultLinearColorMap.cc.

32{
33 G4double value;
34 if(fMaxVal == fMinVal)
35 value = 0.;
36 else
37 value = (val - fMinVal) / (fMaxVal - fMinVal);
38
39 if(value > 1.)
40 {
41 value = 1.;
42 }
43 if(value < 0.)
44 {
45 value = 0.;
46 }
47
48 // color map
49 const int NCOLOR = 6;
50 struct ColorMap
51 {
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 {
65 if(colormap[i].val >= value)
66 {
67 during[0] = i - 1;
68 during[1] = i;
69 break;
70 }
71 }
72
73 // interpolate
74 G4double a = std::fabs(value - colormap[during[0]].val);
75 G4double b = std::fabs(value - colormap[during[1]].val);
76 for(int i = 0; i < 4; i++)
77 {
78 color[i] =
79 (b * colormap[during[0]].rgb[i] + a * colormap[during[1]].rgb[i]) /
80 (colormap[during[1]].val - colormap[during[0]].val);
81 if(color[i] > 1.)
82 color[i] = 1.;
83 }
84}
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85

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