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.11 2009/11/23 05:42:28 perl Exp $ |
---|
27 | // GEANT4 tag $Name: $ |
---|
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 | suffix (""), |
---|
47 | geometry(true), |
---|
48 | solids(true), |
---|
49 | invisibles(true) { |
---|
50 | |
---|
51 | heprepDirectory = new G4UIdirectory("/vis/heprep/"); |
---|
52 | heprepDirectory->SetGuidance("HepRep commands."); |
---|
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); |
---|
77 | |
---|
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 | |
---|
103 | setEventNumberSuffixCommand = new G4UIcmdWithAString("/vis/heprep/setEventNumberSuffix", this); |
---|
104 | setEventNumberSuffixCommand->SetGuidance("Write separate event files, appended with given suffix."); |
---|
105 | setEventNumberSuffixCommand->SetGuidance("Define the suffix with a pattern such as '-0000'."); |
---|
106 | setEventNumberSuffixCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile."); |
---|
107 | setEventNumberSuffixCommand->SetParameterName("suffix",false); |
---|
108 | setEventNumberSuffixCommand->SetDefaultValue(""); |
---|
109 | setEventNumberSuffixCommand->AvailableForStates(G4State_Idle); |
---|
110 | |
---|
111 | appendGeometryCommand = new G4UIcmdWithABool("/vis/heprep/appendGeometry", this); |
---|
112 | appendGeometryCommand->SetGuidance("Appends copy of geometry to every event."); |
---|
113 | appendGeometryCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile."); |
---|
114 | appendGeometryCommand->SetParameterName("flag",false); |
---|
115 | appendGeometryCommand->SetDefaultValue(true); |
---|
116 | appendGeometryCommand->AvailableForStates(G4State_Idle); |
---|
117 | |
---|
118 | addPointAttributesCommand = new G4UIcmdWithABool("/vis/heprep/addPointAttributes", this); |
---|
119 | addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories."); |
---|
120 | addPointAttributesCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile."); |
---|
121 | addPointAttributesCommand->SetParameterName("flag",false); |
---|
122 | addPointAttributesCommand->SetDefaultValue(false); |
---|
123 | addPointAttributesCommand->AvailableForStates(G4State_Idle); |
---|
124 | |
---|
125 | useSolidsCommand = new G4UIcmdWithABool("/vis/heprep/useSolids", this); |
---|
126 | useSolidsCommand->SetGuidance("Use HepRep Solids, rather than Geant4 Primitives."); |
---|
127 | useSolidsCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile."); |
---|
128 | useSolidsCommand->SetParameterName("flag",false); |
---|
129 | useSolidsCommand->SetDefaultValue(true); |
---|
130 | useSolidsCommand->AvailableForStates(G4State_Idle); |
---|
131 | } |
---|
132 | |
---|
133 | G4HepRepMessenger::~G4HepRepMessenger() { |
---|
134 | delete setFileDirCommand; |
---|
135 | delete setFileNameCommand; |
---|
136 | delete setOverwriteCommand; |
---|
137 | delete setCullInvisiblesCommand; |
---|
138 | delete setEventNumberSuffixCommand; |
---|
139 | delete appendGeometryCommand; |
---|
140 | delete addPointAttributesCommand; |
---|
141 | delete useSolidsCommand; |
---|
142 | delete heprepDirectory; |
---|
143 | } |
---|
144 | |
---|
145 | G4String G4HepRepMessenger::GetCurrentValue(G4UIcommand * command) { |
---|
146 | if (command==setFileDirCommand) { |
---|
147 | return fileDir; |
---|
148 | } else if (command==setFileNameCommand) { |
---|
149 | return fileName; |
---|
150 | } else if (command==setOverwriteCommand) { |
---|
151 | return overwrite; |
---|
152 | } else if (command==setCullInvisiblesCommand) { |
---|
153 | return cullInvisibles; |
---|
154 | } else if (command==setEventNumberSuffixCommand) { |
---|
155 | return suffix; |
---|
156 | } else if (command==appendGeometryCommand) { |
---|
157 | return appendGeometryCommand->ConvertToString(geometry); |
---|
158 | } else if (command==addPointAttributesCommand) { |
---|
159 | return addPointAttributesCommand->ConvertToString(pointAttributes); |
---|
160 | } else if (command==useSolidsCommand) { |
---|
161 | return useSolidsCommand->ConvertToString(solids); |
---|
162 | } else { |
---|
163 | return ""; |
---|
164 | } |
---|
165 | } |
---|
166 | |
---|
167 | void G4HepRepMessenger::SetNewValue(G4UIcommand * command, G4String newValue) { |
---|
168 | if (command==setFileDirCommand) { |
---|
169 | fileDir = newValue; |
---|
170 | } else if (command==setFileNameCommand) { |
---|
171 | fileName = newValue; |
---|
172 | } else if (command==setOverwriteCommand) { |
---|
173 | overwrite = setOverwriteCommand->GetNewBoolValue(newValue); |
---|
174 | } else if (command==setCullInvisiblesCommand) { |
---|
175 | cullInvisibles = setCullInvisiblesCommand->GetNewBoolValue(newValue); |
---|
176 | } else if (command==setEventNumberSuffixCommand) { |
---|
177 | suffix = newValue; |
---|
178 | } else if (command==appendGeometryCommand) { |
---|
179 | geometry = appendGeometryCommand->GetNewBoolValue(newValue); |
---|
180 | } else if (command==addPointAttributesCommand) { |
---|
181 | pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue); |
---|
182 | } else if (command==useSolidsCommand) { |
---|
183 | solids = useSolidsCommand->GetNewBoolValue(newValue); |
---|
184 | } |
---|
185 | } |
---|
186 | |
---|
187 | G4String G4HepRepMessenger::getFileDir() { |
---|
188 | return fileDir; |
---|
189 | } |
---|
190 | |
---|
191 | G4String G4HepRepMessenger::getFileName() { |
---|
192 | return fileName; |
---|
193 | } |
---|
194 | |
---|
195 | G4bool G4HepRepMessenger::getOverwrite() { |
---|
196 | return overwrite; |
---|
197 | } |
---|
198 | |
---|
199 | G4bool G4HepRepMessenger::getCullInvisibles() { |
---|
200 | return cullInvisibles; |
---|
201 | } |
---|
202 | |
---|
203 | G4String G4HepRepMessenger::getEventNumberSuffix() { |
---|
204 | return suffix; |
---|
205 | } |
---|
206 | |
---|
207 | G4bool G4HepRepMessenger::appendGeometry() { |
---|
208 | return geometry; |
---|
209 | } |
---|
210 | |
---|
211 | G4bool G4HepRepMessenger::addPointAttributes() { |
---|
212 | return pointAttributes; |
---|
213 | } |
---|
214 | |
---|
215 | G4bool G4HepRepMessenger::useSolids() { |
---|
216 | return solids; |
---|
217 | } |
---|
218 | |
---|
219 | G4bool G4HepRepMessenger::writeInvisibles() { |
---|
220 | return invisibles; |
---|
221 | } |
---|
222 | |
---|