Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UImanager Class Reference

#include <G4UImanager.hh>

+ Inheritance diagram for G4UImanager:

Public Member Functions

 ~G4UImanager ()
 
 G4UImanager (const G4UImanager &)=delete
 
const G4UImanageroperator= (const G4UImanager &)=delete
 
G4bool operator== (const G4UImanager &) const =delete
 
G4bool operator!= (const G4UImanager &) const =delete
 
G4String GetCurrentValues (const char *aCommand)
 
void AddNewCommand (G4UIcommand *newCommand)
 
void RemoveCommand (G4UIcommand *aCommand)
 
void ExecuteMacroFile (const char *fileName)
 
void Loop (const char *macroFile, const char *variableName, G4double initialValue, G4double finalValue, G4double stepSize=1.0)
 
void Foreach (const char *macroFile, const char *variableName, const char *candidates)
 
G4int ApplyCommand (const char *aCommand)
 
G4int ApplyCommand (const G4String &aCommand)
 
void StoreHistory (const char *fileName="G4history.macro")
 
void StoreHistory (G4bool historySwitch, const char *fileName="G4history.macro")
 
void ListCommands (const char *direc)
 
void SetAlias (const char *aliasLine)
 
void RemoveAlias (const char *aliasName)
 
void ListAlias ()
 
G4String SolveAlias (const char *aCmd)
 
void CreateHTML (const char *dir="/")
 
void LoopS (const char *valueList)
 
void ForeachS (const char *valueList)
 
virtual G4bool Notify (G4ApplicationState requestedState)
 
G4String GetCurrentStringValue (const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
 
G4int GetCurrentIntValue (const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
 
G4double GetCurrentDoubleValue (const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
 
G4String GetCurrentStringValue (const char *aCommand, const char *aParameterName, G4bool reGet=true)
 
G4int GetCurrentIntValue (const char *aCommand, const char *aParameterName, G4bool reGet=true)
 
G4double GetCurrentDoubleValue (const char *aCommand, const char *aParameterName, G4bool reGet=true)
 
void SetPauseAtBeginOfEvent (G4bool vl)
 
G4bool GetPauseAtBeginOfEvent () const
 
void SetPauseAtEndOfEvent (G4bool vl)
 
G4bool GetPauseAtEndOfEvent () const
 
G4UIcommandTreeGetTree () const
 
G4UIsessionGetSession () const
 
G4UIsessionGetG4UIWindow () const
 
void SetSession (G4UIsession *const value)
 
void SetG4UIWindow (G4UIsession *const value)
 
void SetCoutDestination (G4UIsession *const value)
 
void SetVerboseLevel (G4int val)
 
G4int GetVerboseLevel () const
 
G4int GetNumberOfHistory () const
 
G4String GetPreviousCommand (G4int i) const
 
void SetMaxHistSize (G4int mx)
 
G4int GetMaxHistSize () const
 
void SetMacroSearchPath (const G4String &path)
 
const G4StringGetMacroSearchPath () const
 
void ParseMacroSearchPath ()
 
G4String FindMacroPath (const G4String &fname) const
 
void SetMasterUIManager (G4bool val)
 
void SetIgnoreCmdNotFound (G4bool val)
 
std::vector< G4String > * GetCommandStack ()
 
void RegisterBridge (G4UIbridge *brg)
 
void SetUpForAThread (G4int tId)
 
void SetUpForSpecialThread (G4String aPrefix)
 
G4int GetThreadID () const
 
void SetCoutFileName (const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
 
void SetCerrFileName (const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
 
void SetThreadPrefixString (const G4String &s="W")
 
void SetThreadUseBuffer (G4bool flg=true)
 
void SetThreadIgnore (G4int tid=0)
 
void SetThreadIgnoreInit (G4bool flg=true)
 
G4MTcoutDestinationGetThreadCout ()
 
G4int GetLastReturnCode () const
 
- Public Member Functions inherited from G4VStateDependent
 G4VStateDependent (G4bool bottom=false)
 
virtual ~G4VStateDependent ()
 
G4bool operator== (const G4VStateDependent &right) const
 
G4bool operator!= (const G4VStateDependent &right) const
 
virtual G4bool Notify (G4ApplicationState requestedState)=0
 

Static Public Member Functions

static G4UImanagerGetUIpointer ()
 
static G4UImanagerGetMasterUIpointer ()
 
static void UseDoublePrecisionStr (G4bool val)
 
static G4bool DoublePrecisionStr ()
 

Protected Member Functions

 G4UImanager ()
 

Detailed Description

Definition at line 57 of file G4UImanager.hh.

Constructor & Destructor Documentation

◆ ~G4UImanager()

G4UImanager::~G4UImanager ( )

Definition at line 116 of file G4UImanager.cc.

117{
118 if(bridges != nullptr)
119 {
120 for(auto itr = bridges->cbegin(); itr != bridges->cend(); ++itr)
121 {
122 delete *itr;
123 }
124 delete bridges;
125 }
126 SetCoutDestination(nullptr);
127 histVec.clear();
128 if(saveHistory)
129 historyFile.close();
130 delete CoutMessenger;
131 delete ProfileMessenger;
132 delete UnitsMessenger;
133 delete UImessenger;
134 delete treeTop;
135 delete aliasList;
136 fUImanagerHasBeenKilled() = true;
137 fUImanager() = nullptr;
138 if(commandStack != nullptr)
139 {
140 commandStack->clear();
141 delete commandStack;
142 }
143 if(threadID >= 0)
144 {
145 delete threadCout;
147 threadID = -1;
148 }
149}
void G4iosFinalization()
Definition: G4ios.cc:112
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:699

◆ G4UImanager() [1/2]

G4UImanager::G4UImanager ( const G4UImanager )
delete

◆ G4UImanager() [2/2]

G4UImanager::G4UImanager ( )
protected

Definition at line 97 of file G4UImanager.cc.

98 : G4VStateDependent(true)
99{
100 treeTop = new G4UIcommandTree("/");
101 aliasList = new G4UIaliasList;
102 SetCoutDestination(session);
103 commandStack = new std::vector<G4String>;
104}

Referenced by GetUIpointer().

Member Function Documentation

◆ AddNewCommand()

void G4UImanager::AddNewCommand ( G4UIcommand newCommand)

Definition at line 271 of file G4UImanager.cc.

272{
273 treeTop->AddNewCommand(newCommand);
274 if(fMasterUImanager() != nullptr && G4Threading::G4GetThreadId() == 0)
275 {
276 fMasterUImanager()->AddWorkerCommand(newCommand);
277 }
278}
void AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly=false)
G4int G4GetThreadId()
Definition: G4Threading.cc:122

◆ ApplyCommand() [1/2]

G4int G4UImanager::ApplyCommand ( const char *  aCommand)

Definition at line 485 of file G4UImanager.cc.

486{
487 G4String aCommand = SolveAlias(aCmd);
488 if(aCommand.isNull())
489 return fAliasNotFound;
490 if(verboseLevel)
491 G4cout << aCommand << G4endl;
492 G4String commandString;
493 G4String commandParameter;
494
495 std::size_t i = aCommand.index(" ");
496 if(i != std::string::npos)
497 {
498 commandString = aCommand(0, i);
499 commandParameter = aCommand(i + 1, aCommand.length() - (i + 1));
500 }
501 else
502 {
503 commandString = aCommand;
504 }
505
506 // remove doubled slash
507 G4int len = commandString.length();
508 G4int ll = 0;
509 G4String a1;
510 G4String a2;
511 while(ll < len - 1)
512 {
513 if(commandString(ll, 2) == "//")
514 {
515 if(ll == 0)
516 {
517 commandString.remove(ll, 1);
518 }
519 else
520 {
521 a1 = commandString(0, ll);
522 a2 = commandString(ll + 1, len - ll - 1);
523 commandString = a1 + a2;
524 }
525 --len;
526 }
527 else
528 {
529 ++ll;
530 }
531 }
532
533 if(isMaster && bridges != nullptr)
534 {
535 for(auto itr = bridges->cbegin(); itr != bridges->cend(); ++itr)
536 {
537 G4int leng = (*itr)->DirLength();
538 if(commandString(0, leng) == (*itr)->DirName())
539 {
540 return (*itr)->LocalUI()->ApplyCommand(commandString + " " +
541 commandParameter);
542 }
543 }
544 }
545
546 G4UIcommand* targetCommand = treeTop->FindPath(commandString);
547 if(targetCommand == nullptr)
548 {
549 if(ignoreCmdNotFound)
550 {
551 if(stackCommandsForBroadcast)
552 {
553 commandStack->push_back(commandString + " " + commandParameter);
554 }
555 return fCommandSucceeded;
556 }
557 else
558 {
559 return fCommandNotFound;
560 }
561 }
562
563 if(stackCommandsForBroadcast && targetCommand->ToBeBroadcasted())
564 {
565 commandStack->push_back(commandString + " " + commandParameter);
566 }
567
568 if(!(targetCommand->IsAvailable()))
569 {
571 }
572
573 if(saveHistory)
574 historyFile << aCommand << G4endl;
575 if(G4int(histVec.size()) >= maxHistSize)
576 {
577 histVec.erase(histVec.begin());
578 }
579 histVec.push_back(aCommand);
580
581 targetCommand->ResetFailure();
582 G4int commandFailureCode = targetCommand->DoIt(commandParameter);
583 if(commandFailureCode == 0)
584 {
585 G4int additionalFailureCode = targetCommand->IfCommandFailed();
586 if(additionalFailureCode > 0)
587 {
589 msg << targetCommand->GetFailureDescription() << "\n"
590 << "Error code : " << additionalFailureCode;
591 G4Exception("G4UImanager::ApplyCommand", "UIMAN0123", JustWarning, msg);
592 commandFailureCode += additionalFailureCode;
593 }
594 }
595 return commandFailureCode;
596}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
int G4int
Definition: G4Types.hh:85
@ fCommandNotFound
@ fAliasNotFound
@ fIllegalApplicationState
@ fCommandSucceeded
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4String & remove(str_size)
str_size index(const char *, G4int pos=0) const
G4bool isNull() const
G4UIcommand * FindPath(const char *commandPath) const
G4bool ToBeBroadcasted() const
Definition: G4UIcommand.hh:173
G4int IfCommandFailed()
Definition: G4UIcommand.hh:189
virtual G4int DoIt(G4String parameterList)
Definition: G4UIcommand.cc:135
void ResetFailure()
Definition: G4UIcommand.hh:191
G4bool IsAvailable()
Definition: G4UIcommand.cc:328
const G4String & GetFailureDescription()
Definition: G4UIcommand.hh:190
G4String SolveAlias(const char *aCmd)
Definition: G4UImanager.cc:424

Referenced by G4UIbridge::ApplyCommand(), ApplyCommand(), G4RunManagerKernel::BuildPhysicsTables(), G4TheMTRayTracer::CreateBitMap(), G4WorkerRunManager::DoWork(), G4VBasicShell::ExecuteCommand(), G4RunManager::GeometryHasBeenModified(), G4TaskRunManagerKernel::InitializeWorker(), G4VVisCommand::InterpolateViews(), G4RunManager::ProcessOneEvent(), G4WorkerRunManager::ProcessOneEvent(), G4WorkerTaskRunManager::ProcessOneEvent(), G4WorkerTaskRunManager::ProcessUI(), G4VVisCommand::RefreshIfRequired(), G4RunManager::ReinitializeGeometry(), G4TaskRunManager::RequestWorkersProcessCommandsStack(), G4RunManager::rndmSaveThisEvent(), G4WorkerRunManager::rndmSaveThisEvent(), G4MTRunManager::rndmSaveThisRun(), G4RunManager::rndmSaveThisRun(), G4WorkerRunManager::rndmSaveThisRun(), G4VVisCommandGeometrySet::Set(), G4OpticalParametersMessenger::SetNewValue(), G4EmExtraParametersMessenger::SetNewValue(), G4EmLowEParametersMessenger::SetNewValue(), G4EmParametersMessenger::SetNewValue(), G4UIcontrolMessenger::SetNewValue(), G4VisCommandList::SetNewValue(), G4VisCommandReviewKeptEvents::SetNewValue(), G4VisCommandDrawTree::SetNewValue(), G4VisCommandDrawView::SetNewValue(), G4VisCommandDrawLogicalVolume::SetNewValue(), G4VisCommandDrawVolume::SetNewValue(), G4VisCommandOpen::SetNewValue(), G4VisCommandSpecify::SetNewValue(), G4VisCommandGeometryRestore::SetNewValue(), G4VisCommandSceneAddTrajectories::SetNewValue(), G4VisCommandsTouchable::SetNewValue(), G4VisCommandsTouchableSet::SetNewValue(), G4VisCommandViewerClone::SetNewValue(), G4VisCommandViewerCreate::SetNewValue(), G4VisCommandViewerFlush::SetNewValue(), G4VisCommandViewerInterpolate::SetNewValue(), G4ProcessManagerMessenger::SetNewValue(), G4ProcessTableMessenger::SetNewValue(), G4TrackingMessenger::SetNewValue(), G4VisCommandGeometrySetVisibility::SetNewValueOnLV(), G4VViewer::SetTouchable(), G4TheMTRayTracer::Trace(), and G4TheRayTracer::Trace().

◆ ApplyCommand() [2/2]

G4int G4UImanager::ApplyCommand ( const G4String aCommand)

Definition at line 479 of file G4UImanager.cc.

480{
481 return ApplyCommand(aCmd.data());
482}
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485

◆ CreateHTML()

void G4UImanager::CreateHTML ( const char *  dir = "/")

Definition at line 744 of file G4UImanager.cc.

745{
746 G4UIcommandTree* tr = FindDirectory(dir);
747 if(tr != nullptr)
748 {
749 tr->CreateHTML();
750 }
751 else
752 {
753 G4cerr << "Directory <" << dir << "> is not found." << G4endl;
754 }
755}
G4GLOB_DLL std::ostream G4cerr

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ DoublePrecisionStr()

G4bool G4UImanager::DoublePrecisionStr ( )
static

Definition at line 158 of file G4UImanager.cc.

159{
160 return doublePrecisionStr;
161}

Referenced by G4UIcommand::ConvertToString(), and G4UIcontrolMessenger::GetCurrentValue().

◆ ExecuteMacroFile()

void G4UImanager::ExecuteMacroFile ( const char *  fileName)

Definition at line 303 of file G4UImanager.cc.

304{
305 G4UIsession* batchSession = new G4UIbatch(fileName, session);
306 session = batchSession;
307 lastRC = 0;
308 G4UIsession* previousSession = session->SessionStart();
309 lastRC = session->GetLastReturnCode();
310 delete session;
311 session = previousSession;
312}
virtual G4UIsession * SessionStart()
Definition: G4UIsession.cc:57
G4int GetLastReturnCode() const
Definition: G4UIsession.hh:63

Referenced by Foreach(), and G4UIcontrolMessenger::SetNewValue().

◆ FindMacroPath()

G4String G4UImanager::FindMacroPath ( const G4String fname) const

Definition at line 793 of file G4UImanager.cc.

794{
795 G4String macrofile = fname;
796
797 for(std::size_t i = 0; i < searchDirs.size(); ++i)
798 {
799 G4String fullpath = searchDirs[i] + "/" + fname;
800 if(FileFound(fullpath))
801 {
802 macrofile = fullpath;
803 break;
804 }
805 }
806 return macrofile;
807}

Referenced by Foreach(), and G4UIcontrolMessenger::SetNewValue().

◆ Foreach()

void G4UImanager::Foreach ( const char *  macroFile,
const char *  variableName,
const char *  candidates 
)

Definition at line 399 of file G4UImanager.cc.

401{
402 G4String candidatesString = candidates;
403 G4Tokenizer parameterToken(candidatesString);
404 G4String cd;
405 while(!((cd = parameterToken()).isNull()))
406 {
407 G4String vl = variableName;
408 vl += " ";
409 vl += cd;
410 SetAlias(vl);
412 if(lastRC != 0)
413 {
415 ed << "Loop aborted due to a command execution error - "
416 << "error code " << lastRC;
417 G4Exception("G4UImanager::Foreach", "UIMAN0201", JustWarning, ed);
418 break;
419 }
420 }
421}
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:303
void SetAlias(const char *aliasLine)
Definition: G4UImanager.cc:706
G4String FindMacroPath(const G4String &fname) const
Definition: G4UImanager.cc:793

Referenced by ForeachS(), and Loop().

◆ ForeachS()

void G4UImanager::ForeachS ( const char *  valueList)

Definition at line 365 of file G4UImanager.cc.

366{
367 G4String vl = valueList;
368 G4Tokenizer parameterToken(vl);
369 G4String mf = parameterToken();
370 G4String vn = parameterToken();
371 G4String c1 = parameterToken();
372 G4String ca;
373 while(!((ca = parameterToken()).isNull()))
374 {
375 c1 += " ";
376 c1 += ca;
377 }
378
379 G4String aliasValue = c1;
380 if(aliasValue(0) == '"')
381 {
382 G4String strippedValue;
383 if(aliasValue(aliasValue.length() - 1) == '"')
384 {
385 strippedValue = aliasValue(1, aliasValue.length() - 2);
386 }
387 else
388 {
389 strippedValue = aliasValue(1, aliasValue.length() - 1);
390 }
391 aliasValue = strippedValue;
392 }
393
394 // Foreach(mf,vn,c1);
395 Foreach(mf, vn, aliasValue);
396}
void Foreach(const char *macroFile, const char *variableName, const char *candidates)
Definition: G4UImanager.cc:399

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ GetCommandStack()

std::vector< G4String > * G4UImanager::GetCommandStack ( )

Definition at line 810 of file G4UImanager.cc.

811{
812 std::vector<G4String>* returnValue = commandStack;
813 commandStack = new std::vector<G4String>;
814 return returnValue;
815}

Referenced by G4MTRunManager::PrepareCommandsStack().

◆ GetCurrentDoubleValue() [1/2]

G4double G4UImanager::GetCurrentDoubleValue ( const char *  aCommand,
const char *  aParameterName,
G4bool  reGet = true 
)

Definition at line 244 of file G4UImanager.cc.

247{
248 G4String targetParameter =
249 GetCurrentStringValue(aCommand, aParameterName, reGet);
250 G4double value;
251 const char* t = targetParameter;
252 std::istringstream is(t);
253 is >> value;
254 return value;
255}
double G4double
Definition: G4Types.hh:83
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:177

◆ GetCurrentDoubleValue() [2/2]

G4double G4UImanager::GetCurrentDoubleValue ( const char *  aCommand,
G4int  parameterNumber = 1,
G4bool  reGet = true 
)

Definition at line 258 of file G4UImanager.cc.

260{
261 G4String targetParameter =
262 GetCurrentStringValue(aCommand, parameterNumber, reGet);
263 G4double value;
264 const char* t = targetParameter;
265 std::istringstream is(t);
266 is >> value;
267 return value;
268}

◆ GetCurrentIntValue() [1/2]

G4int G4UImanager::GetCurrentIntValue ( const char *  aCommand,
const char *  aParameterName,
G4bool  reGet = true 
)

Definition at line 218 of file G4UImanager.cc.

220{
221 G4String targetParameter =
222 GetCurrentStringValue(aCommand, aParameterName, reGet);
223 G4int value;
224 const char* t = targetParameter;
225 std::istringstream is(t);
226 is >> value;
227 return value;
228}

◆ GetCurrentIntValue() [2/2]

G4int G4UImanager::GetCurrentIntValue ( const char *  aCommand,
G4int  parameterNumber = 1,
G4bool  reGet = true 
)

Definition at line 231 of file G4UImanager.cc.

233{
234 G4String targetParameter =
235 GetCurrentStringValue(aCommand, parameterNumber, reGet);
236 G4int value;
237 const char* t = targetParameter;
238 std::istringstream is(t);
239 is >> value;
240 return value;
241}

Referenced by G4TheMTRayTracer::Trace(), and G4TheRayTracer::Trace().

◆ GetCurrentStringValue() [1/2]

G4String G4UImanager::GetCurrentStringValue ( const char *  aCommand,
const char *  aParameterName,
G4bool  reGet = true 
)

Definition at line 201 of file G4UImanager.cc.

204{
205 if(reGet || savedCommand == nullptr)
206 {
207 G4String parameterValues = GetCurrentValues(aCommand);
208 }
209 for(std::size_t i = 0; i < savedCommand->GetParameterEntries(); ++i)
210 {
211 if(aParameterName == savedCommand->GetParameter(i)->GetParameterName())
212 return GetCurrentStringValue(aCommand, i + 1, false);
213 }
214 return G4String();
215}
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:138
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:139
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:164
const G4String & GetParameterName() const

◆ GetCurrentStringValue() [2/2]

G4String G4UImanager::GetCurrentStringValue ( const char *  aCommand,
G4int  parameterNumber = 1,
G4bool  reGet = true 
)

Definition at line 177 of file G4UImanager.cc.

179{
180 if(reGet || savedCommand == nullptr)
181 {
182 savedParameters = GetCurrentValues(aCommand);
183 }
184 G4Tokenizer savedToken(savedParameters);
185 G4String token;
186 for(G4int i_thParameter = 0; i_thParameter < parameterNumber; ++i_thParameter)
187 {
188 token = savedToken();
189 if(token.isNull())
190 return G4String();
191 if(token[(size_t) 0] == '"')
192 {
193 token.append(" ");
194 token.append(savedToken("\""));
195 }
196 }
197 return token;
198}
G4String & append(const G4String &)

Referenced by GetCurrentDoubleValue(), GetCurrentIntValue(), and GetCurrentStringValue().

◆ GetCurrentValues()

G4String G4UImanager::GetCurrentValues ( const char *  aCommand)

Definition at line 164 of file G4UImanager.cc.

165{
166 G4String theCommand = aCommand;
167 savedCommand = treeTop->FindPath(theCommand);
168 if(savedCommand == nullptr)
169 {
170 G4cerr << "command not found" << G4endl;
171 return G4String();
172 }
173 return savedCommand->GetCurrentValue();
174}
G4String GetCurrentValue()
Definition: G4UIcommand.cc:267

Referenced by GetCurrentStringValue(), G4UIcontrolMessenger::SetNewValue(), and G4VBasicShell::ShowCurrent().

◆ GetG4UIWindow()

G4UIsession * G4UImanager::GetG4UIWindow ( ) const
inline

Definition at line 181 of file G4UImanager.hh.

181{ return g4UIWindow; }

◆ GetLastReturnCode()

G4int G4UImanager::GetLastReturnCode ( ) const
inline

Definition at line 247 of file G4UImanager.hh.

247{ return lastRC; }

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ GetMacroSearchPath()

const G4String & G4UImanager::GetMacroSearchPath ( ) const
inline

Definition at line 208 of file G4UImanager.hh.

208{ return searchPath; }

Referenced by G4UIcontrolMessenger::GetCurrentValue().

◆ GetMasterUIpointer()

G4UImanager * G4UImanager::GetMasterUIpointer ( )
static

Definition at line 91 of file G4UImanager.cc.

92{
93 return fMasterUImanager();
94}

Referenced by G4UIbridge::G4UIbridge().

◆ GetMaxHistSize()

G4int G4UImanager::GetMaxHistSize ( ) const
inline

Definition at line 205 of file G4UImanager.hh.

205{ return maxHistSize; }

Referenced by G4UIcontrolMessenger::GetCurrentValue().

◆ GetNumberOfHistory()

G4int G4UImanager::GetNumberOfHistory ( ) const
inline

Definition at line 194 of file G4UImanager.hh.

194{ return G4int(histVec.size()); }

Referenced by G4VBasicShell::ApplyShellCommand(), G4UIGAG::GetCommand(), and G4UIGainServer::GetCommand().

◆ GetPauseAtBeginOfEvent()

G4bool G4UImanager::GetPauseAtBeginOfEvent ( ) const
inline

Definition at line 171 of file G4UImanager.hh.

171{ return pauseAtBeginOfEvent; }

◆ GetPauseAtEndOfEvent()

G4bool G4UImanager::GetPauseAtEndOfEvent ( ) const
inline

Definition at line 173 of file G4UImanager.hh.

173{ return pauseAtEndOfEvent; }

◆ GetPreviousCommand()

G4String G4UImanager::GetPreviousCommand ( G4int  i) const
inline

Definition at line 195 of file G4UImanager.hh.

196 {
197 G4String st;
198 if(i >= 0 && i < G4int(histVec.size()))
199 {
200 st = histVec[i];
201 }
202 return st;
203 }

Referenced by G4VBasicShell::ApplyShellCommand(), G4UIGAG::GetCommand(), and G4UIGainServer::GetCommand().

◆ GetSession()

G4UIsession * G4UImanager::GetSession ( ) const
inline

Definition at line 180 of file G4UImanager.hh.

180{ return session; }

Referenced by G4VisCommandReviewKeptEvents::SetNewValue().

◆ GetThreadCout()

G4MTcoutDestination * G4UImanager::GetThreadCout ( )
inline

Definition at line 242 of file G4UImanager.hh.

242{ return threadCout; }

◆ GetThreadID()

G4int G4UImanager::GetThreadID ( ) const
inline

Definition at line 232 of file G4UImanager.hh.

232{ return threadID; }

◆ GetTree()

◆ GetUIpointer()

G4UImanager * G4UImanager::GetUIpointer ( )
static

Definition at line 77 of file G4UImanager.cc.

78{
79 if(fUImanager() == nullptr)
80 {
81 if(!fUImanagerHasBeenKilled())
82 {
83 fUImanager() = new G4UImanager;
84 fUImanager()->CreateMessenger();
85 }
86 }
87 return fUImanager();
88}

Referenced by G4VBasicShell::ApplyShellCommand(), G4RunManagerKernel::BuildPhysicsTables(), G4VVisCommand::CheckSceneAndNotifyHandlers(), G4VBasicShell::Complete(), G4TaskRunManager::CreateAndStartWorkers(), G4TheMTRayTracer::CreateBitMap(), G4CascadeParamMessenger::CreateDirectory(), G4UImessenger::CreateDirectory(), G4WorkerRunManager::DoWork(), G4VBasicShell::ExecuteCommand(), G4VBasicShell::FindCommand(), G4VBasicShell::FindDirectory(), G4MTRunManager::G4MTRunManager(), G4TaskRunManager::G4TaskRunManager(), G4UIbatch::G4UIbatch(), G4UIGAG::G4UIGAG(), G4UIGainServer::G4UIGainServer(), G4UIterminal::G4UIterminal(), G4VisCommandDrawLogicalVolume::G4VisCommandDrawLogicalVolume(), G4VisCommandDrawVolume::G4VisCommandDrawVolume(), G4VisCommandSceneAddMagneticField::G4VisCommandSceneAddMagneticField(), G4WorkerRunManager::G4WorkerRunManager(), G4RunManager::GeometryHasBeenModified(), G4VisManager::GeometryHasChanged(), G4VUIshell::GetCommandTree(), G4UIcontrolMessenger::GetCurrentValue(), G4TaskRunManagerKernel::InitializeWorker(), G4VVisCommand::InterpolateViews(), G4VisManager::NotifyHandlers(), G4MTRunManager::PrepareCommandsStack(), G4RunManager::ProcessOneEvent(), G4WorkerRunManager::ProcessOneEvent(), G4WorkerTaskRunManager::ProcessOneEvent(), G4WorkerTaskRunManager::ProcessUI(), G4VVisCommand::RefreshIfRequired(), G4RunManager::ReinitializeGeometry(), G4TaskRunManager::RequestWorkersProcessCommandsStack(), G4RunManager::rndmSaveThisEvent(), G4WorkerRunManager::rndmSaveThisEvent(), G4MTRunManager::rndmSaveThisRun(), G4RunManager::rndmSaveThisRun(), G4WorkerRunManager::rndmSaveThisRun(), G4UIbatch::SessionStart(), G4VVisCommandGeometrySet::Set(), G4LocalThreadCoutMessenger::SetNewValue(), G4OpticalParametersMessenger::SetNewValue(), G4EmExtraParametersMessenger::SetNewValue(), G4EmLowEParametersMessenger::SetNewValue(), G4EmParametersMessenger::SetNewValue(), G4UIcontrolMessenger::SetNewValue(), G4VisCommandList::SetNewValue(), G4VisCommandReviewKeptEvents::SetNewValue(), G4VisCommandDrawTree::SetNewValue(), G4VisCommandDrawView::SetNewValue(), G4VisCommandDrawLogicalVolume::SetNewValue(), G4VisCommandDrawVolume::SetNewValue(), G4VisCommandOpen::SetNewValue(), G4VisCommandSpecify::SetNewValue(), G4VisCommandGeometryRestore::SetNewValue(), G4VisCommandSceneAddTrajectories::SetNewValue(), G4VisCommandSceneHandlerCreate::SetNewValue(), G4VisCommandsTouchable::SetNewValue(), G4VisCommandsTouchableSet::SetNewValue(), G4VisCommandViewerClone::SetNewValue(), G4VisCommandViewerCreate::SetNewValue(), G4VisCommandViewerFlush::SetNewValue(), G4VisCommandViewerInterpolate::SetNewValue(), G4ProcessManagerMessenger::SetNewValue(), G4ProcessTableMessenger::SetNewValue(), G4RunMessenger::SetNewValue(), G4TrackingMessenger::SetNewValue(), G4VisCommandGeometrySetVisibility::SetNewValueOnLV(), G4VViewer::SetTouchable(), G4VBasicShell::ShowCurrent(), G4MTRunManagerKernel::StartThread(), G4VBasicShell::TerminalHelp(), G4VViewer::TouchableSetColour(), G4VViewer::TouchableSetVisibility(), G4TheMTRayTracer::Trace(), G4TheRayTracer::Trace(), G4RunManagerKernel::~G4RunManagerKernel(), G4UIcommand::~G4UIcommand(), G4UIGAG::~G4UIGAG(), G4UIGainServer::~G4UIGainServer(), and G4UIterminal::~G4UIterminal().

◆ GetVerboseLevel()

◆ ListAlias()

void G4UImanager::ListAlias ( )

Definition at line 738 of file G4UImanager.cc.

739{
740 aliasList->List();
741}

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ ListCommands()

void G4UImanager::ListCommands ( const char *  direc)

Definition at line 632 of file G4UImanager.cc.

633{
634 G4UIcommandTree* comTree = FindDirectory(direct);
635 if(comTree != nullptr)
636 {
637 comTree->List();
638 }
639 else
640 {
641 G4cout << direct << " is not found." << G4endl;
642 }
643}
void List() const

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ Loop()

void G4UImanager::Loop ( const char *  macroFile,
const char *  variableName,
G4double  initialValue,
G4double  finalValue,
G4double  stepSize = 1.0 
)

Definition at line 336 of file G4UImanager.cc.

339{
340 G4String cd;
341 if(stepSize > 0)
342 {
343 for(G4double d = initialValue; d <= finalValue; d += stepSize)
344 {
345 std::ostringstream os;
346 os << d;
347 cd += os.str();
348 cd += " ";
349 }
350 }
351 else
352 {
353 for(G4double d = initialValue; d >= finalValue; d += stepSize)
354 {
355 std::ostringstream os;
356 os << d;
357 cd += os.str();
358 cd += " ";
359 }
360 }
361 Foreach(macroFile, variableName, cd);
362}

Referenced by LoopS().

◆ LoopS()

void G4UImanager::LoopS ( const char *  valueList)

Definition at line 315 of file G4UImanager.cc.

316{
317 G4String vl = valueList;
318 G4Tokenizer parameterToken(vl);
319 G4String mf = parameterToken();
320 G4String vn = parameterToken();
321 G4String c1 = parameterToken();
322 c1 += " ";
323 c1 += parameterToken();
324 c1 += " ";
325 c1 += parameterToken();
326 const char* t1 = c1;
327 std::istringstream is(t1);
328 G4double d1;
329 G4double d2;
330 G4double d3;
331 is >> d1 >> d2 >> d3;
332 Loop(mf, vn, d1, d2, d3);
333}
void Loop(const char *macroFile, const char *variableName, G4double initialValue, G4double finalValue, G4double stepSize=1.0)
Definition: G4UImanager.cc:336

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ Notify()

G4bool G4UImanager::Notify ( G4ApplicationState  requestedState)
virtual

Implements G4VStateDependent.

Definition at line 675 of file G4UImanager.cc.

676{
677 if(pauseAtBeginOfEvent)
678 {
679 if(requestedState == G4State_EventProc &&
680 G4StateManager::GetStateManager()->GetPreviousState() ==
682 {
683 PauseSession("BeginOfEvent");
684 }
685 }
686 if(pauseAtEndOfEvent)
687 {
688 if(requestedState == G4State_GeomClosed &&
689 G4StateManager::GetStateManager()->GetPreviousState() ==
691 {
692 PauseSession("EndOfEvent");
693 }
694 }
695 return true;
696}
@ G4State_EventProc
@ G4State_GeomClosed
static G4StateManager * GetStateManager()

◆ operator!=()

G4bool G4UImanager::operator!= ( const G4UImanager ) const
delete

◆ operator=()

const G4UImanager & G4UImanager::operator= ( const G4UImanager )
delete

◆ operator==()

G4bool G4UImanager::operator== ( const G4UImanager ) const
delete

◆ ParseMacroSearchPath()

void G4UImanager::ParseMacroSearchPath ( )

Definition at line 758 of file G4UImanager.cc.

759{
760 searchDirs.clear();
761
762 std::size_t idxfirst = 0;
763 std::size_t idxend = 0;
764 G4String pathstring = "";
765 while((idxend = searchPath.index(':', idxfirst)) != G4String::npos)
766 {
767 pathstring = searchPath.substr(idxfirst, idxend - idxfirst);
768 if(pathstring.size() != 0)
769 searchDirs.push_back(pathstring);
770 idxfirst = idxend + 1;
771 }
772
773 pathstring = searchPath.substr(idxfirst, searchPath.size() - idxfirst);
774 if(pathstring.size() != 0)
775 searchDirs.push_back(pathstring);
776}

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ RegisterBridge()

void G4UImanager::RegisterBridge ( G4UIbridge brg)

Definition at line 818 of file G4UImanager.cc.

819{
820 if(brg->LocalUI() == this)
821 {
822 G4Exception("G4UImanager::RegisterBridge()", "UI7002", FatalException,
823 "G4UIBridge cannot bridge between same object.");
824 }
825 else
826 {
827 bridges->push_back(brg);
828 }
829}
@ FatalException
G4UImanager * LocalUI() const
Definition: G4UIbridge.hh:55

Referenced by G4UIbridge::G4UIbridge().

◆ RemoveAlias()

void G4UImanager::RemoveAlias ( const char *  aliasName)

Definition at line 730 of file G4UImanager.cc.

731{
732 G4String aL = aliasName;
733 G4String targetAlias = aL.strip(G4String::both);
734 aliasList->RemoveAlias(targetAlias);
735}
G4String strip(G4int strip_Type=trailing, char c=' ')
void RemoveAlias(const char *aliasName)

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ RemoveCommand()

void G4UImanager::RemoveCommand ( G4UIcommand aCommand)

Definition at line 287 of file G4UImanager.cc.

288{
289 treeTop->RemoveCommand(aCommand);
290 if(fMasterUImanager() != nullptr && G4Threading::G4GetThreadId() == 0)
291 {
292 fMasterUImanager()->RemoveWorkerCommand(aCommand);
293 }
294}
void RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly=false)

Referenced by G4UIcommand::~G4UIcommand().

◆ SetAlias()

void G4UImanager::SetAlias ( const char *  aliasLine)

Definition at line 706 of file G4UImanager.cc.

707{
708 G4String aLine = aliasLine;
709 G4int i = aLine.index(" ");
710 G4String aliasName = aLine(0, i);
711 G4String aliasValue = aLine(i + 1, aLine.length() - (i + 1));
712 if(aliasValue(0) == '"')
713 {
714 G4String strippedValue;
715 if(aliasValue(aliasValue.length() - 1) == '"')
716 {
717 strippedValue = aliasValue(1, aliasValue.length() - 2);
718 }
719 else
720 {
721 strippedValue = aliasValue(1, aliasValue.length() - 1);
722 }
723 aliasValue = strippedValue;
724 }
725
726 aliasList->ChangeAlias(aliasName, aliasValue);
727}
void ChangeAlias(const char *aliasName, const char *aliasValue)

Referenced by Foreach(), and G4UIcontrolMessenger::SetNewValue().

◆ SetCerrFileName()

void G4UImanager::SetCerrFileName ( const G4String fileN = "G4cerr.txt",
G4bool  ifAppend = true 
)

Definition at line 871 of file G4UImanager.cc.

872{
873 // for sequential mode, ignore this method.
874 if(threadID < 0)
875 return;
876
877 if(fileN == "**Screen**")
878 {
879 threadCout->SetCerrFileName(fileN, ifAppend);
880 }
881 else
882 {
883 std::stringstream fn;
884 fn << "G4W_" << threadID << "_" << fileN;
885 threadCout->SetCerrFileName(fn.str(), ifAppend);
886 }
887}
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

◆ SetCoutDestination()

void G4UImanager::SetCoutDestination ( G4UIsession *const  value)

Definition at line 699 of file G4UImanager.cc.

700{
703}
G4GLOB_DLL G4strstreambuf G4coutbuf
Definition: G4ios.cc:108
G4GLOB_DLL G4strstreambuf G4cerrbuf
Definition: G4ios.cc:109
void SetDestination(G4coutDestination *dest)

Referenced by G4UIGAG::G4UIGAG(), G4UImanager(), G4UIGAG::~G4UIGAG(), G4UIGainServer::~G4UIGainServer(), and ~G4UImanager().

◆ SetCoutFileName()

void G4UImanager::SetCoutFileName ( const G4String fileN = "G4cout.txt",
G4bool  ifAppend = true 
)

Definition at line 852 of file G4UImanager.cc.

853{
854 // for sequential mode, ignore this method.
855 if(threadID < 0)
856 return;
857
858 if(fileN == "**Screen**")
859 {
860 threadCout->SetCoutFileName(fileN, ifAppend);
861 }
862 else
863 {
864 std::stringstream fn;
865 fn << "G4W_" << threadID << "_" << fileN;
866 threadCout->SetCoutFileName(fn.str(), ifAppend);
867 }
868}
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

◆ SetG4UIWindow()

void G4UImanager::SetG4UIWindow ( G4UIsession *const  value)
inline

Definition at line 184 of file G4UImanager.hh.

184{ g4UIWindow = value; }

◆ SetIgnoreCmdNotFound()

void G4UImanager::SetIgnoreCmdNotFound ( G4bool  val)
inline

Definition at line 222 of file G4UImanager.hh.

222{ ignoreCmdNotFound = val; }

Referenced by G4WorkerRunManager::G4WorkerRunManager().

◆ SetMacroSearchPath()

void G4UImanager::SetMacroSearchPath ( const G4String path)
inline

Definition at line 207 of file G4UImanager.hh.

207{ searchPath = path; }

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ SetMasterUIManager()

void G4UImanager::SetMasterUIManager ( G4bool  val)
inline

Definition at line 212 of file G4UImanager.hh.

213 {
214 isMaster = val;
215 stackCommandsForBroadcast = val;
216 if(val && !bridges)
217 {
218 bridges = new std::vector<G4UIbridge*>;
219 fMasterUImanager() = this;
220 }
221 }

Referenced by G4MTRunManager::G4MTRunManager(), and G4TaskRunManager::G4TaskRunManager().

◆ SetMaxHistSize()

void G4UImanager::SetMaxHistSize ( G4int  mx)
inline

Definition at line 204 of file G4UImanager.hh.

204{ maxHistSize = mx; }

Referenced by G4UIcontrolMessenger::SetNewValue().

◆ SetPauseAtBeginOfEvent()

void G4UImanager::SetPauseAtBeginOfEvent ( G4bool  vl)
inline

Definition at line 170 of file G4UImanager.hh.

170{ pauseAtBeginOfEvent = vl; }

Referenced by G4RunMessenger::SetNewValue().

◆ SetPauseAtEndOfEvent()

void G4UImanager::SetPauseAtEndOfEvent ( G4bool  vl)
inline

Definition at line 172 of file G4UImanager.hh.

172{ pauseAtEndOfEvent = vl; }

Referenced by G4RunMessenger::SetNewValue().

◆ SetSession()

void G4UImanager::SetSession ( G4UIsession *const  value)
inline

Definition at line 183 of file G4UImanager.hh.

183{ session = value; }

Referenced by G4UIbatch::G4UIbatch(), G4UIGAG::G4UIGAG(), G4UIGAG::~G4UIGAG(), and G4UIGainServer::~G4UIGainServer().

◆ SetThreadIgnore()

void G4UImanager::SetThreadIgnore ( G4int  tid = 0)

Definition at line 908 of file G4UImanager.cc.

909{
910 // for sequential mode, ignore this method.
911 if(threadID < 0)
912 {
913 igThreadID = tid;
914 return;
915 }
916 threadCout->SetIgnoreCout(tid);
917}
void SetIgnoreCout(G4int tid=0)

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

◆ SetThreadIgnoreInit()

void G4UImanager::SetThreadIgnoreInit ( G4bool  flg = true)

Definition at line 920 of file G4UImanager.cc.

921{
922 // for sequential mode, ignore this method.
923 if(threadID < 0)
924 {
925 return;
926 }
927 threadCout->SetIgnoreInit(flg);
928}
void SetIgnoreInit(G4bool val=true)

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

◆ SetThreadPrefixString()

void G4UImanager::SetThreadPrefixString ( const G4String s = "W")

Definition at line 890 of file G4UImanager.cc.

891{
892 // for sequential mode, ignore this method.
893 if(threadID < 0)
894 return;
895 threadCout->SetPrefixString(s);
896}
void SetPrefixString(const G4String &wd="G4WT")

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

◆ SetThreadUseBuffer()

void G4UImanager::SetThreadUseBuffer ( G4bool  flg = true)

Definition at line 899 of file G4UImanager.cc.

900{
901 // for sequential mode, ignore this method.
902 if(threadID < 0)
903 return;
904 threadCout->EnableBuffering(flg);
905}
void EnableBuffering(G4bool flag=true)

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

◆ SetUpForAThread()

void G4UImanager::SetUpForAThread ( G4int  tId)

Definition at line 832 of file G4UImanager.cc.

833{
834 threadID = tId;
836 threadCout = new G4MTcoutDestination(threadID);
837 threadCout->SetIgnoreCout(igThreadID);
838}
void G4iosInitialization()
Definition: G4ios.cc:111

Referenced by G4TaskRunManagerKernel::InitializeWorker(), and G4MTRunManagerKernel::StartThread().

◆ SetUpForSpecialThread()

void G4UImanager::SetUpForSpecialThread ( G4String  aPrefix)

Definition at line 841 of file G4UImanager.cc.

842{
846 threadCout = new G4MTcoutDestination(threadID);
847 threadCout->SetPrefixString(pref);
848 threadCout->SetIgnoreCout(igThreadID);
849}
void G4SetThreadId(G4int aNewValue)
Definition: G4Threading.cc:125

◆ SetVerboseLevel()

◆ SolveAlias()

G4String G4UImanager::SolveAlias ( const char *  aCmd)

Definition at line 424 of file G4UImanager.cc.

425{
426 G4String aCommand = aCmd;
427 G4int ia = aCommand.index("{");
428 G4int iz = aCommand.index("#");
429 while((ia != G4int(std::string::npos)) &&
430 ((iz == G4int(std::string::npos)) || (ia < iz)))
431 {
432 G4int ibx = -1;
433 while(ibx < 0)
434 {
435 G4int ib = aCommand.index("}");
436 if(ib == G4int(std::string::npos))
437 {
438 G4cerr << aCommand << G4endl;
439 for(G4int i = 0; i < ia; ++i)
440 G4cerr << " ";
441 G4cerr << "^" << G4endl;
442 G4cerr << "Unmatched alias parenthesis -- command ignored" << G4endl;
443 G4String nullStr;
444 return nullStr;
445 }
446 G4String ps = aCommand(ia + 1, aCommand.length() - (ia + 1));
447 G4int ic = ps.index("{");
448 G4int id = ps.index("}");
449 if(ic != G4int(std::string::npos) && ic < id)
450 {
451 ia += ic + 1;
452 }
453 else
454 {
455 ibx = ib;
456 }
457 }
458 //--- Here ia represents the position of innermost "{"
459 //--- and ibx represents corresponding "}"
460 G4String subs;
461 if(ia > 0)
462 subs = aCommand(0, ia);
463 G4String alis = aCommand(ia + 1, ibx - ia - 1);
464 G4String rems = aCommand(ibx + 1, aCommand.length() - ibx);
465 G4String* alVal = aliasList->FindAlias(alis);
466 if(!alVal)
467 {
468 G4cerr << "Alias <" << alis << "> not found -- command ignored" << G4endl;
469 G4String nullStr;
470 return nullStr;
471 }
472 aCommand = subs + (*alVal) + rems;
473 ia = aCommand.index("{");
474 }
475 return aCommand;
476}
G4String * FindAlias(const char *aliasName)

Referenced by ApplyCommand(), and G4UIcontrolMessenger::SetNewValue().

◆ StoreHistory() [1/2]

void G4UImanager::StoreHistory ( const char *  fileName = "G4history.macro")

Definition at line 599 of file G4UImanager.cc.

600{
601 StoreHistory(true, fileName);
602}
void StoreHistory(const char *fileName="G4history.macro")
Definition: G4UImanager.cc:599

Referenced by G4UIcontrolMessenger::SetNewValue(), and StoreHistory().

◆ StoreHistory() [2/2]

void G4UImanager::StoreHistory ( G4bool  historySwitch,
const char *  fileName = "G4history.macro" 
)

Definition at line 605 of file G4UImanager.cc.

606{
607 if(historySwitch)
608 {
609 if(saveHistory)
610 {
611 historyFile.close();
612 }
613 historyFile.open((char*) fileName);
614 saveHistory = true;
615 }
616 else
617 {
618 historyFile.close();
619 saveHistory = false;
620 }
621 saveHistory = historySwitch;
622}

◆ UseDoublePrecisionStr()

void G4UImanager::UseDoublePrecisionStr ( G4bool  val)
static

Definition at line 152 of file G4UImanager.cc.

153{
154 doublePrecisionStr = val;
155}

Referenced by G4UIcontrolMessenger::SetNewValue().


The documentation for this class was generated from the following files: