Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions
CCalVisualisable Class Reference

#include <CCalVisualisable.hh>

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 ()
 

Detailed Description

Definition at line 39 of file CCalVisualisable.hh.

Member Enumeration Documentation

Constructor & Destructor Documentation

CCalVisualisable::CCalVisualisable ( G4String  file)

Definition at line 41 of file CCalVisualisable.cc.

References readFile(), setDefault(), and setPath().

41  :visFile(file) {
42  if (!pathName)
43  setPath();
44  setDefault();
45  readFile();
46 }
static void setPath()
virtual CCalVisualisable::~CCalVisualisable ( )
inlinevirtual

Definition at line 71 of file CCalVisualisable.hh.

71 {}

Member Function Documentation

double CCalVisualisable::colorBlue ( visType  v) const
inline

Definition at line 85 of file CCalVisualisable.hh.

References test::v.

Referenced by CCalG4Able::setVisType().

85 {return theParameters[v].bColor;}
double CCalVisualisable::colorGreen ( visType  v) const
inline

Definition at line 84 of file CCalVisualisable.hh.

References test::v.

Referenced by CCalG4Able::setVisType().

84 {return theParameters[v].gColor;}
double CCalVisualisable::colorRed ( visType  v) const
inline

Definition at line 83 of file CCalVisualisable.hh.

References test::v.

Referenced by CCalG4Able::setVisType().

83 {return theParameters[v].rColor;}
bool CCalVisualisable::isVisible ( visType  v) const
inline

Definition at line 80 of file CCalVisualisable.hh.

References test::v.

Referenced by CCalG4Able::setVisType().

80 {return theParameters[v].visibility;}
bool CCalVisualisable::isWireFrame ( visType  v) const
inline

Definition at line 91 of file CCalVisualisable.hh.

References test::v.

Referenced by CCalG4Able::setVisType().

91 {return theParameters[v].wireframe;}
bool CCalVisualisable::readFile ( G4String  file)

Definition at line 48 of file CCalVisualisable.cc.

References readFile().

48  {
49  visFile=file;
50  return readFile();
51 }
bool CCalVisualisable::readFile ( )
protected

Definition at line 78 of file CCalVisualisable.cc.

References Absorber, test::b, Cable, Electronics, g(), G4cerr, G4cout, G4endl, jump(), openGeomFile(), OtherServices, PseudoVolumes, readName(), Sensitive, Support, tab(), and Undefined.

Referenced by CCalVisualisable(), and readFile().

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

Definition at line 62 of file CCalVisualisable.cc.

References test::b, g(), and test::v.

62  {
63  theParameters[v].rColor=r;
64  theParameters[v].gColor=g;
65  theParameters[v].bColor=b;
66 }
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
void CCalVisualisable::setColorBlue ( visType  v,
double  b 
)
inline

Definition at line 88 of file CCalVisualisable.hh.

References test::b, and test::v.

88 {theParameters[v].bColor=b;}
void CCalVisualisable::setColorGreen ( visType  v,
double  g 
)
inline

Definition at line 87 of file CCalVisualisable.hh.

References g(), and test::v.

87 {theParameters[v].gColor=g;}
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
void CCalVisualisable::setColorRed ( visType  v,
double  r 
)
inline

Definition at line 86 of file CCalVisualisable.hh.

References test::v.

86 {theParameters[v].rColor=r;}
void CCalVisualisable::setDefault ( )

Definition at line 53 of file CCalVisualisable.cc.

References Cable, Electronics, OtherServices, PseudoVolumes, Sensitive, and Support.

Referenced by CCalVisualisable().

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 }
void CCalVisualisable::setPath ( )
staticprotected

Definition at line 68 of file CCalVisualisable.cc.

References G4cerr, G4endl, and visEnvName.

Referenced by CCalVisualisable().

68  {
69  pathName = getenv(visEnvName);
70  if (!pathName) {
71  G4cerr << "ERROR: " << visEnvName << " environmental variable not set!"
72  << G4endl;
73  G4cerr << " Set it and restart." << G4endl;
74  exit(-333);
75  }
76 }
const char * visEnvName
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
void CCalVisualisable::setVisible ( visType  v,
bool  flag = true 
)
inline

Definition at line 81 of file CCalVisualisable.hh.

References test::v.

81 {theParameters[v].visibility=flag;}
void CCalVisualisable::setWireFrame ( visType  v,
bool  wf = true 
)
inline

Definition at line 92 of file CCalVisualisable.hh.

References test::v.

92 {theParameters[v].wireframe=wf;}

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