Geant4  10.02.p03
CCalVisualisable Class Reference

#include <CCalVisualisable.hh>

Collaboration diagram for CCalVisualisable:

Classes

class  visParameters
 

Public Types

enum  visType {
  Sensitive =0, Electronics =1, Support =2, Cable =3,
  Absorber =4, OtherServices =5, PseudoVolumes =6, TotalVisTypes =7,
  Undefined =-1
}
 

Public Member Functions

 CCalVisualisable (G4String file)
 
virtual ~CCalVisualisable ()
 
bool readFile (G4String file)
 
void setDefault ()
 
bool isVisible (visType v) const
 
void setVisible (visType v, bool flag=true)
 
double colorRed (visType v) const
 
double colorGreen (visType v) const
 
double colorBlue (visType v) const
 
void setColorRed (visType v, double r)
 
void setColorGreen (visType v, double g)
 
void setColorBlue (visType v, double b)
 
void setColor (visType v, double r, double g, double b)
 
bool isWireFrame (visType v) const
 
void setWireFrame (visType v, bool wf=true)
 

Protected Member Functions

bool readFile ()
 

Static Protected Member Functions

static void setPath ()
 

Private Member Functions

double checkColorRange (double color, char type) const
 

Private Attributes

G4String visFile
 
visParameters theParameters [TotalVisTypes]
 

Static Private Attributes

static const char * pathName =0
 

Detailed Description

Definition at line 39 of file CCalVisualisable.hh.

Member Enumeration Documentation

◆ visType

Constructor & Destructor Documentation

◆ CCalVisualisable()

CCalVisualisable::CCalVisualisable ( G4String  file)

Definition at line 41 of file CCalVisualisable.cc.

41  :visFile(file) {
42  if (!pathName)
43  setPath();
44  setDefault();
45  readFile();
46 }
static void setPath()
static const char * pathName
Here is the call graph for this function:

◆ ~CCalVisualisable()

virtual CCalVisualisable::~CCalVisualisable ( )
inlinevirtual

Definition at line 71 of file CCalVisualisable.hh.

71 {}
Here is the call graph for this function:

Member Function Documentation

◆ checkColorRange()

double CCalVisualisable::checkColorRange ( double  color,
char  type 
) const
private

Definition at line 159 of file CCalVisualisable.cc.

159  {
160  if (cvalue>1) {
161  G4cerr << "ERROR: In " << visFile << ". Color " << ctype << "="
162  << cvalue << " > 1" << G4endl;
163  G4cerr << " It will be reset to 1." << G4endl;
164  return 1.;
165  }
166  if (cvalue<0) {
167  G4cerr << "ERROR: In " << visFile << ". Color " << ctype << "="
168  << cvalue << " < 0" << G4endl;
169  G4cerr << " It will be reset to 0." << G4endl;
170  return 0.;
171  }
172  return cvalue;
173 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ colorBlue()

double CCalVisualisable::colorBlue ( visType  v) const
inline

Definition at line 85 of file CCalVisualisable.hh.

85 {return theParameters[v].bColor;}
visParameters theParameters[TotalVisTypes]
Here is the caller graph for this function:

◆ colorGreen()

double CCalVisualisable::colorGreen ( visType  v) const
inline

Definition at line 84 of file CCalVisualisable.hh.

84 {return theParameters[v].gColor;}
visParameters theParameters[TotalVisTypes]
Here is the caller graph for this function:

◆ colorRed()

double CCalVisualisable::colorRed ( visType  v) const
inline

Definition at line 83 of file CCalVisualisable.hh.

83 {return theParameters[v].rColor;}
visParameters theParameters[TotalVisTypes]
Here is the caller graph for this function:

◆ isVisible()

bool CCalVisualisable::isVisible ( visType  v) const
inline

Definition at line 80 of file CCalVisualisable.hh.

80 {return theParameters[v].visibility;}
visParameters theParameters[TotalVisTypes]
Here is the caller graph for this function:

◆ isWireFrame()

bool CCalVisualisable::isWireFrame ( visType  v) const
inline

Definition at line 91 of file CCalVisualisable.hh.

91 {return theParameters[v].wireframe;}
visParameters theParameters[TotalVisTypes]
Here is the caller graph for this function:

◆ readFile() [1/2]

bool CCalVisualisable::readFile ( G4String  file)

Definition at line 48 of file CCalVisualisable.cc.

48  {
49  visFile=file;
50  return readFile();
51 }
TFile * file
Here is the call graph for this function:

◆ readFile() [2/2]

bool CCalVisualisable::readFile ( )
protected

Definition at line 80 of file CCalVisualisable.cc.

80  {
81  if (visFile=="") {
82  G4cerr << "ERROR: No file was specified from which to read Visualisation parameters"
83  << G4endl;
84  return false;
85  }
86 
88  //Let's open the file
89  G4cout << " ==> Opening file " << visFile
90  << " to read visualisation parameters..."
91  << G4endl;
92 
93  G4String pathname(pathName);
94  std::ifstream is;
95 #ifdef debug
96  G4cout << "Viualisable : Path " << pathname << " FIle " << visFile << G4endl;
97 #endif
98  bool ok = openGeomFile(is, pathname, visFile);
99  if (!ok) {
100  G4cout << "WARNING: Could not read " << visFile << G4endl;
101  G4cout << " Default visualization parameters will be used." << G4endl;
102  return false;
103  }
104 
105  while (is) {
106  G4String viewvol;
107  readName(is,viewvol);
108 
109  visType vt = Undefined;
110  if (viewvol=="Sensitive")
111  vt=Sensitive;
112  else if (viewvol=="Electronics")
113  vt=Electronics;
114  else if (viewvol=="Support")
115  vt=Support;
116  else if (viewvol=="Absorber")
117  vt=Absorber;
118  else if (viewvol=="Cable")
119  vt=Cable;
120  else if (viewvol=="OtherServices")
121  vt=OtherServices;
122  else if (viewvol=="PseudoVolumes")
123  vt=PseudoVolumes;
124  else {
125  vt=Undefined;
126  G4cerr << "WARNING: Unknown type of visualisable object \"" << viewvol
127  << "\"." << G4endl;
128  }
129 
130 
131  int isvisible, wireframe;
132  double r, g, b;
133 
134  is >> isvisible >> r >> g >> b >> wireframe >> jump;
135 
136  r=checkColorRange(r,'R');
137  g=checkColorRange(g,'G');
138  b=checkColorRange(b,'B');
139 
140  if (vt!=Undefined) {
141 #ifdef debug
142  G4cout << tab << viewvol << tab << isvisible << tab
143  << r << " " << g << " "<< b << tab
144  << wireframe << G4endl;
145 #endif
146  theParameters[vt]=visParameters(isvisible, r, g, b, wireframe);
147  }
148 
149  }
150 
152  // Close the file
153  G4cout << " ==> Closing file " << visFile << G4endl;
154  is.close();
155 
156  return true;
157 }
double checkColorRange(double color, char type) const
bool openGeomFile(std::ifstream &is, const G4String &pathname, const G4String &filename)
Definition: CCalutils.cc:116
std::istream & jump(std::istream &)
Definition: CCalutils.cc:95
static const char * pathName
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5206
std::ifstream & readName(std::ifstream &, G4String &)
Definition: CCalutils.cc:53
G4GLOB_DLL std::ostream G4cout
std::ostream & tab(std::ostream &)
Definition: CCalutils.cc:89
visParameters theParameters[TotalVisTypes]
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setColor()

void CCalVisualisable::setColor ( visType  v,
double  r,
double  g,
double  b 
)

Definition at line 62 of file CCalVisualisable.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setColorBlue()

void CCalVisualisable::setColorBlue ( visType  v,
double  b 
)
inline

Definition at line 88 of file CCalVisualisable.hh.

Here is the call graph for this function:

◆ setColorGreen()

void CCalVisualisable::setColorGreen ( visType  v,
double  g 
)
inline

Definition at line 87 of file CCalVisualisable.hh.

function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5206
visParameters theParameters[TotalVisTypes]
Here is the call graph for this function:

◆ setColorRed()

void CCalVisualisable::setColorRed ( visType  v,
double  r 
)
inline

Definition at line 86 of file CCalVisualisable.hh.

◆ setDefault()

void CCalVisualisable::setDefault ( )

Definition at line 53 of file CCalVisualisable.cc.

53  {
54  theParameters[Sensitive] = visParameters(true);
55  theParameters[Electronics] = visParameters(false);
56  theParameters[Support] = visParameters(false);
57  theParameters[Cable] = visParameters(false);
58  theParameters[OtherServices] = visParameters(false);
59  theParameters[PseudoVolumes] = visParameters(false);
60 }
visParameters theParameters[TotalVisTypes]
Here is the caller graph for this function:

◆ setPath()

void CCalVisualisable::setPath ( )
staticprotected

Definition at line 68 of file CCalVisualisable.cc.

68  {
69  pathName = getenv(visEnvName);
70  if (!pathName) {
72  ed << "ERROR: " << visEnvName << " environmental variable not set!"
73  << G4endl;
74  ed << " Set it and restart." << G4endl;
75  G4Exception("CCalVisualisable::setPath()","ccal007",
76  FatalException,ed);
77  }
78 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const char * visEnvName
static const char * pathName
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVisible()

void CCalVisualisable::setVisible ( visType  v,
bool  flag = true 
)
inline

Definition at line 81 of file CCalVisualisable.hh.

◆ setWireFrame()

void CCalVisualisable::setWireFrame ( visType  v,
bool  wf = true 
)
inline

Definition at line 92 of file CCalVisualisable.hh.

Here is the call graph for this function:

Member Data Documentation

◆ pathName

const char * CCalVisualisable::pathName =0
staticprivate

Definition at line 102 of file CCalVisualisable.hh.

◆ theParameters

visParameters CCalVisualisable::theParameters[TotalVisTypes]
private

Definition at line 104 of file CCalVisualisable.hh.

◆ visFile

G4String CCalVisualisable::visFile
private

Definition at line 103 of file CCalVisualisable.hh.


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