Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UImanager.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id$
28//
29
30#ifndef G4UImanager_h
31#define G4UImanager_h 1
32
33#include "globals.hh"
34
35#include <vector>
36#include <fstream>
37#include "G4VStateDependent.hh"
38#include "G4UIcommandStatus.hh"
39class G4UIcommandTree;
40class G4UIcommand;
41class G4UIsession;
44class G4UIaliasList;
45
46// class description:
47//
48// This is a singlton class which controls the command manipulation
49// and the user interface(s). The constructor of this class MUST NOT
50// invoked by the user.
51//
52
54{
55 public: // with description
56 static G4UImanager * GetUIpointer();
57 // A static method to get the pointer to the only existing object
58 // of this class.
59
60 protected:
62 public:
64 private:
65 G4UImanager(const G4UImanager &right);
66 const G4UImanager & operator=(const G4UImanager &right);
67 G4int operator==(const G4UImanager &right) const;
68 G4int operator!=(const G4UImanager &right) const;
69
70 public: // with description
71 G4String GetCurrentValues(const char * aCommand);
72 // This method returns a string which represents the current value(s)
73 // of the parameter(s) of the specified command. Null string will be
74 // returned if the given command is not defined or the command does
75 // not support the GetCurrentValues() method.
76 void AddNewCommand(G4UIcommand * newCommand);
77 // This method register a new command.
78 void RemoveCommand(G4UIcommand * aCommand);
79 // This command remove the registered command. After invokation of this
80 // command, that particular command cannot be applied.
81 void ExecuteMacroFile(const char * fileName);
82 // A macro file defined by the argument will be read by G4UIbatch object.
83 void Loop(const char * macroFile,const char * variableName,
84 G4double initialValue,G4double finalValue,G4double stepSize=1.0);
85 // Execute a macro file more than once with a loop counter.
86 void Foreach(const char * macroFile,const char * variableName,
87 const char * candidates);
88 // Execute a macro file more than once with an aliased variable which takes
89 // a value in the candidate list.
90 G4int ApplyCommand(const char * aCommand);
91 G4int ApplyCommand(const G4String& aCommand);
92 // A command (and parameter(s)) given
93 // by the method's argument will be applied. Zero will be returned in
94 // case the command is successfully executed. Positive non-zero value
95 // will be returned if the command couldn't be executed. The meaning of
96 // this non-zero value is the following.
97 // The returned number : xyy
98 // x00 : G4CommandStatus.hh enumeration
99 // yy : the problematic parameter (first found)
100 void StoreHistory(const char* fileName = "G4history.macro");
101 void StoreHistory(G4bool historySwitch,
102 const char* fileName = "G4history.macro");
103 // The executed commands will be stored in the defined file. If
104 // "historySwitch" is false, saving will be suspended.
105 void ListCommands(const char* direc);
106 // All commands registored under the given directory will be listed to
107 // G4cout.
108 void SetAlias(const char * aliasLine);
109 // Define an alias. The first word of "aliasLine" string is the
110 // alias name and the remaining word(s) is(are) string value
111 // to be aliased.
112 void RemoveAlias(const char * aliasName);
113 // Remove the defined alias.
114 void ListAlias();
115 // Print all aliases.
116 G4String SolveAlias(const char* aCmd);
117 // Convert a command string which contains alias(es).
118 void CreateHTML(const char* dir = "/");
119 // Generate HTML files for defined UI commands
120
121
122 public:
123 void LoopS(const char* valueList);
124 void ForeachS(const char* valueList);
125 // These methods are used by G4UIcontrolMessenger to use Loop() and Foreach() methods.
126 virtual G4bool Notify(G4ApplicationState requestedState);
127 // This method is exclusively invoked by G4StateManager and the user
128 // must not use this method.
129
130 private:
131 void PauseSession(const char* msg);
132 void CreateMessenger();
133 G4UIcommandTree* FindDirectory(const char* dirName);
134
135 //public:
136 // following three methods will be removed quite soon.
137 // void Interact();
138 // void Interact(const char * promptCharacters);
139
140 private:
141 static G4UImanager * fUImanager;
142 static G4bool fUImanagerHasBeenKilled;
143 G4UIcommandTree * treeTop;
144 G4UIsession * session;
145 G4UIsession * g4UIWindow;
146 G4UIcontrolMessenger * UImessenger;
147 G4UnitsMessenger * UnitsMessenger;
148 G4String savedParameters;
149 G4UIcommand * savedCommand;
150 G4int verboseLevel;
151 std::ofstream historyFile;
152 G4bool saveHistory;
153 std::vector<G4String> histVec;
154 G4UIaliasList* aliasList;
155 G4int maxHistSize;
156 G4bool pauseAtBeginOfEvent;
157 G4bool pauseAtEndOfEvent;
158 G4String searchPath;
159 std::vector<G4String> searchDirs;
160
161 public: // with description
162 G4String GetCurrentStringValue(const char * aCommand,
163 G4int parameterNumber=1, G4bool reGet=true);
164 G4int GetCurrentIntValue(const char * aCommand,
165 G4int parameterNumber=1, G4bool reGet=true);
166 G4double GetCurrentDoubleValue(const char * aCommand,
167 G4int parameterNumber=1, G4bool reGet=true);
168 G4String GetCurrentStringValue(const char * aCommand,
169 const char * aParameterName, G4bool reGet=true);
170 G4int GetCurrentIntValue(const char * aCommand,
171 const char * aParameterName, G4bool reGet=true);
172 G4double GetCurrentDoubleValue(const char * aCommand,
173 const char * aParameterName, G4bool reGet=true);
174 // These six methods returns the current value of a parameter of the
175 // given command. For the first three methods, the ordering number of
176 // the parameter (1 is the first parameter) can be given, whereas,
177 // other three methods can give the parameter name.
178 // If "reGet" is true, actual request of returning the current value
179 // will be sent to the corresponding messenger, while, if it is false,
180 // the value stored in G4Umanager will be used. The later case is valid
181 // for the sequential invokation for the same command.
182
184 { pauseAtBeginOfEvent = vl; }
186 { return pauseAtBeginOfEvent; }
188 { pauseAtEndOfEvent = vl; }
190 { return pauseAtEndOfEvent; }
191 // If the boolean flags are true, Pause() method of G4StateManager is invoked
192 // at the very begining (before generating a G4Event object) or at the end of
193 // each event. So that, in case a (G)UI session is defined, the user can interact.
194
195
196 public:
197 inline G4UIcommandTree * GetTree() const
198 { return treeTop; }
199 inline G4UIsession * GetSession() const
200 { return session; }
201 inline G4UIsession * GetG4UIWindow() const
202 { return g4UIWindow; }
203 public: // with description
204 inline void SetSession(G4UIsession *const value)
205 { session = value; }
206 inline void SetG4UIWindow(G4UIsession *const value)
207 { g4UIWindow = value; }
208 // This method defines the active (G)UI session.
209 void SetCoutDestination(G4UIsession *const value);
210 // This method defines the destination of G4cout/G4cerr stream.
211 // For usual cases, this method will be invoked by a concrete
212 // (G)UI session class object and thus the user needs not to invoke
213 // this method by him(her)self.
214
215 public:
216 inline void SetVerboseLevel(G4int val)
217 { verboseLevel = val; }
218 inline G4int GetVerboseLevel() const
219 { return verboseLevel; }
221 { return histVec.size(); }
223 {
224 G4String st;
225 if(i>=0 && i<G4int(histVec.size()))
226 { st = histVec[i]; }
227 return st;
228 }
229 inline void SetMaxHistSize(G4int mx)
230 { maxHistSize = mx; }
231 inline G4int GetMaxHistSize() const
232 { return maxHistSize; }
233
234 inline void SetMacroSearchPath(const G4String& path)
235 { searchPath = path; }
236 inline const G4String& GetMacroSearchPath() const
237 { return searchPath; }
239 G4String FindMacroPath(const G4String& fname) const;
240
241 // Old methods kept for backward compatibility
242 // inline G4UIcommandTree * GetTree() const
243 // { return treeTop; };
244 // inline G4UIsession * GetSession() const
245 // { return session; };
246 // inline void SetSession(G4UIsession *const value)
247 // { session = value; };
248
249};
250
251#endif
G4ApplicationState
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:517
const G4String & GetMacroSearchPath() const
Definition: G4UImanager.hh:236
void ForeachS(const char *valueList)
Definition: G4UImanager.cc:283
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:197
void Foreach(const char *macroFile, const char *variableName, const char *candidates)
Definition: G4UImanager.cc:299
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:369
G4int GetNumberOfHistory() const
Definition: G4UImanager.hh:220
void CreateHTML(const char *dir="/")
Definition: G4UImanager.cc:554
void Loop(const char *macroFile, const char *variableName, G4double initialValue, G4double finalValue, G4double stepSize=1.0)
Definition: G4UImanager.cc:259
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:184
G4String GetPreviousCommand(G4int i) const
Definition: G4UImanager.hh:222
void LoopS(const char *valueList)
Definition: G4UImanager.cc:239
G4bool GetPauseAtBeginOfEvent() const
Definition: G4UImanager.hh:185
void StoreHistory(const char *fileName="G4history.macro")
Definition: G4UImanager.cc:425
void ListCommands(const char *direc)
Definition: G4UImanager.cc:450
G4double GetCurrentDoubleValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:208
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:230
void SetMacroSearchPath(const G4String &path)
Definition: G4UImanager.hh:234
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:134
void SetMaxHistSize(G4int mx)
Definition: G4UImanager.hh:229
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:218
G4UIsession * GetSession() const
Definition: G4UImanager.hh:199
G4bool GetPauseAtEndOfEvent() const
Definition: G4UImanager.hh:189
void SetPauseAtBeginOfEvent(G4bool vl)
Definition: G4UImanager.hh:183
void AddNewCommand(G4UIcommand *newCommand)
Definition: G4UImanager.cc:220
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:122
virtual G4bool Notify(G4ApplicationState requestedState)
Definition: G4UImanager.cc:481
void SetAlias(const char *aliasLine)
Definition: G4UImanager.cc:523
G4String FindMacroPath(const G4String &fname) const
Definition: G4UImanager.cc:593
void RemoveAlias(const char *aliasName)
Definition: G4UImanager.cc:542
G4String SolveAlias(const char *aCmd)
Definition: G4UImanager.cc:316
void ListAlias()
Definition: G4UImanager.cc:549
void RemoveCommand(G4UIcommand *aCommand)
Definition: G4UImanager.cc:225
G4UIsession * GetG4UIWindow() const
Definition: G4UImanager.hh:201
void ParseMacroSearchPath()
Definition: G4UImanager.cc:563
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:51
void SetSession(G4UIsession *const value)
Definition: G4UImanager.hh:204
void SetG4UIWindow(G4UIsession *const value)
Definition: G4UImanager.hh:206
void SetPauseAtEndOfEvent(G4bool vl)
Definition: G4UImanager.hh:187
G4int GetMaxHistSize() const
Definition: G4UImanager.hh:231
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:216