Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 #include "G4HepRepMessenger.hh" 28 29 G4HepRepMessenger* G4HepRepMessenger::fpInstan 30 31 G4HepRepMessenger* G4HepRepMessenger::GetInsta 32 { 33 if(!fpInstance) 34 fpInstance = new G4HepRepMessenger; 35 return fpInstance; 36 } 37 38 G4HepRepMessenger::G4HepRepMessenger() 39 : fileDir("") 40 , fileName("G4Data") 41 , overwrite(false) 42 , cullInvisibles(false) 43 , cylAsPolygons(false) 44 , scale(1.) 45 , suffix("") 46 , geometry(true) 47 , pointAttributes(false) 48 , solids(true) 49 , invisibles(true) 50 { 51 heprepDirectory = new G4UIdirectory("/vis/he 52 heprepDirectory->SetGuidance("HepRep command 53 54 setFileDirCommand = new G4UIcmdWithAString(" 55 setFileDirCommand->SetGuidance("Set director 56 setFileDirCommand->SetGuidance( 57 "This command is used by HepRepFile, not b 58 setFileDirCommand->SetParameterName("directo 59 if(std::getenv("G4HEPREPFILE_DIR") == NULL) 60 { 61 setFileDirCommand->SetDefaultValue(""); 62 } 63 else 64 { 65 setFileDirCommand->SetDefaultValue(std::ge 66 fileDir = std::getenv("G4HEPREPFILE_DIR"); 67 } 68 setFileDirCommand->AvailableForStates(G4Stat 69 70 setFileNameCommand = new G4UIcmdWithAString( 71 setFileNameCommand->SetGuidance("Set file na 72 setFileNameCommand->SetGuidance( 73 "This command is used by HepRepFile, not b 74 setFileNameCommand->SetParameterName("direct 75 if(std::getenv("G4HEPREPFILE_NAME") == NULL) 76 { 77 setFileNameCommand->SetDefaultValue("G4Dat 78 } 79 else 80 { 81 setFileNameCommand->SetDefaultValue(std::g 82 fileName = std::getenv("G4HEPREPFILE_NAME" 83 } 84 setFileNameCommand->AvailableForStates(G4Sta 85 86 setOverwriteCommand = new G4UIcmdWithABool(" 87 setOverwriteCommand->SetGuidance( 88 "Set true to write all output to exact sam 89 setOverwriteCommand->SetGuidance( 90 "Set false to increment the file name for 91 setOverwriteCommand->SetGuidance( 92 "This command is used by HepRepFile, not b 93 setOverwriteCommand->SetParameterName("flag" 94 if(std::getenv("G4HEPREPFILE_OVERWRITE") == 95 { 96 setOverwriteCommand->SetDefaultValue(false 97 } 98 else 99 { 100 setOverwriteCommand->SetDefaultValue(std:: 101 overwrite = 102 setOverwriteCommand->ConvertToBool(std:: 103 } 104 setOverwriteCommand->AvailableForStates(G4St 105 106 setCullInvisiblesCommand = 107 new G4UIcmdWithABool("/vis/heprep/setCullI 108 setCullInvisiblesCommand->SetGuidance( 109 "Remove invisible objects from output file 110 setCullInvisiblesCommand->SetGuidance( 111 "This command is used by HepRepFile, not b 112 setCullInvisiblesCommand->SetParameterName(" 113 if(std::getenv("G4HEPREPFILE_CULL") == NULL) 114 { 115 setCullInvisiblesCommand->SetDefaultValue( 116 } 117 else 118 { 119 setCullInvisiblesCommand->SetDefaultValue( 120 cullInvisibles = 121 setCullInvisiblesCommand->ConvertToBool( 122 } 123 setCullInvisiblesCommand->AvailableForStates 124 125 renderCylAsPolygonsCommand = 126 new G4UIcmdWithABool("/vis/heprep/renderCy 127 renderCylAsPolygonsCommand->SetGuidance( 128 "Render cylinders and cones as polygons.") 129 renderCylAsPolygonsCommand->SetGuidance( 130 "This command is used by HepRepFile, not b 131 renderCylAsPolygonsCommand->SetParameterName 132 renderCylAsPolygonsCommand->SetDefaultValue( 133 renderCylAsPolygonsCommand->AvailableForStat 134 135 setScaleCommand = new G4UIcmdWithADouble("/v 136 setScaleCommand->SetGuidance("Re-Scale coord 137 setScaleCommand->SetParameterName("Scale", t 138 setScaleCommand->SetDefaultValue(1.); 139 setScaleCommand->SetRange("Scale > 0"); 140 141 setCenterCommand = new G4UIcmdWith3VectorAnd 142 setCenterCommand->SetGuidance("Re-Center coo 143 setCenterCommand->SetParameterName("CenterX" 144 setCenterCommand->SetDefaultValue(G4ThreeVec 145 setCenterCommand->SetDefaultUnit("m"); 146 147 setEventNumberSuffixCommand = 148 new G4UIcmdWithAString("/vis/heprep/setEve 149 setEventNumberSuffixCommand->SetGuidance( 150 "Write separate event files, appended with 151 setEventNumberSuffixCommand->SetGuidance( 152 "Define the suffix with a pattern such as 153 setEventNumberSuffixCommand->SetGuidance( 154 "This command is used by HepRepXML, not by 155 setEventNumberSuffixCommand->SetParameterNam 156 setEventNumberSuffixCommand->SetDefaultValue 157 setEventNumberSuffixCommand->AvailableForSta 158 159 appendGeometryCommand = 160 new G4UIcmdWithABool("/vis/heprep/appendGe 161 appendGeometryCommand->SetGuidance( 162 "Appends copy of geometry to every event." 163 appendGeometryCommand->SetGuidance( 164 "This command is used by HepRepXML, not by 165 appendGeometryCommand->SetParameterName("fla 166 appendGeometryCommand->SetDefaultValue(true) 167 appendGeometryCommand->AvailableForStates(G4 168 169 addPointAttributesCommand = 170 new G4UIcmdWithABool("/vis/heprep/addPoint 171 addPointAttributesCommand->SetGuidance( 172 "Adds point attributes to the points of tr 173 addPointAttributesCommand->SetGuidance( 174 "This command is used by HepRepXML, not by 175 addPointAttributesCommand->SetParameterName( 176 addPointAttributesCommand->SetDefaultValue(f 177 addPointAttributesCommand->AvailableForState 178 179 useSolidsCommand = new G4UIcmdWithABool("/vi 180 useSolidsCommand->SetGuidance( 181 "Use HepRep Solids, rather than Geant4 Pri 182 useSolidsCommand->SetGuidance( 183 "This command is used by HepRepXML, not by 184 useSolidsCommand->SetParameterName("flag", f 185 useSolidsCommand->SetDefaultValue(true); 186 useSolidsCommand->AvailableForStates(G4State 187 } 188 189 G4HepRepMessenger::~G4HepRepMessenger() 190 { 191 delete setFileDirCommand; 192 delete setFileNameCommand; 193 delete setOverwriteCommand; 194 delete setCullInvisiblesCommand; 195 delete renderCylAsPolygonsCommand; 196 delete setScaleCommand; 197 delete setCenterCommand; 198 delete setEventNumberSuffixCommand; 199 delete appendGeometryCommand; 200 delete addPointAttributesCommand; 201 delete useSolidsCommand; 202 delete heprepDirectory; 203 } 204 205 G4String G4HepRepMessenger::GetCurrentValue(G4 206 { 207 if(command == setFileDirCommand) 208 { 209 return fileDir; 210 } 211 else if(command == setFileNameCommand) 212 { 213 return fileName; 214 } 215 else if(command == setOverwriteCommand) 216 { 217 return G4UIcommand::ConvertToString(overwr 218 } 219 else if(command == setCullInvisiblesCommand) 220 { 221 return G4UIcommand::ConvertToString(cullIn 222 } 223 else if(command == renderCylAsPolygonsComman 224 { 225 return renderCylAsPolygonsCommand->Convert 226 } 227 else if(command == setScaleCommand) 228 { 229 return setScaleCommand->ConvertToString(sc 230 } 231 else if(command == setCenterCommand) 232 { 233 return setCenterCommand->ConvertToString(c 234 } 235 else if(command == setEventNumberSuffixComma 236 { 237 return suffix; 238 } 239 else if(command == appendGeometryCommand) 240 { 241 return appendGeometryCommand->ConvertToStr 242 } 243 else if(command == addPointAttributesCommand 244 { 245 return addPointAttributesCommand->ConvertT 246 } 247 else if(command == useSolidsCommand) 248 { 249 return useSolidsCommand->ConvertToString(s 250 } 251 else 252 { 253 return ""; 254 } 255 } 256 257 void G4HepRepMessenger::SetNewValue(G4UIcomman 258 { 259 if(command == setFileDirCommand) 260 { 261 fileDir = newValue; 262 } 263 else if(command == setFileNameCommand) 264 { 265 fileName = newValue; 266 } 267 else if(command == setOverwriteCommand) 268 { 269 overwrite = setOverwriteCommand->GetNewBoo 270 } 271 else if(command == setCullInvisiblesCommand) 272 { 273 cullInvisibles = setCullInvisiblesCommand- 274 } 275 else if(command == renderCylAsPolygonsComman 276 { 277 cylAsPolygons = renderCylAsPolygonsCommand 278 } 279 else if(command == setScaleCommand) 280 { 281 scale = setScaleCommand->GetNewDoubleValue 282 } 283 else if(command == setCenterCommand) 284 { 285 center = setCenterCommand->GetNew3VectorVa 286 } 287 else if(command == setEventNumberSuffixComma 288 { 289 suffix = newValue; 290 } 291 else if(command == appendGeometryCommand) 292 { 293 geometry = appendGeometryCommand->GetNewBo 294 } 295 else if(command == addPointAttributesCommand 296 { 297 pointAttributes = addPointAttributesComman 298 } 299 else if(command == useSolidsCommand) 300 { 301 solids = useSolidsCommand->GetNewBoolValue 302 } 303 } 304 305 G4String G4HepRepMessenger::getFileDir() { ret 306 307 G4String G4HepRepMessenger::getFileName() { re 308 309 G4bool G4HepRepMessenger::getOverwrite() { ret 310 311 G4bool G4HepRepMessenger::getCullInvisibles() 312 313 G4bool G4HepRepMessenger::renderCylAsPolygons( 314 315 G4double G4HepRepMessenger::getScale() { retur 316 317 G4ThreeVector G4HepRepMessenger::getCenter() { 318 319 G4String G4HepRepMessenger::getEventNumberSuff 320 321 G4bool G4HepRepMessenger::appendGeometry() { r 322 323 G4bool G4HepRepMessenger::addPointAttributes() 324 325 G4bool G4HepRepMessenger::useSolids() { return 326 327 G4bool G4HepRepMessenger::writeInvisibles() { 328