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 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /persistency/gdml/src/G4GDMLMessenger.cc (Version 11.3.0) and /persistency/gdml/src/G4GDMLMessenger.cc (Version 10.5.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4GDMLMessenger implementation              << 
 27 //                                                 26 //
 28 // Author: Witold Pokorski, October 2010       <<  27 //
 29 // ------------------------------------------- <<  28 //
                                                   >>  29 // class G4GDMLMessenger Implementation
                                                   >>  30 //
                                                   >>  31 // -------------------------------------------------------------------------
 30                                                    32 
 31 #include "G4GDMLMessenger.hh"                      33 #include "G4GDMLMessenger.hh"
 32 #include "G4GDMLParser.hh"                         34 #include "G4GDMLParser.hh"
 33                                                    35 
 34 #include "globals.hh"                              36 #include "globals.hh"
 35 #include "G4RunManager.hh"                         37 #include "G4RunManager.hh"
 36 #include "G4UIdirectory.hh"                        38 #include "G4UIdirectory.hh"
 37 #include "G4UIcmdWithAString.hh"                   39 #include "G4UIcmdWithAString.hh"
 38 #include "G4UIcmdWithABool.hh"                     40 #include "G4UIcmdWithABool.hh"
 39 #include "G4UIcmdWithoutParameter.hh"              41 #include "G4UIcmdWithoutParameter.hh"
 40 #include "G4GeometryManager.hh"                    42 #include "G4GeometryManager.hh"
 41 #include "G4LogicalVolumeStore.hh"                 43 #include "G4LogicalVolumeStore.hh"
 42 #include "G4PhysicalVolumeStore.hh"                44 #include "G4PhysicalVolumeStore.hh"
 43 #include "G4SolidStore.hh"                         45 #include "G4SolidStore.hh"
 44                                                    46 
 45 // ------------------------------------------- << 
 46 G4GDMLMessenger::G4GDMLMessenger(G4GDMLParser*     47 G4GDMLMessenger::G4GDMLMessenger(G4GDMLParser* myPars)
 47   : myParser(myPars)                           <<  48   : myParser(myPars), topvol(0), pFlag(true)
 48 {                                              <<  49 { 
 49   persistencyDir = new G4UIdirectory("/persist     50   persistencyDir = new G4UIdirectory("/persistency/");
 50   persistencyDir->SetGuidance("UI commands spe     51   persistencyDir->SetGuidance("UI commands specific to persistency.");
 51                                                <<  52   
 52   gdmlDir = new G4UIdirectory("/persistency/gd     53   gdmlDir = new G4UIdirectory("/persistency/gdml/");
 53   gdmlDir->SetGuidance("GDML parser and writer     54   gdmlDir->SetGuidance("GDML parser and writer.");
 54                                                <<  55   
 55   ReaderSchema = new G4UIcmdWithAString("/pers <<  56   ReaderCmd = new G4UIcmdWithAString("/persistency/gdml/read",this);
 56   ReaderSchema->SetGuidance("Set alternative G << 
 57   ReaderSchema->SetParameterName("schema_path_ << 
 58   ReaderSchema->AvailableForStates(G4State_Pre << 
 59   ReaderSchema->SetToBeBroadcasted(false);     << 
 60                                                << 
 61   ReaderCmd = new G4UIcmdWithAString("/persist << 
 62   ReaderCmd->SetGuidance("Read GDML file.");       57   ReaderCmd->SetGuidance("Read GDML file.");
 63   ReaderCmd->SetParameterName("filename", fals <<  58   ReaderCmd->SetParameterName("filename",false);
 64   ReaderCmd->AvailableForStates(G4State_PreIni <<  59   ReaderCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
 65   ReaderCmd->SetToBeBroadcasted(false);        << 
 66                                                    60 
 67   TopVolCmd = new G4UIcmdWithAString("/persist <<  61   TopVolCmd = new G4UIcmdWithAString("/persistency/gdml/topvol",this);
 68   TopVolCmd->SetGuidance("Set the top volume f     62   TopVolCmd->SetGuidance("Set the top volume for writing the GDML file.");
 69   TopVolCmd->SetParameterName("topvol", false) <<  63   TopVolCmd->SetParameterName("topvol",false);
 70   TopVolCmd->SetToBeBroadcasted(false);        << 
 71                                                    64 
 72   WriterCmd = new G4UIcmdWithAString("/persist <<  65   WriterCmd = new G4UIcmdWithAString("/persistency/gdml/write",this);
 73   WriterCmd->SetGuidance("Write GDML file.");      66   WriterCmd->SetGuidance("Write GDML file.");
 74   WriterCmd->SetParameterName("filename", fals <<  67   WriterCmd->SetParameterName("filename",false);
 75   WriterCmd->AvailableForStates(G4State_Idle);     68   WriterCmd->AvailableForStates(G4State_Idle);
 76   WriterCmd->SetToBeBroadcasted(false);        << 
 77                                                    69 
 78   StripCmd = new G4UIcmdWithABool("/persistenc <<  70   StripCmd = new G4UIcmdWithABool("/persistency/gdml/strip_pointers",this);
 79   StripCmd->SetGuidance("Enable/disable stripp     71   StripCmd->SetGuidance("Enable/disable stripping of pointers on names");
 80   StripCmd->SetGuidance("when reading a GDML f     72   StripCmd->SetGuidance("when reading a GDML file.");
 81   StripCmd->SetParameterName("strip_pointers", <<  73   StripCmd->SetParameterName("strip_pointers",true);
 82   StripCmd->SetDefaultValue(true);                 74   StripCmd->SetDefaultValue(true);
 83   StripCmd->AvailableForStates(G4State_Idle);      75   StripCmd->AvailableForStates(G4State_Idle);
 84   StripCmd->SetToBeBroadcasted(false);         << 
 85                                                    76 
 86   AppendCmd = new G4UIcmdWithABool("/persisten <<  77   AppendCmd = new G4UIcmdWithABool("/persistency/gdml/add_pointers",this);
 87   AppendCmd->SetGuidance("Enable/disable appen     78   AppendCmd->SetGuidance("Enable/disable appending of pointers to names");
 88   AppendCmd->SetGuidance("when writing a GDML      79   AppendCmd->SetGuidance("when writing a GDML file.");
 89   AppendCmd->SetParameterName("append_pointers <<  80   AppendCmd->SetParameterName("append_pointers",true);
 90   AppendCmd->SetDefaultValue(true);                81   AppendCmd->SetDefaultValue(true);
 91   AppendCmd->AvailableForStates(G4State_Idle);     82   AppendCmd->AvailableForStates(G4State_Idle);
 92   AppendCmd->SetToBeBroadcasted(false);        << 
 93                                                    83 
 94   RegionCmd = new G4UIcmdWithABool("/persisten <<  84   RegionCmd = new G4UIcmdWithABool("/persistency/gdml/export_regions",this);
 95   RegionCmd->SetGuidance("Enable export of geo     85   RegionCmd->SetGuidance("Enable export of geometrical regions");
 96   RegionCmd->SetGuidance("for storing producti     86   RegionCmd->SetGuidance("for storing production cuts.");
 97   RegionCmd->SetParameterName("export_regions" <<  87   RegionCmd->SetParameterName("export_regions",false);
 98   RegionCmd->SetDefaultValue(false);               88   RegionCmd->SetDefaultValue(false);
 99   RegionCmd->AvailableForStates(G4State_Idle);     89   RegionCmd->AvailableForStates(G4State_Idle);
100   RegionCmd->SetToBeBroadcasted(false);        << 
101                                                    90 
102   EcutsCmd = new G4UIcmdWithABool("/persistenc <<  91   EcutsCmd = new G4UIcmdWithABool("/persistency/gdml/export_Ecuts",this);
103   EcutsCmd->SetGuidance("Enable export of ener     92   EcutsCmd->SetGuidance("Enable export of energy cuts associated");
104   EcutsCmd->SetGuidance("to logical volumes.")     93   EcutsCmd->SetGuidance("to logical volumes.");
105   EcutsCmd->SetGuidance("NOTE: may increase co     94   EcutsCmd->SetGuidance("NOTE: may increase considerably the size of the");
106   EcutsCmd->SetGuidance("      GDML file!  Inf     95   EcutsCmd->SetGuidance("      GDML file!  Information is anyhow not used");
107   EcutsCmd->SetGuidance("      for import.");      96   EcutsCmd->SetGuidance("      for import.");
108   EcutsCmd->SetParameterName("export_Ecuts", f <<  97   EcutsCmd->SetParameterName("export_Ecuts",false);
109   EcutsCmd->SetDefaultValue(false);                98   EcutsCmd->SetDefaultValue(false);
110   EcutsCmd->AvailableForStates(G4State_Idle);      99   EcutsCmd->AvailableForStates(G4State_Idle);
111   EcutsCmd->SetToBeBroadcasted(false);         << 
112                                                   100 
113   SDCmd = new G4UIcmdWithABool("/persistency/g << 101   SDCmd = new G4UIcmdWithABool("/persistency/gdml/export_SD",this);
114   SDCmd->SetGuidance("Enable export of SD asso    102   SDCmd->SetGuidance("Enable export of SD associated");
115   SDCmd->SetGuidance("to logical volumes.");      103   SDCmd->SetGuidance("to logical volumes.");
116   SDCmd->SetParameterName("export_SD", false); << 104   SDCmd->SetParameterName("export_SD",false);
117   SDCmd->SetDefaultValue(false);                  105   SDCmd->SetDefaultValue(false);
118   SDCmd->AvailableForStates(G4State_Idle);        106   SDCmd->AvailableForStates(G4State_Idle);
119   SDCmd->SetToBeBroadcasted(false);            << 
120                                                   107 
121   ClearCmd = new G4UIcmdWithoutParameter("/per << 108   ClearCmd = new G4UIcmdWithoutParameter("/persistency/gdml/clear",this);
122   ClearCmd->SetGuidance("Clear geometry (befor    109   ClearCmd->SetGuidance("Clear geometry (before reading a new one from GDML).");
123   ClearCmd->AvailableForStates(G4State_Idle);     110   ClearCmd->AvailableForStates(G4State_Idle);
124   ClearCmd->SetToBeBroadcasted(false);         << 
125 }                                                 111 }
126                                                   112 
127 // ------------------------------------------- << 
128 G4GDMLMessenger::~G4GDMLMessenger()               113 G4GDMLMessenger::~G4GDMLMessenger()
129 {                                                 114 {
130   delete ReaderSchema;                         << 
131   delete ReaderCmd;                               115   delete ReaderCmd;
132   delete WriterCmd;                               116   delete WriterCmd;
133   delete ClearCmd;                                117   delete ClearCmd;
134   delete TopVolCmd;                               118   delete TopVolCmd;
135   delete RegionCmd;                               119   delete RegionCmd;
136   delete EcutsCmd;                                120   delete EcutsCmd;
137   delete SDCmd;                                   121   delete SDCmd;
138   delete persistencyDir;                          122   delete persistencyDir;
139   delete gdmlDir;                                 123   delete gdmlDir;
140   delete StripCmd;                                124   delete StripCmd;
141   delete AppendCmd;                               125   delete AppendCmd;
142 }                                                 126 }
143                                                   127 
144 // ------------------------------------------- << 
145 void G4GDMLMessenger::SetNewValue(G4UIcommand*    128 void G4GDMLMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
146 {                                              << 129 { 
147   if(command == StripCmd)                      << 130   if( command == StripCmd )
148   {                                               131   {
149     G4bool mode = StripCmd->GetNewBoolValue(ne    132     G4bool mode = StripCmd->GetNewBoolValue(newValue);
150     myParser->SetStripFlag(mode);                 133     myParser->SetStripFlag(mode);
151   }                                               134   }
152                                                   135 
153   if(command == AppendCmd)                     << 136   if( command == AppendCmd )
154   {                                               137   {
155     pFlag = AppendCmd->GetNewBoolValue(newValu    138     pFlag = AppendCmd->GetNewBoolValue(newValue);
156     myParser->SetAddPointerToName(pFlag);         139     myParser->SetAddPointerToName(pFlag);
157   }                                               140   }
158                                                   141 
159   if(command == ReaderSchema)                  << 142   if( command == ReaderCmd )
160   {                                            << 143   { 
161     myParser->SetImportSchema(newValue);       << 
162   }                                            << 
163                                                << 
164   if(command == ReaderCmd)                     << 
165   {                                            << 
166     G4GeometryManager::GetInstance()->OpenGeom    144     G4GeometryManager::GetInstance()->OpenGeometry();
167     myParser->Read(newValue);                     145     myParser->Read(newValue);
168     G4RunManager::GetRunManager()->DefineWorld << 146     G4RunManager::GetRunManager()->DefineWorldVolume(myParser->GetWorldVolume());
169       myParser->GetWorldVolume());             << 
170     G4RunManager::GetRunManager()->GeometryDir << 
171   }                                               147   }
172                                                   148 
173   if(command == RegionCmd)                     << 149   if( command == RegionCmd )
174   {                                               150   {
175     G4bool mode = RegionCmd->GetNewBoolValue(n    151     G4bool mode = RegionCmd->GetNewBoolValue(newValue);
176     myParser->SetRegionExport(mode);              152     myParser->SetRegionExport(mode);
177   }                                               153   }
178                                                   154 
179   if(command == EcutsCmd)                      << 155   if( command == EcutsCmd )
180   {                                               156   {
181     G4bool mode = EcutsCmd->GetNewBoolValue(ne    157     G4bool mode = EcutsCmd->GetNewBoolValue(newValue);
182     myParser->SetEnergyCutsExport(mode);          158     myParser->SetEnergyCutsExport(mode);
183   }                                               159   }
184                                                << 160    
185   if(command == SDCmd)                         << 161   if( command == SDCmd )
186   {                                               162   {
187     G4bool mode = SDCmd->GetNewBoolValue(newVa    163     G4bool mode = SDCmd->GetNewBoolValue(newValue);
188     myParser->SetSDExport(mode);                  164     myParser->SetSDExport(mode);
189   }                                               165   }
190                                                << 166    
191   if(command == TopVolCmd)                     << 167   if( command == TopVolCmd )
192   {                                               168   {
193     topvol = G4LogicalVolumeStore::GetInstance    169     topvol = G4LogicalVolumeStore::GetInstance()->GetVolume(newValue);
194   }                                               170   }
195                                                << 171    
196   if(command == WriterCmd)                     << 172   if( command == WriterCmd )
197   {                                               173   {
198     myParser->Write(newValue, topvol, pFlag);     174     myParser->Write(newValue, topvol, pFlag);
199   }                                            << 175   }  
200                                                   176 
201   if(command == ClearCmd)                      << 177   if( command == ClearCmd )
202   {                                            << 178   { 
203     myParser->Clear();                            179     myParser->Clear();
204     G4RunManager::GetRunManager()->Reinitializ    180     G4RunManager::GetRunManager()->ReinitializeGeometry(true);
205   }                                            << 181   }  
206 }                                                 182 }
207                                                   183