File indexing completed on 2025-02-23 09:20:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "G4HumanPhantomMessenger.hh"
0030 #include "G4HumanPhantomConstruction.hh"
0031
0032 #include "G4UIdirectory.hh"
0033 #include "G4UIcmdWithAString.hh"
0034 #include "G4UIcmdWithoutParameter.hh"
0035
0036 #include "globals.hh"
0037
0038 #include "G4RunManager.hh"
0039
0040 G4HumanPhantomMessenger::G4HumanPhantomMessenger(G4HumanPhantomConstruction* myUsrPhtm)
0041 :fUserPhantom(myUsrPhtm),fBps(false)
0042 {
0043 fPhantomDir = new G4UIdirectory("/phantom/");
0044 fPhantomDir->SetGuidance("Set Your Phantom.");
0045
0046 fDir = new G4UIdirectory("/bodypart/");
0047 fDir->SetGuidance("Add Body Part to Phantom");
0048
0049 fModelCmd = new G4UIcmdWithAString("/phantom/setPhantomModel",this);
0050 fModelCmd->SetGuidance("Set sex of Phantom: MIRD, ORNLFemale, ORNLMale, MIX, MIRDHead, ORNLHead.");
0051 fModelCmd->SetParameterName("phantomModel",true);
0052 fModelCmd->SetDefaultValue("MIRD");
0053 fModelCmd->SetCandidates("MIRD ORNLFemale ORNLMale MIRDHead ORNLHead");
0054 fModelCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0055
0056 fSexCmd = new G4UIcmdWithAString("/phantom/setPhantomSex",this);
0057 fSexCmd->SetGuidance("Set sex of Phantom: Male or Female.");
0058 fSexCmd->SetParameterName("phantomSex",true);
0059 fSexCmd->SetDefaultValue("Female");
0060 fSexCmd->SetCandidates("Male Female");
0061 fSexCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0062
0063 fBodypartCmd = new G4UIcmdWithAString("/bodypart/addBodyPart",this);
0064 fBodypartCmd->SetGuidance("Add a Body Part to Phantom");
0065 fBodypartCmd->SetParameterName("bpName",true);
0066 fBodypartCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0067
0068 fEndCmd = new G4UIcmdWithoutParameter("/phantom/buildNewPhantom",this);
0069 fEndCmd->SetGuidance("Build your Phantom.");
0070 fEndCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0071 }
0072
0073 G4HumanPhantomMessenger::~G4HumanPhantomMessenger()
0074 {
0075 delete fModelCmd;
0076 delete fSexCmd;
0077 delete fBodypartCmd;
0078 delete fEndCmd;
0079 delete fPhantomDir;
0080 delete fDir;
0081 }
0082
0083 void G4HumanPhantomMessenger::SetNewValue(G4UIcommand* command,G4String newValue){
0084
0085 if( command == fModelCmd )
0086 {
0087 fUserPhantom->SetPhantomModel(newValue);
0088 }
0089 if( command == fSexCmd )
0090 {
0091 fUserPhantom->SetPhantomSex(newValue);
0092 }
0093 if( command == fBodypartCmd )
0094 {
0095 AddBodyPart(newValue);
0096 }
0097 if( command == fEndCmd )
0098 {
0099 G4cout <<
0100 " ****************>>>> NEW PHANTOM CONSTRUCTION <<<<***************** "
0101 << G4endl;
0102 }
0103 }
0104
0105 void G4HumanPhantomMessenger::AddBodyPart(G4String newBodyPartSensitivity)
0106 {
0107 char* str = new char[newBodyPartSensitivity.length()+1];
0108
0109 strcpy(str, newBodyPartSensitivity.c_str());
0110
0111 std::string bpart = strtok(str," ");
0112
0113 std::string sensitivity = strtok(nullptr," ");
0114
0115 if(sensitivity=="yes"){
0116 fBps=true;
0117 }else{
0118 fBps=false;
0119 }
0120
0121 G4cout << " >>> Body Part = " << bpart << "\n"
0122 << " >>> Sensitivity = " << sensitivity << G4endl;
0123
0124 fUserPhantom->SetBodyPartSensitivity(bpart,fBps);
0125 }
0126