Geant4 Cross Reference |
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 // This example is provided by the Geant4-DNA << 27 // Any report or published results obtained us << 28 // shall cite the following Geant4-DNA collabo << 29 // Med. Phys. 45 (2018) e722-e739 << 30 // Phys. Med. 31 (2015) 861-874 << 31 // Med. Phys. 37 (2010) 4692-4708 << 32 // Int. J. Model. Simul. Sci. Comput. 1 (2010) << 33 // << 34 // The Geant4-DNA web site is available at htt << 35 // << 36 /// \file DetectorMessenger.cc 26 /// \file DetectorMessenger.cc 37 /// \brief Implementation of the DetectorMesse 27 /// \brief Implementation of the DetectorMessenger class 38 28 39 #include "DetectorMessenger.hh" 29 #include "DetectorMessenger.hh" 40 << 41 #include "DetectorConstruction.hh" 30 #include "DetectorConstruction.hh" 42 31 43 #include "G4UIcmdWithADoubleAndUnit.hh" << 32 #include "G4UIdirectory.hh" 44 #include "G4UIcmdWithAString.hh" 33 #include "G4UIcmdWithAString.hh" >> 34 #include "G4UIcmdWithAnInteger.hh" >> 35 #include "G4UIcmdWithADoubleAndUnit.hh" 45 36 46 //....oooOO0OOooo........oooOO0OOooo........oo 37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 38 48 DetectorMessenger::DetectorMessenger(DetectorC << 39 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) 49 : G4UImessenger(), fDetector(Det), fTestemDi << 40 :G4UImessenger(),fDetector(Det), 50 { << 41 fTestemDir(0), >> 42 fDetDir(0), >> 43 fMaterCmd(0), >> 44 fRadiusCmd(0) >> 45 { 51 fTestemDir = new G4UIdirectory("/spower/"); 46 fTestemDir = new G4UIdirectory("/spower/"); 52 fTestemDir->SetGuidance("Detector control"); << 47 fTestemDir->SetGuidance("Detector control."); 53 << 48 54 fDetDir = new G4UIdirectory("/spower/det/"); 49 fDetDir = new G4UIdirectory("/spower/det/"); 55 fDetDir->SetGuidance("Detector construction 50 fDetDir->SetGuidance("Detector construction commands"); 56 << 51 57 fMaterCmd = new G4UIcmdWithAString("/spower/ << 52 fMaterCmd = new G4UIcmdWithAString("/spower/det/setMat",this); 58 fMaterCmd->SetGuidance("Select material of t << 53 fMaterCmd->SetGuidance("Select material of the sphere."); 59 fMaterCmd->SetParameterName("choice", false) << 54 fMaterCmd->SetParameterName("choice",false); 60 fMaterCmd->AvailableForStates(G4State_PreIni << 55 fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 61 fMaterCmd->SetToBeBroadcasted(false); << 56 fMaterCmd->SetToBeBroadcasted(false); 62 << 57 63 fRadiusCmd = new G4UIcmdWithADoubleAndUnit(" << 58 fRadiusCmd = new G4UIcmdWithADoubleAndUnit("/spower/det/setRadius",this); 64 fRadiusCmd->SetGuidance("Set radius of the s << 59 fRadiusCmd->SetGuidance("Set radius of the absorber"); 65 fRadiusCmd->SetParameterName("Radius", false << 60 fRadiusCmd->SetParameterName("Radius",false); 66 fRadiusCmd->SetRange("Radius>0."); 61 fRadiusCmd->SetRange("Radius>0."); 67 fRadiusCmd->SetUnitCategory("Length"); 62 fRadiusCmd->SetUnitCategory("Length"); 68 fRadiusCmd->AvailableForStates(G4State_PreIn << 63 fRadiusCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 69 fRadiusCmd->SetToBeBroadcasted(false); 64 fRadiusCmd->SetToBeBroadcasted(false); 70 } 65 } 71 66 72 //....oooOO0OOooo........oooOO0OOooo........oo 67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 73 68 74 DetectorMessenger::~DetectorMessenger() 69 DetectorMessenger::~DetectorMessenger() 75 { 70 { 76 delete fMaterCmd; 71 delete fMaterCmd; 77 delete fRadiusCmd; 72 delete fRadiusCmd; 78 delete fDetDir; << 73 delete fDetDir; 79 delete fTestemDir; 74 delete fTestemDir; 80 } 75 } 81 76 82 //....oooOO0OOooo........oooOO0OOooo........oo 77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 83 78 84 void DetectorMessenger::SetNewValue(G4UIcomman << 79 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 85 { << 80 { 86 if (command == fMaterCmd) { << 81 if( command == fMaterCmd ) 87 fDetector->SetMaterial(newValue); << 82 { fDetector->SetMaterial(newValue);} 88 } << 83 89 << 84 if( command == fRadiusCmd ) 90 if (command == fRadiusCmd) { << 85 { fDetector->SetRadius(fRadiusCmd->GetNewDoubleValue(newValue));} 91 fDetector->SetRadius(fRadiusCmd->GetNewDou << 92 } << 93 } 86 } 94 87