Warning, file /geant4/examples/advanced/hadrontherapy/src/HadrontherapyDetectorMessenger.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "HadrontherapyDetectorMessenger.hh"
0030 #include "HadrontherapyDetectorConstruction.hh"
0031 #include "G4UIdirectory.hh"
0032 #include "G4UIcmdWith3VectorAndUnit.hh"
0033 #include "G4UIcmdWithoutParameter.hh"
0034 #include "G4UIcmdWithAString.hh"
0035 #include "G4SystemOfUnits.hh"
0036 #include "G4UIcmdWithABool.hh"
0037
0038
0039 HadrontherapyDetectorMessenger::HadrontherapyDetectorMessenger(HadrontherapyDetectorConstruction* detector)
0040 :hadrontherapyDetector(detector)
0041 {
0042
0043 changeThePhantomDir = new G4UIdirectory("/changePhantom/");
0044 changeThePhantomDir -> SetGuidance("Command to change the Phantom Size/position");
0045 changeThePhantomSizeCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/size", this);
0046 changeThePhantomSizeCmd -> SetGuidance("Insert sizes X Y and Z"
0047 "\n 0 or negative values mean <<Don't change it!>>");
0048 changeThePhantomSizeCmd -> SetParameterName("PhantomSizeAlongX",
0049 "PhantomSizeAlongY",
0050 "PhantomSizeAlongZ", false);
0051 changeThePhantomSizeCmd -> SetDefaultUnit("mm");
0052 changeThePhantomSizeCmd -> SetUnitCandidates("nm um mm cm");
0053 changeThePhantomSizeCmd -> AvailableForStates(G4State_Idle);
0054
0055
0056
0057 changeThePhantomMaterialCmd = new G4UIcmdWithAString("/changePhantom/material", this);
0058 changeThePhantomMaterialCmd -> SetGuidance("Change the Phantom and the detector material");
0059 changeThePhantomMaterialCmd -> SetParameterName("PhantomMaterial", false);
0060 changeThePhantomMaterialCmd -> SetDefaultValue("G4_WATER");
0061 changeThePhantomMaterialCmd -> AvailableForStates(G4State_Idle);
0062
0063
0064 changeThePhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/position", this);
0065 changeThePhantomPositionCmd -> SetGuidance("Insert X Y and Z dimensions for the position of the center of the Phantom"
0066 " respect to that of the \"World\"");
0067 changeThePhantomPositionCmd -> SetParameterName("PositionAlongX",
0068 "PositionAlongY",
0069 "PositionAlongZ", false);
0070 changeThePhantomPositionCmd -> SetDefaultUnit("mm");
0071 changeThePhantomPositionCmd -> SetUnitCandidates("um mm cm m");
0072 changeThePhantomPositionCmd -> AvailableForStates(G4State_Idle);
0073
0074
0075 updateCmd = new G4UIcmdWithoutParameter("/changePhantom/update",this);
0076 updateCmd->SetGuidance("Update Phantom/Detector geometry.");
0077 updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
0078 updateCmd->SetGuidance("if you changed geometrical value(s).");
0079 updateCmd->AvailableForStates(G4State_Idle);
0080
0081
0082 changeTheDetectorDir = new G4UIdirectory("/changeDetector/");
0083 changeTheDetectorDir -> SetGuidance("Command to change the Detector's Size/position/Voxels");
0084
0085 changeTheDetectorSizeCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/size",this);
0086 changeTheDetectorSizeCmd -> SetGuidance("Insert sizes for X Y and Z dimensions of the Detector"
0087 "\n 0 or negative values mean <<Don't change it>>");
0088 changeTheDetectorSizeCmd -> SetParameterName("DetectorSizeAlongX", "DetectorSizeAlongY", "DetectorSizeAlongZ", false);
0089 changeTheDetectorSizeCmd -> SetDefaultUnit("mm");
0090 changeTheDetectorSizeCmd -> SetUnitCandidates("nm um mm cm");
0091 changeTheDetectorSizeCmd -> AvailableForStates(G4State_Idle);
0092
0093
0094 changeTheDetectorToPhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/displacement",this);
0095 changeTheDetectorToPhantomPositionCmd -> SetGuidance("Insert X Y and Z displacements between Detector and Phantom"
0096 "\nNegative values mean <<Don't change it!>>");
0097 changeTheDetectorToPhantomPositionCmd -> SetParameterName("DisplacementAlongX",
0098 "DisplacementAlongY",
0099 "DisplacementAlongZ", false);
0100 changeTheDetectorToPhantomPositionCmd -> SetDefaultUnit("mm");
0101 changeTheDetectorToPhantomPositionCmd -> SetUnitCandidates("nm um mm cm");
0102 changeTheDetectorToPhantomPositionCmd -> AvailableForStates(G4State_Idle);
0103
0104
0105 changeTheDetectorVoxelCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/voxelSize",this);
0106 changeTheDetectorVoxelCmd -> SetGuidance("Insert Voxel sizes for X Y and Z dimensions"
0107 "\n 0 or negative values mean <<Don't change it!>>");
0108 changeTheDetectorVoxelCmd -> SetParameterName("VoxelSizeAlongX", "VoxelSizeAlongY", "VoxelSizeAlongZ", false);
0109 changeTheDetectorVoxelCmd -> SetDefaultUnit("mm");
0110 changeTheDetectorVoxelCmd -> SetUnitCandidates("nm um mm cm");
0111 changeTheDetectorVoxelCmd -> AvailableForStates(G4State_Idle);
0112
0113
0114 changeTheSource = new G4UIdirectory("/changeTheSource/");
0115 changeTheSource -> SetGuidance("Command to change the source");
0116
0117
0118
0119
0120
0121
0122 VirtualLayer = new G4UIcmdWithABool("/changeTheSource/VirtualLayer",this);
0123 VirtualLayer -> SetParameterName("VirtualLayer ", false);
0124 VirtualLayer -> SetDefaultValue("false");
0125 VirtualLayer -> SetGuidance("Set if you want place a VirtualLayer"
0126 "\n[usage]: /changeTheSource/VirtualLayer [true/false]");
0127 VirtualLayer -> AvailableForStates(G4State_Idle, G4State_PreInit);
0128
0129
0130 VirtualLayerPosition = new G4UIcmdWith3VectorAndUnit("/changeTheSource/VirtualLayerPosition", this);
0131 VirtualLayerPosition -> SetGuidance("Insert X Y and Z dimensions for the position of the center of the Virtual Layer"
0132 " respect to that of the \"World\"");
0133 VirtualLayerPosition -> SetParameterName("PositionAlongX",
0134 "PositionAlongY",
0135 "PositionAlongZ", false);
0136
0137 VirtualLayerPosition -> SetDefaultUnit("cm");
0138 VirtualLayerPosition -> SetUnitCandidates("um mm cm m");
0139 VirtualLayerPosition -> AvailableForStates(G4State_Idle);
0140
0141
0142
0143 }
0144
0145
0146 HadrontherapyDetectorMessenger::~HadrontherapyDetectorMessenger()
0147 {
0148 delete changeThePhantomDir;
0149 delete changeThePhantomSizeCmd;
0150 delete changeThePhantomPositionCmd;
0151 delete changeThePhantomMaterialCmd;
0152 delete updateCmd;
0153 delete changeTheDetectorDir;
0154 delete changeTheDetectorSizeCmd;
0155 delete changeTheDetectorToPhantomPositionCmd;
0156 delete changeTheDetectorVoxelCmd;
0157 delete VirtualLayer;
0158 delete VirtualLayerPosition;
0159 }
0160
0161
0162 void HadrontherapyDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
0163 {
0164
0165 if( command == changeThePhantomSizeCmd)
0166 {
0167 G4ThreeVector size = changeThePhantomSizeCmd -> GetNew3VectorValue(newValue);
0168 hadrontherapyDetector -> SetPhantomSize(size.getX(),size.getY(),size.getZ());
0169 }
0170 else if (command == changeThePhantomPositionCmd )
0171 {
0172
0173 G4ThreeVector size = changeThePhantomPositionCmd -> GetNew3VectorValue(newValue);
0174 hadrontherapyDetector -> SetPhantomPosition(size);
0175 }
0176 else if (command == changeThePhantomMaterialCmd)
0177 {
0178 hadrontherapyDetector -> SetPhantomMaterial(newValue);
0179 }
0180 else if (command == changeTheDetectorSizeCmd)
0181 {
0182 G4ThreeVector size = changeTheDetectorSizeCmd -> GetNew3VectorValue(newValue);
0183 hadrontherapyDetector -> SetDetectorSize(size.getX(),size.getY(),size.getZ());
0184 }
0185 else if (command == changeTheDetectorToPhantomPositionCmd)
0186 {
0187 G4ThreeVector size = changeTheDetectorToPhantomPositionCmd-> GetNew3VectorValue(newValue);
0188 hadrontherapyDetector -> SetDetectorToPhantomPosition(size);
0189
0190 }
0191 else if (command == changeTheDetectorVoxelCmd)
0192 {
0193 G4ThreeVector size = changeTheDetectorVoxelCmd -> GetNew3VectorValue(newValue);
0194 hadrontherapyDetector -> SetVoxelSize(size.getX(),size.getY(),size.getZ());
0195 }
0196 else if (command == updateCmd)
0197 {
0198 hadrontherapyDetector -> UpdateGeometry();
0199 }
0200
0201 else if(command == VirtualLayer)
0202 {
0203 hadrontherapyDetector->VirtualLayer(VirtualLayer->GetNewBoolValue(newValue));
0204 }
0205 else if(command == VirtualLayerPosition)
0206 {
0207 G4ThreeVector size = VirtualLayerPosition-> GetNew3VectorValue(newValue);
0208
0209 hadrontherapyDetector -> SetVirtualLayerPosition(size);
0210 }
0211
0212 }