Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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$
27 //
28 #include "G4HepRepMessenger.hh"
29 
31 G4HepRepMessenger::fpInstance = 0;
32 
35 {
36  if (!fpInstance) fpInstance = new G4HepRepMessenger;
37  return fpInstance;
38 }
39 
40 G4HepRepMessenger::G4HepRepMessenger() :
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 ) {
60  setFileDirCommand->SetDefaultValue("");
61  } else {
62  setFileDirCommand->SetDefaultValue(getenv("G4HEPREPFILE_DIR"));
63  fileDir = getenv("G4HEPREPFILE_DIR");
64  }
65  setFileDirCommand->AvailableForStates(G4State_Idle);
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 ) {
72  setFileNameCommand->SetDefaultValue("G4Data");
73  } else {
74  setFileNameCommand->SetDefaultValue(getenv("G4HEPREPFILE_NAME"));
75  fileName = getenv("G4HEPREPFILE_NAME");
76  }
77  setFileNameCommand->AvailableForStates(G4State_Idle);
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.");
83  setOverwriteCommand->SetParameterName("flag",false);
84  if ( getenv( "G4HEPREPFILE_OVERWRITE" ) == NULL ) {
85  setOverwriteCommand->SetDefaultValue(false);
86  } else {
87  setOverwriteCommand->SetDefaultValue(getenv("G4HEPREPFILE_OVERWRITE"));
88  overwrite = setOverwriteCommand->ConvertToBool(getenv("G4HEPREPFILE_OVERWRITE"));
89  }
90  setOverwriteCommand->AvailableForStates(G4State_Idle);
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.");
95  setCullInvisiblesCommand->SetParameterName("flag",false);
96  if ( getenv( "G4HEPREPFILE_CULL" ) == NULL ) {
97  setCullInvisiblesCommand->SetDefaultValue(false);
98  } else {
99  setCullInvisiblesCommand->SetDefaultValue(getenv("G4HEPREPFILE_CULL"));
100  cullInvisibles = setCullInvisiblesCommand->ConvertToBool(getenv("G4HEPREPFILE_CULL"));
101  }
102  setCullInvisiblesCommand->AvailableForStates(G4State_Idle);
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.");
107  renderCylAsPolygonsCommand->SetParameterName("flag",false);
108  renderCylAsPolygonsCommand->SetDefaultValue(false);
109  renderCylAsPolygonsCommand->AvailableForStates(G4State_Idle);
110 
111  setScaleCommand = new G4UIcmdWithADouble("/vis/heprep/scale",this);
112  setScaleCommand->SetGuidance("Re-Scale coordinates.");
113  setScaleCommand->SetParameterName("Scale",true);
114  setScaleCommand->SetDefaultValue(1.);
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);
120  setCenterCommand->SetDefaultValue(G4ThreeVector(0.,0.,0.));
121  setCenterCommand->SetDefaultUnit("m");
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.");
127  setEventNumberSuffixCommand->SetParameterName("suffix",false);
128  setEventNumberSuffixCommand->SetDefaultValue("");
129  setEventNumberSuffixCommand->AvailableForStates(G4State_Idle);
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.");
134  appendGeometryCommand->SetParameterName("flag",false);
135  appendGeometryCommand->SetDefaultValue(true);
136  appendGeometryCommand->AvailableForStates(G4State_Idle);
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.");
141  addPointAttributesCommand->SetParameterName("flag",false);
142  addPointAttributesCommand->SetDefaultValue(false);
143  addPointAttributesCommand->AvailableForStates(G4State_Idle);
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);
149  useSolidsCommand->SetDefaultValue(true);
150  useSolidsCommand->AvailableForStates(G4State_Idle);
151 }
152 
154  delete setFileDirCommand;
155  delete setFileNameCommand;
156  delete setOverwriteCommand;
157  delete setCullInvisiblesCommand;
158  delete renderCylAsPolygonsCommand;
159  delete setScaleCommand;
160  delete setCenterCommand;
161  delete setEventNumberSuffixCommand;
162  delete appendGeometryCommand;
163  delete addPointAttributesCommand;
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) {
178  return renderCylAsPolygonsCommand->ConvertToString(cylAsPolygons);
179  } else if (command==setScaleCommand) {
180  return setScaleCommand->ConvertToString(scale);
181  } else if (command==setCenterCommand) {
182  return setCenterCommand->ConvertToString(center,"m");
183  } else if (command==setEventNumberSuffixCommand) {
184  return suffix;
185  } else if (command==appendGeometryCommand) {
186  return appendGeometryCommand->ConvertToString(geometry);
187  } else if (command==addPointAttributesCommand) {
188  return addPointAttributesCommand->ConvertToString(pointAttributes);
189  } else if (command==useSolidsCommand) {
190  return useSolidsCommand->ConvertToString(solids);
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) {
202  overwrite = setOverwriteCommand->GetNewBoolValue(newValue);
203  } else if (command==setCullInvisiblesCommand) {
204  cullInvisibles = setCullInvisiblesCommand->GetNewBoolValue(newValue);
205  } else if (command==renderCylAsPolygonsCommand) {
206  cylAsPolygons = renderCylAsPolygonsCommand->GetNewBoolValue(newValue);
207  } else if (command==setScaleCommand) {
208  scale = setScaleCommand->GetNewDoubleValue(newValue);
209  } else if (command==setCenterCommand) {
210  center = setCenterCommand->GetNew3VectorValue(newValue);
211  } else if (command==setEventNumberSuffixCommand) {
212  suffix = newValue;
213  } else if (command==appendGeometryCommand) {
214  geometry = appendGeometryCommand->GetNewBoolValue(newValue);
215  } else if (command==addPointAttributesCommand) {
216  pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue);
217  } else if (command==useSolidsCommand) {
218  solids = useSolidsCommand->GetNewBoolValue(newValue);
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