File indexing completed on 2026-09-20 08:30:54
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 "VoxelizedSensitiveDetectorMessenger.hh"
0030
0031 #include "G4UIcmdWith3VectorAndUnit.hh"
0032 #include "G4UIcmdWithADoubleAndUnit.hh"
0033 #include "G4UIcmdWithoutParameter.hh"
0034 #include "G4UIcommand.hh"
0035 #include "G4UIdirectory.hh"
0036 #include "G4UIparameter.hh"
0037
0038 #include "VoxelizedSensitiveDetector.hh"
0039
0040 namespace RadioBio
0041 {
0042
0043
0044
0045 VoxelizedSensitiveDetectorMessenger::VoxelizedSensitiveDetectorMessenger(
0046 VoxelizedSensitiveDetector* VoxDet)
0047 : G4UImessenger(), fVoxelizedDetector(VoxDet)
0048 {
0049
0050 fVoxelsDir = new G4UIdirectory("/voxels/");
0051 fVoxelsDir->SetGuidance("commands to change voxels size");
0052
0053
0054 fVoxelSizeCmd = new G4UIcmdWith3VectorAndUnit("/voxels/setVoxelSizes", this);
0055 fVoxelSizeCmd->SetGuidance("Insert voxel sizes X Y and Z");
0056 fVoxelSizeCmd->SetParameterName("SizeAlongX", "SizeAlongY", "SizeAlongZ", false);
0057 fVoxelSizeCmd->SetRange("SizeAlongX>0. && SizeAlongY>0. && SizeAlongZ>0.");
0058 fVoxelSizeCmd->SetUnitCategory("Length");
0059 fVoxelSizeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0060 fVoxelSizeCmd->SetToBeBroadcasted(false);
0061
0062
0063 fVoxelSizeXCmd = new G4UIcmdWithADoubleAndUnit("/voxels/setSizeX", this);
0064 fVoxelSizeXCmd->SetGuidance("Set X width of voxels");
0065 fVoxelSizeXCmd->SetParameterName("Size", false);
0066 fVoxelSizeXCmd->SetRange("Size>0.");
0067 fVoxelSizeXCmd->SetUnitCategory("Length");
0068 fVoxelSizeXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0069 fVoxelSizeXCmd->SetToBeBroadcasted(false);
0070
0071
0072 fVoxelSizeYCmd = new G4UIcmdWithADoubleAndUnit("/voxels/setSizeY", this);
0073 fVoxelSizeYCmd->SetGuidance("Set Y width of voxels");
0074 fVoxelSizeYCmd->SetParameterName("Size", false);
0075 fVoxelSizeYCmd->SetRange("Size>0.");
0076 fVoxelSizeYCmd->SetUnitCategory("Length");
0077 fVoxelSizeYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0078 fVoxelSizeYCmd->SetToBeBroadcasted(false);
0079
0080
0081 fVoxelSizeZCmd = new G4UIcmdWithADoubleAndUnit("/voxels/setSizeZ", this);
0082 fVoxelSizeZCmd->SetGuidance("Set Z width of voxels");
0083 fVoxelSizeZCmd->SetParameterName("Size", false);
0084 fVoxelSizeZCmd->SetRange("Size>0.");
0085 fVoxelSizeZCmd->SetUnitCategory("Length");
0086 fVoxelSizeZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0087 fVoxelSizeZCmd->SetToBeBroadcasted(false);
0088
0089
0090 fUpdateVoxCmd = new G4UIcmdWithoutParameter("/voxels/update", this);
0091 fUpdateVoxCmd->SetGuidance("Update voxelized geometry");
0092 fUpdateVoxCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
0093 fUpdateVoxCmd->SetGuidance("if you changed voxelization");
0094 fUpdateVoxCmd->AvailableForStates(G4State_Idle);
0095 }
0096
0097
0098
0099 VoxelizedSensitiveDetectorMessenger::~VoxelizedSensitiveDetectorMessenger()
0100 {
0101 delete fVoxelsDir;
0102 delete fVoxelSizeCmd;
0103 delete fVoxelSizeXCmd;
0104 delete fVoxelSizeYCmd;
0105 delete fVoxelSizeZCmd;
0106 delete fUpdateVoxCmd;
0107 }
0108
0109
0110
0111 void VoxelizedSensitiveDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0112 {
0113 if (command == fVoxelSizeCmd) {
0114 fVoxelizedDetector->SetVoxelWidth(fVoxelSizeCmd->GetNew3VectorValue(newValue));
0115 }
0116
0117 if (command == fVoxelSizeXCmd) {
0118 fVoxelizedDetector->SetVoxelWidthX(fVoxelSizeXCmd->GetNewDoubleValue(newValue));
0119 }
0120
0121 if (command == fVoxelSizeYCmd) {
0122 fVoxelizedDetector->SetVoxelWidthY(fVoxelSizeYCmd->GetNewDoubleValue(newValue));
0123 }
0124
0125 if (command == fVoxelSizeZCmd) {
0126 fVoxelizedDetector->SetVoxelWidthZ(fVoxelSizeZCmd->GetNewDoubleValue(newValue));
0127 }
0128
0129 if (command == fUpdateVoxCmd) {
0130 fVoxelizedDetector->UpdateVoxelizedGeometry();
0131 }
0132 }
0133
0134
0135
0136 }