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

#include <G4UIXm.hh>

+ Inheritance diagram for G4UIXm:

Public Member Functions

 G4UIXm (G4int, char **)
 
 ~G4UIXm ()
 
G4UIsessionSessionStart ()
 
void AddMenu (const char *, const char *)
 
void AddButton (const char *, const char *, const char *)
 
void Prompt (G4String)
 
void SessionTerminate ()
 
virtual void PauseSessionStart (const G4String &)
 
virtual G4int ReceiveG4debug (const G4String &)
 
virtual G4int ReceiveG4cout (const G4String &)
 
virtual G4int ReceiveG4cerr (const G4String &)
 
G4String GetCommand (Widget)
 
- Public Member Functions inherited from G4VBasicShell
 G4VBasicShell ()
 
 ~G4VBasicShell () override
 
- Public Member Functions inherited from G4UIsession
 G4UIsession ()
 
 G4UIsession (G4int iBatch)
 
 ~G4UIsession () override
 
G4int GetLastReturnCode () const
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()=default
 
virtual ~G4coutDestination ()=default
 
void AddDebugTransformer (const Transformer &t)
 
void AddDebugTransformer (Transformer &&t)
 
void AddCoutTransformer (const Transformer &t)
 
void AddCoutTransformer (Transformer &&t)
 
void AddCerrTransformer (const Transformer &t)
 
void AddCerrTransformer (Transformer &&t)
 
virtual void ResetTransformers ()
 
G4int ReceiveG4debug_ (const G4String &msg)
 
G4int ReceiveG4cout_ (const G4String &msg)
 
G4int ReceiveG4cerr_ (const G4String &msg)
 
- Public Member Functions inherited from G4VInteractiveSession
 G4VInteractiveSession ()
 
virtual ~G4VInteractiveSession ()
 
virtual void AddIcon (const char *, const char *, const char *, const char *)
 
virtual void DefaultIcons (bool)
 
virtual void SetOutputStyle (const char *, const char *)
 
virtual void NativeMenu (bool)
 
virtual void ClearMenu ()
 
virtual void UpdateSceneTree (const G4SceneTreeItem &)
 
void AddInteractor (G4String, G4Interactor)
 
G4Interactor GetInteractor (G4String)
 
const std::map< G4String, OutputStyle > & GetOutputStyles () const
 

Additional Inherited Members

- Public Types inherited from G4coutDestination
using Transformer = std::function<G4bool(G4String&)>
 
- Static Public Member Functions inherited from G4UIsession
static G4int InSession ()
 
- Protected Member Functions inherited from G4VBasicShell
G4String ModifyToFullPathCommand (const char *aCommandLine) const
 
G4String GetCurrentWorkingDirectory () const
 
G4bool ChangeDirectory (const char *newDir)
 
G4UIcommandTreeFindDirectory (const char *dirName) const
 
G4UIcommandFindCommand (const char *commandName) const
 
G4String Complete (const G4String &)
 
G4String FindMatchingPath (G4UIcommandTree *, const G4String &)
 
virtual void ExecuteCommand (const G4String &)
 
void ApplyShellCommand (const G4String &, G4bool &, G4bool &)
 
void ShowCurrent (const G4String &) const
 
void ChangeDirectoryCommand (const G4String &)
 
void ListDirectory (const G4String &) const
 
void TerminalHelp (const G4String &)
 
- Protected Member Functions inherited from G4VInteractiveSession
void SetStyleUtility (const G4String &destination, const G4String &style)
 
- Protected Attributes inherited from G4UIsession
G4int ifBatch = 0
 
G4int lastRC = 0
 
- Protected Attributes inherited from G4coutDestination
std::vector< TransformertransformersDebug
 
std::vector< TransformertransformersCout
 
std::vector< TransformertransformersCerr
 
- Protected Attributes inherited from G4VInteractiveSession
std::map< G4String, OutputStylefOutputStyles
 
- Static Protected Attributes inherited from G4UIsession
static G4ICOMS_DLL G4int inSession = 0
 
- Static Protected Attributes inherited from G4coutDestination
static G4MTGLOB_DLL G4coutDestinationmasterG4coutDestination = nullptr
 

Detailed Description

Definition at line 60 of file G4UIXm.hh.

Constructor & Destructor Documentation

◆ G4UIXm()

G4UIXm::G4UIXm ( G4int argc,
char ** argv )

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 66 of file G4UIXm.cc.

67 : shell(NULL), command(NULL), menuBar(NULL), text(NULL), fHelp(false), fHelpChoice(0)
68/***************************************************************************/
69/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
70{
72 if (UI != NULL) UI->SetSession(this);
73
74 G4Xt* interactorManager = G4Xt::getInstance(argc, argv, (char*)"Xm");
75
76 Widget top = (Widget)interactorManager->GetMainInteractor();
77
78 if (std::getenv("XENVIRONMENT") == NULL) {
79 XrmDatabase database = XrmGetDatabase(XtDisplay(top));
80 if (database != NULL) {
81 XrmPutLineResource(&database, "*topShadowColor:white");
82 XrmPutLineResource(&database, "*bottomShadowColor:black");
83 XrmPutLineResource(&database, "*foreground:black");
84 XrmPutLineResource(&database, "*background:lightgrey");
85 XrmPutLineResource(&database, "*borderColor:lightgrey");
86 XrmPutLineResource(&database, "*fontList:-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1");
87 XrmPutLineResource(&database, "*text.background:white");
88 XrmPutLineResource(&database, "*text.fontList:*courier*-r-*--14-*");
89 XrmPutLineResource(&database, "*text.maxLength:8000");
90 }
91 }
92
93 Arg args[9];
94 XtSetArg(args[0], XmNkeyboardFocusPolicy, XmPOINTER); // For completion.
95 shell = XtAppCreateShell("G4UIXm", "G4UIXm", topLevelShellWidgetClass, XtDisplay(top), args, 1);
96 form = XmCreateForm(shell, (char*)menu_str[0].c_str(), NULL, 0);
97 XtManageChild(form);
98
99 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
100 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
101 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
102 menuBar = XmCreateMenuBar(form, (char*)menu_str[1].c_str(), args, 3);
103
104 XtSetArg(args[0], XmNtopAttachment, XmATTACH_NONE);
105 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
106 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
107 XtSetArg(args[3], XmNbottomAttachment, XmATTACH_FORM);
108 command = XmCreateCommand(form, (char*)menu_str[2].c_str(), args, 4);
109 XtManageChild(command);
110
111 XtSetArg(args[0], XmNtopAttachment, XmATTACH_NONE);
112 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
113 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
114 XtSetArg(args[3], XmNbottomAttachment, XmATTACH_WIDGET);
115 XtSetArg(args[4], XmNbottomWidget, command);
116 XmString cps = XmStringLtoRCreate((char*)menu_str[3].c_str(), (char*)XmSTRING_DEFAULT_CHARSET);
117 XtSetArg(args[5], XmNlabelString, cps);
118 Widget clearButton = XmCreatePushButton(form, (char*)menu_str[4].c_str(), args, 6);
119 XmStringFree(cps);
120 XtManageChild(clearButton);
121
122 XtSetArg(args[0], XmNtopAttachment, XmATTACH_WIDGET);
123 XtSetArg(args[1], XmNtopWidget, menuBar);
124 XtSetArg(args[2], XmNleftAttachment, XmATTACH_FORM);
125 XtSetArg(args[3], XmNrightAttachment, XmATTACH_FORM);
126 XtSetArg(args[4], XmNbottomAttachment, XmATTACH_WIDGET);
127 XtSetArg(args[5], XmNbottomWidget, clearButton);
128 XtSetArg(args[6], XmNeditMode, XmMULTI_LINE_EDIT);
129 XtSetArg(args[7], XmNrows, 12);
130 XtSetArg(args[8], XmNcolumns, 80);
131 text = XmCreateScrolledText(form, (char*)menu_str[5].c_str(), args, 9);
132 XtManageChild(text);
133
134 XtAddCallback(clearButton, XmNactivateCallback, clearButtonCallback, (XtPointer)text);
135 XtAddCallback(command, XmNcommandEnteredCallback, CommandEnteredCallback, (XtPointer)this);
136
137 Widget commandText = XmCommandGetChild(command, XmDIALOG_COMMAND_TEXT);
138 XtAddEventHandler(commandText, KeyPressMask, False, keyHandler, (XtPointer)this);
139
140 XtRealizeWidget(shell);
141 XtMapWidget(shell);
142
143 if (UI != NULL) UI->SetCoutDestination(this);
144}
void SetCoutDestination(G4UIsession *const value)
static G4UImanager * GetUIpointer()
void SetSession(G4UIsession *const value)
Definition G4Xt.hh:49
static G4Xt * getInstance()
Definition G4Xt.cc:54

◆ ~G4UIXm()

G4UIXm::~G4UIXm ( )

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 146 of file G4UIXm.cc.

149{
151 if (UI != NULL) {
152 UI->SetSession(NULL);
153 UI->SetCoutDestination(NULL);
154 }
155 XtDestroyWidget(shell);
156}

Member Function Documentation

◆ AddButton()

void G4UIXm::AddButton ( const char * a_menu,
const char * a_label,
const char * a_command )
virtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4VInteractiveSession.

Definition at line 295 of file G4UIXm.cc.

298{
299 if (a_menu == NULL) return;
300 if (a_label == NULL) return;
301 if (a_command == NULL) return;
302 Widget parent = (Widget)GetInteractor(a_menu);
303 if (parent == NULL) return;
304 Widget widget = XmCreatePushButton(parent, (char*)a_label, NULL, 0);
305 XtManageChild(widget);
306 XtAddCallback(widget, XmNactivateCallback, ButtonCallback, (XtPointer)this);
307 commands[widget] = a_command;
308}
G4Interactor GetInteractor(G4String)

◆ AddMenu()

void G4UIXm::AddMenu ( const char * a_name,
const char * a_label )
virtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4VInteractiveSession.

Definition at line 272 of file G4UIXm.cc.

275{
276 if (menuBar == NULL) return;
277 if (a_name == NULL) return;
278 if (a_label == NULL) return;
279 XtManageChild(menuBar);
280 // Pulldown menu :
281 Widget widget;
282 widget = XmCreatePulldownMenu(menuBar, (char*)a_name, NULL, 0);
283 AddInteractor(a_name, (G4Interactor)widget);
284 // Cascade button :
285 Arg args[2];
286 XmString cps = XmStringLtoRCreate((char*)a_label, (char*)XmSTRING_DEFAULT_CHARSET);
287 XtSetArg(args[0], XmNlabelString, cps);
288 XtSetArg(args[1], XmNsubMenuId, widget);
289 widget = XmCreateCascadeButton(menuBar, (char*)a_name, args, 2);
290 XmStringFree(cps);
291 XtManageChild(widget);
292 ExecuteChangeSizeFunction(form);
293}
void * G4Interactor
void AddInteractor(G4String, G4Interactor)

◆ GetCommand()

G4String G4UIXm::GetCommand ( Widget a_widget)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 310 of file G4UIXm.cc.

313{
314 return commands[a_widget];
315}

◆ PauseSessionStart()

void G4UIXm::PauseSessionStart ( const G4String & a_state)
virtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 193 of file G4UIXm.cc.

196{
197 if (a_state == "G4_pause> ") {
198 SecondaryLoop("Pause, type continue to exit this state");
199 }
200
201 if (a_state == "EndOfEvent") {
202 // Picking with feed back in event data Done here !!!
203 SecondaryLoop("End of event, type continue to exit this state");
204 }
205}

◆ Prompt()

void G4UIXm::Prompt ( G4String aPrompt)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 175 of file G4UIXm.cc.

178{
179 Arg args[1];
180 char* str = (char*)XtNewString(aPrompt.data());
181 XmString cps = XmStringLtoRCreate(str, (char*)XmSTRING_DEFAULT_CHARSET);
182 XtFree(str);
183 XtSetArg(args[0], XmNpromptString, cps);
184 XtSetValues(command, args, 1);
185 XmStringFree(cps);
186}

Referenced by SessionStart().

◆ ReceiveG4cerr()

G4int G4UIXm::ReceiveG4cerr ( const G4String & a_string)
virtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4UIsession.

Definition at line 237 of file G4UIXm.cc.

240{
241 XmTextAppendString(text, (char*)a_string.data());
242 return 0;
243}

◆ ReceiveG4cout()

G4int G4UIXm::ReceiveG4cout ( const G4String & a_string)
virtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4UIsession.

Definition at line 229 of file G4UIXm.cc.

232{
233 XmTextAppendString(text, (char*)a_string.data());
234 return 0;
235}

◆ ReceiveG4debug()

G4int G4UIXm::ReceiveG4debug ( const G4String & a_string)
virtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4UIsession.

Definition at line 222 of file G4UIXm.cc.

225{
226 XmTextAppendString(text, (char*)a_string.data());
227 return 0;
228} /***************************************************************************/

◆ SessionStart()

G4UIsession * G4UIXm::SessionStart ( )
virtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 158 of file G4UIXm.cc.

161{
162 G4Xt* interactorManager = G4Xt::getInstance();
163 Prompt("session");
164 exitSession = false;
165 interactorManager->DisableSecondaryLoop();
166 void* event;
167 while ((event = interactorManager->GetEvent()) != NULL) {
168 interactorManager->DispatchEvent(event);
169 if (exitSession == true) break;
170 }
171 interactorManager->EnableSecondaryLoop();
172 return this;
173}
void Prompt(G4String)
Definition G4UIXm.cc:175
void * GetEvent()
Definition G4Xt.cc:136

◆ SessionTerminate()

void G4UIXm::SessionTerminate ( )

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 188 of file G4UIXm.cc.

191{}

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