49 G4bool G4UImanager::fUImanagerHasBeenKilled =
false;
55 if(!fUImanagerHasBeenKilled)
58 fUImanager->CreateMessenger();
66 UImessenger(0), UnitsMessenger(0)
72 savedParameters = nullString;
78 pauseAtBeginOfEvent =
false;
79 pauseAtEndOfEvent =
false;
84 void 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(
"\""));
157 const char * aParameterName,
G4bool reGet)
159 if(reGet || savedCommand == NULL)
165 if( aParameterName ==
173 const char * aParameterName,
G4bool reGet)
178 const char* t = targetParameter;
179 std::istringstream is(t);
190 const char* t = targetParameter;
191 std::istringstream is(t);
197 const 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;
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;
445 void 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);
597 for (
size_t i = 0; i < searchDirs.size(); i++) {
599 if ( FileFound(fullpath) ) {
600 macrofile = fullpath;