]>
Commit | Line | Data |
---|---|---|
1 | // $Id$ | |
2 | // Category: run | |
3 | // | |
4 | // Author: I. Hrivnacova | |
5 | // | |
6 | // Class TG4RunMessenger | |
7 | // --------------------- | |
8 | // See the class description in the header file. | |
9 | ||
10 | #include "TG4RunMessenger.h" | |
11 | #include "TG4RunManager.h" | |
12 | #include "TG4Globals.h" | |
13 | #include "TG4UICmdWithAComplexString.h" | |
14 | ||
15 | #include <G4UIdirectory.hh> | |
16 | #include <G4UIcmdWithoutParameter.hh> | |
17 | #include <G4UIcmdWithAString.hh> | |
18 | ||
19 | //_____________________________________________________________________________ | |
20 | TG4RunMessenger::TG4RunMessenger(TG4RunManager* runManager) | |
21 | : fRunManager(runManager) | |
22 | { | |
23 | // | |
24 | fDirectory = new G4UIdirectory("/tg4Control/"); | |
25 | fDirectory->SetGuidance("TGeant4 control commands."); | |
26 | ||
27 | fRootCmd = new G4UIcmdWithoutParameter("/tg4Control/root", this); | |
28 | fRootCmd->SetGuidance("Switch to Root interactive shell."); | |
29 | fRootCmd->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc); | |
30 | ||
31 | fRootMacroCmd = new G4UIcmdWithAString("/tg4Control/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); | |
35 | ||
36 | fRootCommandCmd = new TG4UICmdWithAComplexString("/tg4Control/rootCmd", this); | |
37 | fRootCommandCmd->SetGuidance("Process Root command"); | |
38 | fRootCommandCmd->SetParameterName("command", false); | |
39 | fRootCommandCmd->SetDefaultValue(" "); | |
40 | fRootCommandCmd->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc); | |
41 | ||
42 | fG3DefaultsCmd = new G4UIcmdWithoutParameter("/tg4Control/g3Defaults", this); | |
43 | fG3DefaultsCmd->SetGuidance("Set G3 default parameters (cut values,"); | |
44 | fG3DefaultsCmd->SetGuidance("tracking media max step values, ...)"); | |
45 | fG3DefaultsCmd->AvailableForStates(PreInit); | |
46 | } | |
47 | ||
48 | //_____________________________________________________________________________ | |
49 | TG4RunMessenger::TG4RunMessenger(){ | |
50 | // | |
51 | } | |
52 | ||
53 | //_____________________________________________________________________________ | |
54 | TG4RunMessenger::TG4RunMessenger(const TG4RunMessenger& right) { | |
55 | // | |
56 | TG4Globals::Exception("TG4RunMessenger is protected from copying."); | |
57 | } | |
58 | ||
59 | //_____________________________________________________________________________ | |
60 | TG4RunMessenger::~TG4RunMessenger() { | |
61 | // | |
62 | delete fDirectory; | |
63 | delete fRootCmd; | |
64 | delete fRootMacroCmd; | |
65 | delete fRootCommandCmd; | |
66 | delete fG3DefaultsCmd; | |
67 | } | |
68 | ||
69 | // operators | |
70 | ||
71 | //_____________________________________________________________________________ | |
72 | TG4RunMessenger& TG4RunMessenger::operator=(const TG4RunMessenger& right) | |
73 | { | |
74 | // check assignement to self | |
75 | if (this == &right) return *this; | |
76 | ||
77 | TG4Globals::Exception("TG4RunMessenger is protected from assigning."); | |
78 | ||
79 | return *this; | |
80 | } | |
81 | ||
82 | // public methods | |
83 | ||
84 | //_____________________________________________________________________________ | |
85 | void TG4RunMessenger::SetNewValue(G4UIcommand* command, G4String newValue) | |
86 | { | |
87 | // Applies command to the associated object. | |
88 | // --- | |
89 | ||
90 | if (command == fRootCmd) { | |
91 | fRunManager->StartRootUI(); | |
92 | } | |
93 | else if (command == fRootMacroCmd) { | |
94 | fRunManager->ProcessRootMacro(newValue); | |
95 | } | |
96 | else if (command == fRootCommandCmd) { | |
97 | fRunManager->ProcessRootCommand(newValue); | |
98 | } | |
99 | else if (command == fG3DefaultsCmd) { | |
100 | fRunManager->UseG3Defaults(); | |
101 | } | |
102 | } |