4 // See the class description in the header file.
6 #include "TG4RunMessenger.h"
7 #include "TG4RunManager.h"
8 #include "TG4Globals.h"
9 #include "TG4UICmdWithAComplexString.h"
11 #include <G4UIdirectory.hh>
12 #include <G4UIcmdWithoutParameter.hh>
13 #include <G4UIcmdWithAString.hh>
15 TG4RunMessenger::TG4RunMessenger(TG4RunManager* runManager)
16 : fRunManager(runManager)
19 fDirectory = new G4UIdirectory("/g4mc/");
20 fDirectory->SetGuidance("TGeant4 control commands.");
22 fRootCmd = new G4UIcmdWithoutParameter("/g4mc/root", this);
23 fRootCmd->SetGuidance("Switch to Root interactive shell.");
24 fRootCmd->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
26 fRootMacroCmd = new G4UIcmdWithAString("/g4mc/rootMacro", this);
27 fRootMacroCmd->SetGuidance("Process Root macro with given name (from file name.C)");
28 fRootMacroCmd->SetParameterName("macroName", true);
29 fRootMacroCmd->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
31 fRootCommandCmd = new TG4UICmdWithAComplexString("/g4mc/rootCmd", this);
32 fRootCommandCmd->SetGuidance("Process Root command");
33 fRootCommandCmd->SetParameterName("command", false);
34 fRootCommandCmd->SetDefaultValue(" ");
35 fRootCommandCmd->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
37 fG3DefaultsCmd = new G4UIcmdWithoutParameter("/g4mc/g3Defaults", this);
38 fG3DefaultsCmd->SetGuidance("Set G3 default parameters (cut values,");
39 fG3DefaultsCmd->SetGuidance("tracking media max step values, ...)");
40 fG3DefaultsCmd->AvailableForStates(PreInit);
43 TG4RunMessenger::TG4RunMessenger(){
47 TG4RunMessenger::TG4RunMessenger(const TG4RunMessenger& right) {
49 TG4Globals::Exception("TG4RunMessenger is protected from copying.");
52 TG4RunMessenger::~TG4RunMessenger() {
57 delete fRootCommandCmd;
58 delete fG3DefaultsCmd;
63 TG4RunMessenger& TG4RunMessenger::operator=(const TG4RunMessenger& right)
65 // check assignement to self
66 if (this == &right) return *this;
68 TG4Globals::Exception("TG4RunMessenger is protected from assigning.");
75 void TG4RunMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
77 // Applies command to the associated object.
80 if (command == fRootCmd) {
81 fRunManager->StartRootUI();
83 else if (command == fRootMacroCmd) {
84 fRunManager->ProcessRootMacro(newValue);
86 else if (command == fRootCommandCmd) {
87 fRunManager->ProcessRootCommand(newValue);
89 else if (command == fG3DefaultsCmd) {
90 fRunManager->UseG3Defaults();