File indexing completed on 2025-01-18 09:21:24
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
0032
0033
0034
0035 #ifndef G4UImanager_hh
0036 #define G4UImanager_hh 1
0037
0038 #include "G4UIcommandStatus.hh"
0039 #include "G4VStateDependent.hh"
0040 #include "globals.hh"
0041
0042 #include "icomsdefs.hh"
0043
0044 #include <fstream>
0045 #include <vector>
0046
0047 class G4UIcommandTree;
0048 class G4UIcommand;
0049 class G4UIsession;
0050 class G4UIcontrolMessenger;
0051 class G4UnitsMessenger;
0052 class G4LocalThreadCoutMessenger;
0053 class G4UIaliasList;
0054 class G4MTcoutDestination;
0055 class G4UIbridge;
0056
0057 class G4UImanager : public G4VStateDependent
0058 {
0059 public:
0060
0061
0062 static G4UImanager* GetUIpointer();
0063 static G4UImanager* GetMasterUIpointer();
0064
0065 ~G4UImanager() override;
0066
0067 G4UImanager(const G4UImanager&) = delete;
0068 const G4UImanager& operator=(const G4UImanager&) = delete;
0069 G4bool operator==(const G4UImanager&) const = delete;
0070 G4bool operator!=(const G4UImanager&) const = delete;
0071
0072
0073
0074
0075
0076 G4String GetCurrentValues(const char* aCommand);
0077
0078
0079 void AddNewCommand(G4UIcommand* newCommand);
0080
0081
0082
0083 void RemoveCommand(G4UIcommand* aCommand);
0084
0085
0086 void ExecuteMacroFile(const char* fileName);
0087
0088
0089 void Loop(const char* macroFile, const char* variableName, G4double initialValue,
0090 G4double finalValue, G4double stepSize = 1.0);
0091
0092
0093
0094 void Foreach(const char* macroFile, const char* variableName, const char* candidates);
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 G4int ApplyCommand(const char* aCommand);
0105 G4int ApplyCommand(const G4String& aCommand);
0106
0107
0108
0109
0110
0111 G4UIcommand* FindCommand(const char* aCommand);
0112 G4UIcommand* FindCommand(const G4String& aCommand);
0113
0114
0115
0116 void StoreHistory(const char* fileName = "G4history.macro");
0117 void StoreHistory(G4bool historySwitch, const char* fileName = "G4history.macro");
0118
0119
0120
0121 void ListCommands(const char* direc);
0122
0123
0124
0125
0126 void SetAlias(const char* aliasLine);
0127
0128
0129 void RemoveAlias(const char* aliasName);
0130
0131
0132 void ListAlias();
0133
0134
0135 G4String SolveAlias(const char* aCmd);
0136
0137
0138 void CreateHTML(const char* dir = "/");
0139
0140
0141
0142 void LoopS(const char* valueList);
0143 void ForeachS(const char* valueList);
0144
0145
0146 G4bool Notify(G4ApplicationState requestedState) override;
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156 G4String GetCurrentStringValue(const char* aCommand, G4int parameterNumber = 1,
0157 G4bool reGet = true);
0158 G4int GetCurrentIntValue(const char* aCommand, G4int parameterNumber = 1, G4bool reGet = true);
0159 G4double GetCurrentDoubleValue(const char* aCommand, G4int parameterNumber = 1,
0160 G4bool reGet = true);
0161 G4String GetCurrentStringValue(const char* aCommand, const char* aParameterName,
0162 G4bool reGet = true);
0163 G4int GetCurrentIntValue(const char* aCommand, const char* aParameterName, G4bool reGet = true);
0164 G4double GetCurrentDoubleValue(const char* aCommand, const char* aParameterName,
0165 G4bool reGet = true);
0166
0167
0168
0169
0170
0171 inline void SetPauseAtBeginOfEvent(G4bool vl) { pauseAtBeginOfEvent = vl; }
0172 inline G4bool GetPauseAtBeginOfEvent() const { return pauseAtBeginOfEvent; }
0173 inline void SetPauseAtEndOfEvent(G4bool vl) { pauseAtEndOfEvent = vl; }
0174 inline G4bool GetPauseAtEndOfEvent() const { return pauseAtEndOfEvent; }
0175
0176 inline G4UIcommandTree* GetTree() const { return treeTop; }
0177 inline G4UIsession* GetSession() const { return session; }
0178 inline G4UIsession* GetG4UIWindow() const { return g4UIWindow; }
0179
0180 G4UIsession* GetBaseSession() const;
0181
0182
0183 inline void SetSession(G4UIsession* const value) { session = value; }
0184 inline void SetG4UIWindow(G4UIsession* const value) { g4UIWindow = value; }
0185
0186
0187
0188
0189 void SetCoutDestination(G4UIsession* const value);
0190
0191 inline void SetVerboseLevel(G4int val) { verboseLevel = val; }
0192 inline G4int GetVerboseLevel() const { return verboseLevel; }
0193 inline G4int GetNumberOfHistory() const { return G4int(histVec.size()); }
0194 inline G4String GetPreviousCommand(G4int i) const
0195 {
0196 G4String st;
0197 if (i >= 0 && i < G4int(histVec.size())) {
0198 st = histVec[i];
0199 }
0200 return st;
0201 }
0202 inline void SetMaxHistSize(G4int mx) { maxHistSize = mx; }
0203 inline G4int GetMaxHistSize() const { return maxHistSize; }
0204
0205 inline void SetMacroSearchPath(const G4String& path) { searchPath = path; }
0206 inline const G4String& GetMacroSearchPath() const { return searchPath; }
0207 void ParseMacroSearchPath();
0208 G4String FindMacroPath(const G4String& fname) const;
0209
0210 inline void SetMasterUIManager(G4bool val)
0211 {
0212 isMaster = val;
0213 stackCommandsForBroadcast = val;
0214 if (val && (bridges == nullptr)) {
0215 bridges = new std::vector<G4UIbridge*>;
0216 fMasterUImanager() = this;
0217 }
0218 }
0219 inline void SetIgnoreCmdNotFound(G4bool val) { ignoreCmdNotFound = val; }
0220
0221 std::vector<G4String>* GetCommandStack();
0222 void RegisterBridge(G4UIbridge* brg);
0223
0224
0225 void SetUpForAThread(G4int tId);
0226
0227 void SetUpForSpecialThread(const G4String& aPrefix);
0228
0229 inline G4int GetThreadID() const { return threadID; }
0230
0231 void SetCoutFileName(const G4String& fileN = "G4cout.txt", G4bool ifAppend = true);
0232 void SetCerrFileName(const G4String& fileN = "G4cerr.txt", G4bool ifAppend = true);
0233 void SetThreadPrefixString(const G4String& prefix = "W");
0234 void SetThreadUseBuffer(G4bool flg = true);
0235 void SetThreadIgnore(G4int tid = 0);
0236 void SetThreadIgnoreInit(G4bool flg = true);
0237 inline G4MTcoutDestination* GetThreadCout() { return threadCout; }
0238
0239 static void UseDoublePrecisionStr(G4bool val);
0240 static G4bool DoublePrecisionStr();
0241
0242 inline G4int GetLastReturnCode() const { return lastRC; }
0243
0244 inline bool IsLastCommandOutputTreated() { return fLastCommandOutputTreated; }
0245 inline void SetLastCommandOutputTreated() { fLastCommandOutputTreated = true; }
0246
0247 protected:
0248 G4UImanager();
0249
0250 private:
0251 void AddWorkerCommand(G4UIcommand* newCommand);
0252 void RemoveWorkerCommand(G4UIcommand* aCommand);
0253
0254 void PauseSession(const char* msg);
0255 void CreateMessenger();
0256 G4UIcommandTree* FindDirectory(const char* dirName);
0257
0258 private:
0259 G4ICOMS_DLL static G4UImanager*& fUImanager();
0260 G4ICOMS_DLL static G4bool& fUImanagerHasBeenKilled();
0261 G4ICOMS_DLL static G4UImanager*& fMasterUImanager();
0262 G4UIcommandTree* treeTop = nullptr;
0263 G4UIsession* session = nullptr;
0264 G4UIsession* g4UIWindow = nullptr;
0265 G4UIcontrolMessenger* UImessenger = nullptr;
0266 G4UnitsMessenger* UnitsMessenger = nullptr;
0267 G4LocalThreadCoutMessenger* CoutMessenger = nullptr;
0268 G4String savedParameters;
0269 G4UIcommand* savedCommand = nullptr;
0270 G4int verboseLevel = 0;
0271 std::ofstream historyFile;
0272 G4bool saveHistory = false;
0273 std::vector<G4String> histVec;
0274 G4UIaliasList* aliasList = nullptr;
0275 G4int maxHistSize = 20;
0276 G4bool pauseAtBeginOfEvent = false;
0277 G4bool pauseAtEndOfEvent = false;
0278 G4String searchPath = "";
0279 std::vector<G4String> searchDirs;
0280
0281 G4bool isMaster = false;
0282 std::vector<G4UIbridge*>* bridges = nullptr;
0283 G4bool ignoreCmdNotFound = false;
0284 G4bool stackCommandsForBroadcast = false;
0285 std::vector<G4String>* commandStack = nullptr;
0286
0287 G4int threadID = -1;
0288 G4MTcoutDestination* threadCout = nullptr;
0289 G4ICOMS_DLL static G4int igThreadID;
0290
0291 G4ICOMS_DLL static G4bool doublePrecisionStr;
0292
0293 G4int lastRC = 0;
0294
0295 G4bool fLastCommandOutputTreated = true;
0296 };
0297
0298 #endif