4 // Author: I. Hrivnacova
6 // Class TG4RunMessenger
7 // ---------------------
8 // See the class description in the header file.
10 #include "TG4RunMessenger.h"
11 #include "TG4RunManager.h"
12 #include "TG4Globals.h"
13 #include "TG4UICmdWithAComplexString.h"
15 #include <G4UIdirectory.hh>
16 #include <G4UIcmdWithoutParameter.hh>
17 #include <G4UIcmdWithAString.hh>
19 //_____________________________________________________________________________
20 TG4RunMessenger::TG4RunMessenger(TG4RunManager* runManager)
21 : fRunManager(runManager)
24 fDirectory = new G4UIdirectory("/g4mc/");
25 fDirectory->SetGuidance("TGeant4 control commands.");
27 fRootCmd = new G4UIcmdWithoutParameter("/g4mc/root", this);
28 fRootCmd->SetGuidance("Switch to Root interactive shell.");
29 fRootCmd->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
31 fRootMacroCmd = new G4UIcmdWithAString("/g4mc/rootMacro", this);
32 fRootMacroCmd->SetGuidance("Process Root macro with given name (from file name.C)");
33 fRootMacroCmd->SetParameterName("macroName", true);
34 fRootMacroCmd->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
36 fRootCommandCmd = new TG4UICmdWithAComplexString("/g4mc/rootCmd", this);
37 fRootCommandCmd->SetGuidance("Process Root command");
38 fRootCommandCmd->SetParameterName("command", false);
39 fRootCommandCmd->SetDefaultValue(" ");
40 fRootCommandCmd->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
42 fG3DefaultsCmd = new G4UIcmdWithoutParameter("/g4mc/g3Defaults", this);
43 fG3DefaultsCmd->SetGuidance("Set G3 default parameters (cut values,");
44 fG3DefaultsCmd->SetGuidance("tracking media max step values, ...)");
45 fG3DefaultsCmd->AvailableForStates(PreInit);
48 //_____________________________________________________________________________
49 TG4RunMessenger::TG4RunMessenger(){
53 //_____________________________________________________________________________
54 TG4RunMessenger::TG4RunMessenger(const TG4RunMessenger& right) {
56 TG4Globals::Exception("TG4RunMessenger is protected from copying.");
59 //_____________________________________________________________________________
60 TG4RunMessenger::~TG4RunMessenger() {
65 delete fRootCommandCmd;
66 delete fG3DefaultsCmd;
71 //_____________________________________________________________________________
72 TG4RunMessenger& TG4RunMessenger::operator=(const TG4RunMessenger& right)
74 // check assignement to self
75 if (this == &right) return *this;
77 TG4Globals::Exception("TG4RunMessenger is protected from assigning.");
84 //_____________________________________________________________________________
85 void TG4RunMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
87 // Applies command to the associated object.
90 if (command == fRootCmd) {
91 fRunManager->StartRootUI();
93 else if (command == fRootMacroCmd) {
94 fRunManager->ProcessRootMacro(newValue);
96 else if (command == fRootCommandCmd) {
97 fRunManager->ProcessRootCommand(newValue);
99 else if (command == fG3DefaultsCmd) {
100 fRunManager->UseG3Defaults();