Geant4  10.01
G4HepRepMessenger.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4HepRepMessenger.cc 66870 2013-01-14 23:38:59Z adotti $
27 //
28 #include "G4HepRepMessenger.hh"
29 
32 
35 {
37  return fpInstance;
38 }
39 
41  fileDir(""),
42  fileName("G4Data"),
43  overwrite(false),
44  cullInvisibles(false),
45  cylAsPolygons(false),
46  scale(1.),
47  suffix (""),
48  geometry(true),
49  solids(true),
50  invisibles(true) {
51 
52  heprepDirectory = new G4UIdirectory("/vis/heprep/");
53  heprepDirectory->SetGuidance("HepRep commands.");
54 
55  setFileDirCommand = new G4UIcmdWithAString("/vis/heprep/setFileDir", this);
56  setFileDirCommand->SetGuidance("Set directory for output.");
57  setFileDirCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
58  setFileDirCommand->SetParameterName("directory",false);
59  if ( getenv( "G4HEPREPFILE_DIR" ) == NULL ) {
61  } else {
62  setFileDirCommand->SetDefaultValue(getenv("G4HEPREPFILE_DIR"));
63  fileDir = getenv("G4HEPREPFILE_DIR");
64  }
66 
67  setFileNameCommand = new G4UIcmdWithAString("/vis/heprep/setFileName", this);
68  setFileNameCommand->SetGuidance("Set file name for output.");
69  setFileNameCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
70  setFileNameCommand->SetParameterName("directory",false);
71  if ( getenv( "G4HEPREPFILE_NAME" ) == NULL ) {
73  } else {
74  setFileNameCommand->SetDefaultValue(getenv("G4HEPREPFILE_NAME"));
75  fileName = getenv("G4HEPREPFILE_NAME");
76  }
78 
79  setOverwriteCommand = new G4UIcmdWithABool("/vis/heprep/setOverwrite", this);
80  setOverwriteCommand->SetGuidance("Set true to write all output to exact same file name.");
81  setOverwriteCommand->SetGuidance("Set false to increment the file name for each new output.");
82  setOverwriteCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
84  if ( getenv( "G4HEPREPFILE_OVERWRITE" ) == NULL ) {
86  } else {
87  setOverwriteCommand->SetDefaultValue(getenv("G4HEPREPFILE_OVERWRITE"));
88  overwrite = setOverwriteCommand->ConvertToBool(getenv("G4HEPREPFILE_OVERWRITE"));
89  }
91 
92  setCullInvisiblesCommand = new G4UIcmdWithABool("/vis/heprep/setCullInvisibles", this);
93  setCullInvisiblesCommand->SetGuidance("Remove invisible objects from output file.");
94  setCullInvisiblesCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
96  if ( getenv( "G4HEPREPFILE_CULL" ) == NULL ) {
98  } else {
99  setCullInvisiblesCommand->SetDefaultValue(getenv("G4HEPREPFILE_CULL"));
100  cullInvisibles = setCullInvisiblesCommand->ConvertToBool(getenv("G4HEPREPFILE_CULL"));
101  }
103 
104  renderCylAsPolygonsCommand = new G4UIcmdWithABool("/vis/heprep/renderCylAsPolygons", this);
105  renderCylAsPolygonsCommand->SetGuidance("Render cylinders and cones as polygons.");
106  renderCylAsPolygonsCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
110 
111  setScaleCommand = new G4UIcmdWithADouble("/vis/heprep/scale",this);
112  setScaleCommand->SetGuidance("Re-Scale coordinates.");
113  setScaleCommand->SetParameterName("Scale",true);
115  setScaleCommand->SetRange("Scale > 0");
116 
117  setCenterCommand = new G4UIcmdWith3VectorAndUnit("/vis/heprep/center",this);
118  setCenterCommand->SetGuidance("Re-Center coordinates.");
119  setCenterCommand->SetParameterName("CenterX","CenterY","CenterZ",true);
122 
123  setEventNumberSuffixCommand = new G4UIcmdWithAString("/vis/heprep/setEventNumberSuffix", this);
124  setEventNumberSuffixCommand->SetGuidance("Write separate event files, appended with given suffix.");
125  setEventNumberSuffixCommand->SetGuidance("Define the suffix with a pattern such as '-0000'.");
126  setEventNumberSuffixCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
130 
131  appendGeometryCommand = new G4UIcmdWithABool("/vis/heprep/appendGeometry", this);
132  appendGeometryCommand->SetGuidance("Appends copy of geometry to every event.");
133  appendGeometryCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
137 
138  addPointAttributesCommand = new G4UIcmdWithABool("/vis/heprep/addPointAttributes", this);
139  addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories.");
140  addPointAttributesCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
144 
145  useSolidsCommand = new G4UIcmdWithABool("/vis/heprep/useSolids", this);
146  useSolidsCommand->SetGuidance("Use HepRep Solids, rather than Geant4 Primitives.");
147  useSolidsCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile..");
148  useSolidsCommand->SetParameterName("flag",false);
151 }
152 
154  delete setFileDirCommand;
155  delete setFileNameCommand;
156  delete setOverwriteCommand;
159  delete setScaleCommand;
160  delete setCenterCommand;
162  delete appendGeometryCommand;
164  delete useSolidsCommand;
165  delete heprepDirectory;
166 }
167 
169  if (command==setFileDirCommand) {
170  return fileDir;
171  } else if (command==setFileNameCommand) {
172  return fileName;
173  } else if (command==setOverwriteCommand) {
174  return overwrite;
175  } else if (command==setCullInvisiblesCommand) {
176  return cullInvisibles;
177  } else if (command==renderCylAsPolygonsCommand) {
179  } else if (command==setScaleCommand) {
181  } else if (command==setCenterCommand) {
183  } else if (command==setEventNumberSuffixCommand) {
184  return suffix;
185  } else if (command==appendGeometryCommand) {
187  } else if (command==addPointAttributesCommand) {
189  } else if (command==useSolidsCommand) {
191  } else {
192  return "";
193  }
194 }
195 
197  if (command==setFileDirCommand) {
198  fileDir = newValue;
199  } else if (command==setFileNameCommand) {
200  fileName = newValue;
201  } else if (command==setOverwriteCommand) {
203  } else if (command==setCullInvisiblesCommand) {
205  } else if (command==renderCylAsPolygonsCommand) {
207  } else if (command==setScaleCommand) {
209  } else if (command==setCenterCommand) {
211  } else if (command==setEventNumberSuffixCommand) {
212  suffix = newValue;
213  } else if (command==appendGeometryCommand) {
215  } else if (command==addPointAttributesCommand) {
217  } else if (command==useSolidsCommand) {
219  }
220 }
221 
223  return fileDir;
224 }
225 
227  return fileName;
228 }
229 
231  return overwrite;
232 }
233 
235  return cullInvisibles;
236 }
237 
239  return cylAsPolygons;
240 }
241 
243  return scale;
244 }
245 
247  return center;
248 }
249 
251  return suffix;
252 }
253 
255  return geometry;
256 }
257 
259  return pointAttributes;
260 }
261 
263  return solids;
264 }
265 
267  return invisibles;
268 }
269 
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
virtual G4double getScale()
virtual G4String GetCurrentValue(G4UIcommand *command)
virtual G4String getFileName()
G4UIcmdWithADouble * setScaleCommand
G4UIcmdWith3VectorAndUnit * setCenterCommand
virtual G4bool writeInvisibles()
virtual G4bool renderCylAsPolygons()
CLHEP::Hep3Vector G4ThreeVector
G4UIcmdWithABool * appendGeometryCommand
void SetDefaultUnit(const char *defUnit)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:371
G4UIcmdWithABool * useSolidsCommand
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
static G4bool GetNewBoolValue(const char *paramString)
void SetDefaultValue(G4bool defVal)
virtual G4String getEventNumberSuffix()
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWithAString * setEventNumberSuffixCommand
virtual G4bool getOverwrite()
virtual G4String getFileDir()
virtual G4ThreeVector getCenter()
G4UIcmdWithABool * setOverwriteCommand
G4UIcmdWithAString * setFileDirCommand
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:425
G4UIdirectory * heprepDirectory
bool G4bool
Definition: G4Types.hh:79
static G4double GetNewDoubleValue(const char *paramString)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
virtual G4bool getCullInvisibles()
static G4HepRepMessenger * GetInstance()
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:239
virtual G4bool appendGeometry()
G4ThreeVector center
void SetDefaultValue(G4ThreeVector defVal)
G4UIcmdWithABool * setCullInvisiblesCommand
static G4HepRepMessenger * fpInstance
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
void SetDefaultValue(G4double defVal)
G4UIcmdWithABool * addPointAttributesCommand
G4UIcmdWithAString * setFileNameCommand
G4UIcmdWithABool * renderCylAsPolygonsCommand
virtual G4bool addPointAttributes()
double G4double
Definition: G4Types.hh:76
virtual G4bool useSolids()