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

#include <G4UIExecutive.hh>

Public Member Functions

 G4UIExecutive (G4int argc, char **argv, const G4String &type="")
 
 ~G4UIExecutive ()
 
G4UIsessionGetSession () const
 
G4bool IsGUI () const
 
void SetVerbose (G4bool val)
 
void SetPrompt (const G4String &prompt)
 
void SetLsColor (TermColorIndex dirColor, TermColorIndex cmdColor)
 
void SessionStart ()
 

Detailed Description

Definition at line 60 of file G4UIExecutive.hh.

Constructor & Destructor Documentation

◆ G4UIExecutive()

G4UIExecutive::G4UIExecutive ( G4int argc,
char ** argv,
const G4String & type = "" )

Definition at line 79 of file G4UIExecutive.cc.

80 : selected(kNone), session(nullptr), shell(nullptr), isGUI(false), verbose(true)
81{
82 if (verbose) {
83 G4cout << "Available UI session types: [ ";
84 if (qt_build) G4cout << "Qt, ";
85 if (xm_build) G4cout << "Xm, ";
86 if (win32_build) G4cout << "Win32, ";
87 if (tcsh_build) G4cout << "tcsh, ";
88 G4cout << "csh ]" << G4endl;
89 }
90
91 // selecting session type...
92 // 1st priority : in case argumant specified
93 G4String stype = G4StrUtil::to_lower_copy(type); // session type is case-insensitive.
94 if (! type.empty()) SelectSessionByArg(stype);
95
96 // 2nd priority : refer environment variables (as backword compatibility)
97 if (selected == kNone) SelectSessionByEnv();
98
99 // 3rd priority : refer $HOME/.g4session
100 if (selected == kNone) {
101 G4String appinput = argv[0];
102 G4String appname = "";
103 size_t islash = appinput.find_last_of("/\\");
104 if (islash == G4String::npos)
105 appname = appinput;
106 else
107 appname = appinput.substr(islash + 1, appinput.size() - islash - 1);
108
109 SelectSessionByFile(appname);
110 }
111
112 // 4th, best guess of session type
113 if (selected == kNone) SelectSessionByBestGuess();
114
115 // instantiate a session...
116 switch (selected) {
117 case kQt:
118#if defined(G4UI_BUILD_QT_SESSION)
119 session = new G4UIQt(argc, argv);
120 isGUI = true;
121#endif
122 break;
123 case kXm:
124#if defined(G4UI_BUILD_XM_SESSION)
125 session = new G4UIXm(argc, argv);
126 isGUI = true;
127#endif
128 break;
129 case kWin32:
130#if defined(G4UI_BUILD_WIN32_SESSION)
131 DISCARD_PARAMETER(argc);
132 DISCARD_PARAMETER(argv);
133 session = new G4UIWin32();
134 isGUI = true;
135#endif
136 break;
137 case kTcsh:
138#if ! (defined(WIN32) || defined(__MINGW32__))
139 DISCARD_PARAMETER(argc);
140 DISCARD_PARAMETER(argv);
141 shell = new G4UItcsh;
142 session = new G4UIterminal(shell);
143#endif
144 break;
145 case kCsh:
146 DISCARD_PARAMETER(argc);
147 DISCARD_PARAMETER(argv);
148 shell = new G4UIcsh;
149 session = new G4UIterminal(shell);
150 default:
151 break;
152 }
153
154 // fallback (csh)
155 if (session == nullptr) {
156 G4Exception("G4UIExecutive::G4UIExecutive()", "UI0002", JustWarning,
157 "Specified session type is not build in your system,\n"
158 "or no session type is specified.\n"
159 "A fallback session type is used.");
160
161 selected = kCsh;
162 DISCARD_PARAMETER(argc);
163 DISCARD_PARAMETER(argv);
164 shell = new G4UIcsh;
165 session = new G4UIterminal(shell);
166 }
167
168 TIMEMORY_INIT(argc, argv);
169}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
#define TIMEMORY_INIT(...)
#define DISCARD_PARAMETER(p)
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

◆ ~G4UIExecutive()

G4UIExecutive::~G4UIExecutive ( )

Definition at line 172 of file G4UIExecutive.cc.

172{ delete session; }

Member Function Documentation

◆ GetSession()

G4UIsession * G4UIExecutive::GetSession ( ) const
inline

Definition at line 105 of file G4UIExecutive.hh.

105{ return session; }

◆ IsGUI()

G4bool G4UIExecutive::IsGUI ( ) const
inline

Definition at line 107 of file G4UIExecutive.hh.

107{ return isGUI; }

◆ SessionStart()

void G4UIExecutive::SessionStart ( )

Definition at line 295 of file G4UIExecutive.cc.

295{ session->SessionStart(); }

◆ SetLsColor()

void G4UIExecutive::SetLsColor ( TermColorIndex dirColor,
TermColorIndex cmdColor )

Definition at line 289 of file G4UIExecutive.cc.

290{
291 if (shell != nullptr) shell->SetLsColor(dirColor, cmdColor);
292}
virtual void SetLsColor(TermColorIndex, TermColorIndex)

◆ SetPrompt()

void G4UIExecutive::SetPrompt ( const G4String & prompt)

Definition at line 283 of file G4UIExecutive.cc.

284{
285 if (shell != nullptr) shell->SetPrompt(prompt);
286}
void SetPrompt(const G4String &prompt)

◆ SetVerbose()

void G4UIExecutive::SetVerbose ( G4bool val)
inline

Definition at line 109 of file G4UIExecutive.hh.

109{ verbose = val; }

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