Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions
G4UImanager Class Reference

#include <G4UImanager.hh>

Inheritance diagram for G4UImanager:
G4VStateDependent

Public Member Functions

 ~G4UImanager ()
 
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 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)
 
- Public Member Functions inherited from G4VStateDependent
 G4VStateDependent (G4bool bottom=false)
 
virtual ~G4VStateDependent ()
 
G4int operator== (const G4VStateDependent &right) const
 
G4int operator!= (const G4VStateDependent &right) const
 

Static Public Member Functions

static G4UImanagerGetUIpointer ()
 
static G4UImanagerGetMasterUIpointer ()
 

Protected Member Functions

 G4UImanager ()
 

Detailed Description

Definition at line 56 of file G4UImanager.hh.

Constructor & Destructor Documentation

G4UImanager::G4UImanager ( )
protected

Definition at line 74 of file G4UImanager.cc.

References SetCoutDestination().

Referenced by GetUIpointer().

75  : G4VStateDependent(true),
76  UImessenger(0), UnitsMessenger(0), CoutMessenger(0),
77  isMaster(false),bridges(0),
78  ignoreCmdNotFound(false), stackCommandsForBroadcast(false),
79  threadID(-1), threadCout(0)
80 {
81  savedCommand = 0;
82  treeTop = new G4UIcommandTree("/");
83  aliasList = new G4UIaliasList;
84  G4String nullString;
85  savedParameters = nullString;
86  verboseLevel = 0;
87  saveHistory = false;
88  session = NULL;
89  g4UIWindow = NULL;
90  SetCoutDestination(session);
91  pauseAtBeginOfEvent = false;
92  pauseAtEndOfEvent = false;
93  maxHistSize = 20;
94  searchPath="";
95  commandStack = new std::vector<G4String>;
96 }
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:591
G4VStateDependent(G4bool bottom=false)
G4UImanager::~G4UImanager ( )

Definition at line 105 of file G4UImanager.cc.

References G4iosFinalization(), and SetCoutDestination().

106 {
107  if(bridges)
108  {
109  std::vector<G4UIbridge*>::iterator itr = bridges->begin();
110  for(;itr!=bridges->end();itr++)
111  { delete *itr; }
112  delete bridges;
113  }
114  SetCoutDestination(NULL);
115  histVec.clear();
116  if(saveHistory) historyFile.close();
117  delete CoutMessenger;
118  delete UnitsMessenger;
119  delete UImessenger;
120  delete treeTop;
121  delete aliasList;
122  fUImanagerHasBeenKilled = true;
123  fUImanager = NULL;
124  if(commandStack)
125  {
126  commandStack->clear();
127  delete commandStack;
128  }
129  if(threadID >= 0)
130  {
131  if(threadCout) delete threadCout;
133  threadID = -1;
134  }
135 }
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:591
void G4iosFinalization()
Definition: G4ios.cc:86

Member Function Documentation

void G4UImanager::AddNewCommand ( G4UIcommand newCommand)

Definition at line 254 of file G4UImanager.cc.

References G4UIcommandTree::AddNewCommand(), and G4Threading::G4GetThreadId().

255 {
256  treeTop->AddNewCommand( newCommand );
257  if(fMasterUImanager!=0&&G4Threading::G4GetThreadId()==0)
258  { fMasterUImanager->AddWorkerCommand(newCommand); }
259 }
void AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly=false)
G4int G4GetThreadId()
Definition: G4Threading.cc:103
G4int G4UImanager::ApplyCommand ( const char *  aCommand)

Definition at line 419 of file G4UImanager.cc.

References G4UIcommand::DoIt(), fAliasNotFound, fCommandNotFound, fCommandSucceeded, fIllegalApplicationState, G4UIcommandTree::FindPath(), G4cout, G4endl, G4String::index(), G4UIcommand::IsAvailable(), G4String::isNull(), G4String::remove(), SolveAlias(), and G4UIcommand::ToBeBroadcasted().

Referenced by G4UIbridge::ApplyCommand(), ApplyCommand(), CCalRunAction::BeginOfRunAction(), ExGflashRunAction::BeginOfRunAction(), FCALRunAction::BeginOfRunAction(), exrdmRunAction::BeginOfRunAction(), F02RunAction::BeginOfRunAction(), F03RunAction::BeginOfRunAction(), F01RunAction::BeginOfRunAction(), ExG4RunAction01::BeginOfRunAction(), Em10RunAction::BeginOfRunAction(), GammaRayTelRunAction::BeginOfRunAction(), XrayFluoRunAction::BeginOfRunAction(), XrayTelRunAction::BeginOfRunAction(), G4RunManagerKernel::BuildPhysicsTables(), exrdmDetectorConstruction::Construct(), G4TheMTRayTracer::CreateBitMap(), CCalRunAction::EndOfRunAction(), ExGflashRunAction::EndOfRunAction(), exrdmRunAction::EndOfRunAction(), FCALRunAction::EndOfRunAction(), F02RunAction::EndOfRunAction(), F03RunAction::EndOfRunAction(), F01RunAction::EndOfRunAction(), ExG4RunAction01::EndOfRunAction(), G03RunAction::EndOfRunAction(), Em10RunAction::EndOfRunAction(), G02RunAction::EndOfRunAction(), XrayFluoRunAction::EndOfRunAction(), XrayTelRunAction::EndOfRunAction(), tbbTask::execute(), G4VBasicShell::ExecuteCommand(), G4RunManager::GeometryHasBeenModified(), Initialize(), main(), G4WorkerRunManager::ProcessOneEvent(), G4RunManager::ProcessOneEvent(), G4VVisCommandViewer::RefreshIfRequired(), G4RunManager::ReinitializeGeometry(), G4RunManager::rndmSaveThisEvent(), G4RunManager::rndmSaveThisRun(), XrayFluoSimulation::RunSimulation(), G4VVisCommandGeometrySet::Set(), LXeDetectorConstruction::SetDefaults(), G4VisCommandDrawTree::SetNewValue(), PerspectiveVisActionMessenger::SetNewValue(), G4VisCommandDrawView::SetNewValue(), G4VisCommandDrawVolume::SetNewValue(), G4TrackingMessenger::SetNewValue(), CML2PhantomConstructionMessenger::SetNewValue(), CML2AcceleratorConstructionMessenger::SetNewValue(), G4VisCommandGeometryRestore::SetNewValue(), G4ProcessTableMessenger::SetNewValue(), G4VisCommandOpen::SetNewValue(), G4UIcontrolMessenger::SetNewValue(), G4EmManagerMessenger::SetNewValue(), G4ProcessManagerMessenger::SetNewValue(), G4VisCommandList::SetNewValue(), G4EnergyLossMessenger::SetNewValue(), G4VisCommandSpecify::SetNewValue(), G4VisCommandReviewKeptEvents::SetNewValue(), G4VisCommandViewerClone::SetNewValue(), G4VisCommandViewerCreate::SetNewValue(), G4VisCommandViewerFlush::SetNewValue(), G4VisCommandSceneAddTrajectories::SetNewValue(), G4VisCommandGeometrySetVisibility::SetNewValueOnLV(), G4MTRunManagerKernel::StartThread(), G4TheRayTracer::Trace(), and G4TheMTRayTracer::Trace().

420 {
421  G4String aCommand = SolveAlias(aCmd);
422  if(aCommand.isNull()) return fAliasNotFound;
423  if(verboseLevel) G4cout << aCommand << G4endl;
424  G4String commandString;
425  G4String commandParameter;
426 
427  G4int i = aCommand.index(" ");
428  if( i != G4int(std::string::npos) )
429  {
430  commandString = aCommand(0,i);
431  commandParameter = aCommand(i+1,aCommand.length()-(i+1));
432  }
433  else
434  {
435  commandString = aCommand;
436  }
437 
438  // remove doubled slash
439  G4int len = commandString.length();
440  G4int ll = 0;
441  G4String a1;
442  G4String a2;
443  while(ll<len-1)
444  {
445  if(commandString(ll,2)=="//")
446  {
447  if(ll==0)
448  { commandString.remove(ll,1); }
449  else
450  {
451  a1 = commandString(0,ll);
452  a2 = commandString(ll+1,len-ll-1);
453  commandString = a1+a2;
454  }
455  len--;
456  }
457  else
458  { ll++; }
459  }
460 
461  if(isMaster&&bridges)
462  {
463  std::vector<G4UIbridge*>::iterator itr = bridges->begin();
464  for(;itr!=bridges->end();itr++)
465  {
466  G4int leng = (*itr)->DirLength();
467  if(commandString(0,leng)==(*itr)->DirName())
468  { return (*itr)->LocalUI()->ApplyCommand(commandString+" "+commandParameter); }
469  }
470  }
471 
472  G4UIcommand * targetCommand = treeTop->FindPath( commandString );
473  if( targetCommand == NULL )
474  {
475  if(ignoreCmdNotFound)
476  {
477  if(stackCommandsForBroadcast)
478  { commandStack->push_back(commandString+" "+commandParameter); }
479  return fCommandSucceeded;
480  }
481  else
482  { return fCommandNotFound; }
483  }
484 
485  if(stackCommandsForBroadcast && targetCommand->ToBeBroadcasted())
486  { commandStack->push_back(commandString+" "+commandParameter); }
487 
488  if(!(targetCommand->IsAvailable()))
489  { return fIllegalApplicationState; }
490 
491  if(saveHistory) historyFile << aCommand << G4endl;
492  if( G4int(histVec.size()) >= maxHistSize )
493  { histVec.erase(histVec.begin()); }
494  histVec.push_back(aCommand);
495 
496  return targetCommand->DoIt( commandParameter );
497 }
G4bool IsAvailable()
Definition: G4UIcommand.cc:275
G4String & remove(str_size)
G4UIcommand * FindPath(const char *commandPath) const
int G4int
Definition: G4Types.hh:78
G4bool ToBeBroadcasted() const
Definition: G4UIcommand.hh:186
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4String SolveAlias(const char *aCmd)
Definition: G4UImanager.cc:364
const XML_Char int len
#define G4endl
Definition: G4ios.hh:61
G4bool isNull() const
virtual G4int DoIt(G4String parameterList)
Definition: G4UIcommand.cc:108
G4int G4UImanager::ApplyCommand ( const G4String aCommand)

Definition at line 412 of file G4UImanager.cc.

References ApplyCommand(), and G4String::data().

413 {
414  return ApplyCommand(aCmd.data());
415 }
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
void G4UImanager::CreateHTML ( const char *  dir = "/")

Definition at line 628 of file G4UImanager.cc.

References G4UIcommandTree::CreateHTML(), G4cerr, and G4endl.

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

629 {
630  G4UIcommandTree* tr = FindDirectory(dir);
631  if(tr!=0)
632  { tr->CreateHTML(); }
633  else
634  { G4cerr << "Directory <" << dir << "> is not found." << G4endl; }
635 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
void G4UImanager::ExecuteMacroFile ( const char *  fileName)

Definition at line 278 of file G4UImanager.cc.

References G4UIsession::SessionStart().

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

279 {
280  G4UIsession* batchSession = new G4UIbatch(fileName,session);
281  session = batchSession;
282  G4UIsession* previousSession = session->SessionStart();
283  delete session;
284  session = previousSession;
285 }
virtual G4UIsession * SessionStart()
Definition: G4UIsession.cc:38
G4String G4UImanager::FindMacroPath ( const G4String fname) const

Definition at line 667 of file G4UImanager.cc.

References test::fname.

668 {
669  G4String macrofile = fname;
670 
671  for (size_t i = 0; i < searchDirs.size(); i++) {
672  G4String fullpath = searchDirs[i] + "/" + fname;
673  if ( FileFound(fullpath) ) {
674  macrofile = fullpath;
675  break;
676  }
677  }
678 
679  return macrofile;
680 }
void G4UImanager::Foreach ( const char *  macroFile,
const char *  variableName,
const char *  candidates 
)

Definition at line 347 of file G4UImanager.cc.

References ExecuteMacroFile(), and SetAlias().

Referenced by ForeachS(), and Loop().

349 {
350  G4String candidatesString = candidates;
351  G4Tokenizer parameterToken( candidatesString );
352  G4String cd;
353  while(!((cd=parameterToken()).isNull()))
354  {
355  G4String vl = variableName;
356  vl += " ";
357  vl += cd;
358  SetAlias(vl);
359  ExecuteMacroFile(macroFile);
360  }
361 }
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:278
void SetAlias(const char *aliasLine)
Definition: G4UImanager.cc:597
void G4UImanager::ForeachS ( const char *  valueList)

Definition at line 331 of file G4UImanager.cc.

References plottest35::c1, and Foreach().

Referenced by G4UIcontrolMessenger::SetNewValue().

332 {
333  G4String vl = valueList;
334  G4Tokenizer parameterToken(vl);
335  G4String mf = parameterToken();
336  G4String vn = parameterToken();
337  G4String c1 = parameterToken();
338  G4String ca;
339  while(!((ca=parameterToken()).isNull()))
340  {
341  c1 += " ";
342  c1 += ca;
343  }
344  Foreach(mf,vn,c1);
345 }
void Foreach(const char *macroFile, const char *variableName, const char *candidates)
Definition: G4UImanager.cc:347
tuple c1
Definition: plottest35.py:14
std::vector< G4String > * G4UImanager::GetCommandStack ( )

Definition at line 682 of file G4UImanager.cc.

Referenced by G4MTRunManager::PrepareCommandsStack().

683 {
684  std::vector<G4String>* returnValue = commandStack;
685  commandStack = new std::vector<G4String>;
686  return returnValue;
687 }
G4double G4UImanager::GetCurrentDoubleValue ( const char *  aCommand,
G4int  parameterNumber = 1,
G4bool  reGet = true 
)

Definition at line 242 of file G4UImanager.cc.

References GetCurrentStringValue().

244 {
245  G4String targetParameter =
246  GetCurrentStringValue( aCommand, parameterNumber, reGet );
247  G4double value;
248  const char* t = targetParameter;
249  std::istringstream is(t);
250  is >> value;
251  return value;
252 }
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:168
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76
G4double G4UImanager::GetCurrentDoubleValue ( const char *  aCommand,
const char *  aParameterName,
G4bool  reGet = true 
)

Definition at line 230 of file G4UImanager.cc.

References GetCurrentStringValue().

232 {
233  G4String targetParameter =
234  GetCurrentStringValue( aCommand, aParameterName, reGet );
235  G4double value;
236  const char* t = targetParameter;
237  std::istringstream is(t);
238  is >> value;
239  return value;
240 }
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:168
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76
G4int G4UImanager::GetCurrentIntValue ( const char *  aCommand,
G4int  parameterNumber = 1,
G4bool  reGet = true 
)

Definition at line 218 of file G4UImanager.cc.

References GetCurrentStringValue().

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

220 {
221  G4String targetParameter =
222  GetCurrentStringValue( aCommand, parameterNumber, reGet );
223  G4int value;
224  const char* t = targetParameter;
225  std::istringstream is(t);
226  is >> value;
227  return value;
228 }
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:168
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
G4int G4UImanager::GetCurrentIntValue ( const char *  aCommand,
const char *  aParameterName,
G4bool  reGet = true 
)

Definition at line 206 of file G4UImanager.cc.

References GetCurrentStringValue().

208 {
209  G4String targetParameter =
210  GetCurrentStringValue( aCommand, aParameterName, reGet );
211  G4int value;
212  const char* t = targetParameter;
213  std::istringstream is(t);
214  is >> value;
215  return value;
216 }
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:168
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
G4String G4UImanager::GetCurrentStringValue ( const char *  aCommand,
G4int  parameterNumber = 1,
G4bool  reGet = true 
)

Definition at line 168 of file G4UImanager.cc.

References G4String::append(), GetCurrentValues(), and G4String::isNull().

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

170 {
171  if(reGet || savedCommand == NULL)
172  {
173  savedParameters = GetCurrentValues( aCommand );
174  }
175  G4Tokenizer savedToken( savedParameters );
176  G4String token;
177  for(G4int i_thParameter=0;i_thParameter<parameterNumber;i_thParameter++)
178  {
179  token = savedToken();
180  if( token.isNull() ) return G4String();
181  if( token[(size_t)0] == '"' )
182  {
183  token.append(" ");
184  token.append(savedToken("\""));
185  }
186  }
187  return token;
188 }
int G4int
Definition: G4Types.hh:78
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:156
G4String & append(const G4String &)
G4bool isNull() const
G4String G4UImanager::GetCurrentStringValue ( const char *  aCommand,
const char *  aParameterName,
G4bool  reGet = true 
)

Definition at line 190 of file G4UImanager.cc.

References GetCurrentStringValue(), GetCurrentValues(), G4UIcommand::GetParameter(), G4UIcommand::GetParameterEntries(), and G4UIparameter::GetParameterName().

192 {
193  if(reGet || savedCommand == NULL)
194  {
195  G4String parameterValues = GetCurrentValues( aCommand );
196  }
197  for(G4int i=0;i<savedCommand->GetParameterEntries();i++)
198  {
199  if( aParameterName ==
200  savedCommand->GetParameter(i)->GetParameterName() )
201  return GetCurrentStringValue(aCommand,i+1,false);
202  }
203  return G4String();
204 }
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:168
G4String GetParameterName() const
int G4int
Definition: G4Types.hh:78
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:156
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
G4String G4UImanager::GetCurrentValues ( const char *  aCommand)

Definition at line 156 of file G4UImanager.cc.

References G4UIcommandTree::FindPath(), G4cerr, G4endl, and G4UIcommand::GetCurrentValue().

Referenced by export_G4UImanager(), GetCurrentStringValue(), and G4VBasicShell::ShowCurrent().

157 {
158  G4String theCommand = aCommand;
159  savedCommand = treeTop->FindPath( theCommand );
160  if( savedCommand == NULL )
161  {
162  G4cerr << "command not found" << G4endl;
163  return G4String();
164  }
165  return savedCommand->GetCurrentValue();
166 }
G4UIcommand * FindPath(const char *commandPath) const
#define G4endl
Definition: G4ios.hh:61
G4String GetCurrentValue()
Definition: G4UIcommand.cc:220
G4GLOB_DLL std::ostream G4cerr
G4UIsession* G4UImanager::GetG4UIWindow ( ) const
inline

Definition at line 210 of file G4UImanager.hh.

211  { return g4UIWindow; }
const G4String& G4UImanager::GetMacroSearchPath ( ) const
inline

Definition at line 245 of file G4UImanager.hh.

Referenced by export_G4UImanager().

246  { return searchPath; }
G4UImanager * G4UImanager::GetMasterUIpointer ( )
static

Definition at line 71 of file G4UImanager.cc.

Referenced by G4UIbridge::G4UIbridge().

72 { return fMasterUImanager; }
G4int G4UImanager::GetMaxHistSize ( ) const
inline

Definition at line 240 of file G4UImanager.hh.

Referenced by G4UIcontrolMessenger::GetCurrentValue().

241  { return maxHistSize; }
G4int G4UImanager::GetNumberOfHistory ( ) const
inline

Definition at line 229 of file G4UImanager.hh.

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

230  { return histVec.size(); }
G4bool G4UImanager::GetPauseAtBeginOfEvent ( ) const
inline

Definition at line 194 of file G4UImanager.hh.

Referenced by export_G4UImanager().

195  { return pauseAtBeginOfEvent; }
G4bool G4UImanager::GetPauseAtEndOfEvent ( ) const
inline

Definition at line 198 of file G4UImanager.hh.

Referenced by export_G4UImanager().

199  { return pauseAtEndOfEvent; }
G4String G4UImanager::GetPreviousCommand ( G4int  i) const
inline

Definition at line 231 of file G4UImanager.hh.

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

232  {
233  G4String st;
234  if(i>=0 && i<G4int(histVec.size()))
235  { st = histVec[i]; }
236  return st;
237  }
int G4int
Definition: G4Types.hh:78
G4UIsession* G4UImanager::GetSession ( ) const
inline

Definition at line 208 of file G4UImanager.hh.

Referenced by G4VisCommandReviewKeptEvents::SetNewValue().

209  { return session; }
G4UIcommandTree* G4UImanager::GetTree ( ) const
inline
G4UImanager * G4UImanager::GetUIpointer ( )
static

Definition at line 58 of file G4UImanager.cc.

References G4UImanager().

Referenced by G4VBasicShell::ApplyShellCommand(), pyG4UImanager::ApplyUICommand_1(), G4MPImanager::BeamOn(), CCalRunAction::BeginOfRunAction(), ExGflashRunAction::BeginOfRunAction(), FCALRunAction::BeginOfRunAction(), exrdmRunAction::BeginOfRunAction(), F02RunAction::BeginOfRunAction(), F03RunAction::BeginOfRunAction(), F01RunAction::BeginOfRunAction(), ExG4RunAction01::BeginOfRunAction(), Em10RunAction::BeginOfRunAction(), GammaRayTelRunAction::BeginOfRunAction(), XrayFluoRunAction::BeginOfRunAction(), XrayTelRunAction::BeginOfRunAction(), G4RunManagerKernel::BuildPhysicsTables(), CexmcSensitiveDetectorMessenger::CexmcSensitiveDetectorMessenger(), G4VBasicShell::Complete(), exrdmDetectorConstruction::Construct(), G4TheMTRayTracer::CreateBitMap(), G4CascadeParamMessenger::CreateDirectory(), G4UImessenger::CreateDirectory(), G4BlineEventAction::DrawFieldLines(), CCalRunAction::EndOfRunAction(), ExGflashRunAction::EndOfRunAction(), exrdmRunAction::EndOfRunAction(), FCALRunAction::EndOfRunAction(), F01RunAction::EndOfRunAction(), F02RunAction::EndOfRunAction(), F03RunAction::EndOfRunAction(), ExG4RunAction01::EndOfRunAction(), G03RunAction::EndOfRunAction(), Em10RunAction::EndOfRunAction(), G02RunAction::EndOfRunAction(), XrayFluoRunAction::EndOfRunAction(), XrayTelRunAction::EndOfRunAction(), G4VMPIsession::ExecCommand(), tbbTask::execute(), G4VBasicShell::ExecuteCommand(), G4MPImanager::ExecuteThreadCommand(), export_G4UImanager(), G4VBasicShell::FindCommand(), G4VBasicShell::FindDirectory(), G4MTRunManager::G4MTRunManager(), G4UIbatch::G4UIbatch(), G4UIGAG::G4UIGAG(), G4UIGainServer::G4UIGainServer(), G4UIterminal::G4UIterminal(), G4WorkerRunManager::G4WorkerRunManager(), G4RunManager::GeometryHasBeenModified(), G4VisManager::GeometryHasChanged(), G4VUIshell::GetCommandTree(), G4UIcontrolMessenger::GetCurrentValue(), Initialize(), main(), G4VisManager::NotifyHandlers(), G4MTRunManager::PrepareCommandsStack(), G4WorkerRunManager::ProcessOneEvent(), G4RunManager::ProcessOneEvent(), G4VVisCommandViewer::RefreshIfRequired(), G4RunManager::ReinitializeGeometry(), pyglobals::ResetG4PyCoutDestination(), G4RunManager::rndmSaveThisEvent(), G4RunManager::rndmSaveThisRun(), XrayFluoSimulation::RunSimulation(), G4MPIbatch::SessionStart(), G4UIbatch::SessionStart(), G4VVisCommandGeometrySet::Set(), LXeDetectorConstruction::SetDefaults(), pyglobals::SetG4PyCoutDestination(), G4VisCommandDrawTree::SetNewValue(), PerspectiveVisActionMessenger::SetNewValue(), G4MPImessenger::SetNewValue(), G4VisCommandDrawView::SetNewValue(), G4LocalThreadCoutMessenger::SetNewValue(), G4VisCommandSceneHandlerCreate::SetNewValue(), G4VisCommandDrawVolume::SetNewValue(), G4TrackingMessenger::SetNewValue(), CML2PhantomConstructionMessenger::SetNewValue(), CML2AcceleratorConstructionMessenger::SetNewValue(), G4VisCommandGeometryRestore::SetNewValue(), G4ProcessTableMessenger::SetNewValue(), G4VisCommandOpen::SetNewValue(), G4UIcontrolMessenger::SetNewValue(), G4EmManagerMessenger::SetNewValue(), G4RunMessenger::SetNewValue(), G4ProcessManagerMessenger::SetNewValue(), G4VisCommandList::SetNewValue(), G4EnergyLossMessenger::SetNewValue(), G4VisCommandSpecify::SetNewValue(), G4VisCommandReviewKeptEvents::SetNewValue(), G4VisCommandViewerClone::SetNewValue(), G4VisCommandViewerCreate::SetNewValue(), G4VisCommandViewerFlush::SetNewValue(), G4VisCommandSceneAddTrajectories::SetNewValue(), G4VisCommandGeometrySetVisibility::SetNewValueOnLV(), G4VBasicShell::ShowCurrent(), G4MTRunManagerKernel::StartThread(), G4VBasicShell::TerminalHelp(), G4TheRayTracer::Trace(), G4TheMTRayTracer::Trace(), G4VVisCommand::UpdateVisManagerScene(), G4MPIsession::~G4MPIsession(), G4RunManagerKernel::~G4RunManagerKernel(), G4UIcommand::~G4UIcommand(), G4UIGAG::~G4UIGAG(), G4UIGainServer::~G4UIGainServer(), and G4UIterminal::~G4UIterminal().

59 {
60  if(!fUImanager)
61  {
62  if(!fUImanagerHasBeenKilled)
63  {
64  fUImanager = new G4UImanager;
65  fUImanager->CreateMessenger();
66  }
67  }
68  return fUImanager;
69 }
G4int G4UImanager::GetVerboseLevel ( ) const
inline
void G4UImanager::ListAlias ( )

Definition at line 623 of file G4UImanager.cc.

References G4UIaliasList::List().

Referenced by G4UIcontrolMessenger::SetNewValue().

624 {
625  aliasList->List();
626 }
void G4UImanager::ListCommands ( const char *  direc)

Definition at line 524 of file G4UImanager.cc.

References G4cout, G4endl, and G4UIcommandTree::List().

Referenced by G4UIcontrolMessenger::SetNewValue().

525 {
526  G4UIcommandTree* comTree = FindDirectory(direct);
527  if(comTree)
528  { comTree->List(); }
529  else
530  { G4cout << direct << " is not found." << G4endl; }
531 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void List() const
void G4UImanager::Loop ( const char *  macroFile,
const char *  variableName,
G4double  initialValue,
G4double  finalValue,
G4double  stepSize = 1.0 
)

Definition at line 307 of file G4UImanager.cc.

References Foreach().

Referenced by LoopS().

309 {
310  G4String cd;
311  if (stepSize > 0) {
312  for(G4double d=initialValue;d<=finalValue;d+=stepSize)
313  {
314  std::ostringstream os;
315  os << d;
316  cd += os.str();
317  cd += " ";
318  }
319  } else {
320  for(G4double d=initialValue;d>=finalValue;d+=stepSize)
321  {
322  std::ostringstream os;
323  os << d;
324  cd += os.str();
325  cd += " ";
326  }
327  }
328  Foreach(macroFile,variableName,cd);
329 }
void Foreach(const char *macroFile, const char *variableName, const char *candidates)
Definition: G4UImanager.cc:347
double G4double
Definition: G4Types.hh:76
void G4UImanager::LoopS ( const char *  valueList)

Definition at line 287 of file G4UImanager.cc.

References plottest35::c1, Loop(), and plottest35::t1.

Referenced by G4UIcontrolMessenger::SetNewValue().

288 {
289  G4String vl = valueList;
290  G4Tokenizer parameterToken(vl);
291  G4String mf = parameterToken();
292  G4String vn = parameterToken();
293  G4String c1 = parameterToken();
294  c1 += " ";
295  c1 += parameterToken();
296  c1 += " ";
297  c1 += parameterToken();
298  const char* t1 = c1;
299  std::istringstream is(t1);
300  G4double d1;
301  G4double d2;
302  G4double d3;
303  is >> d1 >> d2 >> d3;
304  Loop(mf,vn,d1,d2,d3);
305 }
void Loop(const char *macroFile, const char *variableName, G4double initialValue, G4double finalValue, G4double stepSize=1.0)
Definition: G4UImanager.cc:307
tuple t1
Definition: plottest35.py:33
double G4double
Definition: G4Types.hh:76
tuple c1
Definition: plottest35.py:14
G4bool G4UImanager::Notify ( G4ApplicationState  requestedState)
virtual

Implements G4VStateDependent.

Definition at line 555 of file G4UImanager.cc.

References G4State_EventProc, G4State_GeomClosed, and G4StateManager::GetStateManager().

556 {
557  //G4cout << G4StateManager::GetStateManager()->GetStateString(requestedState) << " <--- " << G4StateManager::GetStateManager()->GetStateString(G4StateManager::GetStateManager()->GetPreviousState()) << G4endl;
558  if(pauseAtBeginOfEvent)
559  {
560  if(requestedState==G4State_EventProc &&
562  { PauseSession("BeginOfEvent"); }
563  }
564  if(pauseAtEndOfEvent)
565  {
566  if(requestedState==G4State_GeomClosed &&
567  G4StateManager::GetStateManager()->GetPreviousState()==G4State_EventProc)
568  { PauseSession("EndOfEvent"); }
569  }
570  return true;
571 }
static G4StateManager * GetStateManager()
void G4UImanager::ParseMacroSearchPath ( )

Definition at line 637 of file G4UImanager.cc.

References G4String::index().

638 {
639  searchDirs.clear();
640 
641  size_t idxfirst = 0;
642  size_t idxend = 0;
643  G4String pathstring = "";
644  while( (idxend = searchPath.index(':', idxfirst)) != G4String::npos) {
645  pathstring = searchPath.substr(idxfirst, idxend-idxfirst);
646  if(pathstring.size() != 0) searchDirs.push_back(pathstring);
647  idxfirst = idxend + 1;
648  }
649 
650  pathstring = searchPath.substr(idxfirst, searchPath.size()-idxfirst);
651  if(pathstring.size() != 0) searchDirs.push_back(pathstring);
652 }
str_size index(const char *, G4int pos=0) const
void G4UImanager::RegisterBridge ( G4UIbridge brg)

Definition at line 689 of file G4UImanager.cc.

References FatalException, G4Exception(), and G4UIbridge::LocalUI().

Referenced by G4UIbridge::G4UIbridge().

690 {
691  if(brg->LocalUI()==this)
692  {
693  G4Exception("G4UImanager::RegisterBridge()","UI7002",FatalException,
694  "G4UIBridge cannot bridge between same object.");
695  }
696  else
697  { bridges->push_back(brg); }
698 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4UImanager * LocalUI() const
Definition: G4UIbridge.hh:72
void G4UImanager::RemoveAlias ( const char *  aliasName)

Definition at line 616 of file G4UImanager.cc.

References G4String::both, G4UIaliasList::RemoveAlias(), and G4String::strip().

Referenced by G4UIcontrolMessenger::SetNewValue().

617 {
618  G4String aL = aliasName;
619  G4String targetAlias = aL.strip(G4String::both);
620  aliasList->RemoveAlias(targetAlias);
621 }
G4String strip(G4int strip_Type=trailing, char c=' ')
void RemoveAlias(const char *aliasName)
void G4UImanager::RemoveCommand ( G4UIcommand aCommand)

Definition at line 266 of file G4UImanager.cc.

References G4Threading::G4GetThreadId(), and G4UIcommandTree::RemoveCommand().

Referenced by G4UIcommand::~G4UIcommand().

267 {
268  treeTop->RemoveCommand( aCommand );
269  if(fMasterUImanager!=0&&G4Threading::G4GetThreadId()==0)
270  { fMasterUImanager->RemoveWorkerCommand(aCommand); }
271 }
void RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly=false)
G4int G4GetThreadId()
Definition: G4Threading.cc:103
void G4UImanager::SetAlias ( const char *  aliasLine)

Definition at line 597 of file G4UImanager.cc.

References G4UIaliasList::ChangeAlias(), and G4String::index().

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

598 {
599  G4String aLine = aliasLine;
600  G4int i = aLine.index(" ");
601  G4String aliasName = aLine(0,i);
602  G4String aliasValue = aLine(i+1,aLine.length()-(i+1));
603  if(aliasValue(0)=='"')
604  {
605  G4String strippedValue;
606  if(aliasValue(aliasValue.length()-1)=='"')
607  { strippedValue = aliasValue(1,aliasValue.length()-2); }
608  else
609  { strippedValue = aliasValue(1,aliasValue.length()-1); }
610  aliasValue = strippedValue;
611  }
612 
613  aliasList->ChangeAlias(aliasName,aliasValue);
614 }
int G4int
Definition: G4Types.hh:78
str_size index(const char *, G4int pos=0) const
void ChangeAlias(const char *aliasName, const char *aliasValue)
void G4UImanager::SetCerrFileName ( const G4String fileN = "G4cerr.txt",
G4bool  ifAppend = true 
)

Definition at line 723 of file G4UImanager.cc.

References G4MTcoutDestination::SetCerrFileName().

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

724 {
725  // for sequential mode, ignore this method.
726  if(threadID<0) return;
727 
728  if(fileN == "**Screen**")
729  { threadCout->SetCerrFileName(fileN,ifAppend); }
730  else
731  {
732  std::stringstream fn;
733  fn<<"G4W_"<<threadID<<"_"<<fileN;
734  threadCout->SetCerrFileName(fn.str(),ifAppend);
735  }
736 }
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
void G4UImanager::SetCoutDestination ( G4UIsession *const  value)

Definition at line 591 of file G4UImanager.cc.

References G4cerrbuf, G4coutbuf, and G4strstreambuf::SetDestination().

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

592 {
593  G4coutbuf.SetDestination(value);
594  G4cerrbuf.SetDestination(value);
595 }
G4strstreambuf G4coutbuf
Definition: G4ios.cc:82
void SetDestination(G4coutDestination *dest)
G4strstreambuf G4cerrbuf
Definition: G4ios.cc:83
void G4UImanager::SetCoutFileName ( const G4String fileN = "G4cout.txt",
G4bool  ifAppend = true 
)

Definition at line 708 of file G4UImanager.cc.

References G4MTcoutDestination::SetCoutFileName().

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

709 {
710  // for sequential mode, ignore this method.
711  if(threadID<0) return;
712 
713  if(fileN == "**Screen**")
714  { threadCout->SetCoutFileName(fileN,ifAppend); }
715  else
716  {
717  std::stringstream fn;
718  fn<<"G4W_"<<threadID<<"_"<<fileN;
719  threadCout->SetCoutFileName(fn.str(),ifAppend);
720  }
721 }
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
void G4UImanager::SetG4UIWindow ( G4UIsession *const  value)
inline

Definition at line 215 of file G4UImanager.hh.

216  { g4UIWindow = value; }
const XML_Char int const XML_Char * value
void G4UImanager::SetIgnoreCmdNotFound ( G4bool  val)
inline

Definition at line 269 of file G4UImanager.hh.

Referenced by G4WorkerRunManager::G4WorkerRunManager().

270  { ignoreCmdNotFound = val; }
void G4UImanager::SetMacroSearchPath ( const G4String path)
inline

Definition at line 243 of file G4UImanager.hh.

Referenced by export_G4UImanager().

244  { searchPath = path; }
void G4UImanager::SetMasterUIManager ( G4bool  val)
inline

Definition at line 258 of file G4UImanager.hh.

Referenced by G4MTRunManager::G4MTRunManager().

259  {
260  isMaster = val;
261  //ignoreCmdNotFound = val;
262  stackCommandsForBroadcast = val;
263  if(val&&!bridges)
264  {
265  bridges = new std::vector<G4UIbridge*>;
266  fMasterUImanager = this;
267  }
268  }
void G4UImanager::SetMaxHistSize ( G4int  mx)
inline

Definition at line 238 of file G4UImanager.hh.

Referenced by G4UIcontrolMessenger::SetNewValue().

239  { maxHistSize = mx; }
void G4UImanager::SetPauseAtBeginOfEvent ( G4bool  vl)
inline

Definition at line 192 of file G4UImanager.hh.

Referenced by export_G4UImanager(), and G4RunMessenger::SetNewValue().

193  { pauseAtBeginOfEvent = vl; }
void G4UImanager::SetPauseAtEndOfEvent ( G4bool  vl)
inline

Definition at line 196 of file G4UImanager.hh.

Referenced by export_G4UImanager(), and G4RunMessenger::SetNewValue().

197  { pauseAtEndOfEvent = vl; }
void G4UImanager::SetSession ( G4UIsession *const  value)
inline

Definition at line 213 of file G4UImanager.hh.

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

214  { session = value; }
const XML_Char int const XML_Char * value
void G4UImanager::SetThreadIgnore ( G4int  tid = 0)

Definition at line 752 of file G4UImanager.cc.

References G4MTcoutDestination::SetIgnoreCout().

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

753 {
754  // for sequential mode, ignore this method.
755  if(threadID<0)
756  {
757  igThreadID = tid;
758  return;
759  }
760  threadCout->SetIgnoreCout(tid);
761 }
void SetIgnoreCout(G4int tid=0)
void G4UImanager::SetThreadPrefixString ( const G4String s = "W")

Definition at line 738 of file G4UImanager.cc.

References G4MTcoutDestination::SetPrefixString().

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

739 {
740  // for sequential mode, ignore this method.
741  if(threadID<0) return;
742  threadCout->SetPrefixString(s);
743 }
void SetPrefixString(const G4String &wd="G4WT")
void G4UImanager::SetThreadUseBuffer ( G4bool  flg = true)

Definition at line 745 of file G4UImanager.cc.

References G4MTcoutDestination::EnableBuffering().

Referenced by G4LocalThreadCoutMessenger::SetNewValue().

746 {
747  // for sequential mode, ignore this method.
748  if(threadID<0) return;
749  threadCout->EnableBuffering(flg);
750 }
void EnableBuffering(G4bool flag=true)
void G4UImanager::SetUpForAThread ( G4int  tId)

Definition at line 700 of file G4UImanager.cc.

References G4iosInitialization(), and G4MTcoutDestination::SetIgnoreCout().

Referenced by tbbTask::execute(), and G4MTRunManagerKernel::StartThread().

701 {
702  threadID = tId;
704  threadCout = new G4MTcoutDestination(threadID);
705  threadCout->SetIgnoreCout(igThreadID);
706 }
void SetIgnoreCout(G4int tid=0)
void G4iosInitialization()
Definition: G4ios.cc:85
void G4UImanager::SetVerboseLevel ( G4int  val)
inline
G4String G4UImanager::SolveAlias ( const char *  aCmd)

Definition at line 364 of file G4UImanager.cc.

References G4UIaliasList::FindAlias(), G4cerr, G4endl, G4String::index(), and iz.

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

365 {
366  G4String aCommand = aCmd;
367  G4int ia = aCommand.index("{");
368  G4int iz = aCommand.index("#");
369  while((ia != G4int(std::string::npos))&&((iz==G4int(std::string::npos))||(ia<iz)))
370  {
371  G4int ibx = -1;
372  while(ibx<0)
373  {
374  G4int ib = aCommand.index("}");
375  if( ib == G4int(std::string::npos) )
376  {
377  G4cerr << aCommand << G4endl;
378  for(G4int i=0;i<ia;i++) G4cerr << " ";
379  G4cerr << "^" << G4endl;
380  G4cerr << "Unmatched alias parenthis -- command ignored" << G4endl;
381  G4String nullStr;
382  return nullStr;
383  }
384  G4String ps = aCommand(ia+1,aCommand.length()-(ia+1));
385  G4int ic = ps.index("{");
386  G4int id = ps.index("}");
387  if(ic!=G4int(std::string::npos) && ic < id)
388  { ia+=ic+1; }
389  else
390  { ibx = ib; }
391  }
392  //--- Here ia represents the position of innermost "{"
393  //--- and ibx represents corresponding "}"
394  G4String subs;
395  if(ia>0) subs = aCommand(0,ia);
396  G4String alis = aCommand(ia+1,ibx-ia-1);
397  G4String rems = aCommand(ibx+1,aCommand.length()-ibx);
398  // G4cout << "<" << subs << "> <" << alis << "> <" << rems << ">" << G4endl;
399  G4String* alVal = aliasList->FindAlias(alis);
400  if(!alVal)
401  {
402  G4cerr << "Alias <" << alis << "> not found -- command ignored" << G4endl;
403  G4String nullStr;
404  return nullStr;
405  }
406  aCommand = subs+(*alVal)+rems;
407  ia = aCommand.index("{");
408  }
409  return aCommand;
410 }
int G4int
Definition: G4Types.hh:78
str_size index(const char *, G4int pos=0) const
G4double iz
Definition: TRTMaterials.hh:39
G4String * FindAlias(const char *aliasName)
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
void G4UImanager::StoreHistory ( const char *  fileName = "G4history.macro")

Definition at line 499 of file G4UImanager.cc.

Referenced by G4UIcontrolMessenger::SetNewValue().

500 { StoreHistory(true,fileName); }
void StoreHistory(const char *fileName="G4history.macro")
Definition: G4UImanager.cc:499
void G4UImanager::StoreHistory ( G4bool  historySwitch,
const char *  fileName = "G4history.macro" 
)

Definition at line 502 of file G4UImanager.cc.

503 {
504  if(historySwitch)
505  {
506  if(saveHistory)
507  { historyFile.close(); }
508  historyFile.open((char*)fileName);
509  saveHistory = true;
510  }
511  else
512  {
513  historyFile.close();
514  saveHistory = false;
515  }
516  saveHistory = historySwitch;
517 }

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