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

#include <G4UIQt.hh>

+ Inheritance diagram for G4UIQt:

Public Member Functions

 G4UIQt (G4int, char **)
 
G4UIsessionSessionStart ()
 
void AddMenu (const char *, const char *)
 
void AddButton (const char *, const char *, const char *)
 
void AddIcon (const char *userLabel, const char *iconFile, const char *command, const char *file_name="")
 
void OutputStyle (const char *, const char *, const char *)
 
void NativeMenu (G4bool aVal)
 
void ClearMenu ()
 
void DefaultIcons (G4bool aVal)
 
G4bool AddTabWidget (QWidget *, QString)
 
QTabWidget * GetViewerTabWidget ()
 
QWidget * GetSceneTreeWidget ()
 
QWidget * GetViewerPropertiesWidget ()
 
QWidget * GetPickInfosWidget ()
 
G4bool IsSplitterReleased ()
 
G4bool IsIconMoveSelected ()
 
G4bool IsIconRotateSelected ()
 
G4bool IsIconPickSelected ()
 
G4bool IsIconZoomInSelected ()
 
G4bool IsIconZoomOutSelected ()
 
void SetIconMoveSelected ()
 
void SetIconRotateSelected ()
 
void SetIconPickSelected ()
 
void SetIconZoomInSelected ()
 
void SetIconZoomOutSelected ()
 
void SetIconHLHSRSelected ()
 
void SetIconHLRSelected ()
 
void SetIconSolidSelected ()
 
void SetIconWireframeSelected ()
 
void SetIconPerspectiveSelected ()
 
void SetIconOrthoSelected ()
 
QMainWindow * GetMainWindow ()
 
QPixmap * getSearchIcon ()
 
QPixmap * getClearIcon ()
 
void SetStartPage (const std::string &)
 
QWidget * GetCoutWidget ()
 
G4UIDockWidgetGetCoutDockWidget ()
 
G4UIDockWidgetGetUserInterfaceWidget ()
 
QTabWidget * GetUITabWidget ()
 
QWidget * GetHistoryWidget ()
 
QWidget * GetHelpWidget ()
 
G4bool AddViewerTab (QWidget *w, std::string title)
 
G4bool AddViewerTabFromFile (std::string fileName, std::string title)
 
 ~G4UIQt ()
 
void Prompt (G4String)
 
void SessionTerminate ()
 
virtual void PauseSessionStart (const G4String &)
 
virtual G4int ReceiveG4cout (const G4String &)
 
virtual G4int ReceiveG4cerr (const G4String &)
 
- 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 123 of file G4UIQt.hh.

Constructor & Destructor Documentation

◆ G4UIQt()

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

Build a Qt window with a menubar, output area and promt area

   +-----------------------+
   |exit menu|             |
   |                       |
   | +-------------------+ |
   | |                   | |
   | |  Output area      | |
   | |                   | |
   | +-------------------+ |
   |      | clear |        |
   | +-------------------+ |
   | |  promt history    | |
   | +-------------------+ |
   | +-------------------+ |
   | |> promt area       | |
   | +-------------------+ |
   +-----------------------+

Definition at line 115 of file G4UIQt.cc.

119:fMainWindow(NULL)
120,fCommandLabel(NULL)
121,fCommandArea(NULL)
122,fCoutTBTextArea(NULL)
123,fUITabWidget(NULL)
124,fCoutFilter(NULL)
125,fCompleter(NULL)
126,fDefaultIcons(true)
127,fHistoryTBTableList(NULL)
128,fHelpTreeWidget(NULL)
129,fHelpTBWidget(NULL)
130,fHistoryTBWidget(NULL)
131,fCoutDockWidget(NULL)
132,fUIDockWidget(NULL)
133,fSceneTreeWidget(NULL)
134,fViewerPropertiesWidget(NULL)
135,fPickInfosWidget(NULL)
136,fHelpLine(NULL)
137,fViewerTabWidget(NULL)
138,fCoutText("Output")
139,fStartPage(NULL)
140,fHelpVSplitter(NULL)
141,fParameterHelpLabel(NULL)
142,fParameterHelpTable(NULL)
143,fToolbarApp(NULL)
144,fToolbarUser(NULL)
145,fStringSeparator("__$$$@%%###__")
146,fLastOpenPath("")
147,fSearchIcon(NULL)
148,fClearIcon(NULL)
149,fSaveIcon(NULL)
150,fOpenIcon(NULL)
151,fMoveIcon(NULL)
152,fRotateIcon(NULL)
153,fPickIcon(NULL)
154,fZoomInIcon(NULL)
155,fZoomOutIcon(NULL)
156,fWireframeIcon(NULL)
157,fSolidIcon(NULL)
158,fHiddenLineRemovalIcon(NULL)
159,fHiddenLineAndSurfaceRemovalIcon(NULL)
160,fPerspectiveIcon(NULL)
161,fOrthoIcon(NULL)
162,fCommandIcon(NULL)
163,fDirIcon(NULL)
164,fRunIcon(NULL)
165,fParamIcon(NULL)
166,fPickTargetIcon(NULL)
167#ifdef G4MULTITHREADED
168,fThreadsFilterComboBox(NULL)
169#endif
170,fDefaultViewerFirstPageHTMLText("")
171,fViewerPropertiesDialog(NULL)
172,fPickInfosDialog(NULL)
173,fLastCompleteCommand("")
174,fMoveSelected(false)
175,fRotateSelected(true)
176,fPickSelected(false)
177,fZoomInSelected(false)
178,fZoomOutSelected(false)
179{
180
181 G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");
182 if (!(QApplication*)interactorManager->GetMainInteractor()) {
184 G4int verbose = UImanager->GetVerboseLevel();
185
186 if (verbose >= 2) {
187 G4cout << "G4UIQt : Unable to init Qt. Aborted" << G4endl;
188 }
189 }
190
192 if(UI!=NULL) UI->SetSession(this);
193 if(UI!=NULL) UI->SetG4UIWindow(this);
194
195 // Check if already define in external app QMainWindow
196 G4bool found = false;
197 Q_FOREACH (QWidget *widget, QApplication::allWidgets()) {
198 if ((found== false) && (widget->inherits("QMainWindow"))) {
199 found = true;
200 }
201 }
202
203 if (found) {
205 G4int verbose = UImanager->GetVerboseLevel();
206
207 if (verbose >= 2) {
208 G4cout << "G4UIQt : Found an external App with a QMainWindow already defined. Aborted" << G4endl;
209 }
210 return ;
211 }
212 CreateIcons();
213
214 // Set default output styles
215 for (const auto& destination: {"cout","cerr","warnings","errors"}) {
216 G4UIQtStyle defaultStyle;
217 defaultStyle.fixed = true;
218 defaultStyle.highlight = true;
219 fOutputStyles[destination] = defaultStyle;
220 }
221
222 fMainWindow = new QMainWindow();
223 fMainWindow->setAttribute(Qt::WA_DeleteOnClose);
224
225 fMainWindow->setCorner( Qt::TopLeftCorner, Qt::LeftDockWidgetArea );
226 fMainWindow->setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
227 fMainWindow->setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
228 fMainWindow->setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
229
230 CreateViewerWidget();
231 fMainWindow->addDockWidget(Qt::LeftDockWidgetArea, CreateUITabWidget());
232 fMainWindow->addDockWidget(Qt::BottomDockWidgetArea, CreateCoutTBWidget());
233
234
235 // add defaults icons
236 SetDefaultIconsToolbar();
237
238 if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP
239
240#ifdef G4MULTITHREADED
241 // explicitly request that cout/cerr messages from threads are ALSO propagated to the master.
243#endif
244
245 fMainWindow->setWindowTitle(QFileInfo( QCoreApplication::applicationFilePath() ).fileName());
246 fMainWindow->move(QPoint(50,50));
247
248 // force the size at be correct at the beggining
249 // because the widget is not realized yet, the size of the main window is not up to date. But
250 // we need it in order to add some viewer inside
251 fMainWindow->resize(fUIDockWidget->width()+fCoutDockWidget->width()+20,
252 fUIDockWidget->height()+fCoutDockWidget->height()+20);
253
254 // set last focus on command line
255 fCommandArea->setFocus(Qt::TabFocusReason);
256
257 // Allow QTextCursor to be called by another thread :
258 // http://qt-project.org/doc/qt-4.8/qmetatype.html#qRegisterMetaType
259 qRegisterMetaType<QTextCursor>("QTextCursor");
260
261 // add some tips
262 AddTabWidget(fStartPage,"Useful tips");
263
264 // Set not visible until session start
265 #if QT_VERSION < 0x040200
266 fMainWindow->hide();
267 #else
268 fMainWindow->setVisible(false);
269 #endif
270}
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
Definition: G4Qt.hh:49
static G4Qt * getInstance()
Definition: G4Qt.cc:51
G4bool AddTabWidget(QWidget *, QString)
Definition: G4UIQt.cc:1860
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:747
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:200
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void SetSession(G4UIsession *const value)
Definition: G4UImanager.hh:190
void SetG4UIWindow(G4UIsession *const value)
Definition: G4UImanager.hh:191
G4Interactor GetMainInteractor()
static G4MTGLOB_DLL G4coutDestination * masterG4coutDestination

◆ ~G4UIQt()

G4UIQt::~G4UIQt ( )

Definition at line 274 of file G4UIQt.cc.

276{
277 G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP
278 if(UI!=NULL) { // TO KEEP
279 UI->SetSession(NULL); // TO KEEP
280 UI->SetG4UIWindow(NULL);
281 UI->SetCoutDestination(0); // TO KEEP
282#ifdef G4MULTITHREADED
283 masterG4coutDestination = 0; // set to cout when UI is deleted
284#endif
285 }
286}

Member Function Documentation

◆ AddButton()

void G4UIQt::AddButton ( const char *  aMenu,
const char *  aLabel,
const char *  aCommand 
)
virtual

Add a new button to a menu

Parameters
aMenu: parent menu
aLabel: label to display
aCommand: command to execute as a callback

Reimplemented from G4VInteractiveSession.

Definition at line 2354 of file G4UIQt.cc.

2359{
2360 if(aMenu==NULL) return; // TO KEEP
2361 if(aLabel==NULL) return; // TO KEEP
2362 if(aCommand==NULL) return; // TO KEEP
2363
2364 QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
2365
2366 if(parentTmp==NULL) {
2368 G4int verbose = UImanager->GetVerboseLevel();
2369
2370 if (verbose >= 2) {
2371 G4cout << "Menu name " << aMenu<< " does not exist, please define it before using it."<< G4endl;
2372 }
2373 return;
2374 }
2375
2376 // Find the command in the command tree
2378 if(UI==NULL) return;
2379 G4UIcommandTree * treeTop = UI->GetTree();
2380
2381 G4String cmd = aCommand;
2382 std::size_t cmdEndPos = cmd.find_first_of(" \t");
2383 if(cmdEndPos!=std::string::npos) {
2384 cmd.erase(cmdEndPos);
2385 }
2386
2387 if(treeTop->FindPath(cmd) == NULL) {
2388 if(cmd != "ls" &&
2389 cmd.substr(0,3) != "ls " &&
2390 cmd != "pwd" &&
2391 cmd != "cd" &&
2392 cmd.substr(0,3) != "cd " &&
2393 cmd != "help" &&
2394 cmd.substr(0,5) != "help " &&
2395 cmd[0] != '?' &&
2396 cmd != "hist" &&
2397 cmd != "history" &&
2398 cmd[0] != '!' &&
2399 cmd != "exit" &&
2400 cmd != "cont" &&
2401 cmd != "continue"){
2403 G4int verbose = UImanager->GetVerboseLevel();
2404
2405 if (verbose >= 2) {
2406 G4cout << "Warning: command '"<< cmd <<"' does not exist, please define it before using it."<< G4endl;
2407 }
2408 }
2409 }
2410
2411#if QT_VERSION < 0x050600
2412 QSignalMapper *signalMapper = new QSignalMapper(this);
2413 QAction *action = parentTmp->addAction(aLabel, signalMapper, SLOT(map()));
2414
2415 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ButtonCallback(const QString&)));
2416 signalMapper->setMapping(action, QString(aCommand));
2417#else
2418 QString cmd_tmp = QString(aCommand);
2419 parentTmp->addAction(aLabel, this, [this, cmd_tmp](){ this->ButtonCallback(cmd_tmp); });
2420#endif
2421}
G4UIcommand * FindPath(const char *commandPath) const
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
G4Interactor GetInteractor(G4String)

◆ AddIcon()

void G4UIQt::AddIcon ( const char *  aLabel,
const char *  aIconFile,
const char *  aCommand,
const char *  aFileName = "" 
)
virtual

special case for the "open" icon. It will open a file selector and map the return file to the given command.

Reimplemented from G4VInteractiveSession.

Definition at line 2429 of file G4UIQt.cc.

2429 {
2430 if(aLabel==NULL) return; // TO KEEP
2431 // special case, aCommand could be NULL if aIconFile is not user_icon
2432 if (aCommand==NULL) {
2433 if (std::string(aIconFile) == "user_icon") {
2434 return; // TO KEEP
2435 }
2436 }
2437 QPixmap* pix;
2438 G4bool userToolBar = false;
2439
2440 if (!fDefaultIcons) {
2441 userToolBar = true;
2442 }
2443 if (std::string(aIconFile) == "user_icon") {
2444 // try to open a file
2446 pix = new QPixmap(UImanager->FindMacroPath(aFileName).data());
2447 if (pix->isNull()) {
2448 G4int verbose = UImanager->GetVerboseLevel();
2449
2450 if (verbose >= 2) {
2451 G4cout << "Warning: file '"<< aFileName <<"' is incorrect or does not exist, this command will not be build"<< G4endl;
2452 }
2453 return;
2454 }
2455 } else if (std::string(aIconFile) == "open") {
2456 pix = fOpenIcon;
2457 } else if (std::string(aIconFile) == "save") {
2458 pix = fSaveIcon;
2459 } else if (std::string(aIconFile) == "move") {
2460 pix = fMoveIcon;
2461 } else if (std::string(aIconFile) == "rotate") {
2462 pix = fRotateIcon;
2463 } else if (std::string(aIconFile) == "pick") {
2464 pix = fPickIcon;
2465 } else if (std::string(aIconFile) == "zoom_in") {
2466 pix = fZoomInIcon;
2467 } else if (std::string(aIconFile) == "zoom_out") {
2468 pix = fZoomOutIcon;
2469 } else if (std::string(aIconFile) == "wireframe") {
2470 pix = fWireframeIcon;
2471 } else if (std::string(aIconFile) == "solid") {
2472 pix = fSolidIcon;
2473 } else if (std::string(aIconFile) == "hidden_line_removal") {
2474 pix = fHiddenLineRemovalIcon;
2475 } else if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
2476 pix = fHiddenLineAndSurfaceRemovalIcon;
2477 } else if (std::string(aIconFile) == "perspective") {
2478 pix = fPerspectiveIcon;
2479 } else if (std::string(aIconFile) == "ortho") {
2480 pix = fOrthoIcon;
2481 } else if (std::string(aIconFile) == "runBeamOn") {
2482 pix = fRunIcon;
2483 } else if (std::string(aIconFile) == "exit") {
2484 pix = fExitIcon;
2485 } else {
2487 G4int verbose = UImanager->GetVerboseLevel();
2488
2489 if (verbose >= 2) {
2490 G4cout << "Parameter"<< aIconFile <<" not defined"<< G4endl;
2491 }
2492 return;
2493 }
2494 QToolBar *currentToolbar = NULL;
2495 if (userToolBar) {
2496 if (fToolbarUser == NULL) {
2497 fToolbarUser = new QToolBar();
2498 fToolbarUser->setIconSize (QSize(20,20));
2499 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
2500 }
2501 currentToolbar = fToolbarUser;
2502 } else {
2503 if (fToolbarApp == NULL) {
2504 fToolbarApp = new QToolBar();
2505 fToolbarApp->setIconSize (QSize(20,20));
2506 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
2507 }
2508 currentToolbar = fToolbarApp;
2509 }
2510
2511 // Check if already present
2512
2513 QList<QAction*> list = currentToolbar->actions();
2514
2515 for (G4int i = 0; i < list.size(); ++i) {
2516 if (list.at(i)->text() == QString(aLabel)) {
2518 if(UI==NULL) return;
2519 G4int verbose = UI->GetVerboseLevel();
2520 if (verbose >= 2) {
2521 G4cout << "Warning: A toolBar icon \""<< aLabel<< "\" already exists with the same name!" << G4endl;
2522 }
2523 }
2524 }
2525
2526#if QT_VERSION < 0x050600
2527 QSignalMapper *signalMapper = new QSignalMapper(this);
2528 QAction *action = currentToolbar->addAction(QIcon(*pix),aLabel, signalMapper, SLOT(map()));
2529#endif
2530 // special cases :"open"
2531 if (std::string(aIconFile) == "open") {
2532 QString txt = aCommand + fStringSeparator + aLabel;
2533#if QT_VERSION < 0x050600
2534 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(OpenIconCallback(const QString &)));
2535 signalMapper->setMapping(action, QString(txt));
2536#else
2537 currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this, txt](){ this->OpenIconCallback(txt); });
2538#endif
2539
2540 // special cases :"save"
2541 } else if (std::string(aIconFile) == "save") {
2542 QString txt = aCommand + fStringSeparator + aLabel;
2543#if QT_VERSION < 0x050600
2544 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(SaveIconCallback(const QString&)));
2545 signalMapper->setMapping(action, QString(txt));
2546#else
2547 currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this, txt](){ this->SaveIconCallback(txt); });
2548#endif
2549
2550 // special cases : cursor style
2551 } else if ((std::string(aIconFile) == "move") ||
2552 (std::string(aIconFile) == "rotate") ||
2553 (std::string(aIconFile) == "pick") ||
2554 (std::string(aIconFile) == "zoom_out") ||
2555 (std::string(aIconFile) == "zoom_in")) {
2556#if QT_VERSION < 0x050600
2557 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ChangeCursorAction(const QString&)));
2558 signalMapper->setMapping(action, QString(aIconFile));
2559#else
2560 QString txt = QString(aIconFile);
2561 QAction* action = currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this, txt](){ this->ChangeCursorAction(txt); });
2562#endif
2563 action->setCheckable(TRUE);
2564 action->setChecked(TRUE);
2565 action->setData(aIconFile);
2566
2567 if (std::string(aIconFile) == "move") {
2569 }
2570 if (std::string(aIconFile) == "rotate") {
2572 }
2573 if (std::string(aIconFile) == "pick") {
2575 }
2576 if (std::string(aIconFile) == "zoom_in") {
2578 }
2579 if (std::string(aIconFile) == "zoom_out") {
2581 }
2582
2583 // special case : surface style
2584 } else if ((std::string(aIconFile) == "hidden_line_removal") ||
2585 (std::string(aIconFile) == "hidden_line_and_surface_removal") ||
2586 (std::string(aIconFile) == "solid") ||
2587 (std::string(aIconFile) == "wireframe")) {
2588#if QT_VERSION < 0x050600
2589 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ChangeSurfaceStyle(const QString&)));
2590 signalMapper->setMapping(action, QString(aIconFile));
2591#else
2592 QString txt = QString(aIconFile);
2593 QAction* action = currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this, txt](){ this->ChangeSurfaceStyle(txt); });
2594#endif
2595 action->setCheckable(TRUE);
2596 action->setChecked(TRUE);
2597 action->setData(aIconFile);
2598
2599 if (std::string(aIconFile) == "hidden_line_removal") {
2601 }
2602 if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
2604 }
2605 if (std::string(aIconFile) == "solid") {
2607 }
2608 if (std::string(aIconFile) == "wireframe") {
2610 }
2611
2612 // special case : perspective/ortho
2613 } else if ((std::string(aIconFile) == "perspective") ||
2614 (std::string(aIconFile) == "ortho")) {
2615#if QT_VERSION < 0x050600
2616 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ChangePerspectiveOrtho(const QString&)));
2617 signalMapper->setMapping(action, QString(aIconFile));
2618#else
2619 QString txt = QString(aIconFile);
2620 QAction* action = currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this, txt](){ this->ChangePerspectiveOrtho(txt); });
2621#endif
2622 action->setCheckable(TRUE);
2623 action->setChecked(TRUE);
2624 action->setData(aIconFile);
2625
2626 if (std::string(aIconFile) == "perspective") {
2628 }
2629 if (std::string(aIconFile) == "ortho") {
2631 }
2632
2633 } else {
2634
2635 // Find the command in the command tree
2637 if(UI==NULL) return;
2638 G4UIcommandTree * treeTop = UI->GetTree();
2639 if (aCommand != NULL) {
2640 std::string str = aCommand;
2641 std::string::size_type pos = str.find(" ");
2642 if (pos != std::string::npos)
2643 {
2644 str = str.substr(0,pos).c_str();
2645 }
2646 if(treeTop->FindPath(str.c_str()) == NULL) {
2648 G4int verbose = UImanager->GetVerboseLevel();
2649
2650 if (verbose >= 2) {
2651 G4cout << "Warning: command '"<< aCommand <<"' does not exist, please define it before using it."<< G4endl;
2652 }
2653 }
2654 }
2655
2656#if QT_VERSION < 0x050600
2657 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ButtonCallback(const QString&)));
2658 signalMapper->setMapping(action, QString(aCommand));
2659#else
2660 QString txt = QString(aCommand);
2661 currentToolbar->addAction(QIcon(*pix), aCommand, this, [this, txt](){ this->ButtonCallback(txt); });
2662#endif
2663 }
2664}
void SetIconPickSelected()
Definition: G4UIQt.cc:4868
void SetIconOrthoSelected()
Definition: G4UIQt.cc:5081
void SetIconZoomInSelected()
Definition: G4UIQt.cc:4899
void SetIconZoomOutSelected()
Definition: G4UIQt.cc:4930
void SetIconHLRSelected()
Definition: G4UIQt.cc:5009
void SetIconPerspectiveSelected()
Definition: G4UIQt.cc:5059
void SetIconSolidSelected()
Definition: G4UIQt.cc:4961
void SetIconRotateSelected()
Definition: G4UIQt.cc:4842
void SetIconWireframeSelected()
Definition: G4UIQt.cc:4985
void SetIconMoveSelected()
Definition: G4UIQt.cc:4816
void SetIconHLHSRSelected()
Definition: G4UIQt.cc:5034
G4String FindMacroPath(const G4String &fname) const
Definition: G4UImanager.cc:845
#define TRUE
Definition: globals.hh:41

Referenced by DefaultIcons().

◆ AddMenu()

void G4UIQt::AddMenu ( const char *  aName,
const char *  aLabel 
)
virtual

Add a new menu to the menu bar

Parameters
aNamename of menu
aLabellabel to display

Reimplemented from G4VInteractiveSession.

Definition at line 2333 of file G4UIQt.cc.

2337{
2338 if (aName == NULL) return;
2339 if (aLabel == NULL) return;
2340
2341 QMenu *fileMenu = new QMenu(aLabel);
2342 fMainWindow->menuBar()->addMenu(fileMenu);
2343
2344 AddInteractor (aName,(G4Interactor)fileMenu);
2345}
void * G4Interactor
void AddInteractor(G4String, G4Interactor)

◆ AddTabWidget()

G4bool G4UIQt::AddTabWidget ( QWidget *  aWidget,
QString  name 
)

Add a new tab widget. Create the tab if it was not done

Definition at line 1860 of file G4UIQt.cc.

1864{
1865 // Special case for Qt version between 5.0 and 5.1 on Mac OSX
1866 // Due to a bug in this Qt version, we can't put a OpenGL Widget inside the QTabWidget.
1867 // A work around is to put it outside. Returning false will fore the wiewer to put the QGLWidget
1868 // inside a new QWindow.
1869
1870#ifdef Q_OS_MAC
1871 #if QT_VERSION < 0x050100
1872 #if QT_VERSION >= 0x050000
1873 QString message = QString(
1874 "This Qt version [")+qVersion ()+"] has some issues with the OpenGL viewer.\n"+
1875 "To prevent problems, you are not allowed to open a Stored nor Immediate viewer.\n" +
1876 "\n" +
1877 "Please upgrade to Qt version >= 5.1\n";
1878
1879 QMessageBox::warning(fMainWindow, tr("Warning"),
1880 tr(message.toStdString().c_str()),
1881 QMessageBox::Ok);
1882 return false;
1883 #endif
1884 #endif
1885#endif
1886
1887 if (fViewerTabWidget == NULL) {
1888 CreateViewerWidget();
1889 }
1890
1891 if (!aWidget) {
1892 return false;
1893 }
1894// Has to be added before we put it into the fViewerTabWidget widget
1895 aWidget->setParent(fViewerTabWidget); // Will create in some cases widget outside
1896 // of UI for a really short moment
1897
1898 fViewerTabWidget->addTab(aWidget,name);
1899
1900 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
1901
1902 // Set visible
1903 #if QT_VERSION < 0x040200
1904 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
1905 #else
1906 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
1907 #endif
1908
1909 // Not the good solution, but ensure that the help tree is correctly build when launching a viewer
1910 // It should be done by a notification when adding a command, but that's nit done yet (Geant4.10.1)␓
1911 FillHelpTree();
1912
1913 return true;
1914}
void setLastTabCreated(G4int a)
Definition: G4UIQt.hh:91

Referenced by G4OpenInventorQtExaminerViewer::afterRealizeHook(), G4OpenGLQtViewer::CreateMainWindow(), G4VtkQtViewer::CreateMainWindow(), G4UIQt(), and G4ToolsSGQtViewer::Initialise().

◆ AddViewerTab()

G4bool G4UIQt::AddViewerTab ( QWidget *  aWidget,
std::string  title 
)

Add a new tab in the viewer

Definition at line 1811 of file G4UIQt.cc.

1815{
1816 if (fViewerTabWidget == NULL) {
1817 return false;
1818 }
1819 fViewerTabWidget->addTab(aWidget,title.c_str());
1820
1821 return true;
1822}

◆ AddViewerTabFromFile()

G4bool G4UIQt::AddViewerTabFromFile ( std::string  fileName,
std::string  title 
)

Add a new tab in the viewer

Definition at line 1827 of file G4UIQt.cc.

1831{
1832 if (fViewerTabWidget == NULL) {
1833 return false;
1834 }
1835
1837 if(UI==NULL) return 0;
1838 std::ifstream file(UI->FindMacroPath(fileName.c_str()).data());
1839 if (file) {
1840
1841 std::string content( (std::istreambuf_iterator<char>(file) ),
1842 (std::istreambuf_iterator<char>() ) );
1843
1844 QTextEdit* text = new QTextEdit();
1845 text->setAcceptRichText (true);
1846 text->setContentsMargins(5,5,5,5);
1847 text->setText(QString("<pre>")+content.c_str()+"</pre>");
1848 text->setReadOnly(true);
1849 fViewerTabWidget->addTab(text,title.c_str());
1850 } else {
1851 return false;
1852 }
1853 return true;
1854}

◆ ClearMenu()

void G4UIQt::ClearMenu ( )
virtual

Reimplemented from G4VInteractiveSession.

Definition at line 2695 of file G4UIQt.cc.

2696{
2697 fMainWindow->menuBar()->clear();
2698}

◆ DefaultIcons()

void G4UIQt::DefaultIcons ( G4bool  aVal)
virtual

Reimplemented from G4VInteractiveSession.

Definition at line 289 of file G4UIQt.cc.

290{
291 fDefaultIcons = aVal;
292
293#if QT_VERSION < 0x040200
294 if (!fMainWindow->isHidden()) {
295#else
296 if (!fMainWindow->isVisible()) {
297#endif
298 return;
299 }
300
301 if (fToolbarApp) {
302 if (aVal) {
303#if QT_VERSION < 0x040200
304 fToolbarApp->show();
305#else
306 fToolbarApp->setVisible(true);
307#endif
308 } else {
309 // Set not visible until session start
310#if QT_VERSION < 0x040200
311 fToolbarApp->hide();
312#else
313 fToolbarApp->setVisible(false);
314#endif
315 }
316 }
317}

◆ getClearIcon()

QPixmap * G4UIQt::getClearIcon ( )
inline

Definition at line 217 of file G4UIQt.hh.

217{ return fClearIcon;};

◆ GetCoutDockWidget()

G4UIDockWidget * G4UIQt::GetCoutDockWidget ( )
inline

Definition at line 230 of file G4UIQt.hh.

230 {
231 return fCoutDockWidget;
232 };

◆ GetCoutWidget()

QWidget * G4UIQt::GetCoutWidget ( )
inline

Definition at line 225 of file G4UIQt.hh.

225 {
226 return fCoutDockWidget->widget();
227 };

◆ GetHelpWidget()

QWidget * G4UIQt::GetHelpWidget ( )
inline

Definition at line 250 of file G4UIQt.hh.

250 {
251 return fHelpTBWidget;
252 }

◆ GetHistoryWidget()

QWidget * G4UIQt::GetHistoryWidget ( )
inline

Definition at line 245 of file G4UIQt.hh.

245 {
246 return fHistoryTBWidget;
247 }

◆ GetMainWindow()

QMainWindow * G4UIQt::GetMainWindow ( )
inline

Definition at line 210 of file G4UIQt.hh.

210 {
211 return fMainWindow;
212 };

Referenced by G4ToolsSGQtViewer::Initialise().

◆ GetPickInfosWidget()

QWidget * G4UIQt::GetPickInfosWidget ( )

Get the Pick Widget

Definition at line 1799 of file G4UIQt.cc.

1801{
1802 if (!fPickInfosDialog) {
1803 CreatePickInfosDialog();
1804 }
1805 return fPickInfosWidget;
1806}

◆ GetSceneTreeWidget()

QWidget * G4UIQt::GetSceneTreeWidget ( )

Get the ViewerComponents ToolBox Widget

Definition at line 1780 of file G4UIQt.cc.

1782{
1783 return fSceneTreeWidget;
1784}

◆ getSearchIcon()

QPixmap * G4UIQt::getSearchIcon ( )
inline

Definition at line 215 of file G4UIQt.hh.

215{ return fSearchIcon;};

◆ GetUITabWidget()

QTabWidget * G4UIQt::GetUITabWidget ( )
inline

Definition at line 240 of file G4UIQt.hh.

240 {
241 return fUITabWidget;
242 }

◆ GetUserInterfaceWidget()

G4UIDockWidget * G4UIQt::GetUserInterfaceWidget ( )
inline

Definition at line 235 of file G4UIQt.hh.

235 {
236 return fUIDockWidget;
237 };

◆ GetViewerPropertiesWidget()

QWidget * G4UIQt::GetViewerPropertiesWidget ( )

Get the Viewer properties Widget

Definition at line 1788 of file G4UIQt.cc.

1790{
1791 if (!fViewerPropertiesDialog) {
1792 CreateViewerPropertiesDialog();
1793 }
1794 return fViewerPropertiesWidget;
1795}

◆ GetViewerTabWidget()

QTabWidget * G4UIQt::GetViewerTabWidget ( )
inline

Definition at line 167 of file G4UIQt.hh.

167 {
168 return fViewerTabWidget;
169 };

Referenced by G4OpenInventorQtExaminerViewer::afterRealizeHook(), G4OpenGLQtViewer::CreateMainWindow(), and G4OpenGLQtViewer::isCurrentWidget().

◆ IsIconMoveSelected()

G4bool G4UIQt::IsIconMoveSelected ( )
inline

◆ IsIconPickSelected()

G4bool G4UIQt::IsIconPickSelected ( )
inline

Definition at line 188 of file G4UIQt.hh.

188 {
189 return fPickSelected;
190 };

Referenced by G4OpenGLQtViewer::G4MousePressEvent(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ IsIconRotateSelected()

G4bool G4UIQt::IsIconRotateSelected ( )
inline

Definition at line 185 of file G4UIQt.hh.

185 {
186 return fRotateSelected;
187 };

Referenced by G4OpenGLQtViewer::G4MousePressEvent(), G4OpenGLQtViewer::G4MouseReleaseEvent(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ IsIconZoomInSelected()

G4bool G4UIQt::IsIconZoomInSelected ( )
inline

Definition at line 191 of file G4UIQt.hh.

191 {
192 return fZoomInSelected;
193 };

Referenced by G4OpenGLQtViewer::G4MousePressEvent(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ IsIconZoomOutSelected()

G4bool G4UIQt::IsIconZoomOutSelected ( )
inline

Definition at line 194 of file G4UIQt.hh.

194 {
195 return fZoomOutSelected;
196 };

Referenced by G4OpenGLQtViewer::G4MousePressEvent(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ IsSplitterReleased()

G4bool G4UIQt::IsSplitterReleased ( )

◆ NativeMenu()

void G4UIQt::NativeMenu ( G4bool  aVal)
virtual

Reimplemented from G4VInteractiveSession.

Definition at line 2686 of file G4UIQt.cc.

2687{
2688 if ( fMainWindow->menuBar()->isNativeMenuBar() == aVal )
2689 return; // already in this state
2690
2691 // Menu become empty when goin from Qt to Native Bar
2692 fMainWindow->menuBar()->setNativeMenuBar(aVal);
2693}

◆ OutputStyle()

void G4UIQt::OutputStyle ( const char *  destination,
const char *  style,
const char *  highlight 
)
virtual

Reimplemented from G4VInteractiveSession.

Definition at line 2667 of file G4UIQt.cc.

2668{
2669 // Specify an output style
2670 // First argument destination (cout cerr warnings errors all)
2671 // Second argument is the style (fixed proportional)
2672 // Third argument highlights commands if "highlight" (and if /control/verbose > 0)
2673 G4String uiQtDestination(destination);
2674 G4UIQtStyle uiQtStyle;
2675 if (G4String(style) == "fixed") uiQtStyle.fixed = true; else uiQtStyle.fixed = false;
2676 if (G4String(highlight) == "highlight") uiQtStyle.highlight = true; else uiQtStyle.highlight = false;
2677 if (uiQtDestination == "all") {
2678 for (auto& i: fOutputStyles) {
2679 i.second = uiQtStyle;
2680 }
2681 } else {
2682 fOutputStyles[uiQtDestination] = uiQtStyle;
2683 }
2684}

◆ PauseSessionStart()

void G4UIQt::PauseSessionStart ( const G4String aState)
virtual

Called by intercoms/src/G4UImanager.cc
Called by visualization/management/src/G4VisCommands.cc with "EndOfEvent" argument
It have to pause the session command terminal.
Call SecondaryLoop to wait for exit event

Parameters
aState
See also
: G4VisCommandReviewKeptEvents::SetNewValue

Implements G4VBasicShell.

Definition at line 2050 of file G4UIQt.cc.

2053{
2054 if (!aState) return;
2055
2056 if(aState=="G4_pause> ") { // TO KEEP
2057 SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP
2058 } // TO KEEP
2059
2060 if(aState=="EndOfEvent") { // TO KEEP
2061 // Picking with feed back in event data Done here !!!
2062 SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP
2063 } // TO KEEP
2064}

◆ Prompt()

void G4UIQt::Prompt ( G4String  aPrompt)

Display the prompt in the prompt area

Parameters
aPrompt: string to display as the promt label

Definition at line 2021 of file G4UIQt.cc.

2024{
2025 if (!aPrompt) return;
2026
2027 fCommandLabel->setText((char*)aPrompt.data());
2028}

Referenced by SessionStart().

◆ ReceiveG4cerr()

G4int G4UIQt::ReceiveG4cerr ( const G4String aString)
virtual

Receive a cerr from Geant4. We have to display it in the cout zone

Parameters
aString: label to add in the display area
Returns
0

Reimplemented from G4UIsession.

Definition at line 2195 of file G4UIQt.cc.

2198{
2199 if (aString.empty()) return 0;
2200
2201#ifdef G4MULTITHREADED
2202 G4AutoLock al(&ReceiveG4cerrMutex);
2203#endif
2204
2205 // Workaround so that output is not lost after crash or G4Exception
2206 // It seems workers write to std::cerr anyway, so limit this to the master
2207#ifdef G4MULTITHREADED
2209#endif
2210 std::cerr << aString;
2211
2212 G4String aStringWithStyle;
2213 // aString has a \n on the end (maybe it comes from G4endl or from the
2214 // Enter key on the command line) - ignore it. That’s why
2215 // i < aString.length() - 1
2216 // But other \n need to be translated to an HTML newline.
2217 // Similarly, spaces need to be translated to an HTML "non-breaking space".
2218 // Tabs (\t) are more tricky since the number of equivalent spaces depends
2219 // on how many characters precede it. Probably needs an HTML table. For now
2220 // we replace \t with four spaces.
2221 for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
2222 if (aString[i] == '\n') {
2223 aStringWithStyle += "<br>";
2224 } else if (aString[i] == ' ') {
2225 aStringWithStyle += "&nbsp;";
2226 } else if (aString[i] == '\t') {
2227 aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
2228 } else if (aString[i] == '<') {
2229 aStringWithStyle += "&lt;";
2230 } else {
2231 aStringWithStyle += aString[i];
2232 }
2233 }
2234 if (fOutputStyles["cerr"].fixed) {
2235 aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
2236 } else {
2237 aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
2238 }
2239
2240 // Add to string
2241
2242 G4UIOutputString txt = G4UIOutputString(QString((char*)aStringWithStyle.data()).trimmed(),
2243 GetThreadPrefix(),
2244 "error");
2245 fG4OutputString.push_back(txt);
2246
2247#ifdef G4MULTITHREADED
2248 QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
2249#else
2250 QString result = FilterOutput(txt,"",fCoutFilter->text());
2251#endif
2252 if (result.isEmpty()) {
2253 return 0;
2254 }
2255
2256 // Suppress space, \n,\t,\r...
2257 if (QString(aString.data()).trimmed() != "") {
2258 if ((G4StateManager::GetStateManager()->GetCurrentState() == G4State_Abort) ||
2259 (G4StateManager::GetStateManager()->GetCurrentState() == G4State_Quit )) {
2260 // In case of Abort or Quit, the useful error message should be in the last error message !
2261 fLastErrMessage += "\n"+aString;
2262 QString criticalMessage = fLastErrMessage.data();
2263#if QT_VERSION < 0x050000
2264 criticalMessage = Qt::escape(criticalMessage);
2265#else
2266 criticalMessage = criticalMessage.toHtmlEscaped();
2267#endif
2268 QMessageBox::critical(fMainWindow, "Error",QString(fLastErrMessage));
2269 }
2270 }
2271 fCoutTBTextArea->append(QString("<font color=\"Red\">") +
2272 result + QString("</font>"));
2273 fCoutTBTextArea->ensureCursorVisible ();
2274
2275 if (QString(aString.data()).trimmed() != "") {
2276 fLastErrMessage += aString;
2277 }
2278#ifdef G4MULTITHREADED
2279 UpdateCoutThreadFilter();
2280#endif
2281 return 0;
2282}
@ G4State_Quit
@ G4State_Abort
static G4StateManager * GetStateManager()
G4bool IsMasterThread()
Definition: G4Threading.cc:124

Referenced by ReceiveG4cout().

◆ ReceiveG4cout()

G4int G4UIQt::ReceiveG4cout ( const G4String aString)
virtual

Receive a cout from Geant4. We have to display it in the cout zone

Parameters
aString: label to add in the display area
Returns
0

Reimplemented from G4UIsession.

Definition at line 2102 of file G4UIQt.cc.

2105{
2106 if(aString.empty()) return 0;
2107
2108#ifdef G4MULTITHREADED
2109 G4AutoLock al(&ReceiveG4coutMutex);
2110#endif
2111
2112 // Try to be smart :
2113 // "*** This is just a warning message. ***"
2114 if (G4StrUtil::contains(aString, "*** This is just a warning message. ***")) {
2115 return ReceiveG4cerr(aString);
2116 }
2117
2118 // Workaround so that output is not lost after crash or G4Exception
2119 // It seems workers write to std::cout anyway, so limit this to the master
2120#ifdef G4MULTITHREADED
2122#endif
2123 std::cout << aString;
2124
2125 G4String aStringWithStyle;
2126 // aString has a \n on the end (maybe it comes from G4endl or from the
2127 // Enter key on the command line) - ignore it. That’s why
2128 // i < aString.length() - 1
2129 // But other \n need to be translated to an HTML newline.
2130 // Similarly, spaces need to be translated to an HTML "non-breaking space".
2131 // Tabs (\t) are more tricky since the number of equivalent spaces depends
2132 // on how many characters precede it. Probably needs an HTML table. For now
2133 // we replace \t with four spaces.
2134 for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
2135 if (aString[i] == '\n') {
2136 aStringWithStyle += "<br>";
2137 } else if (aString[i] == ' ') {
2138 aStringWithStyle += "&nbsp;";
2139 } else if (aString[i] == '\t') {
2140 aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
2141 } else if (aString[i] == '<') {
2142 aStringWithStyle += "&lt;";
2143 } else {
2144 aStringWithStyle += aString[i];
2145 }
2146 }
2147 if (fOutputStyles["cout"].fixed) {
2148 aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
2149 } else {
2150 aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
2151 }
2152
2153 // Add to string
2154 G4UIOutputString txt = G4UIOutputString(QString((char*)aStringWithStyle.data()),GetThreadPrefix());
2155 fG4OutputString.push_back(txt);
2156
2157#ifdef G4MULTITHREADED
2158 QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
2159#else
2160 QString result = FilterOutput(txt,"",fCoutFilter->text());
2161#endif
2162
2163 if (result.isEmpty()) {
2164 return 0;
2165 }
2166
2168 if (fOutputStyles["cout"].highlight) {
2169 if (!UI->IsLastCommandOutputTreated() ) {
2170 QPalette pal;
2171 result = QString("<span style='background:") + pal.link().color().name() + ";'>&nbsp;</span>"
2172 + "<span style='background:" + pal.highlight().color().name() +";'> " + result + "</span>";
2173 }
2174 }
2176
2177 fCoutTBTextArea->append(result);
2178 fCoutTBTextArea->ensureCursorVisible ();
2179
2180#ifdef G4MULTITHREADED
2181 UpdateCoutThreadFilter();
2182#endif
2183
2184 // reset error stack
2185 fLastErrMessage = aString;
2186 return 0;
2187}
virtual G4int ReceiveG4cerr(const G4String &)
Definition: G4UIQt.cc:2195
bool IsLastCommandOutputTreated()
Definition: G4UImanager.hh:256
void SetLastCommandOutputTreated()
Definition: G4UImanager.hh:257
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.

◆ SessionStart()

G4UIsession * G4UIQt::SessionStart ( )
virtual

Start the Qt main loop

Implements G4VBasicShell.

Definition at line 1967 of file G4UIQt.cc.

1969{
1970 G4Qt* interactorManager = G4Qt::getInstance ();
1971 Prompt("Session :");
1972 exitSession = false;
1973
1974 QCoreApplication::sendPostedEvents () ;
1975
1976 #if QT_VERSION < 0x040200
1977 fMainWindow->show();
1978 #else
1979 fMainWindow->setVisible(true);
1980 #endif
1981
1982 if (fDefaultIcons) {
1983#if QT_VERSION < 0x040200
1984 fToolbarApp->show();
1985#else
1986 fToolbarApp->setVisible(true);
1987#endif
1988 } else {
1989 // Set not visible until session start
1990#if QT_VERSION < 0x040200
1991 fToolbarApp->hide();
1992#else
1993 fToolbarApp->setVisible(false);
1994#endif
1995 }
1996 // Rebuild help tree (new command could be registered)
1997 FillHelpTree();
1998
1999 // Rebuild command completion (new command could be registered)
2000 UpdateCommandCompleter();
2001
2002 // Set event filters
2003 fHistoryTBTableList->installEventFilter(this);
2004 fCommandArea->installEventFilter(this);
2005
2006 // Focus on command line
2007 fCommandArea->setFocus();
2008
2009 interactorManager->DisableSecondaryLoop (); // TO KEEP
2010 if ((QApplication*)interactorManager->GetMainInteractor())
2011 ((QApplication*)interactorManager->GetMainInteractor())->exec();
2012
2013 interactorManager->EnableSecondaryLoop ();
2014 return this;
2015}
void Prompt(G4String)
Definition: G4UIQt.cc:2021

◆ SessionTerminate()

void G4UIQt::SessionTerminate ( )

Definition at line 2032 of file G4UIQt.cc.

2034{
2035 G4Qt* interactorManager = G4Qt::getInstance ();
2036 fMainWindow->close();
2037 ((QApplication*)interactorManager->GetMainInteractor())->exit();
2038}

◆ SetIconHLHSRSelected()

void G4UIQt::SetIconHLHSRSelected ( )

Definition at line 5034 of file G4UIQt.cc.

5034 {
5035 // Theses actions should be in the app toolbar
5036
5037 QToolBar* bar = fToolbarApp;
5038 if (!fDefaultIcons) {
5039 bar = fToolbarUser;
5040 }
5041
5042 if (!bar) return;
5043
5044 QList<QAction *> list = bar->actions ();
5045 for (G4int i = 0; i < list.size(); ++i) {
5046 if (list.at(i)->data().toString () == "hidden_line_and_surface_removal") {
5047 list.at(i)->setChecked(TRUE);
5048 } else if (list.at(i)->data().toString () == "solid") {
5049 list.at(i)->setChecked(FALSE);
5050 } else if (list.at(i)->data().toString () == "hidden_line_removal") {
5051 list.at(i)->setChecked(FALSE);
5052 } else if (list.at(i)->data().toString () == "wireframe") {
5053 list.at(i)->setChecked(FALSE);
5054 }
5055 }
5056}
#define FALSE
Definition: globals.hh:38

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconHLRSelected()

void G4UIQt::SetIconHLRSelected ( )

Definition at line 5009 of file G4UIQt.cc.

5009 {
5010 // Theses actions should be in the app toolbar
5011
5012 QToolBar* bar = fToolbarApp;
5013 if (!fDefaultIcons) {
5014 bar = fToolbarUser;
5015 }
5016 if (!bar) return;
5017
5018
5019 QList<QAction *> list = bar->actions ();
5020 for (G4int i = 0; i < list.size(); ++i) {
5021 if (list.at(i)->data().toString () == "hidden_line_removal") {
5022 list.at(i)->setChecked(TRUE);
5023 } else if (list.at(i)->data().toString () == "solid") {
5024 list.at(i)->setChecked(FALSE);
5025 } else if (list.at(i)->data().toString () == "hidden_line_and_surface_removal") {
5026 list.at(i)->setChecked(FALSE);
5027 } else if (list.at(i)->data().toString () == "wireframe") {
5028 list.at(i)->setChecked(FALSE);
5029 }
5030 }
5031}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconMoveSelected()

void G4UIQt::SetIconMoveSelected ( )

Definition at line 4816 of file G4UIQt.cc.

4816 {
4817 // Theses actions should be in the app toolbar
4818 fMoveSelected = true;
4819 fRotateSelected = false;
4820 fPickSelected = false;
4821 fZoomInSelected = false;
4822 fZoomOutSelected = false;
4823
4824 if (fToolbarApp == NULL) return;
4825 QList<QAction *> list = fToolbarApp->actions ();
4826 for (G4int i = 0; i < list.size(); ++i) {
4827 if (list.at(i)->data().toString () == "move") {
4828 list.at(i)->setChecked(TRUE);
4829 } else if (list.at(i)->data().toString () == "rotate") {
4830 list.at(i)->setChecked(FALSE);
4831 } else if (list.at(i)->data().toString () == "pick") {
4832 list.at(i)->setChecked(FALSE);
4833 } else if (list.at(i)->data().toString () == "zoom_in") {
4834 list.at(i)->setChecked(FALSE);
4835 } else if (list.at(i)->data().toString () == "zoom_out") {
4836 list.at(i)->setChecked(FALSE);
4837 }
4838 }
4839}

Referenced by AddIcon().

◆ SetIconOrthoSelected()

void G4UIQt::SetIconOrthoSelected ( )

Definition at line 5081 of file G4UIQt.cc.

5081 {
5082 // Theses actions should be in the app toolbar
5083
5084 QToolBar* bar = fToolbarApp;
5085 if (!fDefaultIcons) {
5086 bar = fToolbarUser;
5087 }
5088
5089 if (!bar) return;
5090
5091 QList<QAction *> list = bar->actions ();
5092 for (G4int i = 0; i < list.size(); ++i) {
5093 if (list.at(i)->data().toString () == "ortho") {
5094 list.at(i)->setChecked(TRUE);
5095 } else if (list.at(i)->data().toString () == "perspective") {
5096 list.at(i)->setChecked(FALSE);
5097 }
5098 }
5099}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconPerspectiveSelected()

void G4UIQt::SetIconPerspectiveSelected ( )

Definition at line 5059 of file G4UIQt.cc.

5059 {
5060 // Theses actions should be in the app toolbar
5061
5062 QToolBar* bar = fToolbarApp;
5063 if (!fDefaultIcons) {
5064 bar = fToolbarUser;
5065 }
5066 if (!bar) return;
5067
5068
5069 QList<QAction *> list = bar->actions ();
5070 for (G4int i = 0; i < list.size(); ++i) {
5071 if (list.at(i)->data().toString () == "perspective") {
5072 list.at(i)->setChecked(TRUE);
5073 } else if (list.at(i)->data().toString () == "ortho") {
5074 list.at(i)->setChecked(FALSE);
5075 }
5076 }
5077}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconPickSelected()

void G4UIQt::SetIconPickSelected ( )

Definition at line 4868 of file G4UIQt.cc.

4868 {
4869 // Theses actions should be in the app toolbar
4870 fPickSelected = true;
4871 fMoveSelected = false;
4872 fRotateSelected = false;
4873 fZoomInSelected = false;
4874 fZoomOutSelected = false;
4875
4876 QToolBar* bar = fToolbarApp;
4877 if (!fDefaultIcons) {
4878 bar = fToolbarUser;
4879 }
4880 if (!bar) return;
4881
4882 QList<QAction *> list = bar->actions ();
4883 for (G4int i = 0; i < list.size(); ++i) {
4884 if (list.at(i)->data().toString () == "pick") {
4885 list.at(i)->setChecked(TRUE);
4886 } else if (list.at(i)->data().toString () == "move") {
4887 list.at(i)->setChecked(FALSE);
4888 } else if (list.at(i)->data().toString () == "rotate") {
4889 list.at(i)->setChecked(FALSE);
4890 } else if (list.at(i)->data().toString () == "zoom_in") {
4891 list.at(i)->setChecked(FALSE);
4892 } else if (list.at(i)->data().toString () == "zoom_out") {
4893 list.at(i)->setChecked(FALSE);
4894 }
4895 }
4896}

Referenced by AddIcon().

◆ SetIconRotateSelected()

void G4UIQt::SetIconRotateSelected ( )

Definition at line 4842 of file G4UIQt.cc.

4842 {
4843 // Theses actions should be in the app toolbar
4844 fRotateSelected = true;
4845 fMoveSelected = false;
4846 fPickSelected = false;
4847 fZoomInSelected = false;
4848 fZoomOutSelected = false;
4849
4850 if (fToolbarApp == NULL) return;
4851 QList<QAction *> list = fToolbarApp->actions ();
4852 for (G4int i = 0; i < list.size(); ++i) {
4853 if (list.at(i)->data().toString () == "rotate") {
4854 list.at(i)->setChecked(TRUE);
4855 } else if (list.at(i)->data().toString () == "move") {
4856 list.at(i)->setChecked(FALSE);
4857 } else if (list.at(i)->data().toString () == "pick") {
4858 list.at(i)->setChecked(FALSE);
4859 } else if (list.at(i)->data().toString () == "zoom_in") {
4860 list.at(i)->setChecked(FALSE);
4861 } else if (list.at(i)->data().toString () == "zoom_out") {
4862 list.at(i)->setChecked(FALSE);
4863 }
4864 }
4865}

Referenced by AddIcon().

◆ SetIconSolidSelected()

void G4UIQt::SetIconSolidSelected ( )

Definition at line 4961 of file G4UIQt.cc.

4961 {
4962 // Theses actions should be in the app toolbar
4963
4964 QToolBar* bar = fToolbarApp;
4965 if (!fDefaultIcons) {
4966 bar = fToolbarUser;
4967 }
4968 if (!bar) return;
4969
4970 QList<QAction *> list = bar->actions ();
4971 for (G4int i = 0; i < list.size(); ++i) {
4972 if (list.at(i)->data().toString () == "solid") {
4973 list.at(i)->setChecked(TRUE);
4974 } else if (list.at(i)->data().toString () == "hidden_line_removal") {
4975 list.at(i)->setChecked(FALSE);
4976 } else if (list.at(i)->data().toString () == "hidden_line_and_surface_removal") {
4977 list.at(i)->setChecked(FALSE);
4978 } else if (list.at(i)->data().toString () == "wireframe") {
4979 list.at(i)->setChecked(FALSE);
4980 }
4981 }
4982}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconWireframeSelected()

void G4UIQt::SetIconWireframeSelected ( )

Definition at line 4985 of file G4UIQt.cc.

4985 {
4986 // Theses actions should be in the app toolbar
4987
4988 QToolBar* bar = fToolbarApp;
4989 if (!fDefaultIcons) {
4990 bar = fToolbarUser;
4991 }
4992 if (!bar) return;
4993
4994 QList<QAction *> list = bar->actions ();
4995 for (G4int i = 0; i < list.size(); ++i) {
4996 if (list.at(i)->data().toString () == "wireframe") {
4997 list.at(i)->setChecked(TRUE);
4998 } else if (list.at(i)->data().toString () == "hidden_line_removal") {
4999 list.at(i)->setChecked(FALSE);
5000 } else if (list.at(i)->data().toString () == "hidden_line_and_surface_removal") {
5001 list.at(i)->setChecked(FALSE);
5002 } else if (list.at(i)->data().toString () == "solid") {
5003 list.at(i)->setChecked(FALSE);
5004 }
5005 }
5006}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconZoomInSelected()

void G4UIQt::SetIconZoomInSelected ( )

Definition at line 4899 of file G4UIQt.cc.

4899 {
4900 // Theses actions should be in the app toolbar
4901 fZoomInSelected = true;
4902 fMoveSelected = false;
4903 fRotateSelected = false;
4904 fPickSelected = false;
4905 fZoomOutSelected = false;
4906
4907 QToolBar* bar = fToolbarApp;
4908 if (!fDefaultIcons) {
4909 bar = fToolbarUser;
4910 }
4911 if (!bar) return;
4912
4913 QList<QAction *> list = bar->actions ();
4914 for (G4int i = 0; i < list.size(); ++i) {
4915 if (list.at(i)->data().toString () == "zoom_in") {
4916 list.at(i)->setChecked(TRUE);
4917 } else if (list.at(i)->data().toString () == "move") {
4918 list.at(i)->setChecked(FALSE);
4919 } else if (list.at(i)->data().toString () == "rotate") {
4920 list.at(i)->setChecked(FALSE);
4921 } else if (list.at(i)->data().toString () == "pick") {
4922 list.at(i)->setChecked(FALSE);
4923 } else if (list.at(i)->data().toString () == "zoom_out") {
4924 list.at(i)->setChecked(FALSE);
4925 }
4926 }
4927}

Referenced by AddIcon().

◆ SetIconZoomOutSelected()

void G4UIQt::SetIconZoomOutSelected ( )

Definition at line 4930 of file G4UIQt.cc.

4930 {
4931 // Theses actions should be in the app toolbar
4932 fZoomOutSelected = true;
4933 fMoveSelected = false;
4934 fRotateSelected = false;
4935 fPickSelected = false;
4936 fZoomInSelected = false;
4937
4938 QToolBar* bar = fToolbarApp;
4939 if (!fDefaultIcons) {
4940 bar = fToolbarUser;
4941 }
4942 if (!bar) return;
4943
4944 QList<QAction *> list = bar->actions ();
4945 for (G4int i = 0; i < list.size(); ++i) {
4946 if (list.at(i)->data().toString () == "zoom_out") {
4947 list.at(i)->setChecked(TRUE);
4948 } else if (list.at(i)->data().toString () == "move") {
4949 list.at(i)->setChecked(FALSE);
4950 } else if (list.at(i)->data().toString () == "rotate") {
4951 list.at(i)->setChecked(FALSE);
4952 } else if (list.at(i)->data().toString () == "pick") {
4953 list.at(i)->setChecked(FALSE);
4954 } else if (list.at(i)->data().toString () == "zoom_in") {
4955 list.at(i)->setChecked(FALSE);
4956 }
4957 }
4958}

Referenced by AddIcon().

◆ SetStartPage()

void G4UIQt::SetStartPage ( const std::string &  text)

Definition at line 1917 of file G4UIQt.cc.

1919{
1920 if (text != "") {
1921 fDefaultViewerFirstPageHTMLText = text;
1922 }
1923 if (!fStartPage) {
1924 fStartPage = new QTextBrowser();
1925 fStartPage->setContentsMargins(5,5,5,5);
1926 fStartPage->setReadOnly(true);
1927 }
1928 fStartPage->setOpenExternalLinks(true);
1929 fStartPage->setHtml(fDefaultViewerFirstPageHTMLText.c_str());
1930}

Referenced by DefaultIcons().


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