Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HadrontherapyDetectorMessenger.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 // This is the *BASIC* version of Hadrontherapy, a Geant4-based application
27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
28 //
29 // Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
30 // the *COMPLETE* version of this program, together with its documentation;
31 // Hadrontherapy (both basic and full version) are supported by the Italian INFN
32 // Institute in the framework of the MC-INFN Group
33 //
34 
37 #include "G4UIdirectory.hh"
40 #include "G4UIcmdWithAString.hh"
41 #include "G4SystemOfUnits.hh"
42 
45  :hadrontherapyDetector(detector)
46 {
47  // Change Phantom size
48  changeThePhantomDir = new G4UIdirectory("/changePhantom/");
49  changeThePhantomDir -> SetGuidance("Command to change the Phantom Size/position");
50  changeThePhantomSizeCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/size", this);
51  changeThePhantomSizeCmd -> SetGuidance("Insert sizes X Y and Z"
52  "\n 0 or negative values mean <<Don't change it!>>");
53  changeThePhantomSizeCmd -> SetParameterName("PhantomSizeAlongX",
54  "PhantomSizeAlongY",
55  "PhantomSizeAlongZ", false);
56  changeThePhantomSizeCmd -> SetDefaultUnit("mm");
57  changeThePhantomSizeCmd -> SetUnitCandidates("nm um mm cm");
58  changeThePhantomSizeCmd -> AvailableForStates(G4State_Idle);
59 
60 
61  // Change Phantom material
62  changeThePhantomMaterialCmd = new G4UIcmdWithAString("/changePhantom/material", this);
63  changeThePhantomMaterialCmd -> SetGuidance("Change the Phantom and the detector material");
64  changeThePhantomMaterialCmd -> SetParameterName("PhantomMaterial", false);
65  changeThePhantomMaterialCmd -> SetDefaultValue("G4_WATER");
66  changeThePhantomMaterialCmd -> AvailableForStates(G4State_Idle);
67 
68  // Change Phantom position
69  changeThePhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/position", this);
70  changeThePhantomPositionCmd -> SetGuidance("Insert X Y and Z dimensions for the position of the center of the Phantom"
71  " respect to that of the \"World\"");
72  changeThePhantomPositionCmd -> SetParameterName("PositionAlongX",
73  "PositionAlongY",
74  "PositionAlongZ", false);
75  changeThePhantomPositionCmd -> SetDefaultUnit("mm");
76  changeThePhantomPositionCmd -> SetUnitCandidates("um mm cm m");
77  changeThePhantomPositionCmd -> AvailableForStates(G4State_Idle);
78 
79 
80  updateCmd = new G4UIcmdWithoutParameter("/changePhantom/update",this);
81  updateCmd->SetGuidance("Update Phantom/Detector geometry.");
82  updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
83  updateCmd->SetGuidance("if you changed geometrical value(s).");
84  updateCmd->AvailableForStates(G4State_Idle);
85 
86  // Change detector size
87  changeTheDetectorDir = new G4UIdirectory("/changeDetector/");
88  changeTheDetectorDir -> SetGuidance("Command to change the Detector's Size/position/Voxels");
89 
90  changeTheDetectorSizeCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/size",this);
91  changeTheDetectorSizeCmd -> SetGuidance("Insert sizes for X Y and Z dimensions of the Detector"
92  "\n 0 or negative values mean <<Don't change it>>");
93  changeTheDetectorSizeCmd -> SetParameterName("DetectorSizeAlongX", "DetectorSizeAlongY", "DetectorSizeAlongZ", false);
94  changeTheDetectorSizeCmd -> SetDefaultUnit("mm");
95  changeTheDetectorSizeCmd -> SetUnitCandidates("nm um mm cm");
96  changeTheDetectorSizeCmd -> AvailableForStates(G4State_Idle);
97 
98  // Change the detector to phantom displacement
99  changeTheDetectorToPhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/displacement",this);
100  changeTheDetectorToPhantomPositionCmd -> SetGuidance("Insert X Y and Z displacements between Detector and Phantom"
101  "\nNegative values mean <<Don't change it!>>");
102  changeTheDetectorToPhantomPositionCmd -> SetParameterName("DisplacementAlongX",
103  "DisplacementAlongY",
104  "DisplacementAlongZ", false);
105  changeTheDetectorToPhantomPositionCmd -> SetDefaultUnit("mm");
106  changeTheDetectorToPhantomPositionCmd -> SetUnitCandidates("nm um mm cm");
107  changeTheDetectorToPhantomPositionCmd -> AvailableForStates(G4State_Idle);
108 
109  // Change voxels by its size
110  changeTheDetectorVoxelCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/voxelSize",this);
111  changeTheDetectorVoxelCmd -> SetGuidance("Insert Voxel sizes for X Y and Z dimensions"
112  "\n 0 or negative values mean <<Don't change it!>>");
113  changeTheDetectorVoxelCmd -> SetParameterName("VoxelSizeAlongX", "VoxelSizeAlongY", "VoxelSizeAlongZ", false);
114  changeTheDetectorVoxelCmd -> SetDefaultUnit("mm");
115  changeTheDetectorVoxelCmd -> SetUnitCandidates("nm um mm cm");
116  changeTheDetectorVoxelCmd -> AvailableForStates(G4State_Idle);
117  }
118 
121 {
122  delete changeThePhantomDir;
123  delete changeThePhantomSizeCmd;
124  delete changeThePhantomPositionCmd;
125  delete changeThePhantomMaterialCmd;
126  delete updateCmd;
127  delete changeTheDetectorDir;
128  delete changeTheDetectorSizeCmd;
129  delete changeTheDetectorToPhantomPositionCmd;
130  delete changeTheDetectorVoxelCmd;
131 }
132 
135 {
136 
137  if( command == changeThePhantomSizeCmd)
138  {
139  G4ThreeVector size = changeThePhantomSizeCmd -> GetNew3VectorValue(newValue);
140  hadrontherapyDetector -> SetPhantomSize(size.getX(),size.getY(),size.getZ());
141  }
142  else if (command == changeThePhantomPositionCmd )
143  {
144  G4ThreeVector size = changeThePhantomPositionCmd -> GetNew3VectorValue(newValue);
145  hadrontherapyDetector -> SetPhantomPosition(size);
146  }
147  else if (command == changeThePhantomMaterialCmd)
148  {
149  hadrontherapyDetector -> SetPhantomMaterial(newValue);
150  }
151  else if (command == changeTheDetectorSizeCmd)
152  {
153  G4ThreeVector size = changeTheDetectorSizeCmd -> GetNew3VectorValue(newValue);
154  hadrontherapyDetector -> SetDetectorSize(size.getX(),size.getY(),size.getZ());
155  }
156  else if (command == changeTheDetectorToPhantomPositionCmd)
157  {
158  G4ThreeVector size = changeTheDetectorToPhantomPositionCmd-> GetNew3VectorValue(newValue);
159  hadrontherapyDetector -> SetDetectorToPhantomPosition(size);
160  }
161  else if (command == changeTheDetectorVoxelCmd)
162  {
163  G4ThreeVector size = changeTheDetectorVoxelCmd -> GetNew3VectorValue(newValue);
164  hadrontherapyDetector -> SetVoxelSize(size.getX(),size.getY(),size.getZ());
165  }
166  else if (command == updateCmd)
167  {
168  hadrontherapyDetector -> UpdateGeometry();
169  }
170 }