Geant4  10.02.p01
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 //
27 // $Id: G4GDMLMessenger.cc 89381 2015-04-08 15:32:47Z 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)
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  RegionCmd = new G4UIcmdWithABool("/persistency/gdml/export_regions",this);
72  RegionCmd->SetGuidance("Enable export of geometrical regions");
73  RegionCmd->SetGuidance("for storing production cuts.");
74  RegionCmd->SetParameterName("export_regions",false);
75  RegionCmd->SetDefaultValue(false);
77 
78  EcutsCmd = new G4UIcmdWithABool("/persistency/gdml/export_Ecuts",this);
79  EcutsCmd->SetGuidance("Enable export of energy cuts associated");
80  EcutsCmd->SetGuidance("to logical volumes.");
81  EcutsCmd->SetGuidance("NOTE: may increase considerably the size of the");
82  EcutsCmd->SetGuidance(" GDML file! Information is anyhow not used");
83  EcutsCmd->SetGuidance(" for import.");
84  EcutsCmd->SetParameterName("export_Ecuts",false);
85  EcutsCmd->SetDefaultValue(false);
87 
88  ClearCmd = new G4UIcmdWithoutParameter("/persistency/gdml/clear",this);
89  ClearCmd->SetGuidance("Clear geometry (before reading a new one from GDML).");
91 }
92 
94 {
95  delete ReaderCmd;
96  delete WriterCmd;
97  delete ClearCmd;
98  delete TopVolCmd;
99  delete RegionCmd;
100  delete EcutsCmd;
101  delete persistencyDir;
102  delete gdmlDir;
103 }
104 
106 {
107  if( command == ReaderCmd )
108  {
110  myParser->Read(newValue);
112  }
113 
114  if( command == RegionCmd )
115  {
116  G4bool mode = RegionCmd->GetNewBoolValue(newValue);
117  myParser->SetRegionExport(mode);
118  }
119 
120  if( command == EcutsCmd )
121  {
122  G4bool mode = EcutsCmd->GetNewBoolValue(newValue);
124  }
125 
126  if( command == TopVolCmd )
127  {
129  }
130 
131  if( command == WriterCmd )
132  {
133  myParser->Write(newValue, topvol);
134  }
135 
136  if( command == ClearCmd )
137  {
138  myParser->Clear();
140  }
141 }
G4LogicalVolume * topvol
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetNewValue(G4UIcommand *, G4String)
G4UIdirectory * persistencyDir
G4VPhysicalVolume * GetWorldVolume(const G4String &setupName="Default") const
G4UIcmdWithAString * WriterCmd
void SetRegionExport(G4bool)
static G4bool GetNewBoolValue(const char *paramString)
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
G4UIcmdWithABool * EcutsCmd
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4GDMLMessenger(G4GDMLParser *)
bool G4bool
Definition: G4Types.hh:79
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
static G4LogicalVolumeStore * GetInstance()
void Write(const G4String &filename, const G4VPhysicalVolume *pvol=0, G4bool storeReferences=true, const G4String &SchemaLocation=G4GDML_DEFAULT_SCHEMALOCATION)
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:239
static G4GeometryManager * GetInstance()
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
void SetEnergyCutsExport(G4bool)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4GDMLParser * myParser
void Read(const G4String &filename, G4bool Validate=true)
G4UIcmdWithAString * ReaderCmd
G4UIcmdWithAString * TopVolCmd
void OpenGeometry(G4VPhysicalVolume *vol=0)
G4UIcmdWithoutParameter * ClearCmd
G4UIcmdWithABool * RegionCmd
G4UIdirectory * gdmlDir