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 | // |
---|
27 | // $Id: MedLinacDetectorMessenger.cc,v 1.5 2006/06/29 16:04:21 gunter Exp $ |
---|
28 | // |
---|
29 | // Code developed by: M. Piergentili |
---|
30 | |
---|
31 | #include "MedLinacDetectorMessenger.hh" |
---|
32 | #include "MedLinacDetectorConstruction.hh" |
---|
33 | #include "G4UIdirectory.hh" |
---|
34 | #include "G4UIcmdWithAString.hh" |
---|
35 | #include "G4UIcmdWithAnInteger.hh" |
---|
36 | #include "G4UIcmdWithADoubleAndUnit.hh" |
---|
37 | #include "G4UIcmdWithoutParameter.hh" |
---|
38 | |
---|
39 | //********************************************************************* |
---|
40 | |
---|
41 | MedLinacDetectorMessenger::MedLinacDetectorMessenger( |
---|
42 | MedLinacDetectorConstruction* MedLinacDet) |
---|
43 | :MedLinacDetector(MedLinacDet) |
---|
44 | { |
---|
45 | |
---|
46 | G4cout <<"==================DetectorMessenger "<<G4endl; |
---|
47 | MedLinacDir = new G4UIdirectory("/Jaws/"); |
---|
48 | MedLinacDir->SetGuidance("jaws position"); |
---|
49 | |
---|
50 | MedLinacDir = new G4UIdirectory("/Phantom/"); |
---|
51 | MedLinacDir->SetGuidance("phantom parameters"); |
---|
52 | |
---|
53 | |
---|
54 | X1Dir = new G4UIdirectory("/Jaws/X1/"); |
---|
55 | X2Dir = new G4UIdirectory("/Jaws/X2/"); |
---|
56 | Y1Dir = new G4UIdirectory("/Jaws/Y1/"); |
---|
57 | Y2Dir = new G4UIdirectory("/Jaws/Y2/"); |
---|
58 | |
---|
59 | |
---|
60 | JawX1PosCmd = new G4UIcmdWithADoubleAndUnit("/Jaws/X1/DistanceFromAxis",this); |
---|
61 | JawX1PosCmd->SetGuidance("Set jawsx1 position (negative)"); |
---|
62 | JawX1PosCmd->SetParameterName("JawsX1Pos_x",false); |
---|
63 | JawX1PosCmd->SetRange("JawsX1Pos_x<=0. && JawsX1Pos_x>-1000."); |
---|
64 | JawX1PosCmd->SetDefaultUnit( "cm" ); |
---|
65 | JawX1PosCmd->SetUnitCategory("Length"); |
---|
66 | JawX1PosCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
67 | |
---|
68 | JawX2PosCmd = new G4UIcmdWithADoubleAndUnit("/Jaws/X2/DistanceFromAxis",this); |
---|
69 | JawX2PosCmd->SetGuidance("Set jawsx2 position (positive)"); |
---|
70 | JawX2PosCmd->SetParameterName("JawsX2Pos_x",false); |
---|
71 | JawX2PosCmd->SetRange("JawsX2Pos_x>=0. && JawsX2Pos_x<1000."); |
---|
72 | JawX2PosCmd->SetDefaultUnit( "cm" ); |
---|
73 | JawX2PosCmd->SetUnitCategory("Length"); |
---|
74 | JawX2PosCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
75 | |
---|
76 | JawY1PosCmd = new G4UIcmdWithADoubleAndUnit("/Jaws/Y1/DistanceFromAxis",this); |
---|
77 | JawY1PosCmd->SetGuidance("Set jawsy1 position (negative)"); |
---|
78 | JawY1PosCmd->SetParameterName("JawsY1Pos_y",false); |
---|
79 | JawY1PosCmd->SetRange("JawsY1Pos_y<=0. && JawsY1Pos_y>-1000."); |
---|
80 | JawY1PosCmd->SetDefaultUnit( "cm" ); |
---|
81 | JawY1PosCmd->SetUnitCategory("Length"); |
---|
82 | JawY1PosCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
83 | |
---|
84 | JawY2PosCmd = new G4UIcmdWithADoubleAndUnit("/Jaws/Y2/DistanceFromAxis",this); |
---|
85 | JawY2PosCmd->SetGuidance("Set jawsy2 position (positive)"); |
---|
86 | JawY2PosCmd->SetParameterName("JawsY2Pos_y",false); |
---|
87 | JawY2PosCmd->SetRange("JawsY2Pos_y>=0. && JawsY2Pos_y<1000."); |
---|
88 | JawY2PosCmd->SetDefaultUnit( "cm" ); |
---|
89 | JawY2PosCmd->SetUnitCategory("Length"); |
---|
90 | JawY2PosCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
91 | |
---|
92 | PhantomDimCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/dimension",this); |
---|
93 | PhantomDimCmd->SetGuidance("Set phantom dimension (cm)"); |
---|
94 | PhantomDimCmd->SetParameterName("phantomDim",false); |
---|
95 | PhantomDimCmd->SetDefaultUnit( "cm" ); |
---|
96 | PhantomDimCmd->SetUnitCategory("Length"); |
---|
97 | PhantomDimCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
98 | |
---|
99 | NVoxelsCmd = new G4UIcmdWithAnInteger("/Phantom/Nvoxels",this); |
---|
100 | NVoxelsCmd->SetGuidance("Set number of voxels along one axis"); |
---|
101 | NVoxelsCmd->SetParameterName("numberOfVoxels",false); |
---|
102 | NVoxelsCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
103 | |
---|
104 | MaxStepCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/maxStep",this); |
---|
105 | MaxStepCmd->SetGuidance("Set max step in the phantom (mm)"); |
---|
106 | MaxStepCmd->SetParameterName("maxStep",false); |
---|
107 | MaxStepCmd->SetDefaultUnit( "mm" ); |
---|
108 | MaxStepCmd->SetUnitCategory("Length"); |
---|
109 | MaxStepCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
110 | |
---|
111 | UpdateCmd = new G4UIcmdWithoutParameter("/Jaws/update",this); |
---|
112 | UpdateCmd->SetGuidance("Update geometry."); |
---|
113 | UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); |
---|
114 | UpdateCmd->SetGuidance("if you changed geometrical value(s)."); |
---|
115 | UpdateCmd->AvailableForStates(G4State_Idle); |
---|
116 | |
---|
117 | |
---|
118 | } |
---|
119 | |
---|
120 | //**************************************************************************** |
---|
121 | MedLinacDetectorMessenger::~MedLinacDetectorMessenger() |
---|
122 | { |
---|
123 | delete JawX1PosCmd; |
---|
124 | delete JawX2PosCmd; |
---|
125 | delete JawY1PosCmd; |
---|
126 | delete JawY2PosCmd; |
---|
127 | delete PhantomDimCmd; |
---|
128 | delete NVoxelsCmd; |
---|
129 | delete MaxStepCmd; |
---|
130 | delete UpdateCmd; |
---|
131 | |
---|
132 | delete MedLinacDir; |
---|
133 | |
---|
134 | delete X1Dir; |
---|
135 | delete X2Dir; |
---|
136 | delete Y1Dir; |
---|
137 | delete Y2Dir; |
---|
138 | } |
---|
139 | |
---|
140 | //**************************************************************************** |
---|
141 | |
---|
142 | void MedLinacDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) |
---|
143 | { |
---|
144 | if( command == JawX1PosCmd ) |
---|
145 | { MedLinacDetector->SetJawX1Pos_x(JawX1PosCmd->GetNewDoubleValue(newValue));} |
---|
146 | |
---|
147 | if( command == JawX2PosCmd ) |
---|
148 | { MedLinacDetector->SetJawX2Pos_x(JawX2PosCmd->GetNewDoubleValue(newValue));} |
---|
149 | |
---|
150 | if( command == JawY1PosCmd ) |
---|
151 | { MedLinacDetector->SetJawY1Pos_y(JawY1PosCmd->GetNewDoubleValue(newValue));} |
---|
152 | |
---|
153 | if( command == JawY2PosCmd ) |
---|
154 | { MedLinacDetector->SetJawY2Pos_y(JawY2PosCmd->GetNewDoubleValue(newValue));} |
---|
155 | |
---|
156 | if( command == PhantomDimCmd ) |
---|
157 | { MedLinacDetector->SetPhantomDim(PhantomDimCmd->GetNewDoubleValue(newValue));} |
---|
158 | |
---|
159 | if( command == NVoxelsCmd ) |
---|
160 | { MedLinacDetector->SetNumberOfVoxels(NVoxelsCmd->GetNewIntValue(newValue)); } |
---|
161 | |
---|
162 | if( command == MaxStepCmd ) |
---|
163 | { MedLinacDetector->SetMaxStep(MaxStepCmd->GetNewDoubleValue(newValue));} |
---|
164 | |
---|
165 | if( command == UpdateCmd ) |
---|
166 | { MedLinacDetector->UpdateGeometry(); } |
---|
167 | |
---|
168 | } |
---|
169 | //**************************************************************************** |
---|