Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes
G4VScoreColorMap Class Referenceabstract

#include <G4VScoreColorMap.hh>

Inheritance diagram for G4VScoreColorMap:
G4DefaultLinearColorMap G4ScoreLogColorMap

Public Member Functions

 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)
 

Protected Attributes

G4String fName
 
G4bool ifFloat
 
G4double fMinVal
 
G4double fMaxVal
 
G4VVisManagerfVisManager
 
G4String fPSUnit
 
G4String fPSName
 

Detailed Description

Definition at line 37 of file G4VScoreColorMap.hh.

Constructor & Destructor Documentation

G4VScoreColorMap::G4VScoreColorMap ( G4String  mName)

Definition at line 42 of file G4VScoreColorMap.cc.

43 :fName(mName),ifFloat(true),fMinVal(0.),fMaxVal(DBL_MAX),fVisManager(0)
44 {;}
G4VVisManager * fVisManager
#define DBL_MAX
Definition: templates.hh:83
G4VScoreColorMap::~G4VScoreColorMap ( )
virtual

Definition at line 46 of file G4VScoreColorMap.cc.

47 {;}

Member Function Documentation

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

Definition at line 49 of file G4VScoreColorMap.cc.

References DrawColorChartBar(), DrawColorChartText(), fVisManager, G4cerr, G4endl, and G4VVisManager::GetConcreteInstance().

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

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

Reimplemented in G4ScoreLogColorMap.

Definition at line 61 of file G4VScoreColorMap.cc.

References test::c, G4VVisManager::Draw2D(), fVisManager, GetMapColor(), GetMax(), GetMin(), G4INCL::Math::max(), G4INCL::Math::min(), G4Visible::SetVisAttributes(), and smax.

Referenced by DrawColorChart().

61  {
62 
63  G4double min = this->GetMin();
64  G4double max = this->GetMax();
65  G4double smin = -0.89, smax = smin + 0.05*(_nPoint)*0.83, step=0.001;
66  G4double c[4];
67  for(G4double y = smin; y < smax; y+=step) {
68  G4double ra = (y-smin)/(smax-smin), rb = 1.-ra;
69  G4Polyline line;
70  line.push_back(G4Point3D(-0.96, y, 0.));
71  line.push_back(G4Point3D(-0.91, y, 0.));
72  this->GetMapColor((ra*max+rb*min)/(ra+rb), c);
73  G4Colour col(c[0], c[1], c[2]);
74  G4VisAttributes att(col);
75  line.SetVisAttributes(&att);
76  fVisManager->Draw2D(line);
77  }
78 
79 }
G4VVisManager * fVisManager
virtual void GetMapColor(G4double val, G4double color[4])=0
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
G4double GetMax() const
const G4int smax
void SetVisAttributes(const G4VisAttributes *)
Definition: G4Visible.cc:80
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
double G4double
Definition: G4Types.hh:76
virtual void Draw2D(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
G4double GetMin() const
void G4VScoreColorMap::DrawColorChartText ( G4int  nPoint)
virtual

Reimplemented in G4ScoreLogColorMap.

Definition at line 80 of file G4VScoreColorMap.cc.

References test::a, test::b, test::c, G4VVisManager::Draw2D(), fPSName, fPSUnit, fVisManager, GetMapColor(), GetMax(), GetMin(), G4INCL::Math::max(), G4INCL::Math::min(), n, G4VMarker::SetScreenSize(), G4Visible::SetVisAttributes(), and test::v.

Referenced by DrawColorChart().

80  {
81 
82  G4double min = this->GetMin();
83  G4double max = this->GetMax();
84  G4double c[4];
85  G4Colour black(0., 0., 0.);
86  for(int n = 0; n < _nPoint; n++) {
87  G4double a = n/(_nPoint-1.), b = 1.-a;
88  G4double v = (a*max + b*min)/(a+b);
89  // background color
90  for(int l = 0; l < 21; l++) {
91  G4Polyline line;
92  line.push_back(G4Point3D(-0.908, -0.905+0.05*n+0.002*l, 0.));
93  line.push_back(G4Point3D(-0.705, -0.905+0.05*n+0.002*l, 0.));
94  G4VisAttributes attblack(black);
95  line.SetVisAttributes(&attblack);
96  fVisManager->Draw2D(line);
97  }
98  // text
99  //char cstring[80];
100  //std::sprintf(cstring, "%8.2e", v);
101  //G4String value(cstring);
102  std::ostringstream oss;
103  oss << std::setw(8) << std::setprecision(1) << std::scientific << v;
104  std::string str = oss.str();
105  G4String value(str.c_str());
106 
107  G4Text text(value, G4Point3D(-0.9, -0.9+0.05*n, 0));
108  G4double size = 12.;
109  text.SetScreenSize(size);
110  this->GetMapColor(v, c);
111  G4Colour color(c[0], c[1], c[2]);
112  G4VisAttributes att(color);
113  text.SetVisAttributes(&att);
114 
115  fVisManager->Draw2D(text);
116  }
117 
118  // draw ps name
119  // background
120  G4int lpsname = 20;//fPSName.size();
121  if(lpsname > 0) {
122  for(int l = 0; l < 22; l++) {
123  G4Polyline line;
124  line.push_back(G4Point3D(-0.9, -0.965+0.002*l, 0.));
125  line.push_back(G4Point3D(-0.9+0.025*lpsname, -0.965+0.002*l, 0.));
126  G4VisAttributes attblack(black);
127  //G4VisAttributes attblack(G4Colour(.5, .5, 1.));
128  line.SetVisAttributes(&attblack);
129  fVisManager->Draw2D(line);
130  }
131  // ps name
132  G4Text txtpsname(fPSName, G4Point3D(-0.9, -0.96, 0.));
133  G4double size = 12.;
134  txtpsname.SetScreenSize(size);
135  G4Colour color(1., 1., 1.);
136  G4VisAttributes att(color);
137  txtpsname.SetVisAttributes(&att);
138  fVisManager->Draw2D(txtpsname);
139  }
140 
141  // draw unit
142  // background
143  G4int len = fPSUnit.size();
144  if(len > 0) {
145  for(int l = 0; l < 21; l++) {
146  G4Polyline line;
147  line.push_back(G4Point3D(-0.7, -0.9+0.002*l, 0.));
148  line.push_back(G4Point3D(-0.7+0.3, -0.9+0.002*l, 0.));
149  G4VisAttributes attblack(black);
150  //G4VisAttributes attblack(G4Colour(.5, .5, .5));
151  line.SetVisAttributes(&attblack);
152  fVisManager->Draw2D(line);
153  }
154  // unit
155  G4String psunit = "[" + fPSUnit + "]";
156  G4Text txtunit(psunit, G4Point3D(-0.69, -0.9, 0.));
157  G4double size = 12.;
158  txtunit.SetScreenSize(size);
159  G4Colour color(1., 1., 1.);
160  G4VisAttributes att(color);
161  txtunit.SetVisAttributes(&att);
162  fVisManager->Draw2D(txtunit);
163  }
164 
165 }
Definition: G4Text.hh:73
G4VVisManager * fVisManager
virtual void GetMapColor(G4double val, G4double color[4])=0
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
G4double GetMax() const
int G4int
Definition: G4Types.hh:78
const G4int n
void SetVisAttributes(const G4VisAttributes *)
Definition: G4Visible.cc:80
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
const XML_Char int const XML_Char * value
const XML_Char int len
double G4double
Definition: G4Types.hh:76
virtual void Draw2D(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
G4double GetMin() const
virtual void G4VScoreColorMap::GetMapColor ( G4double  val,
G4double  color[4] 
)
pure virtual
G4double G4VScoreColorMap::GetMax ( ) const
inline

Definition at line 66 of file G4VScoreColorMap.hh.

References fMaxVal.

Referenced by DrawColorChartBar(), and DrawColorChartText().

67  { return fMaxVal; }
G4double G4VScoreColorMap::GetMin ( ) const
inline

Definition at line 64 of file G4VScoreColorMap.hh.

References fMinVal.

Referenced by DrawColorChartBar(), and DrawColorChartText().

65  { return fMinVal; }
G4String G4VScoreColorMap::GetName ( void  ) const
inline

Definition at line 47 of file G4VScoreColorMap.hh.

References fName.

Referenced by G4ScoringManager::G4ScoringManager(), and G4ScoringManager::RegisterScoreColorMap().

48  { return fName; }
G4bool G4VScoreColorMap::IfFloatMinMax ( ) const
inline
void G4VScoreColorMap::SetFloatingMinMax ( G4bool  vl = true)
inline

Definition at line 49 of file G4VScoreColorMap.hh.

References ifFloat.

Referenced by G4ScoringMessenger::SetNewValue().

50  { ifFloat = vl; }
void G4VScoreColorMap::SetMinMax ( G4double  minVal,
G4double  maxVal 
)
inline

Definition at line 53 of file G4VScoreColorMap.hh.

References fMaxVal, fMinVal, G4cerr, and G4endl.

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

54  {
55  if(minVal >= maxVal)
56  { G4cerr << "WARNING: G4VScoreColoMap::SetMinMax() : minimum is larger than or equal to maximum. Verify values you set, ["
57  << minVal << ", " << maxVal << "]" << G4endl;
58  fMinVal = maxVal; fMaxVal = minVal;
59  }
60  else {
61  fMinVal = minVal; fMaxVal = maxVal;
62  }
63  }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
void G4VScoreColorMap::SetPSName ( G4String psName)
inline
void G4VScoreColorMap::SetPSUnit ( G4String unit)
inline

Field Documentation

G4double G4VScoreColorMap::fMaxVal
protected
G4double G4VScoreColorMap::fMinVal
protected
G4String G4VScoreColorMap::fName
protected

Definition at line 81 of file G4VScoreColorMap.hh.

Referenced by GetName().

G4String G4VScoreColorMap::fPSName
protected
G4String G4VScoreColorMap::fPSUnit
protected
G4VVisManager* G4VScoreColorMap::fVisManager
protected
G4bool G4VScoreColorMap::ifFloat
protected

Definition at line 82 of file G4VScoreColorMap.hh.

Referenced by IfFloatMinMax(), and SetFloatingMinMax().


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