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