Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
HadrontherapyDetectorMessenger.cc
이 파일의 문서화 페이지로 가기
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 // Hadrontherapy advanced example for Geant4
27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
28 
31 #include "G4UIdirectory.hh"
34 #include "G4UIcmdWithAString.hh"
35 #include "G4SystemOfUnits.hh"
36 #include "G4UIcmdWithABool.hh"
37 
40  :hadrontherapyDetector(detector)
41 {
42  // Change Phantom size
43  changeThePhantomDir = new G4UIdirectory("/changePhantom/");
44  changeThePhantomDir -> SetGuidance("Command to change the Phantom Size/position");
45  changeThePhantomSizeCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/size", this);
46  changeThePhantomSizeCmd -> SetGuidance("Insert sizes X Y and Z"
47  "\n 0 or negative values mean <<Don't change it!>>");
48  changeThePhantomSizeCmd -> SetParameterName("PhantomSizeAlongX",
49  "PhantomSizeAlongY",
50  "PhantomSizeAlongZ", false);
51  changeThePhantomSizeCmd -> SetDefaultUnit("mm");
52  changeThePhantomSizeCmd -> SetUnitCandidates("nm um mm cm");
53  changeThePhantomSizeCmd -> AvailableForStates(G4State_Idle);
54 
55 
56  // Change Phantom material
57  changeThePhantomMaterialCmd = new G4UIcmdWithAString("/changePhantom/material", this);
58  changeThePhantomMaterialCmd -> SetGuidance("Change the Phantom and the detector material");
59  changeThePhantomMaterialCmd -> SetParameterName("PhantomMaterial", false);
60  changeThePhantomMaterialCmd -> SetDefaultValue("G4_WATER");
61  changeThePhantomMaterialCmd -> AvailableForStates(G4State_Idle);
62 
63  // Change Phantom position
64  changeThePhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/position", this);
65  changeThePhantomPositionCmd -> SetGuidance("Insert X Y and Z dimensions for the position of the center of the Phantom"
66  " respect to that of the \"World\"");
67  changeThePhantomPositionCmd -> SetParameterName("PositionAlongX",
68  "PositionAlongY",
69  "PositionAlongZ", false);
70  changeThePhantomPositionCmd -> SetDefaultUnit("mm");
71  changeThePhantomPositionCmd -> SetUnitCandidates("um mm cm m");
72  changeThePhantomPositionCmd -> AvailableForStates(G4State_Idle);
73 
74 
75  updateCmd = new G4UIcmdWithoutParameter("/changePhantom/update",this);
76  updateCmd->SetGuidance("Update Phantom/Detector geometry.");
77  updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
78  updateCmd->SetGuidance("if you changed geometrical value(s).");
80 
81  // Change detector size
82  changeTheDetectorDir = new G4UIdirectory("/changeDetector/");
83  changeTheDetectorDir -> SetGuidance("Command to change the Detector's Size/position/Voxels");
84 
85  changeTheDetectorSizeCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/size",this);
86  changeTheDetectorSizeCmd -> SetGuidance("Insert sizes for X Y and Z dimensions of the Detector"
87  "\n 0 or negative values mean <<Don't change it>>");
88  changeTheDetectorSizeCmd -> SetParameterName("DetectorSizeAlongX", "DetectorSizeAlongY", "DetectorSizeAlongZ", false);
89  changeTheDetectorSizeCmd -> SetDefaultUnit("mm");
90  changeTheDetectorSizeCmd -> SetUnitCandidates("nm um mm cm");
91  changeTheDetectorSizeCmd -> AvailableForStates(G4State_Idle);
92 
93  // Change the detector to phantom displacement
94  changeTheDetectorToPhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/displacement",this);
95  changeTheDetectorToPhantomPositionCmd -> SetGuidance("Insert X Y and Z displacements between Detector and Phantom"
96  "\nNegative values mean <<Don't change it!>>");
97  changeTheDetectorToPhantomPositionCmd -> SetParameterName("DisplacementAlongX",
98  "DisplacementAlongY",
99  "DisplacementAlongZ", false);
100  changeTheDetectorToPhantomPositionCmd -> SetDefaultUnit("mm");
101  changeTheDetectorToPhantomPositionCmd -> SetUnitCandidates("nm um mm cm");
103 
104  // Change voxels by its size
105  changeTheDetectorVoxelCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/voxelSize",this);
106  changeTheDetectorVoxelCmd -> SetGuidance("Insert Voxel sizes for X Y and Z dimensions"
107  "\n 0 or negative values mean <<Don't change it!>>");
108  changeTheDetectorVoxelCmd -> SetParameterName("VoxelSizeAlongX", "VoxelSizeAlongY", "VoxelSizeAlongZ", false);
109  changeTheDetectorVoxelCmd -> SetDefaultUnit("mm");
110  changeTheDetectorVoxelCmd -> SetUnitCandidates("nm um mm cm");
111  changeTheDetectorVoxelCmd -> AvailableForStates(G4State_Idle);
112 
113 
114 
115 
116 
117 }
118 
121 {
122  delete changeThePhantomDir;
123  delete changeThePhantomSizeCmd;
126  delete updateCmd;
127  delete changeTheDetectorDir;
128  delete changeTheDetectorSizeCmd;
131 
132 }
133 
136 {
137 
138  if( command == changeThePhantomSizeCmd)
139  {
140  G4ThreeVector size = changeThePhantomSizeCmd -> GetNew3VectorValue(newValue);
141  hadrontherapyDetector -> SetPhantomSize(size.getX(),size.getY(),size.getZ());
142  }
143  else if (command == changeThePhantomPositionCmd )
144  {
145  G4ThreeVector size = changeThePhantomPositionCmd -> GetNew3VectorValue(newValue);
146  hadrontherapyDetector -> SetPhantomPosition(size);
147  }
148  else if (command == changeThePhantomMaterialCmd)
149  {
150  hadrontherapyDetector -> SetPhantomMaterial(newValue);
151  }
152  else if (command == changeTheDetectorSizeCmd)
153  {
154  G4ThreeVector size = changeTheDetectorSizeCmd -> GetNew3VectorValue(newValue);
155  hadrontherapyDetector -> SetDetectorSize(size.getX(),size.getY(),size.getZ());
156  }
157  else if (command == changeTheDetectorToPhantomPositionCmd)
158  {
159  G4ThreeVector size = changeTheDetectorToPhantomPositionCmd-> GetNew3VectorValue(newValue);
160  hadrontherapyDetector -> SetDetectorToPhantomPosition(size);
161  }
162  else if (command == changeTheDetectorVoxelCmd)
163  {
164  G4ThreeVector size = changeTheDetectorVoxelCmd -> GetNew3VectorValue(newValue);
165  hadrontherapyDetector -> SetVoxelSize(size.getX(),size.getY(),size.getZ());
166  }
167  else if (command == updateCmd)
168  {
169  hadrontherapyDetector -> UpdateGeometry();
170  }
171 
172 }
G4UIcmdWith3VectorAndUnit * changeTheDetectorSizeCmd
HadrontherapyDetectorMessenger(HadrontherapyDetectorConstruction *)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
double getZ() const
G4UIcmdWith3VectorAndUnit * changeThePhantomSizeCmd
G4UIcmdWith3VectorAndUnit * changeThePhantomPositionCmd
G4UIcmdWith3VectorAndUnit * changeTheDetectorVoxelCmd
double getX() const
HadrontherapyDetectorConstruction * hadrontherapyDetector
double getY() const
G4UIcmdWith3VectorAndUnit * changeTheDetectorToPhantomPositionCmd
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242