Geant4 Cross Reference |
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 // 28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 30 31 #include "DetectorMessenger.hh" 32 33 #include "G4UIcmdWithADoubleAndUnit.hh" 34 #include "G4UIcmdWithAString.hh" 35 #include "G4UIcmdWithAnInteger.hh" 36 #include "G4UIdirectory.hh" 37 38 #include "DetectorConstruction.hh" 39 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 41 42 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) 43 : G4UImessenger(), 44 fDetector(Det), 45 fTomoDir(nullptr), 46 fDetDir(nullptr), 47 fAbsMaterCmd(nullptr), 48 fAbsThickCmd(nullptr), 49 fAbsSizYZCmd(nullptr), 50 fAbsXposCmd(nullptr), 51 fWorldMaterCmd(nullptr), 52 fWorldXCmd(nullptr), 53 fWorldYZCmd(nullptr), 54 fPhantomType(nullptr) 55 { 56 fTomoDir = new G4UIdirectory("/tomography/"); 57 fTomoDir->SetGuidance("UI commands specific to this example."); 58 59 fDetDir = new G4UIdirectory("/tomography/det/"); 60 fDetDir->SetGuidance("detector construction commands"); 61 62 fAbsMaterCmd = new G4UIcmdWithAString("/tomography/det/setAbsMat", this); 63 fAbsMaterCmd->SetGuidance("Select Material of the Absorber."); 64 fAbsMaterCmd->SetParameterName("choice", false); 65 fAbsMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 66 fAbsMaterCmd->SetToBeBroadcasted(false); 67 68 fWorldMaterCmd = new G4UIcmdWithAString("/tomography/det/setWorldMat", this); 69 fWorldMaterCmd->SetGuidance("Select Material of the World."); 70 fWorldMaterCmd->SetParameterName("wchoice", false); 71 fWorldMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 72 fWorldMaterCmd->SetToBeBroadcasted(false); 73 74 fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setAbsThick", this); 75 fAbsThickCmd->SetGuidance("Set Thickness of the Absorber"); 76 fAbsThickCmd->SetParameterName("SizeZ", false); 77 fAbsThickCmd->SetRange("SizeZ>0."); 78 fAbsThickCmd->SetUnitCategory("Length"); 79 fAbsThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 80 fAbsThickCmd->SetToBeBroadcasted(false); 81 82 fAbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setAbsYZ", this); 83 fAbsSizYZCmd->SetGuidance("Set sizeYZ of the Absorber"); 84 fAbsSizYZCmd->SetParameterName("SizeYZ", false); 85 fAbsSizYZCmd->SetRange("SizeYZ>0."); 86 fAbsSizYZCmd->SetUnitCategory("Length"); 87 fAbsSizYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 88 fAbsSizYZCmd->SetToBeBroadcasted(false); 89 90 fAbsXposCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setAbsXpos", this); 91 fAbsXposCmd->SetGuidance("Set X pos. of the Absorber"); 92 fAbsXposCmd->SetParameterName("Xpos", false); 93 fAbsXposCmd->SetUnitCategory("Length"); 94 fAbsXposCmd->AvailableForStates(G4State_PreInit); 95 fAbsXposCmd->SetToBeBroadcasted(false); 96 97 fWorldXCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setWorldX", this); 98 fWorldXCmd->SetGuidance("Set X size of the World"); 99 fWorldXCmd->SetParameterName("WSizeX", false); 100 fWorldXCmd->SetRange("WSizeX>0."); 101 fWorldXCmd->SetUnitCategory("Length"); 102 fWorldXCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 103 fWorldXCmd->SetToBeBroadcasted(false); 104 105 fWorldYZCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setWorldYZ", this); 106 fWorldYZCmd->SetGuidance("Set sizeYZ of the World"); 107 fWorldYZCmd->SetParameterName("WSizeYZ", false); 108 fWorldYZCmd->SetRange("WSizeYZ>0."); 109 fWorldYZCmd->SetUnitCategory("Length"); 110 fWorldYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 111 fWorldYZCmd->SetToBeBroadcasted(false); 112 113 fPhantomType = new G4UIcmdWithAnInteger("/tomography/det/setPhantomType", this); 114 fPhantomType->SetGuidance("Select the type of target object."); 115 fPhantomType->SetParameterName("choice", false); 116 fPhantomType->AvailableForStates(G4State_PreInit, G4State_Idle); 117 fPhantomType->SetToBeBroadcasted(false); 118 } 119 120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 121 122 DetectorMessenger::~DetectorMessenger() 123 { 124 delete fAbsMaterCmd; 125 delete fAbsThickCmd; 126 delete fAbsSizYZCmd; 127 delete fAbsXposCmd; 128 delete fWorldMaterCmd; 129 delete fWorldXCmd; 130 delete fWorldYZCmd; 131 delete fDetDir; 132 delete fTomoDir; 133 delete fPhantomType; 134 } 135 136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 137 138 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) 139 { 140 if (command == fAbsMaterCmd) { 141 fDetector->SetAbsorberMaterial(newValue); 142 } 143 144 if (command == fWorldMaterCmd) { 145 fDetector->SetWorldMaterial(newValue); 146 } 147 148 if (command == fAbsThickCmd) { 149 fDetector->SetAbsorberThickness(fAbsThickCmd->GetNewDoubleValue(newValue)); 150 } 151 152 if (command == fAbsSizYZCmd) { 153 fDetector->SetAbsorberSizeYZ(fAbsSizYZCmd->GetNewDoubleValue(newValue)); 154 } 155 156 if (command == fAbsXposCmd) { 157 fDetector->SetAbsorberXpos(fAbsXposCmd->GetNewDoubleValue(newValue)); 158 } 159 160 if (command == fWorldXCmd) { 161 fDetector->SetWorldSizeX(fWorldXCmd->GetNewDoubleValue(newValue)); 162 } 163 164 if (command == fWorldYZCmd) { 165 fDetector->SetWorldSizeYZ(fWorldYZCmd->GetNewDoubleValue(newValue)); 166 } 167 168 if (command == fPhantomType) { 169 fDetector->SetPhantomType(fPhantomType->GetNewIntValue(newValue)); 170 } 171 } 172 173 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 174