File indexing completed on 2025-01-18 09:17:05
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 #include "RunActionMessenger.hh"
0032
0033 #include "G4Tokenizer.hh"
0034 #include "G4UIcmdWithABool.hh"
0035 #include "G4UIcmdWithAnInteger.hh"
0036 #include "G4UIdirectory.hh"
0037
0038 #include "RunAction.hh"
0039
0040
0041
0042 RunActionMessenger::RunActionMessenger(RunAction* runAction)
0043 : G4UImessenger(), fRunAction(runAction), fRunDir(nullptr), fScanParamsCmd(nullptr)
0044 {
0045 fRunDir = new G4UIdirectory("/tomography/run/");
0046 fRunDir->SetGuidance("run control");
0047
0048 fScanParamsCmd = new G4UIcommand("/tomography/run/scanParameters", this);
0049 fScanParamsCmd->SetGuidance("Set scan parameters: number of projections, slices and pixels");
0050
0051 auto nbProjections = new G4UIparameter("NbProjections", 'i', false);
0052 nbProjections->SetGuidance("number of scan projections");
0053 nbProjections->SetParameterRange("NbProjections>=1");
0054 fScanParamsCmd->SetParameter(nbProjections);
0055
0056 auto nbSlices = new G4UIparameter("NbSlices", 'i', false);
0057 nbSlices->SetGuidance("number of scan slices");
0058 nbSlices->SetParameterRange("NbSlices>=1");
0059 fScanParamsCmd->SetParameter(nbSlices);
0060
0061 auto nbPixels = new G4UIparameter("NbPixels", 'i', false);
0062 nbPixels->SetGuidance("number of scan pixels");
0063 nbPixels->SetParameterRange("NbPixels>=1");
0064 fScanParamsCmd->SetParameter(nbPixels);
0065 fScanParamsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0066
0067 resumeCmd = new G4UIcmdWithABool("/tomography/run/resumeSimulation", this);
0068 resumeCmd->SetGuidance("Resume the simulation after an interruption");
0069 resumeCmd->SetParameterName("interruptionFlag", true);
0070 resumeCmd->SetDefaultValue(false);
0071 resumeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0072
0073 resumeProjectionIndexCmd =
0074 new G4UIcmdWithAnInteger("/tomography/run/resumeProjectionIndex", this);
0075 resumeProjectionIndexCmd->SetGuidance("Set the index of projection to resume the simulation");
0076 resumeProjectionIndexCmd->SetParameterName("ProjectionIndex", true);
0077 resumeProjectionIndexCmd->SetDefaultValue(0);
0078 resumeProjectionIndexCmd->SetRange("ProjectionIndex >=0");
0079 resumeProjectionIndexCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0080 }
0081
0082
0083
0084 RunActionMessenger::~RunActionMessenger()
0085 {
0086 delete fRunDir;
0087 delete fScanParamsCmd;
0088 delete resumeCmd;
0089 delete resumeProjectionIndexCmd;
0090 }
0091
0092
0093
0094 void RunActionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0095 {
0096 if (command == fScanParamsCmd) {
0097 G4Tokenizer next(newValue);
0098 G4int nbProjections = StoI(next());
0099 G4int nbSlices = StoI(next());
0100 G4int nbPixels = StoI(next());
0101 fRunAction->SetScanParameters(nbProjections, nbSlices, nbPixels);
0102 }
0103 else if (command == resumeCmd) {
0104 fRunAction->SetInterruptionFlag(resumeCmd->GetNewBoolValue(newValue));
0105 }
0106 else if (command == resumeProjectionIndexCmd) {
0107 fRunAction->SetResumeProjectionIndex(resumeProjectionIndexCmd->GetNewIntValue(newValue));
0108 }
0109 }
0110
0111