49G4bool G4UImanager::fUImanagerHasBeenKilled =
false;
55 if(!fUImanagerHasBeenKilled)
58 fUImanager->CreateMessenger();
66 UImessenger(0), UnitsMessenger(0)
72 savedParameters = nullString;
78 pauseAtBeginOfEvent =
false;
79 pauseAtEndOfEvent =
false;
84void G4UImanager::CreateMessenger()
94 if(saveHistory) historyFile.close();
96 delete UnitsMessenger;
99 fUImanagerHasBeenKilled =
true;
106 UImessenger = ui.UImessenger;
107 UnitsMessenger = ui.UnitsMessenger;
108 aliasList = ui.aliasList;
109 g4UIWindow = ui.g4UIWindow;
110 savedCommand= ui.savedCommand;
111 session = ui.session;
112 treeTop = ui.treeTop;
118{
return (
this==&right); }
120{
return (
this!=&right); }
125 savedCommand = treeTop->
FindPath( theCommand );
126 if( savedCommand == NULL )
137 if(reGet || savedCommand == NULL)
143 for(
G4int i_thParameter=0;i_thParameter<parameterNumber;i_thParameter++)
145 token = savedToken();
147 if( token[(
size_t)0] ==
'"' )
150 token.
append(savedToken(
"\""));
157const char * aParameterName,
G4bool reGet)
159 if(reGet || savedCommand == NULL)
165 if( aParameterName ==
173const char * aParameterName,
G4bool reGet)
178 const char* t = targetParameter;
179 std::istringstream is(t);
190 const char* t = targetParameter;
191 std::istringstream is(t);
197const char * aParameterName,
G4bool reGet)
202 const char* t = targetParameter;
203 std::istringstream is(t);
214 const char* t = targetParameter;
215 std::istringstream is(t);
233 session = batchSession;
236 session = previousSession;
247 c1 += parameterToken();
249 c1 += parameterToken();
251 std::istringstream is(t1);
255 is >> d1 >> d2 >> d3;
256 Loop(mf,vn,d1,d2,d3);
264 for(
G4double d=initialValue;d<=finalValue;d+=stepSize)
266 std::ostringstream os;
272 for(
G4double d=initialValue;d>=finalValue;d+=stepSize)
274 std::ostringstream os;
280 Foreach(macroFile,variableName,cd);
291 while(!((ca=parameterToken()).isNull()))
300 const char * candidates)
302 G4String candidatesString = candidates;
305 while(!((cd=parameterToken()).isNull()))
321 while((ia !=
G4int(std::string::npos))&&((iz==
G4int(std::string::npos))||(ia<iz)))
327 if( ib ==
G4int(std::string::npos) )
332 G4cerr <<
"Unmatched alias parenthis -- command ignored" <<
G4endl;
336 G4String ps = aCommand(ia+1,aCommand.length()-(ia+1));
339 if(ic!=
G4int(std::string::npos) && ic <
id)
347 if(ia>0) subs = aCommand(0,ia);
348 G4String alis = aCommand(ia+1,ibx-ia-1);
349 G4String rems = aCommand(ibx+1,aCommand.length()-ibx);
354 G4cerr <<
"Alias <" << alis <<
"> not found -- command ignored" <<
G4endl;
358 aCommand = subs+(*alVal)+rems;
359 ia = aCommand.
index(
"{");
378 if( i !=
G4int(std::string::npos) )
380 commandString = aCommand(0,i);
381 commandParameter = aCommand(i+1,aCommand.length()-(i+1));
385 commandString = aCommand;
389 G4int len = commandString.length();
395 if(commandString(ll,2)==
"//")
398 { commandString.
remove(ll,1); }
401 a1 = commandString(0,ll);
402 a2 = commandString(ll+1,len-ll-1);
403 commandString = a1+a2;
412 if( targetCommand == NULL )
418 if(saveHistory) historyFile << aCommand <<
G4endl;
419 if(
G4int(histVec.size()) >= maxHistSize )
420 { histVec.erase(histVec.begin()); }
421 histVec.push_back(aCommand);
422 return targetCommand->
DoIt( commandParameter );
433 { historyFile.close(); }
434 historyFile.open((
char*)fileName);
442 saveHistory = historySwitch;
445void G4UImanager::PauseSession(
const char* msg)
463 if( targetDir( targetDir.length()-1 ) !=
'/' )
464 { targetDir +=
"/"; }
466 if( targetDir ==
"/" )
469 while( idx <
G4int(targetDir.length())-1 )
472 G4String targetDirString = targetDir(0,i+1);
473 comTree = comTree->
GetTree(targetDirString);
474 if( comTree == NULL )
484 if(pauseAtBeginOfEvent)
488 { PauseSession(
"BeginOfEvent"); }
490 if(pauseAtEndOfEvent)
494 { PauseSession(
"EndOfEvent"); }
528 G4String aliasValue = aLine(i+1,aLine.length()-(i+1));
529 if(aliasValue(0)==
'"')
532 if(aliasValue(aliasValue.length()-1)==
'"')
533 { strippedValue = aliasValue(1,aliasValue.length()-2); }
535 { strippedValue = aliasValue(1,aliasValue.length()-1); }
536 aliasValue = strippedValue;
560 {
G4cerr <<
"Directory <" << dir <<
"> is not found." <<
G4endl; }
570 while( (idxend = searchPath.
index(
':', idxfirst)) != G4String::npos) {
571 pathstring = searchPath.substr(idxfirst, idxend-idxfirst);
572 if(pathstring.size() != 0) searchDirs.push_back(pathstring);
573 idxfirst = idxend + 1;
576 pathstring = searchPath.substr(idxfirst, searchPath.size()-idxfirst);
577 if(pathstring.size() != 0) searchDirs.push_back(pathstring);
585 fs.open(fname.c_str(), std::ios::in);
597 for (
size_t i = 0; i < searchDirs.size(); i++) {
598 G4String fullpath = searchDirs[i] +
"/" + fname;
599 if ( FileFound(fullpath) ) {
600 macrofile = fullpath;
@ fIllegalApplicationState
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
G4DLLIMPORT G4strstreambuf G4coutbuf
G4DLLIMPORT G4strstreambuf G4cerrbuf
static G4StateManager * GetStateManager()
G4String & remove(str_size)
G4String & append(const G4String &)
str_size index(const char *, G4int pos=0) const
G4String strip(G4int strip_Type=trailing, char c=' ')
const char * data() const
G4String * FindAlias(const char *aliasName)
void ChangeAlias(const char *aliasName, const char *aliasValue)
void RemoveAlias(const char *aliasName)
G4UIcommandTree * GetTree(G4int i)
void RemoveCommand(G4UIcommand *aCommand)
G4UIcommand * FindPath(const char *commandPath) const
void AddNewCommand(G4UIcommand *newCommand)
G4UIparameter * GetParameter(G4int i) const
virtual G4int DoIt(G4String parameterList)
G4int GetParameterEntries() const
G4String GetCurrentValue()
void SetCoutDestination(G4UIsession *const value)
void ForeachS(const char *valueList)
void Foreach(const char *macroFile, const char *variableName, const char *candidates)
G4int ApplyCommand(const char *aCommand)
void CreateHTML(const char *dir="/")
void Loop(const char *macroFile, const char *variableName, G4double initialValue, G4double finalValue, G4double stepSize=1.0)
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
void LoopS(const char *valueList)
void StoreHistory(const char *fileName="G4history.macro")
void ListCommands(const char *direc)
G4double GetCurrentDoubleValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
void ExecuteMacroFile(const char *fileName)
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
void AddNewCommand(G4UIcommand *newCommand)
G4String GetCurrentValues(const char *aCommand)
virtual G4bool Notify(G4ApplicationState requestedState)
void SetAlias(const char *aliasLine)
G4String FindMacroPath(const G4String &fname) const
void RemoveAlias(const char *aliasName)
G4String SolveAlias(const char *aCmd)
void RemoveCommand(G4UIcommand *aCommand)
void ParseMacroSearchPath()
static G4UImanager * GetUIpointer()
G4String GetParameterName() const
virtual void PauseSessionStart(const G4String &Prompt)
virtual G4UIsession * SessionStart()
void SetDestination(G4coutDestination *dest)