G4GDMLMessenger.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 //
00030 // class G4GDMLMessenger Implementation
00031 //
00032 // -------------------------------------------------------------------------
00033 
00034 #include "G4GDMLMessenger.hh"
00035 #include "G4GDMLParser.hh"
00036 
00037 #include "globals.hh"
00038 #include "G4RunManager.hh"
00039 #include "G4UIdirectory.hh"
00040 #include "G4UIcmdWithAString.hh"
00041 #include "G4UIcmdWithoutParameter.hh"
00042 #include "G4GeometryManager.hh"
00043 #include "G4LogicalVolumeStore.hh"
00044 #include "G4PhysicalVolumeStore.hh"
00045 #include "G4SolidStore.hh"
00046 
00047 G4GDMLMessenger::G4GDMLMessenger(G4GDMLParser* myPars)
00048   : myParser(myPars), topvol(0)
00049 { 
00050   persistencyDir = new G4UIdirectory("/persistency/");
00051   persistencyDir->SetGuidance("UI commands specific to persistency.");
00052   
00053   gdmlDir = new G4UIdirectory("/persistency/gdml/");
00054   gdmlDir->SetGuidance("GDML parser and writer.");
00055   
00056   ReaderCmd = new G4UIcmdWithAString("/persistency/gdml/read",this);
00057   ReaderCmd->SetGuidance("Read GDML file.");
00058   ReaderCmd->SetParameterName("filename",false);
00059   ReaderCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00060 
00061   TopVolCmd = new G4UIcmdWithAString("/persistency/gdml/topvol",this);
00062   TopVolCmd->SetGuidance("Set the top volume for writing the GDML file.");
00063   TopVolCmd->SetParameterName("topvol",false);
00064 
00065   WriterCmd = new G4UIcmdWithAString("/persistency/gdml/write",this);
00066   WriterCmd->SetGuidance("Write GDML file.");
00067   WriterCmd->SetParameterName("filename",false);
00068   WriterCmd->AvailableForStates(G4State_Idle);
00069 
00070   ClearCmd = new G4UIcmdWithoutParameter("/persistency/gdml/clear",this);
00071   ClearCmd->SetGuidance("Clear geometry (before reading a new one from GDML).");
00072   ClearCmd->AvailableForStates(G4State_Idle);
00073 }
00074 
00075 G4GDMLMessenger::~G4GDMLMessenger()
00076 {
00077   delete ReaderCmd;
00078   delete WriterCmd;
00079   delete ClearCmd;
00080   delete TopVolCmd;
00081   delete persistencyDir;
00082   delete gdmlDir;
00083 }
00084 
00085 void G4GDMLMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
00086 { 
00087   if( command == ReaderCmd )
00088   { 
00089     G4GeometryManager::GetInstance()->OpenGeometry();
00090     myParser->Read(newValue);
00091     G4RunManager::GetRunManager()->DefineWorldVolume(myParser->GetWorldVolume());
00092   }
00093 
00094   if( command == TopVolCmd )
00095   {
00096     topvol = G4LogicalVolumeStore::GetInstance()->GetVolume(newValue);
00097   }
00098    
00099   if( command == WriterCmd )
00100   {
00101     myParser->Write(newValue, topvol);
00102   }  
00103 
00104   if( command == ClearCmd )
00105   { 
00106     myParser->Clear();
00107     G4GeometryManager::GetInstance()->OpenGeometry();
00108     G4PhysicalVolumeStore::Clean();
00109     G4LogicalVolumeStore::Clean();
00110     G4SolidStore::Clean();
00111   }  
00112 }

Generated on Mon May 27 17:48:19 2013 for Geant4 by  doxygen 1.4.7