Geant4  10.00.p03
G4HumanPhantomMessenger.cc
Go to the documentation of this file.
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 , M. G. Pia, INFN Genova and F. Ambroglini INFN Perugia, 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 //
36 
37 #include "G4UIdirectory.hh"
38 #include "G4UIcmdWithAString.hh"
40 
41 #include "globals.hh"
42 
43 #include "G4RunManager.hh"
44 
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");
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");
67 
68  bodypartCmd = new G4UIcmdWithAString("/bodypart/addBodyPart",this);
69  bodypartCmd->SetGuidance("Add a Body Part to Phantom");
70  bodypartCmd->SetParameterName("bpName",true);
72 
73  endCmd = new G4UIcmdWithoutParameter("/phantom/buildNewPhantom",this);
74  endCmd->SetGuidance("Build your Phantom.");
76 
77 }
78 
80 {
81  delete modelCmd;
82  delete sexCmd;
83  delete bodypartCmd;
84  delete endCmd;
85  delete phantomDir;
86  delete bpDir;
87 }
88 
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 bpart = 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 = " << bpart << "\n"
129  << " >>> Sensitivity = " << sensitivity << G4endl;
130 
132 }
133 
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4HumanPhantomMessenger(G4HumanPhantomConstruction *myUsrPhtm)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4HumanPhantomConstruction * myUserPhantom
G4UIcmdWithoutParameter * endCmd
G4GLOB_DLL std::ostream G4cout
void SetBodyPartSensitivity(G4String, G4bool)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
G4UIcmdWithAString * bodypartCmd
void SetDefaultValue(const char *defVal)
void SetCandidates(const char *candidateList)
#define G4endl
Definition: G4ios.hh:61