Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4UIExecutive Class Reference

#include <G4UIExecutive.hh>

Public Member Functions

 G4UIExecutive (G4int argc, char **argv, const G4String &type="")
 
 ~G4UIExecutive ()
 
G4UIsessionGetSession () const
 
G4bool IsGUI () const
 
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 ( G4int  argc,
char **  argv,
const G4String type = "" 
)

Definition at line 91 of file G4UIExecutive.cc.

92  : selected(kNone), session(NULL), shell(NULL), isGUI(false)
93 {
94  G4cout << "Available UI session types: [ ";
95  if ( qt_build ) G4cout << "Qt, ";
96  if ( xm_build ) G4cout << "Xm, ";
97  if ( win32_build) G4cout << "Win32, ";
98  if ( wt_build ) G4cout << "Wt, ";
99  G4cout << "GAG, ";
100  if (tcsh_build ) G4cout << "tcsh, ";
101  G4cout << "csh ]" << G4endl;
102 
103  // selecting session type...
104  // 1st priority : in case argumant specified
105  G4String stype = type;
106  stype.toLower(); // session type is case-insensitive.
107  if (type != "") SelectSessionByArg(stype);
108 
109  // 2nd priority : refer environment variables (as backword compatibility)
110  if ( selected == kNone ) SelectSessionByEnv();
111 
112  // 3rd priority : refer $HOME/.g4session
113  if ( selected == kNone ) {
114  G4String appinput = argv[0];
115  G4String appname = "";
116  size_t islash = appinput.find_last_of("/\\");
117  if (islash == G4String::npos)
118  appname = appinput;
119  else
120  appname = appinput(islash+1, appinput.size()-islash-1);
121 
122  SelectSessionByFile(appname);
123  }
124 
125  // 4th, best guess of session type
126  if ( selected == kNone) SelectSessionByBestGuess();
127 
128  // instantiate a session...
129  switch ( selected ) {
130  case kQt:
131 #if defined(G4UI_BUILD_QT_SESSION)
132  session = new G4UIQt(argc, argv);
133  isGUI = true;
134 #endif
135  break;
136  case kXm:
137 #if defined(G4UI_BUILD_XM_SESSION)
138  session = new G4UIXm(argc, argv);
139  isGUI = true;
140 #endif
141  break;
142  case kWin32:
143 #if defined(G4UI_BUILD_WIN32_SESSION)
144  DISCARD_PARAMETER(argc);
145  DISCARD_PARAMETER(argv);
146  session = new G4UIWin32();
147 #endif
148  break;
149  case kWt:
150 #if defined(G4UI_BUILD_WT_SESSION)
151  session = new G4UIWt(argc, argv);
152  isGUI = true;
153 #endif
154  break;
155  case kGag:
156  DISCARD_PARAMETER(argc);
157  DISCARD_PARAMETER(argv);
158  session = new G4UIGAG();
159  isGUI = true;
160  break;
161  case kTcsh:
162 #ifndef WIN32
163  DISCARD_PARAMETER(argc);
164  DISCARD_PARAMETER(argv);
165  shell = new G4UItcsh;
166  session = new G4UIterminal(shell);
167 #endif
168  break;
169  case kCsh:
170  DISCARD_PARAMETER(argc);
171  DISCARD_PARAMETER(argv);
172  shell = new G4UIcsh;
173  session = new G4UIterminal(shell);
174  default:
175  break;
176  }
177 
178  // fallback (csh)
179  if ( session == NULL ) {
180  G4Exception("G4UIExecutive::G4UIExecutive()",
181  "UI0002",
182  JustWarning,
183  "Specified session type is not build in your system,\n"
184  "or no session type is specified.\n"
185  "A fallback session type is used.");
186 
187  selected = kCsh;
188  DISCARD_PARAMETER(argc);
189  DISCARD_PARAMETER(argv);
190  shell = new G4UIcsh;
191  session = new G4UIterminal(shell);
192  }
193 }
static const G4bool wt_build
static const G4bool win32_build
static const G4bool qt_build
#define DISCARD_PARAMETER(p)
G4GLOB_DLL std::ostream G4cout
static const G4bool xm_build
void toLower()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static const G4bool tcsh_build
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

G4UIExecutive::~G4UIExecutive ( )

Definition at line 196 of file G4UIExecutive.cc.

197 {
198  if ( selected != kWt ) delete session;
199 }

Member Function Documentation

G4UIsession * G4UIExecutive::GetSession ( ) const
inline

Definition at line 92 of file G4UIExecutive.hh.

93 {
94  return session;
95 }
G4bool G4UIExecutive::IsGUI ( ) const
inline

Definition at line 97 of file G4UIExecutive.hh.

98 {
99  return isGUI;
100 }
void G4UIExecutive::SessionStart ( )

Definition at line 304 of file G4UIExecutive.cc.

305 {
306  session-> SessionStart();
307 }
void G4UIExecutive::SetLsColor ( TermColorIndex  dirColor,
TermColorIndex  cmdColor 
)

Definition at line 297 of file G4UIExecutive.cc.

299 {
300  if(shell) shell-> SetLsColor(dirColor, cmdColor);
301 }
void SetLsColor(TermColorIndex dirColor, TermColorIndex cmdColor)
void G4UIExecutive::SetPrompt ( const G4String prompt)

Definition at line 291 of file G4UIExecutive.cc.

292 {
293  if(shell) shell-> SetPrompt(prompt);
294 }
void SetPrompt(const G4String &prompt)

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