Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // Hadrontherapy advanced example for Geant4 27 // See more at: https://twiki.cern.ch/twiki/bi 28 29 #include "HadrontherapyDetectorMessenger.hh" 30 #include "HadrontherapyDetectorConstruction.hh 31 #include "G4UIdirectory.hh" 32 #include "G4UIcmdWith3VectorAndUnit.hh" 33 #include "G4UIcmdWithoutParameter.hh" 34 #include "G4UIcmdWithAString.hh" 35 #include "G4SystemOfUnits.hh" 36 #include "G4UIcmdWithABool.hh" 37 38 ////////////////////////////////////////////// 39 HadrontherapyDetectorMessenger::HadrontherapyD 40 :hadrontherapyDetector(detector) 41 { 42 // Change Phantom size 43 changeThePhantomDir = new G4UIdirectory("/ 44 changeThePhantomDir -> SetGuidance("Comman 45 changeThePhantomSizeCmd = new G4UIcmdWith3 46 changeThePhantomSizeCmd -> SetGuidance("In 47 "\n 48 changeThePhantomSizeCmd -> SetParameterNam 49 50 51 changeThePhantomSizeCmd -> SetDefaultUnit( 52 changeThePhantomSizeCmd -> SetUnitCandidat 53 changeThePhantomSizeCmd -> AvailableForSta 54 55 56 // Change Phantom material 57 changeThePhantomMaterialCmd = new G4UIcmdW 58 changeThePhantomMaterialCmd -> SetGuidance 59 changeThePhantomMaterialCmd -> SetParamete 60 changeThePhantomMaterialCmd -> SetDefaultV 61 changeThePhantomMaterialCmd -> AvailableFo 62 63 // Change Phantom position 64 changeThePhantomPositionCmd = new G4UIcmdW 65 changeThePhantomPositionCmd -> SetGuidance 66 67 changeThePhantomPositionCmd -> SetParamete 68 69 70 changeThePhantomPositionCmd -> SetDefaultU 71 changeThePhantomPositionCmd -> SetUnitCand 72 changeThePhantomPositionCmd -> AvailableFo 73 74 75 updateCmd = new G4UIcmdWithoutParameter("/ 76 updateCmd->SetGuidance("Update Phantom/Det 77 updateCmd->SetGuidance("This command MUST 78 updateCmd->SetGuidance("if you changed geo 79 updateCmd->AvailableForStates(G4State_Idle 80 81 // Change detector size 82 changeTheDetectorDir = new G4UIdirectory(" 83 changeTheDetectorDir -> SetGuidance("Comma 84 85 changeTheDetectorSizeCmd = new G4UIcmdWith 86 changeTheDetectorSizeCmd -> SetGuidance("I 87 "\ 88 changeTheDetectorSizeCmd -> SetParameterNa 89 changeTheDetectorSizeCmd -> SetDefaultUnit 90 changeTheDetectorSizeCmd -> SetUnitCandida 91 changeTheDetectorSizeCmd -> AvailableForSt 92 93 // Change the detector to phantom displac 94 changeTheDetectorToPhantomPositionCmd = ne 95 changeTheDetectorToPhantomPositionCmd -> S 96 97 changeTheDetectorToPhantomPositionCmd -> S 98 99 100 changeTheDetectorToPhantomPositionCmd -> S 101 changeTheDetectorToPhantomPositionCmd -> S 102 changeTheDetectorToPhantomPositionCmd -> A 103 104 // Change voxels by its size 105 changeTheDetectorVoxelCmd = new G4UIcmdWit 106 changeTheDetectorVoxelCmd -> SetGuidance(" 107 " 108 changeTheDetectorVoxelCmd -> SetParameterN 109 changeTheDetectorVoxelCmd -> SetDefaultUni 110 changeTheDetectorVoxelCmd -> SetUnitCandid 111 changeTheDetectorVoxelCmd -> AvailableForS 112 113 114 changeTheSource = new G4UIdirectory("/chan 115 changeTheSource -> SetGuidance("Command to 116 117 118 119 120 ////////////////////////////////////////// 121 122 VirtualLayer = new G4UIcmdWithABool("/chan 123 VirtualLayer -> SetParameterName("VirtualL 124 VirtualLayer -> SetDefaultValue("false"); 125 VirtualLayer -> SetGuidance("Set if you wa 126 "\n[usage]: /c 127 VirtualLayer -> AvailableForStates(G4State 128 129 130 VirtualLayerPosition = new G4UIcmdWith3Vec 131 VirtualLayerPosition -> SetGuidance("Inser 132 " resp 133 VirtualLayerPosition -> SetParameterName(" 134 " 135 " 136 137 VirtualLayerPosition -> SetDefaultUnit("cm 138 VirtualLayerPosition -> SetUnitCandidates( 139 VirtualLayerPosition -> AvailableForStates 140 141 142 143 } 144 145 ////////////////////////////////////////////// 146 HadrontherapyDetectorMessenger::~Hadrontherapy 147 { 148 delete changeThePhantomDir; 149 delete changeThePhantomSizeCmd; 150 delete changeThePhantomPositionCmd; 151 delete changeThePhantomMaterialCmd; 152 delete updateCmd; 153 delete changeTheDetectorDir; 154 delete changeTheDetectorSizeCmd; 155 delete changeTheDetectorToPhantomPositionC 156 delete changeTheDetectorVoxelCmd; 157 delete VirtualLayer; 158 delete VirtualLayerPosition; 159 } 160 161 ////////////////////////////////////////////// 162 void HadrontherapyDetectorMessenger::SetNewVal 163 { 164 165 if( command == changeThePhantomSizeCmd) 166 { 167 G4ThreeVector size = changeThePhantomS 168 hadrontherapyDetector -> SetPhantomSiz 169 } 170 else if (command == changeThePhantomPositi 171 { 172 173 G4ThreeVector size = changeThePhantomP 174 hadrontherapyDetector -> SetPhantomPos 175 } 176 else if (command == changeThePhantomMateri 177 { 178 hadrontherapyDetector -> SetPhantomMat 179 } 180 else if (command == changeTheDetectorSizeC 181 { 182 G4ThreeVector size = changeTheDetector 183 hadrontherapyDetector -> SetDetectorSi 184 } 185 else if (command == changeTheDetectorToPha 186 { 187 G4ThreeVector size = changeTheDetector 188 hadrontherapyDetector -> SetDetectorTo 189 190 } 191 else if (command == changeTheDetectorVoxel 192 { 193 G4ThreeVector size = changeTheDetector 194 hadrontherapyDetector -> SetVoxelSize( 195 } 196 else if (command == updateCmd) 197 { 198 hadrontherapyDetector -> UpdateGeometr 199 } 200 201 else if(command == VirtualLayer) 202 { 203 hadrontherapyDetector->VirtualLayer(Vi 204 } 205 else if(command == VirtualLayerPosition) 206 { 207 G4ThreeVector size = VirtualLayerPosit 208 209 hadrontherapyDetector -> SetVirtualLay 210 } 211 212 } 213