| 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,v 1.13 2010/06/21 04:43:07 perl Exp $
|
|---|
| 27 | // GEANT4 tag $Name: geant4-09-04-beta-01 $
|
|---|
| 28 | //
|
|---|
| 29 | #include "G4HepRepMessenger.hh"
|
|---|
| 30 |
|
|---|
| 31 | G4HepRepMessenger*
|
|---|
| 32 | G4HepRepMessenger::fpInstance = 0;
|
|---|
| 33 |
|
|---|
| 34 | G4HepRepMessenger*
|
|---|
| 35 | G4HepRepMessenger::GetInstance()
|
|---|
| 36 | {
|
|---|
| 37 | if (!fpInstance) fpInstance = new G4HepRepMessenger;
|
|---|
| 38 | return fpInstance;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | G4HepRepMessenger::G4HepRepMessenger() :
|
|---|
| 42 | fileDir(""),
|
|---|
| 43 | fileName("G4Data"),
|
|---|
| 44 | overwrite(false),
|
|---|
| 45 | cullInvisibles(false),
|
|---|
| 46 | cylAsPolygons(false),
|
|---|
| 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 | setEventNumberSuffixCommand = new G4UIcmdWithAString("/vis/heprep/setEventNumberSuffix", this);
|
|---|
| 112 | setEventNumberSuffixCommand->SetGuidance("Write separate event files, appended with given suffix.");
|
|---|
| 113 | setEventNumberSuffixCommand->SetGuidance("Define the suffix with a pattern such as '-0000'.");
|
|---|
| 114 | setEventNumberSuffixCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
|
|---|
| 115 | setEventNumberSuffixCommand->SetParameterName("suffix",false);
|
|---|
| 116 | setEventNumberSuffixCommand->SetDefaultValue("");
|
|---|
| 117 | setEventNumberSuffixCommand->AvailableForStates(G4State_Idle);
|
|---|
| 118 |
|
|---|
| 119 | appendGeometryCommand = new G4UIcmdWithABool("/vis/heprep/appendGeometry", this);
|
|---|
| 120 | appendGeometryCommand->SetGuidance("Appends copy of geometry to every event.");
|
|---|
| 121 | appendGeometryCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
|
|---|
| 122 | appendGeometryCommand->SetParameterName("flag",false);
|
|---|
| 123 | appendGeometryCommand->SetDefaultValue(true);
|
|---|
| 124 | appendGeometryCommand->AvailableForStates(G4State_Idle);
|
|---|
| 125 |
|
|---|
| 126 | addPointAttributesCommand = new G4UIcmdWithABool("/vis/heprep/addPointAttributes", this);
|
|---|
| 127 | addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories.");
|
|---|
| 128 | addPointAttributesCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
|
|---|
| 129 | addPointAttributesCommand->SetParameterName("flag",false);
|
|---|
| 130 | addPointAttributesCommand->SetDefaultValue(false);
|
|---|
| 131 | addPointAttributesCommand->AvailableForStates(G4State_Idle);
|
|---|
| 132 |
|
|---|
| 133 | useSolidsCommand = new G4UIcmdWithABool("/vis/heprep/useSolids", this);
|
|---|
| 134 | useSolidsCommand->SetGuidance("Use HepRep Solids, rather than Geant4 Primitives.");
|
|---|
| 135 | useSolidsCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile..");
|
|---|
| 136 | useSolidsCommand->SetParameterName("flag",false);
|
|---|
| 137 | useSolidsCommand->SetDefaultValue(true);
|
|---|
| 138 | useSolidsCommand->AvailableForStates(G4State_Idle);
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | G4HepRepMessenger::~G4HepRepMessenger() {
|
|---|
| 142 | delete setFileDirCommand;
|
|---|
| 143 | delete setFileNameCommand;
|
|---|
| 144 | delete setOverwriteCommand;
|
|---|
| 145 | delete setCullInvisiblesCommand;
|
|---|
| 146 | delete renderCylAsPolygonsCommand;
|
|---|
| 147 | delete setEventNumberSuffixCommand;
|
|---|
| 148 | delete appendGeometryCommand;
|
|---|
| 149 | delete addPointAttributesCommand;
|
|---|
| 150 | delete useSolidsCommand;
|
|---|
| 151 | delete heprepDirectory;
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | G4String G4HepRepMessenger::GetCurrentValue(G4UIcommand * command) {
|
|---|
| 155 | if (command==setFileDirCommand) {
|
|---|
| 156 | return fileDir;
|
|---|
| 157 | } else if (command==setFileNameCommand) {
|
|---|
| 158 | return fileName;
|
|---|
| 159 | } else if (command==setOverwriteCommand) {
|
|---|
| 160 | return overwrite;
|
|---|
| 161 | } else if (command==setCullInvisiblesCommand) {
|
|---|
| 162 | return cullInvisibles;
|
|---|
| 163 | } else if (command==renderCylAsPolygonsCommand) {
|
|---|
| 164 | return renderCylAsPolygonsCommand->ConvertToString(cylAsPolygons);
|
|---|
| 165 | } else if (command==setEventNumberSuffixCommand) {
|
|---|
| 166 | return suffix;
|
|---|
| 167 | } else if (command==appendGeometryCommand) {
|
|---|
| 168 | return appendGeometryCommand->ConvertToString(geometry);
|
|---|
| 169 | } else if (command==addPointAttributesCommand) {
|
|---|
| 170 | return addPointAttributesCommand->ConvertToString(pointAttributes);
|
|---|
| 171 | } else if (command==useSolidsCommand) {
|
|---|
| 172 | return useSolidsCommand->ConvertToString(solids);
|
|---|
| 173 | } else {
|
|---|
| 174 | return "";
|
|---|
| 175 | }
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | void G4HepRepMessenger::SetNewValue(G4UIcommand * command, G4String newValue) {
|
|---|
| 179 | if (command==setFileDirCommand) {
|
|---|
| 180 | fileDir = newValue;
|
|---|
| 181 | } else if (command==setFileNameCommand) {
|
|---|
| 182 | fileName = newValue;
|
|---|
| 183 | } else if (command==setOverwriteCommand) {
|
|---|
| 184 | overwrite = setOverwriteCommand->GetNewBoolValue(newValue);
|
|---|
| 185 | } else if (command==setCullInvisiblesCommand) {
|
|---|
| 186 | cullInvisibles = setCullInvisiblesCommand->GetNewBoolValue(newValue);
|
|---|
| 187 | } else if (command==renderCylAsPolygonsCommand) {
|
|---|
| 188 | cylAsPolygons = renderCylAsPolygonsCommand->GetNewBoolValue(newValue);
|
|---|
| 189 | } else if (command==setEventNumberSuffixCommand) {
|
|---|
| 190 | suffix = newValue;
|
|---|
| 191 | } else if (command==appendGeometryCommand) {
|
|---|
| 192 | geometry = appendGeometryCommand->GetNewBoolValue(newValue);
|
|---|
| 193 | } else if (command==addPointAttributesCommand) {
|
|---|
| 194 | pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue);
|
|---|
| 195 | } else if (command==useSolidsCommand) {
|
|---|
| 196 | solids = useSolidsCommand->GetNewBoolValue(newValue);
|
|---|
| 197 | }
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | G4String G4HepRepMessenger::getFileDir() {
|
|---|
| 201 | return fileDir;
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | G4String G4HepRepMessenger::getFileName() {
|
|---|
| 205 | return fileName;
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | G4bool G4HepRepMessenger::getOverwrite() {
|
|---|
| 209 | return overwrite;
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | G4bool G4HepRepMessenger::getCullInvisibles() {
|
|---|
| 213 | return cullInvisibles;
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | G4bool G4HepRepMessenger::renderCylAsPolygons() {
|
|---|
| 217 | return cylAsPolygons;
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 | G4String G4HepRepMessenger::getEventNumberSuffix() {
|
|---|
| 221 | return suffix;
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | G4bool G4HepRepMessenger::appendGeometry() {
|
|---|
| 225 | return geometry;
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | G4bool G4HepRepMessenger::addPointAttributes() {
|
|---|
| 229 | return pointAttributes;
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | G4bool G4HepRepMessenger::useSolids() {
|
|---|
| 233 | return solids;
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | G4bool G4HepRepMessenger::writeInvisibles() {
|
|---|
| 237 | return invisibles;
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|