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