Geant4 11.1.1
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 **)
 
G4UIsessionSessionStart ()
 
void AddMenu (const char *, const char *)
 
void AddButton (const char *, const char *, const char *)
 
 ~G4UIXm ()
 
void Prompt (G4String)
 
void SessionTerminate ()
 
virtual void PauseSessionStart (const G4String &)
 
virtual G4int ReceiveG4cout (const G4String &)
 
virtual G4int ReceiveG4cerr (const G4String &)
 
G4String GetCommand (Widget)
 
- Public Member Functions inherited from G4VBasicShell
 G4VBasicShell ()
 
virtual ~G4VBasicShell ()
 
virtual G4UIsessionSessionStart ()=0
 
virtual void PauseSessionStart (const G4String &Prompt)=0
 
- Public Member Functions inherited from G4UIsession
 G4UIsession ()
 
 G4UIsession (G4int iBatch)
 
 ~G4UIsession () override
 
virtual G4UIsessionSessionStart ()
 
virtual void PauseSessionStart (const G4String &Prompt)
 
G4int ReceiveG4cout (const G4String &coutString) override
 
G4int ReceiveG4cerr (const G4String &cerrString) override
 
G4int GetLastReturnCode () const
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()=default
 
virtual ~G4coutDestination ()=default
 
void AddCoutTransformer (const Transformer &t)
 
void AddCoutTransformer (Transformer &&t)
 
void AddCerrTransformer (const Transformer &t)
 
void AddCerrTransformer (Transformer &&t)
 
virtual void ResetTransformers ()
 
virtual G4int ReceiveG4cout (const G4String &msg)
 
virtual G4int ReceiveG4cerr (const G4String &msg)
 
G4int ReceiveG4cout_ (const G4String &msg)
 
G4int ReceiveG4cerr_ (const G4String &msg)
 
- Public Member Functions inherited from G4VInteractiveSession
 G4VInteractiveSession ()
 
virtual ~G4VInteractiveSession ()
 
virtual void AddMenu (const char *, const char *)
 
virtual void AddButton (const char *, const char *, const char *)
 
virtual void AddIcon (const char *, const char *, const char *, const char *)
 
virtual void DefaultIcons (bool)
 
virtual void OutputStyle (const char *, const char *, const char *)
 
virtual void NativeMenu (bool)
 
virtual void ClearMenu ()
 
void AddInteractor (G4String, G4Interactor)
 
G4Interactor GetInteractor (G4String)
 

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 &)
 
virtual G4bool GetHelpChoice (G4int &)=0
 
virtual void ExitHelp () const =0
 
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 Attributes inherited from G4UIsession
G4int ifBatch = 0
 
G4int lastRC = 0
 
- Protected Attributes inherited from G4coutDestination
std::vector< TransformertransformersCout
 
std::vector< TransformertransformersCerr
 
- 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 70 of file G4UIXm.cc.

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

◆ ~G4UIXm()

G4UIXm::~G4UIXm ( )

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

Definition at line 162 of file G4UIXm.cc.

166{
168 if(UI!=NULL) {
169 UI->SetSession(NULL);
170 UI->SetCoutDestination(NULL);
171 }
172 XtDestroyWidget(shell);
173}

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 325 of file G4UIXm.cc.

332{
333 if(a_menu==NULL) return;
334 if(a_label==NULL) return;
335 if(a_command==NULL) return;
336 Widget parent = (Widget)GetInteractor(a_menu);
337 if(parent==NULL) return;
338 Widget widget = XmCreatePushButton(parent,(char*)a_label,NULL,0);
339 XtManageChild (widget);
340 XtAddCallback (widget,XmNactivateCallback,ButtonCallback,(XtPointer)this);
341 commands[widget] = a_command;
342}
G4Interactor GetInteractor(G4String)

◆ AddMenu()

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

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

Reimplemented from G4VInteractiveSession.

Definition at line 299 of file G4UIXm.cc.

305{
306 if(menuBar==NULL) return;
307 if(a_name==NULL) return;
308 if(a_label==NULL) return;
309 XtManageChild (menuBar);
310 // Pulldown menu :
311 Widget widget;
312 widget = XmCreatePulldownMenu (menuBar,(char*)a_name,NULL,0);
313 AddInteractor (a_name,(G4Interactor)widget);
314 // Cascade button :
315 Arg args[2];
316 XmString cps = XmStringLtoRCreate((char*)a_label,(char*)XmSTRING_DEFAULT_CHARSET);
317 XtSetArg (args[0],XmNlabelString,cps);
318 XtSetArg (args[1],XmNsubMenuId,widget);
319 widget = XmCreateCascadeButton (menuBar,(char*)a_name,args,2);
320 XmStringFree (cps);
321 XtManageChild (widget);
322 ExecuteChangeSizeFunction(form);
323}
void * G4Interactor
void AddInteractor(G4String, G4Interactor)

◆ GetCommand()

G4String G4UIXm::GetCommand ( Widget  a_widget)

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

Definition at line 344 of file G4UIXm.cc.

349{
350 return commands[a_widget];
351}

◆ PauseSessionStart()

void G4UIXm::PauseSessionStart ( const G4String a_state)
virtual

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

Implements G4VBasicShell.

Definition at line 215 of file G4UIXm.cc.

220{
221 if(a_state=="G4_pause> ") {
222 SecondaryLoop ("Pause, type continue to exit this state");
223 }
224
225 if(a_state=="EndOfEvent") {
226 // Picking with feed back in event data Done here !!!
227 SecondaryLoop ("End of event, type continue to exit this state");
228 }
229}

◆ Prompt()

void G4UIXm::Prompt ( G4String  aPrompt)

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

Definition at line 193 of file G4UIXm.cc.

198{
199 Arg args[1];
200 char* str = (char*)XtNewString(aPrompt.data());
201 XmString cps = XmStringLtoRCreate(str,(char*)XmSTRING_DEFAULT_CHARSET);
202 XtFree(str);
203 XtSetArg(args[0],XmNpromptString,cps);
204 XtSetValues(command,args,1);
205 XmStringFree(cps);
206}

Referenced by SessionStart().

◆ ReceiveG4cerr()

G4int G4UIXm::ReceiveG4cerr ( const G4String a_string)
virtual

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

Reimplemented from G4UIsession.

Definition at line 258 of file G4UIXm.cc.

263{
264 XmTextAppendString(text,(char*)a_string.data());
265 return 0;
266}

◆ ReceiveG4cout()

G4int G4UIXm::ReceiveG4cout ( const G4String a_string)
virtual

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

Reimplemented from G4UIsession.

Definition at line 248 of file G4UIXm.cc.

253{
254 XmTextAppendString(text,(char*)a_string.data());
255 return 0;
256}

◆ SessionStart()

G4UIsession * G4UIXm::SessionStart ( )
virtual

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

Implements G4VBasicShell.

Definition at line 175 of file G4UIXm.cc.

179{
180 G4Xt* interactorManager = G4Xt::getInstance ();
181 Prompt("session");
182 exitSession = false;
183 interactorManager->DisableSecondaryLoop ();
184 void* event;
185 while((event = interactorManager->GetEvent())!=NULL) {
186 interactorManager->DispatchEvent(event);
187 if(exitSession==true) break;
188 }
189 interactorManager->EnableSecondaryLoop ();
190 return this;
191}
void Prompt(G4String)
Definition: G4UIXm.cc:193
void * GetEvent()
Definition: G4Xt.cc:150

◆ SessionTerminate()

void G4UIXm::SessionTerminate ( )

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

Definition at line 208 of file G4UIXm.cc.

212{
213}

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