File indexing completed on 2025-02-23 09:20:21
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
0030
0031
0032
0033 #include "DetectorMessenger.hh"
0034
0035 DetectorMessenger::~DetectorMessenger()
0036 {
0037
0038 delete fieldSide;
0039 delete sourceToSkinDistance;
0040 delete phantomSide;
0041 delete voxelSide;
0042 delete voxelDepth;
0043 }
0044
0045 DetectorMessenger::DetectorMessenger(DetectorConstruction* myDetector)
0046 : detPointer(myDetector)
0047 {
0048 fieldSide = new G4UIcmdWithADoubleAndUnit("/DetectorConstruction/Acc/fieldSide", this);
0049 fieldSide -> SetDefaultUnit("mm");
0050 fieldSide -> SetDefaultValue(100.);
0051 fieldSide -> SetGuidance("Set the field side");
0052 detPointer -> SetJaws(100.*mm);
0053
0054 sourceToSkinDistance = new G4UIcmdWithADoubleAndUnit("/DetectorConstruction/Acc/sourceToSkinDistance", this);
0055 sourceToSkinDistance -> SetDefaultUnit("mm");
0056 sourceToSkinDistance -> SetDefaultValue(900.);
0057 sourceToSkinDistance -> SetGuidance("Set the distance between the source and the patient's skin");
0058 detPointer -> SetTargetPosition(900.*mm);
0059
0060 phantomSide = new G4UIcmdWithADoubleAndUnit("/DetectorConstruction/Phantom/phantomSide", this);
0061 phantomSide -> SetDefaultUnit("mm");
0062 phantomSide -> SetDefaultValue(255.*mm);
0063 phantomSide -> SetGuidance("Set the side of the phantom");
0064 detPointer -> SetPhantomSide(255.*mm);
0065
0066 voxelSide = new G4UIcmdWithADoubleAndUnit("/DetectorConstruction/Phantom/voxelSide", this);
0067 voxelSide -> SetDefaultUnit("mm");
0068 voxelSide -> SetDefaultValue(5.*mm);
0069 voxelSide -> SetGuidance("Set the phantom voxel lateral dimension");
0070 detPointer -> SetVoxelSide(5.*mm);
0071
0072 voxelDepth = new G4UIcmdWithADoubleAndUnit("/DetectorConstruction/Phantom/voxelDepth", this);
0073 voxelDepth -> SetDefaultUnit("mm");
0074 voxelDepth -> SetDefaultValue(5.*mm);
0075 voxelDepth -> SetGuidance("Set the phantom voxel depth");
0076 detPointer -> SetVoxelDepth(5.*mm);
0077 }
0078
0079 void DetectorMessenger::SetNewValue(G4UIcommand* cmd, G4String newValue)
0080 {
0081 if (cmd == fieldSide)
0082 {
0083 fieldSide -> GetNewUnitValue(newValue);
0084 detPointer -> SetJaws(fieldSide -> GetNewDoubleValue(newValue));
0085 detPointer -> UpdateGeometry("fieldSide", fieldSide -> GetNewDoubleRawValue(newValue));
0086 }
0087 else if (cmd == sourceToSkinDistance)
0088 {
0089 sourceToSkinDistance -> GetNewUnitValue(newValue);
0090 detPointer -> SetTargetPosition(sourceToSkinDistance -> GetNewDoubleValue(newValue));
0091 detPointer -> UpdateGeometry("sourceToSkinDistance", sourceToSkinDistance -> GetNewDoubleRawValue(newValue));
0092 }
0093 else if (cmd == voxelDepth)
0094 {
0095 voxelDepth -> GetNewUnitValue(newValue);
0096 detPointer -> SetVoxelDepth(voxelDepth ->GetNewDoubleValue(newValue));
0097 detPointer -> UpdateGeometry("voxelDepth", voxelDepth -> GetNewDoubleRawValue(newValue));
0098 }
0099 else if (cmd == voxelSide)
0100 {
0101 voxelSide -> GetNewUnitValue(newValue);
0102 detPointer -> SetVoxelSide(voxelSide ->GetNewDoubleValue(newValue));
0103 detPointer -> UpdateGeometry("voxelSide", voxelSide -> GetNewDoubleRawValue(newValue));
0104
0105 }
0106 else if (cmd == phantomSide)
0107 {
0108 phantomSide -> GetNewUnitValue(newValue);
0109 detPointer -> SetPhantomSide(phantomSide ->GetNewDoubleValue(newValue));
0110 detPointer -> UpdateGeometry("phantomSide", phantomSide -> GetNewDoubleRawValue(newValue));
0111 }
0112 else
0113 G4cerr << "DetectorMessenger::SetNewValue: command not found" << G4endl;
0114 }
0115
0116
0117
0118