Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4GDMLMessenger.cc
이 파일의 문서화 페이지로 가기
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 //
27 // $Id: G4GDMLMessenger.cc 105114 2017-07-13 09:49:54Z gcosmo $
28 //
29 //
30 // class G4GDMLMessenger Implementation
31 //
32 // -------------------------------------------------------------------------
33 
34 #include "G4GDMLMessenger.hh"
35 #include "G4GDMLParser.hh"
36 
37 #include "globals.hh"
38 #include "G4RunManager.hh"
39 #include "G4UIdirectory.hh"
40 #include "G4UIcmdWithAString.hh"
41 #include "G4UIcmdWithABool.hh"
43 #include "G4GeometryManager.hh"
44 #include "G4LogicalVolumeStore.hh"
45 #include "G4PhysicalVolumeStore.hh"
46 #include "G4SolidStore.hh"
47 
49  : myParser(myPars), topvol(0), pFlag(true)
50 {
51  persistencyDir = new G4UIdirectory("/persistency/");
52  persistencyDir->SetGuidance("UI commands specific to persistency.");
53 
54  gdmlDir = new G4UIdirectory("/persistency/gdml/");
55  gdmlDir->SetGuidance("GDML parser and writer.");
56 
57  ReaderCmd = new G4UIcmdWithAString("/persistency/gdml/read",this);
58  ReaderCmd->SetGuidance("Read GDML file.");
59  ReaderCmd->SetParameterName("filename",false);
61 
62  TopVolCmd = new G4UIcmdWithAString("/persistency/gdml/topvol",this);
63  TopVolCmd->SetGuidance("Set the top volume for writing the GDML file.");
64  TopVolCmd->SetParameterName("topvol",false);
65 
66  WriterCmd = new G4UIcmdWithAString("/persistency/gdml/write",this);
67  WriterCmd->SetGuidance("Write GDML file.");
68  WriterCmd->SetParameterName("filename",false);
70 
71  StripCmd = new G4UIcmdWithABool("/persistency/gdml/strip_pointers",this);
72  StripCmd->SetGuidance("Enable/disable stripping of pointers on names");
73  StripCmd->SetGuidance("when reading a GDML file.");
74  StripCmd->SetParameterName("strip_pointers",true);
77 
78  AppendCmd = new G4UIcmdWithABool("/persistency/gdml/add_pointers",this);
79  AppendCmd->SetGuidance("Enable/disable appending of pointers to names");
80  AppendCmd->SetGuidance("when writing a GDML file.");
81  AppendCmd->SetParameterName("append_pointers",true);
84 
85  RegionCmd = new G4UIcmdWithABool("/persistency/gdml/export_regions",this);
86  RegionCmd->SetGuidance("Enable export of geometrical regions");
87  RegionCmd->SetGuidance("for storing production cuts.");
88  RegionCmd->SetParameterName("export_regions",false);
89  RegionCmd->SetDefaultValue(false);
91 
92  EcutsCmd = new G4UIcmdWithABool("/persistency/gdml/export_Ecuts",this);
93  EcutsCmd->SetGuidance("Enable export of energy cuts associated");
94  EcutsCmd->SetGuidance("to logical volumes.");
95  EcutsCmd->SetGuidance("NOTE: may increase considerably the size of the");
96  EcutsCmd->SetGuidance(" GDML file! Information is anyhow not used");
97  EcutsCmd->SetGuidance(" for import.");
98  EcutsCmd->SetParameterName("export_Ecuts",false);
99  EcutsCmd->SetDefaultValue(false);
101 
102  SDCmd = new G4UIcmdWithABool("/persistency/gdml/export_SD",this);
103  SDCmd->SetGuidance("Enable export of SD associated");
104  SDCmd->SetGuidance("to logical volumes.");
105  SDCmd->SetParameterName("export_SD",false);
106  SDCmd->SetDefaultValue(false);
108 
109  ClearCmd = new G4UIcmdWithoutParameter("/persistency/gdml/clear",this);
110  ClearCmd->SetGuidance("Clear geometry (before reading a new one from GDML).");
112 }
113 
115 {
116  delete ReaderCmd;
117  delete WriterCmd;
118  delete ClearCmd;
119  delete TopVolCmd;
120  delete RegionCmd;
121  delete EcutsCmd;
122  delete SDCmd;
123  delete persistencyDir;
124  delete gdmlDir;
125  delete StripCmd;
126  delete AppendCmd;
127 }
128 
130 {
131  if( command == StripCmd )
132  {
133  G4bool mode = StripCmd->GetNewBoolValue(newValue);
134  myParser->SetStripFlag(mode);
135  }
136 
137  if( command == AppendCmd )
138  {
139  pFlag = AppendCmd->GetNewBoolValue(newValue);
141  }
142 
143  if( command == ReaderCmd )
144  {
146  myParser->Read(newValue);
148  }
149 
150  if( command == RegionCmd )
151  {
152  G4bool mode = RegionCmd->GetNewBoolValue(newValue);
153  myParser->SetRegionExport(mode);
154  }
155 
156  if( command == EcutsCmd )
157  {
158  G4bool mode = EcutsCmd->GetNewBoolValue(newValue);
160  }
161 
162  if( command == SDCmd )
163  {
164  G4bool mode = SDCmd->GetNewBoolValue(newValue);
165  myParser->SetSDExport(mode);
166  }
167 
168  if( command == TopVolCmd )
169  {
171  }
172 
173  if( command == WriterCmd )
174  {
175  myParser->Write(newValue, topvol, pFlag);
176  }
177 
178  if( command == ClearCmd )
179  {
180  myParser->Clear();
182  }
183 }
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
G4VPhysicalVolume * GetWorldVolume(const G4String &setupName="Default") const
G4LogicalVolume * topvol
G4UIcmdWithAString * TopVolCmd
G4UIcmdWithAString * WriterCmd
void SetDefaultValue(G4bool defVal)
G4GDMLMessenger(G4GDMLParser *)
G4UIcmdWithABool * SDCmd
void Read(const G4String &filename, G4bool Validate=true)
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4UIcmdWithABool * EcutsCmd
G4UIdirectory * gdmlDir
static G4bool GetNewBoolValue(const char *paramString)
void SetNewValue(G4UIcommand *, G4String)
G4GDMLParser * myParser
G4UIcmdWithAString * ReaderCmd
void SetRegionExport(G4bool)
bool G4bool
Definition: G4Types.hh:79
G4UIdirectory * persistencyDir
static G4GeometryManager * GetInstance()
void SetStripFlag(G4bool)
G4UIcmdWithoutParameter * ClearCmd
void OpenGeometry(G4VPhysicalVolume *vol=0)
void SetEnergyCutsExport(G4bool)
void SetAddPointerToName(G4bool set)
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWithABool * AppendCmd
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void Write(const G4String &filename, const G4VPhysicalVolume *pvol=0, G4bool storeReferences=true, const G4String &SchemaLocation=G4GDML_DEFAULT_SCHEMALOCATION)
G4UIcmdWithABool * StripCmd
void SetSDExport(G4bool)
G4UIcmdWithABool * RegionCmd
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242
static G4LogicalVolumeStore * GetInstance()
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const