gboard
Loading...
Searching...
No Matches
GUI_Session Class Reference

A custom Geant4 UI session that forwards Geant4 text output to a GBoard widget. More...

#include <gui_session.h>

Public Member Functions

 GUI_Session (const std::shared_ptr< GOptions > &gopt, GBoard *board)
 Constructs a GUI_Session.
 
G4int ReceiveG4cout (const G4String &coutString) override
 Receives standard output from Geant4 and forwards it to the board.
 
G4int ReceiveG4cerr (const G4String &cerrString) override
 Receives error output from Geant4 and forwards it to the board.
 
 ~GUI_Session () override
 Destructor.
 
- Public Member Functions inherited from GBase< GUI_Session >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Additional Inherited Members

- Protected Attributes inherited from GBase< GUI_Session >
std::shared_ptr< GLoggerlog
 

Detailed Description

This class implements the Geant4 UI session interface (G4UIsession) so that:

  • Standard output produced via Geant4 UI mechanisms is routed into a GUI log board.
  • Error output is routed similarly.

Typical usage:

  • Construct a GUI_Session with a valid GBoard pointer.
  • Register it with G4UImanager as the cout destination.
  • As Geant4 emits output, this session converts it into rich text and appends it to the board.

Ownership

GUI_Session does not own the GBoard; the caller controls the board lifetime.

Formatting

The implementation converts common ANSI formatting sequences into HTML suitable for QTextEdit rich text:

  • foreground colors 30–37
  • bold
  • underline
  • reset

Definition at line 32 of file gui_session.h.

Constructor & Destructor Documentation

◆ GUI_Session()

GUI_Session::GUI_Session ( const std::shared_ptr< GOptions > & gopt,
GBoard * board )

The constructor registers this instance as the Geant4 cout destination via G4UImanager.

Parameters
goptShared pointer to the module options/logging configuration.
boardPointer to the GBoard widget that will display forwarded messages (not owned).

Definition at line 6 of file gui_session.cc.

◆ ~GUI_Session()

GUI_Session::~GUI_Session ( )
override

Detaches this session from G4UImanager to avoid callbacks into a destroyed object.

Definition at line 207 of file gui_session.cc.

Member Function Documentation

◆ ReceiveG4cerr()

G4int GUI_Session::ReceiveG4cerr ( const G4String & cerrString)
override

The incoming string may contain multiple lines. The implementation splits the text into lines, converts each line into rich text, and appends it to the board.

Parameters
cerrStringThe error output string emitted by Geant4.
Returns
Always returns 0 (as required by G4UIsession interface).

Definition at line 36 of file gui_session.cc.

◆ ReceiveG4cout()

G4int GUI_Session::ReceiveG4cout ( const G4String & coutString)
override

The incoming string may contain multiple lines. The implementation splits the text into lines, converts each line into rich text, and appends it to the board.

Parameters
coutStringThe standard output string emitted by Geant4.
Returns
Always returns 0 (as required by G4UIsession interface).

Definition at line 15 of file gui_session.cc.


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