source: trunk/source/persistency/gdml/src/G4GDMLMessenger.cc@ 1353

Last change on this file since 1353 was 1350, checked in by garnier, 15 years ago

update to last version 4.9.4

File size: 4.2 KB
RevLine 
[1350]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,v 1.3 2010/11/02 11:44:15 gcosmo Exp $
28// GEANT4 tag $Name: gdml-V09-03-09 $
29//
30//
31// class G4GDMLMessenger Implementation
32//
33// -------------------------------------------------------------------------
34
35#include "G4GDMLMessenger.hh"
36#include "G4GDMLParser.hh"
37
38#include "globals.hh"
39#include "G4RunManager.hh"
40#include "G4UIdirectory.hh"
41#include "G4UIcmdWithAString.hh"
42#include "G4UIcmdWithoutParameter.hh"
43#include "G4GeometryManager.hh"
44#include "G4LogicalVolumeStore.hh"
45#include "G4PhysicalVolumeStore.hh"
46#include "G4SolidStore.hh"
47
48G4GDMLMessenger::G4GDMLMessenger(G4GDMLParser* myPars)
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);
60 ReaderCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
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);
69 WriterCmd->AvailableForStates(G4State_Idle);
70
71 ClearCmd = new G4UIcmdWithoutParameter("/persistency/gdml/clear",this);
72 ClearCmd->SetGuidance("Clear geometry (before reading a new one from GDML).");
73 ClearCmd->AvailableForStates(G4State_Idle);
74}
75
76G4GDMLMessenger::~G4GDMLMessenger()
77{
78 delete ReaderCmd;
79 delete WriterCmd;
80 delete ClearCmd;
81 delete TopVolCmd;
82 delete persistencyDir;
83 delete gdmlDir;
84}
85
86void G4GDMLMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
87{
88 if( command == ReaderCmd )
89 {
90 G4GeometryManager::GetInstance()->OpenGeometry();
91 myParser->Read(newValue);
92 G4RunManager::GetRunManager()->DefineWorldVolume(myParser->GetWorldVolume());
93 }
94
95 if( command == TopVolCmd )
96 {
97 topvol = G4LogicalVolumeStore::GetInstance()->GetVolume(newValue);
98 }
99
100 if( command == WriterCmd )
101 {
102 myParser->Write(newValue, topvol);
103 }
104
105 if( command == ClearCmd )
106 {
107 myParser->Clear();
108 G4GeometryManager::GetInstance()->OpenGeometry();
109 G4PhysicalVolumeStore::Clean();
110 G4LogicalVolumeStore::Clean();
111 G4SolidStore::Clean();
112 }
113}
Note: See TracBrowser for help on using the repository browser.