Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VScoreColorMap Class Referenceabstract

#include <G4VScoreColorMap.hh>

+ Inheritance diagram for G4VScoreColorMap:

Public Member Functions

 G4VScoreColorMap (G4String mName)
 
virtual ~G4VScoreColorMap ()=default
 
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)
 

Protected Attributes

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 G4VScoreColorMap.hh.

Constructor & Destructor Documentation

◆ G4VScoreColorMap()

G4VScoreColorMap::G4VScoreColorMap ( G4String mName)

Definition at line 42 of file G4VScoreColorMap.cc.

43 : fName(mName)
44{}

◆ ~G4VScoreColorMap()

virtual G4VScoreColorMap::~G4VScoreColorMap ( )
virtualdefault

Member Function Documentation

◆ DrawColorChart()

void G4VScoreColorMap::DrawColorChart ( G4int nPoint = 5)
virtual

Definition at line 46 of file G4VScoreColorMap.cc.

47{
49 if(fVisManager == nullptr)
50 {
51 G4cerr << "G4VScoringMesh::DrawColorChart(): no visualization system"
52 << G4endl;
53 return;
54 }
55
56 DrawColorChartBar(_nPoint);
57 DrawColorChartText(_nPoint);
58}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition G4ios.hh:67
virtual void DrawColorChartText(G4int nPoint)
G4VVisManager * fVisManager
virtual void DrawColorChartBar(G4int nPoint)
static G4VVisManager * GetConcreteInstance()

Referenced by G4ScoringBox::Draw(), G4ScoringCylinder::Draw(), G4ScoringBox::DrawColumn(), and G4ScoringCylinder::DrawColumn().

◆ DrawColorChartBar()

void G4VScoreColorMap::DrawColorChartBar ( G4int nPoint)
virtual

Reimplemented in G4ScoreLogColorMap.

Definition at line 60 of file G4VScoreColorMap.cc.

61{
62 G4double min = this->GetMin();
63 G4double max = this->GetMax();
64 G4double smin = -0.89, smax = smin + 0.05 * (_nPoint) *0.83, step = 0.001;
65 G4double c[4];
66
68
69 for(G4double y = smin; y < smax; y += step)
70 {
71 G4double ra = (y - smin) / (smax - smin), rb = 1. - ra;
72 G4Polyline line;
73 line.push_back(G4Point3D(-0.96, y, 0.));
74 line.push_back(G4Point3D(-0.91, y, 0.));
75 this->GetMapColor((ra * max + rb * min) / (ra + rb), c);
76 G4Colour col(c[0], c[1], c[2]);
77 G4VisAttributes att(col);
78 line.SetVisAttributes(&att);
79 fVisManager->Draw2D(line);
80 }
81
83}
HepGeom::Point3D< G4double > G4Point3D
Definition G4Point3D.hh:34
double G4double
Definition G4Types.hh:83
G4double GetMax() const
G4double GetMin() const
virtual void GetMapColor(G4double val, G4double color[4])=0
virtual void Draw2D(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void EndDraw2D()=0
virtual void BeginDraw2D(const G4Transform3D &objectTransformation=G4Transform3D())=0
void SetVisAttributes(const G4VisAttributes *)
Definition G4Visible.cc:98
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

Referenced by DrawColorChart().

◆ DrawColorChartText()

void G4VScoreColorMap::DrawColorChartText ( G4int nPoint)
virtual

Reimplemented in G4ScoreLogColorMap.

Definition at line 85 of file G4VScoreColorMap.cc.

86{
87 G4double min = this->GetMin();
88 G4double max = this->GetMax();
89 G4double c[4];
90 G4Colour black(0.1, 0.1, 0.1, 0.8);
91
93
94 for(int n = 0; n < _nPoint; n++)
95 {
96 G4double a = n / (_nPoint - 1.), b = 1. - a;
97 G4double v = (a * max + b * min) / (a + b);
98 // background color
99
100 for(int l = 0; l < 21; l++)
101 {
102 G4Polyline line;
103 line.push_back(G4Point3D(-0.9, -0.905 + 0.05 * n + 0.002 * l, 0.));
104 line.push_back(G4Point3D(-0.75, -0.905 + 0.05 * n + 0.002 * l, 0.));
105 G4VisAttributes attblack(black);
106 line.SetVisAttributes(&attblack);
107 fVisManager->Draw2D(line);
108 }
109
110 // text
111 std::ostringstream oss;
112 oss << std::setw(8) << std::setprecision(1) << std::scientific << v;
113 G4String value = oss.str();
114
115 G4Text text(value, G4Point3D(-0.9, -0.9 + 0.05 * n, 0.4));
116 G4double size = 12.;
117 text.SetScreenSize(size);
118 this->GetMapColor(v, c);
119 G4Colour color(c[0], c[1], c[2], 1.);
120 G4VisAttributes att(color);
121 text.SetVisAttributes(&att);
122
123 fVisManager->Draw2D(text);
124 }
125
126 // draw ps name
127 // background
128 G4double lpsname = 2. + fPSName.size() * 0.95;
129 if(lpsname > 0)
130 {
131 for(int l = 0; l < 22; l++)
132 {
133 G4Polyline line;
134 line.push_back(G4Point3D(-0.92, -0.965 + 0.002 * l, 0.));
135 line.push_back(
136 G4Point3D(-0.92 + 0.025 * lpsname, -0.965 + 0.002 * l, 0.));
137 G4VisAttributes attblack(black);
138 line.SetVisAttributes(&attblack);
139 fVisManager->Draw2D(line);
140 }
141
142 // ps name
143 G4Text txtpsname(fPSName, G4Point3D(-0.9, -0.96, 0.1));
144 G4double size = 12.;
145 txtpsname.SetScreenSize(size);
146 G4Colour color(1., 1., 1.);
147 G4VisAttributes att(color);
148 txtpsname.SetVisAttributes(&att);
149 fVisManager->Draw2D(txtpsname);
150 }
151
152 // draw unit
153 // background
154 G4double len = 2. + fPSUnit.size();
155 if(len > 0)
156 {
157 for(int l = 0; l < 21; l++)
158 {
159 G4Polyline line;
160 line.push_back(G4Point3D(-0.7, -0.9 + 0.002 * l, 0.));
161 line.push_back(G4Point3D(-0.7 + 0.025 * len, -0.9 + 0.002 * l, 0.));
162 G4VisAttributes attblack(black);
163 line.SetVisAttributes(&attblack);
164 fVisManager->Draw2D(line);
165 }
166
167 // unit
168 G4String psunit = "[" + fPSUnit + "]";
169 G4Text txtunit(psunit, G4Point3D(-0.69, -0.9, 0.1));
170 G4double size = 12.;
171 txtunit.SetScreenSize(size);
172 G4Colour color(1., 1., 1.);
173 G4VisAttributes att(color);
174 txtunit.SetVisAttributes(&att);
175 fVisManager->Draw2D(txtunit);
176 }
177
179}

Referenced by DrawColorChart().

◆ GetMapColor()

◆ GetMax()

G4double G4VScoreColorMap::GetMax ( ) const
inline

Definition at line 66 of file G4VScoreColorMap.hh.

66{ return fMaxVal; }

Referenced by DrawColorChartBar(), and DrawColorChartText().

◆ GetMin()

G4double G4VScoreColorMap::GetMin ( ) const
inline

Definition at line 65 of file G4VScoreColorMap.hh.

65{ return fMinVal; }

Referenced by DrawColorChartBar(), and DrawColorChartText().

◆ GetName()

G4String G4VScoreColorMap::GetName ( ) const
inline

◆ IfFloatMinMax()

G4bool G4VScoreColorMap::IfFloatMinMax ( ) const
inline

◆ SetFloatingMinMax()

void G4VScoreColorMap::SetFloatingMinMax ( G4bool vl = true)
inline

Definition at line 47 of file G4VScoreColorMap.hh.

47{ ifFloat = vl; }

Referenced by G4ScoringMessenger::SetNewValue().

◆ SetMinMax()

void G4VScoreColorMap::SetMinMax ( G4double minVal,
G4double maxVal )
inline

Definition at line 49 of file G4VScoreColorMap.hh.

50 {
51 if(minVal >= maxVal)
52 {
53 G4cerr << "WARNING: G4VScoreColoMap::SetMinMax() : minimum is larger "
54 "than or equal to maximum. Verify values you set, ["
55 << minVal << ", " << maxVal << "]" << G4endl;
56 fMinVal = maxVal;
57 fMaxVal = minVal;
58 }
59 else
60 {
61 fMinVal = minVal;
62 fMaxVal = maxVal;
63 }
64 }

Referenced by G4ScoringBox::Draw(), G4ScoringCylinder::Draw(), G4ScoringBox::DrawColumn(), G4ScoringCylinder::DrawColumn(), and G4ScoringMessenger::SetNewValue().

◆ SetPSName()

void G4VScoreColorMap::SetPSName ( G4String & psName)
inline

◆ SetPSUnit()

void G4VScoreColorMap::SetPSUnit ( G4String & unit)
inline

Member Data Documentation

◆ fMaxVal

◆ fMinVal

◆ fName

G4String G4VScoreColorMap::fName
protected

Definition at line 79 of file G4VScoreColorMap.hh.

Referenced by GetName().

◆ fPSName

G4String G4VScoreColorMap::fPSName = ""
protected

◆ fPSUnit

G4String G4VScoreColorMap::fPSUnit = ""
protected

◆ fVisManager

◆ ifFloat

G4bool G4VScoreColorMap::ifFloat = true
protected

Definition at line 80 of file G4VScoreColorMap.hh.

Referenced by IfFloatMinMax(), and SetFloatingMinMax().


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