[807] | 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 | // Authors: S. Guatelli and M. G. Pia, INFN Genova, Italy |
---|
| 27 | // |
---|
| 28 | // Based on code developed by the undergraduate student G. Guerrieri |
---|
| 29 | // Note: this is a preliminary beta-version of the code; an improved |
---|
| 30 | // version will be distributed in the next Geant4 public release, compliant |
---|
| 31 | // with the design in a forthcoming publication, and subject to a |
---|
| 32 | // design and code review. |
---|
| 33 | // |
---|
| 34 | #include "G4HumanPhantomMessenger.hh" |
---|
| 35 | #include "G4HumanPhantomConstruction.hh" |
---|
| 36 | |
---|
| 37 | #include "G4UIdirectory.hh" |
---|
| 38 | #include "G4UIcmdWithAString.hh" |
---|
| 39 | #include "G4UIcmdWithoutParameter.hh" |
---|
| 40 | |
---|
| 41 | #include "globals.hh" |
---|
| 42 | |
---|
| 43 | #include "G4RunManager.hh" |
---|
| 44 | |
---|
| 45 | G4HumanPhantomMessenger::G4HumanPhantomMessenger(G4HumanPhantomConstruction* myUsrPhtm) |
---|
| 46 | :myUserPhantom(myUsrPhtm),bps(false) |
---|
| 47 | { |
---|
| 48 | phantomDir = new G4UIdirectory("/phantom/"); |
---|
| 49 | phantomDir->SetGuidance("Set Your Phantom."); |
---|
| 50 | |
---|
| 51 | bpDir = new G4UIdirectory("/bodypart/"); |
---|
| 52 | bpDir->SetGuidance("Add Body Part to Phantom"); |
---|
| 53 | |
---|
| 54 | modelCmd = new G4UIcmdWithAString("/phantom/setPhantomModel",this); |
---|
| 55 | modelCmd->SetGuidance("Set sex of Phantom: MIRD, ORNLFemale, ORNLMale, MIX, MIRDHead, ORNLHead."); |
---|
| 56 | modelCmd->SetParameterName("phantomModel",true); |
---|
| 57 | modelCmd->SetDefaultValue("MIRD"); |
---|
| 58 | modelCmd->SetCandidates("MIRD ORNLFemale ORNLMale MIX MIRDHead ORNLHead"); |
---|
| 59 | modelCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
| 60 | |
---|
| 61 | sexCmd = new G4UIcmdWithAString("/phantom/setPhantomSex",this); |
---|
| 62 | sexCmd->SetGuidance("Set sex of Phantom: Male or Female."); |
---|
| 63 | sexCmd->SetParameterName("phantomSex",true); |
---|
| 64 | sexCmd->SetDefaultValue("Female"); |
---|
| 65 | sexCmd->SetCandidates("Male Female"); |
---|
| 66 | sexCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
| 67 | |
---|
| 68 | bodypartCmd = new G4UIcmdWithAString("/bodypart/addBodyPart",this); |
---|
| 69 | bodypartCmd->SetGuidance("Add a Body Part to Phantom"); |
---|
| 70 | bodypartCmd->SetParameterName("bpName",true); |
---|
| 71 | bodypartCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
| 72 | |
---|
| 73 | endCmd = new G4UIcmdWithoutParameter("/phantom/buildNewPhantom",this); |
---|
| 74 | endCmd->SetGuidance("Build your Phantom."); |
---|
| 75 | endCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
| 76 | |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | G4HumanPhantomMessenger::~G4HumanPhantomMessenger() |
---|
| 80 | { |
---|
| 81 | delete modelCmd; |
---|
| 82 | delete sexCmd; |
---|
| 83 | delete bodypartCmd; |
---|
| 84 | delete endCmd; |
---|
| 85 | delete phantomDir; |
---|
| 86 | delete bpDir; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | void G4HumanPhantomMessenger::SetNewValue(G4UIcommand* command,G4String newValue){ |
---|
| 90 | |
---|
| 91 | if( command == modelCmd ) |
---|
| 92 | { |
---|
| 93 | myUserPhantom->SetPhantomModel(newValue); |
---|
| 94 | } |
---|
| 95 | if( command == sexCmd ) |
---|
| 96 | { |
---|
| 97 | myUserPhantom->SetPhantomSex(newValue); |
---|
| 98 | } |
---|
| 99 | if( command == bodypartCmd ) |
---|
| 100 | { |
---|
| 101 | AddBodyPart(newValue); |
---|
| 102 | } |
---|
| 103 | if( command == endCmd ) |
---|
| 104 | { |
---|
| 105 | G4cout << |
---|
| 106 | " ****************>>>> NEW PHANTOM CONSTRUCTION <<<<***************** " |
---|
| 107 | << G4endl; |
---|
| 108 | } |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | void G4HumanPhantomMessenger::AddBodyPart(G4String newBodyPartSensitivity) |
---|
| 112 | { |
---|
| 113 | |
---|
| 114 | char* str = new char[newBodyPartSensitivity.length()+1]; |
---|
| 115 | |
---|
| 116 | strcpy(str, newBodyPartSensitivity.c_str()); |
---|
| 117 | |
---|
| 118 | std::string bodypart = strtok(str," "); |
---|
| 119 | |
---|
| 120 | std::string sensitivity = strtok(NULL," "); |
---|
| 121 | |
---|
| 122 | if(sensitivity=="yes"){ |
---|
| 123 | bps=true; |
---|
| 124 | }else{ |
---|
| 125 | bps=false; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | G4cout << " >>> Body Part = " << bodypart << "\n" |
---|
| 129 | << " >>> Sensitivity = " << sensitivity << G4endl; |
---|
| 130 | |
---|
| 131 | myUserPhantom->SetBodyPartSensitivity(bodypart,bps); |
---|
| 132 | } |
---|
| 133 | |
---|