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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 //
 28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 30 
 31 #include "DetectorMessenger.hh"
 32 
 33 #include "G4UIcmdWithADoubleAndUnit.hh"
 34 #include "G4UIcmdWithAString.hh"
 35 #include "G4UIcmdWithAnInteger.hh"
 36 #include "G4UIdirectory.hh"
 37 
 38 #include "DetectorConstruction.hh"
 39 
 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 41 
 42 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det)
 43   : G4UImessenger(),
 44     fDetector(Det),
 45     fTomoDir(nullptr),
 46     fDetDir(nullptr),
 47     fAbsMaterCmd(nullptr),
 48     fAbsThickCmd(nullptr),
 49     fAbsSizYZCmd(nullptr),
 50     fAbsXposCmd(nullptr),
 51     fWorldMaterCmd(nullptr),
 52     fWorldXCmd(nullptr),
 53     fWorldYZCmd(nullptr),
 54     fPhantomType(nullptr)
 55 {
 56   fTomoDir = new G4UIdirectory("/tomography/");
 57   fTomoDir->SetGuidance("UI commands specific to this example.");
 58 
 59   fDetDir = new G4UIdirectory("/tomography/det/");
 60   fDetDir->SetGuidance("detector construction commands");
 61 
 62   fAbsMaterCmd = new G4UIcmdWithAString("/tomography/det/setAbsMat", this);
 63   fAbsMaterCmd->SetGuidance("Select Material of the Absorber.");
 64   fAbsMaterCmd->SetParameterName("choice", false);
 65   fAbsMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
 66   fAbsMaterCmd->SetToBeBroadcasted(false);
 67 
 68   fWorldMaterCmd = new G4UIcmdWithAString("/tomography/det/setWorldMat", this);
 69   fWorldMaterCmd->SetGuidance("Select Material of the World.");
 70   fWorldMaterCmd->SetParameterName("wchoice", false);
 71   fWorldMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
 72   fWorldMaterCmd->SetToBeBroadcasted(false);
 73 
 74   fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setAbsThick", this);
 75   fAbsThickCmd->SetGuidance("Set Thickness of the Absorber");
 76   fAbsThickCmd->SetParameterName("SizeZ", false);
 77   fAbsThickCmd->SetRange("SizeZ>0.");
 78   fAbsThickCmd->SetUnitCategory("Length");
 79   fAbsThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
 80   fAbsThickCmd->SetToBeBroadcasted(false);
 81 
 82   fAbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setAbsYZ", this);
 83   fAbsSizYZCmd->SetGuidance("Set sizeYZ of the Absorber");
 84   fAbsSizYZCmd->SetParameterName("SizeYZ", false);
 85   fAbsSizYZCmd->SetRange("SizeYZ>0.");
 86   fAbsSizYZCmd->SetUnitCategory("Length");
 87   fAbsSizYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
 88   fAbsSizYZCmd->SetToBeBroadcasted(false);
 89 
 90   fAbsXposCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setAbsXpos", this);
 91   fAbsXposCmd->SetGuidance("Set X pos. of the Absorber");
 92   fAbsXposCmd->SetParameterName("Xpos", false);
 93   fAbsXposCmd->SetUnitCategory("Length");
 94   fAbsXposCmd->AvailableForStates(G4State_PreInit);
 95   fAbsXposCmd->SetToBeBroadcasted(false);
 96 
 97   fWorldXCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setWorldX", this);
 98   fWorldXCmd->SetGuidance("Set X size of the World");
 99   fWorldXCmd->SetParameterName("WSizeX", false);
100   fWorldXCmd->SetRange("WSizeX>0.");
101   fWorldXCmd->SetUnitCategory("Length");
102   fWorldXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
103   fWorldXCmd->SetToBeBroadcasted(false);
104 
105   fWorldYZCmd = new G4UIcmdWithADoubleAndUnit("/tomography/det/setWorldYZ", this);
106   fWorldYZCmd->SetGuidance("Set sizeYZ of the World");
107   fWorldYZCmd->SetParameterName("WSizeYZ", false);
108   fWorldYZCmd->SetRange("WSizeYZ>0.");
109   fWorldYZCmd->SetUnitCategory("Length");
110   fWorldYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
111   fWorldYZCmd->SetToBeBroadcasted(false);
112 
113   fPhantomType = new G4UIcmdWithAnInteger("/tomography/det/setPhantomType", this);
114   fPhantomType->SetGuidance("Select the type of target object.");
115   fPhantomType->SetParameterName("choice", false);
116   fPhantomType->AvailableForStates(G4State_PreInit, G4State_Idle);
117   fPhantomType->SetToBeBroadcasted(false);
118 }
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 
122 DetectorMessenger::~DetectorMessenger()
123 {
124   delete fAbsMaterCmd;
125   delete fAbsThickCmd;
126   delete fAbsSizYZCmd;
127   delete fAbsXposCmd;
128   delete fWorldMaterCmd;
129   delete fWorldXCmd;
130   delete fWorldYZCmd;
131   delete fDetDir;
132   delete fTomoDir;
133   delete fPhantomType;
134 }
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
137 
138 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
139 {
140   if (command == fAbsMaterCmd) {
141     fDetector->SetAbsorberMaterial(newValue);
142   }
143 
144   if (command == fWorldMaterCmd) {
145     fDetector->SetWorldMaterial(newValue);
146   }
147 
148   if (command == fAbsThickCmd) {
149     fDetector->SetAbsorberThickness(fAbsThickCmd->GetNewDoubleValue(newValue));
150   }
151 
152   if (command == fAbsSizYZCmd) {
153     fDetector->SetAbsorberSizeYZ(fAbsSizYZCmd->GetNewDoubleValue(newValue));
154   }
155 
156   if (command == fAbsXposCmd) {
157     fDetector->SetAbsorberXpos(fAbsXposCmd->GetNewDoubleValue(newValue));
158   }
159 
160   if (command == fWorldXCmd) {
161     fDetector->SetWorldSizeX(fWorldXCmd->GetNewDoubleValue(newValue));
162   }
163 
164   if (command == fWorldYZCmd) {
165     fDetector->SetWorldSizeYZ(fWorldYZCmd->GetNewDoubleValue(newValue));
166   }
167 
168   if (command == fPhantomType) {
169     fDetector->SetPhantomType(fPhantomType->GetNewIntValue(newValue));
170   }
171 }
172 
173 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
174