File indexing completed on 2026-09-15 08:29:29
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 "DoseMessenger.hh"
0030
0031 #include "Dose.hh"
0032 #include <G4UIcmdWithABool.hh>
0033 #include <G4UIcmdWithADouble.hh>
0034 #include <G4UIcmdWithAString.hh>
0035 #include <G4UIcmdWithAnInteger.hh>
0036 #include <G4UIcmdWithoutParameter.hh>
0037 #include <G4UIdirectory.hh>
0038
0039 namespace RadioBio
0040 {
0041
0042
0043
0044 DoseMessenger::DoseMessenger(Dose* dose) : G4UImessenger(), fDose(dose)
0045 {
0046
0047 fDoseDir = new G4UIdirectory("/dose/");
0048 fDoseDir->SetGuidance("commands to setup dose calculation");
0049
0050
0051 fCalculationCmd = new G4UIcmdWithABool("/dose/calculate", this);
0052 fCalculationCmd->SetGuidance("Whether to enable dose calculation");
0053 fCalculationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0054 fCalculationCmd->SetToBeBroadcasted(false);
0055
0056
0057 fVerbosityCmd = new G4UIcmdWithAnInteger("/dose/verbose", this);
0058 fVerbosityCmd->SetGuidance("Set verbosity level of dose");
0059 fVerbosityCmd->SetGuidance("0 = quiet");
0060 fVerbosityCmd->SetGuidance("1 = important messages (~10 per run)");
0061 fVerbosityCmd->SetGuidance("2 = debug");
0062 fVerbosityCmd->SetToBeBroadcasted(false);
0063
0064
0065 fResetCmd = new G4UIcmdWithoutParameter("/dose/reset", this);
0066 fResetCmd->SetGuidance("Reset accumulated data");
0067 fResetCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0068 fResetCmd->SetToBeBroadcasted(false);
0069
0070
0071 fDosePathCmd = new G4UIcmdWithAString("/dose/fileName", this);
0072 fDosePathCmd->SetGuidance("Set the filename for the dose file");
0073 fDosePathCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0074 fDosePathCmd->SetToBeBroadcasted(false);
0075
0076
0077 fPrintCmd = new G4UIcmdWithoutParameter("/dose/print", this);
0078 fPrintCmd->SetGuidance("Print dose parameters");
0079 fPrintCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0080 fPrintCmd->SetToBeBroadcasted(false);
0081 }
0082
0083
0084
0085 DoseMessenger::~DoseMessenger()
0086 {
0087 delete fDoseDir;
0088 delete fCalculationCmd;
0089 delete fVerbosityCmd;
0090 delete fResetCmd;
0091 delete fDosePathCmd;
0092 delete fPrintCmd;
0093 }
0094
0095
0096
0097 void DoseMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0098 {
0099 if (command == fCalculationCmd) {
0100 fDose->SetCalculationEnabled(fCalculationCmd->GetNewBoolValue(newValue));
0101 }
0102
0103 if (command == fVerbosityCmd) {
0104 fDose->SetVerboseLevel(fVerbosityCmd->GetNewIntValue(newValue));
0105 }
0106
0107 if (command == fResetCmd) {
0108 fDose->Reset();
0109 }
0110
0111 if (command == fDosePathCmd) {
0112 fDose->SetPath(newValue);
0113 }
0114
0115 if (command == fPrintCmd) {
0116 fDose->PrintParameters();
0117 }
0118 }
0119
0120
0121
0122 }