Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GDMLMessenger.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// G4GDMLMessenger implementation
27//
28// Author: Witold Pokorski, October 2010
29// --------------------------------------------------------------------
30
31#include "G4GDMLMessenger.hh"
32#include "G4GDMLParser.hh"
33
34#include "globals.hh"
35#include "G4RunManager.hh"
36#include "G4UIdirectory.hh"
37#include "G4UIcmdWithAString.hh"
38#include "G4UIcmdWithABool.hh"
40#include "G4GeometryManager.hh"
43#include "G4SolidStore.hh"
44
45// --------------------------------------------------------------------
47 : myParser(myPars)
48{
49 persistencyDir = new G4UIdirectory("/persistency/");
50 persistencyDir->SetGuidance("UI commands specific to persistency.");
51
52 gdmlDir = new G4UIdirectory("/persistency/gdml/");
53 gdmlDir->SetGuidance("GDML parser and writer.");
54
55 ReaderSchema = new G4UIcmdWithAString("/persistency/gdml/schema", this);
56 ReaderSchema->SetGuidance("Set alternative GDML schema file for import validation.");
57 ReaderSchema->SetParameterName("schema_path_and_filename", false);
59 ReaderSchema->SetToBeBroadcasted(false);
60
61 ReaderCmd = new G4UIcmdWithAString("/persistency/gdml/read", this);
62 ReaderCmd->SetGuidance("Read GDML file.");
63 ReaderCmd->SetParameterName("filename", false);
65 ReaderCmd->SetToBeBroadcasted(false);
66
67 TopVolCmd = new G4UIcmdWithAString("/persistency/gdml/topvol", this);
68 TopVolCmd->SetGuidance("Set the top volume for writing the GDML file.");
69 TopVolCmd->SetParameterName("topvol", false);
70 TopVolCmd->SetToBeBroadcasted(false);
71
72 WriterCmd = new G4UIcmdWithAString("/persistency/gdml/write", this);
73 WriterCmd->SetGuidance("Write GDML file.");
74 WriterCmd->SetParameterName("filename", false);
76 WriterCmd->SetToBeBroadcasted(false);
77
78 StripCmd = new G4UIcmdWithABool("/persistency/gdml/strip_pointers", this);
79 StripCmd->SetGuidance("Enable/disable stripping of pointers on names");
80 StripCmd->SetGuidance("when reading a GDML file.");
81 StripCmd->SetParameterName("strip_pointers", true);
82 StripCmd->SetDefaultValue(true);
84 StripCmd->SetToBeBroadcasted(false);
85
86 AppendCmd = new G4UIcmdWithABool("/persistency/gdml/add_pointers", this);
87 AppendCmd->SetGuidance("Enable/disable appending of pointers to names");
88 AppendCmd->SetGuidance("when writing a GDML file.");
89 AppendCmd->SetParameterName("append_pointers", true);
90 AppendCmd->SetDefaultValue(true);
92 AppendCmd->SetToBeBroadcasted(false);
93
94 RegionCmd = new G4UIcmdWithABool("/persistency/gdml/export_regions", this);
95 RegionCmd->SetGuidance("Enable export of geometrical regions");
96 RegionCmd->SetGuidance("for storing production cuts.");
97 RegionCmd->SetParameterName("export_regions", false);
98 RegionCmd->SetDefaultValue(false);
100 RegionCmd->SetToBeBroadcasted(false);
101
102 EcutsCmd = new G4UIcmdWithABool("/persistency/gdml/export_Ecuts", this);
103 EcutsCmd->SetGuidance("Enable export of energy cuts associated");
104 EcutsCmd->SetGuidance("to logical volumes.");
105 EcutsCmd->SetGuidance("NOTE: may increase considerably the size of the");
106 EcutsCmd->SetGuidance(" GDML file! Information is anyhow not used");
107 EcutsCmd->SetGuidance(" for import.");
108 EcutsCmd->SetParameterName("export_Ecuts", false);
109 EcutsCmd->SetDefaultValue(false);
111 EcutsCmd->SetToBeBroadcasted(false);
112
113 SDCmd = new G4UIcmdWithABool("/persistency/gdml/export_SD", this);
114 SDCmd->SetGuidance("Enable export of SD associated");
115 SDCmd->SetGuidance("to logical volumes.");
116 SDCmd->SetParameterName("export_SD", false);
117 SDCmd->SetDefaultValue(false);
119 SDCmd->SetToBeBroadcasted(false);
120
121 ClearCmd = new G4UIcmdWithoutParameter("/persistency/gdml/clear", this);
122 ClearCmd->SetGuidance("Clear geometry (before reading a new one from GDML).");
124 ClearCmd->SetToBeBroadcasted(false);
125}
126
127// --------------------------------------------------------------------
129{
130 delete ReaderSchema;
131 delete ReaderCmd;
132 delete WriterCmd;
133 delete ClearCmd;
134 delete TopVolCmd;
135 delete RegionCmd;
136 delete EcutsCmd;
137 delete SDCmd;
138 delete persistencyDir;
139 delete gdmlDir;
140 delete StripCmd;
141 delete AppendCmd;
142}
143
144// --------------------------------------------------------------------
146{
147 if(command == StripCmd)
148 {
149 G4bool mode = StripCmd->GetNewBoolValue(newValue);
150 myParser->SetStripFlag(mode);
151 }
152
153 if(command == AppendCmd)
154 {
155 pFlag = AppendCmd->GetNewBoolValue(newValue);
156 myParser->SetAddPointerToName(pFlag);
157 }
158
159 if(command == ReaderSchema)
160 {
161 myParser->SetImportSchema(newValue);
162 }
163
164 if(command == ReaderCmd)
165 {
167 myParser->Read(newValue);
169 myParser->GetWorldVolume());
171 }
172
173 if(command == RegionCmd)
174 {
175 G4bool mode = RegionCmd->GetNewBoolValue(newValue);
176 myParser->SetRegionExport(mode);
177 }
178
179 if(command == EcutsCmd)
180 {
181 G4bool mode = EcutsCmd->GetNewBoolValue(newValue);
182 myParser->SetEnergyCutsExport(mode);
183 }
184
185 if(command == SDCmd)
186 {
187 G4bool mode = SDCmd->GetNewBoolValue(newValue);
188 myParser->SetSDExport(mode);
189 }
190
191 if(command == TopVolCmd)
192 {
193 topvol = G4LogicalVolumeStore::GetInstance()->GetVolume(newValue);
194 }
195
196 if(command == WriterCmd)
197 {
198 myParser->Write(newValue, topvol, pFlag);
199 }
200
201 if(command == ClearCmd)
202 {
203 myParser->Clear();
205 }
206}
@ G4State_Idle
@ G4State_PreInit
bool G4bool
Definition G4Types.hh:86
G4GDMLMessenger(G4GDMLParser *)
void SetNewValue(G4UIcommand *, G4String)
G4VPhysicalVolume * GetWorldVolume(const G4String &setupName="Default") const
void SetSDExport(G4bool)
void SetEnergyCutsExport(G4bool)
void Read(const G4String &filename, G4bool Validate=false)
void SetImportSchema(const G4String &path_and_filename)
void SetStripFlag(G4bool)
void SetAddPointerToName(G4bool set)
void Write(const G4String &filename, const G4VPhysicalVolume *pvol=0, G4bool storeReferences=true, const G4String &SchemaLocation=G4GDML_DEFAULT_WRITE_SCHEMALOCATION)
void SetRegionExport(G4bool)
static G4GeometryManager * GetInstance()
void OpenGeometry(G4VPhysicalVolume *vol=nullptr)
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true, G4bool reverseSearch=false) const
static G4LogicalVolumeStore * GetInstance()
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static G4RunManager * GetRunManager()
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
void GeometryDirectlyUpdated(G4bool val=true)
static G4bool GetNewBoolValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetToBeBroadcasted(G4bool val)
void SetGuidance(const char *aGuidance)
void AvailableForStates(G4ApplicationState s1)