source: trunk/source/intercoms/include/G4UImanager.hh@ 1261

Last change on this file since 1261 was 1256, checked in by garnier, 16 years ago

remove cycle dependency

File size: 10.2 KB
RevLine 
[821]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//
[1256]27// $Id: G4UImanager.hh,v 1.22 2010/05/19 14:50:30 lgarnier Exp $
28// GEANT4 tag $Name: $
[821]29//
30
31#ifndef G4UImanager_h
32#define G4UImanager_h 1
33
34#include "globals.hh"
35
36#include <vector>
37#include <fstream>
38#include "G4VStateDependent.hh"
39#include "G4UIcommandStatus.hh"
40class G4UIcommandTree;
41class G4UIcommand;
42class G4UIsession;
43class G4UIcontrolMessenger;
44class G4UnitsMessenger;
45class G4UIaliasList;
46
47// class description:
48//
49// This is a singlton class which controls the command manipulation
50// and the user interface(s). The constructor of this class MUST NOT
51// invoked by the user.
52//
53
54class G4UImanager : public G4VStateDependent
55{
56 public: // with description
57 static G4UImanager * GetUIpointer();
58 // A static method to get the pointer to the only existing object
59 // of this class.
60
61 protected:
62 G4UImanager();
63 public:
64 ~G4UImanager();
65 private:
66 G4UImanager(const G4UImanager &right);
67 const G4UImanager & operator=(const G4UImanager &right);
68 G4int operator==(const G4UImanager &right) const;
69 G4int operator!=(const G4UImanager &right) const;
70
71 public: // with description
72 G4String GetCurrentValues(const char * aCommand);
73 // This method returns a string which represents the current value(s)
74 // of the parameter(s) of the specified command. Null string will be
75 // returned if the given command is not defined or the command does
76 // not support the GetCurrentValues() method.
77 void AddNewCommand(G4UIcommand * newCommand);
78 // This method register a new command.
79 void RemoveCommand(G4UIcommand * aCommand);
80 // This command remove the registered command. After invokation of this
81 // command, that particular command cannot be applied.
82 void ExecuteMacroFile(const char * fileName);
83 // A macro file defined by the argument will be read by G4UIbatch object.
84 void Loop(const char * macroFile,const char * variableName,
85 G4double initialValue,G4double finalValue,G4double stepSize=1.0);
86 // Execute a macro file more than once with a loop counter.
87 void Foreach(const char * macroFile,const char * variableName,
88 const char * candidates);
89 // Execute a macro file more than once with an aliased variable which takes
90 // a value in the candidate list.
91 G4int ApplyCommand(const char * aCommand);
92 G4int ApplyCommand(G4String aCommand);
93 // A command (and parameter(s)) given
94 // by the method's argument will be applied. Zero will be returned in
95 // case the command is successfully executed. Positive non-zero value
96 // will be returned if the command couldn't be executed. The meaning of
97 // this non-zero value is the following.
98 // The returned number : xyy
99 // x00 : G4CommandStatus.hh enumeration
100 // yy : the problematic parameter (first found)
101 void StoreHistory(const char* fileName = "G4history.macro");
102 void StoreHistory(G4bool historySwitch,
103 const char* fileName = "G4history.macro");
104 // The executed commands will be stored in the defined file. If
105 // "historySwitch" is false, saving will be suspended.
106 void ListCommands(const char* direc);
107 // All commands registored under the given directory will be listed to
108 // G4cout.
109 void SetAlias(const char * aliasLine);
110 // Define an alias. The first word of "aliasLine" string is the
111 // alias name and the remaining word(s) is(are) string value
112 // to be aliased.
113 void RemoveAlias(const char * aliasName);
114 // Remove the defined alias.
115 void ListAlias();
116 // Print all aliases.
117 G4String SolveAlias(const char* aCmd);
118 // Convert a command string which contains alias(es).
119 void CreateHTML(const char* dir = "/");
120 // Generate HTML files for defined UI commands
121
122
123 public:
124 void LoopS(const char* valueList);
125 void ForeachS(const char* valueList);
126 // These methods are used by G4UIcontrolMessenger to use Loop() and Foreach() methods.
127 virtual G4bool Notify(G4ApplicationState requestedState);
128 // This method is exclusively invoked by G4StateManager and the user
129 // must not use this method.
130
131 private:
132 void PauseSession(const char* msg);
133 void CreateMessenger();
134 G4UIcommandTree* FindDirectory(const char* dirName);
135
136 //public:
137 // following three methods will be removed quite soon.
138 // void Interact();
139 // void Interact(const char * promptCharacters);
140
141 private:
142 static G4UImanager * fUImanager;
143 static G4bool fUImanagerHasBeenKilled;
144 G4UIcommandTree * treeTop;
145 G4UIsession * session;
[1256]146 G4UIsession * g4UIWindow;
[821]147 G4UIcontrolMessenger * UImessenger;
148 G4UnitsMessenger * UnitsMessenger;
149 G4String savedParameters;
150 G4UIcommand * savedCommand;
151 G4int verboseLevel;
152 std::ofstream historyFile;
153 G4bool saveHistory;
154 std::vector<G4String> histVec;
155 G4UIaliasList* aliasList;
156 G4int maxHistSize;
157 G4bool pauseAtBeginOfEvent;
158 G4bool pauseAtEndOfEvent;
159
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
183 inline void SetPauseAtBeginOfEvent(G4bool vl)
184 { pauseAtBeginOfEvent = vl; }
185 inline G4bool GetPauseAtBeginOfEvent() const
186 { return pauseAtBeginOfEvent; }
187 inline void SetPauseAtEndOfEvent(G4bool vl)
188 { pauseAtEndOfEvent = vl; }
189 inline G4bool GetPauseAtEndOfEvent() const
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; }
[1256]201 inline G4UIsession * GetG4UIWindow() const
202 { return g4UIWindow; }
[821]203 public: // with description
[1228]204 inline void SetSession(G4UIsession *const value)
205 { session = value; }
[1256]206 inline void SetG4UIWindow(G4UIsession *const value)
207 { g4UIWindow = value; }
[821]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; }
220 inline G4int GetNumberOfHistory() const
221 { return histVec.size(); }
222 inline G4String GetPreviousCommand(G4int i) const
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 // Old methods kept for backward compatibility
235 // inline G4UIcommandTree * GetTree() const
236 // { return treeTop; };
237 // inline G4UIsession * GetSession() const
238 // { return session; };
239 // inline void SetSession(G4UIsession *const value)
240 // { session = value; };
241
242};
243
244#endif
245
Note: See TracBrowser for help on using the repository browser.