[834] | 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 | // |
---|
[1315] | 26 | // $Id: G4HepRepMessenger.cc,v 1.12 2010/06/05 06:25:03 perl Exp $ |
---|
| 27 | // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ |
---|
[834] | 28 | // |
---|
| 29 | #include "G4HepRepMessenger.hh" |
---|
| 30 | |
---|
[1228] | 31 | G4HepRepMessenger* |
---|
| 32 | G4HepRepMessenger::fpInstance = 0; |
---|
| 33 | |
---|
| 34 | G4HepRepMessenger* |
---|
| 35 | G4HepRepMessenger::GetInstance() |
---|
| 36 | { |
---|
| 37 | if (!fpInstance) fpInstance = new G4HepRepMessenger; |
---|
| 38 | return fpInstance; |
---|
| 39 | } |
---|
| 40 | |
---|
[834] | 41 | G4HepRepMessenger::G4HepRepMessenger() : |
---|
[1228] | 42 | fileDir(""), |
---|
| 43 | fileName("G4Data"), |
---|
| 44 | overwrite(false), |
---|
| 45 | cullInvisibles(false), |
---|
[834] | 46 | suffix (""), |
---|
| 47 | geometry(true), |
---|
| 48 | solids(true), |
---|
| 49 | invisibles(true) { |
---|
| 50 | |
---|
| 51 | heprepDirectory = new G4UIdirectory("/vis/heprep/"); |
---|
| 52 | heprepDirectory->SetGuidance("HepRep commands."); |
---|
[1228] | 53 | |
---|
| 54 | setFileDirCommand = new G4UIcmdWithAString("/vis/heprep/setFileDir", this); |
---|
| 55 | setFileDirCommand->SetGuidance("Set directory for output."); |
---|
| 56 | setFileDirCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML."); |
---|
| 57 | setFileDirCommand->SetParameterName("directory",false); |
---|
| 58 | if ( getenv( "G4HEPREPFILE_DIR" ) == NULL ) { |
---|
| 59 | setFileDirCommand->SetDefaultValue(""); |
---|
| 60 | } else { |
---|
| 61 | setFileDirCommand->SetDefaultValue(getenv("G4HEPREPFILE_DIR")); |
---|
| 62 | fileDir = getenv("G4HEPREPFILE_DIR"); |
---|
| 63 | } |
---|
| 64 | setFileDirCommand->AvailableForStates(G4State_Idle); |
---|
| 65 | |
---|
| 66 | setFileNameCommand = new G4UIcmdWithAString("/vis/heprep/setFileName", this); |
---|
| 67 | setFileNameCommand->SetGuidance("Set file name for output."); |
---|
| 68 | setFileNameCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML."); |
---|
| 69 | setFileNameCommand->SetParameterName("directory",false); |
---|
| 70 | if ( getenv( "G4HEPREPFILE_NAME" ) == NULL ) { |
---|
| 71 | setFileNameCommand->SetDefaultValue("G4Data"); |
---|
| 72 | } else { |
---|
| 73 | setFileNameCommand->SetDefaultValue(getenv("G4HEPREPFILE_NAME")); |
---|
| 74 | fileName = getenv("G4HEPREPFILE_NAME"); |
---|
| 75 | } |
---|
| 76 | setFileNameCommand->AvailableForStates(G4State_Idle); |
---|
[834] | 77 | |
---|
[1228] | 78 | setOverwriteCommand = new G4UIcmdWithABool("/vis/heprep/setOverwrite", this); |
---|
| 79 | setOverwriteCommand->SetGuidance("Set true to write all output to exact same file name."); |
---|
| 80 | setOverwriteCommand->SetGuidance("Set false to increment the file name for each new output."); |
---|
| 81 | setOverwriteCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML."); |
---|
| 82 | setOverwriteCommand->SetParameterName("flag",false); |
---|
| 83 | if ( getenv( "G4HEPREPFILE_OVERWRITE" ) == NULL ) { |
---|
| 84 | setOverwriteCommand->SetDefaultValue(false); |
---|
| 85 | } else { |
---|
| 86 | setOverwriteCommand->SetDefaultValue(getenv("G4HEPREPFILE_OVERWRITE")); |
---|
| 87 | overwrite = setOverwriteCommand->ConvertToBool(getenv("G4HEPREPFILE_OVERWRITE")); |
---|
| 88 | } |
---|
| 89 | setOverwriteCommand->AvailableForStates(G4State_Idle); |
---|
| 90 | |
---|
| 91 | setCullInvisiblesCommand = new G4UIcmdWithABool("/vis/heprep/setCullInvisibles", this); |
---|
| 92 | setCullInvisiblesCommand->SetGuidance("Remove invisible objects from output file."); |
---|
| 93 | setCullInvisiblesCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML."); |
---|
| 94 | setCullInvisiblesCommand->SetParameterName("flag",false); |
---|
| 95 | if ( getenv( "G4HEPREPFILE_CULL" ) == NULL ) { |
---|
| 96 | setCullInvisiblesCommand->SetDefaultValue(false); |
---|
| 97 | } else { |
---|
| 98 | setCullInvisiblesCommand->SetDefaultValue(getenv("G4HEPREPFILE_CULL")); |
---|
| 99 | cullInvisibles = setCullInvisiblesCommand->ConvertToBool(getenv("G4HEPREPFILE_CULL")); |
---|
| 100 | } |
---|
| 101 | setCullInvisiblesCommand->AvailableForStates(G4State_Idle); |
---|
| 102 | |
---|
[1315] | 103 | renderCylAsPolygonsCommand = new G4UIcmdWithABool("/vis/heprep/renderCylAsPolygons", this); |
---|
| 104 | renderCylAsPolygonsCommand->SetGuidance("Render cylinders and cones as polygons."); |
---|
| 105 | renderCylAsPolygonsCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML."); |
---|
| 106 | renderCylAsPolygonsCommand->SetParameterName("flag",false); |
---|
| 107 | renderCylAsPolygonsCommand->SetDefaultValue(true); |
---|
| 108 | renderCylAsPolygonsCommand->AvailableForStates(G4State_Idle); |
---|
| 109 | |
---|
[834] | 110 | setEventNumberSuffixCommand = new G4UIcmdWithAString("/vis/heprep/setEventNumberSuffix", this); |
---|
| 111 | setEventNumberSuffixCommand->SetGuidance("Write separate event files, appended with given suffix."); |
---|
| 112 | setEventNumberSuffixCommand->SetGuidance("Define the suffix with a pattern such as '-0000'."); |
---|
[1228] | 113 | setEventNumberSuffixCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile."); |
---|
[834] | 114 | setEventNumberSuffixCommand->SetParameterName("suffix",false); |
---|
| 115 | setEventNumberSuffixCommand->SetDefaultValue(""); |
---|
| 116 | setEventNumberSuffixCommand->AvailableForStates(G4State_Idle); |
---|
| 117 | |
---|
| 118 | appendGeometryCommand = new G4UIcmdWithABool("/vis/heprep/appendGeometry", this); |
---|
| 119 | appendGeometryCommand->SetGuidance("Appends copy of geometry to every event."); |
---|
[1228] | 120 | appendGeometryCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile."); |
---|
[834] | 121 | appendGeometryCommand->SetParameterName("flag",false); |
---|
| 122 | appendGeometryCommand->SetDefaultValue(true); |
---|
| 123 | appendGeometryCommand->AvailableForStates(G4State_Idle); |
---|
| 124 | |
---|
| 125 | addPointAttributesCommand = new G4UIcmdWithABool("/vis/heprep/addPointAttributes", this); |
---|
| 126 | addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories."); |
---|
[1228] | 127 | addPointAttributesCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile."); |
---|
[834] | 128 | addPointAttributesCommand->SetParameterName("flag",false); |
---|
| 129 | addPointAttributesCommand->SetDefaultValue(false); |
---|
| 130 | addPointAttributesCommand->AvailableForStates(G4State_Idle); |
---|
[1315] | 131 | |
---|
| 132 | useSolidsCommand = new G4UIcmdWithABool("/vis/heprep/useSolids", this); |
---|
| 133 | useSolidsCommand->SetGuidance("Use HepRep Solids, rather than Geant4 Primitives."); |
---|
| 134 | useSolidsCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.."); |
---|
| 135 | useSolidsCommand->SetParameterName("flag",false); |
---|
| 136 | useSolidsCommand->SetDefaultValue(true); |
---|
| 137 | useSolidsCommand->AvailableForStates(G4State_Idle); |
---|
[834] | 138 | } |
---|
| 139 | |
---|
| 140 | G4HepRepMessenger::~G4HepRepMessenger() { |
---|
[1228] | 141 | delete setFileDirCommand; |
---|
| 142 | delete setFileNameCommand; |
---|
| 143 | delete setOverwriteCommand; |
---|
| 144 | delete setCullInvisiblesCommand; |
---|
[1315] | 145 | delete renderCylAsPolygonsCommand; |
---|
[834] | 146 | delete setEventNumberSuffixCommand; |
---|
| 147 | delete appendGeometryCommand; |
---|
| 148 | delete addPointAttributesCommand; |
---|
| 149 | delete useSolidsCommand; |
---|
| 150 | delete heprepDirectory; |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | G4String G4HepRepMessenger::GetCurrentValue(G4UIcommand * command) { |
---|
[1228] | 154 | if (command==setFileDirCommand) { |
---|
| 155 | return fileDir; |
---|
| 156 | } else if (command==setFileNameCommand) { |
---|
| 157 | return fileName; |
---|
| 158 | } else if (command==setOverwriteCommand) { |
---|
| 159 | return overwrite; |
---|
| 160 | } else if (command==setCullInvisiblesCommand) { |
---|
| 161 | return cullInvisibles; |
---|
[1315] | 162 | } else if (command==renderCylAsPolygonsCommand) { |
---|
| 163 | return renderCylAsPolygonsCommand->ConvertToString(cylAsPolygons); |
---|
[1228] | 164 | } else if (command==setEventNumberSuffixCommand) { |
---|
| 165 | return suffix; |
---|
[834] | 166 | } else if (command==appendGeometryCommand) { |
---|
| 167 | return appendGeometryCommand->ConvertToString(geometry); |
---|
| 168 | } else if (command==addPointAttributesCommand) { |
---|
| 169 | return addPointAttributesCommand->ConvertToString(pointAttributes); |
---|
| 170 | } else if (command==useSolidsCommand) { |
---|
| 171 | return useSolidsCommand->ConvertToString(solids); |
---|
| 172 | } else { |
---|
| 173 | return ""; |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | void G4HepRepMessenger::SetNewValue(G4UIcommand * command, G4String newValue) { |
---|
[1228] | 178 | if (command==setFileDirCommand) { |
---|
| 179 | fileDir = newValue; |
---|
| 180 | } else if (command==setFileNameCommand) { |
---|
| 181 | fileName = newValue; |
---|
| 182 | } else if (command==setOverwriteCommand) { |
---|
| 183 | overwrite = setOverwriteCommand->GetNewBoolValue(newValue); |
---|
| 184 | } else if (command==setCullInvisiblesCommand) { |
---|
| 185 | cullInvisibles = setCullInvisiblesCommand->GetNewBoolValue(newValue); |
---|
[1315] | 186 | } else if (command==renderCylAsPolygonsCommand) { |
---|
| 187 | cylAsPolygons = renderCylAsPolygonsCommand->GetNewBoolValue(newValue); |
---|
[1228] | 188 | } else if (command==setEventNumberSuffixCommand) { |
---|
[834] | 189 | suffix = newValue; |
---|
| 190 | } else if (command==appendGeometryCommand) { |
---|
| 191 | geometry = appendGeometryCommand->GetNewBoolValue(newValue); |
---|
| 192 | } else if (command==addPointAttributesCommand) { |
---|
| 193 | pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue); |
---|
| 194 | } else if (command==useSolidsCommand) { |
---|
| 195 | solids = useSolidsCommand->GetNewBoolValue(newValue); |
---|
| 196 | } |
---|
| 197 | } |
---|
| 198 | |
---|
[1228] | 199 | G4String G4HepRepMessenger::getFileDir() { |
---|
| 200 | return fileDir; |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | G4String G4HepRepMessenger::getFileName() { |
---|
| 204 | return fileName; |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | G4bool G4HepRepMessenger::getOverwrite() { |
---|
| 208 | return overwrite; |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | G4bool G4HepRepMessenger::getCullInvisibles() { |
---|
| 212 | return cullInvisibles; |
---|
| 213 | } |
---|
| 214 | |
---|
[1315] | 215 | G4bool G4HepRepMessenger::renderCylAsPolygons() { |
---|
| 216 | return cylAsPolygons; |
---|
| 217 | } |
---|
| 218 | |
---|
[834] | 219 | G4String G4HepRepMessenger::getEventNumberSuffix() { |
---|
| 220 | return suffix; |
---|
| 221 | } |
---|
| 222 | |
---|
| 223 | G4bool G4HepRepMessenger::appendGeometry() { |
---|
| 224 | return geometry; |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | G4bool G4HepRepMessenger::addPointAttributes() { |
---|
| 228 | return pointAttributes; |
---|
| 229 | } |
---|
| 230 | |
---|
| 231 | G4bool G4HepRepMessenger::useSolids() { |
---|
| 232 | return solids; |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | G4bool G4HepRepMessenger::writeInvisibles() { |
---|
| 236 | return invisibles; |
---|
| 237 | } |
---|
| 238 | |
---|