Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/interfaces/implementation/src/G4UIQt.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /interfaces/implementation/src/G4UIQt.cc (Version 11.3.0) and /interfaces/implementation/src/G4UIQt.cc (Version 11.2.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 //                                                 27 //
 28 // L. Garnier                                      28 // L. Garnier
 29                                                    29 
 30 #include "G4UIQt.hh"                               30 #include "G4UIQt.hh"
 31                                                    31 
 32 #include "G4MTcoutDestination.hh"                  32 #include "G4MTcoutDestination.hh"
 33 #include "G4Qt.hh"                                 33 #include "G4Qt.hh"
 34 #include "G4StateManager.hh"                       34 #include "G4StateManager.hh"
 35 #include "G4Types.hh"                              35 #include "G4Types.hh"
 36 #include "G4UIcommand.hh"                          36 #include "G4UIcommand.hh"
 37 #include "G4UIcommandStatus.hh"                    37 #include "G4UIcommandStatus.hh"
 38 #include "G4UIcommandTree.hh"                      38 #include "G4UIcommandTree.hh"
 39 #include "G4UImanager.hh"                          39 #include "G4UImanager.hh"
 40 #include "G4UIcommand.hh"                          40 #include "G4UIcommand.hh"
 41 #include "G4UIparameter.hh"                        41 #include "G4UIparameter.hh"
 42 #include "G4SceneTreeItem.hh"                      42 #include "G4SceneTreeItem.hh"
 43 #include "G4AttCheck.hh"                           43 #include "G4AttCheck.hh"
 44                                                    44 
 45 #include <qapplication.h>                          45 #include <qapplication.h>
 46 #include <qdialog.h>                               46 #include <qdialog.h>
 47 #include <qevent.h>                                47 #include <qevent.h>
 48 #include <qlabel.h>                                48 #include <qlabel.h>
 49 #include <qlayout.h>                               49 #include <qlayout.h>
 50 #include <qlineedit.h>                             50 #include <qlineedit.h>
 51 #include <qmenubar.h>                              51 #include <qmenubar.h>
 52 #include <qmessagebox.h>                           52 #include <qmessagebox.h>
 53 #include <qpushbutton.h>                           53 #include <qpushbutton.h>
 54 #include <qscrollbar.h>                            54 #include <qscrollbar.h>
 55 #include <qsplitter.h>                             55 #include <qsplitter.h>
 56 #include <qtextbrowser.h>                          56 #include <qtextbrowser.h>
 57 #include <qtextedit.h>                             57 #include <qtextedit.h>
 58 #include <qwidget.h>                               58 #include <qwidget.h>
 59                                                    59 
 60 #include <cstring>                                 60 #include <cstring>
 61 #include <qboxlayout.h>                            61 #include <qboxlayout.h>
 62 #include <qbuttongroup.h>                          62 #include <qbuttongroup.h>
 63 #include <qcolordialog.h>                          63 #include <qcolordialog.h>
 64 #include <qcombobox.h>                             64 #include <qcombobox.h>
 65 #include <qcompleter.h>                            65 #include <qcompleter.h>
 66 #include <qfiledialog.h>                           66 #include <qfiledialog.h>
 67 #include <qgroupbox.h>                             67 #include <qgroupbox.h>
 68 #include <qheaderview.h>                           68 #include <qheaderview.h>
 69 #include <qlistwidget.h>                           69 #include <qlistwidget.h>
 70 #include <qmainwindow.h>                           70 #include <qmainwindow.h>
 71 #include <qmenu.h>                                 71 #include <qmenu.h>
 72 #include <qpainter.h>                              72 #include <qpainter.h>
 73 #include <qradiobutton.h>                          73 #include <qradiobutton.h>
 74 #include <qscrollarea.h>                           74 #include <qscrollarea.h>
 75 #include <qstandarditemmodel.h>                    75 #include <qstandarditemmodel.h>
 76 #include <qstringlist.h>                           76 #include <qstringlist.h>
 77 #include <qtabbar.h>                               77 #include <qtabbar.h>
 78 #include <qtablewidget.h>                          78 #include <qtablewidget.h>
 79 #include <qtabwidget.h>                            79 #include <qtabwidget.h>
 80 #include <qtextstream.h>                           80 #include <qtextstream.h>
 81 #include <qtoolbar.h>                              81 #include <qtoolbar.h>
 82 #include <qtoolbox.h>                              82 #include <qtoolbox.h>
 83                                                    83 
 84 #include <QInputDialog>                            84 #include <QInputDialog>
 85                                                    85 
 86 #include <set>                                     86 #include <set>
 87 #include <map>                                     87 #include <map>
 88 #include <cstdlib>                                 88 #include <cstdlib>
 89                                                    89 
 90 #ifndef G4GMAKE                                    90 #ifndef G4GMAKE
 91 #  include "moc_G4UIQt.cpp"                        91 #  include "moc_G4UIQt.cpp"
 92 #endif                                             92 #endif
 93                                                    93 
 94 // Pourquoi Static et non  variables de classe     94 // Pourquoi Static et non  variables de classe ?
 95 static G4bool exitSession = true;                  95 static G4bool exitSession = true;
 96 static G4bool exitPause = true;                    96 static G4bool exitPause = true;
 97                                                    97 
 98 /**   Build a Qt window with a menubar, output     98 /**   Build a Qt window with a menubar, output area and promt area<br>
 99 <pre>                                              99 <pre>
100    +-----------------------+                      100    +-----------------------+
101    |exit menu|             |                      101    |exit menu|             |
102    |                       |                      102    |                       |
103    | +-------------------+ |                      103    | +-------------------+ |
104    | |                   | |                      104    | |                   | |
105    | |  Output area      | |                      105    | |  Output area      | |
106    | |                   | |                      106    | |                   | |
107    | +-------------------+ |                      107    | +-------------------+ |
108    |      | clear |        |                      108    |      | clear |        |
109    | +-------------------+ |                      109    | +-------------------+ |
110    | |  promt history    | |                      110    | |  promt history    | |
111    | +-------------------+ |                      111    | +-------------------+ |
112    | +-------------------+ |                      112    | +-------------------+ |
113    | |> promt area       | |                      113    | |> promt area       | |
114    | +-------------------+ |                      114    | +-------------------+ |
115    +-----------------------+                      115    +-----------------------+
116 </pre>                                            116 </pre>
117 */                                                117 */
118 G4UIQt::G4UIQt(G4int argc, char** argv)           118 G4UIQt::G4UIQt(G4int argc, char** argv)
119   : fMainWindow(nullptr),                         119   : fMainWindow(nullptr),
120     fCommandLabel(nullptr),                       120     fCommandLabel(nullptr),
121     fCommandArea(nullptr),                        121     fCommandArea(nullptr),
122     fCoutTBTextArea(nullptr),                     122     fCoutTBTextArea(nullptr),
123     fUITabWidget(nullptr),                        123     fUITabWidget(nullptr),
124     fCoutFilter(nullptr),                         124     fCoutFilter(nullptr),
125     fCompleter(nullptr),                          125     fCompleter(nullptr),
126     fDefaultIcons(true),                          126     fDefaultIcons(true),
127     fHistoryTBTableList(nullptr),                 127     fHistoryTBTableList(nullptr),
128     fHelpTreeWidget(nullptr),                     128     fHelpTreeWidget(nullptr),
129     fHelpTBWidget(nullptr),                       129     fHelpTBWidget(nullptr),
130     fHistoryTBWidget(nullptr),                    130     fHistoryTBWidget(nullptr),
131     fCoutDockWidget(nullptr),                     131     fCoutDockWidget(nullptr),
132     fUIDockWidget(nullptr),                       132     fUIDockWidget(nullptr),
133     fSceneTreeWidget(nullptr),                    133     fSceneTreeWidget(nullptr),
134     fNewSceneTreeWidget(nullptr),                 134     fNewSceneTreeWidget(nullptr),
135     fNewSceneTreeItemTreeWidget(nullptr),         135     fNewSceneTreeItemTreeWidget(nullptr),
136     fViewerPropertiesWidget(nullptr),             136     fViewerPropertiesWidget(nullptr),
137     fPickInfosWidget(nullptr),                    137     fPickInfosWidget(nullptr),
138     fHelpLine(nullptr),                           138     fHelpLine(nullptr),
139     fViewerTabWidget(nullptr),                    139     fViewerTabWidget(nullptr),
140     fCoutText("Output"),                          140     fCoutText("Output"),
141     fStartPage(nullptr),                          141     fStartPage(nullptr),
142     fHelpVSplitter(nullptr),                      142     fHelpVSplitter(nullptr),
143     fParameterHelpLabel(nullptr),                 143     fParameterHelpLabel(nullptr),
144     fParameterHelpTable(nullptr),                 144     fParameterHelpTable(nullptr),
145     fToolbarApp(nullptr),                         145     fToolbarApp(nullptr),
146     fToolbarUser(nullptr),                        146     fToolbarUser(nullptr),
147     fStringSeparator("__$$$@%%###__"),            147     fStringSeparator("__$$$@%%###__"),
148     fLastOpenPath(""),                            148     fLastOpenPath(""),
149     fSearchIcon(nullptr),                         149     fSearchIcon(nullptr),
150     fClearIcon(nullptr),                          150     fClearIcon(nullptr),
151     fSaveIcon(nullptr),                           151     fSaveIcon(nullptr),
152     fOpenIcon(nullptr),                           152     fOpenIcon(nullptr),
153     fMoveIcon(nullptr),                           153     fMoveIcon(nullptr),
154     fRotateIcon(nullptr),                         154     fRotateIcon(nullptr),
155     fPickIcon(nullptr),                           155     fPickIcon(nullptr),
156     fZoomInIcon(nullptr),                         156     fZoomInIcon(nullptr),
157     fZoomOutIcon(nullptr),                        157     fZoomOutIcon(nullptr),
158     fWireframeIcon(nullptr),                      158     fWireframeIcon(nullptr),
159     fSolidIcon(nullptr),                          159     fSolidIcon(nullptr),
160     fHiddenLineRemovalIcon(nullptr),              160     fHiddenLineRemovalIcon(nullptr),
161     fHiddenLineAndSurfaceRemovalIcon(nullptr),    161     fHiddenLineAndSurfaceRemovalIcon(nullptr),
162     fPerspectiveIcon(nullptr),                    162     fPerspectiveIcon(nullptr),
163     fOrthoIcon(nullptr),                          163     fOrthoIcon(nullptr),
164     fCommandIcon(nullptr),                        164     fCommandIcon(nullptr),
165     fDirIcon(nullptr),                            165     fDirIcon(nullptr),
166     fRunIcon(nullptr),                            166     fRunIcon(nullptr),
167     fParamIcon(nullptr),                          167     fParamIcon(nullptr),
168     fPickTargetIcon(nullptr),                     168     fPickTargetIcon(nullptr),
169     fExitIcon(nullptr)                            169     fExitIcon(nullptr)
170 #ifdef G4MULTITHREADED                            170 #ifdef G4MULTITHREADED
171     ,                                             171     ,
172     fThreadsFilterComboBox(nullptr)               172     fThreadsFilterComboBox(nullptr)
173 #endif                                            173 #endif
174     ,                                             174     ,
175     fDefaultViewerFirstPageHTMLText(""),          175     fDefaultViewerFirstPageHTMLText(""),
176     fViewerPropertiesDialog(nullptr),             176     fViewerPropertiesDialog(nullptr),
177     fPickInfosDialog(nullptr),                    177     fPickInfosDialog(nullptr),
178     fLastCompleteCommand(""),                     178     fLastCompleteCommand(""),
179     fMoveSelected(false),                         179     fMoveSelected(false),
180     fRotateSelected(true),                        180     fRotateSelected(true),
181     fPickSelected(false),                         181     fPickSelected(false),
182     fZoomInSelected(false),                       182     fZoomInSelected(false),
183     fZoomOutSelected(false)                       183     fZoomOutSelected(false)
184 {                                                 184 {
185   G4Qt* interactorManager = G4Qt::getInstance(    185   G4Qt* interactorManager = G4Qt::getInstance(argc, argv, (char*)"Qt");
186   if ((QApplication*)interactorManager->GetMai    186   if ((QApplication*)interactorManager->GetMainInteractor() == nullptr) {
187     G4UImanager* UImanager = G4UImanager::GetU    187     G4UImanager* UImanager = G4UImanager::GetUIpointer();
188     G4int verbose = UImanager->GetVerboseLevel    188     G4int verbose = UImanager->GetVerboseLevel();
189                                                   189 
190     if (verbose >= 2) {                           190     if (verbose >= 2) {
191       G4cout << "G4UIQt : Unable to init Qt. A    191       G4cout << "G4UIQt : Unable to init Qt. Aborted" << G4endl;
192     }                                             192     }
193   }                                               193   }
194                                                   194 
195   G4UImanager* UI = G4UImanager::GetUIpointer(    195   G4UImanager* UI = G4UImanager::GetUIpointer();
196   if (UI != nullptr) UI->SetSession(this);        196   if (UI != nullptr) UI->SetSession(this);
197   if (UI != nullptr) UI->SetG4UIWindow(this);     197   if (UI != nullptr) UI->SetG4UIWindow(this);
198                                                   198 
199   // Check if already define in external app Q    199   // Check if already define in external app QMainWindow
200   G4bool found = false;                           200   G4bool found = false;
201   Q_FOREACH (QWidget* widget, QApplication::al    201   Q_FOREACH (QWidget* widget, QApplication::allWidgets()) {
202     if ((!found) && (widget->inherits("QMainWi    202     if ((!found) && (widget->inherits("QMainWindow"))) {
203       found = true;                               203       found = true;
204     }                                             204     }
205   }                                               205   }
206                                                   206 
207   if (found) {                                    207   if (found) {
208     G4UImanager* UImanager = G4UImanager::GetU    208     G4UImanager* UImanager = G4UImanager::GetUIpointer();
209     G4int verbose = UImanager->GetVerboseLevel    209     G4int verbose = UImanager->GetVerboseLevel();
210                                                   210 
211     if (verbose >= 2) {                           211     if (verbose >= 2) {
212       G4cout << "G4UIQt : Found an external Ap    212       G4cout << "G4UIQt : Found an external App with a QMainWindow already defined. Aborted"
213              << G4endl;                           213              << G4endl;
214     }                                             214     }
215     return;                                       215     return;
216   }                                               216   }
217   CreateIcons();                                  217   CreateIcons();
218                                                   218 
219   fMainWindow = new QMainWindow();                219   fMainWindow = new QMainWindow();
220   fMainWindow->setAttribute(Qt::WA_DeleteOnClo    220   fMainWindow->setAttribute(Qt::WA_DeleteOnClose);
221                                                   221 
222   fMainWindow->setCorner(Qt::TopLeftCorner, Qt    222   fMainWindow->setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
223   fMainWindow->setCorner(Qt::TopRightCorner, Q    223   fMainWindow->setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
224   fMainWindow->setCorner(Qt::BottomLeftCorner,    224   fMainWindow->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
225   fMainWindow->setCorner(Qt::BottomRightCorner    225   fMainWindow->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
226                                                   226 
227   CreateViewerWidget();                           227   CreateViewerWidget();
228   fMainWindow->addDockWidget(Qt::LeftDockWidge    228   fMainWindow->addDockWidget(Qt::LeftDockWidgetArea, CreateUITabWidget());
229   fMainWindow->addDockWidget(Qt::BottomDockWid    229   fMainWindow->addDockWidget(Qt::BottomDockWidgetArea, CreateCoutTBWidget());
230                                                   230 
231   // Create the new scene tree stuff              231   // Create the new scene tree stuff
232   fNewSceneTreeWidget = new QWidget;              232   fNewSceneTreeWidget = new QWidget;
233   fNewSceneTreeWidget->setStyleSheet ("padding    233   fNewSceneTreeWidget->setStyleSheet ("padding: 0px ");
234   fNewSceneTreeWidget->setLayout(new QVBoxLayo    234   fNewSceneTreeWidget->setLayout(new QVBoxLayout);
235   fNewSceneTreeWidget->layout()->setContentsMa    235   fNewSceneTreeWidget->layout()->setContentsMargins(5,5,5,5);
236   fNewSceneTreeWidget->setWindowTitle("some na    236   fNewSceneTreeWidget->setWindowTitle("some name"/*QString(GetName().data())*/);
237   // Add it to the "old" fSceneTreeWidget         237   // Add it to the "old" fSceneTreeWidget
238   fSceneTreeWidget->layout()->addWidget(fNewSc    238   fSceneTreeWidget->layout()->addWidget(fNewSceneTreeWidget);
239   CreateNewSceneTreeWidget();                     239   CreateNewSceneTreeWidget();
240                                                   240 
241   // add defaults icons                           241   // add defaults icons
242   SetDefaultIconsToolbar();                       242   SetDefaultIconsToolbar();
243                                                   243 
244   if (UI != nullptr) UI->SetCoutDestination(th    244   if (UI != nullptr) UI->SetCoutDestination(this);  // TO KEEP
245                                                   245 
246 #ifdef G4MULTITHREADED                            246 #ifdef G4MULTITHREADED
247   // explicitly request that cout/cerr message    247   // explicitly request that cout/cerr messages from threads are ALSO propagated to the master.
248   masterG4coutDestination = this;                 248   masterG4coutDestination = this;
249 #endif                                            249 #endif
250                                                   250 
251   fMainWindow->setWindowTitle(QFileInfo(QCoreA    251   fMainWindow->setWindowTitle(QFileInfo(QCoreApplication::applicationFilePath()).fileName());
252   fMainWindow->move(QPoint(50, 50));              252   fMainWindow->move(QPoint(50, 50));
253                                                   253 
254   // force the size at be correct at the beggi    254   // force the size at be correct at the beggining
255   // because the widget is not realized yet, t    255   // because the widget is not realized yet, the size of the main window is not up to date. But
256   // we need it in order to add some viewer in    256   // we need it in order to add some viewer inside
257   fMainWindow->resize(fUIDockWidget->width() +    257   fMainWindow->resize(fUIDockWidget->width() + fCoutDockWidget->width() + 20,
258     fUIDockWidget->height() + fCoutDockWidget-    258     fUIDockWidget->height() + fCoutDockWidget->height() + 20);
259                                                   259 
260   // set last focus on command line               260   // set last focus on command line
261   fCommandArea->setFocus(Qt::TabFocusReason);     261   fCommandArea->setFocus(Qt::TabFocusReason);
262                                                   262 
263   // Allow QTextCursor to be called by another    263   // Allow QTextCursor to be called by another thread :
264   // http://qt-project.org/doc/qt-4.8/qmetatyp    264   // http://qt-project.org/doc/qt-4.8/qmetatype.html#qRegisterMetaType
265   qRegisterMetaType<QTextCursor>("QTextCursor"    265   qRegisterMetaType<QTextCursor>("QTextCursor");
266                                                   266 
267   // add some tips                                267   // add some tips
268   AddTabWidget(fStartPage, "Useful tips");        268   AddTabWidget(fStartPage, "Useful tips");
269                                                   269 
270   // Set not visible until session start          270   // Set not visible until session start
271   fMainWindow->setVisible(false);                 271   fMainWindow->setVisible(false);
272 }                                                 272 }
273                                                   273 
274 G4UIQt::~G4UIQt()                                 274 G4UIQt::~G4UIQt()
275 {                                                 275 {
276   G4UImanager* UI = G4UImanager::GetUIpointer(    276   G4UImanager* UI = G4UImanager::GetUIpointer();  // TO KEEP
277   if (UI != nullptr) {  // TO KEEP                277   if (UI != nullptr) {  // TO KEEP
278     UI->SetSession(nullptr);  // TO KEEP          278     UI->SetSession(nullptr);  // TO KEEP
279     UI->SetG4UIWindow(nullptr);                   279     UI->SetG4UIWindow(nullptr);
280     UI->SetCoutDestination(nullptr);  // TO KE    280     UI->SetCoutDestination(nullptr);  // TO KEEP
281 #ifdef G4MULTITHREADED                            281 #ifdef G4MULTITHREADED
282     masterG4coutDestination = nullptr;  // set    282     masterG4coutDestination = nullptr;  // set to cout when UI is deleted
283 #endif                                            283 #endif
284   }                                               284   }
285 }                                                 285 }
286                                                   286 
287 void G4UIQt::DefaultIcons(G4bool aVal)            287 void G4UIQt::DefaultIcons(G4bool aVal)
288 {                                                 288 {
289   fDefaultIcons = aVal;                           289   fDefaultIcons = aVal;
290                                                   290 
291   if (! fMainWindow->isVisible()) {               291   if (! fMainWindow->isVisible()) {
292     return;                                       292     return;
293   }                                               293   }
294                                                   294 
295   if (fToolbarApp != nullptr) {                   295   if (fToolbarApp != nullptr) {
296     if (aVal) {                                   296     if (aVal) {
297       fToolbarApp->setVisible(true);              297       fToolbarApp->setVisible(true);
298     }                                             298     }
299     else {                                        299     else {
300       // Set not visible until session start      300       // Set not visible until session start
301       fToolbarApp->setVisible(false);             301       fToolbarApp->setVisible(false);
302     }                                             302     }
303   }                                               303   }
304 }                                                 304 }
305                                                   305 
306 void G4UIQt::SetDefaultIconsToolbar()             306 void G4UIQt::SetDefaultIconsToolbar()
307 {                                                 307 {
308   if (fDefaultIcons) {                            308   if (fDefaultIcons) {
309     if (fToolbarApp == nullptr) {                 309     if (fToolbarApp == nullptr) {
310       fToolbarApp = new QToolBar();               310       fToolbarApp = new QToolBar();
311       fToolbarApp->setIconSize(QSize(20, 20));    311       fToolbarApp->setIconSize(QSize(20, 20));
312       fMainWindow->addToolBar(Qt::TopToolBarAr    312       fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
313     }                                             313     }
314                                                   314 
315     // Open/Save Icons                            315     // Open/Save Icons
316     AddIcon("Open macro file", "open", "/contr    316     AddIcon("Open macro file", "open", "/control/execute");
317     AddIcon("Save viewer state", "save", "/vis    317     AddIcon("Save viewer state", "save", "/vis/viewer/save");
318                                                   318 
319     // View parameters                            319     // View parameters
320     fToolbarApp->addAction(QIcon(*fParamIcon),    320     fToolbarApp->addAction(QIcon(*fParamIcon), "Viewer properties", this,
321       [this]() { this->ViewerPropertiesIconCal    321       [this]() { this->ViewerPropertiesIconCallback(0); });
322                                                   322 
323     // Cursors style icons                        323     // Cursors style icons
324     AddIcon("Move", "move", "");                  324     AddIcon("Move", "move", "");
325     AddIcon("Pick", "pick", "");                  325     AddIcon("Pick", "pick", "");
326     AddIcon("Zoom out", "zoom_out", "");          326     AddIcon("Zoom out", "zoom_out", "");
327     AddIcon("Zoom in", "zoom_in", "");            327     AddIcon("Zoom in", "zoom_in", "");
328     AddIcon("Rotate", "rotate", "");              328     AddIcon("Rotate", "rotate", "");
329                                                   329 
330     // Surface Style icons                        330     // Surface Style icons
331     AddIcon("Hidden line removal", "hidden_lin    331     AddIcon("Hidden line removal", "hidden_line_removal", "");
332     AddIcon("Hidden line and hidden surface re    332     AddIcon("Hidden line and hidden surface removal", "hidden_line_and_surface_removal", "");
333     AddIcon("Surfaces", "solid", "");             333     AddIcon("Surfaces", "solid", "");
334     AddIcon("Wireframe", "wireframe", "");        334     AddIcon("Wireframe", "wireframe", "");
335                                                   335 
336     // Perspective/Ortho icons                    336     // Perspective/Ortho icons
337     AddIcon("Perspective", "perspective", "");    337     AddIcon("Perspective", "perspective", "");
338     AddIcon("Orthographic", "ortho", "");         338     AddIcon("Orthographic", "ortho", "");
339     AddIcon("Run beam on", "runBeamOn", "/run/    339     AddIcon("Run beam on", "runBeamOn", "/run/beamOn 1");
340     AddIcon("Exit Application", "exit", "exit"    340     AddIcon("Exit Application", "exit", "exit");
341   }                                               341   }
342 }                                                 342 }
343                                                   343 
344 // clang-format off                               344 // clang-format off
345 void G4UIQt::CreateIcons()                        345 void G4UIQt::CreateIcons()
346 {                                                 346 {
347   const char * const save[]={                     347   const char * const save[]={
348     "32 32 24 1",                                 348     "32 32 24 1",
349     "       c None",                              349     "       c None",
350     "+      c #000200",                           350     "+      c #000200",
351     "@      c #141E43",                           351     "@      c #141E43",
352     "#      c #000C56",                           352     "#      c #000C56",
353     "$      c #494A47",                           353     "$      c #494A47",
354     "%      c #636662",                           354     "%      c #636662",
355     "&      c #312F2A",                           355     "&      c #312F2A",
356     "*      c #191B19",                           356     "*      c #191B19",
357     "=      c #002992",                           357     "=      c #002992",
358     "-      c #003DFF",                           358     "-      c #003DFF",
359     ";      c #041DA5",                           359     ";      c #041DA5",
360     ">      c #A8A9A3",                           360     ">      c #A8A9A3",
361     ",      c #FDFFFC",                           361     ",      c #FDFFFC",
362     "'      c #DDE0DD",                           362     "'      c #DDE0DD",
363     ")      c #818783",                           363     ")      c #818783",
364     "!      c #C9CBC8",                           364     "!      c #C9CBC8",
365     "~      c #0116C3",                           365     "~      c #0116C3",
366     "{      c #C5C8FA",                           366     "{      c #C5C8FA",
367     "]      c #6596FC",                           367     "]      c #6596FC",
368     "^      c #A0B4F9",                           368     "^      c #A0B4F9",
369     "/      c #0B2AFD",                           369     "/      c #0B2AFD",
370     "(      c #799BE3",                           370     "(      c #799BE3",
371     "_      c #5F4826",                           371     "_      c #5F4826",
372     ":      c #D5D8D5",                           372     ":      c #D5D8D5",
373     "                                ",           373     "                                ",
374     "                                ",           374     "                                ",
375     "   +++++++++++++++++++++++++    ",           375     "   +++++++++++++++++++++++++    ",
376     "  +@##+$%%%%%%%%%%%%%%%&*$%&+   ",           376     "  +@##+$%%%%%%%%%%%%%%%&*$%&+   ",
377     "  +=-;@>,,''',,,,,,,',,)&!,)+   ",           377     "  +=-;@>,,''',,,,,,,',,)&!,)+   ",
378     "  +;-~@>,,,,,,,,,,,,,,,>$!,)+   ",           378     "  +;-~@>,,,,,,,,,,,,,,,>$!,)+   ",
379     "  +=-~@>,,,,,{]]]]]^,,,>*&$&+   ",           379     "  +=-~@>,,,,,{]]]]]^,,,>*&$&+   ",
380     "  +=-~@>,,,,,'{^{^^{,,,>*#=#+   ",           380     "  +=-~@>,,,,,'{^{^^{,,,>*#=#+   ",
381     "  +=-~@>,,,,,,,,,,,,,,,>@~/=+   ",           381     "  +=-~@>,,,,,,,,,,,,,,,>@~/=+   ",
382     "  +=-~@>,,,{{{''''{',,,>@~-=+   ",           382     "  +=-~@>,,,{{{''''{',,,>@~-=+   ",
383     "  +=-~@>,,'^]]]]]]({,,,>@~-=+   ",           383     "  +=-~@>,,'^]]]]]]({,,,>@~-=+   ",
384     "  +=-~@>,,,{{{{{{{{{,,,>@~-=+   ",           384     "  +=-~@>,,,{{{{{{{{{,,,>@~-=+   ",
385     "  +=-~@>,,,,,'{^{{^{,,,>@~-=+   ",           385     "  +=-~@>,,,,,'{^{{^{,,,>@~-=+   ",
386     "  +=-~@>,,,,,]]]]]]],,,>@~-=+   ",           386     "  +=-~@>,,,,,]]]]]]],,,>@~-=+   ",
387     "  +=-~*>,,,,,,,,,,,,,,,>@~-=+   ",           387     "  +=-~*>,,,,,,,,,,,,,,,>@~-=+   ",
388     "  +=-~@>,,,,,,,,,,,,,,,>@~-=+   ",           388     "  +=-~@>,,,,,,,,,,,,,,,>@~-=+   ",
389     "  +=-/=$%%%%%%%%%%%%%%%$=/-=+   ",           389     "  +=-/=$%%%%%%%%%%%%%%%$=/-=+   ",
390     "  +=---;###############;---=+   ",           390     "  +=---;###############;---=+   ",
391     "  +=---////////////////----=+   ",           391     "  +=---////////////////----=+   ",
392     "  +=----------------///----=+   ",           392     "  +=----------------///----=+   ",
393     "  +=---=@##############@#--=+   ",           393     "  +=---=@##############@#--=+   ",
394     "  +=---@+++++++++++*%))_+~-=+   ",           394     "  +=---@+++++++++++*%))_+~-=+   ",
395     "  +=---#+++++++++++&:,,>@~-=+   ",           395     "  +=---#+++++++++++&:,,>@~-=+   ",
396     "  +=---#+++++++++++$',,>@~-=+   ",           396     "  +=---#+++++++++++$',,>@~-=+   ",
397     "  +=---#+++++++++++&!,,>@~-=+   ",           397     "  +=---#+++++++++++&!,,>@~-=+   ",
398     "  +=/--#+++++++++++&',,>@~-=+   ",           398     "  +=/--#+++++++++++&',,>@~-=+   ",
399     "   @;--#+++++++++++$',,>@~-=+   ",           399     "   @;--#+++++++++++$',,>@~-=+   ",
400     "    @;;@+++++++++++*)!>%@=;#+   ",           400     "    @;;@+++++++++++*)!>%@=;#+   ",
401     "     @++++++++++++++*&**++@++   ",           401     "     @++++++++++++++*&**++@++   ",
402     "                                ",           402     "                                ",
403     "                                ",           403     "                                ",
404     "                                "}           404     "                                "}
405   ;                                               405   ;
406   fSaveIcon = new QPixmap(save);                  406   fSaveIcon = new QPixmap(save);
407                                                   407 
408   const char * const search[]  = {                408   const char * const search[]  = {
409     /* columns rows colors chars-per-pixel */     409     /* columns rows colors chars-per-pixel */
410     "19 19 8 1",                                  410     "19 19 8 1",
411     "  c #5C5C5C",                                411     "  c #5C5C5C",
412     ". c #7D7D7D",                                412     ". c #7D7D7D",
413     "X c #9B9B9B",                                413     "X c #9B9B9B",
414     "o c #C3C3C3",                                414     "o c #C3C3C3",
415     "O c None",                                   415     "O c None",
416     "+ c #000000",                                416     "+ c #000000",
417     "@ c #000000",                                417     "@ c #000000",
418     "# c None",                                   418     "# c None",
419     /* pixels */                                  419     /* pixels */
420     "OOOOOOOOOOOOOOOOOOO",                        420     "OOOOOOOOOOOOOOOOOOO",
421     "OOOOOOOOOOOOOOOOOOO",                        421     "OOOOOOOOOOOOOOOOOOO",
422     "OOOOOOOo.  .oOOOOOO",                        422     "OOOOOOOo.  .oOOOOOO",
423     "OOOOOOX      XOOOOO",                        423     "OOOOOOX      XOOOOO",
424     "OOOOOo  XOOX  oOOOO",                        424     "OOOOOo  XOOX  oOOOO",
425     "OOOOO. XOOOOX .OOOO",                        425     "OOOOO. XOOOOX .OOOO",
426     "OOOOO  OOOOOO  OOOO",                        426     "OOOOO  OOOOOO  OOOO",
427     "OOOOO  OOOOOO  OOOO",                        427     "OOOOO  OOOOOO  OOOO",
428     "OOOOO. XOOOOo .OOOO",                        428     "OOOOO. XOOOOo .OOOO",
429     "OOOOOo  oOOo  oOOOO",                        429     "OOOOOo  oOOo  oOOOO",
430     "OOOOOOX       XOOOO",                        430     "OOOOOOX       XOOOO",
431     "OOOOOOOo.  .   XOOO",                        431     "OOOOOOOo.  .   XOOO",
432     "OOOOOOOOOOOOO.  XOO",                        432     "OOOOOOOOOOOOO.  XOO",
433     "OOOOOOOOOOOOOO. XOO",                        433     "OOOOOOOOOOOOOO. XOO",
434     "OOOOOOOOOOOOOOOoOOO",                        434     "OOOOOOOOOOOOOOOoOOO",
435     "OOOOOOOOOOOOOOOOOOO",                        435     "OOOOOOOOOOOOOOOOOOO",
436     "OOOOOOOOOOOOOOOOOOO",                        436     "OOOOOOOOOOOOOOOOOOO",
437     "OOOOOOOOOOOOOOOOOOO",                        437     "OOOOOOOOOOOOOOOOOOO",
438     "OOOOOOOOOOOOOOOOOOO"                         438     "OOOOOOOOOOOOOOOOOOO"
439   };                                              439   };
440   fSearchIcon = new QPixmap(search);              440   fSearchIcon = new QPixmap(search);
441                                                   441 
442   const char * const clear[]  = {                 442   const char * const clear[]  = {
443     /* columns rows colors chars-per-pixel */     443     /* columns rows colors chars-per-pixel */
444     "20 20 8 1",                                  444     "20 20 8 1",
445     "  c #020202",                                445     "  c #020202",
446     ". c #202020",                                446     ". c #202020",
447     "X c #2C2C2C",                                447     "X c #2C2C2C",
448     "o c #797979",                                448     "o c #797979",
449     "O c None",                                   449     "O c None",
450     "+ c #797979",                                450     "+ c #797979",
451     "@ c #797979",                                451     "@ c #797979",
452     "# c #797979",                                452     "# c #797979",
453     /* pixels */                                  453     /* pixels */
454     "OOOOOOOOOOOOOOOOOOOO",                       454     "OOOOOOOOOOOOOOOOOOOO",
455     "OOOOOOOo    oOOOOOOO",                       455     "OOOOOOOo    oOOOOOOO",
456     "OOOOOXX      XXOOOOO",                       456     "OOOOOXX      XXOOOOO",
457     "OOOOOOOOOOOOOOOOOOOO",                       457     "OOOOOOOOOOOOOOOOOOOO",
458     "OOOOOOOOOOOOOOOOOOOO",                       458     "OOOOOOOOOOOOOOOOOOOO",
459     "OOOO XXXXXXXXXX OOOO",                       459     "OOOO XXXXXXXXXX OOOO",
460     "OOO XOOOOOOOOOO  OOO",                       460     "OOO XOOOOOOOOOO  OOO",
461     "OOOOXOooOooOooO OOOO",                       461     "OOOOXOooOooOooO OOOO",
462     "OOOOXOooOooOooO OOOO",                       462     "OOOOXOooOooOooO OOOO",
463     "OOOOXOooOooOooO OOOO",                       463     "OOOOXOooOooOooO OOOO",
464     "OOOOXOooOooOooO OOOO",                       464     "OOOOXOooOooOooO OOOO",
465     "OOOOXOooOooOooO OOOO",                       465     "OOOOXOooOooOooO OOOO",
466     "OOOOXOooOooOooO OOOO",                       466     "OOOOXOooOooOooO OOOO",
467     "OOOOXOooOooOooO OOOO",                       467     "OOOOXOooOooOooO OOOO",
468     "OOOOXOooOooOooO OOOO",                       468     "OOOOXOooOooOooO OOOO",
469     "OOOOXOooOooOooO OOOO",                       469     "OOOOXOooOooOooO OOOO",
470     "OOOOXOooOooOooO OOOO",                       470     "OOOOXOooOooOooO OOOO",
471     "OOOOXOOOOOOOOOO OOOO",                       471     "OOOOXOOOOOOOOOO OOOO",
472     "OOOOOooooooooooOOOOO",                       472     "OOOOOooooooooooOOOOO",
473     "OOOOOO........OOOOOO"                        473     "OOOOOO........OOOOOO"
474   };                                              474   };
475                                                   475 
476   fClearIcon = new QPixmap(clear);                476   fClearIcon = new QPixmap(clear);
477                                                   477 
478                                                   478 
479   const char * const open[]={                     479   const char * const open[]={
480     "32 32 33 1",                                 480     "32 32 33 1",
481     "       c None",                              481     "       c None",
482     "+      c #09091E",                           482     "+      c #09091E",
483     "@      c #191B18",                           483     "@      c #191B18",
484     "#      c #5F615F",                           484     "#      c #5F615F",
485     "$      c #777977",                           485     "$      c #777977",
486     "%      c #AEB1AF",                           486     "%      c #AEB1AF",
487     "&      c #929491",                           487     "&      c #929491",
488     "*      c #515250",                           488     "*      c #515250",
489     "=      c #858784",                           489     "=      c #858784",
490     "-      c #333533",                           490     "-      c #333533",
491     ";      c #000100",                           491     ";      c #000100",
492     ">      c #272926",                           492     ">      c #272926",
493     ",      c #424341",                           493     ",      c #424341",
494     "'      c #696C6A",                           494     "'      c #696C6A",
495     ")      c #5F4927",                           495     ")      c #5F4927",
496     "!      c #583D18",                           496     "!      c #583D18",
497     "~      c #6E6A5B",                           497     "~      c #6E6A5B",
498     "{      c #47351D",                           498     "{      c #47351D",
499     "]      c #E0A554",                           499     "]      c #E0A554",
500     "^      c #FFD67B",                           500     "^      c #FFD67B",
501     "/      c #EFB465",                           501     "/      c #EFB465",
502     "(      c #FDBF6C",                           502     "(      c #FDBF6C",
503     "_      c #FFCD76",                           503     "_      c #FFCD76",
504     ":      c #806238",                           504     ":      c #806238",
505     "<      c #362611",                           505     "<      c #362611",
506     "[      c #0B0D0A",                           506     "[      c #0B0D0A",
507     "}      c #68471B",                           507     "}      c #68471B",
508     "|      c #523E22",                           508     "|      c #523E22",
509     "1      c #B78A51",                           509     "1      c #B78A51",
510     "2      c #A17B44",                           510     "2      c #A17B44",
511     "3      c #D6A45E",                           511     "3      c #D6A45E",
512     "4      c #C29354",                           512     "4      c #C29354",
513     "5      c #A1A3A0",                           513     "5      c #A1A3A0",
514     "                                ",           514     "                                ",
515     "                                ",           515     "                                ",
516     "                     +@@@#      ",           516     "                     +@@@#      ",
517     "                    $%   +&   * ",           517     "                    $%   +&   * ",
518     "                   #=     $  -; ",           518     "                   #=     $  -; ",
519     "                           %>;+ ",           519     "                           %>;+ ",
520     "                           ,;;+ ",           520     "                           ,;;+ ",
521     "  &#$''#'                 >;;;+ ",           521     "  &#$''#'                 >;;;+ ",
522     " =)!)!!!!~                *#$'' ",           522     " =)!)!!!!~                *#$'' ",
523     " {]^/((_({-  %%%%%%%%%%%        ",           523     " {]^/((_({-  %%%%%%%%%%%        ",
524     " {(^_^^^^:<{{{{{{{{{{{{{[&      ",           524     " {(^_^^^^:<{{{{{{{{{{{{{[&      ",
525     " {/_/(((((/]]]]]]]]]]]/]!#      ",           525     " {/_/(((((/]]]]]]]]]]]/]!#      ",
526     " {/^(((((_^^^^^^^^^^^^^^:#      ",           526     " {/^(((((_^^^^^^^^^^^^^^:#      ",
527     " {/^(((_^^____________^^}$      ",           527     " {/^(((_^^____________^^}$      ",
528     " {/^(((((/////////////((!#      ",           528     " {/^(((((/////////////((!#      ",
529     " {/^/^_:<|||||||||||||||@@****1 ",           529     " {/^/^_:<|||||||||||||||@@****1 ",
530     " {/^/^(<[)||||||||||||||))!!}<; ",           530     " {/^/^(<[)||||||||||||||))!!}<; ",
531     " {/^_(:|234444444444444444432)1 ",           531     " {/^_(:|234444444444444444432)1 ",
532     " {/_^/<)34444444444444444443},  ",           532     " {/_^/<)34444444444444444443},  ",
533     " {/^(2{:41111111111111111142|5  ",           533     " {/^(2{:41111111111111111142|5  ",
534     " {3^3<:31111111111111111143}-   ",           534     " {3^3<:31111111111111111143}-   ",
535     " {/^2<:31111111111111111441|'   ",           535     " {/^2<:31111111111111111441|'   ",
536     " {_/<:41111111111111111143},    ",           536     " {_/<:41111111111111111143},    ",
537     " {(4<:31111111111111111144!#    ",           537     " {(4<:31111111111111111144!#    ",
538     " )4))44111111111111111144},     ",           538     " )4))44111111111111111144},     ",
539     " )2<:31111111111111111144{#     ",           539     " )2<:31111111111111111144{#     ",
540     " @|:14444444444444444444}*      ",           540     " @|:14444444444444444444}*      ",
541     " ;@434444444444444444434<#      ",           541     " ;@434444444444444444434<#      ",
542     " ;[))))))))))))))))))))!~       ",           542     " ;[))))))))))))))))))))!~       ",
543     " ++++++++++++++++++++++;%       ",           543     " ++++++++++++++++++++++;%       ",
544     "                                ",           544     "                                ",
545     "                                "}           545     "                                "}
546   ;                                               546   ;
547   fOpenIcon = new QPixmap(open);                  547   fOpenIcon = new QPixmap(open);
548                                                   548 
549                                                   549 
550   const char * const move[]={                     550   const char * const move[]={
551     "32 32 16 1",                                 551     "32 32 16 1",
552     "       c None",                              552     "       c None",
553     ".      c #F1F1F1",                           553     ".      c #F1F1F1",
554     "+      c #939393",                           554     "+      c #939393",
555     "@      c #282828",                           555     "@      c #282828",
556     "#      c #787878",                           556     "#      c #787878",
557     "$      c #000000",                           557     "$      c #000000",
558     "%      c #CCCCCC",                           558     "%      c #CCCCCC",
559     "&      c #1A1A1A",                           559     "&      c #1A1A1A",
560     "*      c #0D0D0D",                           560     "*      c #0D0D0D",
561     "=      c #5D5D5D",                           561     "=      c #5D5D5D",
562     "-      c #AEAEAE",                           562     "-      c #AEAEAE",
563     ";      c #BBBBBB",                           563     ";      c #BBBBBB",
564     ">      c #C9C9C9",                           564     ">      c #C9C9C9",
565     ",      c #D6D6D6",                           565     ",      c #D6D6D6",
566     "'      c #FFFFFF",                           566     "'      c #FFFFFF",
567     ")      c #999999",                           567     ")      c #999999",
568     "                                ",           568     "                                ",
569     "                                ",           569     "                                ",
570     "                                ",           570     "                                ",
571     "                                ",           571     "                                ",
572     "               ..               ",           572     "               ..               ",
573     "               ++               ",           573     "               ++               ",
574     "              .@@.              ",           574     "              .@@.              ",
575     "              #$$#              ",           575     "              #$$#              ",
576     "             %&$$*%             ",           576     "             %&$$*%             ",
577     "             =$$$$=             ",           577     "             =$$$$=             ",
578     "            -**$$**-            ",           578     "            -**$$**-            ",
579     "            %;%&*>;%            ",           579     "            %;%&*>;%            ",
580     "          -%   @&   %-          ",           580     "          -%   @&   %-          ",
581     "        ,=*;   @&   ;*=,        ",           581     "        ,=*;   @&   ;*=,        ",
582     "      .#*$$>        >$$*#.      ",           582     "      .#*$$>        >$$*#.      ",
583     "    ')&$$$$*@@    @@*$$$$&)'    ",           583     "    ')&$$$$*@@    @@*$$$$&)'    ",
584     "    ')&$$$$*@@    @@*$$$$&+'    ",           584     "    ')&$$$$*@@    @@*$$$$&+'    ",
585     "      .#*$$>        >$$*#.      ",           585     "      .#*$$>        >$$*#.      ",
586     "        ,=*;   @&   ;*=,        ",           586     "        ,=*;   @&   ;*=,        ",
587     "          -%   @&   %-          ",           587     "          -%   @&   %-          ",
588     "            %;%&*>>%            ",           588     "            %;%&*>>%            ",
589     "            -**$$**-            ",           589     "            -**$$**-            ",
590     "             =$$$$=             ",           590     "             =$$$$=             ",
591     "             %&$$*%             ",           591     "             %&$$*%             ",
592     "              #$$#              ",           592     "              #$$#              ",
593     "              .@@.              ",           593     "              .@@.              ",
594     "               ++               ",           594     "               ++               ",
595     "               ..               ",           595     "               ..               ",
596     "                                ",           596     "                                ",
597     "                                ",           597     "                                ",
598     "                                ",           598     "                                ",
599     "                                "}           599     "                                "}
600   ;                                               600   ;
601   fMoveIcon = new QPixmap(move);                  601   fMoveIcon = new QPixmap(move);
602                                                   602 
603   const char * const rotate[]={                   603   const char * const rotate[]={
604     "32 32 27 1",                                 604     "32 32 27 1",
605     "       c None",                              605     "       c None",
606     ".      c #003333",                           606     ".      c #003333",
607     "+      c #000066",                           607     "+      c #000066",
608     "@      c #1A1A1A",                           608     "@      c #1A1A1A",
609     "#      c #003399",                           609     "#      c #003399",
610     "$      c #3333CC",                           610     "$      c #3333CC",
611     "%      c #000033",                           611     "%      c #000033",
612     "&      c #353535",                           612     "&      c #353535",
613     "*      c #434343",                           613     "*      c #434343",
614     "=      c #336699",                           614     "=      c #336699",
615     "-      c #3399FF",                           615     "-      c #3399FF",
616     ";      c #003366",                           616     ";      c #003366",
617     ">      c #5D5D5D",                           617     ">      c #5D5D5D",
618     ",      c #282828",                           618     ",      c #282828",
619     "'      c #3399CC",                           619     "'      c #3399CC",
620     ")      c #333333",                           620     ")      c #333333",
621     "!      c #3366CC",                           621     "!      c #3366CC",
622     "~      c #333399",                           622     "~      c #333399",
623     "{      c #505050",                           623     "{      c #505050",
624     "]      c #666666",                           624     "]      c #666666",
625     "^      c #333366",                           625     "^      c #333366",
626     "/      c #0033CC",                           626     "/      c #0033CC",
627     "(      c #3366FF",                           627     "(      c #3366FF",
628     "_      c #336666",                           628     "_      c #336666",
629     ":      c #787878",                           629     ":      c #787878",
630     "<      c #868686",                           630     "<      c #868686",
631     "[      c #6B6B6B",                           631     "[      c #6B6B6B",
632     "                   .++@         ",           632     "                   .++@         ",
633     "                  #$$%&*        ",           633     "                  #$$%&*        ",
634     "                 =--; *>,       ",           634     "                 =--; *>,       ",
635     "                 '-=  )>&       ",           635     "                 '-=  )>&       ",
636     "                !-',  ,>*       ",           636     "                !-',  ,>*       ",
637     "             !!=--=    >*       ",           637     "             !!=--=    >*       ",
638     "            =------!!~@&)@      ",           638     "            =------!!~@&)@      ",
639     "             --------!*{{{*&,   ",           639     "             --------!*{{{*&,   ",
640     "             -------=){*{{{>>{) ",           640     "             -------=){*{{{>>{) ",
641     "            ,!-----=  ){&  ,&{{@",           641     "            ,!-----=  ){&  ,&{{@",
642     "          ,*>!----=   &>&     )@",           642     "          ,*>!----=   &>&     )@",
643     "         ){>)~---=    *])      @",           643     "         ){>)~---=    *])      @",
644     "        @*>,  --!     ,&@       ",           644     "        @*>,  --!     ,&@       ",
645     "        @{*   '!      ,-!=~^,@  ",           645     "        @{*   '!      ,-!=~^,@  ",
646     "        @&    ==      {/(----!^ ",           646     "        @&    ==      {/(----!^ ",
647     "         _           ]:;(----'  ",           647     "         _           ]:;(----'  ",
648     "         ==_         >{+(----~  ",           648     "         ==_         >{+(----~  ",
649     "          !-!!======!!(((---!   ",           649     "          !-!!======!!(((---!   ",
650     "           ='--------------!    ",           650     "           ='--------------!    ",
651     "             =!!!!'!!=; !-!     ",           651     "             =!!!!'!!=; !-!     ",
652     "                   &<*  !~      ",           652     "                   &<*  !~      ",
653     "              @.  *[*   ;       ",           653     "              @.  *[*   ;       ",
654     "               ;+)>*            ",           654     "               ;+)>*            ",
655     "                 @@             ",           655     "                 @@             ",
656     "                                ",           656     "                                ",
657     "                                ",           657     "                                ",
658     "                                ",           658     "                                ",
659     "                                ",           659     "                                ",
660     "                                ",           660     "                                ",
661     "                                ",           661     "                                ",
662     "                                ",           662     "                                ",
663     "                                "}           663     "                                "}
664   ;                                               664   ;
665   fRotateIcon = new QPixmap(rotate);              665   fRotateIcon = new QPixmap(rotate);
666                                                   666 
667   const char * const pick[]={                     667   const char * const pick[]={
668     /* columns rows colors chars-per-pixel */     668     /* columns rows colors chars-per-pixel */
669     "20 20 12 1 ",                                669     "20 20 12 1 ",
670     "  c #050804",                                670     "  c #050804",
671     ". c #222321",                                671     ". c #222321",
672     "X c #3B3C3A",                                672     "X c #3B3C3A",
673     "o c #4C4E4B",                                673     "o c #4C4E4B",
674     "O c #616360",                                674     "O c #616360",
675     "+ c #747673",                                675     "+ c #747673",
676     "@ c #8A8C89",                                676     "@ c #8A8C89",
677     "# c #9FA19E",                                677     "# c #9FA19E",
678     "$ c #BABCB9",                                678     "$ c #BABCB9",
679     "% c #CED0CD",                                679     "% c #CED0CD",
680     "& c #E4E6E3",                                680     "& c #E4E6E3",
681     "* c None",                                   681     "* c None",
682     /* pixels */                                  682     /* pixels */
683     "*********oo*********",                       683     "*********oo*********",
684     "*********oo*********",                       684     "*********oo*********",
685     "******$O.  .O%******",                       685     "******$O.  .O%******",
686     "****&o .O..O  O*****",                       686     "****&o .O..O  O*****",
687     "***&X @**oo**@ X****",                       687     "***&X @**oo**@ X****",
688     "***o $***oo***$ O***",                       688     "***o $***oo***$ O***",
689     "**% @**********@ %**",                       689     "**% @**********@ %**",
690     "**O.***********& +**",                       690     "**O.***********& +**",
691     "**.O*****@@*****o.**",                       691     "**.O*****@@*****o.**",
692     "oo .oo**@  #*&XX. oo",                       692     "oo .oo**@  #*&XX. oo",
693     "oo .oo**@  #*&oo. oO",                       693     "oo .oo**@  #*&oo. oO",
694     "**.O*****##*****oX**",                       694     "**.O*****##*****oX**",
695     "**O ***********& +**",                       695     "**O ***********& +**",
696     "**% @****&&****+ &**",                       696     "**% @****&&****+ &**",
697     "***O $***Xo***# +***",                       697     "***O $***Xo***# +***",
698     "****X @&*Xo*&+ o****",                       698     "****X @&*Xo*&+ o****",
699     "*****O  o..o  +*****",                       699     "*****O  o..o  +*****",
700     "******%+.  X+&******",                       700     "******%+.  X+&******",
701     "*********oo*********",                       701     "*********oo*********",
702     "*********oO*********"                        702     "*********oO*********"
703   };                                              703   };
704   fPickIcon = new QPixmap(pick);                  704   fPickIcon = new QPixmap(pick);
705                                                   705 
706   const char * const zoom_in[]={                  706   const char * const zoom_in[]={
707     "32 32 11 1",                                 707     "32 32 11 1",
708     "       c None",                              708     "       c None",
709     ".      c #C9CBC8",                           709     ".      c #C9CBC8",
710     "+      c #A8A9A3",                           710     "+      c #A8A9A3",
711     "@      c #818783",                           711     "@      c #818783",
712     "#      c #D5D8D5",                           712     "#      c #D5D8D5",
713     "$      c #9BCCCC",                           713     "$      c #9BCCCC",
714     "%      c #5FC7F4",                           714     "%      c #5FC7F4",
715     "&      c #FDFFFC",                           715     "&      c #FDFFFC",
716     "*      c #636662",                           716     "*      c #636662",
717     "=      c #9599CE",                           717     "=      c #9599CE",
718     "-      c #DDE0DD",                           718     "-      c #DDE0DD",
719     "                                ",           719     "                                ",
720     "                                ",           720     "                                ",
721     "                                ",           721     "                                ",
722     "                                ",           722     "                                ",
723     "                                ",           723     "                                ",
724     "          .++@@++.              ",           724     "          .++@@++.              ",
725     "         +++..#.+++             ",           725     "         +++..#.+++             ",
726     "       .@+...++++#+@.           ",           726     "       .@+...++++#+@.           ",
727     "       @$.%%+&&&@%..@           ",           727     "       @$.%%+&&&@%..@           ",
728     "      ++.%%%+&&&*%%.++          ",           728     "      ++.%%%+&&&*%%.++          ",
729     "     .+#%%%%+&&&*%%.#+          ",           729     "     .+#%%%%+&&&*%%.#+          ",
730     "     ++..%%%+&&&*%%%.++         ",           730     "     ++..%%%+&&&*%%%.++         ",
731     "     +#.+++++&&&*++++.+         ",           731     "     +#.+++++&&&*++++.+         ",
732     "     @.+&&&&&&&&&&&&&+@         ",           732     "     @.+&&&&&&&&&&&&&+@         ",
733     "     @#+&&&&&&&&&&&&&+@         ",           733     "     @#+&&&&&&&&&&&&&+@         ",
734     "     @.+&&&&&&&&&&&&&+.         ",           734     "     @.+&&&&&&&&&&&&&+.         ",
735     "     +++@***+&&&****@+.         ",           735     "     +++@***+&&&****@+.         ",
736     "     ....++++&&&*++++..         ",           736     "     ....++++&&&*++++..         ",
737     "      ++.===+&&&*%=.++          ",           737     "      ++.===+&&&*%=.++          ",
738     "       @..==+&&&*=..@#&         ",           738     "       @..==+&&&*=..@#&         ",
739     "       .@+#.+&&&@-+@@*@         ",           739     "       .@+#.+&&&@-+@@*@         ",
740     "         +++.++++++ *+@*        ",           740     "         +++.++++++ *+@*        ",
741     "          .+@@@++.  @**+*       ",           741     "          .+@@@++.  @**+*       ",
742     "                    .*@*+*      ",           742     "                    .*@*+*      ",
743     "                     .*@*+*     ",           743     "                     .*@*+*     ",
744     "                      +*@@*     ",           744     "                      +*@@*     ",
745     "                       .**+     ",           745     "                       .**+     ",
746     "                                ",           746     "                                ",
747     "                                ",           747     "                                ",
748     "                                ",           748     "                                ",
749     "                                ",           749     "                                ",
750     "                                "}           750     "                                "}
751   ;                                               751   ;
752   fZoomInIcon = new QPixmap(zoom_in);             752   fZoomInIcon = new QPixmap(zoom_in);
753                                                   753 
754   const char * const zoom_out[]={                 754   const char * const zoom_out[]={
755     "32 32 11 1",                                 755     "32 32 11 1",
756     "       c None",                              756     "       c None",
757     ".      c #C9CBC8",                           757     ".      c #C9CBC8",
758     "+      c #A8A9A3",                           758     "+      c #A8A9A3",
759     "@      c #818783",                           759     "@      c #818783",
760     "#      c #D5D8D5",                           760     "#      c #D5D8D5",
761     "$      c #5FC7F4",                           761     "$      c #5FC7F4",
762     "%      c #9BCCCC",                           762     "%      c #9BCCCC",
763     "&      c #FDFFFC",                           763     "&      c #FDFFFC",
764     "*      c #636662",                           764     "*      c #636662",
765     "=      c #9599CE",                           765     "=      c #9599CE",
766     "-      c #DDE0DD",                           766     "-      c #DDE0DD",
767     "                                ",           767     "                                ",
768     "                                ",           768     "                                ",
769     "                                ",           769     "                                ",
770     "                                ",           770     "                                ",
771     "                                ",           771     "                                ",
772     "          .++@@++.              ",           772     "          .++@@++.              ",
773     "         +++..#.+++             ",           773     "         +++..#.+++             ",
774     "       .@+..$$$$.#+@.           ",           774     "       .@+..$$$$.#+@.           ",
775     "       @%.$$$$$$$$..@           ",           775     "       @%.$$$$$$$$..@           ",
776     "      ++.$$$$$$$$$$.++          ",           776     "      ++.$$$$$$$$$$.++          ",
777     "     .+#$$$$$$$$$$$.#+          ",           777     "     .+#$$$$$$$$$$$.#+          ",
778     "     ++..$$$$$$$$$$$.++         ",           778     "     ++..$$$$$$$$$$$.++         ",
779     "     +#.+++++++++++++.+         ",           779     "     +#.+++++++++++++.+         ",
780     "     @.+&&&&&&&&&&&&&+@         ",           780     "     @.+&&&&&&&&&&&&&+@         ",
781     "     @#+&&&&&&&&&&&&&+@         ",           781     "     @#+&&&&&&&&&&&&&+@         ",
782     "     @.+&&&&&&&&&&&&&+.         ",           782     "     @.+&&&&&&&&&&&&&+.         ",
783     "     +++@***********@+.         ",           783     "     +++@***********@+.         ",
784     "     ....++++++++++++..         ",           784     "     ....++++++++++++..         ",
785     "      ++.===$$$$$$=.++          ",           785     "      ++.===$$$$$$=.++          ",
786     "       @..===$$$$=..@#&         ",           786     "       @..===$$$$=..@#&         ",
787     "       .@+#.$$$..-+@@*@         ",           787     "       .@+#.$$$..-+@@*@         ",
788     "         +++#--.+++ *+@*        ",           788     "         +++#--.+++ *+@*        ",
789     "          .+@@@++.  @**+*       ",           789     "          .+@@@++.  @**+*       ",
790     "                    .*@*+*      ",           790     "                    .*@*+*      ",
791     "                     .*@*+*     ",           791     "                     .*@*+*     ",
792     "                      +*@@*     ",           792     "                      +*@@*     ",
793     "                       .**+     ",           793     "                       .**+     ",
794     "                                ",           794     "                                ",
795     "                                ",           795     "                                ",
796     "                                ",           796     "                                ",
797     "                                ",           797     "                                ",
798     "                                "}           798     "                                "}
799   ;                                               799   ;
800   fZoomOutIcon = new QPixmap(zoom_out);           800   fZoomOutIcon = new QPixmap(zoom_out);
801                                                   801 
802   const char * const wireframe[]={                802   const char * const wireframe[]={
803     "32 32 24 1",                                 803     "32 32 24 1",
804     "       c None",                              804     "       c None",
805     "+      c #E4E4E4",                           805     "+      c #E4E4E4",
806     "@      c #D5D5D5",                           806     "@      c #D5D5D5",
807     "#      c #E1E1E1",                           807     "#      c #E1E1E1",
808     "$      c #E7E7E7",                           808     "$      c #E7E7E7",
809     "%      c #D8D8D8",                           809     "%      c #D8D8D8",
810     "&      c #A7A7A7",                           810     "&      c #A7A7A7",
811     "*      c #000000",                           811     "*      c #000000",
812     "=      c #989898",                           812     "=      c #989898",
813     "-      c #8A8A8A",                           813     "-      c #8A8A8A",
814     ";      c #B5B5B5",                           814     ";      c #B5B5B5",
815     ">      c #1B1B1B",                           815     ">      c #1B1B1B",
816     ",      c #676767",                           816     ",      c #676767",
817     "'      c #959595",                           817     "'      c #959595",
818     ")      c #4A4A4A",                           818     ")      c #4A4A4A",
819     "!      c #878787",                           819     "!      c #878787",
820     "~      c #D3D3D3",                           820     "~      c #D3D3D3",
821     "{      c #C4C4C4",                           821     "{      c #C4C4C4",
822     "]      c #A4A4A4",                           822     "]      c #A4A4A4",
823     "^      c #5B5B5B",                           823     "^      c #5B5B5B",
824     "/      c #B3B3B3",                           824     "/      c #B3B3B3",
825     "(      c #787878",                           825     "(      c #787878",
826     "_      c #C7C7C7",                           826     "_      c #C7C7C7",
827     ":      c #585858",                           827     ":      c #585858",
828     "                                ",           828     "                                ",
829     "                  +@@#          ",           829     "                  +@@#          ",
830     "          $%@@@@@&****=+        ",           830     "          $%@@@@@&****=+        ",
831     "        +&********&@-***;       ",           831     "        +&********&@-***;       ",
832     "   +@@@&**&@@@@@@$  @*-&>&+     ",           832     "   +@@@&**&@@@@@@$  @*-&>&+     ",
833     "  +*****&+          %*@ ,**'#   ",           833     "  +*****&+          %*@ ,**'#   ",
834     "  @***)!~           @*{&*****+  ",           834     "  @***)!~           @*{&*****+  ",
835     "  @*!]***&+        +-*^**'~!*@  ",           835     "  @*!]***&+        +-*^**'~!*@  ",
836     "  @*~ +@&**&@@@@@@&****&+  ~*@  ",           836     "  @*~ +@&**&@@@@@@&****&+  ~*@  ",
837     "  @*@    +&********&-*=    @*@  ",           837     "  @*@    +&********&-*=    @*@  ",
838     "  @*@      $%@-*-@$ @*@    @*@  ",           838     "  @*@      $%@-*-@$ @*@    @*@  ",
839     "  @*@         @*@   %*%    @*@  ",           839     "  @*@         @*@   %*%    @*@  ",
840     "  @*@         %*%   %*%    @*@  ",           840     "  @*@         %*%   %*%    @*@  ",
841     "  @*@         %*%   %*%    @*@  ",           841     "  @*@         %*%   %*%    @*@  ",
842     "  @*@         %*%   %*%    @*@  ",           842     "  @*@         %*%   %*%    @*@  ",
843     "  @*@         %*%   %*%    @*@  ",           843     "  @*@         %*%   %*%    @*@  ",
844     "  @*@         %*%   %*%    @*@  ",           844     "  @*@         %*%   %*%    @*@  ",
845     "  @*@         @*@   %*%    @*@  ",           845     "  @*@         @*@   %*%    @*@  ",
846     "  @*@         =*-+  @*@    @*@  ",           846     "  @*@         =*-+  @*@    @*@  ",
847     "  @*@    $%@@&****&@-*-+   @*@  ",           847     "  @*@    $%@@&****&@-*-+   @*@  ",
848     "  @*@ $@&*****&@@&******&~~!*@  ",           848     "  @*@ $@&*****&@@&******&~~!*@  ",
849     "  @*{/***&@@%$    $@-*-&*****+  ",           849     "  @*{/***&@@%$    $@-*-&*****+  ",
850     "  @*)*)(-~          @*@ ~)**]   ",           850     "  @*)*)(-~          @*@ ~)**]   ",
851     "  +*******&@@@@+    %*_+]**]    ",           851     "  +*******&@@@@+    %*_+]**]    ",
852     "   +@@@@@&******&@%+_*^**]#     ",           852     "   +@@@@@&******&@%+_*^**]#     ",
853     "          $%@@@&****:**&+       ",           853     "          $%@@@&****:**&+       ",
854     "                +%@&**&         ",           854     "                +%@&**&         ",
855     "                    ++          ",           855     "                    ++          ",
856     "                                ",           856     "                                ",
857     "                                ",           857     "                                ",
858     "                                ",           858     "                                ",
859     "                                "}           859     "                                "}
860   ;                                               860   ;
861   fWireframeIcon = new QPixmap(wireframe);        861   fWireframeIcon = new QPixmap(wireframe);
862                                                   862 
863   const char * const solid[]={                    863   const char * const solid[]={
864     "32 32 33 1",                                 864     "32 32 33 1",
865     "       c None",                              865     "       c None",
866     "+      c #C2DEDE",                           866     "+      c #C2DEDE",
867     "@      c #B5D7DF",                           867     "@      c #B5D7DF",
868     "#      c #ACD6E6",                           868     "#      c #ACD6E6",
869     "$      c #60C0EC",                           869     "$      c #60C0EC",
870     "%      c #4EB7EE",                           870     "%      c #4EB7EE",
871     "&      c #53B9ED",                           871     "&      c #53B9ED",
872     "*      c #82CEEA",                           872     "*      c #82CEEA",
873     "=      c #CFDDDA",                           873     "=      c #CFDDDA",
874     "-      c #94C9E8",                           874     "-      c #94C9E8",
875     ";      c #0960FF",                           875     ";      c #0960FF",
876     ">      c #0943FF",                           876     ">      c #0943FF",
877     ",      c #0949FF",                           877     ",      c #0949FF",
878     "'      c #3CB3F0",                           878     "'      c #3CB3F0",
879     ")      c #71C7EB",                           879     ")      c #71C7EB",
880     "!      c #73CBE5",                           880     "!      c #73CBE5",
881     "~      c #D3DDDB",                           881     "~      c #D3DDDB",
882     "{      c #C4DDDE",                           882     "{      c #C4DDDE",
883     "]      c #B7D5DF",                           883     "]      c #B7D5DF",
884     "^      c #2DACF5",                           884     "^      c #2DACF5",
885     "/      c #59C1ED",                           885     "/      c #59C1ED",
886     "(      c #5FC0ED",                           886     "(      c #5FC0ED",
887     "_      c #85CEE9",                           887     "_      c #85CEE9",
888     ":      c #096BFF",                           888     ":      c #096BFF",
889     "<      c #2AACF6",                           889     "<      c #2AACF6",
890     "[      c #5CBEEC",                           890     "[      c #5CBEEC",
891     "}      c #7ACAE4",                           891     "}      c #7ACAE4",
892     "|      c #73CAEB",                           892     "|      c #73CAEB",
893     "1      c #71C8E5",                           893     "1      c #71C8E5",
894     "2      c #D1DDDA",                           894     "2      c #D1DDDA",
895     "3      c #CBDDD9",                           895     "3      c #CBDDD9",
896     "4      c #67C1EB",                           896     "4      c #67C1EB",
897     "5      c #80CDEA",                           897     "5      c #80CDEA",
898     "                                ",           898     "                                ",
899     "                                ",           899     "                                ",
900     "          +@@@@@@#$%&*=         ",           900     "          +@@@@@@#$%&*=         ",
901     "        +-;>>>>>>>>>,')!~       ",           901     "        +-;>>>>>>>>>,')!~       ",
902     "   {]@@-;>>>>>>>>>>>>^/(_=      ",           902     "   {]@@-;>>>>>>>>>>>>^/(_=      ",
903     "  {:>>>>>>>>>>>>>>>>><//[)!=    ",           903     "  {:>>>>>>>>>>>>>>>>><//[)!=    ",
904     "  ]>>>>>>>>>>>>>>>>>><////[)}   ",           904     "  ]>>>>>>>>>>>>>>>>>><////[)}   ",
905     "  @>>>>>>>>>>>>>>>>>><//////|   ",           905     "  @>>>>>>>>>>>>>>>>>><//////|   ",
906     "  @>>>>>>>>>>>>>>>>>><//////|   ",           906     "  @>>>>>>>>>>>>>>>>>><//////|   ",
907     "  @>>>>>>>>>>>>>>>>>><//////|   ",           907     "  @>>>>>>>>>>>>>>>>>><//////|   ",
908     "  @>>>>>>>>>>>>>>>>>><//////|   ",           908     "  @>>>>>>>>>>>>>>>>>><//////|   ",
909     "  @>>>>>>>>>>>>>>>>>><//////|   ",           909     "  @>>>>>>>>>>>>>>>>>><//////|   ",
910     "  @>>>>>>>>>>>>>>>>>><//////|   ",           910     "  @>>>>>>>>>>>>>>>>>><//////|   ",
911     "  @>>>>>>>>>>>>>>>>>><//////|   ",           911     "  @>>>>>>>>>>>>>>>>>><//////|   ",
912     "  @>>>>>>>>>>>>>>>>>><//////|   ",           912     "  @>>>>>>>>>>>>>>>>>><//////|   ",
913     "  @>>>>>>>>>>>>>>>>>><//////|   ",           913     "  @>>>>>>>>>>>>>>>>>><//////|   ",
914     "  @>>>>>>>>>>>>>>>>>><//////|   ",           914     "  @>>>>>>>>>>>>>>>>>><//////|   ",
915     "  @>>>>>>>>>>>>>>>>>><//////|   ",           915     "  @>>>>>>>>>>>>>>>>>><//////|   ",
916     "  @>>>>>>>>>>>>>>>>>><//////|   ",           916     "  @>>>>>>>>>>>>>>>>>><//////|   ",
917     "  @>>>>>>>>>>>>>>>>>><//////|   ",           917     "  @>>>>>>>>>>>>>>>>>><//////|   ",
918     "  @>>>>>>>>>>>>>>>>>><//////|   ",           918     "  @>>>>>>>>>>>>>>>>>><//////|   ",
919     "  @>>>>>>>>>>>>>>>>>></////[1   ",           919     "  @>>>>>>>>>>>>>>>>>></////[1   ",
920     "  @>>>>>>>>>>>>>>>>>><////[*2   ",           920     "  @>>>>>>>>>>>>>>>>>><////[*2   ",
921     "  {:>>>>>>>>>>>>>>>>><//[)12    ",           921     "  {:>>>>>>>>>>>>>>>>><//[)12    ",
922     "   +@@@@@-;>>>>>>>>>><[)13      ",           922     "   +@@@@@-;>>>>>>>>>><[)13      ",
923     "          {]@@@-;>>>,'*3        ",           923     "          {]@@@-;>>>,'*3        ",
924     "                +@@#452         ",           924     "                +@@#452         ",
925     "                                ",           925     "                                ",
926     "                                ",           926     "                                ",
927     "                                ",           927     "                                ",
928     "                                ",           928     "                                ",
929     "                                "}           929     "                                "}
930   ;                                               930   ;
931   fSolidIcon = new QPixmap(solid);                931   fSolidIcon = new QPixmap(solid);
932                                                   932 
933   const char * const hidden_line_removal[]={      933   const char * const hidden_line_removal[]={
934     "32 32 15 1",                                 934     "32 32 15 1",
935     "       c None",                              935     "       c None",
936     "+      c #D5D5D5",                           936     "+      c #D5D5D5",
937     "@      c #C7C7C7",                           937     "@      c #C7C7C7",
938     "#      c #9C9C9C",                           938     "#      c #9C9C9C",
939     "$      c #000000",                           939     "$      c #000000",
940     "%      c #8E8E8E",                           940     "%      c #8E8E8E",
941     "&      c #808080",                           941     "&      c #808080",
942     "*      c #A9A9A9",                           942     "*      c #A9A9A9",
943     "=      c #D8D8D8",                           943     "=      c #D8D8D8",
944     "-      c #CACACA",                           944     "-      c #CACACA",
945     ";      c #181818",                           945     ";      c #181818",
946     ">      c #9F9F9F",                           946     ">      c #9F9F9F",
947     ",      c #ACACAC",                           947     ",      c #ACACAC",
948     "'      c #B9B9B9",                           948     "'      c #B9B9B9",
949     ")      c #555555",                           949     ")      c #555555",
950     "                                ",           950     "                                ",
951     "                  +@@+          ",           951     "                  +@@+          ",
952     "          +@@@@@@#$$$$%+        ",           952     "          +@@@@@@#$$$$%+        ",
953     "        +#$$$$$$$$#@&$$$*       ",           953     "        +#$$$$$$$$#@&$$$*       ",
954     "   =-@@#$$#@@@@@-=  @$&#;>=     ",           954     "   =-@@#$$#@@@@@-=  @$&#;>=     ",
955     "  =$$$$$#+          -$@ *$$%+   ",           955     "  =$$$$$#+          -$@ *$$%+   ",
956     "  -$&@-=            -$-  #$$$=  ",           956     "  -$&@-=            -$-  #$$$=  ",
957     "  -$@               -$-   +&$-  ",           957     "  -$@               -$-   +&$-  ",
958     "  @$@               @$@    @$@  ",           958     "  @$@               @$@    @$@  ",
959     "  @$@               @$@    @$@  ",           959     "  @$@               @$@    @$@  ",
960     "  @$@               @$@    @$@  ",           960     "  @$@               @$@    @$@  ",
961     "  @$@               @$@    @$@  ",           961     "  @$@               @$@    @$@  ",
962     "  @$@               @$@    @$@  ",           962     "  @$@               @$@    @$@  ",
963     "  @$@               @$@    @$@  ",           963     "  @$@               @$@    @$@  ",
964     "  @$@               @$@    @$@  ",           964     "  @$@               @$@    @$@  ",
965     "  @$@               @$@    @$@  ",           965     "  @$@               @$@    @$@  ",
966     "  @$@               @$@    @$@  ",           966     "  @$@               @$@    @$@  ",
967     "  @$@               @$@    @$@  ",           967     "  @$@               @$@    @$@  ",
968     "  @$@               @$@    @$@  ",           968     "  @$@               @$@    @$@  ",
969     "  @$@               @$@    @$@  ",           969     "  @$@               @$@    @$@  ",
970     "  @$@               @$@    @$@  ",           970     "  @$@               @$@    @$@  ",
971     "  @$@               @$@    #$=  ",           971     "  @$@               @$@    #$=  ",
972     "  -$&@@@-=          -$-  =>;,   ",           972     "  -$&@@@-=          -$-  =>;,   ",
973     "  =$$$$$$$#@@@-=    -$'+#$$,    ",           973     "  =$$$$$$$#@@@-=    -$'+#$$,    ",
974     "   =-@@@@#$$$$$$#@-+'$)$$#+     ",           974     "   =-@@@@#$$$$$$#@-+'$)$$#+     ",
975     "          =-@@@#$$$$)$$#+       ",           975     "          =-@@@#$$$$)$$#+       ",
976     "                +@@#$$#         ",           976     "                +@@#$$#         ",
977     "                    ++          ",           977     "                    ++          ",
978     "                                ",           978     "                                ",
979     "                                ",           979     "                                ",
980     "                                ",           980     "                                ",
981     "                                "}           981     "                                "}
982   ;                                               982   ;
983   fHiddenLineRemovalIcon = new QPixmap(hidden_    983   fHiddenLineRemovalIcon = new QPixmap(hidden_line_removal);
984                                                   984 
985   const char * const hidden_line_and_surface_r    985   const char * const hidden_line_and_surface_removal[]={
986     "32 32 40 1",                                 986     "32 32 40 1",
987     "       c None",                              987     "       c None",
988     "+      c #FFFFFF",                           988     "+      c #FFFFFF",
989     "@      c #89A2E9",                           989     "@      c #89A2E9",
990     "#      c #5378E3",                           990     "#      c #5378E3",
991     "$      c #A2B5ED",                           991     "$      c #A2B5ED",
992     "%      c #5379E3",                           992     "%      c #5379E3",
993     "&      c #5076E3",                           993     "&      c #5076E3",
994     "*      c #3E69E4",                           994     "*      c #3E69E4",
995     "=      c #0C43F8",                           995     "=      c #0C43F8",
996     "-      c #043FFE",                           996     "-      c #043FFE",
997     ";      c #CDD9ED",                           997     ";      c #CDD9ED",
998     ">      c #BDCDE9",                           998     ">      c #BDCDE9",
999     ",      c #FBFCFC",                           999     ",      c #FBFCFC",
1000     "'      c #406AE4",                          1000     "'      c #406AE4",
1001     ")      c #0439FE",                          1001     ")      c #0439FE",
1002     "!      c #0137FF",                          1002     "!      c #0137FF",
1003     "~      c #4F75E3",                          1003     "~      c #4F75E3",
1004     "{      c #9EB5E3",                          1004     "{      c #9EB5E3",
1005     "]      c #829FE0",                          1005     "]      c #829FE0",
1006     "^      c #B6C6E7",                          1006     "^      c #B6C6E7",
1007     "/      c #9DB4E3",                          1007     "/      c #9DB4E3",
1008     "(      c #7E9CE0",                          1008     "(      c #7E9CE0",
1009     "_      c #B2C3E9",                          1009     "_      c #B2C3E9",
1010     ":      c #7E9AE0",                          1010     ":      c #7E9AE0",
1011     "<      c #86A2E1",                          1011     "<      c #86A2E1",
1012     "[      c #CAD6ED",                          1012     "[      c #CAD6ED",
1013     "}      c #5177E3",                          1013     "}      c #5177E3",
1014     "|      c #829CE0",                          1014     "|      c #829CE0",
1015     "1      c #BCCCE9",                          1015     "1      c #BCCCE9",
1016     "2      c #3A67E6",                          1016     "2      c #3A67E6",
1017     "3      c #0A43FA",                          1017     "3      c #0A43FA",
1018     "4      c #95ACE1",                          1018     "4      c #95ACE1",
1019     "5      c #BBCBE9",                          1019     "5      c #BBCBE9",
1020     "6      c #A9BBE5",                          1020     "6      c #A9BBE5",
1021     "7      c #96AFE1",                          1021     "7      c #96AFE1",
1022     "8      c #BDCBE9",                          1022     "8      c #BDCBE9",
1023     "9      c #4067E4",                          1023     "9      c #4067E4",
1024     "0      c #6485E5",                          1024     "0      c #6485E5",
1025     "a      c #E3EAF3",                          1025     "a      c #E3EAF3",
1026     "b      c #CAD6F3",                          1026     "b      c #CAD6F3",
1027     "                                ",          1027     "                                ",
1028     "                                ",          1028     "                                ",
1029     "                  ++++          ",          1029     "                  ++++          ",
1030     "          ++++++++@#$+++        ",          1030     "          ++++++++@#$+++        ",
1031     "        ++@%####&*=-#+;>,       ",          1031     "        ++@%####&*=-#+;>,       ",
1032     "   +++++@'=)))))))!)~+{]^++     ",          1032     "   +++++@'=)))))))!)~+{]^++     ",
1033     "   +$%&*=)!!!!!!!!!)~+/(]_+++   ",          1033     "   +$%&*=)!!!!!!!!!)~+/(]_+++   ",
1034     "   +#-))!!!!!!!!!!!)~+/(::<[+   ",          1034     "   +#-))!!!!!!!!!!!)~+/(::<[+   ",
1035     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1035     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1036     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1036     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1037     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1037     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1038     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1038     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1039     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1039     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1040     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1040     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1041     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1041     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1042     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1042     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1043     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1043     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1044     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1044     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1045     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1045     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1046     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1046     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1047     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",          1047     "   +#)!!!!!!!!!!!!!!}+/::::{+   ",
1048     "   +#)!!!!!!!!!!!!!!}+/:::|1+   ",          1048     "   +#)!!!!!!!!!!!!!!}+/:::|1+   ",
1049     "   +$#}}~23!!!!!!!!)~+/(]45,    ",          1049     "   +$#}}~23!!!!!!!!)~+/(]45,    ",
1050     "   +++++++@#}}~23!!)~+678++     ",          1050     "   +++++++@#}}~23!!)~+678++     ",
1051     "          ++++++@#~90+a++       ",          1051     "          ++++++@#~90+a++       ",
1052     "                ++++b++         ",          1052     "                ++++b++         ",
1053     "                    ++          ",          1053     "                    ++          ",
1054     "                                ",          1054     "                                ",
1055     "                                ",          1055     "                                ",
1056     "                                ",          1056     "                                ",
1057     "                                ",          1057     "                                ",
1058     "                                "}          1058     "                                "}
1059   ;                                              1059   ;
1060   fHiddenLineAndSurfaceRemovalIcon = new QPix    1060   fHiddenLineAndSurfaceRemovalIcon = new QPixmap(hidden_line_and_surface_removal);
1061                                                  1061 
1062   const char * const perspective[]={             1062   const char * const perspective[]={
1063     "32 32 3 1",                                 1063     "32 32 3 1",
1064     "       c None",                             1064     "       c None",
1065     ".      c #D5D8D5",                          1065     ".      c #D5D8D5",
1066     "+      c #000000",                          1066     "+      c #000000",
1067     "                                ",          1067     "                                ",
1068     "                                ",          1068     "                                ",
1069     "                                ",          1069     "                                ",
1070     "                                ",          1070     "                                ",
1071     "                                ",          1071     "                                ",
1072     "           ................     ",          1072     "           ................     ",
1073     "       ....+++++++++++++++.     ",          1073     "       ....+++++++++++++++.     ",
1074     "    ...++++..+.........+++.     ",          1074     "    ...++++..+.........+++.     ",
1075     "   ..++..............++..+.     ",          1075     "   ..++..............++..+.     ",
1076     "   .+++++++++++++++++.. .+.     ",          1076     "   .+++++++++++++++++.. .+.     ",
1077     "   .+...............+.  .+.     ",          1077     "   .+...............+.  .+.     ",
1078     "   .+.      .+.    .+.  .+.     ",          1078     "   .+.      .+.    .+.  .+.     ",
1079     "   .+.      .+.    .+.  .+.     ",          1079     "   .+.      .+.    .+.  .+.     ",
1080     "   .+.      .+.    .+.  .+.     ",          1080     "   .+.      .+.    .+.  .+.     ",
1081     "   .+.      .+.    .+.  .+.     ",          1081     "   .+.      .+.    .+.  .+.     ",
1082     "   .+.      .+.    .+.  .+.     ",          1082     "   .+.      .+.    .+.  .+.     ",
1083     "   .+.      .+.    .+.  .+.     ",          1083     "   .+.      .+.    .+.  .+.     ",
1084     "   .+.      .+.    .+.  .+.     ",          1084     "   .+.      .+.    .+.  .+.     ",
1085     "   .+.      .+.    .+.  .+.     ",          1085     "   .+.      .+.    .+.  .+.     ",
1086     "   .+.      .+......+....+.     ",          1086     "   .+.      .+......+....+.     ",
1087     "   .+.     ..++++++.+.++++.     ",          1087     "   .+.     ..++++++.+.++++.     ",
1088     "   .+.    .++.......+...+..     ",          1088     "   .+.    .++.......+...+..     ",
1089     "   .+.   .++.      .+..++.      ",          1089     "   .+.   .++.      .+..++.      ",
1090     "   .+. ..+..       .+..+.       ",          1090     "   .+. ..+..       .+..+.       ",
1091     "   .+..++.         .+.+.        ",          1091     "   .+..++.         .+.+.        ",
1092     "   .+.++.          .+++.        ",          1092     "   .+.++.          .+++.        ",
1093     "   .+++.............++.         ",          1093     "   .+++.............++.         ",
1094     "   .+++++++++++++++++.          ",          1094     "   .+++++++++++++++++.          ",
1095     "   ...................          ",          1095     "   ...................          ",
1096     "                                ",          1096     "                                ",
1097     "                                ",          1097     "                                ",
1098     "                                "}          1098     "                                "}
1099   ;                                              1099   ;
1100   fPerspectiveIcon = new QPixmap(perspective)    1100   fPerspectiveIcon = new QPixmap(perspective);
1101                                                  1101 
1102   const char * const ortho[]={                   1102   const char * const ortho[]={
1103     "32 32 3 1",                                 1103     "32 32 3 1",
1104     "       c None",                             1104     "       c None",
1105     ".      c #D5D8D5",                          1105     ".      c #D5D8D5",
1106     "@      c #000000",                          1106     "@      c #000000",
1107     "                                ",          1107     "                                ",
1108     "                                ",          1108     "                                ",
1109     "                                ",          1109     "                                ",
1110     "          ...................   ",          1110     "          ...................   ",
1111     "         ..@@@@@@@@@@@@@@@@@.   ",          1111     "         ..@@@@@@@@@@@@@@@@@.   ",
1112     "       ..@@@.............@@@.   ",          1112     "       ..@@@.............@@@.   ",
1113     "      ..@@.@.         ..@..@.   ",          1113     "      ..@@.@.         ..@..@.   ",
1114     "    ..@@ ..@.        .@@...@.   ",          1114     "    ..@@ ..@.        .@@...@.   ",
1115     "   ..@@..............@@.. .@.   ",          1115     "   ..@@..............@@.. .@.   ",
1116     "   .@@@@@@@@@@@@@@@@@..   .@.   ",          1116     "   .@@@@@@@@@@@@@@@@@..   .@.   ",
1117     "   .@...............@.    .@.   ",          1117     "   .@...............@.    .@.   ",
1118     "   .@.    .@.      .@.    .@.   ",          1118     "   .@.    .@.      .@.    .@.   ",
1119     "   .@.    .@.      .@.    .@.   ",          1119     "   .@.    .@.      .@.    .@.   ",
1120     "   .@.    .@.      .@.    .@.   ",          1120     "   .@.    .@.      .@.    .@.   ",
1121     "   .@.    .@.      .@.    .@.   ",          1121     "   .@.    .@.      .@.    .@.   ",
1122     "   .@.    .@.      .@.    .@.   ",          1122     "   .@.    .@.      .@.    .@.   ",
1123     "   .@.    .@.      .@.    .@.   ",          1123     "   .@.    .@.      .@.    .@.   ",
1124     "   .@.    .@.      .@.    .@.   ",          1124     "   .@.    .@.      .@.    .@.   ",
1125     "   .@.    .@.      .@.    .@.   ",          1125     "   .@.    .@.      .@.    .@.   ",
1126     "   .@.    .@.      .@.    .@.   ",          1126     "   .@.    .@.      .@.    .@.   ",
1127     "   .@.    .@.      .@.    .@.   ",          1127     "   .@.    .@.      .@.    .@.   ",
1128     "   .@.    .@........@......@.   ",          1128     "   .@.    .@........@......@.   ",
1129     "   .@.   .@@@@@@@@@.@.@@@@@@.   ",          1129     "   .@.   .@@@@@@@@@.@.@@@@@@.   ",
1130     "   .@.  .@@+........@....@@..   ",          1130     "   .@.  .@@+........@....@@..   ",
1131     "   .@...@.         .@...@...    ",          1131     "   .@...@.         .@...@...    ",
1132     "   .@.@@.          .@.@@ .      ",          1132     "   .@.@@.          .@.@@ .      ",
1133     "   .@@@.............@@@..       ",          1133     "   .@@@.............@@@..       ",
1134     "   .@@@@@@@@@@@@@@@@@...        ",          1134     "   .@@@@@@@@@@@@@@@@@...        ",
1135     "   ...................          ",          1135     "   ...................          ",
1136     "                                ",          1136     "                                ",
1137     "                                ",          1137     "                                ",
1138     "                                "}          1138     "                                "}
1139   ;                                              1139   ;
1140   fOrthoIcon = new QPixmap(ortho);               1140   fOrthoIcon = new QPixmap(ortho);
1141                                                  1141 
1142   const char * const commandIcon[]={             1142   const char * const commandIcon[]={
1143     "20 20 25 1 ",                               1143     "20 20 25 1 ",
1144     "  c #4ED17F",                               1144     "  c #4ED17F",
1145     ". c #4FD280",                               1145     ". c #4FD280",
1146     "X c #50D381",                               1146     "X c #50D381",
1147     "o c #5BD181",                               1147     "o c #5BD181",
1148     "O c #5DD382",                               1148     "O c #5DD382",
1149     "+ c #59D48A",                               1149     "+ c #59D48A",
1150     "@ c #66D68C",                               1150     "@ c #66D68C",
1151     "# c #6FD895",                               1151     "# c #6FD895",
1152     "$ c #85DEA4",                               1152     "$ c #85DEA4",
1153     "% c #8CE0AC",                               1153     "% c #8CE0AC",
1154     "& c #96E4B8",                               1154     "& c #96E4B8",
1155     "* c #9EE3B8",                               1155     "* c #9EE3B8",
1156     "= c #A8E5BB",                               1156     "= c #A8E5BB",
1157     "- c #A7E8C4",                               1157     "- c #A7E8C4",
1158     "; c #B2EAC8",                               1158     "; c #B2EAC8",
1159     ": c #B9ECD1",                               1159     ": c #B9ECD1",
1160     "> c #C2EDD3",                               1160     "> c #C2EDD3",
1161     ", c #CBF1DF",                               1161     ", c #CBF1DF",
1162     "< c #D4F3E3",                               1162     "< c #D4F3E3",
1163     "1 c #DDF4E5",                               1163     "1 c #DDF4E5",
1164     "2 c #DBF5EC",                               1164     "2 c #DBF5EC",
1165     "3 c #E5F7F0",                               1165     "3 c #E5F7F0",
1166     "4 c #EDFAFB",                               1166     "4 c #EDFAFB",
1167     "5 c #F6FBFE",                               1167     "5 c #F6FBFE",
1168     "6 c #FEFFFC",                               1168     "6 c #FEFFFC",
1169     /* pixels */                                 1169     /* pixels */
1170     "66666666666666666666",                      1170     "66666666666666666666",
1171     "66%++++++++++++++&56",                      1171     "66%++++++++++++++&56",
1172     "6$ o..o......o..o *6",                      1172     "6$ o..o......o..o *6",
1173     "6+o...o*<441;@.o..+6",                      1173     "6+o...o*<441;@.o..+6",
1174     "6+..o@1553<354$..o+6",                      1174     "6+..o@1553<354$..o+6",
1175     "6+..o<5<@  .*54#o.+6",                      1175     "6+..o<5<@  .*54#o.+6",
1176     "6+o.*52X     :5-..@6",                      1176     "6+o.*52X     :5-..@6",
1177     "6+..15%      o$+o.+6",                      1177     "6+..15%      o$+o.+6",
1178     "6+.+55@        .o.+6",                      1178     "6+.+55@        .o.+6",
1179     "6O.#54         .X.+6",                      1179     "6O.#54         .X.+6",
1180     "6O #54         .X.+6",                      1180     "6O #54         .X.+6",
1181     "6O.+55@        .o.+6",                      1181     "6O.+55@        .o.+6",
1182     "6+..25%      @,*o.@6",                      1182     "6+..25%      @,*o.@6",
1183     "6+o.*52X     :5>.o+6",                      1183     "6+o.*52X     :5>.o+6",
1184     "6+..O25<@  X=54#o.+6",                      1184     "6+..O25<@  X=54#o.+6",
1185     "6+.o.@1553<354$...@6",                      1185     "6+.o.@1553<354$...@6",
1186     "6+o..oo*<44<;@o..o+6",                      1186     "6+o..oo*<44<;@o..o+6",
1187     "6$ .o..o.....o..o *6",                      1187     "6$ .o..o.....o..o *6",
1188     "66%+++++OOOO+++++*66",                      1188     "66%+++++OOOO+++++*66",
1189     "66666666666666666666"                       1189     "66666666666666666666"
1190   };                                             1190   };
1191   fCommandIcon = new QPixmap(commandIcon);       1191   fCommandIcon = new QPixmap(commandIcon);
1192                                                  1192 
1193   const char * const dirIcon[]={                 1193   const char * const dirIcon[]={
1194     "20 20 25 1 ",                               1194     "20 20 25 1 ",
1195     "  c #DF5959",                               1195     "  c #DF5959",
1196     ". c #DD5F5F",                               1196     ". c #DD5F5F",
1197     "X c #DE7370",                               1197     "X c #DE7370",
1198     "o c #E06360",                               1198     "o c #E06360",
1199     "O c #E06467",                               1199     "O c #E06467",
1200     "+ c #E06C6C",                               1200     "+ c #E06C6C",
1201     "@ c #E57979",                               1201     "@ c #E57979",
1202     "# c #E08886",                               1202     "# c #E08886",
1203     "$ c #E18D91",                               1203     "$ c #E18D91",
1204     "% c #E19D9B",                               1204     "% c #E19D9B",
1205     "& c #E99B9D",                               1205     "& c #E99B9D",
1206     "* c #E8A2A2",                               1206     "* c #E8A2A2",
1207     "= c #EEB2B0",                               1207     "= c #EEB2B0",
1208     "- c #EDBBBC",                               1208     "- c #EDBBBC",
1209     "; c #EDCBC7",                               1209     "; c #EDCBC7",
1210     ": c #E9CDD1",                               1210     ": c #E9CDD1",
1211     "> c #F1D5D6",                               1211     "> c #F1D5D6",
1212     ", c #F9DFE2",                               1212     ", c #F9DFE2",
1213     "< c #EFE8E7",                               1213     "< c #EFE8E7",
1214     "1 c #F3E3E4",                               1214     "1 c #F3E3E4",
1215     "2 c #F8EEEC",                               1215     "2 c #F8EEEC",
1216     "3 c #FCF6F4",                               1216     "3 c #FCF6F4",
1217     "4 c #F6F3F9",                               1217     "4 c #F6F3F9",
1218     "5 c #F2F8FC",                               1218     "5 c #F2F8FC",
1219     "6 c #FEFFFD",                               1219     "6 c #FEFFFD",
1220     /* pixels */                                 1220     /* pixels */
1221     "66666666666666666666",                      1221     "66666666666666666666",
1222     "66$oOOOOOOOOOOOOo%66",                      1222     "66$oOOOOOOOOOOOOo%66",
1223     "6#                %6",                      1223     "6#                %6",
1224     "6o  +,666663:+    o6",                      1224     "6o  +,666663:+    o6",
1225     "6o  =635533666$   o6",                      1225     "6o  =635533666$   o6",
1226     "6o  -65:+  +165X  o6",                      1226     "6o  -65:+  +165X  o6",
1227     "6o  >6<.     36;  O6",                      1227     "6o  >6<.     36;  O6",
1228     "6o  26-      &6>. o6",                      1228     "6o  26-      &6>. o6",
1229     "6. o56*      @63. o6",                      1229     "6. o56*      @63. o6",
1230     "6. X56&      o66. o6",                      1230     "6. X56&      o66. o6",
1231     "6. X56&      +63. o6",                      1231     "6. X56&      +63. o6",
1232     "6. o56*      @62. o6",                      1232     "6. o56*      @62. o6",
1233     "6o  26-      =61  O6",                      1233     "6o  26-      =61  O6",
1234     "6o  >6<.    o36:  o6",                      1234     "6o  >6<.    o36:  o6",
1235     "6o  -65:+  @265X  o6",                      1235     "6o  -65:+  @265X  o6",
1236     "6o  =635543665#   O6",                      1236     "6o  =635543665#   O6",
1237     "6o  +1666662;+    o6",                      1237     "6o  +1666662;+    o6",
1238     "6#                %6",                      1238     "6#                %6",
1239     "66$OOOoo....OOOOo%66",                      1239     "66$OOOoo....OOOOo%66",
1240     "66666666666666666666"}                      1240     "66666666666666666666"}
1241   ;                                              1241   ;
1242   fDirIcon = new QPixmap(dirIcon);               1242   fDirIcon = new QPixmap(dirIcon);
1243                                                  1243 
1244                                                  1244 
1245   const char * const runIcon[]={                 1245   const char * const runIcon[]={
1246     /* columns rows colors chars-per-pixel */    1246     /* columns rows colors chars-per-pixel */
1247     "20 20 33 1 ",                               1247     "20 20 33 1 ",
1248     "  c #5CA323",                               1248     "  c #5CA323",
1249     ". c #5EA03F",                               1249     ". c #5EA03F",
1250     "X c #6DB620",                               1250     "X c #6DB620",
1251     "o c #66AD3F",                               1251     "o c #66AD3F",
1252     "O c #70B73C",                               1252     "O c #70B73C",
1253     "+ c #7CC13F",                               1253     "+ c #7CC13F",
1254     "@ c #569B41",                               1254     "@ c #569B41",
1255     "# c #61A14E",                               1255     "# c #61A14E",
1256     "$ c #70A95D",                               1256     "$ c #70A95D",
1257     "% c #7EB55C",                               1257     "% c #7EB55C",
1258     "& c #85B94E",                               1258     "& c #85B94E",
1259     "* c #90BE49",                               1259     "* c #90BE49",
1260     "= c #81B669",                               1260     "= c #81B669",
1261     "- c #81B370",                               1261     "- c #81B370",
1262     "; c #95CA46",                               1262     "; c #95CA46",
1263     ": c #A1CD40",                               1263     ": c #A1CD40",
1264     "> c #AED045",                               1264     "> c #AED045",
1265     ", c #B3D558",                               1265     ", c #B3D558",
1266     "< c #9BC87E",                               1266     "< c #9BC87E",
1267     "1 c #AED668",                               1267     "1 c #AED668",
1268     "2 c #A2D075",                               1268     "2 c #A2D075",
1269     "3 c #C2DC73",                               1269     "3 c #C2DC73",
1270     "4 c #A5C98F",                               1270     "4 c #A5C98F",
1271     "5 c #C1DC9F",                               1271     "5 c #C1DC9F",
1272     "6 c #CAE18E",                               1272     "6 c #CAE18E",
1273     "7 c #CCE39A",                               1273     "7 c #CCE39A",
1274     "8 c #C4DCB6",                               1274     "8 c #C4DCB6",
1275     "9 c #E3ECBA",                               1275     "9 c #E3ECBA",
1276     "0 c #EEF3D3",                               1276     "0 c #EEF3D3",
1277     "q c #F0F7DE",                               1277     "q c #F0F7DE",
1278     "w c #F8FAE9",                               1278     "w c #F8FAE9",
1279     "e c #FCFFFB",                               1279     "e c #FCFFFB",
1280     "r c None",                                  1280     "r c None",
1281     /* pixels */                                 1281     /* pixels */
1282     "rrrrrrrr%<<2rrrrrrrr",                      1282     "rrrrrrrr%<<2rrrrrrrr",
1283     "rrrrr5=$$$$===rrrrrr",                      1283     "rrrrr5=$$$$===rrrrrr",
1284     "rrrr<##$$$$$---&rrrr",                      1284     "rrrr<##$$$$$---&rrrr",
1285     "rrr=###$$$$-----%rrr",                      1285     "rrr=###$$$$-----%rrr",
1286     "rr=####$$$$------&rr",                      1286     "rr=####$$$$------&rr",
1287     "r2@####7##$-------rr",                      1287     "r2@####7##$-------rr",
1288     "r.@####048$-------Or",                      1288     "r.@####048$-------Or",
1289     "r.@####q4ee=----$@.r",                      1289     "r.@####q4ee=----$@.r",
1290     " .@@###w4eee5%$#@@@X",                      1290     " .@@###w4eee5%$#@@@X",
1291     " .@@@..w4eeeeqo..@@X",                      1291     " .@@@..w4eeeeqo..@@X",
1292     " .@..ooe<eeee7Oooo@X",                      1292     " .@..ooe<eeee7Oooo@X",
1293     " ..oooOe2eee6OOOooo ",                      1293     " ..oooOe2eee6OOOooo ",
1294     "rOooOO+e2ew2+++++O+r",                      1294     "rOooOO+e2ew2+++++O+r",
1295     "r:oO+++e30,;;;;;++Or",                      1295     "r:oO+++e30,;;;;;++Or",
1296     "r :++;:9,>,,>>:;;1rr",                      1296     "r :++;:9,>,,>>:;;1rr",
1297     "rr*1;:>,333333,>32rr",                      1297     "rr*1;:>,333333,>32rr",
1298     "rrr66,1367777637<rrr",                      1298     "rrr66,1367777637<rrr",
1299     "rrrr509799999905rrrr",                      1299     "rrrr509799999905rrrr",
1300     "rrrrr=8wqwwww8-rrrrr",                      1300     "rrrrr=8wqwwww8-rrrrr",
1301     "rrrrrrrr4444rrrrrrrr"                       1301     "rrrrrrrr4444rrrrrrrr"
1302   };                                             1302   };
1303   fRunIcon = new QPixmap(runIcon);               1303   fRunIcon = new QPixmap(runIcon);
1304                                                  1304 
1305   const char * const paramIcon[]={               1305   const char * const paramIcon[]={
1306     /* columns rows colors chars-per-pixel */    1306     /* columns rows colors chars-per-pixel */
1307     "20 20 35 1 ",                               1307     "20 20 35 1 ",
1308     "  c #2E2525",                               1308     "  c #2E2525",
1309     ". c #403737",                               1309     ". c #403737",
1310     "X c #423A3A",                               1310     "X c #423A3A",
1311     "o c #443C3C",                               1311     "o c #443C3C",
1312     "O c #473F3F",                               1312     "O c #473F3F",
1313     "+ c #4C4444",                               1313     "+ c #4C4444",
1314     "@ c #4F4848",                               1314     "@ c #4F4848",
1315     "# c #514949",                               1315     "# c #514949",
1316     "$ c #544D4D",                               1316     "$ c #544D4D",
1317     "% c #595252",                               1317     "% c #595252",
1318     "& c #625B5B",                               1318     "& c #625B5B",
1319     "* c #696262",                               1319     "* c #696262",
1320     "= c #6D6666",                               1320     "= c #6D6666",
1321     "- c #716B6B",                               1321     "- c #716B6B",
1322     "; c #726C6C",                               1322     "; c #726C6C",
1323     ": c #767171",                               1323     ": c #767171",
1324     "> c #7E7878",                               1324     "> c #7E7878",
1325     ", c #8B8787",                               1325     ", c #8B8787",
1326     "< c #8C8787",                               1326     "< c #8C8787",
1327     "1 c #8D8888",                               1327     "1 c #8D8888",
1328     "2 c #918D8D",                               1328     "2 c #918D8D",
1329     "3 c #928E8E",                               1329     "3 c #928E8E",
1330     "4 c #948F8F",                               1330     "4 c #948F8F",
1331     "5 c #9C9898",                               1331     "5 c #9C9898",
1332     "6 c #9D9999",                               1332     "6 c #9D9999",
1333     "7 c #D5D4D4",                               1333     "7 c #D5D4D4",
1334     "8 c #D8D6D6",                               1334     "8 c #D8D6D6",
1335     "9 c #DDDBDB",                               1335     "9 c #DDDBDB",
1336     "0 c #EFEFEF",                               1336     "0 c #EFEFEF",
1337     "q c #F6F6F6",                               1337     "q c #F6F6F6",
1338     "w c None",                                  1338     "w c None",
1339     "e c None",                                  1339     "e c None",
1340     "r c None",                                  1340     "r c None",
1341     "t c gray99",                                1341     "t c gray99",
1342     "y c None",                                  1342     "y c None",
1343     /* pixels */                                 1343     /* pixels */
1344     "wwwwwwww5  5wwwwwwww",                      1344     "wwwwwwww5  5wwwwwwww",
1345     "wwwwwwww,  ,wwwwwwww",                      1345     "wwwwwwww,  ,wwwwwwww",
1346     "www&;ww7+  +9ww=-www",                      1346     "www&;ww7+  +9ww=-www",
1347     "ww&  O#      OX  *ww",                      1347     "ww&  O#      OX  *ww",
1348     "ww;              >ww",                      1348     "ww;              >ww",
1349     "wwwO    .%%X    +www",                      1349     "wwwO    .%%X    +www",
1350     "www#   3wwww3   Owww",                      1350     "www#   3wwww3   Owww",
1351     "ww7   3wwwwww3   7ww",                      1351     "ww7   3wwwwww3   7ww",
1352     "5<+  .wwwwwww0.  +<5",                      1352     "5<+  .wwwwwww0.  +<5",
1353     "     %wwwwwwww$     ",                      1353     "     %wwwwwwww$     ",
1354     "     %wwwwwwww$     ",                      1354     "     %wwwwwwww$     ",
1355     "5<+  .wwwwwww0X  +<5",                      1355     "5<+  .wwwwwww0X  +<5",
1356     "ww9   4wwwwww1   9ww",                      1356     "ww9   4wwwwww1   9ww",
1357     "wwwO   30ww03   Owww",                      1357     "wwwO   30ww03   Owww",
1358     "wwwX    X#$X    @www",                      1358     "wwwX    X#$X    @www",
1359     "ww=              =ww",                      1359     "ww=              =ww",
1360     "ww-  +O      ++  :ww",                      1360     "ww-  +O      ++  :ww",
1361     "www*>ww7+  +7ww=:www",                      1361     "www*>ww7+  +7ww=:www",
1362     "wwwwwwww1  1wwwwwwww",                      1362     "wwwwwwww1  1wwwwwwww",
1363     "wwwwwwww5  5wwwwwwww"                       1363     "wwwwwwww5  5wwwwwwww"
1364   };                                             1364   };
1365   fParamIcon = new QPixmap(paramIcon);           1365   fParamIcon = new QPixmap(paramIcon);
1366                                                  1366 
1367   const char * const exitIcon[]={                1367   const char * const exitIcon[]={
1368     /* columns rows colors chars-per-pixel */    1368     /* columns rows colors chars-per-pixel */
1369     "23 28 55 1 ",                               1369     "23 28 55 1 ",
1370     "  c None",                                  1370     "  c None",
1371     ". c #350505",                               1371     ". c #350505",
1372     "X c #3A0505",                               1372     "X c #3A0505",
1373     "o c #3C0605",                               1373     "o c #3C0605",
1374     "O c #3D0605",                               1374     "O c #3D0605",
1375     "+ c #430606",                               1375     "+ c #430606",
1376     "@ c #440606",                               1376     "@ c #440606",
1377     "# c #470706",                               1377     "# c #470706",
1378     "$ c #500707",                               1378     "$ c #500707",
1379     "% c #510807",                               1379     "% c #510807",
1380     "& c #520807",                               1380     "& c #520807",
1381     "* c #530807",                               1381     "* c #530807",
1382     "= c #550808",                               1382     "= c #550808",
1383     "- c #570808",                               1383     "- c #570808",
1384     "; c #5C0908",                               1384     "; c #5C0908",
1385     ": c #5D0908",                               1385     ": c #5D0908",
1386     "> c #5F0908",                               1386     "> c #5F0908",
1387     ", c #630A08",                               1387     ", c #630A08",
1388     "< c #640A09",                               1388     "< c #640A09",
1389     "1 c #6B0A09",                               1389     "1 c #6B0A09",
1390     "2 c #6C0A09",                               1390     "2 c #6C0A09",
1391     "3 c #720B0A",                               1391     "3 c #720B0A",
1392     "4 c #760B0A",                               1392     "4 c #760B0A",
1393     "5 c #770B0A",                               1393     "5 c #770B0A",
1394     "6 c #7A0B0B",                               1394     "6 c #7A0B0B",
1395     "7 c #7D0C0B",                               1395     "7 c #7D0C0B",
1396     "8 c #7F0C0B",                               1396     "8 c #7F0C0B",
1397     "9 c #840D0B",                               1397     "9 c #840D0B",
1398     "0 c #850D0C",                               1398     "0 c #850D0C",
1399     "q c #880D0C",                               1399     "q c #880D0C",
1400     "w c #8D0E0C",                               1400     "w c #8D0E0C",
1401     "e c #900E0C",                               1401     "e c #900E0C",
1402     "r c #940E0D",                               1402     "r c #940E0D",
1403     "t c #950E0D",                               1403     "t c #950E0D",
1404     "y c #9C0F0E",                               1404     "y c #9C0F0E",
1405     "u c #9E100E",                               1405     "u c #9E100E",
1406     "i c #AA100E",                               1406     "i c #AA100E",
1407     "p c #AC100F",                               1407     "p c #AC100F",
1408     "a c #AD100F",                               1408     "a c #AD100F",
1409     "s c #AE110F",                               1409     "s c #AE110F",
1410     "d c #B31110",                               1410     "d c #B31110",
1411     "f c #B51210",                               1411     "f c #B51210",
1412     "g c #B61210",                               1412     "g c #B61210",
1413     "h c #B71210",                               1413     "h c #B71210",
1414     "j c #B91210",                               1414     "j c #B91210",
1415     "k c #C01311",                               1415     "k c #C01311",
1416     "l c #C21311",                               1416     "l c #C21311",
1417     "z c #C81311",                               1417     "z c #C81311",
1418     "x c #C91312",                               1418     "x c #C91312",
1419     "c c #CC1412",                               1419     "c c #CC1412",
1420     "v c #CE1412",                               1420     "v c #CE1412",
1421     "b c #D01412",                               1421     "b c #D01412",
1422     "n c #D11412",                               1422     "n c #D11412",
1423     "m c #D31412",                               1423     "m c #D31412",
1424     "M c #D51513",                               1424     "M c #D51513",
1425     /* pixels */                                 1425     /* pixels */
1426     "                       ",                   1426     "                       ",
1427     "          O=           ",                   1427     "          O=           ",
1428     "         :MMh          ",                   1428     "         :MMh          ",
1429     "         hMMM          ",                   1429     "         hMMM          ",
1430     "         jMMM          ",                   1430     "         jMMM          ",
1431     "    <x1  jMMM  %xw     ",                   1431     "    <x1  jMMM  %xw     ",
1432     "   rMMM  jMMM  MMMk    ",                   1432     "   rMMM  jMMM  MMMk    ",
1433     "  rMMMM# jMMM  MMMMx   ",                   1433     "  rMMMM# jMMM  MMMMx   ",
1434     " OMMMMk  jMMM  8MMMM9  ",                   1434     " OMMMMk  jMMM  8MMMM9  ",
1435     " xMMMM   jMMM   pMMMM  ",                   1435     " xMMMM   jMMM   pMMMM  ",
1436     " MMMM    jMMM    xMMM8 ",                   1436     " MMMM    jMMM    xMMM8 ",
1437     "rMMM3    jMMM     MMMM ",                   1437     "rMMM3    jMMM     MMMM ",
1438     "MMMM     hMMM     MMMM ",                   1438     "MMMM     hMMM     MMMM ",
1439     "MMMM     :MMh     hMMM ",                   1439     "MMMM     :MMh     hMMM ",
1440     "MMMM      O%      8MMM ",                   1440     "MMMM      O%      8MMM ",
1441     "MMMM              pMMM ",                   1441     "MMMM              pMMM ",
1442     "MMMM              MMMM ",                   1442     "MMMM              MMMM ",
1443     "wMMM3             MMMM ",                   1443     "wMMM3             MMMM ",
1444     ".MMMM            xMMM9 ",                   1444     ".MMMM            xMMM9 ",
1445     " hMMMk          wMMMM  ",                   1445     " hMMMk          wMMMM  ",
1446     "  MMMMMO       hMMMM=  ",                   1446     "  MMMMMO       hMMMM=  ",
1447     "  <MMMMMp:  $rMMMMMp   ",                   1447     "  <MMMMMp:  $rMMMMMp   ",
1448     "   yMMMMMMMMMMMMMMk    ",                   1448     "   yMMMMMMMMMMMMMMk    ",
1449     "    #MMMMMMMMMMMM3     ",                   1449     "    #MMMMMMMMMMMM3     ",
1450     "      uMMMMMMMMk       ",                   1450     "      uMMMMMMMMk       ",
1451     "        #1wr3%         ",                   1451     "        #1wr3%         ",
1452     "                       ",                   1452     "                       ",
1453     "                       "                    1453     "                       "
1454   };                                             1454   };
1455   fExitIcon= new QPixmap(exitIcon);              1455   fExitIcon= new QPixmap(exitIcon);
1456 }                                                1456 }
1457 // clang-format on                               1457 // clang-format on
1458                                                  1458 
1459 namespace {                                      1459 namespace {
1460   G4SceneTreeItem* ConvertToG4SceneTreeItem(Q    1460   G4SceneTreeItem* ConvertToG4SceneTreeItem(QTreeWidgetItem* item)
1461   {                                              1461   {
1462     auto qVariant = item->data(0, Qt::UserRol    1462     auto qVariant = item->data(0, Qt::UserRole);
1463     std::istringstream iss(qVariant.toString(    1463     std::istringstream iss(qVariant.toString().toStdString());
1464     void* itemAddress; iss >> itemAddress;       1464     void* itemAddress; iss >> itemAddress;
1465     return static_cast<G4SceneTreeItem*>(item    1465     return static_cast<G4SceneTreeItem*>(itemAddress);
1466   }                                              1466   }
1467                                                  1467 
1468   QColor ConvertG4ColourToQColor(const G4Colo    1468   QColor ConvertG4ColourToQColor(const G4Colour& g4Colour)
1469   {                                              1469   {
1470     return QColor((int)(g4Colour.GetRed()*255    1470     return QColor((int)(g4Colour.GetRed()*255),
1471                   (int)(g4Colour.GetGreen()*2    1471                   (int)(g4Colour.GetGreen()*255),
1472                   (int)(g4Colour.GetBlue()*25    1472                   (int)(g4Colour.GetBlue()*255),
1473                   (int)(g4Colour.GetAlpha()*2    1473                   (int)(g4Colour.GetAlpha()*255));
1474   }                                              1474   }
1475                                                  1475 
1476   G4Colour ConvertQColorToG4Colour(const QCol    1476   G4Colour ConvertQColorToG4Colour(const QColor& qColor)
1477   {                                              1477   {
1478     return G4Color(qColor.red()/255.,            1478     return G4Color(qColor.red()/255.,
1479                    qColor.green()/255.,          1479                    qColor.green()/255.,
1480                    qColor.blue()/255.,           1480                    qColor.blue()/255.,
1481                    qColor.alpha()/255.);         1481                    qColor.alpha()/255.);
1482   }                                              1482   }
1483 }                                                1483 }
1484                                                  1484 
1485 void G4UIQt::CreateNewSceneTreeWidget()          1485 void G4UIQt::CreateNewSceneTreeWidget()
1486 {                                                1486 {
1487   auto vLayout = fNewSceneTreeWidget->layout(    1487   auto vLayout = fNewSceneTreeWidget->layout();
1488   // reduce margins                              1488   // reduce margins
1489   vLayout->setContentsMargins(0,0,0,0);          1489   vLayout->setContentsMargins(0,0,0,0);
1490                                                  1490 
1491   fNewSceneTreeItemTreeWidget = new NewSceneT    1491   fNewSceneTreeItemTreeWidget = new NewSceneTreeItemTreeWidget;
1492   fNewSceneTreeItemTreeWidget->setSelectionMo    1492   fNewSceneTreeItemTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
1493   vLayout->addWidget(fNewSceneTreeItemTreeWid    1493   vLayout->addWidget(fNewSceneTreeItemTreeWidget);
1494                                                  1494 
1495   // A click on the item is handled here.        1495   // A click on the item is handled here.
1496   // A click on the check box makes the volum    1496   // A click on the check box makes the volume visible/invisible
1497   connect(fNewSceneTreeItemTreeWidget, &QTree    1497   connect(fNewSceneTreeItemTreeWidget, &QTreeWidget::itemClicked,
1498           [&](QTreeWidgetItem* item){SceneTre    1498           [&](QTreeWidgetItem* item){SceneTreeItemClicked(item);});
1499   // A double click on either the colour icon    1499   // A double click on either the colour icon or the name pops up a colour dialogue
1500   connect(fNewSceneTreeItemTreeWidget, &QTree    1500   connect(fNewSceneTreeItemTreeWidget, &QTreeWidget::itemDoubleClicked,
1501           [&](QTreeWidgetItem* item){SceneTre    1501           [&](QTreeWidgetItem* item){SceneTreeItemDoubleClicked(item);});
1502                                                  1502 
1503   // A click on the expansion triangle is han    1503   // A click on the expansion triangle is handled here.
1504   connect(fNewSceneTreeItemTreeWidget, &QTree    1504   connect(fNewSceneTreeItemTreeWidget, &QTreeWidget::itemExpanded,
1505           [&](QTreeWidgetItem* item){SceneTre    1505           [&](QTreeWidgetItem* item){SceneTreeItemExpanded(item);});
1506   connect(fNewSceneTreeItemTreeWidget, &QTree    1506   connect(fNewSceneTreeItemTreeWidget, &QTreeWidget::itemCollapsed,
1507           [&](QTreeWidgetItem* item){SceneTre    1507           [&](QTreeWidgetItem* item){SceneTreeItemCollapsed(item);});
1508 }                                                1508 }
1509                                                  1509   
1510 void G4UIQt::UpdateSceneTree(const G4SceneTre    1510 void G4UIQt::UpdateSceneTree(const G4SceneTreeItem& root)
1511 {                                                1511 {
1512   //  G4debug << "\nG4UIQt::UpdateSceneTree:     1512   //  G4debug << "\nG4UIQt::UpdateSceneTree: scene tree summary\n";
1513   //  root.DumpTree(G4debug);  // Verbosity =    1513   //  root.DumpTree(G4debug);  // Verbosity = 0 (one line per item)
1514   //  G4debug << "\nG4UIQt::UpdateSceneTree:     1514   //  G4debug << "\nG4UIQt::UpdateSceneTree: scene tree dump\n";
1515   //  root.DumpTree(G4debug,1);  // Verbosity    1515   //  root.DumpTree(G4debug,1);  // Verbosity = 1 (higher levels available)
1516                                                  1516 
1517   // Clear the existing GUI-side tree            1517   // Clear the existing GUI-side tree
1518   fNewSceneTreeItemTreeWidget->clear();          1518   fNewSceneTreeItemTreeWidget->clear();
1519   // (I think this deletes everything - the t    1519   // (I think this deletes everything - the top level items and their children.)
1520                                                  1520 
1521   // Build a new GUI-side tree                   1521   // Build a new GUI-side tree
1522   fNewSceneTreeItemTreeWidget->setHeaderLabel    1522   fNewSceneTreeItemTreeWidget->setHeaderLabel (root.GetDescription().c_str());
1523   for (const auto& model : root.GetChildren()    1523   for (const auto& model : root.GetChildren()) {
1524                                                  1524 
1525     auto item = new QTreeWidgetItem(fNewScene    1525     auto item = new QTreeWidgetItem(fNewSceneTreeItemTreeWidget);
1526                                                  1526 
1527     // Add this GUI-side representation of th    1527     // Add this GUI-side representation of the model as a child of the top widget
1528     fNewSceneTreeItemTreeWidget->insertTopLev    1528     fNewSceneTreeItemTreeWidget->insertTopLevelItem(0,item);
1529                                                  1529 
1530     // Add text that appears in the scene tre    1530     // Add text that appears in the scene tree
1531     item->setText(0, model.GetModelType().c_s    1531     item->setText(0, model.GetModelType().c_str());
1532                                                  1532 
1533     // Load with info from model                 1533     // Load with info from model
1534     // There may be a way to add data as a QV    1534     // There may be a way to add data as a QVariant, or a list of QVariants,
1535     // but let's try adding a G4SceneTreeItem    1535     // but let's try adding a G4SceneTreeItem pointer as a hex string. (There
1536     // does not seem to be a way of adding a     1536     // does not seem to be a way of adding a pointer directly.)
1537     std::ostringstream oss; oss << std::hex <    1537     std::ostringstream oss; oss << std::hex << &model;
1538     auto data = QVariant(oss.str().c_str());     1538     auto data = QVariant(oss.str().c_str());
1539     item->setData(0, Qt::UserRole, data);        1539     item->setData(0, Qt::UserRole, data);
1540                                                  1540 
1541     // Load a tooltip                            1541     // Load a tooltip
1542     G4String toolTipMessage = model.GetModelD << 1542     item->setToolTip(0, model.GetModelDescription().c_str());
1543     if (!model.GetFurtherInfo().empty()) {    << 
1544       toolTipMessage += "\n  " + model.GetFur << 
1545     }                                         << 
1546     item->setToolTip(0, toolTipMessage.c_str( << 
1547                                                  1543 
1548     // Set the check state                       1544     // Set the check state
1549     item->setCheckState                          1545     item->setCheckState
1550     (0, model.GetVisAttributes().IsVisible()?    1546     (0, model.GetVisAttributes().IsVisible()? Qt::Checked: Qt::Unchecked);
1551                                                  1547 
1552     // Set the expand state                      1548     // Set the expand state
1553     item->setExpanded(model.IsExpanded());       1549     item->setExpanded(model.IsExpanded());
1554                                                  1550 
1555     if (model.GetType() == G4SceneTreeItem::p    1551     if (model.GetType() == G4SceneTreeItem::pvmodel) {
1556       BuildPVQTree(model,item);                  1552       BuildPVQTree(model,item);
1557     }                                            1553     }
1558   }                                              1554   }
1559 }                                                1555 }
1560                                                  1556 
1561 // Build Physical Volume tree of touchables      1557 // Build Physical Volume tree of touchables
1562 void G4UIQt::BuildPVQTree(const G4SceneTreeIt    1558 void G4UIQt::BuildPVQTree(const G4SceneTreeItem& g4stItem, QTreeWidgetItem* qtwItem)
1563 {                                                1559 {
1564   const auto& g4stChildren = g4stItem.GetChil    1560   const auto& g4stChildren = g4stItem.GetChildren();
1565   for (const auto& g4stChild: g4stChildren) {    1561   for (const auto& g4stChild: g4stChildren) {
1566     QStringList qStringList;                     1562     QStringList qStringList;
1567     qStringList.append(g4stChild.GetDescripti    1563     qStringList.append(g4stChild.GetDescription().c_str());
1568     auto newQTWItem = new QTreeWidgetItem(qSt    1564     auto newQTWItem = new QTreeWidgetItem(qStringList);
1569                                                  1565 
1570     // Add a GUI-side representation of the t    1566     // Add a GUI-side representation of the touchable as a child
1571     qtwItem->addChild(newQTWItem);               1567     qtwItem->addChild(newQTWItem);
1572                                                  1568     
1573     // Load with info from g4stChild             1569     // Load with info from g4stChild
1574     // There may be a way to add data as a QV    1570     // There may be a way to add data as a QVariant, or a list of QVariants,
1575     // but let's try adding a G4SceneTreeItem    1571     // but let's try adding a G4SceneTreeItem pointer as a hex string. (There
1576     // does not seem to be a way of adding a     1572     // does not seem to be a way of adding a pointer directly.)
1577     std::ostringstream oss; oss << std::hex <    1573     std::ostringstream oss; oss << std::hex << &g4stChild;
1578     auto data = QVariant(oss.str().c_str());     1574     auto data = QVariant(oss.str().c_str());
1579     newQTWItem->setData(0, Qt::UserRole, data    1575     newQTWItem->setData(0, Qt::UserRole, data);
1580                                                  1576 
1581     // Load a tooltip                            1577     // Load a tooltip
1582     if (g4stChild.GetType() == G4SceneTreeIte    1578     if (g4stChild.GetType() == G4SceneTreeItem::ghost) {
1583       auto& nameCopyNo = g4stChild.GetDescrip    1579       auto& nameCopyNo = g4stChild.GetDescription();
1584       auto name = nameCopyNo.substr(0,nameCop    1580       auto name = nameCopyNo.substr(0,nameCopyNo.find(':'));
1585       oss.str(""); oss << nameCopyNo <<          1581       oss.str(""); oss << nameCopyNo <<
1586       ": Click to make visible and get more i    1582       ": Click to make visible and get more information."
1587       "\n  This may not work if the volume is    1583       "\n  This may not work if the volume is in the \"base path\". (Hover on"
1588       "\n  the model to see base path.) If th    1584       "\n  the model to see base path.) If this is the case,"
1589       "\n  \"/vis/scene/add/volume " << name     1585       "\n  \"/vis/scene/add/volume " << name << "\" to bring into the displayed tree.)";
1590       newQTWItem->setToolTip(0, oss.str().c_s    1586       newQTWItem->setToolTip(0, oss.str().c_str());
1591     } else {  // A fully defined touchable       1587     } else {  // A fully defined touchable
1592       oss.str(""); oss << g4stChild.GetPVPath    1588       oss.str(""); oss << g4stChild.GetPVPath() <<
1593       "\nTo see properties, right-click/dump.    1589       "\nTo see properties, right-click/dump.";
1594       newQTWItem->setToolTip(0, oss.str().c_s    1590       newQTWItem->setToolTip(0, oss.str().c_str());
1595     }                                            1591     }
1596                                                  1592 
1597     // Set the check state                       1593     // Set the check state
1598     newQTWItem->setCheckState                    1594     newQTWItem->setCheckState
1599     (0, g4stChild.GetVisAttributes().IsVisibl    1595     (0, g4stChild.GetVisAttributes().IsVisible()? Qt::Checked: Qt::Unchecked);
1600                                                  1596     
1601     // Set the expand state                      1597     // Set the expand state
1602     newQTWItem->setExpanded(g4stChild.IsExpan    1598     newQTWItem->setExpanded(g4stChild.IsExpanded());
1603                                                  1599 
1604     // Set colour icon                           1600     // Set colour icon
1605     QPixmap pixmap = QPixmap(QSize(16, 16));     1601     QPixmap pixmap = QPixmap(QSize(16, 16));
1606     pixmap.fill(ConvertG4ColourToQColor(g4stC    1602     pixmap.fill(ConvertG4ColourToQColor(g4stChild.GetVisAttributes().GetColour()));
1607     QPainter painter(&pixmap);                   1603     QPainter painter(&pixmap);
1608     painter.setPen(Qt::black);                   1604     painter.setPen(Qt::black);
1609     painter.drawRect(0,0,15,15); // Draw cont    1605     painter.drawRect(0,0,15,15); // Draw contour
1610     newQTWItem->setIcon(0,pixmap);               1606     newQTWItem->setIcon(0,pixmap);
1611                                                  1607 
1612     // Continue recursively                      1608     // Continue recursively
1613     BuildPVQTree(g4stChild,newQTWItem);          1609     BuildPVQTree(g4stChild,newQTWItem);
1614   }                                              1610   }
1615 }                                                1611 }
1616                                                  1612 
1617 void G4UIQt::SceneTreeItemClicked(QTreeWidget    1613 void G4UIQt::SceneTreeItemClicked(QTreeWidgetItem* item)
1618 {                                                1614 {
1619   if (item == nullptr) return;                   1615   if (item == nullptr) return;
1620   auto sceneTreeItem = ConvertToG4SceneTreeIt    1616   auto sceneTreeItem = ConvertToG4SceneTreeItem(item);
1621   if (sceneTreeItem == nullptr) return;          1617   if (sceneTreeItem == nullptr) return;
1622                                                  1618 
1623   auto uiMan = G4UImanager::GetUIpointer();      1619   auto uiMan = G4UImanager::GetUIpointer();
1624                                                  1620 
1625   // Respond according to type                   1621   // Respond according to type
1626   G4String argument = "false", inverse = "tru    1622   G4String argument = "false", inverse = "true";
1627   auto newCheckState = item->checkState(0);      1623   auto newCheckState = item->checkState(0);
1628   auto oldCheckState                             1624   auto oldCheckState
1629   = sceneTreeItem->GetVisAttributes().IsVisib    1625   = sceneTreeItem->GetVisAttributes().IsVisible()? Qt::Checked: Qt::Unchecked;
1630   switch (sceneTreeItem->GetType()) {            1626   switch (sceneTreeItem->GetType()) {
1631     case G4SceneTreeItem::unidentified:          1627     case G4SceneTreeItem::unidentified:
1632       break;  // Do nothing                      1628       break;  // Do nothing
1633     case G4SceneTreeItem::root:                  1629     case G4SceneTreeItem::root:
1634       break;  // Do nothing                      1630       break;  // Do nothing
1635     case G4SceneTreeItem::model:                 1631     case G4SceneTreeItem::model:
1636       [[fallthrough]];                        << 1632       // Clicked - but has checkbox actually been clicked?
                                                   >> 1633       if (newCheckState != oldCheckState) {
                                                   >> 1634         if (newCheckState == Qt::Checked) argument = "true";
                                                   >> 1635         G4String modelName, text;
                                                   >> 1636         std::istringstream iss(sceneTreeItem->GetModelDescription());
                                                   >> 1637         iss >> modelName >> text;
                                                   >> 1638         if (modelName.find("Text") != std::string::npos) {
                                                   >> 1639           // Text model: special case, use text to identify
                                                   >> 1640           uiMan->ApplyCommand("/vis/scene/activateModel " + text + ' ' + argument);
                                                   >> 1641         } else {
                                                   >> 1642           uiMan->ApplyCommand("/vis/scene/activateModel " + modelName + ' ' + argument);
                                                   >> 1643         }
                                                   >> 1644       }
                                                   >> 1645       break;
1637     case G4SceneTreeItem::pvmodel:               1646     case G4SceneTreeItem::pvmodel:
1638       // Clicked - but has checkbox actually     1647       // Clicked - but has checkbox actually been clicked?
1639       if (newCheckState != oldCheckState) {      1648       if (newCheckState != oldCheckState) {
1640         if (newCheckState == Qt::Checked) arg    1649         if (newCheckState == Qt::Checked) argument = "true";
1641         uiMan->ApplyCommand                   << 1650         G4String modelName, pvName;
1642         ("/vis/scene/activateModel \"" + scen << 1651         std::istringstream iss(sceneTreeItem->GetModelDescription());
                                                   >> 1652         iss >> modelName >> pvName;
                                                   >> 1653         uiMan->ApplyCommand("/vis/scene/activateModel " + pvName + ' ' + argument);
1643       }                                          1654       }
1644       break;                                     1655       break;
1645     case G4SceneTreeItem::ghost:                 1656     case G4SceneTreeItem::ghost:
1646       [[fallthrough]];                           1657       [[fallthrough]];
1647     case G4SceneTreeItem::touchable:             1658     case G4SceneTreeItem::touchable:
1648       // Construct and apply touchable comman    1659       // Construct and apply touchable commands
1649       // Clicked - but has checkbox actually     1660       // Clicked - but has checkbox actually been clicked?
1650       if (newCheckState != oldCheckState) {      1661       if (newCheckState != oldCheckState) {
1651         if (newCheckState == Qt::Checked) {      1662         if (newCheckState == Qt::Checked) {
1652           argument = "true"; inverse = "false    1663           argument = "true"; inverse = "false";
1653         }                                        1664         }
1654         uiMan->ApplyCommand("/vis/set/touchab    1665         uiMan->ApplyCommand("/vis/set/touchable" + sceneTreeItem->GetPVPath());
1655         uiMan->ApplyCommand("/vis/touchable/s    1666         uiMan->ApplyCommand("/vis/touchable/set/visibility " + argument);
1656         // If daughters, set daughtersInvisib    1667         // If daughters, set daughtersInvisible too
1657         if (sceneTreeItem->GetChildren().size    1668         if (sceneTreeItem->GetChildren().size() > 0 ) {
1658           uiMan->ApplyCommand("/vis/touchable    1669           uiMan->ApplyCommand("/vis/touchable/set/daughtersInvisible " + inverse);
1659         }                                        1670         }
1660         // If not cancelled and if daughters     1671         // If not cancelled and if daughters > 0 and if making invisible
1661         static G4bool wanted = true;             1672         static G4bool wanted = true;
1662         if (wanted && sceneTreeItem->GetChild    1673         if (wanted && sceneTreeItem->GetChildren().size() > 0 && argument == "false") {
1663           QMessageBox msgBox;                    1674           QMessageBox msgBox;
1664           msgBox.setText                         1675           msgBox.setText
1665           ("This action makes this volume and    1676           ("This action makes this volume and all descendants invisible."
1666            " To see descendants, right-click     1677            " To see descendants, right-click and select daughtersInvisible/false"
1667            " and check visibility of descenda    1678            " and check visibility of descendants individually.");
1668           msgBox.setInformativeText              1679           msgBox.setInformativeText
1669           ("To suppress this message click \"    1680           ("To suppress this message click \"Discard\" or \"Don't Save\"");
1670           msgBox.setStandardButtons(QMessageB    1681           msgBox.setStandardButtons(QMessageBox::Discard | QMessageBox::Ok);
1671           msgBox.setDefaultButton(QMessageBox    1682           msgBox.setDefaultButton(QMessageBox::Ok);
1672           auto action = msgBox.exec();           1683           auto action = msgBox.exec();
1673           if (action == QMessageBox::Discard)    1684           if (action == QMessageBox::Discard) {
1674             wanted = false;                      1685             wanted = false;
1675           }                                      1686           }
1676         }                                        1687         }
1677       }                                          1688       }
1678       break;                                     1689       break;
1679   }                                              1690   }
1680 }                                                1691 }
1681                                                  1692 
1682 void G4UIQt::SceneTreeItemDoubleClicked(QTree    1693 void G4UIQt::SceneTreeItemDoubleClicked(QTreeWidgetItem* item)
1683 {                                                1694 {
1684   if (item == nullptr) return;                   1695   if (item == nullptr) return;
1685   auto sceneTreeItem = ConvertToG4SceneTreeIt    1696   auto sceneTreeItem = ConvertToG4SceneTreeItem(item);
1686   if (sceneTreeItem == nullptr) return;          1697   if (sceneTreeItem == nullptr) return;
1687   if (sceneTreeItem->GetType() != G4SceneTree    1698   if (sceneTreeItem->GetType() != G4SceneTreeItem::touchable) return;
1688                                                  1699 
1689   auto oldQColor = ConvertG4ColourToQColor(sc    1700   auto oldQColor = ConvertG4ColourToQColor(sceneTreeItem->GetVisAttributes().GetColour());
1690   auto newQColor = QColorDialog::getColor     << 1701   auto newQColor = QColorDialog::getColor(oldQColor, fNewSceneTreeItemTreeWidget, "", QColorDialog::ShowAlphaChannel);
1691   (oldQColor, fNewSceneTreeItemTreeWidget, "" << 
1692   if (!newQColor.isValid()) return;              1702   if (!newQColor.isValid()) return;
1693   if (newQColor == oldQColor) return;            1703   if (newQColor == oldQColor) return;
1694                                                  1704 
1695   auto newColour = ConvertQColorToG4Colour(ne    1705   auto newColour = ConvertQColorToG4Colour(newQColor);
1696   std::ostringstream oss; oss << std::setprec    1706   std::ostringstream oss; oss << std::setprecision(2)
1697   << newColour.GetRed() << ' ' << newColour.G    1707   << newColour.GetRed() << ' ' << newColour.GetGreen()
1698   << ' ' << newColour.GetBlue() << ' ' << new    1708   << ' ' << newColour.GetBlue() << ' ' << newColour.GetAlpha();
1699   auto uiMan = G4UImanager::GetUIpointer();      1709   auto uiMan = G4UImanager::GetUIpointer();
1700   uiMan->ApplyCommand("/vis/set/touchable" +     1710   uiMan->ApplyCommand("/vis/set/touchable" + sceneTreeItem->GetPVPath());
1701   uiMan->ApplyCommand("/vis/touchable/set/col    1711   uiMan->ApplyCommand("/vis/touchable/set/colour " + oss.str());
1702                                               << 
1703   // Normally the sceneTreeItem will be updat << 
1704   // commands, but if the user sets the opaci << 
1705   // transmit it (this is because some users  << 
1706   // invisible - perhaps they should use the  << 
1707   // By design, the sceneTreeItem remains, so << 
1708   // the colour will not be updated, so we do << 
1709   if (newColour.GetAlpha() == 0.) {           << 
1710     sceneTreeItem->AccessVisAttributes().SetC << 
1711   }                                           << 
1712 }                                                1712 }
1713                                                  1713 
1714 void G4UIQt::SceneTreeItemExpanded(QTreeWidge    1714 void G4UIQt::SceneTreeItemExpanded(QTreeWidgetItem* item)
1715 {                                                1715 {
1716   if (item == nullptr) return;                   1716   if (item == nullptr) return;
1717   auto sceneTreeItem = ConvertToG4SceneTreeIt    1717   auto sceneTreeItem = ConvertToG4SceneTreeItem(item);
1718   if (sceneTreeItem == nullptr) return;          1718   if (sceneTreeItem == nullptr) return;
1719                                                  1719 
1720   if (sceneTreeItem->GetType() == G4SceneTree    1720   if (sceneTreeItem->GetType() == G4SceneTreeItem::ghost ||
1721       sceneTreeItem->GetType() == G4SceneTree    1721       sceneTreeItem->GetType() == G4SceneTreeItem::touchable) {
1722     sceneTreeItem->SetExpanded(true);            1722     sceneTreeItem->SetExpanded(true);
1723   }                                              1723   }
1724 }                                                1724 }
1725                                                  1725 
1726 void G4UIQt::SceneTreeItemCollapsed(QTreeWidg    1726 void G4UIQt::SceneTreeItemCollapsed(QTreeWidgetItem* item)
1727 {                                                1727 {
1728   if (item == nullptr) return;                   1728   if (item == nullptr) return;
1729   auto sceneTreeItem = ConvertToG4SceneTreeIt    1729   auto sceneTreeItem = ConvertToG4SceneTreeItem(item);
1730   if (sceneTreeItem == nullptr) return;          1730   if (sceneTreeItem == nullptr) return;
1731                                                  1731 
1732   if (sceneTreeItem->GetType() == G4SceneTree    1732   if (sceneTreeItem->GetType() == G4SceneTreeItem::ghost ||
1733       sceneTreeItem->GetType() == G4SceneTree    1733       sceneTreeItem->GetType() == G4SceneTreeItem::touchable) {
1734     sceneTreeItem->SetExpanded(false);           1734     sceneTreeItem->SetExpanded(false);
1735   }                                              1735   }
1736 }                                                1736 }
1737                                                  1737 
1738 void G4UIQt::NewSceneTreeItemTreeWidget::mous    1738 void G4UIQt::NewSceneTreeItemTreeWidget::mousePressEvent(QMouseEvent* ev)
1739 {                                                1739 {
1740 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))     1740 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
1741   auto currentMousePressPosition = ev->global    1741   auto currentMousePressPosition = ev->globalPos();
1742 #else                                            1742 #else
1743   auto currentMousePressPosition = ev->global    1743   auto currentMousePressPosition = ev->globalPosition().toPoint();
1744 #endif                                           1744 #endif
1745                                                  1745 
1746   if (ev->button() == Qt::RightButton) {         1746   if (ev->button() == Qt::RightButton) {
1747     auto item = currentItem();                   1747     auto item = currentItem();
1748     if (item) {                                  1748     if (item) {
1749       auto sceneTreeItem = ConvertToG4SceneTr    1749       auto sceneTreeItem = ConvertToG4SceneTreeItem(item);
1750       if (sceneTreeItem) {                       1750       if (sceneTreeItem) {
1751         if (sceneTreeItem->GetType() == G4Sce    1751         if (sceneTreeItem->GetType() == G4SceneTreeItem::touchable) {
1752                                                  1752 
1753           // We wish to present actions (and     1753           // We wish to present actions (and menus) in alphabetical order. I have
1754           // not found the required insert me    1754           // not found the required insert methods so we make our own list (map)
1755           // and add actions and menus and th    1755           // and add actions and menus and then creating appropriate qActions.
1756           // Using std::map to get alphabetic    1756           // Using std::map to get alphabetical order. To control the order use
1757           // std::list of pairs instead.         1757           // std::list of pairs instead.
1758           enum CommandType {withoutParameter,    1758           enum CommandType {withoutParameter, withABool, withAnInteger, withADouble, withAString};
1759           static std::map<G4String,CommandTyp    1759           static std::map<G4String,CommandType> alphabetical;  // Ensures alphabetical order
1760           static G4bool first = true;            1760           static G4bool first = true;
1761           if (first) {                           1761           if (first) {
1762             first = false;                       1762             first = false;
1763             // Rather than simply take all co    1763             // Rather than simply take all commands, select those that make sense
1764             // in this pop-up menu.              1764             // in this pop-up menu.
1765             // Select from /vis/touchable. Th    1765             // Select from /vis/touchable. These are actions without parameter or for
1766             // which it only makes sense to u    1766             // which it only makes sense to use their default omitable paramater.
1767             alphabetical["centreAndZoomInOn"]    1767             alphabetical["centreAndZoomInOn"] = withoutParameter;
1768             alphabetical["centreOn"] = withou    1768             alphabetical["centreOn"] = withoutParameter;
1769             alphabetical["dump"] = withoutPar    1769             alphabetical["dump"] = withoutParameter;
1770             alphabetical["extentForField"] =     1770             alphabetical["extentForField"] = withoutParameter;
1771             alphabetical["localAxes"] = witho    1771             alphabetical["localAxes"] = withoutParameter;
1772             alphabetical["showExtent"] = with    1772             alphabetical["showExtent"] = withoutParameter;
1773             alphabetical["twinkle"] = without    1773             alphabetical["twinkle"] = withoutParameter;
1774             alphabetical["volumeForField"] =     1774             alphabetical["volumeForField"] = withoutParameter;
1775             // Commands from /vis/touchable/s    1775             // Commands from /vis/touchable/set
1776             // Actions with a Boolean paramat    1776             // Actions with a Boolean paramater
1777             alphabetical["daughtersInvisible"    1777             alphabetical["daughtersInvisible"] = withABool;
1778             alphabetical["forceAuxEdgeVisible    1778             alphabetical["forceAuxEdgeVisible"] = withABool;
1779             alphabetical["forceCloud"] = with    1779             alphabetical["forceCloud"] = withABool;
1780             alphabetical["forceSolid"] = with    1780             alphabetical["forceSolid"] = withABool;
1781             alphabetical["forceWireframe"] =     1781             alphabetical["forceWireframe"] = withABool;
1782             alphabetical["visibility"] = with    1782             alphabetical["visibility"] = withABool;
1783             // Actions with an integer           1783             // Actions with an integer
1784             alphabetical["lineSegmentsPerCirc    1784             alphabetical["lineSegmentsPerCircle"] = withAnInteger;
1785             alphabetical["numberOfCloudPoints    1785             alphabetical["numberOfCloudPoints"] = withAnInteger;
1786             // Actions with a double             1786             // Actions with a double
1787             alphabetical["lineWidth"] = withA    1787             alphabetical["lineWidth"] = withADouble;
1788             // Actions with a string             1788             // Actions with a string
1789             alphabetical["lineStyle"] = withA    1789             alphabetical["lineStyle"] = withAString;
1790           }                                      1790           }
1791                                                  1791 
1792           QMenu topMenu;  // Local (temporary    1792           QMenu topMenu;  // Local (temporary) object for this item
1793           std::vector<QAction*> actions;  //     1793           std::vector<QAction*> actions;  // Temporary container for action pointers
1794           std::vector<QMenu*> menus;  // Temp    1794           std::vector<QMenu*> menus;  // Temporary container for menu pointers
1795                                                  1795 
1796           for (const auto& action : alphabeti    1796           for (const auto& action : alphabetical) {
1797             const auto& af = action.first;  /    1797             const auto& af = action.first;  // G4String name of action
1798                                                  1798 
1799             if (action.second == withoutParam    1799             if (action.second == withoutParameter) {
1800                                                  1800 
1801               auto qAction = new QAction(af.c    1801               auto qAction = new QAction(af.c_str(), this);
1802               actions.push_back(qAction);  //    1802               actions.push_back(qAction);  // into temporary container
1803               topMenu.addAction(qAction);        1803               topMenu.addAction(qAction);
1804               connect(qAction, &QAction::trig    1804               connect(qAction, &QAction::triggered, this,
1805                       [this, &af, &sceneTreeI    1805                       [this, &af, &sceneTreeItem]{ActWithoutParameter(af, sceneTreeItem);});
1806                                                  1806 
1807             } else if (action.second == withA    1807             } else if (action.second == withABool) {
1808                                                  1808 
1809               auto menu = new QMenu(af.c_str(    1809               auto menu = new QMenu(af.c_str());
1810               menus.push_back(menu);  // into    1810               menus.push_back(menu);  // into temporary container
1811               topMenu.addMenu(menu);             1811               topMenu.addMenu(menu);
1812               auto qActionTrue = new QAction(    1812               auto qActionTrue = new QAction("true", this);
1813               actions.push_back(qActionTrue);    1813               actions.push_back(qActionTrue);  // into temporary container
1814               menu->addAction(qActionTrue);      1814               menu->addAction(qActionTrue);
1815               connect(qActionTrue, &QAction::    1815               connect(qActionTrue, &QAction::triggered, this,
1816                       [this, &af, &sceneTreeI    1816                       [this, &af, &sceneTreeItem]{ActWithABool(af, sceneTreeItem, true);});
1817               auto qActionFalse = new QAction    1817               auto qActionFalse = new QAction("false", this);
1818               actions.push_back(qActionFalse)    1818               actions.push_back(qActionFalse);  // into temporary container
1819               menu->addAction(qActionFalse);     1819               menu->addAction(qActionFalse);
1820               connect(qActionFalse, &QAction:    1820               connect(qActionFalse, &QAction::triggered, this,
1821                       [this, &af, &sceneTreeI    1821                       [this, &af, &sceneTreeItem]{ActWithABool(af, sceneTreeItem, false);});
1822                                                  1822 
1823             } else if (action.second == withA    1823             } else if (action.second == withAnInteger) {
1824                                                  1824 
1825               auto qAction = new QAction(af.c    1825               auto qAction = new QAction(af.c_str(), this);
1826               actions.push_back(qAction);  //    1826               actions.push_back(qAction);  // into temporary container
1827               topMenu.addAction(qAction);        1827               topMenu.addAction(qAction);
1828               connect(qAction, &QAction::trig    1828               connect(qAction, &QAction::triggered, this,
1829                       [this, &af, &sceneTreeI    1829                       [this, &af, &sceneTreeItem]{ActWithAnInteger(af, sceneTreeItem);});
1830                                                  1830 
1831             } else if (action.second == withA    1831             } else if (action.second == withADouble) {
1832                                                  1832 
1833               auto qAction = new QAction(af.c    1833               auto qAction = new QAction(af.c_str(), this);
1834               actions.push_back(qAction);  //    1834               actions.push_back(qAction);  // into temporary container
1835               topMenu.addAction(qAction);        1835               topMenu.addAction(qAction);
1836               connect(qAction, &QAction::trig    1836               connect(qAction, &QAction::triggered, this,
1837                       [this, &af, &sceneTreeI    1837                       [this, &af, &sceneTreeItem]{ActWithADouble(af, sceneTreeItem);});
1838                                                  1838 
1839             } else if (action.second == withA    1839             } else if (action.second == withAString) {
1840                                                  1840 
1841               auto qAction = new QAction(af.c    1841               auto qAction = new QAction(af.c_str(), this);
1842               actions.push_back(qAction);  //    1842               actions.push_back(qAction);  // into temporary container
1843               topMenu.addAction(qAction);        1843               topMenu.addAction(qAction);
1844               connect(qAction, &QAction::trig    1844               connect(qAction, &QAction::triggered, this,
1845                       [this, &af, &sceneTreeI    1845                       [this, &af, &sceneTreeItem]{ActWithAString(af, sceneTreeItem);});
1846             }                                    1846             }
1847           }                                      1847           }
1848                                                  1848 
1849           topMenu.exec(currentMousePressPosit    1849           topMenu.exec(currentMousePressPosition);
1850                                                  1850 
1851           // Clean up                            1851           // Clean up
1852           for (auto action : actions) {          1852           for (auto action : actions) {
1853             // No need to disconnect. Qt say,    1853             // No need to disconnect. Qt say, "A signal-slot connection is removed
1854             // when either of the objects inv    1854             // when either of the objects involved are destroyed."
1855             delete action;                       1855             delete action;
1856           }                                      1856           }
1857           for (auto menu : menus) {              1857           for (auto menu : menus) {
1858             delete menu;                         1858             delete menu;
1859           }                                      1859           }
1860         }                                        1860         }
1861       }                                          1861       }
1862     }                                            1862     }
1863   }                                              1863   }
1864                                                  1864   
1865   // Pass event on up the widget tree for oth    1865   // Pass event on up the widget tree for other actions
1866   QTreeWidget::mousePressEvent(ev);              1866   QTreeWidget::mousePressEvent(ev);
1867 }                                                1867 }
1868                                                  1868 
1869 void G4UIQt::NewSceneTreeItemTreeWidget::ActW    1869 void G4UIQt::NewSceneTreeItemTreeWidget::ActWithoutParameter
1870  (const G4String& action, G4SceneTreeItem* sc    1870  (const G4String& action, G4SceneTreeItem* sceneTreeItem)
1871 {                                                1871 {
1872   // Special case: dump                          1872   // Special case: dump
1873   if (action == "dump") {                        1873   if (action == "dump") {
1874     static G4bool wanted = true;                 1874     static G4bool wanted = true;
1875     if (wanted) {                                1875     if (wanted) {
1876       QMessageBox msgBox;                        1876       QMessageBox msgBox;
1877       std::ostringstream oss;                    1877       std::ostringstream oss;
1878       oss << G4AttCheck(sceneTreeItem->GetAtt    1878       oss << G4AttCheck(sceneTreeItem->GetAttValues(), sceneTreeItem->GetAttDefs());
1879       // Just the first 1000 characters, othe    1879       // Just the first 1000 characters, otherwise it spreads off screen
1880       msgBox.setText((oss.str().substr(0,1000    1880       msgBox.setText((oss.str().substr(0,1000)+"...").c_str());
1881       msgBox.setInformativeText                  1881       msgBox.setInformativeText
1882       ("To suppress this message click \"Disc    1882       ("To suppress this message click \"Discard\" or \"Don't Save\"."
1883        "\nTo get a complete dump to session o    1883        "\nTo get a complete dump to session output click \"Ok\","
1884        "\nElse click \"Close\".");               1884        "\nElse click \"Close\".");
1885       msgBox.setStandardButtons                  1885       msgBox.setStandardButtons
1886       (QMessageBox::Discard | QMessageBox::Cl    1886       (QMessageBox::Discard | QMessageBox::Close | QMessageBox::Ok);
1887       msgBox.setDefaultButton(QMessageBox::Ok    1887       msgBox.setDefaultButton(QMessageBox::Ok);
1888       auto result = msgBox.exec();               1888       auto result = msgBox.exec();
1889       if (result == QMessageBox::Discard) {      1889       if (result == QMessageBox::Discard) {
1890         wanted = false;                          1890         wanted = false;
1891       } else if (result == QMessageBox::Close    1891       } else if (result == QMessageBox::Close) {
1892         return;                                  1892         return;
1893       }                                          1893       }
1894     }                                            1894     }
1895   }                                              1895   }
1896   auto uiMan = G4UImanager::GetUIpointer();      1896   auto uiMan = G4UImanager::GetUIpointer();
1897   uiMan->ApplyCommand("/vis/set/touchable" +     1897   uiMan->ApplyCommand("/vis/set/touchable" + sceneTreeItem->GetPVPath());
1898   uiMan->ApplyCommand("/vis/touchable/" + act    1898   uiMan->ApplyCommand("/vis/touchable/" + action);
1899 }                                                1899 }
1900                                                  1900 
1901 void G4UIQt::NewSceneTreeItemTreeWidget::ActW    1901 void G4UIQt::NewSceneTreeItemTreeWidget::ActWithABool
1902  (const G4String& action, G4SceneTreeItem* sc    1902  (const G4String& action, G4SceneTreeItem* sceneTreeItem, G4bool whatever)
1903 {                                                1903 {
1904   auto uiMan = G4UImanager::GetUIpointer();      1904   auto uiMan = G4UImanager::GetUIpointer();
1905   uiMan->ApplyCommand("/vis/set/touchable" +     1905   uiMan->ApplyCommand("/vis/set/touchable" + sceneTreeItem->GetPVPath());
1906   G4String which = whatever? "true": "false";    1906   G4String which = whatever? "true": "false";
1907   uiMan->ApplyCommand("/vis/touchable/set/" +    1907   uiMan->ApplyCommand("/vis/touchable/set/" + action + ' ' + which);
1908 }                                                1908 }
1909                                                  1909 
1910 void G4UIQt::NewSceneTreeItemTreeWidget::ActW    1910 void G4UIQt::NewSceneTreeItemTreeWidget::ActWithAnInteger
1911 (const G4String& action, G4SceneTreeItem* sce    1911 (const G4String& action, G4SceneTreeItem* sceneTreeItem)
1912 {                                                1912 {
1913   G4bool ok = true;                              1913   G4bool ok = true;
1914   auto newValue = QInputDialog::getInt(this,     1914   auto newValue = QInputDialog::getInt(this, action.c_str(), action.c_str(),
1915                                        0, 0,  << 1915                                        0, 0, 999, 1, &ok);
1916   if (ok) {                                      1916   if (ok) {
1917     auto uiMan = G4UImanager::GetUIpointer();    1917     auto uiMan = G4UImanager::GetUIpointer();
1918     uiMan->ApplyCommand("/vis/set/touchable"     1918     uiMan->ApplyCommand("/vis/set/touchable" + sceneTreeItem->GetPVPath());
1919     uiMan->ApplyCommand("/vis/touchable/set/"    1919     uiMan->ApplyCommand("/vis/touchable/set/" + action + ' '
1920                         + G4UIcommand::Conver    1920                         + G4UIcommand::ConvertToString(newValue));
1921   }                                              1921   }
1922 }                                                1922 }
1923                                                  1923 
1924 void G4UIQt::NewSceneTreeItemTreeWidget::ActW    1924 void G4UIQt::NewSceneTreeItemTreeWidget::ActWithADouble
1925  (const G4String& action, G4SceneTreeItem* sc    1925  (const G4String& action, G4SceneTreeItem* sceneTreeItem)
1926 {                                                1926 {
1927   G4bool ok = true;                              1927   G4bool ok = true;
1928   auto newValue = QInputDialog::getDouble(thi    1928   auto newValue = QInputDialog::getDouble(this, action.c_str(), action.c_str(),
1929                                           0,     1929                                           0, 0, 999, 1, &ok);
1930   if (ok) {                                      1930   if (ok) {
1931     auto uiMan = G4UImanager::GetUIpointer();    1931     auto uiMan = G4UImanager::GetUIpointer();
1932     uiMan->ApplyCommand("/vis/set/touchable"     1932     uiMan->ApplyCommand("/vis/set/touchable" + sceneTreeItem->GetPVPath());
1933     uiMan->ApplyCommand("/vis/touchable/set/"    1933     uiMan->ApplyCommand("/vis/touchable/set/" + action + ' '
1934                         + G4UIcommand::Conver    1934                         + G4UIcommand::ConvertToString(newValue));
1935   }                                              1935   }
1936 }                                                1936 }
1937                                                  1937 
1938 void G4UIQt::NewSceneTreeItemTreeWidget::ActW    1938 void G4UIQt::NewSceneTreeItemTreeWidget::ActWithAString
1939  (const G4String& action, G4SceneTreeItem* sc    1939  (const G4String& action, G4SceneTreeItem* sceneTreeItem)
1940 {                                                1940 {
1941   auto uiMan = G4UImanager::GetUIpointer();      1941   auto uiMan = G4UImanager::GetUIpointer();
1942   auto command = uiMan->FindCommand("/vis/tou    1942   auto command = uiMan->FindCommand("/vis/touchable/set/" + action);
1943   if (command) {                                 1943   if (command) {
1944     QStringList qStringList;                     1944     QStringList qStringList;
1945     const auto& candidates = command->GetPara    1945     const auto& candidates = command->GetParameter(0)->GetParameterCandidates();
1946     std::istringstream iss(candidates);          1946     std::istringstream iss(candidates);
1947     G4String candidate;                          1947     G4String candidate;
1948     while (iss >> candidate) qStringList.appe    1948     while (iss >> candidate) qStringList.append(candidate.c_str());
1949     G4bool ok = true;                            1949     G4bool ok = true;
1950     auto chosenValue = QInputDialog::getItem(    1950     auto chosenValue = QInputDialog::getItem(this, action.c_str(), action.c_str(), qStringList,
1951                                                  1951                                              0, false, &ok);
1952     if (ok) {                                    1952     if (ok) {
1953       uiMan->ApplyCommand("/vis/set/touchable    1953       uiMan->ApplyCommand("/vis/set/touchable" + sceneTreeItem->GetPVPath());
1954       G4String g4ChosenValue = chosenValue.to    1954       G4String g4ChosenValue = chosenValue.toStdString();
1955       uiMan->ApplyCommand("/vis/touchable/set    1955       uiMan->ApplyCommand("/vis/touchable/set/" + action + ' ' + g4ChosenValue);
1956     }                                            1956     }
1957   }                                              1957   }
1958 }                                                1958 }
1959                                                  1959 
1960                                                  1960 
1961 /** Create the History ToolBox Widget            1961 /** Create the History ToolBox Widget
1962  */                                              1962  */
1963 QWidget* G4UIQt::CreateHistoryTBWidget()         1963 QWidget* G4UIQt::CreateHistoryTBWidget()
1964 {                                                1964 {
1965   fHistoryTBWidget = new QWidget();              1965   fHistoryTBWidget = new QWidget();
1966                                                  1966 
1967   auto layoutHistoryTB = new QVBoxLayout();      1967   auto layoutHistoryTB = new QVBoxLayout();
1968   fHistoryTBTableList = new QListWidget();       1968   fHistoryTBTableList = new QListWidget();
1969   fHistoryTBTableList->setSelectionMode(QAbst    1969   fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
1970   connect(fHistoryTBTableList, SIGNAL(itemSel    1970   connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
1971                                                  1971 
1972   layoutHistoryTB->addWidget(fHistoryTBTableL    1972   layoutHistoryTB->addWidget(fHistoryTBTableList);
1973                                                  1973 
1974   fHistoryTBWidget->setLayout(layoutHistoryTB    1974   fHistoryTBWidget->setLayout(layoutHistoryTB);
1975   return fHistoryTBWidget;                       1975   return fHistoryTBWidget;
1976 }                                                1976 }
1977                                                  1977 
1978 /** Create the Help ToolBox Widget               1978 /** Create the Help ToolBox Widget
1979  */                                              1979  */
1980 QWidget* G4UIQt::CreateHelpTBWidget()            1980 QWidget* G4UIQt::CreateHelpTBWidget()
1981 {                                                1981 {
1982   fHelpTBWidget = new QWidget();                 1982   fHelpTBWidget = new QWidget();
1983                                                  1983 
1984   auto helpWidget = new QWidget();               1984   auto helpWidget = new QWidget();
1985   auto helpLayout = new QHBoxLayout();           1985   auto helpLayout = new QHBoxLayout();
1986   auto vLayout = new QVBoxLayout();              1986   auto vLayout = new QVBoxLayout();
1987   fHelpVSplitter = new QSplitter(Qt::Vertical    1987   fHelpVSplitter = new QSplitter(Qt::Vertical);
1988   fHelpLine = new QLineEdit();                   1988   fHelpLine = new QLineEdit();
1989   helpLayout->addWidget(new QLabel("Search :"    1989   helpLayout->addWidget(new QLabel("Search :"));
1990   helpLayout->addWidget(fHelpLine);              1990   helpLayout->addWidget(fHelpLine);
1991   connect(fHelpLine, SIGNAL(editingFinished()    1991   connect(fHelpLine, SIGNAL(editingFinished()), this, SLOT(LookForHelpStringCallback()));
1992                                                  1992 
1993   // Create Help tree                            1993   // Create Help tree
1994   FillHelpTree();                                1994   FillHelpTree();
1995                                                  1995 
1996   fParameterHelpLabel = new QTextEdit();         1996   fParameterHelpLabel = new QTextEdit();
1997   fParameterHelpLabel->setReadOnly(true);        1997   fParameterHelpLabel->setReadOnly(true);
1998   fParameterHelpTable = new QTableWidget();      1998   fParameterHelpTable = new QTableWidget();
1999                                                  1999 
2000   // Set layouts                                 2000   // Set layouts
2001                                                  2001 
2002   if (fHelpTreeWidget != nullptr) {              2002   if (fHelpTreeWidget != nullptr) {
2003     fHelpVSplitter->addWidget(fHelpTreeWidget    2003     fHelpVSplitter->addWidget(fHelpTreeWidget);
2004     fHelpVSplitter->setStretchFactor(0,4);       2004     fHelpVSplitter->setStretchFactor(0,4);
2005   }                                              2005   }
2006   fHelpVSplitter->addWidget(fParameterHelpLab    2006   fHelpVSplitter->addWidget(fParameterHelpLabel);
2007   fHelpVSplitter->addWidget(fParameterHelpTab    2007   fHelpVSplitter->addWidget(fParameterHelpTable);
2008                                                  2008 
2009   fParameterHelpLabel->setVisible(false);        2009   fParameterHelpLabel->setVisible(false);
2010   fParameterHelpTable->setVisible(false);        2010   fParameterHelpTable->setVisible(false);
2011   QSizePolicy policy = QSizePolicy(QSizePolic    2011   QSizePolicy policy = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
2012   policy.setVerticalStretch(1);                  2012   policy.setVerticalStretch(1);
2013   fParameterHelpLabel->setSizePolicy(policy);    2013   fParameterHelpLabel->setSizePolicy(policy);
2014   fParameterHelpTable->setSizePolicy(policy);    2014   fParameterHelpTable->setSizePolicy(policy);
2015                                                  2015 
2016   vLayout->addWidget(helpWidget);                2016   vLayout->addWidget(helpWidget);
2017   vLayout->addWidget(fHelpVSplitter, 1);         2017   vLayout->addWidget(fHelpVSplitter, 1);
2018   vLayout->setContentsMargins(5, 5, 5, 5);       2018   vLayout->setContentsMargins(5, 5, 5, 5);
2019                                                  2019 
2020   helpWidget->setLayout(helpLayout);             2020   helpWidget->setLayout(helpLayout);
2021   fHelpTBWidget->setLayout(vLayout);             2021   fHelpTBWidget->setLayout(vLayout);
2022                                                  2022 
2023   return fHelpTBWidget;                          2023   return fHelpTBWidget;
2024 }                                                2024 }
2025                                                  2025 
2026 /** Create the Cout ToolBox Widget               2026 /** Create the Cout ToolBox Widget
2027  */                                              2027  */
2028 G4UIDockWidget* G4UIQt::CreateCoutTBWidget()     2028 G4UIDockWidget* G4UIQt::CreateCoutTBWidget()
2029 {                                                2029 {
2030   auto coutTBWidget = new QWidget();             2030   auto coutTBWidget = new QWidget();
2031                                                  2031 
2032   auto layoutCoutTB = new QVBoxLayout();         2032   auto layoutCoutTB = new QVBoxLayout();
2033                                                  2033 
2034   fCoutTBTextArea = new QTextEdit();             2034   fCoutTBTextArea = new QTextEdit();
2035                                                  2035 
2036   fCoutFilter = new QLineEdit();                 2036   fCoutFilter = new QLineEdit();
2037   fCoutFilter->setToolTip("Filter output by..    2037   fCoutFilter->setToolTip("Filter output by...");
2038                                                  2038 
2039   fCoutFilter->addAction(*fSearchIcon, QLineE    2039   fCoutFilter->addAction(*fSearchIcon, QLineEdit::TrailingPosition);
2040   fCoutFilter->setStyleSheet("border-radius:7    2040   fCoutFilter->setStyleSheet("border-radius:7px;");
2041                                                  2041 
2042   auto coutTBClearButton = new QPushButton();    2042   auto coutTBClearButton = new QPushButton();
2043   coutTBClearButton->setIcon(*fClearIcon);       2043   coutTBClearButton->setIcon(*fClearIcon);
2044   coutTBClearButton->setToolTip("Clear consol    2044   coutTBClearButton->setToolTip("Clear console output");
2045   coutTBClearButton->setStyleSheet("border-ra    2045   coutTBClearButton->setStyleSheet("border-radius:7px;");
2046   connect(coutTBClearButton, SIGNAL(clicked()    2046   connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
2047   connect(                                       2047   connect(
2048     fCoutFilter, SIGNAL(textEdited(const QStr    2048     fCoutFilter, SIGNAL(textEdited(const QString&)), SLOT(CoutFilterCallback(const QString&)));
2049                                                  2049 
2050   auto coutTBSaveOutputButton = new QPushButt    2050   auto coutTBSaveOutputButton = new QPushButton();
2051   coutTBSaveOutputButton->setIcon(*fSaveIcon)    2051   coutTBSaveOutputButton->setIcon(*fSaveIcon);
2052   coutTBSaveOutputButton->setToolTip("Save co    2052   coutTBSaveOutputButton->setToolTip("Save console output");
2053   coutTBSaveOutputButton->setStyleSheet("bord    2053   coutTBSaveOutputButton->setStyleSheet("border-radius:7px;");
2054   connect(coutTBSaveOutputButton, SIGNAL(clic    2054   connect(coutTBSaveOutputButton, SIGNAL(clicked()), SLOT(SaveOutputCallback()));
2055                                                  2055 
2056   fCoutTBTextArea->setReadOnly(true);            2056   fCoutTBTextArea->setReadOnly(true);
2057                                                  2057 
2058   auto coutButtonWidget = new QWidget();         2058   auto coutButtonWidget = new QWidget();
2059   auto layoutCoutTBButtons = new QHBoxLayout(    2059   auto layoutCoutTBButtons = new QHBoxLayout();
2060                                                  2060 
2061 #ifdef G4MULTITHREADED                           2061 #ifdef G4MULTITHREADED
2062   // add all candidates to widget                2062   // add all candidates to widget
2063   fThreadsFilterComboBox = new QComboBox();      2063   fThreadsFilterComboBox = new QComboBox();
2064   fThreadsFilterComboBox->setInsertPolicy(QCo    2064   fThreadsFilterComboBox->setInsertPolicy(QComboBox::InsertAlphabetically);
2065   connect(                                       2065   connect(
2066     fThreadsFilterComboBox, SIGNAL(activated(    2066     fThreadsFilterComboBox, SIGNAL(activated(int)), this, SLOT(ThreadComboBoxCallback(int)));
2067                                                  2067 
2068   UpdateCoutThreadFilter();                      2068   UpdateCoutThreadFilter();
2069                                                  2069 
2070   fThreadsFilterComboBox->setToolTip("Thread     2070   fThreadsFilterComboBox->setToolTip("Thread selection in output");
2071   layoutCoutTBButtons->addWidget(new QLabel("    2071   layoutCoutTBButtons->addWidget(new QLabel(" Threads:"));
2072   layoutCoutTBButtons->addWidget(fThreadsFilt    2072   layoutCoutTBButtons->addWidget(fThreadsFilterComboBox);
2073 #endif                                           2073 #endif
2074                                                  2074 
2075   layoutCoutTBButtons->addWidget(fCoutFilter)    2075   layoutCoutTBButtons->addWidget(fCoutFilter);
2076   layoutCoutTBButtons->addWidget(coutTBClearB    2076   layoutCoutTBButtons->addWidget(coutTBClearButton);
2077   layoutCoutTBButtons->addWidget(coutTBSaveOu    2077   layoutCoutTBButtons->addWidget(coutTBSaveOutputButton);
2078   coutButtonWidget->setLayout(layoutCoutTBBut    2078   coutButtonWidget->setLayout(layoutCoutTBButtons);
2079                                                  2079 
2080   // reduce margins                              2080   // reduce margins
2081   layoutCoutTBButtons->setContentsMargins(3,     2081   layoutCoutTBButtons->setContentsMargins(3, 3, 3, 0);
2082                                                  2082 
2083   layoutCoutTB->addWidget(coutButtonWidget);     2083   layoutCoutTB->addWidget(coutButtonWidget);
2084   layoutCoutTB->addWidget(fCoutTBTextArea);      2084   layoutCoutTB->addWidget(fCoutTBTextArea);
2085                                                  2085 
2086   coutTBWidget->setLayout(layoutCoutTB);         2086   coutTBWidget->setLayout(layoutCoutTB);
2087                                                  2087 
2088   fCoutTBTextArea->setMinimumSize(100, 100);     2088   fCoutTBTextArea->setMinimumSize(100, 100);
2089                                                  2089 
2090   // Command line :                              2090   // Command line :
2091   auto commandLineWidget = new QWidget();        2091   auto commandLineWidget = new QWidget();
2092   auto layoutCommandLine = new QHBoxLayout();    2092   auto layoutCommandLine = new QHBoxLayout();
2093                                                  2093 
2094   // fill them                                   2094   // fill them
2095                                                  2095 
2096   fCommandLabel = new QLabel("");                2096   fCommandLabel = new QLabel("");
2097   fCommandArea = new QLineEdit();                2097   fCommandArea = new QLineEdit();
2098                                                  2098 
2099   // The QCompleter will be append at Session    2099   // The QCompleter will be append at SessionStart()
2100                                                  2100 
2101   fCommandArea->activateWindow();                2101   fCommandArea->activateWindow();
2102                                                  2102 
2103   fCommandArea->setFocusPolicy(Qt::StrongFocu    2103   fCommandArea->setFocusPolicy(Qt::StrongFocus);
2104   fCommandArea->setFocus(Qt::TabFocusReason);    2104   fCommandArea->setFocus(Qt::TabFocusReason);
2105   fCommandArea->setToolTip("Apply command");     2105   fCommandArea->setToolTip("Apply command");
2106                                                  2106 
2107   layoutCommandLine->addWidget(fCommandLabel)    2107   layoutCommandLine->addWidget(fCommandLabel);
2108   layoutCommandLine->addWidget(fCommandArea);    2108   layoutCommandLine->addWidget(fCommandArea);
2109                                                  2109 
2110   // Connect signal                              2110   // Connect signal
2111   connect(fCommandArea, SIGNAL(returnPressed(    2111   connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
2112   connect(                                       2112   connect(
2113     fCommandArea, SIGNAL(textEdited(const QSt    2113     fCommandArea, SIGNAL(textEdited(const QString&)), SLOT(CommandEditedCallback(const QString&)));
2114                                                  2114 
2115   commandLineWidget->setLayout(layoutCommandL    2115   commandLineWidget->setLayout(layoutCommandLine);
2116   commandLineWidget->setMinimumSize(50, 50);     2116   commandLineWidget->setMinimumSize(50, 50);
2117                                                  2117 
2118   layoutCoutTB->addWidget(commandLineWidget);    2118   layoutCoutTB->addWidget(commandLineWidget);
2119                                                  2119 
2120   fCoutDockWidget = new G4UIDockWidget("Outpu    2120   fCoutDockWidget = new G4UIDockWidget("Output");
2121   fCoutDockWidget->setAllowedAreas(Qt::TopDoc    2121   fCoutDockWidget->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
2122                                                  2122 
2123   fCoutDockWidget->setWidget(coutTBWidget);      2123   fCoutDockWidget->setWidget(coutTBWidget);
2124   return fCoutDockWidget;                        2124   return fCoutDockWidget;
2125 }                                                2125 }
2126                                                  2126 
2127 /** Create the VisParameters ToolBox Widget      2127 /** Create the VisParameters ToolBox Widget
2128  */                                              2128  */
2129 QWidget* G4UIQt::CreateVisParametersTBWidget(    2129 QWidget* G4UIQt::CreateVisParametersTBWidget() { return nullptr; }
2130                                                  2130 
2131 /** Create the VisParameters ToolBox Widget      2131 /** Create the VisParameters ToolBox Widget
2132  */                                              2132  */
2133 G4UIDockWidget* G4UIQt::CreateUITabWidget()      2133 G4UIDockWidget* G4UIQt::CreateUITabWidget()
2134 {                                                2134 {
2135   fUITabWidget = new QTabWidget();               2135   fUITabWidget = new QTabWidget();
2136                                                  2136 
2137   // the left dock                               2137   // the left dock
2138   fUITabWidget->addTab(CreateSceneTreeWidget(    2138   fUITabWidget->addTab(CreateSceneTreeWidget(), "Scene tree");
2139   fUITabWidget->addTab(CreateHelpTBWidget(),     2139   fUITabWidget->addTab(CreateHelpTBWidget(), "Help");
2140   fUITabWidget->addTab(CreateHistoryTBWidget(    2140   fUITabWidget->addTab(CreateHistoryTBWidget(), "History");
2141   fUITabWidget->setCurrentWidget(fHelpTBWidge    2141   fUITabWidget->setCurrentWidget(fHelpTBWidget);
2142                                                  2142 
2143   fUITabWidget->setTabToolTip(0, "Tree of sce    2143   fUITabWidget->setTabToolTip(0, "Tree of scene items");
2144   fUITabWidget->setTabToolTip(1, "Help widget    2144   fUITabWidget->setTabToolTip(1, "Help widget");
2145   fUITabWidget->setTabToolTip(2, "All command    2145   fUITabWidget->setTabToolTip(2, "All commands history");
2146   connect(fUITabWidget, SIGNAL(currentChanged    2146   connect(fUITabWidget, SIGNAL(currentChanged(int)), SLOT(ToolBoxActivated(int)));
2147                                                  2147 
2148   fUIDockWidget = new G4UIDockWidget("");        2148   fUIDockWidget = new G4UIDockWidget("");
2149   fUIDockWidget->setAllowedAreas(Qt::LeftDock    2149   fUIDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
2150                                                  2150 
2151   fUIDockWidget->setWidget(fUITabWidget);        2151   fUIDockWidget->setWidget(fUITabWidget);
2152                                                  2152 
2153   return fUIDockWidget;                          2153   return fUIDockWidget;
2154 }                                                2154 }
2155                                                  2155 
2156 QWidget* G4UIQt::CreateSceneTreeWidget()         2156 QWidget* G4UIQt::CreateSceneTreeWidget()
2157 {                                                2157 {
2158   fSceneTreeWidget = new QWidget();              2158   fSceneTreeWidget = new QWidget();
2159   auto layout = new QVBoxLayout();               2159   auto layout = new QVBoxLayout();
2160   fSceneTreeWidget->setLayout(layout);           2160   fSceneTreeWidget->setLayout(layout);
2161                                                  2161 
2162   fSceneTreeWidget->setVisible(false);           2162   fSceneTreeWidget->setVisible(false);
2163                                                  2163 
2164   return fSceneTreeWidget;                       2164   return fSceneTreeWidget;
2165 }                                                2165 }
2166                                                  2166 
2167 void G4UIQt::CreateViewerWidget()                2167 void G4UIQt::CreateViewerWidget()
2168 {                                                2168 {
2169   // Set layouts                                 2169   // Set layouts
2170                                                  2170 
2171   // clang-format off                            2171   // clang-format off
2172   SetStartPage(std::string("<table width='100    2172   SetStartPage(std::string("<table width='100%'><tr><td width='30%'></td><td><div ")+
2173                              "style='color: r    2173                              "style='color: rgb(140, 31, 31); font-size: xx-large; font-family: Garamond, serif; padding-bottom: 0px; font-weight: normal'>Geant4: "+
2174                              QApplication::ap    2174                              QApplication::applicationName ().toStdString()+
2175                              "</div></td><td     2175                              "</div></td><td width='40%'>&nbsp;<br/><i>http://cern.ch/geant4/</i></td></tr></table>"+
2176                              "<p>&nbsp;</p>"+    2176                              "<p>&nbsp;</p>"+
2177                              "<div style='bac    2177                              "<div style='background:#EEEEEE;'><b>Tooltips :</b><ul>"+
2178                              "<li><b>Start a     2178                              "<li><b>Start a new viewer :</b><br />"+
2179                              "<i>'/vis/open/.    2179                              "<i>'/vis/open/...'<br />"+
2180                              "For example '/v    2180                              "For example '/vis/open OGL'</i></li>"+
2181                              "<li><b>Execute     2181                              "<li><b>Execute a macro file :</b><br />"+
2182                              "<i>'/control/ex    2182                              "<i>'/control/execute my_macro_file'</i></li>"+
2183                              "</ul></div>"+      2183                              "</ul></div>"+
2184                                                  2184 
2185                              "<div style='bac    2185                              "<div style='background:#EEEEEE;'><b>Documentation :</b><ul>"+
2186                              "<li><b>Visualis    2186                              "<li><b>Visualisation publication :</b><br />"+
2187                              "<i><a href='htt    2187                              "<i><a href='http://www.worldscientific.com/doi/abs/10.1142/S1793962313400011'>The Geant4 Visualization System - A Multi-Driver Graphics System</b><br />,  Allison, J. et al., International Journal of Modeling, Simulation, and Scientific Computing, Vol. 4, Suppl. 1 (2013) 1340001</a>:<br/> http://www.worldscientific.com/doi/abs/10.1142/S1793962313400011</i></li>"+
2188                              "</ul></div>"+      2188                              "</ul></div>"+
2189                                                  2189 
2190                              "<div style='bac    2190                              "<div style='background:#EEEEEE;'><b>Getting Help :</b><ul>"+
2191                              "<li><b>If probl    2191                              "<li><b>If problems arise, try <a href='https://cern.ch/geant4-forum'>browsing the user forum</a> to see whether or not your problem has already been encountered.<br /> If it hasn't, you can post it and Geant4 developers will do their best to find a solution. This is also a good place to<br /> discuss Geant4 topics in general.</b> https://cern.ch/geant4-forum"+
2192                              "<li><b>Get a lo    2192                              "<li><b>Get a look at <a href='http://cern.ch/geant4/support'>Geant4 User support pages</a>: <i>http://cern.ch/geant4/support</i></b></li>"+
2193                              "</ul></div>"       2193                              "</ul></div>"
2194                              );                  2194                              );
2195   // clang-format on                             2195   // clang-format on
2196                                                  2196 
2197   // fill right splitter                         2197   // fill right splitter
2198   if (fViewerTabWidget == nullptr) {             2198   if (fViewerTabWidget == nullptr) {
2199 #if QT_VERSION < 0x060000                     << 
2200     fViewerTabWidget = new G4QTabWidget();       2199     fViewerTabWidget = new G4QTabWidget();
2201 #else                                         << 
2202     fViewerTabWidget = new QTabWidget();      << 
2203 #endif                                        << 
2204     fMainWindow->setCentralWidget(fViewerTabW    2200     fMainWindow->setCentralWidget(fViewerTabWidget);
2205     fViewerTabWidget->setTabsClosable(true);     2201     fViewerTabWidget->setTabsClosable(true);
2206                                                  2202 
2207     fViewerTabWidget->setUsesScrollButtons(tr    2203     fViewerTabWidget->setUsesScrollButtons(true);
2208                                                  2204 
2209     connect(fViewerTabWidget, SIGNAL(tabClose    2205     connect(fViewerTabWidget, SIGNAL(tabCloseRequested(int)),this, SLOT(TabCloseCallback(int)));
2210 #if QT_VERSION < 0x060000                     << 
2211     connect(fViewerTabWidget, SIGNAL(currentC    2206     connect(fViewerTabWidget, SIGNAL(currentChanged(int)), SLOT(UpdateTabWidget(int)));
2212 #else                                         << 
2213     connect(fViewerTabWidget, SIGNAL(currentC << 
2214 #endif                                        << 
2215   }                                              2207   }
2216                                                  2208 
2217   // set the QGLWidget size policy               2209   // set the QGLWidget size policy
2218   QSizePolicy policy = QSizePolicy(QSizePolic    2210   QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
2219   policy.setVerticalStretch(4);                  2211   policy.setVerticalStretch(4);
2220   fViewerTabWidget->setSizePolicy(policy);       2212   fViewerTabWidget->setSizePolicy(policy);
2221                                                  2213 
2222   fViewerTabWidget->setMinimumSize(40, 40);      2214   fViewerTabWidget->setMinimumSize(40, 40);
2223 }                                                2215 }
2224                                                  2216 
2225 /** Get the ViewerComponents ToolBox Widget      2217 /** Get the ViewerComponents ToolBox Widget
2226  */                                              2218  */
2227 QWidget* G4UIQt::GetSceneTreeWidget() { retur    2219 QWidget* G4UIQt::GetSceneTreeWidget() { return fSceneTreeWidget; }
2228                                                  2220 
2229 /** Get the Viewer properties  Widget            2221 /** Get the Viewer properties  Widget
2230  */                                              2222  */
2231 QWidget* G4UIQt::GetViewerPropertiesWidget()     2223 QWidget* G4UIQt::GetViewerPropertiesWidget()
2232 {                                                2224 {
2233   if (fViewerPropertiesDialog == nullptr) {      2225   if (fViewerPropertiesDialog == nullptr) {
2234     CreateViewerPropertiesDialog();              2226     CreateViewerPropertiesDialog();
2235   }                                              2227   }
2236   return fViewerPropertiesWidget;                2228   return fViewerPropertiesWidget;
2237 }                                                2229 }
2238                                                  2230 
2239 /** Get the Pick Widget                          2231 /** Get the Pick Widget
2240  */                                              2232  */
2241 QWidget* G4UIQt::GetPickInfosWidget()            2233 QWidget* G4UIQt::GetPickInfosWidget()
2242 {                                                2234 {
2243   if (fPickInfosDialog == nullptr) {             2235   if (fPickInfosDialog == nullptr) {
2244     CreatePickInfosDialog();                     2236     CreatePickInfosDialog();
2245   }                                              2237   }
2246   return fPickInfosWidget;                       2238   return fPickInfosWidget;
2247 }                                                2239 }
2248                                                  2240 
2249 /**   Add a new tab in the viewer                2241 /**   Add a new tab in the viewer
2250  */                                              2242  */
2251 G4bool G4UIQt::AddViewerTab(QWidget* aWidget,    2243 G4bool G4UIQt::AddViewerTab(QWidget* aWidget, std::string title)
2252 {                                                2244 {
2253   if (fViewerTabWidget == nullptr) {             2245   if (fViewerTabWidget == nullptr) {
2254     return false;                                2246     return false;
2255   }                                              2247   }
2256   fViewerTabWidget->addTab(aWidget, title.c_s    2248   fViewerTabWidget->addTab(aWidget, title.c_str());
2257                                                  2249 
2258   return true;                                   2250   return true;
2259 }                                                2251 }
2260                                                  2252 
2261 /**   Add a new tab in the viewer                2253 /**   Add a new tab in the viewer
2262  */                                              2254  */
2263 G4bool G4UIQt::AddViewerTabFromFile(std::stri    2255 G4bool G4UIQt::AddViewerTabFromFile(std::string fileName, std::string title)
2264 {                                                2256 {
2265   if (fViewerTabWidget == nullptr) {             2257   if (fViewerTabWidget == nullptr) {
2266     return false;                                2258     return false;
2267   }                                              2259   }
2268                                                  2260 
2269   G4UImanager* UI = G4UImanager::GetUIpointer    2261   G4UImanager* UI = G4UImanager::GetUIpointer();
2270   if (UI == nullptr) return false;               2262   if (UI == nullptr) return false;
2271   std::ifstream file(UI->FindMacroPath(fileNa    2263   std::ifstream file(UI->FindMacroPath(fileName.c_str()).data());
2272   if (file) {                                    2264   if (file) {
2273     std::string content((std::istreambuf_iter    2265     std::string content((std::istreambuf_iterator<char>(file)), (std::istreambuf_iterator<char>()));
2274                                                  2266 
2275     auto text = new QTextEdit();                 2267     auto text = new QTextEdit();
2276     text->setAcceptRichText(true);               2268     text->setAcceptRichText(true);
2277     text->setContentsMargins(5, 5, 5, 5);        2269     text->setContentsMargins(5, 5, 5, 5);
2278     text->setText(QString("<pre>") + content.    2270     text->setText(QString("<pre>") + content.c_str() + "</pre>");
2279     text->setReadOnly(true);                     2271     text->setReadOnly(true);
2280     fViewerTabWidget->addTab(text, title.c_st    2272     fViewerTabWidget->addTab(text, title.c_str());
2281   }                                              2273   }
2282   else {                                         2274   else {
2283     return false;                                2275     return false;
2284   }                                              2276   }
2285   return true;                                   2277   return true;
2286 }                                                2278 }
2287                                                  2279 
2288 /**   Add a new tab widget.                      2280 /**   Add a new tab widget.
2289   Create the tab if it was not done              2281   Create the tab if it was not done
2290 */                                               2282 */
2291 G4bool G4UIQt::AddTabWidget(QWidget* aWidget,    2283 G4bool G4UIQt::AddTabWidget(QWidget* aWidget, QString name)
2292 {                                                2284 {
2293 #if QT_VERSION < 0x060000                     << 
2294   if (fViewerTabWidget == nullptr) {             2285   if (fViewerTabWidget == nullptr) {
2295     CreateViewerWidget();                        2286     CreateViewerWidget();
2296   }                                              2287   }
2297 #endif                                        << 
2298                                                  2288 
2299   if (aWidget == nullptr) {                      2289   if (aWidget == nullptr) {
2300     return false;                                2290     return false;
2301   }                                              2291   }
2302 #if QT_VERSION < 0x060000                     << 
2303   // Has to be added before we put it into th    2292   // Has to be added before we put it into the fViewerTabWidget widget
2304   aWidget->setParent(fViewerTabWidget);  // W    2293   aWidget->setParent(fViewerTabWidget);  // Will create in some cases widget outside
2305   // of UI for a really short moment             2294   // of UI for a really short moment
2306                                                  2295 
2307   fViewerTabWidget->addTab(aWidget, name);       2296   fViewerTabWidget->addTab(aWidget, name);
2308                                                  2297 
2309   fViewerTabWidget->setCurrentIndex(fViewerTa    2298   fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count() - 1);
2310                                                  2299 
2311   // Set visible                                 2300   // Set visible
2312   fViewerTabWidget->setLastTabCreated(fViewer    2301   fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
2313 #else                                         << 
2314   //G.Barrand: disconnect temporarily the sig << 
2315   //           if adding a viewer, the Update << 
2316   //           issue an ERROR message since t << 
2317   //           at this moment (see the logic  << 
2318   QObject::disconnect(fViewerTabWidget, SIGNA << 
2319   fViewerTabWidget->addTab(aWidget, name);    << 
2320   fViewerTabWidget->setCurrentIndex(fViewerTa << 
2321   QObject::connect(fViewerTabWidget, SIGNAL(c << 
2322 #endif                                        << 
2323                                                  2302 
2324   // Not the good solution, but ensure that t    2303   // Not the good solution, but ensure that the help tree is correctly build when launching a viewer
2325   // It should be done by a notification when    2304   // It should be done by a notification when adding a command, but that's nit done yet
2326   // (Geant4.10.1)                               2305   // (Geant4.10.1)
2327   FillHelpTree();                                2306   FillHelpTree();
2328                                                  2307 
2329   return true;                                   2308   return true;
2330 }                                                2309 }
2331                                                  2310 
2332 void G4UIQt::SetStartPage(const std::string&     2311 void G4UIQt::SetStartPage(const std::string& text)
2333 {                                                2312 {
2334   if (! text.empty()) {                          2313   if (! text.empty()) {
2335     fDefaultViewerFirstPageHTMLText = text;      2314     fDefaultViewerFirstPageHTMLText = text;
2336   }                                              2315   }
2337   if (fStartPage == nullptr) {                   2316   if (fStartPage == nullptr) {
2338     fStartPage = new QTextBrowser();             2317     fStartPage = new QTextBrowser();
2339     fStartPage->setContentsMargins(5, 5, 5, 5    2318     fStartPage->setContentsMargins(5, 5, 5, 5);
2340     fStartPage->setReadOnly(true);               2319     fStartPage->setReadOnly(true);
2341   }                                              2320   }
2342   fStartPage->setOpenExternalLinks(true);        2321   fStartPage->setOpenExternalLinks(true);
2343   fStartPage->setHtml(fDefaultViewerFirstPage    2322   fStartPage->setHtml(fDefaultViewerFirstPageHTMLText.c_str());
2344 }                                                2323 }
2345                                                  2324 
2346 #if QT_VERSION < 0x060000                     << 
2347 void G4UIQt::UpdateTabWidget(int tabNumber)      2325 void G4UIQt::UpdateTabWidget(int tabNumber)
2348 {                                                2326 {
2349   if (fViewerTabWidget == nullptr) {             2327   if (fViewerTabWidget == nullptr) {
2350     fViewerTabWidget = new G4QTabWidget;         2328     fViewerTabWidget = new G4QTabWidget;
2351   }                                              2329   }
2352                                                  2330 
2353   fViewerTabWidget->setCurrentIndex(tabNumber    2331   fViewerTabWidget->setCurrentIndex(tabNumber);
2354                                                  2332 
2355   // Send this signal to unblock graphic upda    2333   // Send this signal to unblock graphic updates !
2356   fViewerTabWidget->setTabSelected(false);       2334   fViewerTabWidget->setTabSelected(false);
2357                                                  2335 
2358   fViewerTabWidget->setVisible(true);            2336   fViewerTabWidget->setVisible(true);
2359                                                  2337 
2360   // This will send a paintEvent to OGL Viewe    2338   // This will send a paintEvent to OGL Viewers
2361   fViewerTabWidget->setTabSelected(true);        2339   fViewerTabWidget->setTabSelected(true);
2362 }                                                2340 }
2363 #else                                         << 
2364 void G4UIQt::UpdateTabWidget(int)             << 
2365 {                                             << 
2366   //G.Barrand: have the Apply("vis/viewer/sel << 
2367   //           in a G4QTabWidget::paintEvent( << 
2368   //           adequate Qt mechanism to do th << 
2369   if (fViewerTabWidget->currentWidget() != nu << 
2370     auto edit = dynamic_cast<QTextEdit*>(fVie << 
2371     if (edit == nullptr) {                    << 
2372       QString text = fViewerTabWidget->tabTex << 
2373       QString paramSelect = QString("/vis/vie << 
2374       G4UImanager::GetUIpointer()->ApplyComma << 
2375     }                                         << 
2376   }                                           << 
2377 }                                             << 
2378 #endif                                        << 
2379                                                  2341 
2380 /** Send resize event to all tabs                2342 /** Send resize event to all tabs
2381  */                                              2343  */
2382 void G4UIQt::ResizeTabWidget(QResizeEvent* e)    2344 void G4UIQt::ResizeTabWidget(QResizeEvent* e)
2383 {                                                2345 {
2384   if (fViewerTabWidget != nullptr) {             2346   if (fViewerTabWidget != nullptr) {
2385     for (G4int a = 0; a < fViewerTabWidget->c    2347     for (G4int a = 0; a < fViewerTabWidget->count(); a++) {
2386       fViewerTabWidget->widget(a)->resize(e->    2348       fViewerTabWidget->widget(a)->resize(e->size());
2387     }                                            2349     }
2388   }                                              2350   }
2389 }                                                2351 }
2390                                                  2352 
2391 /**   Start the Qt main loop                     2353 /**   Start the Qt main loop
2392  */                                              2354  */
2393 G4UIsession* G4UIQt::SessionStart()              2355 G4UIsession* G4UIQt::SessionStart()
2394 {                                                2356 {
2395   G4Qt* interactorManager = G4Qt::getInstance    2357   G4Qt* interactorManager = G4Qt::getInstance();
2396   Prompt("Session :");                           2358   Prompt("Session :");
2397   exitSession = false;                           2359   exitSession = false;
2398                                                  2360 
2399   QCoreApplication::sendPostedEvents();          2361   QCoreApplication::sendPostedEvents();
2400                                                  2362 
2401   fMainWindow->setVisible(true);                 2363   fMainWindow->setVisible(true);
2402                                                  2364 
2403   if (fDefaultIcons) {                           2365   if (fDefaultIcons) {
2404     fToolbarApp->setVisible(true);               2366     fToolbarApp->setVisible(true);
2405   }                                              2367   }
2406   else {                                         2368   else {
2407     // Set not visible until session start       2369     // Set not visible until session start
2408     fToolbarApp->setVisible(false);              2370     fToolbarApp->setVisible(false);
2409   }                                              2371   }
2410   // Rebuild help tree (new command could be     2372   // Rebuild help tree (new command could be registered)
2411   FillHelpTree();                                2373   FillHelpTree();
2412                                                  2374 
2413   // Rebuild command completion (new command     2375   // Rebuild command completion (new command could be registered)
2414   UpdateCommandCompleter();                      2376   UpdateCommandCompleter();
2415                                                  2377 
2416   // Set event filters                           2378   // Set event filters
2417   fHistoryTBTableList->installEventFilter(thi    2379   fHistoryTBTableList->installEventFilter(this);
2418   fCommandArea->installEventFilter(this);        2380   fCommandArea->installEventFilter(this);
2419                                                  2381 
2420   // Focus on command line                       2382   // Focus on command line
2421   fCommandArea->setFocus();                      2383   fCommandArea->setFocus();
2422                                                  2384 
2423   interactorManager->DisableSecondaryLoop();     2385   interactorManager->DisableSecondaryLoop();  // TO KEEP
2424   if ((QApplication*)interactorManager->GetMa    2386   if ((QApplication*)interactorManager->GetMainInteractor() != nullptr)
2425     ((QApplication*)interactorManager->GetMai    2387     ((QApplication*)interactorManager->GetMainInteractor())->exec();
2426                                                  2388 
2427   interactorManager->EnableSecondaryLoop();      2389   interactorManager->EnableSecondaryLoop();
2428   return this;                                   2390   return this;
2429 }                                                2391 }
2430                                                  2392 
2431 /**   Display the prompt in the prompt area      2393 /**   Display the prompt in the prompt area
2432    @param aPrompt : string to display as the     2394    @param aPrompt : string to display as the promt label
2433 */                                               2395 */
2434 void G4UIQt::Prompt(const G4String& aPrompt)  << 2396 void G4UIQt::Prompt(G4String aPrompt)
2435 {                                                2397 {
2436   if (aPrompt == nullptr) return;                2398   if (aPrompt == nullptr) return;
2437                                                  2399 
2438   fCommandLabel->setText((char*)aPrompt.data(    2400   fCommandLabel->setText((char*)aPrompt.data());
2439 }                                                2401 }
2440                                                  2402 
2441 void G4UIQt::SessionTerminate()                  2403 void G4UIQt::SessionTerminate()
2442 {                                                2404 {
2443   G4Qt* interactorManager = G4Qt::getInstance    2405   G4Qt* interactorManager = G4Qt::getInstance();
2444   fMainWindow->close();                          2406   fMainWindow->close();
2445   ((QApplication*)interactorManager->GetMainI    2407   ((QApplication*)interactorManager->GetMainInteractor())->exit();
2446 }                                                2408 }
2447                                                  2409 
2448 /**                                              2410 /**
2449    Called by intercoms/src/G4UImanager.cc<br>    2411    Called by intercoms/src/G4UImanager.cc<br>
2450    Called by visualization/management/src/G4V    2412    Called by visualization/management/src/G4VisCommands.cc with "EndOfEvent" argument<br>
2451    It have to pause the session command termi    2413    It have to pause the session command terminal.<br>
2452    Call SecondaryLoop to wait for exit event<    2414    Call SecondaryLoop to wait for exit event<br>
2453    @param aState                                 2415    @param aState
2454    @see : G4VisCommandReviewKeptEvents::SetNe    2416    @see : G4VisCommandReviewKeptEvents::SetNewValue
2455 */                                               2417 */
2456 void G4UIQt::PauseSessionStart(const G4String    2418 void G4UIQt::PauseSessionStart(const G4String& aState)
2457 {                                                2419 {
2458   if (aState == nullptr) return;                 2420   if (aState == nullptr) return;
2459                                                  2421 
2460   if (aState == "G4_pause> ") {  // TO KEEP      2422   if (aState == "G4_pause> ") {  // TO KEEP
2461     SecondaryLoop("Pause, type continue to ex    2423     SecondaryLoop("Pause, type continue to exit this state");  // TO KEEP
2462   }  // TO KEEP                                  2424   }  // TO KEEP
2463                                                  2425 
2464   if (aState == "EndOfEvent") {  // TO KEEP      2426   if (aState == "EndOfEvent") {  // TO KEEP
2465     // Picking with feed back in event data D    2427     // Picking with feed back in event data Done here !!!
2466     SecondaryLoop("End of event, type continu    2428     SecondaryLoop("End of event, type continue to exit this state");  // TO KEEP
2467   }  // TO KEEP                                  2429   }  // TO KEEP
2468 }                                                2430 }
2469                                                  2431 
2470 /**                                              2432 /**
2471    Begin the secondary loop                      2433    Begin the secondary loop
2472    @param a_prompt : label to display as the     2434    @param a_prompt : label to display as the prompt label
2473  */                                              2435  */
2474 void G4UIQt::SecondaryLoop(const G4String& aP << 2436 void G4UIQt::SecondaryLoop(G4String aPrompt)
2475 {                                                2437 {
2476   if (aPrompt == nullptr) return;                2438   if (aPrompt == nullptr) return;
2477                                                  2439 
2478   G4Qt* interactorManager = G4Qt::getInstance    2440   G4Qt* interactorManager = G4Qt::getInstance();  // TO KEEP ?
2479   Prompt(aPrompt);  // TO KEEP                   2441   Prompt(aPrompt);  // TO KEEP
2480   exitPause = false;  // TO KEEP                 2442   exitPause = false;  // TO KEEP
2481   while (true) {                                 2443   while (true) {
2482     ((QApplication*)interactorManager)->proce    2444     ((QApplication*)interactorManager)->processEvents(QEventLoop::WaitForMoreEvents);
2483     if (exitPause) break;  // TO KEEP            2445     if (exitPause) break;  // TO KEEP
2484   }  // TO KEEP                                  2446   }  // TO KEEP
2485   Prompt("Session :");  // TO KEEP               2447   Prompt("Session :");  // TO KEEP
2486 }                                                2448 }
2487                                                  2449 
2488 #ifdef G4MULTITHREADED                           2450 #ifdef G4MULTITHREADED
2489 #  include "G4AutoLock.hh"                       2451 #  include "G4AutoLock.hh"
2490 #  include "G4Threading.hh"                      2452 #  include "G4Threading.hh"
2491 namespace                                        2453 namespace
2492 {                                                2454 {
2493   G4Mutex ReceiveMutex = G4MUTEX_INITIALIZER;    2455   G4Mutex ReceiveMutex = G4MUTEX_INITIALIZER;
2494 }  // namespace                                  2456 }  // namespace
2495 #endif                                           2457 #endif
2496                                                  2458 
2497 /**                                              2459 /**
2498    Receive a debug log message from Geant4. W    2460    Receive a debug log message from Geant4. We have to display it in the cout zone
2499    @param aString : label to add in the displ    2461    @param aString : label to add in the display area
2500    @return 0                                     2462    @return 0
2501 */                                               2463 */
2502 G4int G4UIQt::ReceiveG4debug(const G4String&     2464 G4int G4UIQt::ReceiveG4debug(const G4String& aString)
2503 {                                                2465 {
2504   if (aString.empty()) return 0;                 2466   if (aString.empty()) return 0;
2505                                                  2467 
2506 #ifdef G4MULTITHREADED                           2468 #ifdef G4MULTITHREADED
2507   G4AutoLock al(&ReceiveMutex);                  2469   G4AutoLock al(&ReceiveMutex);
2508 #endif                                           2470 #endif
2509                                                  2471 
2510   // A workaround so that output is not lost     2472   // A workaround so that output is not lost after crash or G4Exception.
2511   // The "workaround" is to make sure all flu    2473   // The "workaround" is to make sure all flushed output appears on
2512   // the terminal after a crash, because even    2474   // the terminal after a crash, because even flushed output can
2513   // get lost in the Qt UI system.               2475   // get lost in the Qt UI system.
2514   // But...it seems workers write to std::cou    2476   // But...it seems workers write to std::cout/cerr anyway (is that a bug?),
2515   // so limit this to the master thread          2477   // so limit this to the master thread
2516 #ifdef G4MULTITHREADED                           2478 #ifdef G4MULTITHREADED
2517   if (G4Threading::IsMasterThread())             2479   if (G4Threading::IsMasterThread())
2518 #endif                                           2480 #endif
2519     std::cout << aString << std::flush;          2481     std::cout << aString << std::flush;
2520                                                  2482 
2521   G4String aStringWithStyle;                     2483   G4String aStringWithStyle;
2522   // aString has a \n on the end (maybe it co    2484   // aString has a \n on the end (maybe it comes from G4endl or from the
2523   // Enter key on the command line) - ignore     2485   // Enter key on the command line) - ignore it. That’s why
2524   // i < aString.length() - 1                    2486   // i < aString.length() - 1
2525   // But other \n need to be translated to an    2487   // But other \n need to be translated to an HTML newline.
2526   // Similarly, spaces need to be translated     2488   // Similarly, spaces need to be translated to an HTML "non-breaking space".
2527   // Tabs (\t) are more tricky since the numb    2489   // Tabs (\t) are more tricky since the number of equivalent spaces depends
2528   // on how many characters precede it. Proba    2490   // on how many characters precede it. Probably needs an HTML table. For now
2529   // we replace \t with four spaces.             2491   // we replace \t with four spaces.
2530   for (G4int i = 0; i < (G4int)aString.length    2492   for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
2531     if (aString[i] == '\n') {                    2493     if (aString[i] == '\n') {
2532       aStringWithStyle += "<br>";                2494       aStringWithStyle += "<br>";
2533     }                                            2495     }
2534     else if (aString[i] == ' ') {                2496     else if (aString[i] == ' ') {
2535       aStringWithStyle += "&nbsp;";              2497       aStringWithStyle += "&nbsp;";
2536     }                                            2498     }
2537     else if (aString[i] == '\t') {               2499     else if (aString[i] == '\t') {
2538       aStringWithStyle += "&nbsp;&nbsp;&nbsp;    2500       aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
2539     }                                            2501     }
2540     else if (aString[i] == '<') {                2502     else if (aString[i] == '<') {
2541       aStringWithStyle += "&lt;";                2503       aStringWithStyle += "&lt;";
2542     }                                            2504     }
2543     else {                                       2505     else {
2544       aStringWithStyle += aString[i];            2506       aStringWithStyle += aString[i];
2545     }                                            2507     }
2546   }                                              2508   }
2547   if (fOutputStyles["debug"].fixed) {            2509   if (fOutputStyles["debug"].fixed) {
2548     aStringWithStyle = "<span style='font-fam    2510     aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
2549   }                                              2511   }
2550   else {                                         2512   else {
2551     aStringWithStyle = "<span>" + aStringWith    2513     aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
2552   }                                              2514   }
2553                                                  2515 
2554   // Add to string                               2516   // Add to string
2555   G4UIOutputString txt =                         2517   G4UIOutputString txt =
2556     G4UIOutputString(QString((char*)aStringWi    2518     G4UIOutputString(QString((char*)aStringWithStyle.data()), GetThreadPrefix());
2557   fG4OutputString.push_back(txt);                2519   fG4OutputString.push_back(txt);
2558                                                  2520 
2559 #ifdef G4MULTITHREADED                           2521 #ifdef G4MULTITHREADED
2560   QString result = FilterOutput(txt, fThreads    2522   QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
2561 #else                                            2523 #else
2562   QString result = FilterOutput(txt, "", fCou    2524   QString result = FilterOutput(txt, "", fCoutFilter->text());
2563 #endif                                           2525 #endif
2564                                                  2526 
2565   if (result.isEmpty()) {                        2527   if (result.isEmpty()) {
2566     return 0;                                    2528     return 0;
2567   }                                              2529   }
2568                                                  2530 
2569   if (fOutputStyles["debug"].highlight) {        2531   if (fOutputStyles["debug"].highlight) {
2570     QPalette pal;                                2532     QPalette pal;
2571     result = QString("<span style='background    2533     result = QString("<span style='background:") + pal.link().color().name() + ";'>&nbsp;</span>" +
2572              "<span style='background: Pink;'    2534              "<span style='background: Pink;'> " + result + "</span>";
2573   }                                              2535   }
2574   result = QString("<font color=\"Green\">")     2536   result = QString("<font color=\"Green\">") + result + QString("</font>");
2575                                                  2537 
2576   fCoutTBTextArea->append(result);               2538   fCoutTBTextArea->append(result);
2577   fCoutTBTextArea->ensureCursorVisible();        2539   fCoutTBTextArea->ensureCursorVisible();
2578                                                  2540 
2579 #ifdef G4MULTITHREADED                           2541 #ifdef G4MULTITHREADED
2580   UpdateCoutThreadFilter();                      2542   UpdateCoutThreadFilter();
2581 #endif                                           2543 #endif
2582                                                  2544 
2583   return 0;                                      2545   return 0;
2584 }                                                2546 }
2585                                                  2547 
2586 /**                                              2548 /**
2587    Receive a cout from Geant4. We have to dis    2549    Receive a cout from Geant4. We have to display it in the cout zone
2588    @param aString : label to add in the displ    2550    @param aString : label to add in the display area
2589    @return 0                                     2551    @return 0
2590 */                                               2552 */
2591 G4int G4UIQt::ReceiveG4cout(const G4String& a    2553 G4int G4UIQt::ReceiveG4cout(const G4String& aString)
2592 {                                                2554 {
2593   if (aString.empty()) return 0;                 2555   if (aString.empty()) return 0;
2594                                                  2556 
2595   // Try to be smart :                           2557   // Try to be smart :
2596   // "*** This is just a warning message. ***    2558   // "*** This is just a warning message. ***"
2597   if (G4StrUtil::contains(aString, "*** This     2559   if (G4StrUtil::contains(aString, "*** This is just a warning message. ***")) {
2598     return ReceiveG4cerr(aString);               2560     return ReceiveG4cerr(aString);
2599   }                                              2561   }
2600                                                  2562 
2601 #ifdef G4MULTITHREADED                           2563 #ifdef G4MULTITHREADED
2602   G4AutoLock al(&ReceiveMutex);                  2564   G4AutoLock al(&ReceiveMutex);
2603 #endif                                           2565 #endif
2604                                                  2566 
2605   // A workaround so that output is not lost     2567   // A workaround so that output is not lost after crash or G4Exception.
2606   // The "workaround" is to make sure all flu    2568   // The "workaround" is to make sure all flushed output appears on
2607   // the terminal after a crash, because even    2569   // the terminal after a crash, because even flushed output can
2608   // get lost in the Qt UI system.               2570   // get lost in the Qt UI system.
2609   // But...it seems workers write to std::cou    2571   // But...it seems workers write to std::cout/cerr anyway (is that a bug?),
2610   // so limit this to the master thread          2572   // so limit this to the master thread
2611 #ifdef G4MULTITHREADED                           2573 #ifdef G4MULTITHREADED
2612   if (G4Threading::IsMasterThread())             2574   if (G4Threading::IsMasterThread())
2613 #endif                                           2575 #endif
2614     std::cout << aString << std::flush;          2576     std::cout << aString << std::flush;
2615                                                  2577 
2616   G4String aStringWithStyle;                     2578   G4String aStringWithStyle;
2617   // aString has a \n on the end (maybe it co    2579   // aString has a \n on the end (maybe it comes from G4endl or from the
2618   // Enter key on the command line) - ignore     2580   // Enter key on the command line) - ignore it. That’s why
2619   // i < aString.length() - 1                    2581   // i < aString.length() - 1
2620   // But other \n need to be translated to an    2582   // But other \n need to be translated to an HTML newline.
2621   // Similarly, spaces need to be translated     2583   // Similarly, spaces need to be translated to an HTML "non-breaking space".
2622   // Tabs (\t) are more tricky since the numb    2584   // Tabs (\t) are more tricky since the number of equivalent spaces depends
2623   // on how many characters precede it. Proba    2585   // on how many characters precede it. Probably needs an HTML table. For now
2624   // we replace \t with four spaces.             2586   // we replace \t with four spaces.
2625   for (G4int i = 0; i < (G4int)aString.length    2587   for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
2626     if (aString[i] == '\n') {                    2588     if (aString[i] == '\n') {
2627       aStringWithStyle += "<br>";                2589       aStringWithStyle += "<br>";
2628     }                                            2590     }
2629     else if (aString[i] == ' ') {                2591     else if (aString[i] == ' ') {
2630       aStringWithStyle += "&nbsp;";              2592       aStringWithStyle += "&nbsp;";
2631     }                                            2593     }
2632     else if (aString[i] == '\t') {               2594     else if (aString[i] == '\t') {
2633       aStringWithStyle += "&nbsp;&nbsp;&nbsp;    2595       aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
2634     }                                            2596     }
2635     else if (aString[i] == '<') {                2597     else if (aString[i] == '<') {
2636       aStringWithStyle += "&lt;";                2598       aStringWithStyle += "&lt;";
2637     }                                            2599     }
2638     else {                                       2600     else {
2639       aStringWithStyle += aString[i];            2601       aStringWithStyle += aString[i];
2640     }                                            2602     }
2641   }                                              2603   }
2642   if (fOutputStyles["cout"].fixed) {             2604   if (fOutputStyles["cout"].fixed) {
2643     aStringWithStyle = "<span style='font-fam    2605     aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
2644   }                                              2606   }
2645   else {                                         2607   else {
2646     aStringWithStyle = "<span>" + aStringWith    2608     aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
2647   }                                              2609   }
2648                                                  2610 
2649   // Add to string                               2611   // Add to string
2650   G4UIOutputString txt =                         2612   G4UIOutputString txt =
2651     G4UIOutputString(QString((char*)aStringWi    2613     G4UIOutputString(QString((char*)aStringWithStyle.data()), GetThreadPrefix());
2652   fG4OutputString.push_back(txt);                2614   fG4OutputString.push_back(txt);
2653                                                  2615 
2654 #ifdef G4MULTITHREADED                           2616 #ifdef G4MULTITHREADED
2655   QString result = FilterOutput(txt, fThreads    2617   QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
2656 #else                                            2618 #else
2657   QString result = FilterOutput(txt, "", fCou    2619   QString result = FilterOutput(txt, "", fCoutFilter->text());
2658 #endif                                           2620 #endif
2659                                                  2621 
2660   if (result.isEmpty()) {                        2622   if (result.isEmpty()) {
2661     return 0;                                    2623     return 0;
2662   }                                              2624   }
2663                                                  2625 
2664   G4UImanager* UI = G4UImanager::GetUIpointer    2626   G4UImanager* UI = G4UImanager::GetUIpointer();
2665   if (fOutputStyles["cout"].highlight) {         2627   if (fOutputStyles["cout"].highlight) {
2666     if (! UI->IsLastCommandOutputTreated()) {    2628     if (! UI->IsLastCommandOutputTreated()) {
2667       QPalette pal;                              2629       QPalette pal;
2668       result = QString("<span style='backgrou    2630       result = QString("<span style='background:") + pal.link().color().name() +
2669                ";'>&nbsp;</span>" + "<span st    2631                ";'>&nbsp;</span>" + "<span style='background:" + pal.highlight().color().name() +
2670                ";'> " + result + "</span>";      2632                ";'> " + result + "</span>";
2671     }                                            2633     }
2672   }                                              2634   }
2673   UI->SetLastCommandOutputTreated();             2635   UI->SetLastCommandOutputTreated();
2674                                                  2636 
2675   fCoutTBTextArea->append(result);               2637   fCoutTBTextArea->append(result);
2676   fCoutTBTextArea->ensureCursorVisible();        2638   fCoutTBTextArea->ensureCursorVisible();
2677                                                  2639 
2678 #ifdef G4MULTITHREADED                           2640 #ifdef G4MULTITHREADED
2679   UpdateCoutThreadFilter();                      2641   UpdateCoutThreadFilter();
2680 #endif                                           2642 #endif
2681                                                  2643 
2682   // reset error stack                           2644   // reset error stack
2683   fLastErrMessage = aString;                     2645   fLastErrMessage = aString;
2684   return 0;                                      2646   return 0;
2685 }                                                2647 }
2686                                                  2648 
2687 /**                                              2649 /**
2688    Receive a cerr from Geant4. We have to dis    2650    Receive a cerr from Geant4. We have to display it in the cout zone
2689    @param aString : label to add in the displ    2651    @param aString : label to add in the display area
2690    @return 0                                     2652    @return 0
2691 */                                               2653 */
2692 G4int G4UIQt::ReceiveG4cerr(const G4String& a    2654 G4int G4UIQt::ReceiveG4cerr(const G4String& aString)
2693 {                                                2655 {
2694   if (aString.empty()) return 0;                 2656   if (aString.empty()) return 0;
2695                                                  2657 
2696 #ifdef G4MULTITHREADED                           2658 #ifdef G4MULTITHREADED
2697   G4AutoLock al(&ReceiveMutex);                  2659   G4AutoLock al(&ReceiveMutex);
2698 #endif                                           2660 #endif
2699                                                  2661 
2700   // A workaround so that output is not lost     2662   // A workaround so that output is not lost after crash or G4Exception.
2701   // The "workaround" is to make sure all flu    2663   // The "workaround" is to make sure all flushed output appears on
2702   // the terminal after a crash, because even    2664   // the terminal after a crash, because even flushed output can
2703   // get lost in the Qt UI system.               2665   // get lost in the Qt UI system.
2704   // But...it seems workers write to std::cou    2666   // But...it seems workers write to std::cout/cerr anyway (is that a bug?),
2705   // so limit this to the master thread          2667   // so limit this to the master thread
2706 #ifdef G4MULTITHREADED                           2668 #ifdef G4MULTITHREADED
2707   if (G4Threading::IsMasterThread())             2669   if (G4Threading::IsMasterThread())
2708 #endif                                           2670 #endif
2709     std::cerr << aString << std::flush;          2671     std::cerr << aString << std::flush;
2710                                                  2672 
2711   G4String aStringWithStyle;                     2673   G4String aStringWithStyle;
2712   // aString has a \n on the end (maybe it co    2674   // aString has a \n on the end (maybe it comes from G4endl or from the
2713   // Enter key on the command line) - ignore     2675   // Enter key on the command line) - ignore it. That’s why
2714   // i < aString.length() - 1                    2676   // i < aString.length() - 1
2715   // But other \n need to be translated to an    2677   // But other \n need to be translated to an HTML newline.
2716   // Similarly, spaces need to be translated     2678   // Similarly, spaces need to be translated to an HTML "non-breaking space".
2717   // Tabs (\t) are more tricky since the numb    2679   // Tabs (\t) are more tricky since the number of equivalent spaces depends
2718   // on how many characters precede it. Proba    2680   // on how many characters precede it. Probably needs an HTML table. For now
2719   // we replace \t with four spaces.             2681   // we replace \t with four spaces.
2720   for (G4int i = 0; i < (G4int)aString.length    2682   for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
2721     if (aString[i] == '\n') {                    2683     if (aString[i] == '\n') {
2722       aStringWithStyle += "<br>";                2684       aStringWithStyle += "<br>";
2723     }                                            2685     }
2724     else if (aString[i] == ' ') {                2686     else if (aString[i] == ' ') {
2725       aStringWithStyle += "&nbsp;";              2687       aStringWithStyle += "&nbsp;";
2726     }                                            2688     }
2727     else if (aString[i] == '\t') {               2689     else if (aString[i] == '\t') {
2728       aStringWithStyle += "&nbsp;&nbsp;&nbsp;    2690       aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
2729     }                                            2691     }
2730     else if (aString[i] == '<') {                2692     else if (aString[i] == '<') {
2731       aStringWithStyle += "&lt;";                2693       aStringWithStyle += "&lt;";
2732     }                                            2694     }
2733     else {                                       2695     else {
2734       aStringWithStyle += aString[i];            2696       aStringWithStyle += aString[i];
2735     }                                            2697     }
2736   }                                              2698   }
2737   if (fOutputStyles["cerr"].fixed) {             2699   if (fOutputStyles["cerr"].fixed) {
2738     aStringWithStyle = "<span style='font-fam    2700     aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
2739   }                                              2701   }
2740   else {                                         2702   else {
2741     aStringWithStyle = "<span>" + aStringWith    2703     aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
2742   }                                              2704   }
2743                                                  2705 
2744   // Add to string                               2706   // Add to string
2745                                                  2707 
2746   G4UIOutputString txt =                         2708   G4UIOutputString txt =
2747     G4UIOutputString(QString((char*)aStringWi    2709     G4UIOutputString(QString((char*)aStringWithStyle.data()).trimmed(), GetThreadPrefix(), "error");
2748   fG4OutputString.push_back(txt);                2710   fG4OutputString.push_back(txt);
2749                                                  2711 
2750 #ifdef G4MULTITHREADED                           2712 #ifdef G4MULTITHREADED
2751   QString result = FilterOutput(txt, fThreads    2713   QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
2752 #else                                            2714 #else
2753   QString result = FilterOutput(txt, "", fCou    2715   QString result = FilterOutput(txt, "", fCoutFilter->text());
2754 #endif                                           2716 #endif
2755   if (result.isEmpty()) {                        2717   if (result.isEmpty()) {
2756     return 0;                                    2718     return 0;
2757   }                                              2719   }
2758                                                  2720 
2759   // Suppress space, \n,\t,\r...                 2721   // Suppress space, \n,\t,\r...
2760   if (QString(aString.data()).trimmed() != ""    2722   if (QString(aString.data()).trimmed() != "") {
2761     if ((G4StateManager::GetStateManager()->G    2723     if ((G4StateManager::GetStateManager()->GetCurrentState() == G4State_Abort) ||
2762         (G4StateManager::GetStateManager()->G    2724         (G4StateManager::GetStateManager()->GetCurrentState() == G4State_Quit))
2763     {                                            2725     {
2764       // In case of Abort or Quit, the useful    2726       // In case of Abort or Quit, the useful error message should be in the last error message !
2765       fLastErrMessage += "\n" + aString;         2727       fLastErrMessage += "\n" + aString;
2766       QString criticalMessage = fLastErrMessa    2728       QString criticalMessage = fLastErrMessage.data();
2767       criticalMessage = criticalMessage.toHtm    2729       criticalMessage = criticalMessage.toHtmlEscaped();
2768       QMessageBox::critical(fMainWindow, "Err    2730       QMessageBox::critical(fMainWindow, "Error", QString(fLastErrMessage));
2769     }                                            2731     }
2770   }                                              2732   }
2771   fCoutTBTextArea->append(QString("<font colo    2733   fCoutTBTextArea->append(QString("<font color=\"Red\">") + result + QString("</font>"));
2772   fCoutTBTextArea->ensureCursorVisible();        2734   fCoutTBTextArea->ensureCursorVisible();
2773                                                  2735 
2774   if (QString(aString.data()).trimmed() != ""    2736   if (QString(aString.data()).trimmed() != "") {
2775     fLastErrMessage += aString;                  2737     fLastErrMessage += aString;
2776   }                                              2738   }
2777 #ifdef G4MULTITHREADED                           2739 #ifdef G4MULTITHREADED
2778   UpdateCoutThreadFilter();                      2740   UpdateCoutThreadFilter();
2779 #endif                                           2741 #endif
2780   return 0;                                      2742   return 0;
2781 }                                                2743 }
2782                                                  2744 
2783 G4String G4UIQt::GetThreadPrefix()               2745 G4String G4UIQt::GetThreadPrefix()
2784 {                                                2746 {
2785   G4String threadPrefix = "";                    2747   G4String threadPrefix = "";
2786 #ifdef G4MULTITHREADED                           2748 #ifdef G4MULTITHREADED
2787   G4UImanager* UI = G4UImanager::GetUIpointer    2749   G4UImanager* UI = G4UImanager::GetUIpointer();
2788   if (UI == nullptr) return "";                  2750   if (UI == nullptr) return "";
2789   if (UI->GetThreadCout() != nullptr) {          2751   if (UI->GetThreadCout() != nullptr) {
2790     threadPrefix = UI->GetThreadCout()->GetFu    2752     threadPrefix = UI->GetThreadCout()->GetFullPrefixString().data();
2791     if (UI->GetThreadCout()->GetPrefixString(    2753     if (UI->GetThreadCout()->GetPrefixString() == G4String("G4VIS")) {
2792       return "G4VIS";                            2754       return "G4VIS";
2793     }                                            2755     }
2794   }                                              2756   }
2795 #endif                                           2757 #endif
2796   return threadPrefix;                           2758   return threadPrefix;
2797 }                                                2759 }
2798                                                  2760 
2799 #ifdef G4MULTITHREADED                           2761 #ifdef G4MULTITHREADED
2800 void G4UIQt::UpdateCoutThreadFilter()            2762 void G4UIQt::UpdateCoutThreadFilter()
2801 {                                                2763 {
2802   G4UImanager* UI = G4UImanager::GetUIpointer    2764   G4UImanager* UI = G4UImanager::GetUIpointer();
2803   if (UI == nullptr) return;                     2765   if (UI == nullptr) return;
2804                                                  2766 
2805   // add "All" and "Master"                      2767   // add "All" and "Master"
2806   if (fThreadsFilterComboBox->count() < 2) {     2768   if (fThreadsFilterComboBox->count() < 2) {
2807     if (fThreadsFilterComboBox->findText("All    2769     if (fThreadsFilterComboBox->findText("All", Qt::MatchExactly) == -1) {
2808       fThreadsFilterComboBox->addItem("All");    2770       fThreadsFilterComboBox->addItem("All");
2809     }                                            2771     }
2810   }                                              2772   }
2811   if (fThreadsFilterComboBox->count() < 2) {     2773   if (fThreadsFilterComboBox->count() < 2) {
2812     if (fThreadsFilterComboBox->findText("Mas    2774     if (fThreadsFilterComboBox->findText("Master", Qt::MatchExactly) == -1) {
2813       fThreadsFilterComboBox->addItem("Master    2775       fThreadsFilterComboBox->addItem("Master");
2814     }                                            2776     }
2815   }                                              2777   }
2816   // Add current Cout                            2778   // Add current Cout
2817   G4String prefix = GetThreadPrefix();           2779   G4String prefix = GetThreadPrefix();
2818   if (! prefix.empty()) {                        2780   if (! prefix.empty()) {
2819     if (fThreadsFilterComboBox->findText(pref    2781     if (fThreadsFilterComboBox->findText(prefix.data(), Qt::MatchExactly) == -1) {
2820       fThreadsFilterComboBox->addItem(prefix.    2782       fThreadsFilterComboBox->addItem(prefix.data());
2821     }                                            2783     }
2822   }                                              2784   }
2823 }                                                2785 }
2824 #endif                                           2786 #endif
2825                                                  2787 
2826 /**                                              2788 /**
2827    Add a new menu to the menu bar                2789    Add a new menu to the menu bar
2828    @param aName name of menu                     2790    @param aName name of menu
2829    @param aLabel label to display                2791    @param aLabel label to display
2830  */                                              2792  */
2831 void G4UIQt::AddMenu(const char* aName, const    2793 void G4UIQt::AddMenu(const char* aName, const char* aLabel)
2832 {                                                2794 {
2833   if (aName == nullptr) return;                  2795   if (aName == nullptr) return;
2834   if (aLabel == nullptr) return;                 2796   if (aLabel == nullptr) return;
2835                                                  2797 
2836   auto fileMenu = new QMenu(aLabel);             2798   auto fileMenu = new QMenu(aLabel);
2837   fMainWindow->menuBar()->addMenu(fileMenu);     2799   fMainWindow->menuBar()->addMenu(fileMenu);
2838                                                  2800 
2839   AddInteractor(aName, (G4Interactor)fileMenu    2801   AddInteractor(aName, (G4Interactor)fileMenu);
2840 }                                                2802 }
2841                                                  2803 
2842 /**                                              2804 /**
2843    Add a new button to a menu                    2805    Add a new button to a menu
2844    @param aMenu : parent menu                    2806    @param aMenu : parent menu
2845    @param aLabel : label to display              2807    @param aLabel : label to display
2846    @param aCommand : command to execute as a     2808    @param aCommand : command to execute as a callback
2847  */                                              2809  */
2848 void G4UIQt::AddButton(const char* aMenu, con    2810 void G4UIQt::AddButton(const char* aMenu, const char* aLabel, const char* aCommand)
2849 {                                                2811 {
2850   if (aMenu == nullptr) return;  // TO KEEP      2812   if (aMenu == nullptr) return;  // TO KEEP
2851   if (aLabel == nullptr) return;  // TO KEEP     2813   if (aLabel == nullptr) return;  // TO KEEP
2852   if (aCommand == nullptr) return;  // TO KEE    2814   if (aCommand == nullptr) return;  // TO KEEP
2853                                                  2815 
2854   QMenu* parentTmp = (QMenu*)GetInteractor(aM    2816   QMenu* parentTmp = (QMenu*)GetInteractor(aMenu);
2855                                                  2817 
2856   if (parentTmp == nullptr) {                    2818   if (parentTmp == nullptr) {
2857     G4UImanager* UImanager = G4UImanager::Get    2819     G4UImanager* UImanager = G4UImanager::GetUIpointer();
2858     G4int verbose = UImanager->GetVerboseLeve    2820     G4int verbose = UImanager->GetVerboseLevel();
2859                                                  2821 
2860     if (verbose >= 2) {                          2822     if (verbose >= 2) {
2861       G4cout << "Menu name " << aMenu << " do    2823       G4cout << "Menu name " << aMenu << " does not exist, please define it before using it."
2862              << G4endl;                          2824              << G4endl;
2863     }                                            2825     }
2864     return;                                      2826     return;
2865   }                                              2827   }
2866                                                  2828 
2867   // Find the command in the command tree        2829   // Find the command in the command tree
2868   G4UImanager* UI = G4UImanager::GetUIpointer    2830   G4UImanager* UI = G4UImanager::GetUIpointer();
2869   if (UI == nullptr) return;                     2831   if (UI == nullptr) return;
2870   G4UIcommandTree* treeTop = UI->GetTree();      2832   G4UIcommandTree* treeTop = UI->GetTree();
2871                                                  2833 
2872   G4String cmd = aCommand;                       2834   G4String cmd = aCommand;
2873   std::size_t cmdEndPos = cmd.find_first_of("    2835   std::size_t cmdEndPos = cmd.find_first_of(" \t");
2874   if (cmdEndPos != std::string::npos) {          2836   if (cmdEndPos != std::string::npos) {
2875     cmd.erase(cmdEndPos);                        2837     cmd.erase(cmdEndPos);
2876   }                                              2838   }
2877                                                  2839 
2878   if (treeTop->FindPath(cmd) == nullptr) {       2840   if (treeTop->FindPath(cmd) == nullptr) {
2879     if (cmd != "ls" && cmd.substr(0, 3) != "l    2841     if (cmd != "ls" && cmd.substr(0, 3) != "ls " && cmd != "pwd" && cmd != "cd" &&
2880         cmd.substr(0, 3) != "cd " && cmd != "    2842         cmd.substr(0, 3) != "cd " && cmd != "help" && cmd.substr(0, 5) != "help " &&
2881         cmd[0] != '?' && cmd != "hist" && cmd    2843         cmd[0] != '?' && cmd != "hist" && cmd != "history" && cmd[0] != '!' && cmd != "exit" &&
2882         cmd != "cont" && cmd != "continue")      2844         cmd != "cont" && cmd != "continue")
2883     {                                            2845     {
2884       G4UImanager* UImanager = G4UImanager::G    2846       G4UImanager* UImanager = G4UImanager::GetUIpointer();
2885       G4int verbose = UImanager->GetVerboseLe    2847       G4int verbose = UImanager->GetVerboseLevel();
2886                                                  2848 
2887       if (verbose >= 2) {                        2849       if (verbose >= 2) {
2888         G4cout << "Warning: command '" << cmd    2850         G4cout << "Warning: command '" << cmd
2889                << "' does not exist, please d    2851                << "' does not exist, please define it before using it." << G4endl;
2890       }                                          2852       }
2891     }                                            2853     }
2892   }                                              2854   }
2893                                                  2855 
2894   QString cmd_tmp = QString(aCommand);           2856   QString cmd_tmp = QString(aCommand);
2895   parentTmp->addAction(aLabel, this, [this, c    2857   parentTmp->addAction(aLabel, this, [this, cmd_tmp]() { this->ButtonCallback(cmd_tmp); });
2896 }                                                2858 }
2897                                                  2859 
2898 /**                                              2860 /**
2899  special case for the "open" icon. It will op    2861  special case for the "open" icon. It will open a file selector and map the return file to the given
2900  command.                                        2862  command.
2901 */                                               2863 */
2902 void G4UIQt::AddIcon(                            2864 void G4UIQt::AddIcon(
2903   const char* aLabel, const char* aIconFile,     2865   const char* aLabel, const char* aIconFile, const char* aCommand, const char* aFileName)
2904 {                                                2866 {
2905   if (aLabel == nullptr) return;  // TO KEEP     2867   if (aLabel == nullptr) return;  // TO KEEP
2906   // special case, aCommand could be NULL if     2868   // special case, aCommand could be NULL if aIconFile is not user_icon
2907   if (aCommand == nullptr) {                     2869   if (aCommand == nullptr) {
2908     if (std::string(aIconFile) == "user_icon"    2870     if (std::string(aIconFile) == "user_icon") {
2909       return;  // TO KEEP                        2871       return;  // TO KEEP
2910     }                                            2872     }
2911   }                                              2873   }
2912   QPixmap* pix;                                  2874   QPixmap* pix;
2913   G4bool userToolBar = false;                    2875   G4bool userToolBar = false;
2914                                                  2876 
2915   if (! fDefaultIcons) {                         2877   if (! fDefaultIcons) {
2916     userToolBar = true;                          2878     userToolBar = true;
2917   }                                              2879   }
2918   if (std::string(aIconFile) == "user_icon")     2880   if (std::string(aIconFile) == "user_icon") {
2919     // try to open a file                        2881     // try to open a file
2920     G4UImanager* UImanager = G4UImanager::Get    2882     G4UImanager* UImanager = G4UImanager::GetUIpointer();
2921     pix = new QPixmap(UImanager->FindMacroPat    2883     pix = new QPixmap(UImanager->FindMacroPath(aFileName).data());
2922     if (pix->isNull()) {                         2884     if (pix->isNull()) {
2923       G4int verbose = UImanager->GetVerboseLe    2885       G4int verbose = UImanager->GetVerboseLevel();
2924                                                  2886 
2925       if (verbose >= 2) {                        2887       if (verbose >= 2) {
2926         G4cout << "Warning: file '" << aFileN    2888         G4cout << "Warning: file '" << aFileName
2927                << "' is incorrect or does not    2889                << "' is incorrect or does not exist, this command will not be build" << G4endl;
2928       }                                          2890       }
2929       return;                                    2891       return;
2930     }                                            2892     }
2931   }                                              2893   }
2932   else if (std::string(aIconFile) == "open")     2894   else if (std::string(aIconFile) == "open") {
2933     pix = fOpenIcon;                             2895     pix = fOpenIcon;
2934   }                                              2896   }
2935   else if (std::string(aIconFile) == "save")     2897   else if (std::string(aIconFile) == "save") {
2936     pix = fSaveIcon;                             2898     pix = fSaveIcon;
2937   }                                              2899   }
2938   else if (std::string(aIconFile) == "move")     2900   else if (std::string(aIconFile) == "move") {
2939     pix = fMoveIcon;                             2901     pix = fMoveIcon;
2940   }                                              2902   }
2941   else if (std::string(aIconFile) == "rotate"    2903   else if (std::string(aIconFile) == "rotate") {
2942     pix = fRotateIcon;                           2904     pix = fRotateIcon;
2943   }                                              2905   }
2944   else if (std::string(aIconFile) == "pick")     2906   else if (std::string(aIconFile) == "pick") {
2945     pix = fPickIcon;                             2907     pix = fPickIcon;
2946   }                                              2908   }
2947   else if (std::string(aIconFile) == "zoom_in    2909   else if (std::string(aIconFile) == "zoom_in") {
2948     pix = fZoomInIcon;                           2910     pix = fZoomInIcon;
2949   }                                              2911   }
2950   else if (std::string(aIconFile) == "zoom_ou    2912   else if (std::string(aIconFile) == "zoom_out") {
2951     pix = fZoomOutIcon;                          2913     pix = fZoomOutIcon;
2952   }                                              2914   }
2953   else if (std::string(aIconFile) == "wirefra    2915   else if (std::string(aIconFile) == "wireframe") {
2954     pix = fWireframeIcon;                        2916     pix = fWireframeIcon;
2955   }                                              2917   }
2956   else if (std::string(aIconFile) == "solid")    2918   else if (std::string(aIconFile) == "solid") {
2957     pix = fSolidIcon;                            2919     pix = fSolidIcon;
2958   }                                              2920   }
2959   else if (std::string(aIconFile) == "hidden_    2921   else if (std::string(aIconFile) == "hidden_line_removal") {
2960     pix = fHiddenLineRemovalIcon;                2922     pix = fHiddenLineRemovalIcon;
2961   }                                              2923   }
2962   else if (std::string(aIconFile) == "hidden_    2924   else if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
2963     pix = fHiddenLineAndSurfaceRemovalIcon;      2925     pix = fHiddenLineAndSurfaceRemovalIcon;
2964   }                                              2926   }
2965   else if (std::string(aIconFile) == "perspec    2927   else if (std::string(aIconFile) == "perspective") {
2966     pix = fPerspectiveIcon;                      2928     pix = fPerspectiveIcon;
2967   }                                              2929   }
2968   else if (std::string(aIconFile) == "ortho")    2930   else if (std::string(aIconFile) == "ortho") {
2969     pix = fOrthoIcon;                            2931     pix = fOrthoIcon;
2970   }                                              2932   }
2971   else if (std::string(aIconFile) == "runBeam    2933   else if (std::string(aIconFile) == "runBeamOn") {
2972     pix = fRunIcon;                              2934     pix = fRunIcon;
2973   }                                              2935   }
2974   else if (std::string(aIconFile) == "exit")     2936   else if (std::string(aIconFile) == "exit") {
2975     pix = fExitIcon;                             2937     pix = fExitIcon;
2976   }                                              2938   }
2977   else {                                         2939   else {
2978     G4UImanager* UImanager = G4UImanager::Get    2940     G4UImanager* UImanager = G4UImanager::GetUIpointer();
2979     G4int verbose = UImanager->GetVerboseLeve    2941     G4int verbose = UImanager->GetVerboseLevel();
2980                                                  2942 
2981     if (verbose >= 2) {                          2943     if (verbose >= 2) {
2982       G4cout << "Parameter" << aIconFile << "    2944       G4cout << "Parameter" << aIconFile << " not defined" << G4endl;
2983     }                                            2945     }
2984     return;                                      2946     return;
2985   }                                              2947   }
2986   QToolBar* currentToolbar = nullptr;            2948   QToolBar* currentToolbar = nullptr;
2987   if (userToolBar) {                             2949   if (userToolBar) {
2988     if (fToolbarUser == nullptr) {               2950     if (fToolbarUser == nullptr) {
2989       fToolbarUser = new QToolBar();             2951       fToolbarUser = new QToolBar();
2990       fToolbarUser->setIconSize(QSize(20, 20)    2952       fToolbarUser->setIconSize(QSize(20, 20));
2991       fMainWindow->addToolBar(Qt::TopToolBarA    2953       fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
2992     }                                            2954     }
2993     currentToolbar = fToolbarUser;               2955     currentToolbar = fToolbarUser;
2994   }                                              2956   }
2995   else {                                         2957   else {
2996     if (fToolbarApp == nullptr) {                2958     if (fToolbarApp == nullptr) {
2997       fToolbarApp = new QToolBar();              2959       fToolbarApp = new QToolBar();
2998       fToolbarApp->setIconSize(QSize(20, 20))    2960       fToolbarApp->setIconSize(QSize(20, 20));
2999       fMainWindow->addToolBar(Qt::TopToolBarA    2961       fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
3000     }                                            2962     }
3001     currentToolbar = fToolbarApp;                2963     currentToolbar = fToolbarApp;
3002   }                                              2964   }
3003                                                  2965 
3004   // Check if already present                    2966   // Check if already present
3005                                                  2967 
3006   QList<QAction*> list = currentToolbar->acti    2968   QList<QAction*> list = currentToolbar->actions();
3007                                                  2969 
3008   for (auto i : list) {                          2970   for (auto i : list) {
3009     if (i->text() == QString(aLabel)) {          2971     if (i->text() == QString(aLabel)) {
3010       G4UImanager* UI = G4UImanager::GetUIpoi    2972       G4UImanager* UI = G4UImanager::GetUIpointer();
3011       if (UI == nullptr) return;                 2973       if (UI == nullptr) return;
3012       G4int verbose = UI->GetVerboseLevel();     2974       G4int verbose = UI->GetVerboseLevel();
3013       if (verbose >= 2) {                        2975       if (verbose >= 2) {
3014         G4cout << "Warning: A toolBar icon \"    2976         G4cout << "Warning: A toolBar icon \"" << aLabel << "\" already exists with the same name!"
3015                << G4endl;                        2977                << G4endl;
3016       }                                          2978       }
3017     }                                            2979     }
3018   }                                              2980   }
3019                                                  2981 
3020   // special cases :"open"                       2982   // special cases :"open"
3021   if (std::string(aIconFile) == "open") {        2983   if (std::string(aIconFile) == "open") {
3022     QString txt = aCommand + fStringSeparator    2984     QString txt = aCommand + fStringSeparator + aLabel;
3023     currentToolbar->addAction(                   2985     currentToolbar->addAction(
3024       QIcon(*pix), aIconFile, this, [this, tx    2986       QIcon(*pix), aIconFile, this, [this, txt]() { this->OpenIconCallback(txt); });
3025                                                  2987 
3026     // special cases :"save"                     2988     // special cases :"save"
3027   }                                              2989   }
3028   else if (std::string(aIconFile) == "save")     2990   else if (std::string(aIconFile) == "save") {
3029     QString txt = aCommand + fStringSeparator    2991     QString txt = aCommand + fStringSeparator + aLabel;
3030     currentToolbar->addAction(                   2992     currentToolbar->addAction(
3031       QIcon(*pix), aIconFile, this, [this, tx    2993       QIcon(*pix), aIconFile, this, [this, txt]() { this->SaveIconCallback(txt); });
3032     // special cases : cursor style              2994     // special cases : cursor style
3033   }                                              2995   }
3034   else if ((std::string(aIconFile) == "move")    2996   else if ((std::string(aIconFile) == "move") || (std::string(aIconFile) == "rotate") ||
3035            (std::string(aIconFile) == "pick")    2997            (std::string(aIconFile) == "pick") || (std::string(aIconFile) == "zoom_out") ||
3036            (std::string(aIconFile) == "zoom_i    2998            (std::string(aIconFile) == "zoom_in"))
3037   {                                              2999   {
3038     QString txt = QString(aIconFile);            3000     QString txt = QString(aIconFile);
3039     QAction* action = currentToolbar->addActi    3001     QAction* action = currentToolbar->addAction(
3040       QIcon(*pix), aIconFile, this, [this, tx    3002       QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangeCursorAction(txt); });
3041     action->setCheckable(true);                  3003     action->setCheckable(true);
3042     action->setChecked(true);                    3004     action->setChecked(true);
3043     action->setData(aIconFile);                  3005     action->setData(aIconFile);
3044                                                  3006 
3045     if (std::string(aIconFile) == "move") {      3007     if (std::string(aIconFile) == "move") {
3046       SetIconMoveSelected();                     3008       SetIconMoveSelected();
3047     }                                            3009     }
3048     if (std::string(aIconFile) == "rotate") {    3010     if (std::string(aIconFile) == "rotate") {
3049       SetIconRotateSelected();                   3011       SetIconRotateSelected();
3050     }                                            3012     }
3051     if (std::string(aIconFile) == "pick") {      3013     if (std::string(aIconFile) == "pick") {
3052       SetIconPickSelected();                     3014       SetIconPickSelected();
3053     }                                            3015     }
3054     if (std::string(aIconFile) == "zoom_in")     3016     if (std::string(aIconFile) == "zoom_in") {
3055       SetIconZoomInSelected();                   3017       SetIconZoomInSelected();
3056     }                                            3018     }
3057     if (std::string(aIconFile) == "zoom_out")    3019     if (std::string(aIconFile) == "zoom_out") {
3058       SetIconZoomOutSelected();                  3020       SetIconZoomOutSelected();
3059     }                                            3021     }
3060                                                  3022 
3061     // special case : surface style              3023     // special case : surface style
3062   }                                              3024   }
3063   else if ((std::string(aIconFile) == "hidden    3025   else if ((std::string(aIconFile) == "hidden_line_removal") ||
3064            (std::string(aIconFile) == "hidden    3026            (std::string(aIconFile) == "hidden_line_and_surface_removal") ||
3065            (std::string(aIconFile) == "solid"    3027            (std::string(aIconFile) == "solid") || (std::string(aIconFile) == "wireframe"))
3066   {                                              3028   {
3067     QString txt = QString(aIconFile);            3029     QString txt = QString(aIconFile);
3068     QAction* action = currentToolbar->addActi    3030     QAction* action = currentToolbar->addAction(
3069       QIcon(*pix), aIconFile, this, [this, tx    3031       QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangeSurfaceStyle(txt); });
3070     action->setCheckable(true);                  3032     action->setCheckable(true);
3071     action->setChecked(true);                    3033     action->setChecked(true);
3072     action->setData(aIconFile);                  3034     action->setData(aIconFile);
3073                                                  3035 
3074     if (std::string(aIconFile) == "hidden_lin    3036     if (std::string(aIconFile) == "hidden_line_removal") {
3075       SetIconHLRSelected();                      3037       SetIconHLRSelected();
3076     }                                            3038     }
3077     if (std::string(aIconFile) == "hidden_lin    3039     if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
3078       SetIconHLHSRSelected();                    3040       SetIconHLHSRSelected();
3079     }                                            3041     }
3080     if (std::string(aIconFile) == "solid") {     3042     if (std::string(aIconFile) == "solid") {
3081       SetIconSolidSelected();                    3043       SetIconSolidSelected();
3082     }                                            3044     }
3083     if (std::string(aIconFile) == "wireframe"    3045     if (std::string(aIconFile) == "wireframe") {
3084       SetIconWireframeSelected();                3046       SetIconWireframeSelected();
3085     }                                            3047     }
3086                                                  3048 
3087     // special case : perspective/ortho          3049     // special case : perspective/ortho
3088   }                                              3050   }
3089   else if ((std::string(aIconFile) == "perspe    3051   else if ((std::string(aIconFile) == "perspective") || (std::string(aIconFile) == "ortho")) {
3090     QString txt = QString(aIconFile);            3052     QString txt = QString(aIconFile);
3091     QAction* action = currentToolbar->addActi    3053     QAction* action = currentToolbar->addAction(
3092       QIcon(*pix), aIconFile, this, [this, tx    3054       QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangePerspectiveOrtho(txt); });
3093     action->setCheckable(true);                  3055     action->setCheckable(true);
3094     action->setChecked(true);                    3056     action->setChecked(true);
3095     action->setData(aIconFile);                  3057     action->setData(aIconFile);
3096                                                  3058 
3097     if (std::string(aIconFile) == "perspectiv    3059     if (std::string(aIconFile) == "perspective") {
3098       SetIconPerspectiveSelected();              3060       SetIconPerspectiveSelected();
3099     }                                            3061     }
3100     if (std::string(aIconFile) == "ortho") {     3062     if (std::string(aIconFile) == "ortho") {
3101       SetIconOrthoSelected();                    3063       SetIconOrthoSelected();
3102     }                                            3064     }
3103   }                                              3065   }
3104   else {                                         3066   else {
3105     // Find the command in the command tree      3067     // Find the command in the command tree
3106     G4UImanager* UI = G4UImanager::GetUIpoint    3068     G4UImanager* UI = G4UImanager::GetUIpointer();
3107     if (UI == nullptr) return;                   3069     if (UI == nullptr) return;
3108     G4UIcommandTree* treeTop = UI->GetTree();    3070     G4UIcommandTree* treeTop = UI->GetTree();
3109     if (aCommand != nullptr) {                   3071     if (aCommand != nullptr) {
3110       std::string str = aCommand;                3072       std::string str = aCommand;
3111       std::string::size_type pos = str.find('    3073       std::string::size_type pos = str.find(' ');
3112       if (pos != std::string::npos) {            3074       if (pos != std::string::npos) {
3113         str = str.substr(0, pos).c_str();        3075         str = str.substr(0, pos).c_str();
3114       }                                          3076       }
3115       if (treeTop->FindPath(str.c_str()) == n    3077       if (treeTop->FindPath(str.c_str()) == nullptr) {
3116         G4UImanager* UImanager = G4UImanager:    3078         G4UImanager* UImanager = G4UImanager::GetUIpointer();
3117         G4int verbose = UImanager->GetVerbose    3079         G4int verbose = UImanager->GetVerboseLevel();
3118                                                  3080 
3119         if (verbose >= 2) {                      3081         if (verbose >= 2) {
3120           G4cout << "Warning: command '" << a    3082           G4cout << "Warning: command '" << aCommand
3121                  << "' does not exist, please    3083                  << "' does not exist, please define it before using it." << G4endl;
3122         }                                        3084         }
3123       }                                          3085       }
3124     }                                            3086     }
3125     QString txt = QString(aCommand);             3087     QString txt = QString(aCommand);
3126     currentToolbar->addAction(                   3088     currentToolbar->addAction(
3127       QIcon(*pix), aCommand, this, [this, txt    3089       QIcon(*pix), aCommand, this, [this, txt]() { this->ButtonCallback(txt); });
3128   }                                              3090   }
3129 }                                                3091 }
3130                                                  3092 
3131 void G4UIQt::SetOutputStyle(const char* desti    3093 void G4UIQt::SetOutputStyle(const char* destination, const char* style)
3132 {                                                3094 {
3133   // Specify an output style                     3095   // Specify an output style
3134   // First argument destination ("cout" etc o    3096   // First argument destination ("cout" etc or "all")
3135   // Second argument is the required style -     3097   // Second argument is the required style - see guidance
3136                                                  3098 
3137   SetStyleUtility(destination, style);           3099   SetStyleUtility(destination, style);
3138 }                                                3100 }
3139                                                  3101 
3140 void G4UIQt::NativeMenu(G4bool aVal)             3102 void G4UIQt::NativeMenu(G4bool aVal)
3141 {                                                3103 {
3142   if (fMainWindow->menuBar()->isNativeMenuBar    3104   if (fMainWindow->menuBar()->isNativeMenuBar() == aVal) return;  // already in this state
3143                                                  3105 
3144   // Menu become empty when goin from Qt to N    3106   // Menu become empty when goin from Qt to Native Bar
3145   fMainWindow->menuBar()->setNativeMenuBar(aV    3107   fMainWindow->menuBar()->setNativeMenuBar(aVal);
3146 }                                                3108 }
3147                                                  3109 
3148 void G4UIQt::ClearMenu() { fMainWindow->menuB    3110 void G4UIQt::ClearMenu() { fMainWindow->menuBar()->clear(); }
3149                                                  3111 
3150 void G4UIQt::ActivateCommand(G4String newComm    3112 void G4UIQt::ActivateCommand(G4String newCommand)
3151 {                                                3113 {
3152   if (fHelpTreeWidget == nullptr) {              3114   if (fHelpTreeWidget == nullptr) {
3153     return;                                      3115     return;
3154   }                                              3116   }
3155   // Look for the choosen command "newCommand    3117   // Look for the choosen command "newCommand"
3156   std::size_t i = newCommand.find(' ');          3118   std::size_t i = newCommand.find(' ');
3157   G4String targetCom = "";                       3119   G4String targetCom = "";
3158   if (i != std::string::npos) {                  3120   if (i != std::string::npos) {
3159     G4String newValue = newCommand.substr(i +    3121     G4String newValue = newCommand.substr(i + 1, newCommand.length() - (i + 1));
3160     G4StrUtil::strip(newValue);                  3122     G4StrUtil::strip(newValue);
3161     targetCom = ModifyToFullPathCommand(newVa    3123     targetCom = ModifyToFullPathCommand(newValue);
3162   }                                              3124   }
3163   if (! targetCom.empty()) {                     3125   if (! targetCom.empty()) {
3164     OpenHelpTreeOnCommand(targetCom.data());     3126     OpenHelpTreeOnCommand(targetCom.data());
3165   }                                              3127   }
3166                                                  3128 
3167   fUITabWidget->setCurrentWidget(fHelpTBWidge    3129   fUITabWidget->setCurrentWidget(fHelpTBWidget);
3168 }                                                3130 }
3169                                                  3131 
3170 /**                                              3132 /**
3171    Create the help tree widget                   3133    Create the help tree widget
3172    @param parent : parent of tree widget         3134    @param parent : parent of tree widget
3173    @return the widget containing the tree or     3135    @return the widget containing the tree or NULL if it could not have beeen created
3174  */                                              3136  */
3175                                                  3137 
3176 void G4UIQt::InitHelpTreeAndVisParametersWidg    3138 void G4UIQt::InitHelpTreeAndVisParametersWidget()
3177 {                                                3139 {
3178   if (fHelpTreeWidget == nullptr) {              3140   if (fHelpTreeWidget == nullptr) {
3179     fHelpTreeWidget = new QTreeWidget();         3141     fHelpTreeWidget = new QTreeWidget();
3180   }                                              3142   }
3181                                                  3143 
3182   // build widget                                3144   // build widget
3183   fHelpTreeWidget->setSelectionMode(QAbstract    3145   fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
3184   QStringList labels;                            3146   QStringList labels;
3185   labels << QString("Command");                  3147   labels << QString("Command");
3186   fHelpTreeWidget->setHeaderLabels(labels);      3148   fHelpTreeWidget->setHeaderLabels(labels);
3187                                                  3149 
3188   connect(fHelpTreeWidget, SIGNAL(itemSelecti    3150   connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(HelpTreeClicCallback()));
3189   connect(fHelpTreeWidget, SIGNAL(itemDoubleC    3151   connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this,
3190     SLOT(HelpTreeDoubleClicCallback()));         3152     SLOT(HelpTreeDoubleClicCallback()));
3191 }                                                3153 }
3192 /**                                              3154 /**
3193    Create the help tree widget                   3155    Create the help tree widget
3194    @param parent : parent of tree widget         3156    @param parent : parent of tree widget
3195    @return the widget containing the tree or     3157    @return the widget containing the tree or NULL if it could not have beeen created
3196  */                                              3158  */
3197                                                  3159 
3198 void G4UIQt::FillHelpTree()                      3160 void G4UIQt::FillHelpTree()
3199 {                                                3161 {
3200   if (fHelpTreeWidget == nullptr) {              3162   if (fHelpTreeWidget == nullptr) {
3201     InitHelpTreeAndVisParametersWidget();        3163     InitHelpTreeAndVisParametersWidget();
3202   }                                              3164   }
3203                                                  3165 
3204   QString searchText = fHelpLine->text();        3166   QString searchText = fHelpLine->text();
3205                                                  3167 
3206   if (searchText == "") {                        3168   if (searchText == "") {
3207     // clear old help tree                       3169     // clear old help tree
3208     //    fHelpTreeWidget->clear();              3170     //    fHelpTreeWidget->clear();
3209   }                                              3171   }
3210   else {                                         3172   else {
3211     return;                                      3173     return;
3212   }                                              3174   }
3213                                                  3175 
3214   if (fParameterHelpLabel != nullptr) {          3176   if (fParameterHelpLabel != nullptr) {
3215     fParameterHelpLabel->setText("Choose a co    3177     fParameterHelpLabel->setText("Choose a command in the command tree");
3216     fParameterHelpTable->setVisible(false);      3178     fParameterHelpTable->setVisible(false);
3217   }                                              3179   }
3218                                                  3180 
3219   if (fHelpLine != nullptr) {                    3181   if (fHelpLine != nullptr) {
3220     fHelpLine->setText("");                      3182     fHelpLine->setText("");
3221   }                                              3183   }
3222                                                  3184 
3223   G4UImanager* UI = G4UImanager::GetUIpointer    3185   G4UImanager* UI = G4UImanager::GetUIpointer();
3224   if (UI == nullptr) return;                     3186   if (UI == nullptr) return;
3225   G4UIcommandTree* treeTop = UI->GetTree();      3187   G4UIcommandTree* treeTop = UI->GetTree();
3226                                                  3188 
3227   G4int treeSize = treeTop->GetTreeEntry();      3189   G4int treeSize = treeTop->GetTreeEntry();
3228   QTreeWidgetItem* newItem = nullptr;            3190   QTreeWidgetItem* newItem = nullptr;
3229   QString commandText = "";                      3191   QString commandText = "";
3230   for (G4int a = 0; a < treeSize; ++a) {         3192   for (G4int a = 0; a < treeSize; ++a) {
3231     // Creating new item                         3193     // Creating new item
3232     newItem = nullptr;                           3194     newItem = nullptr;
3233                                                  3195 
3234     commandText = QString((char*)(treeTop->Ge    3196     commandText = QString((char*)(treeTop->GetTree(a + 1)->GetPathName()).data()).trimmed();
3235                                                  3197 
3236     // if already exist, don't create it !       3198     // if already exist, don't create it !
3237     for (G4int b = 0; b < fHelpTreeWidget->to    3199     for (G4int b = 0; b < fHelpTreeWidget->topLevelItemCount(); ++b) {
3238       if (newItem == nullptr) newItem = FindT    3200       if (newItem == nullptr) newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b), commandText);
3239     }                                            3201     }
3240                                                  3202 
3241     if (newItem == nullptr) {                    3203     if (newItem == nullptr) {
3242       newItem = new QTreeWidgetItem();           3204       newItem = new QTreeWidgetItem();
3243       newItem->setText(0, GetShortCommandPath    3205       newItem->setText(0, GetShortCommandPath(commandText));
3244       fHelpTreeWidget->addTopLevelItem(newIte    3206       fHelpTreeWidget->addTopLevelItem(newItem);
3245     }                                            3207     }
3246                                                  3208 
3247     // look for childs                           3209     // look for childs
3248     CreateHelpTree(newItem, treeTop->GetTree(    3210     CreateHelpTree(newItem, treeTop->GetTree(a + 1));
3249   }                                              3211   }
3250 }                                                3212 }
3251                                                  3213 
3252 /**   Fill the Help Tree Widget                  3214 /**   Fill the Help Tree Widget
3253    @param aParent : parent item to fill          3215    @param aParent : parent item to fill
3254    @param aCommandTree : commandTree node ass    3216    @param aCommandTree : commandTree node associate with this part of the Tree
3255 */                                               3217 */
3256 void G4UIQt::CreateHelpTree(QTreeWidgetItem*     3218 void G4UIQt::CreateHelpTree(QTreeWidgetItem* aParent, G4UIcommandTree* aCommandTree)
3257 {                                                3219 {
3258   if (aParent == nullptr) return;                3220   if (aParent == nullptr) return;
3259   if (aCommandTree == nullptr) return;           3221   if (aCommandTree == nullptr) return;
3260                                                  3222 
3261   // Creating new item                           3223   // Creating new item
3262   QTreeWidgetItem* newItem;                      3224   QTreeWidgetItem* newItem;
3263                                                  3225 
3264   QString commandText = "";                      3226   QString commandText = "";
3265   // Get the Sub directories                     3227   // Get the Sub directories
3266   for (G4int a = 0; a < aCommandTree->GetTree    3228   for (G4int a = 0; a < aCommandTree->GetTreeEntry(); ++a) {
3267     commandText = QString((char*)(aCommandTre    3229     commandText = QString((char*)(aCommandTree->GetTree(a + 1)->GetPathName()).data()).trimmed();
3268                                                  3230 
3269     // if already exist, don't create it !       3231     // if already exist, don't create it !
3270     newItem = FindTreeItem(aParent, commandTe    3232     newItem = FindTreeItem(aParent, commandText);
3271     if (newItem == nullptr) {                    3233     if (newItem == nullptr) {
3272       newItem = new QTreeWidgetItem();           3234       newItem = new QTreeWidgetItem();
3273       newItem->setText(0, GetShortCommandPath    3235       newItem->setText(0, GetShortCommandPath(commandText));
3274       aParent->addChild(newItem);                3236       aParent->addChild(newItem);
3275     }                                            3237     }
3276     CreateHelpTree(newItem, aCommandTree->Get    3238     CreateHelpTree(newItem, aCommandTree->GetTree(a + 1));
3277   }                                              3239   }
3278                                                  3240 
3279   // Get the Commands                            3241   // Get the Commands
3280                                                  3242 
3281   for (G4int a = 0; a < aCommandTree->GetComm    3243   for (G4int a = 0; a < aCommandTree->GetCommandEntry(); ++a) {
3282     QStringList stringList;                      3244     QStringList stringList;
3283     commandText =                                3245     commandText =
3284       QString((char*)(aCommandTree->GetComman    3246       QString((char*)(aCommandTree->GetCommand(a + 1)->GetCommandPath()).data()).trimmed();
3285                                                  3247 
3286     // if already exist, don't create it !       3248     // if already exist, don't create it !
3287     newItem = FindTreeItem(aParent, commandTe    3249     newItem = FindTreeItem(aParent, commandText);
3288     if (newItem == nullptr) {                    3250     if (newItem == nullptr) {
3289       newItem = new QTreeWidgetItem();           3251       newItem = new QTreeWidgetItem();
3290       newItem->setText(0, GetShortCommandPath    3252       newItem->setText(0, GetShortCommandPath(commandText));
3291       aParent->addChild(newItem);                3253       aParent->addChild(newItem);
3292       newItem->setExpanded(false);               3254       newItem->setExpanded(false);
3293     }                                            3255     }
3294   }                                              3256   }
3295 }                                                3257 }
3296                                                  3258 
3297 /**                                              3259 /**
3298  Add the following command to the correspondi    3260  Add the following command to the corresponding groupbox
3299  If depthLevel is 1 : create ToolBox             3261  If depthLevel is 1 : create ToolBox
3300  If depthLevel is 2 or more : create GroupBox    3262  If depthLevel is 2 or more : create GroupBox
3301 */                                               3263 */
3302 G4bool G4UIQt::CreateVisCommandGroupAndToolBo    3264 G4bool G4UIQt::CreateVisCommandGroupAndToolBox(
3303   G4UIcommand* aCommand, QWidget* aParent, G4    3265   G4UIcommand* aCommand, QWidget* aParent, G4int aDepthLevel, G4bool isDialog)
3304 {                                                3266 {
3305   QString commandText =                          3267   QString commandText =
3306     QString((char*)(aCommand->GetCommandPath(    3268     QString((char*)(aCommand->GetCommandPath().data())).section("/", -aDepthLevel);
3307                                                  3269 
3308   if (commandText == nullptr) {                  3270   if (commandText == nullptr) {
3309     return false;                                3271     return false;
3310   }                                              3272   }
3311                                                  3273 
3312   // Look if groupBox is create                  3274   // Look if groupBox is create
3313   //  QGroupBox* gBoxCommandWidget;              3275   //  QGroupBox* gBoxCommandWidget;
3314   QWidget* newParentWidget = nullptr;            3276   QWidget* newParentWidget = nullptr;
3315   G4bool found = false;                          3277   G4bool found = false;
3316   QString commandSection = commandText.left(c    3278   QString commandSection = commandText.left(commandText.indexOf("/"));
3317                                                  3279 
3318   if (aDepthLevel == 1) {                        3280   if (aDepthLevel == 1) {
3319     auto currentParent = dynamic_cast<QToolBo    3281     auto currentParent = dynamic_cast<QToolBox*>(aParent);
3320     if (currentParent != nullptr) {              3282     if (currentParent != nullptr) {
3321       // already exists ?                        3283       // already exists ?
3322       for (G4int a = 0; a < currentParent->co    3284       for (G4int a = 0; a < currentParent->count(); ++a) {
3323         if (currentParent->itemText(a) == com    3285         if (currentParent->itemText(a) == commandSection) {
3324           found = true;                          3286           found = true;
3325           newParentWidget = currentParent->wi    3287           newParentWidget = currentParent->widget(a);
3326         }                                        3288         }
3327       }                                          3289       }
3328     }                                            3290     }
3329     // Not found ? create it                     3291     // Not found ? create it
3330     if (! found) {                               3292     if (! found) {
3331       newParentWidget = new QGroupBox();         3293       newParentWidget = new QGroupBox();
3332       newParentWidget->setLayout(new QVBoxLay    3294       newParentWidget->setLayout(new QVBoxLayout());
3333       if (currentParent != nullptr) {            3295       if (currentParent != nullptr) {
3334         currentParent->addItem(newParentWidge    3296         currentParent->addItem(newParentWidget, commandSection);
3335       }                                          3297       }
3336       else {                                     3298       else {
3337         if (aParent->layout() == nullptr) {      3299         if (aParent->layout() == nullptr) {
3338           aParent->setLayout(new QVBoxLayout(    3300           aParent->setLayout(new QVBoxLayout());
3339         }                                        3301         }
3340         aParent->layout()->addWidget(newParen    3302         aParent->layout()->addWidget(newParentWidget);
3341       }                                          3303       }
3342                                                  3304 
3343       if (commandText.indexOf("/") == -1) {      3305       if (commandText.indexOf("/") == -1) {
3344         // Guidance                              3306         // Guidance
3345         QString guidance;                        3307         QString guidance;
3346         auto n_guidanceEntry = (G4int)aComman    3308         auto n_guidanceEntry = (G4int)aCommand->GetGuidanceEntries();
3347         for (G4int i_thGuidance = 0; i_thGuid    3309         for (G4int i_thGuidance = 0; i_thGuidance < n_guidanceEntry; i_thGuidance++) {
3348           guidance += QString((char*)(aComman    3310           guidance += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n";
3349         }                                        3311         }
3350         newParentWidget->setToolTip(guidance)    3312         newParentWidget->setToolTip(guidance);
3351       }                                          3313       }
3352                                                  3314 
3353       auto sc = dynamic_cast<QScrollArea*>(ne    3315       auto sc = dynamic_cast<QScrollArea*>(newParentWidget->parent()->parent());
3354       if (sc != nullptr) {                       3316       if (sc != nullptr) {
3355         sc->ensureWidgetVisible(newParentWidg    3317         sc->ensureWidgetVisible(newParentWidget);
3356       }                                          3318       }
3357     }                                            3319     }
3358   }                                              3320   }
3359   else {                                         3321   else {
3360     // try to know if this level is already t    3322     // try to know if this level is already there
3361     auto currentParent = dynamic_cast<QGroupB    3323     auto currentParent = dynamic_cast<QGroupBox*>(aParent);
3362     if (currentParent != nullptr) {              3324     if (currentParent != nullptr) {
3363       // if depth==2, then we add a [more par    3325       // if depth==2, then we add a [more parameters inside] to the toolBoxItem parent
3364       // QGroupBox > QWidget > QScrollArea >     3326       // QGroupBox > QWidget > QScrollArea > QToolBox
3365       if (aDepthLevel == 2) {                    3327       if (aDepthLevel == 2) {
3366         auto parentToolBox = dynamic_cast<QTo    3328         auto parentToolBox = dynamic_cast<QToolBox*>(currentParent->parent()->parent()->parent());
3367         if (parentToolBox != nullptr) {          3329         if (parentToolBox != nullptr) {
3368           //          parentToolBox->setItemT    3330           //          parentToolBox->setItemText(parentToolBox->indexOf(currentParent),"[more
3369           //          parameters inside]");      3331           //          parameters inside]");
3370         }                                        3332         }
3371       }                                          3333       }
3372       for (G4int a = 0; a < aParent->layout()    3334       for (G4int a = 0; a < aParent->layout()->count(); ++a) {
3373         auto gb = dynamic_cast<QGroupBox*>(aP    3335         auto gb = dynamic_cast<QGroupBox*>(aParent->layout()->itemAt(a)->widget());
3374         if (gb != nullptr) {                     3336         if (gb != nullptr) {
3375           if (gb->title() == commandSection)     3337           if (gb->title() == commandSection) {
3376             found = true;                        3338             found = true;
3377             newParentWidget = gb;                3339             newParentWidget = gb;
3378           }                                      3340           }
3379         }                                        3341         }
3380       }                                          3342       }
3381     }                                            3343     }
3382                                                  3344 
3383     // Not found ? create it                     3345     // Not found ? create it
3384     if (! found) {                               3346     if (! found) {
3385       newParentWidget = new QGroupBox();         3347       newParentWidget = new QGroupBox();
3386       newParentWidget->setLayout(new QVBoxLay    3348       newParentWidget->setLayout(new QVBoxLayout());
3387       if (aParent->layout() == nullptr) {        3349       if (aParent->layout() == nullptr) {
3388         aParent->setLayout(new QVBoxLayout())    3350         aParent->setLayout(new QVBoxLayout());
3389       }                                          3351       }
3390       aParent->layout()->addWidget(newParentW    3352       aParent->layout()->addWidget(newParentWidget);
3391                                                  3353 
3392       // set toolTip                             3354       // set toolTip
3393       // Guidance                                3355       // Guidance
3394       QString guidance;                          3356       QString guidance;
3395       auto n_guidanceEntry = (G4int)aCommand-    3357       auto n_guidanceEntry = (G4int)aCommand->GetGuidanceEntries();
3396       for (G4int i_thGuidance = 0; i_thGuidan    3358       for (G4int i_thGuidance = 0; i_thGuidance < n_guidanceEntry; i_thGuidance++) {
3397         guidance += QString((char*)(aCommand-    3359         guidance += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n";
3398       }                                          3360       }
3399       newParentWidget->setToolTip(guidance);     3361       newParentWidget->setToolTip(guidance);
3400     }                                            3362     }
3401   }                                              3363   }
3402                                                  3364 
3403   // fill command groupbox                       3365   // fill command groupbox
3404   if (commandText.indexOf("/") == -1) {          3366   if (commandText.indexOf("/") == -1) {
3405     if (CreateCommandWidget(aCommand, newPare    3367     if (CreateCommandWidget(aCommand, newParentWidget, isDialog)) {
3406       return true;                               3368       return true;
3407     }                                            3369     }
3408   }                                              3370   }
3409   else {                                         3371   else {
3410     CreateVisCommandGroupAndToolBox(aCommand,    3372     CreateVisCommandGroupAndToolBox(aCommand, newParentWidget, aDepthLevel - 1, isDialog);
3411   }                                              3373   }
3412                                                  3374 
3413   return true;                                   3375   return true;
3414 }                                                3376 }
3415                                                  3377 
3416 /** Create a widget with the command paramete    3378 /** Create a widget with the command parameters inside
3417     @param command: command line                 3379     @param command: command line
3418     @parent : parent widget                      3380     @parent : parent widget
3419     @isDialog : true if we want apply/cancel     3381     @isDialog : true if we want apply/cancel button and close at end, false if we want only apply
3420 */                                               3382 */
3421 G4bool G4UIQt::CreateCommandWidget(G4UIcomman    3383 G4bool G4UIQt::CreateCommandWidget(G4UIcommand* aCommand, QWidget* aParent, G4bool isDialog)
3422 {                                                3384 {
3423   if (aCommand == nullptr) {                     3385   if (aCommand == nullptr) {
3424     return false;                                3386     return false;
3425   }                                              3387   }
3426                                                  3388 
3427   // parameters                                  3389   // parameters
3428   auto n_parameterEntry = (G4int)aCommand->Ge    3390   auto n_parameterEntry = (G4int)aCommand->GetParameterEntries();
3429   if (n_parameterEntry > 0) {                    3391   if (n_parameterEntry > 0) {
3430     G4UIparameter* param;                        3392     G4UIparameter* param;
3431                                                  3393 
3432     // Re-implementation of G4UIparameter.cc     3394     // Re-implementation of G4UIparameter.cc
3433     auto paramWidget = new QWidget();            3395     auto paramWidget = new QWidget();
3434     auto gridLayout = new QGridLayout();         3396     auto gridLayout = new QGridLayout();
3435     paramWidget->setLayout(gridLayout);          3397     paramWidget->setLayout(gridLayout);
3436                                                  3398 
3437     // Special case for colour, try to displa    3399     // Special case for colour, try to display a color chooser if we found red/green/blue parameter
3438     unsigned int nbColorParameter = 0;           3400     unsigned int nbColorParameter = 0;
3439     G4bool isStillColorParameter = false;        3401     G4bool isStillColorParameter = false;
3440     G4bool isColorDialogAdded = false;           3402     G4bool isColorDialogAdded = false;
3441     QLabel* redLabel = nullptr;                  3403     QLabel* redLabel = nullptr;
3442     QLabel* greenLabel = nullptr;                3404     QLabel* greenLabel = nullptr;
3443     QString redDefaultStr = "";                  3405     QString redDefaultStr = "";
3444     QString greenDefaultStr = "";                3406     QString greenDefaultStr = "";
3445     QString blueDefaultStr = "";                 3407     QString blueDefaultStr = "";
3446     QWidget* redInput = nullptr;                 3408     QWidget* redInput = nullptr;
3447     QWidget* greenInput = nullptr;               3409     QWidget* greenInput = nullptr;
3448                                                  3410 
3449     for (G4int i_thParameter = 0; i_thParamet    3411     for (G4int i_thParameter = 0; i_thParameter < n_parameterEntry; i_thParameter++) {
3450       QString txt;                               3412       QString txt;
3451       param = aCommand->GetParameter(i_thPara    3413       param = aCommand->GetParameter(i_thParameter);
3452       auto label = new QLabel(QString((char*)    3414       auto label = new QLabel(QString((char*)(param->GetParameterName()).data()));
3453                                                  3415 
3454       if ((label->text() == "red") || (label-    3416       if ((label->text() == "red") || (label->text() == "red_or_string")) {
3455         nbColorParameter++;                      3417         nbColorParameter++;
3456         isStillColorParameter = true;            3418         isStillColorParameter = true;
3457       }                                          3419       }
3458       else if ((label->text() == "green") &&     3420       else if ((label->text() == "green") && isStillColorParameter) {
3459         nbColorParameter++;                      3421         nbColorParameter++;
3460       }                                          3422       }
3461       else if ((label->text() == "blue") && i    3423       else if ((label->text() == "blue") && isStillColorParameter) {
3462         nbColorParameter++;                      3424         nbColorParameter++;
3463       }                                          3425       }
3464       else if (! isColorDialogAdded) {           3426       else if (! isColorDialogAdded) {
3465         // not following red/green/blue param    3427         // not following red/green/blue parameters ?
3466         if (nbColorParameter == 1) {             3428         if (nbColorParameter == 1) {
3467           gridLayout->addWidget(redLabel, i_t    3429           gridLayout->addWidget(redLabel, i_thParameter - 1, 0);
3468           gridLayout->addWidget(redInput, i_t    3430           gridLayout->addWidget(redInput, i_thParameter - 1, 1);
3469         }                                        3431         }
3470         else if (nbColorParameter == 2) {        3432         else if (nbColorParameter == 2) {
3471           gridLayout->addWidget(redLabel, i_t    3433           gridLayout->addWidget(redLabel, i_thParameter - 2, 0);
3472           gridLayout->addWidget(redInput, i_t    3434           gridLayout->addWidget(redInput, i_thParameter - 2, 1);
3473           gridLayout->addWidget(greenLabel, i    3435           gridLayout->addWidget(greenLabel, i_thParameter - 1, 0);
3474           gridLayout->addWidget(greenInput, i    3436           gridLayout->addWidget(greenInput, i_thParameter - 1, 1);
3475         }                                        3437         }
3476         nbColorParameter = 0;                    3438         nbColorParameter = 0;
3477       }                                          3439       }
3478       // Check parameter type, could be NULL     3440       // Check parameter type, could be NULL if not found
3479       QWidget* input = nullptr;                  3441       QWidget* input = nullptr;
3480       if ((QString(QChar(param->GetParameterT    3442       if ((QString(QChar(param->GetParameterType())) == "d") ||
3481           (QString(QChar(param->GetParameterT    3443           (QString(QChar(param->GetParameterType())) == "i"))
3482       {                                          3444       {
3483         input = new QLineEdit();                 3445         input = new QLineEdit();
3484         // set default value                     3446         // set default value
3485         dynamic_cast<QLineEdit*>(input)->setT    3447         dynamic_cast<QLineEdit*>(input)->setText(QString((char*)(param->GetDefaultValue()).data()));
3486                                                  3448 
3487         if (((label->text() == "red") || (lab    3449         if (((label->text() == "red") || (label->text() == "red_or_string")) &&
3488             isStillColorParameter)               3450             isStillColorParameter)
3489         {                                        3451         {
3490           redDefaultStr = QString((char*)(par    3452           redDefaultStr = QString((char*)(param->GetDefaultValue()).data());
3491         }                                        3453         }
3492         else if ((label->text() == "green") &    3454         else if ((label->text() == "green") && isStillColorParameter) {
3493           greenDefaultStr = QString((char*)(p    3455           greenDefaultStr = QString((char*)(param->GetDefaultValue()).data());
3494         }                                        3456         }
3495         else if ((label->text() == "blue") &&    3457         else if ((label->text() == "blue") && isStillColorParameter) {
3496           blueDefaultStr = QString((char*)(pa    3458           blueDefaultStr = QString((char*)(param->GetDefaultValue()).data());
3497         }                                        3459         }
3498       }                                          3460       }
3499       else if (QString(QChar(param->GetParame    3461       else if (QString(QChar(param->GetParameterType())) == "b") {
3500         input = new QWidget();                   3462         input = new QWidget();
3501         auto layout = new QHBoxLayout();         3463         auto layout = new QHBoxLayout();
3502         input->setLayout(layout);                3464         input->setLayout(layout);
3503                                                  3465 
3504         auto buttons = new QButtonGroup();       3466         auto buttons = new QButtonGroup();
3505         auto radioOff = new QRadioButton("0")    3467         auto radioOff = new QRadioButton("0");
3506         auto radioOn = new QRadioButton("1");    3468         auto radioOn = new QRadioButton("1");
3507         buttons->addButton(radioOn);             3469         buttons->addButton(radioOn);
3508         buttons->addButton(radioOff);            3470         buttons->addButton(radioOff);
3509         layout->addWidget(radioOn);              3471         layout->addWidget(radioOn);
3510         layout->addWidget(radioOff);             3472         layout->addWidget(radioOff);
3511                                                  3473 
3512         // set default value                     3474         // set default value
3513         QString defaultValue = QString((char*    3475         QString defaultValue = QString((char*)(param->GetDefaultValue()).data());
3514         if (defaultValue == "0") {               3476         if (defaultValue == "0") {
3515           radioOff->setChecked(true);            3477           radioOff->setChecked(true);
3516         }                                        3478         }
3517         else if (defaultValue == "1") {          3479         else if (defaultValue == "1") {
3518           radioOn->setChecked(true);             3480           radioOn->setChecked(true);
3519         }                                        3481         }
3520       }                                          3482       }
3521       else if ((QString(QChar(param->GetParam    3483       else if ((QString(QChar(param->GetParameterType())) == "s") &&
3522                (! param->GetParameterCandidat    3484                (! param->GetParameterCandidates().empty()))
3523       {                                          3485       {
3524         input = new QComboBox();                 3486         input = new QComboBox();
3525         QString candidates = QString((char*)(    3487         QString candidates = QString((char*)(param->GetParameterCandidates()).data());
3526         QStringList list = candidates.split("    3488         QStringList list = candidates.split(" ");
3527                                                  3489 
3528         // add all candidates to widget          3490         // add all candidates to widget
3529         QString defaultValue = QString((char*    3491         QString defaultValue = QString((char*)(param->GetDefaultValue()).data());
3530         for (int a = 0; a < list.size(); a++)    3492         for (int a = 0; a < list.size(); a++) {
3531           dynamic_cast<QComboBox*>(input)->ad    3493           dynamic_cast<QComboBox*>(input)->addItem(list.at(a));
3532           if (list.at(a) == defaultValue) {      3494           if (list.at(a) == defaultValue) {
3533             dynamic_cast<QComboBox*>(input)->    3495             dynamic_cast<QComboBox*>(input)->setCurrentIndex(a);
3534           }                                      3496           }
3535         }                                        3497         }
3536       }                                          3498       }
3537       else if ((QString(QChar(param->GetParam    3499       else if ((QString(QChar(param->GetParameterType())) == "s")) {  // string
3538         input = new QLineEdit();                 3500         input = new QLineEdit();
3539         // set default value                     3501         // set default value
3540         dynamic_cast<QLineEdit*>(input)->setT    3502         dynamic_cast<QLineEdit*>(input)->setText(QString((char*)(param->GetDefaultValue()).data()));
3541       }                                          3503       }
3542       else if ((QString(QChar(param->GetParam    3504       else if ((QString(QChar(param->GetParameterType())) == "c")) {  // on/off
3543         input = new QWidget();                   3505         input = new QWidget();
3544         auto layout = new QHBoxLayout();         3506         auto layout = new QHBoxLayout();
3545         input->setLayout(layout);                3507         input->setLayout(layout);
3546                                                  3508 
3547         auto buttons = new QButtonGroup();       3509         auto buttons = new QButtonGroup();
3548         auto radioOff = new QRadioButton("off    3510         auto radioOff = new QRadioButton("off");
3549         auto radioOn = new QRadioButton("on")    3511         auto radioOn = new QRadioButton("on");
3550         buttons->addButton(radioOn);             3512         buttons->addButton(radioOn);
3551         buttons->addButton(radioOff);            3513         buttons->addButton(radioOff);
3552         layout->addWidget(radioOn);              3514         layout->addWidget(radioOn);
3553         layout->addWidget(radioOff);             3515         layout->addWidget(radioOff);
3554                                                  3516 
3555         // set default value                     3517         // set default value
3556         QString defaultValue = QString((char*    3518         QString defaultValue = QString((char*)(param->GetDefaultValue()).data());
3557         if (defaultValue == "off") {             3519         if (defaultValue == "off") {
3558           radioOff->setChecked(true);            3520           radioOff->setChecked(true);
3559         }                                        3521         }
3560         else if (defaultValue == "on") {         3522         else if (defaultValue == "on") {
3561           radioOn->setChecked(true);             3523           radioOn->setChecked(true);
3562         }                                        3524         }
3563       }                                          3525       }
3564       else {                                     3526       else {
3565         input = new QLineEdit();                 3527         input = new QLineEdit();
3566         dynamic_cast<QLineEdit*>(input)->setT    3528         dynamic_cast<QLineEdit*>(input)->setText(QString((char*)(param->GetDefaultValue()).data()));
3567       }                                          3529       }
3568                                                  3530 
3569       txt += "\nParameter : " + QString((char    3531       txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n";
3570       if (! param->GetParameterGuidance().emp    3532       if (! param->GetParameterGuidance().empty())
3571         txt += QString((char*)(param->GetPara    3533         txt += QString((char*)(param->GetParameterGuidance()).data()) + "\n";
3572                                                  3534 
3573       txt += " Parameter type  : " + QString(    3535       txt += " Parameter type  : " + QString(QChar(param->GetParameterType())) + "\n";
3574       if (param->IsOmittable()) {                3536       if (param->IsOmittable()) {
3575         txt += " Omittable       : True\n";      3537         txt += " Omittable       : True\n";
3576       }                                          3538       }
3577       else {                                     3539       else {
3578         txt += " Omittable       : False\n";     3540         txt += " Omittable       : False\n";
3579       }                                          3541       }
3580       if (param->GetCurrentAsDefault()) {        3542       if (param->GetCurrentAsDefault()) {
3581         txt += " Default value   : taken from    3543         txt += " Default value   : taken from the current value\n";
3582       }                                          3544       }
3583       else if (! param->GetDefaultValue().emp    3545       else if (! param->GetDefaultValue().empty()) {
3584         txt += " Default value   : " + QStrin    3546         txt += " Default value   : " + QString((char*)(param->GetDefaultValue()).data()) + "\n";
3585       }                                          3547       }
3586       if (! param->GetParameterRange().empty(    3548       if (! param->GetParameterRange().empty()) {
3587         txt += " Parameter range : " + QStrin    3549         txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data()) + "\n";
3588       }                                          3550       }
3589       if (! param->GetParameterCandidates().e    3551       if (! param->GetParameterCandidates().empty()) {
3590         txt +=                                   3552         txt +=
3591           " Candidates      : " + QString((ch    3553           " Candidates      : " + QString((char*)(param->GetParameterCandidates()).data()) + "\n";
3592       }                                          3554       }
3593                                                  3555 
3594       if (isStillColorParameter && (nbColorPa    3556       if (isStillColorParameter && (nbColorParameter != 0)) {
3595         if ((label->text() == "red") || (labe    3557         if ((label->text() == "red") || (label->text() == "red_or_string")) {
3596           redLabel = label;                      3558           redLabel = label;
3597           redInput = input;                      3559           redInput = input;
3598         }                                        3560         }
3599         else if (label->text() == "green") {     3561         else if (label->text() == "green") {
3600           greenLabel = label;                    3562           greenLabel = label;
3601           greenInput = input;                    3563           greenInput = input;
3602         }                                        3564         }
3603         else if (label->text() == "blue") {      3565         else if (label->text() == "blue") {
3604           // we have all, then add a color ch    3566           // we have all, then add a color chooser
3605                                                  3567 
3606           // Create a pixmap with the default    3568           // Create a pixmap with the default color
3607           QColor qc;                             3569           QColor qc;
3608           if ((redDefaultStr != "") && (redDe    3570           if ((redDefaultStr != "") && (redDefaultStr != "") && (redDefaultStr != "")) {
3609             qc.setRgbF(                          3571             qc.setRgbF(
3610               redDefaultStr.toDouble(), green    3572               redDefaultStr.toDouble(), greenDefaultStr.toDouble(), blueDefaultStr.toDouble());
3611           }                                      3573           }
3612           QPixmap pixmap = QPixmap(QSize(16,     3574           QPixmap pixmap = QPixmap(QSize(16, 16));
3613           pixmap.fill(qc);                       3575           pixmap.fill(qc);
3614           QPainter painter(&pixmap);             3576           QPainter painter(&pixmap);
3615           painter.setPen(Qt::black);             3577           painter.setPen(Qt::black);
3616           painter.drawRect(0, 0, 15, 15);  //    3578           painter.drawRect(0, 0, 15, 15);  // Draw contour
3617                                                  3579 
3618           input = new QPushButton("Change col    3580           input = new QPushButton("Change color");
3619           dynamic_cast<QPushButton*>(input)->    3581           dynamic_cast<QPushButton*>(input)->setIcon(pixmap);
3620           dynamic_cast<QPushButton*>(input)->    3582           dynamic_cast<QPushButton*>(input)->setAccessibleName(
3621             redDefaultStr + " " + greenDefaul    3583             redDefaultStr + " " + greenDefaultStr + " " + blueDefaultStr);
3622           label = new QLabel("Choose color");    3584           label = new QLabel("Choose color");
3623                                                  3585 
3624           // less 1 because we have to add on    3586           // less 1 because we have to add one to the row number
3625           nbColorParameter--;                    3587           nbColorParameter--;
3626           gridLayout->addWidget(label, i_thPa    3588           gridLayout->addWidget(label, i_thParameter - nbColorParameter, 0);
3627           input->setToolTip("Select the curre    3589           input->setToolTip("Select the current color");
3628           gridLayout->addWidget(input, i_thPa    3590           gridLayout->addWidget(input, i_thParameter - nbColorParameter, 1);
3629                                                  3591 
3630           // Connect pushButton to ColorDialo    3592           // Connect pushButton to ColorDialog in callback
3631           connect(dynamic_cast<QPushButton*>(    3593           connect(dynamic_cast<QPushButton*>(input), &QPushButton::clicked,
3632             [this, input]() { this->ChangeCol    3594             [this, input]() { this->ChangeColorCallback(input); });
3633           isColorDialogAdded = true;             3595           isColorDialogAdded = true;
3634           isStillColorParameter = false;         3596           isStillColorParameter = false;
3635         }                                        3597         }
3636       }                                          3598       }
3637       else {                                     3599       else {
3638         gridLayout->addWidget(label, i_thPara    3600         gridLayout->addWidget(label, i_thParameter - nbColorParameter, 0);
3639         input->setToolTip(txt);                  3601         input->setToolTip(txt);
3640         gridLayout->addWidget(input, i_thPara    3602         gridLayout->addWidget(input, i_thParameter - nbColorParameter, 1);
3641       }                                          3603       }
3642     }                                            3604     }
3643     // add command name in hidden value at la    3605     // add command name in hidden value at last line position 0
3644     auto name = new QLabel(QString((char*)(aC    3606     auto name = new QLabel(QString((char*)(aCommand->GetCommandPath().data())));
3645     name->hide();                                3607     name->hide();
3646     gridLayout->addWidget(name, n_parameterEn    3608     gridLayout->addWidget(name, n_parameterEntry - nbColorParameter, 0);
3647                                                  3609 
3648     auto applyButton = new QPushButton("Apply    3610     auto applyButton = new QPushButton("Apply");
3649     if (! isDialog) {                            3611     if (! isDialog) {
3650       gridLayout->addWidget(applyButton, n_pa    3612       gridLayout->addWidget(applyButton, n_parameterEntry - nbColorParameter, 1);
3651       connect(applyButton, &QPushButton::clic    3613       connect(applyButton, &QPushButton::clicked,
3652         [this, paramWidget]() { this->VisPara    3614         [this, paramWidget]() { this->VisParameterCallback(paramWidget); });
3653     }                                            3615     }
3654     else {                                       3616     else {
3655       // Apply/Cancel buttons                    3617       // Apply/Cancel buttons
3656                                                  3618 
3657       applyButton->setAutoDefault(true);         3619       applyButton->setAutoDefault(true);
3658       applyButton->setDefault(true);             3620       applyButton->setDefault(true);
3659                                                  3621 
3660       auto cancelButton = new QPushButton(tr(    3622       auto cancelButton = new QPushButton(tr("&Cancel"));
3661       cancelButton->setAutoDefault(true);        3623       cancelButton->setAutoDefault(true);
3662       gridLayout->addWidget(cancelButton, n_p    3624       gridLayout->addWidget(cancelButton, n_parameterEntry - nbColorParameter, 1);
3663       gridLayout->addWidget(applyButton, n_pa    3625       gridLayout->addWidget(applyButton, n_parameterEntry - nbColorParameter, 0);
3664                                                  3626 
3665       connect(applyButton, &QPushButton::clic    3627       connect(applyButton, &QPushButton::clicked,
3666         [this, paramWidget]() { this->VisPara    3628         [this, paramWidget]() { this->VisParameterCallback(paramWidget); });
3667                                                  3629 
3668       QWidget* parentCheck = aParent;            3630       QWidget* parentCheck = aParent;
3669       QDialog* parentDialog = nullptr;           3631       QDialog* parentDialog = nullptr;
3670       G4bool found = false;                      3632       G4bool found = false;
3671       while ((parentCheck->parentWidget()) !=    3633       while ((parentCheck->parentWidget()) != nullptr) {
3672         parentCheck = parentCheck->parentWidg    3634         parentCheck = parentCheck->parentWidget();
3673         parentDialog = dynamic_cast<QDialog*>    3635         parentDialog = dynamic_cast<QDialog*>(parentCheck);
3674         if (parentDialog != nullptr) {           3636         if (parentDialog != nullptr) {
3675           connect(applyButton, SIGNAL(clicked    3637           connect(applyButton, SIGNAL(clicked()), parentDialog, SLOT(accept()));
3676           connect(cancelButton, SIGNAL(clicke    3638           connect(cancelButton, SIGNAL(clicked()), parentDialog, SLOT(reject()));
3677           found = true;                          3639           found = true;
3678         }                                        3640         }
3679       }                                          3641       }
3680       if (! found) {                             3642       if (! found) {
3681         return false;                            3643         return false;
3682       }                                          3644       }
3683     }                                            3645     }
3684                                                  3646 
3685     if (aParent->layout() == nullptr) {          3647     if (aParent->layout() == nullptr) {
3686       aParent->setLayout(new QVBoxLayout());     3648       aParent->setLayout(new QVBoxLayout());
3687     }                                            3649     }
3688     aParent->layout()->addWidget(paramWidget)    3650     aParent->layout()->addWidget(paramWidget);
3689   }                                              3651   }
3690                                                  3652 
3691   return true;                                   3653   return true;
3692 }                                                3654 }
3693                                                  3655 
3694 /** Find a treeItemWidget in the help tree       3656 /** Find a treeItemWidget in the help tree
3695     @param aCommand item's String to look for    3657     @param aCommand item's String to look for
3696     @return item if found, NULL if not           3658     @return item if found, NULL if not
3697 */                                               3659 */
3698 QTreeWidgetItem* G4UIQt::FindTreeItem(QTreeWi    3660 QTreeWidgetItem* G4UIQt::FindTreeItem(QTreeWidgetItem* aParent, const QString& aCommand)
3699 {                                                3661 {
3700   if (aParent == nullptr) return nullptr;        3662   if (aParent == nullptr) return nullptr;
3701                                                  3663 
3702   // Suppress last "/"                           3664   // Suppress last "/"
3703   QString myCommand = aCommand;                  3665   QString myCommand = aCommand;
3704                                                  3666 
3705   if (myCommand.lastIndexOf("/") == (myComman    3667   if (myCommand.lastIndexOf("/") == (myCommand.size() - 1)) {
3706     myCommand = myCommand.left(myCommand.size    3668     myCommand = myCommand.left(myCommand.size() - 1);
3707   }                                              3669   }
3708                                                  3670 
3709   if (GetLongCommandPath(aParent) == myComman    3671   if (GetLongCommandPath(aParent) == myCommand) return aParent;
3710                                                  3672 
3711   QTreeWidgetItem* tmp = nullptr;                3673   QTreeWidgetItem* tmp = nullptr;
3712   for (G4int a = 0; a < aParent->childCount()    3674   for (G4int a = 0; a < aParent->childCount(); ++a) {
3713     if (tmp == nullptr) tmp = FindTreeItem(aP    3675     if (tmp == nullptr) tmp = FindTreeItem(aParent->child(a), myCommand);
3714   }                                              3676   }
3715   return tmp;                                    3677   return tmp;
3716 }                                                3678 }
3717                                                  3679 
3718 /**   Build the command list parameters in a     3680 /**   Build the command list parameters in a QString<br>
3719  Reimplement partialy the G4UIparameter.cc       3681  Reimplement partialy the G4UIparameter.cc
3720  @param aCommand : command to list parameters    3682  @param aCommand : command to list parameters
3721  @see G4UIparameter::List()                      3683  @see G4UIparameter::List()
3722  @see G4UIcommand::List()                        3684  @see G4UIcommand::List()
3723  @return the command list parameters, or "" i    3685  @return the command list parameters, or "" if nothing
3724  */                                              3686  */
3725 QString G4UIQt::GetCommandList(const G4UIcomm    3687 QString G4UIQt::GetCommandList(const G4UIcommand* aCommand)
3726 {                                                3688 {
3727   QString txt = "";                              3689   QString txt = "";
3728   if (aCommand == nullptr) return txt;           3690   if (aCommand == nullptr) return txt;
3729                                                  3691 
3730   G4String commandPath = aCommand->GetCommand    3692   G4String commandPath = aCommand->GetCommandPath();
3731   G4String rangeString = aCommand->GetRange()    3693   G4String rangeString = aCommand->GetRange();
3732   auto n_guidanceEntry = (G4int)aCommand->Get    3694   auto n_guidanceEntry = (G4int)aCommand->GetGuidanceEntries();
3733   auto n_parameterEntry = (G4int)aCommand->Ge    3695   auto n_parameterEntry = (G4int)aCommand->GetParameterEntries();
3734                                                  3696 
3735   if ((commandPath.empty()) && (rangeString.e    3697   if ((commandPath.empty()) && (rangeString.empty()) && (n_guidanceEntry == 0) &&
3736       (n_parameterEntry == 0))                   3698       (n_parameterEntry == 0))
3737   {                                              3699   {
3738     return txt;                                  3700     return txt;
3739   }                                              3701   }
3740                                                  3702 
3741   if ((commandPath.length() - 1) != '/') {       3703   if ((commandPath.length() - 1) != '/') {
3742     txt += "Command " + QString((char*)(comma    3704     txt += "Command " + QString((char*)(commandPath).data()) + "\n";
3743   }                                              3705   }
3744   txt += "Guidance :\n";                         3706   txt += "Guidance :\n";
3745                                                  3707 
3746   for (G4int i_thGuidance = 0; i_thGuidance <    3708   for (G4int i_thGuidance = 0; i_thGuidance < n_guidanceEntry; i_thGuidance++) {
3747     txt += QString((char*)(aCommand->GetGuida    3709     txt += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n";
3748   }                                              3710   }
3749   if (! rangeString.empty()) {                   3711   if (! rangeString.empty()) {
3750     txt += " Range of parameters : " + QStrin    3712     txt += " Range of parameters : " + QString((char*)(rangeString).data()) + "\n";
3751   }                                              3713   }
3752   if (n_parameterEntry > 0) {                    3714   if (n_parameterEntry > 0) {
3753     G4UIparameter* param;                        3715     G4UIparameter* param;
3754                                                  3716 
3755     // Re-implementation of G4UIparameter.cc     3717     // Re-implementation of G4UIparameter.cc
3756                                                  3718 
3757     for (G4int i_thParameter = 0; i_thParamet    3719     for (G4int i_thParameter = 0; i_thParameter < n_parameterEntry; i_thParameter++) {
3758       param = aCommand->GetParameter(i_thPara    3720       param = aCommand->GetParameter(i_thParameter);
3759       txt += "\nParameter : " + QString((char    3721       txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n";
3760       if (! param->GetParameterGuidance().emp    3722       if (! param->GetParameterGuidance().empty())
3761         txt += QString((char*)(param->GetPara    3723         txt += QString((char*)(param->GetParameterGuidance()).data()) + "\n";
3762       txt += " Parameter type  : " + QString(    3724       txt += " Parameter type  : " + QString(QChar(param->GetParameterType())) + "\n";
3763       if (param->IsOmittable()) {                3725       if (param->IsOmittable()) {
3764         txt += " Omittable       : True\n";      3726         txt += " Omittable       : True\n";
3765       }                                          3727       }
3766       else {                                     3728       else {
3767         txt += " Omittable       : False\n";     3729         txt += " Omittable       : False\n";
3768       }                                          3730       }
3769       if (param->GetCurrentAsDefault()) {        3731       if (param->GetCurrentAsDefault()) {
3770         txt += " Default value   : taken from    3732         txt += " Default value   : taken from the current value\n";
3771       }                                          3733       }
3772       else if (! param->GetDefaultValue().emp    3734       else if (! param->GetDefaultValue().empty()) {
3773         txt += " Default value   : " + QStrin    3735         txt += " Default value   : " + QString((char*)(param->GetDefaultValue()).data()) + "\n";
3774       }                                          3736       }
3775       if (! param->GetParameterRange().empty(    3737       if (! param->GetParameterRange().empty()) {
3776         txt += " Parameter range : " + QStrin    3738         txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data()) + "\n";
3777       }                                          3739       }
3778       if (! param->GetParameterCandidates().e    3740       if (! param->GetParameterCandidates().empty()) {
3779         txt +=                                   3741         txt +=
3780           " Candidates      : " + QString((ch    3742           " Candidates      : " + QString((char*)(param->GetParameterCandidates()).data()) + "\n";
3781       }                                          3743       }
3782     }                                            3744     }
3783   }                                              3745   }
3784   return txt;                                    3746   return txt;
3785 }                                                3747 }
3786                                                  3748 
3787 /**   Build the command list parameters in a     3749 /**   Build the command list parameters in a QString with HTML<br>
3788    Reimplement partialy the G4UIparameter.cc     3750    Reimplement partialy the G4UIparameter.cc
3789    @param aCommand : command to list paramete    3751    @param aCommand : command to list parameters
3790    @see G4UIparameter::List()                    3752    @see G4UIparameter::List()
3791    @see G4UIcommand::List()                      3753    @see G4UIcommand::List()
3792    @return the command list parameters, or ""    3754    @return the command list parameters, or "" if nothing
3793 */                                               3755 */
3794 void G4UIQt::updateHelpArea(const G4UIcommand    3756 void G4UIQt::updateHelpArea(const G4UIcommand* aCommand)
3795 {                                                3757 {
3796   if (fParameterHelpLabel == nullptr) return;    3758   if (fParameterHelpLabel == nullptr) return;
3797   if (fParameterHelpTable == nullptr) return;    3759   if (fParameterHelpTable == nullptr) return;
3798                                                  3760 
3799   fParameterHelpLabel->setTextInteractionFlag    3761   fParameterHelpLabel->setTextInteractionFlags(Qt::NoTextInteraction);
3800   QString txt;                                   3762   QString txt;
3801   if (aCommand == nullptr) return;               3763   if (aCommand == nullptr) return;
3802                                                  3764 
3803   G4String commandPath = aCommand->GetCommand    3765   G4String commandPath = aCommand->GetCommandPath();
3804   G4String rangeString = aCommand->GetRange()    3766   G4String rangeString = aCommand->GetRange();
3805   auto n_guidanceEntry = (G4int)aCommand->Get    3767   auto n_guidanceEntry = (G4int)aCommand->GetGuidanceEntries();
3806   auto n_parameterEntry = (G4int)aCommand->Ge    3768   auto n_parameterEntry = (G4int)aCommand->GetParameterEntries();
3807                                                  3769 
3808   if ((commandPath.empty()) && (rangeString.e    3770   if ((commandPath.empty()) && (rangeString.empty()) && (n_guidanceEntry == 0) &&
3809       (n_parameterEntry == 0))                   3771       (n_parameterEntry == 0))
3810   {                                              3772   {
3811     return;                                      3773     return;
3812   }                                              3774   }
3813                                                  3775 
3814   if ((commandPath.length() - 1) != '/') {       3776   if ((commandPath.length() - 1) != '/') {
3815     txt += "<b>Command </b> " + QString((char    3777     txt += "<b>Command </b> " + QString((char*)(commandPath).data()) + "<br />";
3816   }                                              3778   }
3817   txt += "<b>Guidance :</b> ";                   3779   txt += "<b>Guidance :</b> ";
3818   QString tmpGuidance = "";                      3780   QString tmpGuidance = "";
3819   for (G4int i_thGuidance = 0; i_thGuidance <    3781   for (G4int i_thGuidance = 0; i_thGuidance < n_guidanceEntry; i_thGuidance++) {
3820     tmpGuidance = QString((char*)(aCommand->G    3782     tmpGuidance = QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data());
3821     tmpGuidance = tmpGuidance.toHtmlEscaped()    3783     tmpGuidance = tmpGuidance.toHtmlEscaped();
3822     tmpGuidance.replace("\n", "<br />");         3784     tmpGuidance.replace("\n", "<br />");
3823     txt += tmpGuidance + "<br />";               3785     txt += tmpGuidance + "<br />";
3824   }                                              3786   }
3825   if (! rangeString.empty()) {                   3787   if (! rangeString.empty()) {
3826     QString range = QString((char*)(rangeStri    3788     QString range = QString((char*)(rangeString).data());
3827     range = range.toHtmlEscaped();               3789     range = range.toHtmlEscaped();
3828     txt += "<b>Range of parameters : </b> " +    3790     txt += "<b>Range of parameters : </b> " + range + "<br />";
3829   }                                              3791   }
3830   else {                                         3792   else {
3831     txt += "<br />";                             3793     txt += "<br />";
3832   }                                              3794   }
3833   fParameterHelpLabel->setHtml(txt);             3795   fParameterHelpLabel->setHtml(txt);
3834                                                  3796 
3835   if (n_parameterEntry > 0) {                    3797   if (n_parameterEntry > 0) {
3836     G4UIparameter* param;                        3798     G4UIparameter* param;
3837                                                  3799 
3838     // Re-implementation of G4UIparameter.cc     3800     // Re-implementation of G4UIparameter.cc
3839                                                  3801 
3840     fParameterHelpTable->clear();                3802     fParameterHelpTable->clear();
3841     fParameterHelpTable->setRowCount(n_parame    3803     fParameterHelpTable->setRowCount(n_parameterEntry);
3842     fParameterHelpTable->setColumnCount(8);      3804     fParameterHelpTable->setColumnCount(8);
3843     fParameterHelpTable->setHorizontalHeaderL    3805     fParameterHelpTable->setHorizontalHeaderLabels(
3844       QStringList() << tr("") << tr("Paramete    3806       QStringList() << tr("") << tr("Parameter") << tr("Guidance") << tr("Type") << tr("Ommitable")
3845                     << tr("Default") << tr("R    3807                     << tr("Default") << tr("Range") << tr("Candidate"));
3846     fParameterHelpTable->setColumnWidth(2, 60    3808     fParameterHelpTable->setColumnWidth(2, 60);
3847                                                  3809 
3848     fParameterHelpTable->verticalHeader()->se    3810     fParameterHelpTable->verticalHeader()->setVisible(false);
3849     fParameterHelpTable->setAlternatingRowCol    3811     fParameterHelpTable->setAlternatingRowColors(true);
3850     fParameterHelpTable->verticalHeader()->se    3812     fParameterHelpTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
3851     fParameterHelpTable->horizontalHeader()->    3813     fParameterHelpTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
3852     fParameterHelpTable->setWordWrap(true);      3814     fParameterHelpTable->setWordWrap(true);
3853                                                  3815 
3854     QTableWidgetItem* t = fParameterHelpTable    3816     QTableWidgetItem* t = fParameterHelpTable->horizontalHeaderItem(1);
3855     QFont fnt = t->font();                       3817     QFont fnt = t->font();
3856     G4int size = fnt.pointSize();                3818     G4int size = fnt.pointSize();
3857     fnt.setPointSize(size - 2);                  3819     fnt.setPointSize(size - 2);
3858                                                  3820 
3859     for (G4int a = 0; a < n_parameterEntry; a    3821     for (G4int a = 0; a < n_parameterEntry; a++) {
3860       param = aCommand->GetParameter(a);         3822       param = aCommand->GetParameter(a);
3861       fParameterHelpTable->setItem(a, 0, new     3823       fParameterHelpTable->setItem(a, 0, new QTableWidgetItem(QString::number(a + 1)));
3862                                                  3824 
3863       fParameterHelpTable->setItem(              3825       fParameterHelpTable->setItem(
3864         a, 1, new QTableWidgetItem(QString((c    3826         a, 1, new QTableWidgetItem(QString((char*)(param->GetParameterName()).data())));
3865       if (! param->GetParameterGuidance().emp    3827       if (! param->GetParameterGuidance().empty()) {
3866         fParameterHelpTable->setItem(            3828         fParameterHelpTable->setItem(
3867           a, 2, new QTableWidgetItem(QString(    3829           a, 2, new QTableWidgetItem(QString((char*)(param->GetParameterGuidance()).data())));
3868       }                                          3830       }
3869       fParameterHelpTable->setItem(              3831       fParameterHelpTable->setItem(
3870         a, 3, new QTableWidgetItem(QString(QC    3832         a, 3, new QTableWidgetItem(QString(QChar(param->GetParameterType()))));
3871                                                  3833 
3872       if (param->IsOmittable()) {                3834       if (param->IsOmittable()) {
3873         fParameterHelpTable->setItem(a, 4, ne    3835         fParameterHelpTable->setItem(a, 4, new QTableWidgetItem(QString("True")));
3874       }                                          3836       }
3875       else {                                     3837       else {
3876         fParameterHelpTable->setItem(a, 4, ne    3838         fParameterHelpTable->setItem(a, 4, new QTableWidgetItem(QString("False")));
3877       }                                          3839       }
3878       if (param->GetCurrentAsDefault()) {        3840       if (param->GetCurrentAsDefault()) {
3879         fParameterHelpTable->setItem(            3841         fParameterHelpTable->setItem(
3880           a, 5, new QTableWidgetItem(QString(    3842           a, 5, new QTableWidgetItem(QString("taken from the current value")));
3881       }                                          3843       }
3882       else if (! param->GetDefaultValue().emp    3844       else if (! param->GetDefaultValue().empty()) {
3883         fParameterHelpTable->setItem(            3845         fParameterHelpTable->setItem(
3884           a, 5, new QTableWidgetItem(QString(    3846           a, 5, new QTableWidgetItem(QString((char*)(param->GetDefaultValue()).data())));
3885       }                                          3847       }
3886       if (! param->GetParameterRange().empty(    3848       if (! param->GetParameterRange().empty()) {
3887         fParameterHelpTable->setItem(            3849         fParameterHelpTable->setItem(
3888           a, 6, new QTableWidgetItem(QString(    3850           a, 6, new QTableWidgetItem(QString((char*)(param->GetParameterRange()).data())));
3889       }                                          3851       }
3890       if (! param->GetParameterCandidates().e    3852       if (! param->GetParameterCandidates().empty()) {
3891         fParameterHelpTable->setItem(            3853         fParameterHelpTable->setItem(
3892           a, 7, new QTableWidgetItem(QString(    3854           a, 7, new QTableWidgetItem(QString((char*)(param->GetParameterCandidates()).data())));
3893       }                                          3855       }
3894       // tooltips                                3856       // tooltips
3895       for (G4int b = 0; b < 8; ++b) {            3857       for (G4int b = 0; b < 8; ++b) {
3896         QTableWidgetItem* tmp = fParameterHel    3858         QTableWidgetItem* tmp = fParameterHelpTable->item(a, b);
3897         if (tmp != nullptr) {                    3859         if (tmp != nullptr) {
3898           tmp->setToolTip(tmp->text());          3860           tmp->setToolTip(tmp->text());
3899           tmp->setFlags(Qt::NoItemFlags);        3861           tmp->setFlags(Qt::NoItemFlags);
3900         }                                        3862         }
3901       }                                          3863       }
3902       fParameterHelpTable->resizeRowToContent    3864       fParameterHelpTable->resizeRowToContents(a);
3903     }                                            3865     }
3904     for (G4int c = 0; c < 8; ++c) {              3866     for (G4int c = 0; c < 8; ++c) {
3905       if (c != 2) {                              3867       if (c != 2) {
3906         fParameterHelpTable->resizeColumnToCo    3868         fParameterHelpTable->resizeColumnToContents(c);
3907       }                                          3869       }
3908     }                                            3870     }
3909     fParameterHelpLabel->setVisible(true);       3871     fParameterHelpLabel->setVisible(true);
3910     fParameterHelpTable->setVisible(true);       3872     fParameterHelpTable->setVisible(true);
3911   }                                              3873   }
3912 }                                                3874 }
3913                                                  3875 
3914 /**                                              3876 /**
3915    Return true if this command takes almost a    3877    Return true if this command takes almost a number (int, double, bool,
3916    string) as an input                           3878    string) as an input
3917    or a string with a candidate list             3879    or a string with a candidate list
3918  */                                              3880  */
3919 G4bool G4UIQt::IsGUICommand(const G4UIcommand    3881 G4bool G4UIQt::IsGUICommand(const G4UIcommand* aCommand)
3920 {                                                3882 {
3921   if (aCommand == nullptr) return false;         3883   if (aCommand == nullptr) return false;
3922                                                  3884 
3923   auto n_parameterEntry = (G4int)aCommand->Ge    3885   auto n_parameterEntry = (G4int)aCommand->GetParameterEntries();
3924                                                  3886 
3925   if (n_parameterEntry > 0) {                    3887   if (n_parameterEntry > 0) {
3926     G4UIparameter* param;                        3888     G4UIparameter* param;
3927                                                  3889 
3928     // Re-implementation of G4UIparameter.cc     3890     // Re-implementation of G4UIparameter.cc
3929                                                  3891 
3930     for (G4int i_thParameter = 0; i_thParamet    3892     for (G4int i_thParameter = 0; i_thParameter < n_parameterEntry; i_thParameter++) {
3931       param = aCommand->GetParameter(i_thPara    3893       param = aCommand->GetParameter(i_thParameter);
3932       if (QString(QChar(param->GetParameterTy    3894       if (QString(QChar(param->GetParameterType())) == "d") {
3933         return true;                             3895         return true;
3934       }                                          3896       }
3935       if (QString(QChar(param->GetParameterTy    3897       if (QString(QChar(param->GetParameterType())) == "b") {
3936         return true;                             3898         return true;
3937       }                                          3899       }
3938       if (QString(QChar(param->GetParameterTy    3900       if (QString(QChar(param->GetParameterType())) == "i") {
3939         return true;                             3901         return true;
3940       }                                          3902       }
3941       if (QString(QChar(param->GetParameterTy    3903       if (QString(QChar(param->GetParameterType())) == "s") {
3942         return true;                             3904         return true;
3943       }                                          3905       }
3944     }                                            3906     }
3945   }                                              3907   }
3946   return false;                                  3908   return false;
3947 }                                                3909 }
3948                                                  3910 
3949 /**  Implement G4VBasicShell vurtual function    3911 /**  Implement G4VBasicShell vurtual function
3950  */                                              3912  */
3951 G4bool G4UIQt::GetHelpChoice(G4int&) { return    3913 G4bool G4UIQt::GetHelpChoice(G4int&) { return true; }
3952                                                  3914 
3953 /**   Event filter method. Every event from Q    3915 /**   Event filter method. Every event from QtApplication goes here.<br/>
3954    We apply a filter only for the Up and Down    3916    We apply a filter only for the Up and Down Arrow press when the QLineEdit<br/>
3955    is active. If this filter match, Up arrow     3917    is active. If this filter match, Up arrow we give the previous command<br/>
3956    and Down arrow will give the next if exist    3918    and Down arrow will give the next if exist.<br/>
3957    @param obj Emitter of the event               3919    @param obj Emitter of the event
3958    @param event Kind of event                    3920    @param event Kind of event
3959 */                                               3921 */
3960 G4bool G4UIQt::eventFilter(  // Should stay w    3922 G4bool G4UIQt::eventFilter(  // Should stay with a minuscule eventFilter because of Qt
3961   QObject* aObj, QEvent* aEvent)                 3923   QObject* aObj, QEvent* aEvent)
3962 {                                                3924 {
3963   G4bool tabKeyPress = false;                    3925   G4bool tabKeyPress = false;
3964   G4bool moveCommandCursor = false;              3926   G4bool moveCommandCursor = false;
3965   if (aObj == nullptr) return false;             3927   if (aObj == nullptr) return false;
3966   if (aEvent == nullptr) return false;           3928   if (aEvent == nullptr) return false;
3967                                                  3929 
3968   if (aObj == fHistoryTBTableList) {             3930   if (aObj == fHistoryTBTableList) {
3969     if (aEvent->type() == QEvent::KeyPress) {    3931     if (aEvent->type() == QEvent::KeyPress) {
3970       fCommandArea->setFocus();                  3932       fCommandArea->setFocus();
3971     }                                            3933     }
3972   }                                              3934   }
3973                                                  3935 
3974   if (aObj == fCompleter->popup()) {             3936   if (aObj == fCompleter->popup()) {
3975     if (aEvent->type() == QEvent::KeyPress) {    3937     if (aEvent->type() == QEvent::KeyPress) {
3976       auto e = static_cast<QKeyEvent*>(aEvent    3938       auto e = static_cast<QKeyEvent*>(aEvent);
3977       if (e->key() == (Qt::Key_Tab)) {           3939       if (e->key() == (Qt::Key_Tab)) {
3978         tabKeyPress = true;                      3940         tabKeyPress = true;
3979       }                                          3941       }
3980     }                                            3942     }
3981     else if (aEvent->type() == QEvent::Hide)     3943     else if (aEvent->type() == QEvent::Hide) {
3982       // Store this value                        3944       // Store this value
3983       QString c = fCommandArea->text();          3945       QString c = fCommandArea->text();
3984       fLastCompleteCommand = c.left(c.indexOf    3946       fLastCompleteCommand = c.left(c.indexOf("<"));
3985     }                                            3947     }
3986   }                                              3948   }
3987                                                  3949 
3988   if (aObj == fCommandArea) {                    3950   if (aObj == fCommandArea) {
3989     if (aEvent->type() == QEvent::KeyPress) {    3951     if (aEvent->type() == QEvent::KeyPress) {
3990       auto e = static_cast<QKeyEvent*>(aEvent    3952       auto e = static_cast<QKeyEvent*>(aEvent);
3991       if ((e->key() == (Qt::Key_Down)) || (e-    3953       if ((e->key() == (Qt::Key_Down)) || (e->key() == (Qt::Key_PageDown)) ||
3992           (e->key() == (Qt::Key_Up)) || (e->k    3954           (e->key() == (Qt::Key_Up)) || (e->key() == (Qt::Key_PageUp)))
3993       {                                          3955       {
3994         G4int selection = fHistoryTBTableList    3956         G4int selection = fHistoryTBTableList->currentRow();
3995         if (fHistoryTBTableList->count() != 0    3957         if (fHistoryTBTableList->count() != 0) {
3996           if (selection == -1) {                 3958           if (selection == -1) {
3997             selection = fHistoryTBTableList->    3959             selection = fHistoryTBTableList->count() - 1;
3998           }                                      3960           }
3999           else {                                 3961           else {
4000             if (e->key() == (Qt::Key_Down)) {    3962             if (e->key() == (Qt::Key_Down)) {
4001               if (selection < (fHistoryTBTabl    3963               if (selection < (fHistoryTBTableList->count() - 1)) selection++;
4002             }                                    3964             }
4003             else if (e->key() == (Qt::Key_Pag    3965             else if (e->key() == (Qt::Key_PageDown)) {
4004               selection = fHistoryTBTableList    3966               selection = fHistoryTBTableList->count() - 1;
4005             }                                    3967             }
4006             else if (e->key() == (Qt::Key_Up)    3968             else if (e->key() == (Qt::Key_Up)) {
4007               if (selection > 0) selection--;    3969               if (selection > 0) selection--;
4008             }                                    3970             }
4009             else if (e->key() == (Qt::Key_Pag    3971             else if (e->key() == (Qt::Key_PageUp)) {
4010               selection = 0;                     3972               selection = 0;
4011             }                                    3973             }
4012           }                                      3974           }
4013           fHistoryTBTableList->clearSelection    3975           fHistoryTBTableList->clearSelection();
4014           fHistoryTBTableList->item(selection    3976           fHistoryTBTableList->item(selection)->setSelected(true);
4015           fHistoryTBTableList->setCurrentItem    3977           fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
4016         }                                        3978         }
4017         moveCommandCursor = true;                3979         moveCommandCursor = true;
4018       }                                          3980       }
4019       else if (e->key() == (Qt::Key_Tab)) {      3981       else if (e->key() == (Qt::Key_Tab)) {
4020         tabKeyPress = true;                      3982         tabKeyPress = true;
4021       }                                          3983       }
4022       else if (((e->modifiers() == Qt::Contro    3984       else if (((e->modifiers() == Qt::ControlModifier) || (e->modifiers() == Qt::MetaModifier)) &&
4023                (e->key() == Qt::Key_A))          3985                (e->key() == Qt::Key_A))
4024       {                                          3986       {
4025         fCommandArea->home(false);               3987         fCommandArea->home(false);
4026         return true;                             3988         return true;
4027       }                                          3989       }
4028       else if (((e->modifiers() == Qt::Contro    3990       else if (((e->modifiers() == Qt::ControlModifier) || (e->modifiers() == Qt::MetaModifier)) &&
4029                (e->key() == Qt::Key_E))          3991                (e->key() == Qt::Key_E))
4030       {                                          3992       {
4031         fCommandArea->end(false);                3993         fCommandArea->end(false);
4032         return true;                             3994         return true;
4033       }                                          3995       }
4034     }                                            3996     }
4035     else if (aEvent->type() == QEvent::Paint)    3997     else if (aEvent->type() == QEvent::Paint) {
4036       if (fLastCompleteCommand != "") {          3998       if (fLastCompleteCommand != "") {
4037         fCommandArea->setText(fLastCompleteCo    3999         fCommandArea->setText(fLastCompleteCommand);
4038         fLastCompleteCommand = "";               4000         fLastCompleteCommand = "";
4039       }                                          4001       }
4040     }                                            4002     }
4041   }                                              4003   }
4042   if (tabKeyPress) {                             4004   if (tabKeyPress) {
4043     G4String ss = Complete(fCommandArea->text    4005     G4String ss = Complete(fCommandArea->text().toStdString().c_str());
4044     fCommandArea->setText((char*)(ss.data()))    4006     fCommandArea->setText((char*)(ss.data()));
4045     fCommandArea->setFocus();                    4007     fCommandArea->setFocus();
4046     // do not pass by parent, it will disable    4008     // do not pass by parent, it will disable widget tab focus !
4047     return true;                                 4009     return true;
4048     // L.Garnier : MetaModifier is CTRL for M    4010     // L.Garnier : MetaModifier is CTRL for MAC, but I don't want to put a MAC
4049     // specific #ifdef                           4011     // specific #ifdef
4050   }                                              4012   }
4051                                                  4013 
4052   G4bool res = false;                            4014   G4bool res = false;
4053   // change cursor position if needed            4015   // change cursor position if needed
4054   if (moveCommandCursor) {                       4016   if (moveCommandCursor) {
4055     fCommandArea->setCursorPosition((int)fCom    4017     fCommandArea->setCursorPosition((int)fCommandArea->text().length());
4056     fCommandArea->setCursorPosition(4);          4018     fCommandArea->setCursorPosition(4);
4057   }                                              4019   }
4058   else {                                         4020   else {
4059     // pass the event on to the parent class     4021     // pass the event on to the parent class
4060     res = QObject::eventFilter(aObj, aEvent);    4022     res = QObject::eventFilter(aObj, aEvent);
4061   }                                              4023   }
4062   return res;                                    4024   return res;
4063 }                                                4025 }
4064                                                  4026 
4065 void G4UIQt::UpdateCommandCompleter()            4027 void G4UIQt::UpdateCommandCompleter()
4066 {                                                4028 {
4067   if (fCommandArea == nullptr) return;           4029   if (fCommandArea == nullptr) return;
4068                                                  4030 
4069   // remove previous one                         4031   // remove previous one
4070   fCommandArea->setCompleter(nullptr);           4032   fCommandArea->setCompleter(nullptr);
4071   if (fCompleter != nullptr) {                   4033   if (fCompleter != nullptr) {
4072     if (fCompleter->popup() != nullptr) {        4034     if (fCompleter->popup() != nullptr) {
4073       fCompleter->popup()->removeEventFilter(    4035       fCompleter->popup()->removeEventFilter(this);
4074     }                                            4036     }
4075   }                                              4037   }
4076                                                  4038 
4077   QStandardItemModel* model = CreateCompleter    4039   QStandardItemModel* model = CreateCompleterModel("/");
4078   fCompleter = new QCompleter(model);            4040   fCompleter = new QCompleter(model);
4079                                                  4041 
4080   // set all dir visibles in completion          4042   // set all dir visibles in completion
4081   G4UImanager* UI = G4UImanager::GetUIpointer    4043   G4UImanager* UI = G4UImanager::GetUIpointer();
4082   G4UIcommandTree* commandTreeTop = UI->GetTr    4044   G4UIcommandTree* commandTreeTop = UI->GetTree();
4083   G4UIcommandTree* aTree = commandTreeTop->Fi    4045   G4UIcommandTree* aTree = commandTreeTop->FindCommandTree("/");
4084   if (aTree != nullptr) {                        4046   if (aTree != nullptr) {
4085     int Ndir = aTree->GetTreeEntry();            4047     int Ndir = aTree->GetTreeEntry();
4086     fCompleter->setMaxVisibleItems(Ndir);        4048     fCompleter->setMaxVisibleItems(Ndir);
4087   }                                              4049   }
4088   fCommandArea->setCompleter(fCompleter);        4050   fCommandArea->setCompleter(fCompleter);
4089   fCompleter->popup()->installEventFilter(thi    4051   fCompleter->popup()->installEventFilter(this);
4090 }                                                4052 }
4091                                                  4053 
4092 QStandardItemModel* G4UIQt::CreateCompleterMo << 4054 QStandardItemModel* G4UIQt::CreateCompleterModel(G4String aCmd)
4093 {                                                4055 {
4094   QList<QStandardItem*> dirModelList;            4056   QList<QStandardItem*> dirModelList;
4095   QList<QStandardItem*> commandModelList;        4057   QList<QStandardItem*> commandModelList;
4096   QList<QStandardItem*> subDirModelList;         4058   QList<QStandardItem*> subDirModelList;
4097   QList<QStandardItem*> subCommandModelList;     4059   QList<QStandardItem*> subCommandModelList;
4098                                                  4060 
4099   G4String strtmp;                               4061   G4String strtmp;
4100   G4int nMatch = 0;                              4062   G4int nMatch = 0;
4101                                                  4063 
4102   G4String pName = aCmd;                         4064   G4String pName = aCmd;
4103   G4String remainingPath = aCmd;                 4065   G4String remainingPath = aCmd;
4104   G4String empty = "";                           4066   G4String empty = "";
4105   G4String matchingPath = empty;                 4067   G4String matchingPath = empty;
4106                                                  4068 
4107   // find the tree                               4069   // find the tree
4108   auto jpre = pName.rfind('/');                  4070   auto jpre = pName.rfind('/');
4109   if (jpre != G4String::npos) pName.erase(jpr    4071   if (jpre != G4String::npos) pName.erase(jpre + 1);
4110   G4UImanager* UI = G4UImanager::GetUIpointer    4072   G4UImanager* UI = G4UImanager::GetUIpointer();
4111   G4UIcommandTree* commandTreeTop = UI->GetTr    4073   G4UIcommandTree* commandTreeTop = UI->GetTree();
4112   G4UIcommandTree* aTree = commandTreeTop->Fi    4074   G4UIcommandTree* aTree = commandTreeTop->FindCommandTree(pName);
4113   if (aTree != nullptr) {                        4075   if (aTree != nullptr) {
4114     G4int Ndir = aTree->GetTreeEntry();          4076     G4int Ndir = aTree->GetTreeEntry();
4115     G4int Ncmd = aTree->GetCommandEntry();       4077     G4int Ncmd = aTree->GetCommandEntry();
4116                                                  4078 
4117     // directory ...                             4079     // directory ...
4118     for (G4int idir = 1; idir <= Ndir; ++idir    4080     for (G4int idir = 1; idir <= Ndir; ++idir) {
4119       G4String fpdir = aTree->GetTree(idir)->    4081       G4String fpdir = aTree->GetTree(idir)->GetPathName();
4120       // matching test                           4082       // matching test
4121       if (fpdir.find(remainingPath, 0) == 0)     4083       if (fpdir.find(remainingPath, 0) == 0) {
4122         if (nMatch == 0) {                       4084         if (nMatch == 0) {
4123           matchingPath = fpdir;                  4085           matchingPath = fpdir;
4124         }                                        4086         }
4125         else {                                   4087         else {
4126           matchingPath = aTree->GetFirstMatch    4088           matchingPath = aTree->GetFirstMatchedString(fpdir, matchingPath);
4127         }                                        4089         }
4128         nMatch++;                                4090         nMatch++;
4129                                                  4091 
4130         // append to dir model list              4092         // append to dir model list
4131         auto item1 = new QStandardItem(fpdir.    4093         auto item1 = new QStandardItem(fpdir.data());
4132         QIcon i = QIcon(*fDirIcon);              4094         QIcon i = QIcon(*fDirIcon);
4133         item1->setData(1);  // dir               4095         item1->setData(1);  // dir
4134         item1->setIcon(QIcon(*fDirIcon));        4096         item1->setIcon(QIcon(*fDirIcon));
4135         dirModelList.append(item1);              4097         dirModelList.append(item1);
4136                                                  4098 
4137         // Go recursively                        4099         // Go recursively
4138         QStandardItemModel* subModel = Create    4100         QStandardItemModel* subModel = CreateCompleterModel(fpdir.data());
4139         for (G4int a = 0; a < subModel->rowCo    4101         for (G4int a = 0; a < subModel->rowCount(); ++a) {
4140           // copy item (an item could only be    4102           // copy item (an item could only be part of one model
4141           auto tempItem = new QStandardItem(s    4103           auto tempItem = new QStandardItem(subModel->item(a)->text());
4142           tempItem->setIcon(subModel->item(a)    4104           tempItem->setIcon(subModel->item(a)->icon());
4143           tempItem->setToolTip(subModel->item    4105           tempItem->setToolTip(subModel->item(a)->toolTip());
4144           tempItem->setData(subModel->item(a)    4106           tempItem->setData(subModel->item(a)->data());
4145                                                  4107 
4146           // dir                                 4108           // dir
4147           if (tempItem->data() == 1) {           4109           if (tempItem->data() == 1) {
4148             subModel->item(a);                   4110             subModel->item(a);
4149             subDirModelList.append(tempItem);    4111             subDirModelList.append(tempItem);
4150           }                                      4112           }
4151           // command                             4113           // command
4152           else if (tempItem->data() == 0) {      4114           else if (tempItem->data() == 0) {
4153             subCommandModelList.append(tempIt    4115             subCommandModelList.append(tempItem);
4154           }                                      4116           }
4155         }                                        4117         }
4156       }                                          4118       }
4157     }                                            4119     }
4158                                                  4120 
4159     // command ...                               4121     // command ...
4160     G4int n_parameterEntry;                      4122     G4int n_parameterEntry;
4161     G4String rangeString;                        4123     G4String rangeString;
4162     G4int n_guidanceEntry;                       4124     G4int n_guidanceEntry;
4163     G4UIcommand* command;                        4125     G4UIcommand* command;
4164     G4UIparameter* param;                        4126     G4UIparameter* param;
4165     std::string tooltip;                         4127     std::string tooltip;
4166     G4String params;                             4128     G4String params;
4167                                                  4129 
4168     for (G4int icmd = 1; icmd <= Ncmd; ++icmd    4130     for (G4int icmd = 1; icmd <= Ncmd; ++icmd) {
4169       tooltip = "";                              4131       tooltip = "";
4170       params = " ";                              4132       params = " ";
4171       command = aTree->GetCommand(icmd);         4133       command = aTree->GetCommand(icmd);
4172       G4String longCommandName = aTree->GetPa    4134       G4String longCommandName = aTree->GetPathName() + command->GetCommandName();
4173       rangeString = command->GetRange();         4135       rangeString = command->GetRange();
4174       n_guidanceEntry = (G4int)command->GetGu    4136       n_guidanceEntry = (G4int)command->GetGuidanceEntries();
4175       n_parameterEntry = (G4int)command->GetP    4137       n_parameterEntry = (G4int)command->GetParameterEntries();
4176                                                  4138 
4177       // matching test                           4139       // matching test
4178       if (longCommandName.find(remainingPath,    4140       if (longCommandName.find(remainingPath, 0) == 0) {
4179         if (nMatch == 0) {                       4141         if (nMatch == 0) {
4180           matchingPath = longCommandName + "     4142           matchingPath = longCommandName + " ";
4181         }                                        4143         }
4182         else {                                   4144         else {
4183           strtmp = longCommandName + " ";        4145           strtmp = longCommandName + " ";
4184           matchingPath = aTree->GetFirstMatch    4146           matchingPath = aTree->GetFirstMatchedString(matchingPath, strtmp);
4185         }                                        4147         }
4186                                                  4148 
4187         // guidance                              4149         // guidance
4188         for (G4int i_thGuidance = 0; i_thGuid    4150         for (G4int i_thGuidance = 0; i_thGuidance < n_guidanceEntry; i_thGuidance++) {
4189           tooltip += std::string((command->Ge    4151           tooltip += std::string((command->GetGuidanceLine(i_thGuidance)).data());
4190           if (i_thGuidance < n_guidanceEntry     4152           if (i_thGuidance < n_guidanceEntry - 1) {
4191             tooltip += "\n";                     4153             tooltip += "\n";
4192           }                                      4154           }
4193         }                                        4155         }
4194                                                  4156 
4195         // parameters                            4157         // parameters
4196         for (G4int a = 0; a < n_parameterEntr    4158         for (G4int a = 0; a < n_parameterEntry; a++) {
4197           param = command->GetParameter(a);      4159           param = command->GetParameter(a);
4198           if (param->IsOmittable()) {            4160           if (param->IsOmittable()) {
4199             params += "[<" + param->GetParame    4161             params += "[<" + param->GetParameterName() + ">] ";
4200           }                                      4162           }
4201           else {                                 4163           else {
4202             params += "<" + param->GetParamet    4164             params += "<" + param->GetParameterName() + "> ";
4203           }                                      4165           }
4204         }                                        4166         }
4205         nMatch++;                                4167         nMatch++;
4206                                                  4168 
4207         // Append to command model list          4169         // Append to command model list
4208         auto item = new QStandardItem(G4Strin    4170         auto item = new QStandardItem(G4String(longCommandName + params).data());
4209         item->setData(0);  // command            4171         item->setData(0);  // command
4210         item->setIcon(QIcon(*fCommandIcon));     4172         item->setIcon(QIcon(*fCommandIcon));
4211         item->setToolTip(tooltip.c_str());       4173         item->setToolTip(tooltip.c_str());
4212                                                  4174 
4213         commandModelList.append(item);           4175         commandModelList.append(item);
4214       }                                          4176       }
4215     }                                            4177     }
4216   }                                              4178   }
4217                                                  4179 
4218   auto model = new QStandardItemModel();         4180   auto model = new QStandardItemModel();
4219   // initialize the model                        4181   // initialize the model
4220   model->setColumnCount(1);                      4182   model->setColumnCount(1);
4221                                                  4183 
4222   // concat models                               4184   // concat models
4223   for (auto a : dirModelList) {                  4185   for (auto a : dirModelList) {
4224     model->appendRow(a);                         4186     model->appendRow(a);
4225   }                                              4187   }
4226   for (auto a : subDirModelList) {               4188   for (auto a : subDirModelList) {
4227     model->appendRow(a);                         4189     model->appendRow(a);
4228   }                                              4190   }
4229   for (auto a : commandModelList) {              4191   for (auto a : commandModelList) {
4230     model->appendRow(a);                         4192     model->appendRow(a);
4231   }                                              4193   }
4232   for (auto a : subCommandModelList) {           4194   for (auto a : subCommandModelList) {
4233     model->appendRow(a);                         4195     model->appendRow(a);
4234   }                                              4196   }
4235                                                  4197 
4236   return model;                                  4198   return model;
4237 }                                                4199 }
4238                                                  4200 
4239 /********************************************    4201 /***************************************************************************/
4240 //                                               4202 //
4241 //             SLOTS DEFINITIONS                 4203 //             SLOTS DEFINITIONS
4242 //                                               4204 //
4243 /********************************************    4205 /***************************************************************************/
4244                                                  4206 
4245 /**   Called when user give "help" command.      4207 /**   Called when user give "help" command.
4246  */                                              4208  */
4247 void G4UIQt::ShowHelpCallback() { TerminalHel    4209 void G4UIQt::ShowHelpCallback() { TerminalHelp(""); }
4248                                                  4210 
4249 /**   Called when user click on clear button.    4211 /**   Called when user click on clear button. Clear the text Output area
4250  */                                              4212  */
4251 void G4UIQt::ClearButtonCallback()               4213 void G4UIQt::ClearButtonCallback()
4252 {                                                4214 {
4253   fCoutTBTextArea->clear();                      4215   fCoutTBTextArea->clear();
4254   fG4OutputString.clear();                       4216   fG4OutputString.clear();
4255 }                                                4217 }
4256                                                  4218 
4257 /**   Called when user exit session              4219 /**   Called when user exit session
4258  */                                              4220  */
4259 void G4UIQt::ExitSession() { SessionTerminate    4221 void G4UIQt::ExitSession() { SessionTerminate(); }
4260                                                  4222 
4261 void G4UIQt::ExitHelp() const {}                 4223 void G4UIQt::ExitHelp() const {}
4262                                                  4224 
4263 /**   Callback call when "click on a menu ent    4225 /**   Callback call when "click on a menu entry.<br>
4264    Send the associated command to geant4         4226    Send the associated command to geant4
4265 */                                               4227 */
4266 void G4UIQt::CommandEnteredCallback()            4228 void G4UIQt::CommandEnteredCallback()
4267 {                                                4229 {
4268   // split by any new line character             4230   // split by any new line character
4269   fCommandArea->setText(fCommandArea->text().    4231   fCommandArea->setText(fCommandArea->text().trimmed());
4270 #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))    4232 #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
4271   QStringList list = fCommandArea->text().spl    4233   QStringList list = fCommandArea->text().split(QRegularExpression("[\r\n]"),QString::SkipEmptyParts);
4272 #else                                            4234 #else
4273   QStringList list = fCommandArea->text().spl    4235   QStringList list = fCommandArea->text().split(QRegularExpression("[\r\n]"),Qt::SkipEmptyParts);
4274 #endif                                           4236 #endif
4275                                                  4237 
4276   // Apply for all commands                      4238   // Apply for all commands
4277   for (G4int a = 0; a < list.size(); ++a) {      4239   for (G4int a = 0; a < list.size(); ++a) {
4278     QString txt(list[a].trimmed());              4240     QString txt(list[a].trimmed());
4279     if (txt != "") {                             4241     if (txt != "") {
4280       fHistoryTBTableList->addItem(txt);         4242       fHistoryTBTableList->addItem(txt);
4281       fHistoryTBTableList->clearSelection();     4243       fHistoryTBTableList->clearSelection();
4282       fHistoryTBTableList->setCurrentItem(nul    4244       fHistoryTBTableList->setCurrentItem(nullptr);
4283       fCommandArea->setText("");                 4245       fCommandArea->setText("");
4284       G4Qt* interactorManager = G4Qt::getInst    4246       G4Qt* interactorManager = G4Qt::getInstance();
4285       if (interactorManager != nullptr) {        4247       if (interactorManager != nullptr) {
4286         interactorManager->FlushAndWaitExecut    4248         interactorManager->FlushAndWaitExecution();
4287       }                                          4249       }
4288                                                  4250 
4289       G4String command = txt.toStdString().c_    4251       G4String command = txt.toStdString().c_str();
4290       if (command.substr(0, 4) != "help") {      4252       if (command.substr(0, 4) != "help") {
4291         ApplyShellCommand(command, exitSessio    4253         ApplyShellCommand(command, exitSession, exitPause);
4292       }                                          4254       }
4293       else {                                     4255       else {
4294         ActivateCommand(command);                4256         ActivateCommand(command);
4295       }                                          4257       }
4296     }                                            4258     }
4297   }                                              4259   }
4298   // set the focus to the command line           4260   // set the focus to the command line
4299   fCommandArea->setFocus();                      4261   fCommandArea->setFocus();
4300                                                  4262 
4301   // Rebuild help tree                           4263   // Rebuild help tree
4302   FillHelpTree();                                4264   FillHelpTree();
4303                                                  4265 
4304   // Rebuild command completion                  4266   // Rebuild command completion
4305   UpdateCommandCompleter();                      4267   UpdateCommandCompleter();
4306                                                  4268 
4307   if (exitSession) SessionTerminate();           4269   if (exitSession) SessionTerminate();
4308 }                                                4270 }
4309                                                  4271 
4310 /** Callback when the text in the line edit i    4272 /** Callback when the text in the line edit is changed.
4311  When a newline is inserted, trigger the Acti    4273  When a newline is inserted, trigger the Activate Command
4312  on this text end set unchanged the end of th    4274  on this text end set unchanged the end of the line after the newline.
4313  */                                              4275  */
4314 void G4UIQt::CommandEditedCallback(const QStr    4276 void G4UIQt::CommandEditedCallback(const QString&)
4315 {                                                4277 {
4316 #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))    4278 #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
4317   QStringList list = fCommandArea->text().spl    4279   QStringList list = fCommandArea->text().split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts);
4318 #else                                            4280 #else
4319   QStringList list = fCommandArea->text().spl    4281   QStringList list = fCommandArea->text().split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
4320 #endif                                           4282 #endif
4321                                                  4283 
4322   if (list.size() > 1) {  // trigger Activate    4284   if (list.size() > 1) {  // trigger ActivateCommand
4323     for (G4int a = 0; a < list.size() - 1; ++    4285     for (G4int a = 0; a < list.size() - 1; ++a) {
4324       // set only the first part                 4286       // set only the first part
4325       fCommandArea->setText(list[a]);            4287       fCommandArea->setText(list[a]);
4326       // trigger callback                        4288       // trigger callback
4327       CommandEnteredCallback();                  4289       CommandEnteredCallback();
4328     }                                            4290     }
4329     // reset unfinished command                  4291     // reset unfinished command
4330     fCommandArea->setText(list[list.size() -     4292     fCommandArea->setText(list[list.size() - 1]);
4331   }                                              4293   }
4332 }                                                4294 }
4333                                                  4295 
4334 /** Callback when one of the scene/vis parame    4296 /** Callback when one of the scene/vis parameters has changed
4335  */                                              4297  */
4336 void G4UIQt::VisParameterCallback(QWidget* wi    4298 void G4UIQt::VisParameterCallback(QWidget* widget)
4337 {                                                4299 {
4338   if (widget == nullptr) {                       4300   if (widget == nullptr) {
4339     return;                                      4301     return;
4340   }                                              4302   }
4341                                                  4303 
4342   // Look in all the Grid layout, but only co    4304   // Look in all the Grid layout, but only column 1 (0 is the parameter name)
4343   auto grid = dynamic_cast<QGridLayout*>(widg    4305   auto grid = dynamic_cast<QGridLayout*>(widget->layout());
4344   if (grid == nullptr) {                         4306   if (grid == nullptr) {
4345     return;                                      4307     return;
4346   }                                              4308   }
4347   QString command;                               4309   QString command;
4348   QWidget* name = grid->itemAtPosition(grid->    4310   QWidget* name = grid->itemAtPosition(grid->rowCount() - 1, 0)->widget();
4349   if (dynamic_cast<QLabel*>(name) == nullptr)    4311   if (dynamic_cast<QLabel*>(name) == nullptr) {
4350     return;                                      4312     return;
4351   }                                              4313   }
4352   command += (dynamic_cast<QLabel*>(name))->t    4314   command += (dynamic_cast<QLabel*>(name))->text() + " ";
4353                                                  4315 
4354   for (G4int a = 0; a < grid->rowCount() - 1;    4316   for (G4int a = 0; a < grid->rowCount() - 1; ++a) {
4355     QWidget* widgetTmp = grid->itemAtPosition    4317     QWidget* widgetTmp = grid->itemAtPosition(a, 1)->widget();
4356                                                  4318 
4357     // 4 kind of widgets : QLineEdit / QCombo    4319     // 4 kind of widgets : QLineEdit / QComboBox / radioButtonsGroup / QPushButton (color chooser)
4358     if (widgetTmp != nullptr) {                  4320     if (widgetTmp != nullptr) {
4359       if (dynamic_cast<QLineEdit*>(widgetTmp)    4321       if (dynamic_cast<QLineEdit*>(widgetTmp) != nullptr) {
4360         command += (dynamic_cast<QLineEdit*>(    4322         command += (dynamic_cast<QLineEdit*>(widgetTmp))->text() + " ";
4361       }                                          4323       }
4362       else if (dynamic_cast<QComboBox*>(widge    4324       else if (dynamic_cast<QComboBox*>(widgetTmp) != nullptr) {
4363         command += (dynamic_cast<QComboBox*>(    4325         command += (dynamic_cast<QComboBox*>(widgetTmp))
4364                      ->itemText((dynamic_cast    4326                      ->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex()) +
4365                    " ";                          4327                    " ";
4366                                                  4328 
4367         // Color chooser                         4329         // Color chooser
4368       }                                          4330       }
4369       else if (dynamic_cast<QPushButton*>(wid    4331       else if (dynamic_cast<QPushButton*>(widgetTmp) != nullptr) {
4370         command += widgetTmp->accessibleName(    4332         command += widgetTmp->accessibleName() + " ";
4371                                                  4333 
4372         // Check for Button group                4334         // Check for Button group
4373       }                                          4335       }
4374       else if (dynamic_cast<QWidget*>(widgetT    4336       else if (dynamic_cast<QWidget*>(widgetTmp) != nullptr) {
4375         if (widgetTmp->layout()->count() > 0)    4337         if (widgetTmp->layout()->count() > 0) {
4376           if (dynamic_cast<QRadioButton*>(wid    4338           if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != nullptr) {
4377             QAbstractButton* checked =           4339             QAbstractButton* checked =
4378               (dynamic_cast<QRadioButton*>(wi    4340               (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()))
4379                 ->group()                        4341                 ->group()
4380                 ->checkedButton();               4342                 ->checkedButton();
4381             if (checked != nullptr) {            4343             if (checked != nullptr) {
4382               command += (dynamic_cast<QRadio    4344               command += (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()))
4383                            ->group()             4345                            ->group()
4384                            ->checkedButton()     4346                            ->checkedButton()
4385                            ->text() +            4347                            ->text() +
4386                          " ";                    4348                          " ";
4387             }                                    4349             }
4388           }                                      4350           }
4389         }                                        4351         }
4390       }                                          4352       }
4391     }                                            4353     }
4392   }                                              4354   }
4393   if (command != "") {                           4355   if (command != "") {
4394     G4UImanager* UI = G4UImanager::GetUIpoint    4356     G4UImanager* UI = G4UImanager::GetUIpointer();
4395     if (UI != nullptr) {                         4357     if (UI != nullptr) {
4396       UI->ApplyCommand(command.toStdString().    4358       UI->ApplyCommand(command.toStdString().c_str());
4397     }                                            4359     }
4398   }                                              4360   }
4399 }                                                4361 }
4400                                                  4362 
4401 /**   Callback call when "enter" clicked on t    4363 /**   Callback call when "enter" clicked on the command zone.<br>
4402       If command has no parameters :send the     4364       If command has no parameters :send the command to geant4
4403       Else, open a dialog for parameters inpu    4365       Else, open a dialog for parameters input
4404       @param aCommand                            4366       @param aCommand
4405 */                                               4367 */
4406 void G4UIQt::ButtonCallback(const QString& aC    4368 void G4UIQt::ButtonCallback(const QString& aCommand)
4407 {                                                4369 {
4408   G4String ss = G4StrUtil::lstrip_copy(G4Stri    4370   G4String ss = G4StrUtil::lstrip_copy(G4String(aCommand.toStdString().c_str()));
4409                                                  4371 
4410   G4UImanager* UI = G4UImanager::GetUIpointer    4372   G4UImanager* UI = G4UImanager::GetUIpointer();
4411   if (UI == nullptr) return;                     4373   if (UI == nullptr) return;
4412   G4UIcommandTree* treeTop = UI->GetTree();      4374   G4UIcommandTree* treeTop = UI->GetTree();
4413                                                  4375 
4414   G4UIcommand* command = treeTop->FindPath(ss    4376   G4UIcommand* command = treeTop->FindPath(ss);
4415                                                  4377 
4416   if (command != nullptr) {                      4378   if (command != nullptr) {
4417     // if is GUI, then open a dialog             4379     // if is GUI, then open a dialog
4418     if (IsGUICommand(command)) {                 4380     if (IsGUICommand(command)) {
4419       auto menuParameterDialog = new QDialog(    4381       auto menuParameterDialog = new QDialog();
4420                                                  4382 
4421       if (CreateVisCommandGroupAndToolBox(com    4383       if (CreateVisCommandGroupAndToolBox(command, menuParameterDialog, 1, true)) {
4422         menuParameterDialog->setWindowTitle(a    4384         menuParameterDialog->setWindowTitle(aCommand);
4423         menuParameterDialog->setSizePolicy(QS    4385         menuParameterDialog->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
4424                                                  4386 
4425         // exec this dialog, apply the comman    4387         // exec this dialog, apply the command automaticaly, and return
4426         menuParameterDialog->exec();             4388         menuParameterDialog->exec();
4427         return;                                  4389         return;
4428       }                                          4390       }
4429       delete menuParameterDialog;                4391       delete menuParameterDialog;
4430     }                                            4392     }
4431   }                                              4393   }
4432                                                  4394 
4433   ApplyShellCommand(ss, exitSession, exitPaus    4395   ApplyShellCommand(ss, exitSession, exitPause);
4434                                                  4396 
4435   // Rebuild help tree                           4397   // Rebuild help tree
4436   FillHelpTree();                                4398   FillHelpTree();
4437                                                  4399 
4438   if (exitSession) SessionTerminate();           4400   if (exitSession) SessionTerminate();
4439 }                                                4401 }
4440                                                  4402 
4441 /**   This callback is activated when user se    4403 /**   This callback is activated when user selected a item in the help tree
4442  */                                              4404  */
4443 void G4UIQt::HelpTreeClicCallback()              4405 void G4UIQt::HelpTreeClicCallback()
4444 {                                                4406 {
4445   QTreeWidgetItem* item = nullptr;               4407   QTreeWidgetItem* item = nullptr;
4446   if (fHelpTreeWidget == nullptr) return;        4408   if (fHelpTreeWidget == nullptr) return;
4447                                                  4409 
4448   QList<QTreeWidgetItem*> list = fHelpTreeWid    4410   QList<QTreeWidgetItem*> list = fHelpTreeWidget->selectedItems();
4449   if (list.isEmpty()) return;                    4411   if (list.isEmpty()) return;
4450   item = list.first();                           4412   item = list.first();
4451   if (item == nullptr) return;                   4413   if (item == nullptr) return;
4452                                                  4414 
4453   G4UImanager* UI = G4UImanager::GetUIpointer    4415   G4UImanager* UI = G4UImanager::GetUIpointer();
4454   if (UI == nullptr) return;                     4416   if (UI == nullptr) return;
4455   G4UIcommandTree* treeTop = UI->GetTree();      4417   G4UIcommandTree* treeTop = UI->GetTree();
4456                                                  4418 
4457   std::string itemText = GetLongCommandPath(i    4419   std::string itemText = GetLongCommandPath(item).toStdString();
4458                                                  4420 
4459   // check if it is a command path               4421   // check if it is a command path
4460   if (item->childCount() > 0) {                  4422   if (item->childCount() > 0) {
4461     itemText += "/";                             4423     itemText += "/";
4462   }                                              4424   }
4463   G4UIcommand* command = treeTop->FindPath(it    4425   G4UIcommand* command = treeTop->FindPath(itemText.c_str());
4464                                                  4426 
4465   if (command != nullptr) {                      4427   if (command != nullptr) {
4466     updateHelpArea(command);                     4428     updateHelpArea(command);
4467   }                                              4429   }
4468   else {  // this is a command                   4430   else {  // this is a command
4469     G4UIcommandTree* path = treeTop->FindComm    4431     G4UIcommandTree* path = treeTop->FindCommandTree(itemText.c_str());
4470     if (path != nullptr) {                       4432     if (path != nullptr) {
4471       // this is not a command, this is a sub    4433       // this is not a command, this is a sub directory
4472       // We display the Title                    4434       // We display the Title
4473       fParameterHelpLabel->setVisible(true);     4435       fParameterHelpLabel->setVisible(true);
4474       fParameterHelpLabel->setText(path->GetT    4436       fParameterHelpLabel->setText(path->GetTitle().data());
4475       fParameterHelpTable->setVisible(false);    4437       fParameterHelpTable->setVisible(false);
4476     }                                            4438     }
4477   }                                              4439   }
4478 }                                                4440 }
4479                                                  4441 
4480 /**   This callback is activated when user do    4442 /**   This callback is activated when user double clic on a item in the help tree
4481  */                                              4443  */
4482 void G4UIQt::HelpTreeDoubleClicCallback()        4444 void G4UIQt::HelpTreeDoubleClicCallback()
4483 {                                                4445 {
4484   HelpTreeClicCallback();                        4446   HelpTreeClicCallback();
4485                                                  4447 
4486   QTreeWidgetItem* item = nullptr;               4448   QTreeWidgetItem* item = nullptr;
4487   if (fHelpTreeWidget == nullptr) return;        4449   if (fHelpTreeWidget == nullptr) return;
4488                                                  4450 
4489   QList<QTreeWidgetItem*> list = fHelpTreeWid    4451   QList<QTreeWidgetItem*> list = fHelpTreeWidget->selectedItems();
4490   if (list.isEmpty()) return;                    4452   if (list.isEmpty()) return;
4491   item = list.first();                           4453   item = list.first();
4492   if (item == nullptr) return;                   4454   if (item == nullptr) return;
4493                                                  4455 
4494   fCommandArea->clear();                         4456   fCommandArea->clear();
4495   fCommandArea->setText(GetLongCommandPath(it    4457   fCommandArea->setText(GetLongCommandPath(item));
4496 }                                                4458 }
4497                                                  4459 
4498 /**   Callback called when user select an old    4460 /**   Callback called when user select an old command in the command history<br>
4499    Give it to the command area.                  4461    Give it to the command area.
4500 */                                               4462 */
4501 void G4UIQt::CommandHistoryCallback()            4463 void G4UIQt::CommandHistoryCallback()
4502 {                                                4464 {
4503   QListWidgetItem* item = nullptr;               4465   QListWidgetItem* item = nullptr;
4504   if (fHistoryTBTableList == nullptr) return;    4466   if (fHistoryTBTableList == nullptr) return;
4505                                                  4467 
4506   QList<QListWidgetItem*> list = fHistoryTBTa    4468   QList<QListWidgetItem*> list = fHistoryTBTableList->selectedItems();
4507   if (list.isEmpty()) return;                    4469   if (list.isEmpty()) return;
4508   item = list.first();                           4470   item = list.first();
4509   if (item == nullptr) return;                   4471   if (item == nullptr) return;
4510   fCommandArea->setText(item->text());           4472   fCommandArea->setText(item->text());
4511 }                                                4473 }
4512                                                  4474 
4513 void G4UIQt::ThreadComboBoxCallback(int) { Co    4475 void G4UIQt::ThreadComboBoxCallback(int) { CoutFilterCallback(""); }
4514                                                  4476 
4515 void G4UIQt::CoutFilterCallback(const QString    4477 void G4UIQt::CoutFilterCallback(const QString&)
4516 {                                                4478 {
4517   FilterAllOutputTextArea();                     4479   FilterAllOutputTextArea();
4518                                                  4480 
4519   fCoutTBTextArea->repaint();                    4481   fCoutTBTextArea->repaint();
4520   fCoutTBTextArea->verticalScrollBar()->setSl    4482   fCoutTBTextArea->verticalScrollBar()->setSliderPosition(
4521     fCoutTBTextArea->verticalScrollBar()->max    4483     fCoutTBTextArea->verticalScrollBar()->maximum());
4522 }                                                4484 }
4523                                                  4485 
4524 void G4UIQt::SaveOutputCallback()                4486 void G4UIQt::SaveOutputCallback()
4525 {                                                4487 {
4526   QString fileName = QFileDialog::getSaveFile    4488   QString fileName = QFileDialog::getSaveFileName(
4527     fMainWindow, "Save console output as...",    4489     fMainWindow, "Save console output as...", fLastOpenPath, "Save output as...");
4528   if (fileName != "") {                          4490   if (fileName != "") {
4529     QFile data(fileName);                        4491     QFile data(fileName);
4530     if (data.open(QFile::WriteOnly | QFile::T    4492     if (data.open(QFile::WriteOnly | QFile::Truncate)) {
4531       QTextStream out(&data);                    4493       QTextStream out(&data);
4532       out << fCoutTBTextArea->toPlainText();     4494       out << fCoutTBTextArea->toPlainText();
4533       out.flush();                               4495       out.flush();
4534     }                                            4496     }
4535     data.close();                                4497     data.close();
4536   }                                              4498   }
4537 }                                                4499 }
4538                                                  4500 
4539 QString G4UIQt::FilterOutput(                    4501 QString G4UIQt::FilterOutput(
4540   const G4UIOutputString& output, const QStri    4502   const G4UIOutputString& output, const QString& currentThread, const QString& filter)
4541 {                                                4503 {
4542 #ifdef G4MULTITHREADED                           4504 #ifdef G4MULTITHREADED
4543   if ((currentThread == "All") || (currentThr << 4505   if ((currentThread == "All") || (currentThread == output.fThread)) {
4544 #else                                            4506 #else
4545   if (currentThread == "") {                     4507   if (currentThread == "") {
4546 #endif                                           4508 #endif
4547     if (output.fText.contains(QRegularExpress    4509     if (output.fText.contains(QRegularExpression(filter))) {
4548       return output.fText;                       4510       return output.fText;
4549     }                                            4511     }
4550   }                                              4512   }
4551   return "";                                     4513   return "";
4552 }                                                4514 }
4553                                                  4515 
4554 void G4UIQt::FilterAllOutputTextArea()           4516 void G4UIQt::FilterAllOutputTextArea()
4555 {                                                4517 {
4556   QString currentThread = "";                    4518   QString currentThread = "";
4557 #ifdef G4MULTITHREADED                           4519 #ifdef G4MULTITHREADED
4558   currentThread = fThreadsFilterComboBox->cur    4520   currentThread = fThreadsFilterComboBox->currentText();
4559   if (currentThread == "Master") {               4521   if (currentThread == "Master") {
4560     currentThread = "";                          4522     currentThread = "";
4561   }                                              4523   }
4562 #endif                                           4524 #endif
4563   QString filter = fCoutFilter->text();          4525   QString filter = fCoutFilter->text();
4564   G4String previousOutputStream = "";            4526   G4String previousOutputStream = "";
4565                                                  4527 
4566   QString pref = "";                             4528   QString pref = "";
4567   QString post = "";                             4529   QString post = "";
4568                                                  4530 
4569   fCoutTBTextArea->clear();                      4531   fCoutTBTextArea->clear();
4570                                                  4532 
4571   for (auto& out : fG4OutputString) {            4533   for (auto& out : fG4OutputString) {
4572     if (FilterOutput(out, currentThread, filt    4534     if (FilterOutput(out, currentThread, filter) != "") {
4573       // changing color ?                        4535       // changing color ?
4574       if (out.fOutputStream != previousOutput    4536       if (out.fOutputStream != previousOutputStream) {
4575         previousOutputStream = out.fOutputStr    4537         previousOutputStream = out.fOutputStream;
4576         if (out.fOutputStream == "info") {       4538         if (out.fOutputStream == "info") {
4577           pref = "";                             4539           pref = "";
4578           post = "";                             4540           post = "";
4579         }                                        4541         }
4580         else if (out.fOutputStream == "warnin    4542         else if (out.fOutputStream == "warning") {
4581           pref = "<font color=\"DarkYellow\">    4543           pref = "<font color=\"DarkYellow\">";
4582           post = "</font>";                      4544           post = "</font>";
4583         }                                        4545         }
4584         else {                                   4546         else {
4585           pref = "<font color=\"Red\">";         4547           pref = "<font color=\"Red\">";
4586           post = "</font>";                      4548           post = "</font>";
4587         }                                        4549         }
4588       }                                          4550       }
4589       fCoutTBTextArea->append(pref + out.fTex    4551       fCoutTBTextArea->append(pref + out.fText + post);
4590     }                                            4552     }
4591   }                                              4553   }
4592 }                                                4554 }
4593                                                  4555 
4594 /**   Callback called when user give a new st    4556 /**   Callback called when user give a new string to look for<br>
4595    Display a list of matching commands descri    4557    Display a list of matching commands descriptions. If no string is set,
4596    will display the complete help tree           4558    will display the complete help tree
4597 */                                               4559 */
4598 void G4UIQt::LookForHelpStringCallback()         4560 void G4UIQt::LookForHelpStringCallback()
4599 {                                                4561 {
4600   fHelpLine->setText(fHelpLine->text().trimme    4562   fHelpLine->setText(fHelpLine->text().trimmed());
4601   QString searchText = fHelpLine->text();        4563   QString searchText = fHelpLine->text();
4602                                                  4564 
4603   fParameterHelpLabel->setText("");              4565   fParameterHelpLabel->setText("");
4604   fParameterHelpTable->setVisible(false);        4566   fParameterHelpTable->setVisible(false);
4605   if (searchText == "") {                        4567   if (searchText == "") {
4606     // clear old help tree                       4568     // clear old help tree
4607     fHelpTreeWidget->clear();                    4569     fHelpTreeWidget->clear();
4608                                                  4570 
4609     FillHelpTree();                              4571     FillHelpTree();
4610                                                  4572 
4611     return;                                      4573     return;
4612   }                                              4574   }
4613   OpenHelpTreeOnCommand(searchText);             4575   OpenHelpTreeOnCommand(searchText);
4614 }                                                4576 }
4615                                                  4577 
4616 void G4UIQt::OpenHelpTreeOnCommand(const QStr    4578 void G4UIQt::OpenHelpTreeOnCommand(const QString& searchText)
4617 {                                                4579 {
4618   // the help tree                               4580   // the help tree
4619   G4UImanager* UI = G4UImanager::GetUIpointer    4581   G4UImanager* UI = G4UImanager::GetUIpointer();
4620   if (UI == nullptr) return;                     4582   if (UI == nullptr) return;
4621   G4UIcommandTree* treeTop = UI->GetTree();      4583   G4UIcommandTree* treeTop = UI->GetTree();
4622                                                  4584 
4623   G4int treeSize = treeTop->GetTreeEntry();      4585   G4int treeSize = treeTop->GetTreeEntry();
4624                                                  4586 
4625   // clear old help tree                         4587   // clear old help tree
4626   fHelpTreeWidget->clear();                      4588   fHelpTreeWidget->clear();
4627                                                  4589 
4628   // look for new items                          4590   // look for new items
4629                                                  4591 
4630   int tmp = 0;                                   4592   int tmp = 0;
4631                                                  4593 
4632 #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))    4594 #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
4633   // Before Qt5.15                               4595   // Before Qt5.15
4634   QMap<G4int, QString> commandResultMap;         4596   QMap<G4int, QString> commandResultMap;
4635   QMap<G4int, QString> commandChildResultMap;    4597   QMap<G4int, QString> commandChildResultMap;
4636   for (G4int a = 0; a < treeSize; ++a) {         4598   for (G4int a = 0; a < treeSize; ++a) {
4637     G4UIcommand* command = treeTop->FindPath(    4599     G4UIcommand* command = treeTop->FindPath(treeTop->GetTree(a + 1)->GetPathName().data());
4638     tmp = GetCommandList(command).count(searc    4600     tmp = GetCommandList(command).count(searchText, Qt::CaseInsensitive);
4639     if (tmp > 0) {                               4601     if (tmp > 0) {
4640       commandResultMap.insertMulti(              4602       commandResultMap.insertMulti(
4641         tmp, QString((char*)(treeTop->GetTree    4603         tmp, QString((char*)(treeTop->GetTree(a + 1)->GetPathName()).data()));
4642     }                                            4604     }
4643     // look for childs                           4605     // look for childs
4644     commandChildResultMap = LookForHelpString    4606     commandChildResultMap = LookForHelpStringInChildTree(treeTop->GetTree(a + 1), searchText);
4645     // insert new childs                         4607     // insert new childs
4646     if (! commandChildResultMap.empty()) {       4608     if (! commandChildResultMap.empty()) {
4647       QMap<int, QString>::const_iterator i =     4609       QMap<int, QString>::const_iterator i = commandChildResultMap.constBegin();
4648       while (i != commandChildResultMap.const    4610       while (i != commandChildResultMap.constEnd()) {
4649         commandResultMap.insertMulti(i.key(),    4611         commandResultMap.insertMulti(i.key(), i.value());
4650         i++;                                     4612         i++;
4651       }                                          4613       }
4652       commandChildResultMap.clear();             4614       commandChildResultMap.clear();
4653     }                                            4615     }
4654   }                                              4616   }
4655 #else                                            4617 #else
4656   // Qt5.15 and beyond                           4618   // Qt5.15 and beyond
4657   QMultiMap<G4int, QString> commandResultMap;    4619   QMultiMap<G4int, QString> commandResultMap;
4658   QMultiMap<G4int, QString> commandChildResul    4620   QMultiMap<G4int, QString> commandChildResultMap;
4659   for (G4int a = 0; a < treeSize; ++a) {         4621   for (G4int a = 0; a < treeSize; ++a) {
4660     G4UIcommand* command = treeTop->FindPath(    4622     G4UIcommand* command = treeTop->FindPath(treeTop->GetTree(a + 1)->GetPathName().data());
4661     tmp = (int)GetCommandList(command).count(    4623     tmp = (int)GetCommandList(command).count(searchText, Qt::CaseInsensitive);
4662     if (tmp > 0) {                               4624     if (tmp > 0) {
4663       commandResultMap.insert(tmp, QString((c    4625       commandResultMap.insert(tmp, QString((char*)(treeTop->GetTree(a + 1)->GetPathName()).data()));
4664     }                                            4626     }
4665     // look for childs                           4627     // look for childs
4666     commandChildResultMap = LookForHelpString    4628     commandChildResultMap = LookForHelpStringInChildTree(treeTop->GetTree(a + 1), searchText);
4667     // insert new childs                         4629     // insert new childs
4668     if (! commandChildResultMap.empty()) {       4630     if (! commandChildResultMap.empty()) {
4669       auto i = commandChildResultMap.constBeg    4631       auto i = commandChildResultMap.constBegin();
4670       while (i != commandChildResultMap.const    4632       while (i != commandChildResultMap.constEnd()) {
4671         commandResultMap.insert(i.key(), i.va    4633         commandResultMap.insert(i.key(), i.value());
4672         ++i;                                     4634         ++i;
4673       }                                          4635       }
4674       commandChildResultMap.clear();             4636       commandChildResultMap.clear();
4675     }                                            4637     }
4676   }                                              4638   }
4677 #endif                                           4639 #endif
4678                                                  4640 
4679   // build new help tree                         4641   // build new help tree
4680   fHelpTreeWidget->setSelectionMode(QAbstract    4642   fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
4681   fHelpTreeWidget->setColumnCount(2);            4643   fHelpTreeWidget->setColumnCount(2);
4682   QStringList labels;                            4644   QStringList labels;
4683   labels << QString("Command") << QString("Ma    4645   labels << QString("Command") << QString("Match");
4684   fHelpTreeWidget->setHeaderLabels(labels);      4646   fHelpTreeWidget->setHeaderLabels(labels);
4685                                                  4647 
4686   if (commandResultMap.empty()) {                4648   if (commandResultMap.empty()) {
4687     fParameterHelpLabel->setText("No match fo    4649     fParameterHelpLabel->setText("No match found");
4688     fParameterHelpTable->setVisible(false);      4650     fParameterHelpTable->setVisible(false);
4689     return;                                      4651     return;
4690   }                                              4652   }
4691                                                  4653 
4692   auto i = commandResultMap.constEnd();          4654   auto i = commandResultMap.constEnd();
4693   i--;                                           4655   i--;
4694   // 10 maximum progress values                  4656   // 10 maximum progress values
4695   G4float multValue = 10.0 / (G4float)(i.key(    4657   G4float multValue = 10.0 / (G4float)(i.key());
4696   QString progressChar = "|";                    4658   QString progressChar = "|";
4697   QString progressStr = "|";                     4659   QString progressStr = "|";
4698                                                  4660 
4699   QTreeWidgetItem* newItem;                      4661   QTreeWidgetItem* newItem;
4700   G4bool end = false;                            4662   G4bool end = false;
4701   while (! end) {                                4663   while (! end) {
4702     if (i == commandResultMap.constBegin()) {    4664     if (i == commandResultMap.constBegin()) {
4703       end = true;                                4665       end = true;
4704     }                                            4666     }
4705     for (G4int a = 0; a < G4int(i.key() * mul    4667     for (G4int a = 0; a < G4int(i.key() * multValue); ++a) {
4706       progressStr += progressChar;               4668       progressStr += progressChar;
4707     }                                            4669     }
4708     newItem = new QTreeWidgetItem();             4670     newItem = new QTreeWidgetItem();
4709     QString commandStr = i.value().trimmed();    4671     QString commandStr = i.value().trimmed();
4710                                                  4672 
4711     if (commandStr.indexOf("/") == 0) {          4673     if (commandStr.indexOf("/") == 0) {
4712       commandStr = commandStr.right(commandSt    4674       commandStr = commandStr.right(commandStr.size() - 1);
4713     }                                            4675     }
4714                                                  4676 
4715     newItem->setText(0, commandStr);             4677     newItem->setText(0, commandStr);
4716     newItem->setText(1, progressStr);            4678     newItem->setText(1, progressStr);
4717     fHelpTreeWidget->addTopLevelItem(newItem)    4679     fHelpTreeWidget->addTopLevelItem(newItem);
4718     newItem->setForeground(1, QBrush(Qt::blue    4680     newItem->setForeground(1, QBrush(Qt::blue));
4719     progressStr = "|";                           4681     progressStr = "|";
4720     i--;                                         4682     i--;
4721   }                                              4683   }
4722   fHelpTreeWidget->resizeColumnToContents(0);    4684   fHelpTreeWidget->resizeColumnToContents(0);
4723   fHelpTreeWidget->sortItems(1, Qt::Descendin    4685   fHelpTreeWidget->sortItems(1, Qt::DescendingOrder);
4724   //  fHelpTreeWidget->setColumnWidth(1,10);/    4686   //  fHelpTreeWidget->setColumnWidth(1,10);//resizeColumnToContents (1);
4725 }                                                4687 }
4726                                                  4688 
4727 #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))    4689 #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
4728 // Before Qt5.15                                 4690 // Before Qt5.15
4729 QMap<G4int, QString> G4UIQt::LookForHelpStrin    4691 QMap<G4int, QString> G4UIQt::LookForHelpStringInChildTree(
4730   G4UIcommandTree* aCommandTree, const QStrin    4692   G4UIcommandTree* aCommandTree, const QString& text)
4731 {                                                4693 {
4732   QMap<G4int, QString> commandResultMap;         4694   QMap<G4int, QString> commandResultMap;
4733   if (aCommandTree == NULL) return commandRes    4695   if (aCommandTree == NULL) return commandResultMap;
4734   // Get the Sub directories                     4696   // Get the Sub directories
4735   G4int tmp = 0;                                 4697   G4int tmp = 0;
4736   QMap<G4int, QString> commandChildResultMap;    4698   QMap<G4int, QString> commandChildResultMap;
4737   for (G4int a = 0; a < aCommandTree->GetTree    4699   for (G4int a = 0; a < aCommandTree->GetTreeEntry(); ++a) {
4738     const G4UIcommand* command = aCommandTree    4700     const G4UIcommand* command = aCommandTree->GetGuidance();
4739     tmp = GetCommandList(command).count(text,    4701     tmp = GetCommandList(command).count(text, Qt::CaseInsensitive);
4740     if (tmp > 0) {                               4702     if (tmp > 0) {
4741       commandResultMap.insertMulti(              4703       commandResultMap.insertMulti(
4742         tmp, QString((char*)(aCommandTree->Ge    4704         tmp, QString((char*)(aCommandTree->GetTree(a + 1)->GetPathName()).data()));
4743     }                                            4705     }
4744     // look for childs                           4706     // look for childs
4745     commandChildResultMap = LookForHelpString    4707     commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->GetTree(a + 1), text);
4746     if (! commandChildResultMap.empty()) {       4708     if (! commandChildResultMap.empty()) {
4747       // insert new childs                       4709       // insert new childs
4748       QMap<G4int, QString>::const_iterator i     4710       QMap<G4int, QString>::const_iterator i = commandChildResultMap.constBegin();
4749       while (i != commandChildResultMap.const    4711       while (i != commandChildResultMap.constEnd()) {
4750         commandResultMap.insertMulti(i.key(),    4712         commandResultMap.insertMulti(i.key(), i.value());
4751         ++i;                                     4713         ++i;
4752       }                                          4714       }
4753       commandChildResultMap.clear();             4715       commandChildResultMap.clear();
4754     }                                            4716     }
4755   }                                              4717   }
4756   // Get the Commands                            4718   // Get the Commands
4757   for (G4int a = 0; a < aCommandTree->GetComm    4719   for (G4int a = 0; a < aCommandTree->GetCommandEntry(); ++a) {
4758     const G4UIcommand* command = aCommandTree    4720     const G4UIcommand* command = aCommandTree->GetCommand(a + 1);
4759     tmp = GetCommandList(command).count(text,    4721     tmp = GetCommandList(command).count(text, Qt::CaseInsensitive);
4760     if (tmp > 0) {                               4722     if (tmp > 0) {
4761       commandResultMap.insertMulti(              4723       commandResultMap.insertMulti(
4762         tmp, QString((char*)(aCommandTree->Ge    4724         tmp, QString((char*)(aCommandTree->GetCommand(a + 1)->GetCommandPath()).data()));
4763     }                                            4725     }
4764   }                                              4726   }
4765   return commandResultMap;                       4727   return commandResultMap;
4766 }                                                4728 }
4767 #else                                            4729 #else
4768 // Qt5.15 and beyond                             4730 // Qt5.15 and beyond
4769 QMultiMap<G4int, QString> G4UIQt::LookForHelp    4731 QMultiMap<G4int, QString> G4UIQt::LookForHelpStringInChildTree(
4770   G4UIcommandTree* aCommandTree, const QStrin    4732   G4UIcommandTree* aCommandTree, const QString& text)
4771 {                                                4733 {
4772   QMultiMap<G4int, QString> commandResultMap;    4734   QMultiMap<G4int, QString> commandResultMap;
4773   if (aCommandTree == nullptr) return command    4735   if (aCommandTree == nullptr) return commandResultMap;
4774   // Get the Sub directories                     4736   // Get the Sub directories
4775   G4int tmp = 0;                                 4737   G4int tmp = 0;
4776   QMultiMap<G4int, QString> commandChildResul    4738   QMultiMap<G4int, QString> commandChildResultMap;
4777   for (G4int a = 0; a < aCommandTree->GetTree    4739   for (G4int a = 0; a < aCommandTree->GetTreeEntry(); ++a) {
4778     const G4UIcommand* command = aCommandTree    4740     const G4UIcommand* command = aCommandTree->GetGuidance();
4779     tmp = (int)GetCommandList(command).count(    4741     tmp = (int)GetCommandList(command).count(text, Qt::CaseInsensitive);
4780     if (tmp > 0) {                               4742     if (tmp > 0) {
4781       commandResultMap.insert(                   4743       commandResultMap.insert(
4782         tmp, QString((char*)(aCommandTree->Ge    4744         tmp, QString((char*)(aCommandTree->GetTree(a + 1)->GetPathName()).data()));
4783     }                                            4745     }
4784     // look for childs                           4746     // look for childs
4785     commandChildResultMap = LookForHelpString    4747     commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->GetTree(a + 1), text);
4786     if (! commandChildResultMap.empty()) {       4748     if (! commandChildResultMap.empty()) {
4787       // insert new childs                       4749       // insert new childs
4788       auto i = commandChildResultMap.constBeg    4750       auto i = commandChildResultMap.constBegin();
4789       while (i != commandChildResultMap.const    4751       while (i != commandChildResultMap.constEnd()) {
4790         commandResultMap.insert(i.key(), i.va    4752         commandResultMap.insert(i.key(), i.value());
4791         ++i;                                     4753         ++i;
4792       }                                          4754       }
4793       commandChildResultMap.clear();             4755       commandChildResultMap.clear();
4794     }                                            4756     }
4795   }                                              4757   }
4796   // Get the Commands                            4758   // Get the Commands
4797   for (G4int a = 0; a < aCommandTree->GetComm    4759   for (G4int a = 0; a < aCommandTree->GetCommandEntry(); ++a) {
4798     const G4UIcommand* command = aCommandTree    4760     const G4UIcommand* command = aCommandTree->GetCommand(a + 1);
4799     tmp = (int)GetCommandList(command).count(    4761     tmp = (int)GetCommandList(command).count(text, Qt::CaseInsensitive);
4800     if (tmp > 0) {                               4762     if (tmp > 0) {
4801       commandResultMap.insert(                   4763       commandResultMap.insert(
4802         tmp, QString((char*)(aCommandTree->Ge    4764         tmp, QString((char*)(aCommandTree->GetCommand(a + 1)->GetCommandPath()).data()));
4803     }                                            4765     }
4804   }                                              4766   }
4805   return commandResultMap;                       4767   return commandResultMap;
4806 }                                                4768 }
4807 #endif                                           4769 #endif
4808                                                  4770 
4809 QString G4UIQt::GetShortCommandPath(QString&  << 4771 QString G4UIQt::GetShortCommandPath(QString commandPath)
4810 {                                                4772 {
4811   if (commandPath.indexOf("/") == 0) {           4773   if (commandPath.indexOf("/") == 0) {
4812     commandPath = commandPath.right(commandPa    4774     commandPath = commandPath.right(commandPath.size() - 1);
4813   }                                              4775   }
4814                                                  4776 
4815   commandPath = commandPath.right(commandPath    4777   commandPath = commandPath.right(commandPath.size() - commandPath.lastIndexOf("/", -2) - 1);
4816                                                  4778 
4817   if (commandPath.lastIndexOf("/") == (comman    4779   if (commandPath.lastIndexOf("/") == (commandPath.size() - 1)) {
4818     commandPath = commandPath.left(commandPat    4780     commandPath = commandPath.left(commandPath.size() - 1);
4819   }                                              4781   }
4820                                                  4782 
4821   return commandPath;                            4783   return commandPath;
4822 }                                                4784 }
4823                                                  4785 
4824 QString G4UIQt::GetLongCommandPath(QTreeWidge    4786 QString G4UIQt::GetLongCommandPath(QTreeWidgetItem* item)
4825 {                                                4787 {
4826   if (item == nullptr) return "";                4788   if (item == nullptr) return "";
4827                                                  4789 
4828   // rebuild path:                               4790   // rebuild path:
4829   QString itemText = "";                         4791   QString itemText = "";
4830   itemText = item->text(0);                      4792   itemText = item->text(0);
4831                                                  4793 
4832   while (item->parent() != nullptr) {            4794   while (item->parent() != nullptr) {
4833     itemText = item->parent()->text(0) + "/"     4795     itemText = item->parent()->text(0) + "/" + itemText;
4834     item = item->parent();                       4796     item = item->parent();
4835   }                                              4797   }
4836   itemText = "/" + itemText;                     4798   itemText = "/" + itemText;
4837                                                  4799 
4838   return itemText;                               4800   return itemText;
4839 }                                                4801 }
4840                                                  4802 
4841 void G4UIQt::ChangeColorCallback(QWidget* wid    4803 void G4UIQt::ChangeColorCallback(QWidget* widget)
4842 {                                                4804 {
4843   if (widget == nullptr) {                       4805   if (widget == nullptr) {
4844     return;                                      4806     return;
4845   }                                              4807   }
4846                                                  4808 
4847   auto button = dynamic_cast<QPushButton*>(wi    4809   auto button = dynamic_cast<QPushButton*>(widget);
4848   if (button == nullptr) {                       4810   if (button == nullptr) {
4849     return;                                      4811     return;
4850   }                                              4812   }
4851   QString value = button->accessibleName();      4813   QString value = button->accessibleName();
4852                                                  4814 
4853   QColor old;                                    4815   QColor old;
4854   old.setRgbF(value.section(" ", 0, 1).toDoub    4816   old.setRgbF(value.section(" ", 0, 1).toDouble(), value.section(" ", 1, 2).toDouble(),
4855     value.section(" ", 2, 3).toDouble());        4817     value.section(" ", 2, 3).toDouble());
4856   QColor color =                                 4818   QColor color =
4857     QColorDialog::getColor(old, fUITabWidget,    4819     QColorDialog::getColor(old, fUITabWidget, "Change color", QColorDialog::ShowAlphaChannel);
4858                                                  4820 
4859   if (color.isValid()) {                         4821   if (color.isValid()) {
4860     // rebuild the widget icon                   4822     // rebuild the widget icon
4861     QPixmap pixmap = QPixmap(QSize(16, 16));     4823     QPixmap pixmap = QPixmap(QSize(16, 16));
4862     pixmap.fill(color);                          4824     pixmap.fill(color);
4863     QPainter painter(&pixmap);                   4825     QPainter painter(&pixmap);
4864     painter.setPen(Qt::black);                   4826     painter.setPen(Qt::black);
4865     painter.drawRect(0, 0, 15, 15);  // Draw     4827     painter.drawRect(0, 0, 15, 15);  // Draw contour
4866                                                  4828 
4867     button->setAccessibleName(QString::number    4829     button->setAccessibleName(QString::number(color.redF()) + " " +
4868                               QString::number    4830                               QString::number(color.greenF()) + " " +
4869                               QString::number    4831                               QString::number(color.blueF()) + " ");
4870     button->setIcon(pixmap);                     4832     button->setIcon(pixmap);
4871   }                                              4833   }
4872 }                                                4834 }
4873                                                  4835 
4874 void G4UIQt::ChangeCursorAction(const QString    4836 void G4UIQt::ChangeCursorAction(const QString& action)
4875 {                                                4837 {
4876   // Theses actions should be in the app tool    4838   // Theses actions should be in the app toolbar
4877                                                  4839 
4878   fMoveSelected = true;                          4840   fMoveSelected = true;
4879   fPickSelected = true;                          4841   fPickSelected = true;
4880   fRotateSelected = true;                        4842   fRotateSelected = true;
4881   fZoomInSelected = true;                        4843   fZoomInSelected = true;
4882   fZoomOutSelected = true;                       4844   fZoomOutSelected = true;
4883                                                  4845 
4884   if (fToolbarApp == nullptr) return;            4846   if (fToolbarApp == nullptr) return;
4885   QList<QAction*> list = fToolbarApp->actions    4847   QList<QAction*> list = fToolbarApp->actions();
4886   for (auto i : list) {                          4848   for (auto i : list) {
4887     if (i->data().toString() == action) {        4849     if (i->data().toString() == action) {
4888       i->setChecked(true);                       4850       i->setChecked(true);
4889       if (i->data().toString() == "pick") {      4851       if (i->data().toString() == "pick") {
4890         G4UImanager::GetUIpointer()->ApplyCom    4852         G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/picking true");
4891         CreatePickInfosDialog();                 4853         CreatePickInfosDialog();
4892                                                  4854 
4893         fPickInfosDialog->show();                4855         fPickInfosDialog->show();
4894         fPickInfosDialog->raise();               4856         fPickInfosDialog->raise();
4895         fPickInfosDialog->activateWindow();      4857         fPickInfosDialog->activateWindow();
4896       }                                          4858       }
4897     }                                            4859     }
4898     else if (i->data().toString() == "move")     4860     else if (i->data().toString() == "move") {
4899       fMoveSelected = false;                     4861       fMoveSelected = false;
4900       i->setChecked(false);                      4862       i->setChecked(false);
4901     }                                            4863     }
4902     else if (i->data().toString() == "pick")     4864     else if (i->data().toString() == "pick") {
4903       fPickSelected = false;                     4865       fPickSelected = false;
4904       i->setChecked(false);                      4866       i->setChecked(false);
4905       G4UImanager::GetUIpointer()->ApplyComma    4867       G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/picking false");
4906       if (fPickInfosDialog != nullptr) {         4868       if (fPickInfosDialog != nullptr) {
4907         fPickInfosDialog->hide();                4869         fPickInfosDialog->hide();
4908       }                                          4870       }
4909     }                                            4871     }
4910     else if (i->data().toString() == "rotate"    4872     else if (i->data().toString() == "rotate") {
4911       fRotateSelected = false;                   4873       fRotateSelected = false;
4912       i->setChecked(false);                      4874       i->setChecked(false);
4913     }                                            4875     }
4914     else if (i->data().toString() == "zoom_in    4876     else if (i->data().toString() == "zoom_in") {
4915       fZoomInSelected = false;                   4877       fZoomInSelected = false;
4916       i->setChecked(false);                      4878       i->setChecked(false);
4917     }                                            4879     }
4918     else if (i->data().toString() == "zoom_ou    4880     else if (i->data().toString() == "zoom_out") {
4919       fZoomOutSelected = false;                  4881       fZoomOutSelected = false;
4920       i->setChecked(false);                      4882       i->setChecked(false);
4921     }                                            4883     }
4922   }                                              4884   }
4923   // FIXME : Should connect this to Vis          4885   // FIXME : Should connect this to Vis
4924 }                                                4886 }
4925                                                  4887 
4926 /* A little bit like "void G4OpenGLQtViewer::    4888 /* A little bit like "void G4OpenGLQtViewer::toggleDrawingAction(int aAction)"
4927    But for all viewers, not only Qt              4889    But for all viewers, not only Qt
4928                                                  4890 
4929 FIXME : Should be a feedback when changing vi    4891 FIXME : Should be a feedback when changing viewer !
4930                                                  4892 
4931  */                                              4893  */
4932 void G4UIQt::ChangeSurfaceStyle(const QString    4894 void G4UIQt::ChangeSurfaceStyle(const QString& action)
4933 {                                                4895 {
4934   // Theses actions should be in the app tool    4896   // Theses actions should be in the app toolbar
4935                                                  4897 
4936   if (fToolbarApp == nullptr) return;            4898   if (fToolbarApp == nullptr) return;
4937   QList<QAction*> list = fToolbarApp->actions    4899   QList<QAction*> list = fToolbarApp->actions();
4938   for (auto i : list) {                          4900   for (auto i : list) {
4939     if (i->data().toString() == action) {        4901     if (i->data().toString() == action) {
4940       i->setChecked(true);                       4902       i->setChecked(true);
4941     }                                            4903     }
4942     else if (i->data().toString() == "hidden_    4904     else if (i->data().toString() == "hidden_line_removal") {
4943       i->setChecked(false);                      4905       i->setChecked(false);
4944     }                                            4906     }
4945     else if (i->data().toString() == "hidden_    4907     else if (i->data().toString() == "hidden_line_and_surface_removal") {
4946       i->setChecked(false);                      4908       i->setChecked(false);
4947     }                                            4909     }
4948     else if (i->data().toString() == "solid")    4910     else if (i->data().toString() == "solid") {
4949       i->setChecked(false);                      4911       i->setChecked(false);
4950     }                                            4912     }
4951     else if (i->data().toString() == "wirefra    4913     else if (i->data().toString() == "wireframe") {
4952       i->setChecked(false);                      4914       i->setChecked(false);
4953     }                                            4915     }
4954   }                                              4916   }
4955   // FIXME : Should connect this to Vis          4917   // FIXME : Should connect this to Vis
4956                                                  4918 
4957   if (action == "hidden_line_removal") {         4919   if (action == "hidden_line_removal") {
4958     G4UImanager::GetUIpointer()->ApplyCommand    4920     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/style w");
4959     G4UImanager::GetUIpointer()->ApplyCommand    4921     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/hiddenEdge 1");
4960   }                                              4922   }
4961   else if (action == "hidden_line_and_surface    4923   else if (action == "hidden_line_and_surface_removal") {
4962     G4UImanager::GetUIpointer()->ApplyCommand    4924     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/style s");
4963     G4UImanager::GetUIpointer()->ApplyCommand    4925     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/hiddenEdge 1");
4964   }                                              4926   }
4965   else if (action == "solid") {                  4927   else if (action == "solid") {
4966     G4UImanager::GetUIpointer()->ApplyCommand    4928     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/style s");
4967     G4UImanager::GetUIpointer()->ApplyCommand    4929     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/hiddenEdge 0");
4968   }                                              4930   }
4969   else if (action == "wireframe") {              4931   else if (action == "wireframe") {
4970     G4UImanager::GetUIpointer()->ApplyCommand    4932     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/style w");
4971     G4UImanager::GetUIpointer()->ApplyCommand    4933     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/hiddenEdge 0");
4972   }                                              4934   }
4973 }                                                4935 }
4974                                                  4936 
4975 void G4UIQt::OpenIconCallback(const QString&     4937 void G4UIQt::OpenIconCallback(const QString& aParam)
4976 {                                                4938 {
4977   QString aCommand = aParam.left(aParam.index    4939   QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4978   QString aLabel = aParam.mid(aParam.indexOf(    4940   QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator) + fStringSeparator.length());
4979                                                  4941 
4980   QString nomFich = QFileDialog::getOpenFileN    4942   QString nomFich = QFileDialog::getOpenFileName(fMainWindow, aLabel, fLastOpenPath,
4981     "Macro files (*.mac);;Geant4 files( *.mac    4943     "Macro files (*.mac);;Geant4 files( *.mac *.g4* *.in);;All (*.*)");
4982   if (nomFich != "") {                           4944   if (nomFich != "") {
4983     G4UImanager::GetUIpointer()->ApplyCommand    4945     G4UImanager::GetUIpointer()->ApplyCommand(
4984       (QString(aCommand) + QString(" ") + nom    4946       (QString(aCommand) + QString(" ") + nomFich).toStdString().c_str());
4985     QDir dir;                                    4947     QDir dir;
4986     fLastOpenPath = dir.absoluteFilePath(nomF    4948     fLastOpenPath = dir.absoluteFilePath(nomFich);
4987   }                                              4949   }
4988 }                                                4950 }
4989                                                  4951 
4990 void G4UIQt::SaveIconCallback(const QString&     4952 void G4UIQt::SaveIconCallback(const QString& aParam)
4991 {                                                4953 {
4992   QString aCommand = aParam.left(aParam.index    4954   QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4993   QString aLabel = aParam.mid(aParam.indexOf(    4955   QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator) + fStringSeparator.length());
4994                                                  4956 
4995   QString nomFich =                              4957   QString nomFich =
4996     QFileDialog::getSaveFileName(fMainWindow,    4958     QFileDialog::getSaveFileName(fMainWindow, aLabel, fLastOpenPath, "Macro files (*.mac)");
4997   if (nomFich != "") {                           4959   if (nomFich != "") {
4998     G4UImanager::GetUIpointer()->ApplyCommand    4960     G4UImanager::GetUIpointer()->ApplyCommand(
4999       (QString(aCommand) + QString(" ") + nom    4961       (QString(aCommand) + QString(" ") + nomFich).toStdString().c_str());
5000     QDir dir;                                    4962     QDir dir;
5001     fLastOpenPath = dir.absoluteFilePath(nomF    4963     fLastOpenPath = dir.absoluteFilePath(nomFich);
5002   }                                              4964   }
5003 }                                                4965 }
5004                                                  4966 
5005 void G4UIQt::CreateViewerPropertiesDialog()      4967 void G4UIQt::CreateViewerPropertiesDialog()
5006 {                                                4968 {
5007   if (fViewerPropertiesDialog != nullptr) {      4969   if (fViewerPropertiesDialog != nullptr) {
5008     return;                                      4970     return;
5009   }                                              4971   }
5010   fViewerPropertiesDialog = new QDialog();       4972   fViewerPropertiesDialog = new QDialog();
5011                                                  4973 
5012   fViewerPropertiesDialog->setWindowTitle("Vi    4974   fViewerPropertiesDialog->setWindowTitle("Viewer properties");
5013   fViewerPropertiesDialog->setSizePolicy(        4975   fViewerPropertiesDialog->setSizePolicy(
5014     QSizePolicy(QSizePolicy::Expanding, QSize    4976     QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
5015                                                  4977 
5016   if (fViewerPropertiesWidget == nullptr) {      4978   if (fViewerPropertiesWidget == nullptr) {
5017     fViewerPropertiesWidget = new QWidget();     4979     fViewerPropertiesWidget = new QWidget();
5018     auto layoutPropertiesWidget = new QVBoxLa    4980     auto layoutPropertiesWidget = new QVBoxLayout();
5019     fViewerPropertiesWidget->setLayout(layout    4981     fViewerPropertiesWidget->setLayout(layoutPropertiesWidget);
5020                                                  4982 
5021     CreateEmptyViewerPropertiesWidget();         4983     CreateEmptyViewerPropertiesWidget();
5022   }                                              4984   }
5023                                                  4985 
5024   auto layoutDialog = new QVBoxLayout();         4986   auto layoutDialog = new QVBoxLayout();
5025                                                  4987 
5026   layoutDialog->addWidget(fViewerPropertiesWi    4988   layoutDialog->addWidget(fViewerPropertiesWidget);
5027   layoutDialog->setContentsMargins(0, 0, 0, 0    4989   layoutDialog->setContentsMargins(0, 0, 0, 0);
5028   fViewerPropertiesDialog->setLayout(layoutDi    4990   fViewerPropertiesDialog->setLayout(layoutDialog);
5029 }                                                4991 }
5030                                                  4992 
5031 void G4UIQt::CreatePickInfosDialog()             4993 void G4UIQt::CreatePickInfosDialog()
5032 {                                                4994 {
5033   if (fPickInfosDialog != nullptr) {             4995   if (fPickInfosDialog != nullptr) {
5034     return;                                      4996     return;
5035   }                                              4997   }
5036   fPickInfosDialog = new QDialog();              4998   fPickInfosDialog = new QDialog();
5037                                                  4999 
5038   fPickInfosDialog->setWindowTitle("Pick info    5000   fPickInfosDialog->setWindowTitle("Pick infos");
5039   fPickInfosDialog->setSizePolicy(QSizePolicy    5001   fPickInfosDialog->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
5040                                                  5002 
5041   if (fPickInfosWidget == nullptr) {             5003   if (fPickInfosWidget == nullptr) {
5042     fPickInfosWidget = new QWidget();            5004     fPickInfosWidget = new QWidget();
5043     auto layoutPickInfos = new QVBoxLayout();    5005     auto layoutPickInfos = new QVBoxLayout();
5044     fPickInfosWidget->setLayout(layoutPickInf    5006     fPickInfosWidget->setLayout(layoutPickInfos);
5045                                                  5007 
5046     CreateEmptyPickInfosWidget();                5008     CreateEmptyPickInfosWidget();
5047   }                                              5009   }
5048                                                  5010 
5049   auto layoutDialog = new QVBoxLayout();         5011   auto layoutDialog = new QVBoxLayout();
5050                                                  5012 
5051   layoutDialog->addWidget(fPickInfosWidget);     5013   layoutDialog->addWidget(fPickInfosWidget);
5052   layoutDialog->setContentsMargins(0, 0, 0, 0    5014   layoutDialog->setContentsMargins(0, 0, 0, 0);
5053   fPickInfosDialog->setLayout(layoutDialog);     5015   fPickInfosDialog->setLayout(layoutDialog);
5054   fPickInfosDialog->setWindowFlags(Qt::Window    5016   fPickInfosDialog->setWindowFlags(Qt::WindowStaysOnTopHint);
5055 }                                                5017 }
5056                                                  5018 
5057 void G4UIQt::CreateEmptyViewerPropertiesWidge    5019 void G4UIQt::CreateEmptyViewerPropertiesWidget()
5058 {                                                5020 {
5059   if (fViewerPropertiesWidget == nullptr) ret    5021   if (fViewerPropertiesWidget == nullptr) return;
5060   if (fViewerPropertiesWidget->layout() == nu    5022   if (fViewerPropertiesWidget->layout() == nullptr) return;
5061   QLayoutItem* wItem;                            5023   QLayoutItem* wItem;
5062   if (fViewerPropertiesWidget->layout()->coun    5024   if (fViewerPropertiesWidget->layout()->count() != 0) {
5063     while ((wItem = fViewerPropertiesWidget->    5025     while ((wItem = fViewerPropertiesWidget->layout()->takeAt(0)) != nullptr) {
5064       delete wItem->widget();                    5026       delete wItem->widget();
5065       delete wItem;                              5027       delete wItem;
5066     }                                            5028     }
5067   }                                              5029   }
5068   // Add empty one                               5030   // Add empty one
5069   auto label = new QLabel("No viewer - Please    5031   auto label = new QLabel("No viewer - Please open a viewer first");
5070   fViewerPropertiesWidget->layout()->addWidge    5032   fViewerPropertiesWidget->layout()->addWidget(label);
5071   fViewerPropertiesDialog->setWindowTitle("No    5033   fViewerPropertiesDialog->setWindowTitle("No viewer");
5072   fViewerPropertiesDialog->setVisible(false);    5034   fViewerPropertiesDialog->setVisible(false);
5073 }                                                5035 }
5074                                                  5036 
5075 void G4UIQt::CreateEmptyPickInfosWidget()        5037 void G4UIQt::CreateEmptyPickInfosWidget()
5076 {                                                5038 {
5077   QLayoutItem* wItem;                            5039   QLayoutItem* wItem;
5078   if (fPickInfosWidget->layout()->count() !=     5040   if (fPickInfosWidget->layout()->count() != 0) {
5079     while ((wItem = fPickInfosWidget->layout(    5041     while ((wItem = fPickInfosWidget->layout()->takeAt(0)) != nullptr) {
5080       delete wItem->widget();                    5042       delete wItem->widget();
5081       delete wItem;                              5043       delete wItem;
5082     }                                            5044     }
5083   }                                              5045   }
5084   // Add empty one                               5046   // Add empty one
5085   auto label = new QLabel("Click on the objec    5047   auto label = new QLabel("Click on the object you want to pick");
5086   fPickInfosWidget->layout()->addWidget(label    5048   fPickInfosWidget->layout()->addWidget(label);
5087   fPickInfosDialog->setWindowTitle("Nothing t    5049   fPickInfosDialog->setWindowTitle("Nothing to pick");
5088 }                                                5050 }
5089                                                  5051 
5090 void G4UIQt::ViewerPropertiesIconCallback(int    5052 void G4UIQt::ViewerPropertiesIconCallback(int)
5091 {                                                5053 {
5092   CreateViewerPropertiesDialog();                5054   CreateViewerPropertiesDialog();
5093                                                  5055 
5094   fViewerPropertiesDialog->show();               5056   fViewerPropertiesDialog->show();
5095   fViewerPropertiesDialog->raise();              5057   fViewerPropertiesDialog->raise();
5096   fViewerPropertiesDialog->activateWindow();     5058   fViewerPropertiesDialog->activateWindow();
5097 }                                                5059 }
5098                                                  5060 
5099 void G4UIQt::ChangePerspectiveOrtho(const QSt    5061 void G4UIQt::ChangePerspectiveOrtho(const QString& action)
5100 {                                                5062 {
5101   // Theses actions should be in the app tool    5063   // Theses actions should be in the app toolbar
5102                                                  5064 
5103   if (fToolbarApp == nullptr) return;            5065   if (fToolbarApp == nullptr) return;
5104   QList<QAction*> list = fToolbarApp->actions    5066   QList<QAction*> list = fToolbarApp->actions();
5105   QString checked = "";                          5067   QString checked = "";
5106   for (auto i : list) {                          5068   for (auto i : list) {
5107     if (i->data().toString() == action) {        5069     if (i->data().toString() == action) {
5108       i->setChecked(true);                       5070       i->setChecked(true);
5109       checked = i->data().toString();            5071       checked = i->data().toString();
5110     }                                            5072     }
5111     else if (i->data().toString() == "perspec    5073     else if (i->data().toString() == "perspective") {
5112       i->setChecked(false);                      5074       i->setChecked(false);
5113     }                                            5075     }
5114     else if (i->data().toString() == "ortho")    5076     else if (i->data().toString() == "ortho") {
5115       i->setChecked(false);                      5077       i->setChecked(false);
5116     }                                            5078     }
5117   }                                              5079   }
5118                                                  5080 
5119   if ((action == "ortho") && (checked == "ort    5081   if ((action == "ortho") && (checked == "ortho")) {
5120     G4UImanager::GetUIpointer()->ApplyCommand    5082     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/projection o");
5121   }                                              5083   }
5122   else if ((action == "perspective") && (chec    5084   else if ((action == "perspective") && (checked == "perspective")) {
5123     G4UImanager::GetUIpointer()->ApplyCommand    5085     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/projection p");
5124   }                                              5086   }
5125 }                                                5087 }
5126                                                  5088 
5127 void G4UIQt::SetIconMoveSelected()               5089 void G4UIQt::SetIconMoveSelected()
5128 {                                                5090 {
5129   // Theses actions should be in the app tool    5091   // Theses actions should be in the app toolbar
5130   fMoveSelected = true;                          5092   fMoveSelected = true;
5131   fRotateSelected = false;                       5093   fRotateSelected = false;
5132   fPickSelected = false;                         5094   fPickSelected = false;
5133   fZoomInSelected = false;                       5095   fZoomInSelected = false;
5134   fZoomOutSelected = false;                      5096   fZoomOutSelected = false;
5135                                                  5097 
5136   if (fToolbarApp == nullptr) return;            5098   if (fToolbarApp == nullptr) return;
5137   QList<QAction*> list = fToolbarApp->actions    5099   QList<QAction*> list = fToolbarApp->actions();
5138   for (auto i : list) {                          5100   for (auto i : list) {
5139     if (i->data().toString() == "move") {        5101     if (i->data().toString() == "move") {
5140       i->setChecked(true);                       5102       i->setChecked(true);
5141     }                                            5103     }
5142     else if (i->data().toString() == "rotate"    5104     else if (i->data().toString() == "rotate") {
5143       i->setChecked(false);                      5105       i->setChecked(false);
5144     }                                            5106     }
5145     else if (i->data().toString() == "pick")     5107     else if (i->data().toString() == "pick") {
5146       i->setChecked(false);                      5108       i->setChecked(false);
5147     }                                            5109     }
5148     else if (i->data().toString() == "zoom_in    5110     else if (i->data().toString() == "zoom_in") {
5149       i->setChecked(false);                      5111       i->setChecked(false);
5150     }                                            5112     }
5151     else if (i->data().toString() == "zoom_ou    5113     else if (i->data().toString() == "zoom_out") {
5152       i->setChecked(false);                      5114       i->setChecked(false);
5153     }                                            5115     }
5154   }                                              5116   }
5155 }                                                5117 }
5156                                                  5118 
5157 void G4UIQt::SetIconRotateSelected()             5119 void G4UIQt::SetIconRotateSelected()
5158 {                                                5120 {
5159   // Theses actions should be in the app tool    5121   // Theses actions should be in the app toolbar
5160   fRotateSelected = true;                        5122   fRotateSelected = true;
5161   fMoveSelected = false;                         5123   fMoveSelected = false;
5162   fPickSelected = false;                         5124   fPickSelected = false;
5163   fZoomInSelected = false;                       5125   fZoomInSelected = false;
5164   fZoomOutSelected = false;                      5126   fZoomOutSelected = false;
5165                                                  5127 
5166   if (fToolbarApp == nullptr) return;            5128   if (fToolbarApp == nullptr) return;
5167   QList<QAction*> list = fToolbarApp->actions    5129   QList<QAction*> list = fToolbarApp->actions();
5168   for (auto i : list) {                          5130   for (auto i : list) {
5169     if (i->data().toString() == "rotate") {      5131     if (i->data().toString() == "rotate") {
5170       i->setChecked(true);                       5132       i->setChecked(true);
5171     }                                            5133     }
5172     else if (i->data().toString() == "move")     5134     else if (i->data().toString() == "move") {
5173       i->setChecked(false);                      5135       i->setChecked(false);
5174     }                                            5136     }
5175     else if (i->data().toString() == "pick")     5137     else if (i->data().toString() == "pick") {
5176       i->setChecked(false);                      5138       i->setChecked(false);
5177     }                                            5139     }
5178     else if (i->data().toString() == "zoom_in    5140     else if (i->data().toString() == "zoom_in") {
5179       i->setChecked(false);                      5141       i->setChecked(false);
5180     }                                            5142     }
5181     else if (i->data().toString() == "zoom_ou    5143     else if (i->data().toString() == "zoom_out") {
5182       i->setChecked(false);                      5144       i->setChecked(false);
5183     }                                            5145     }
5184   }                                              5146   }
5185 }                                                5147 }
5186                                                  5148 
5187 void G4UIQt::SetIconPickSelected()               5149 void G4UIQt::SetIconPickSelected()
5188 {                                                5150 {
5189   // Theses actions should be in the app tool    5151   // Theses actions should be in the app toolbar
5190   fPickSelected = true;                          5152   fPickSelected = true;
5191   fMoveSelected = false;                         5153   fMoveSelected = false;
5192   fRotateSelected = false;                       5154   fRotateSelected = false;
5193   fZoomInSelected = false;                       5155   fZoomInSelected = false;
5194   fZoomOutSelected = false;                      5156   fZoomOutSelected = false;
5195                                                  5157 
5196   QToolBar* bar = fToolbarApp;                   5158   QToolBar* bar = fToolbarApp;
5197   if (! fDefaultIcons) {                         5159   if (! fDefaultIcons) {
5198     bar = fToolbarUser;                          5160     bar = fToolbarUser;
5199   }                                              5161   }
5200   if (bar == nullptr) return;                    5162   if (bar == nullptr) return;
5201                                                  5163 
5202   QList<QAction*> list = bar->actions();         5164   QList<QAction*> list = bar->actions();
5203   for (auto i : list) {                          5165   for (auto i : list) {
5204     if (i->data().toString() == "pick") {        5166     if (i->data().toString() == "pick") {
5205       i->setChecked(true);                       5167       i->setChecked(true);
5206     }                                            5168     }
5207     else if (i->data().toString() == "move")     5169     else if (i->data().toString() == "move") {
5208       i->setChecked(false);                      5170       i->setChecked(false);
5209     }                                            5171     }
5210     else if (i->data().toString() == "rotate"    5172     else if (i->data().toString() == "rotate") {
5211       i->setChecked(false);                      5173       i->setChecked(false);
5212     }                                            5174     }
5213     else if (i->data().toString() == "zoom_in    5175     else if (i->data().toString() == "zoom_in") {
5214       i->setChecked(false);                      5176       i->setChecked(false);
5215     }                                            5177     }
5216     else if (i->data().toString() == "zoom_ou    5178     else if (i->data().toString() == "zoom_out") {
5217       i->setChecked(false);                      5179       i->setChecked(false);
5218     }                                            5180     }
5219   }                                              5181   }
5220 }                                                5182 }
5221                                                  5183 
5222 void G4UIQt::SetIconZoomInSelected()             5184 void G4UIQt::SetIconZoomInSelected()
5223 {                                                5185 {
5224   // Theses actions should be in the app tool    5186   // Theses actions should be in the app toolbar
5225   fZoomInSelected = true;                        5187   fZoomInSelected = true;
5226   fMoveSelected = false;                         5188   fMoveSelected = false;
5227   fRotateSelected = false;                       5189   fRotateSelected = false;
5228   fPickSelected = false;                         5190   fPickSelected = false;
5229   fZoomOutSelected = false;                      5191   fZoomOutSelected = false;
5230                                                  5192 
5231   QToolBar* bar = fToolbarApp;                   5193   QToolBar* bar = fToolbarApp;
5232   if (! fDefaultIcons) {                         5194   if (! fDefaultIcons) {
5233     bar = fToolbarUser;                          5195     bar = fToolbarUser;
5234   }                                              5196   }
5235   if (bar == nullptr) return;                    5197   if (bar == nullptr) return;
5236                                                  5198 
5237   QList<QAction*> list = bar->actions();         5199   QList<QAction*> list = bar->actions();
5238   for (auto i : list) {                          5200   for (auto i : list) {
5239     if (i->data().toString() == "zoom_in") {     5201     if (i->data().toString() == "zoom_in") {
5240       i->setChecked(true);                       5202       i->setChecked(true);
5241     }                                            5203     }
5242     else if (i->data().toString() == "move")     5204     else if (i->data().toString() == "move") {
5243       i->setChecked(false);                      5205       i->setChecked(false);
5244     }                                            5206     }
5245     else if (i->data().toString() == "rotate"    5207     else if (i->data().toString() == "rotate") {
5246       i->setChecked(false);                      5208       i->setChecked(false);
5247     }                                            5209     }
5248     else if (i->data().toString() == "pick")     5210     else if (i->data().toString() == "pick") {
5249       i->setChecked(false);                      5211       i->setChecked(false);
5250     }                                            5212     }
5251     else if (i->data().toString() == "zoom_ou    5213     else if (i->data().toString() == "zoom_out") {
5252       i->setChecked(false);                      5214       i->setChecked(false);
5253     }                                            5215     }
5254   }                                              5216   }
5255 }                                                5217 }
5256                                                  5218 
5257 void G4UIQt::SetIconZoomOutSelected()            5219 void G4UIQt::SetIconZoomOutSelected()
5258 {                                                5220 {
5259   // Theses actions should be in the app tool    5221   // Theses actions should be in the app toolbar
5260   fZoomOutSelected = true;                       5222   fZoomOutSelected = true;
5261   fMoveSelected = false;                         5223   fMoveSelected = false;
5262   fRotateSelected = false;                       5224   fRotateSelected = false;
5263   fPickSelected = false;                         5225   fPickSelected = false;
5264   fZoomInSelected = false;                       5226   fZoomInSelected = false;
5265                                                  5227 
5266   QToolBar* bar = fToolbarApp;                   5228   QToolBar* bar = fToolbarApp;
5267   if (! fDefaultIcons) {                         5229   if (! fDefaultIcons) {
5268     bar = fToolbarUser;                          5230     bar = fToolbarUser;
5269   }                                              5231   }
5270   if (bar == nullptr) return;                    5232   if (bar == nullptr) return;
5271                                                  5233 
5272   QList<QAction*> list = bar->actions();         5234   QList<QAction*> list = bar->actions();
5273   for (auto i : list) {                          5235   for (auto i : list) {
5274     if (i->data().toString() == "zoom_out") {    5236     if (i->data().toString() == "zoom_out") {
5275       i->setChecked(true);                       5237       i->setChecked(true);
5276     }                                            5238     }
5277     else if (i->data().toString() == "move")     5239     else if (i->data().toString() == "move") {
5278       i->setChecked(false);                      5240       i->setChecked(false);
5279     }                                            5241     }
5280     else if (i->data().toString() == "rotate"    5242     else if (i->data().toString() == "rotate") {
5281       i->setChecked(false);                      5243       i->setChecked(false);
5282     }                                            5244     }
5283     else if (i->data().toString() == "pick")     5245     else if (i->data().toString() == "pick") {
5284       i->setChecked(false);                      5246       i->setChecked(false);
5285     }                                            5247     }
5286     else if (i->data().toString() == "zoom_in    5248     else if (i->data().toString() == "zoom_in") {
5287       i->setChecked(false);                      5249       i->setChecked(false);
5288     }                                            5250     }
5289   }                                              5251   }
5290 }                                                5252 }
5291                                                  5253 
5292 void G4UIQt::SetIconSolidSelected()              5254 void G4UIQt::SetIconSolidSelected()
5293 {                                                5255 {
5294   // Theses actions should be in the app tool    5256   // Theses actions should be in the app toolbar
5295                                                  5257 
5296   QToolBar* bar = fToolbarApp;                   5258   QToolBar* bar = fToolbarApp;
5297   if (! fDefaultIcons) {                         5259   if (! fDefaultIcons) {
5298     bar = fToolbarUser;                          5260     bar = fToolbarUser;
5299   }                                              5261   }
5300   if (bar == nullptr) return;                    5262   if (bar == nullptr) return;
5301                                                  5263 
5302   QList<QAction*> list = bar->actions();         5264   QList<QAction*> list = bar->actions();
5303   for (auto i : list) {                          5265   for (auto i : list) {
5304     if (i->data().toString() == "solid") {       5266     if (i->data().toString() == "solid") {
5305       i->setChecked(true);                       5267       i->setChecked(true);
5306     }                                            5268     }
5307     else if (i->data().toString() == "hidden_    5269     else if (i->data().toString() == "hidden_line_removal") {
5308       i->setChecked(false);                      5270       i->setChecked(false);
5309     }                                            5271     }
5310     else if (i->data().toString() == "hidden_    5272     else if (i->data().toString() == "hidden_line_and_surface_removal") {
5311       i->setChecked(false);                      5273       i->setChecked(false);
5312     }                                            5274     }
5313     else if (i->data().toString() == "wirefra    5275     else if (i->data().toString() == "wireframe") {
5314       i->setChecked(false);                      5276       i->setChecked(false);
5315     }                                            5277     }
5316   }                                              5278   }
5317 }                                                5279 }
5318                                                  5280 
5319 void G4UIQt::SetIconWireframeSelected()          5281 void G4UIQt::SetIconWireframeSelected()
5320 {                                                5282 {
5321   // Theses actions should be in the app tool    5283   // Theses actions should be in the app toolbar
5322                                                  5284 
5323   QToolBar* bar = fToolbarApp;                   5285   QToolBar* bar = fToolbarApp;
5324   if (! fDefaultIcons) {                         5286   if (! fDefaultIcons) {
5325     bar = fToolbarUser;                          5287     bar = fToolbarUser;
5326   }                                              5288   }
5327   if (bar == nullptr) return;                    5289   if (bar == nullptr) return;
5328                                                  5290 
5329   QList<QAction*> list = bar->actions();         5291   QList<QAction*> list = bar->actions();
5330   for (auto i : list) {                          5292   for (auto i : list) {
5331     if (i->data().toString() == "wireframe")     5293     if (i->data().toString() == "wireframe") {
5332       i->setChecked(true);                       5294       i->setChecked(true);
5333     }                                            5295     }
5334     else if (i->data().toString() == "hidden_    5296     else if (i->data().toString() == "hidden_line_removal") {
5335       i->setChecked(false);                      5297       i->setChecked(false);
5336     }                                            5298     }
5337     else if (i->data().toString() == "hidden_    5299     else if (i->data().toString() == "hidden_line_and_surface_removal") {
5338       i->setChecked(false);                      5300       i->setChecked(false);
5339     }                                            5301     }
5340     else if (i->data().toString() == "solid")    5302     else if (i->data().toString() == "solid") {
5341       i->setChecked(false);                      5303       i->setChecked(false);
5342     }                                            5304     }
5343   }                                              5305   }
5344 }                                                5306 }
5345                                                  5307 
5346 void G4UIQt::SetIconHLRSelected()                5308 void G4UIQt::SetIconHLRSelected()
5347 {                                                5309 {
5348   // Theses actions should be in the app tool    5310   // Theses actions should be in the app toolbar
5349                                                  5311 
5350   QToolBar* bar = fToolbarApp;                   5312   QToolBar* bar = fToolbarApp;
5351   if (! fDefaultIcons) {                         5313   if (! fDefaultIcons) {
5352     bar = fToolbarUser;                          5314     bar = fToolbarUser;
5353   }                                              5315   }
5354   if (bar == nullptr) return;                    5316   if (bar == nullptr) return;
5355                                                  5317 
5356   QList<QAction*> list = bar->actions();         5318   QList<QAction*> list = bar->actions();
5357   for (auto i : list) {                          5319   for (auto i : list) {
5358     if (i->data().toString() == "hidden_line_    5320     if (i->data().toString() == "hidden_line_removal") {
5359       i->setChecked(true);                       5321       i->setChecked(true);
5360     }                                            5322     }
5361     else if (i->data().toString() == "solid")    5323     else if (i->data().toString() == "solid") {
5362       i->setChecked(false);                      5324       i->setChecked(false);
5363     }                                            5325     }
5364     else if (i->data().toString() == "hidden_    5326     else if (i->data().toString() == "hidden_line_and_surface_removal") {
5365       i->setChecked(false);                      5327       i->setChecked(false);
5366     }                                            5328     }
5367     else if (i->data().toString() == "wirefra    5329     else if (i->data().toString() == "wireframe") {
5368       i->setChecked(false);                      5330       i->setChecked(false);
5369     }                                            5331     }
5370   }                                              5332   }
5371 }                                                5333 }
5372                                                  5334 
5373 void G4UIQt::SetIconHLHSRSelected()              5335 void G4UIQt::SetIconHLHSRSelected()
5374 {                                                5336 {
5375   // Theses actions should be in the app tool    5337   // Theses actions should be in the app toolbar
5376                                                  5338 
5377   QToolBar* bar = fToolbarApp;                   5339   QToolBar* bar = fToolbarApp;
5378   if (! fDefaultIcons) {                         5340   if (! fDefaultIcons) {
5379     bar = fToolbarUser;                          5341     bar = fToolbarUser;
5380   }                                              5342   }
5381                                                  5343 
5382   if (bar == nullptr) return;                    5344   if (bar == nullptr) return;
5383                                                  5345 
5384   QList<QAction*> list = bar->actions();         5346   QList<QAction*> list = bar->actions();
5385   for (auto i : list) {                          5347   for (auto i : list) {
5386     if (i->data().toString() == "hidden_line_    5348     if (i->data().toString() == "hidden_line_and_surface_removal") {
5387       i->setChecked(true);                       5349       i->setChecked(true);
5388     }                                            5350     }
5389     else if (i->data().toString() == "solid")    5351     else if (i->data().toString() == "solid") {
5390       i->setChecked(false);                      5352       i->setChecked(false);
5391     }                                            5353     }
5392     else if (i->data().toString() == "hidden_    5354     else if (i->data().toString() == "hidden_line_removal") {
5393       i->setChecked(false);                      5355       i->setChecked(false);
5394     }                                            5356     }
5395     else if (i->data().toString() == "wirefra    5357     else if (i->data().toString() == "wireframe") {
5396       i->setChecked(false);                      5358       i->setChecked(false);
5397     }                                            5359     }
5398   }                                              5360   }
5399 }                                                5361 }
5400                                                  5362 
5401 void G4UIQt::SetIconPerspectiveSelected()        5363 void G4UIQt::SetIconPerspectiveSelected()
5402 {                                                5364 {
5403   // Theses actions should be in the app tool    5365   // Theses actions should be in the app toolbar
5404                                                  5366 
5405   QToolBar* bar = fToolbarApp;                   5367   QToolBar* bar = fToolbarApp;
5406   if (! fDefaultIcons) {                         5368   if (! fDefaultIcons) {
5407     bar = fToolbarUser;                          5369     bar = fToolbarUser;
5408   }                                              5370   }
5409   if (bar == nullptr) return;                    5371   if (bar == nullptr) return;
5410                                                  5372 
5411   QList<QAction*> list = bar->actions();         5373   QList<QAction*> list = bar->actions();
5412   for (auto i : list) {                          5374   for (auto i : list) {
5413     if (i->data().toString() == "perspective"    5375     if (i->data().toString() == "perspective") {
5414       i->setChecked(true);                       5376       i->setChecked(true);
5415     }                                            5377     }
5416     else if (i->data().toString() == "ortho")    5378     else if (i->data().toString() == "ortho") {
5417       i->setChecked(false);                      5379       i->setChecked(false);
5418     }                                            5380     }
5419   }                                              5381   }
5420 }                                                5382 }
5421                                                  5383 
5422 void G4UIQt::SetIconOrthoSelected()              5384 void G4UIQt::SetIconOrthoSelected()
5423 {                                                5385 {
5424   // Theses actions should be in the app tool    5386   // Theses actions should be in the app toolbar
5425                                                  5387 
5426   QToolBar* bar = fToolbarApp;                   5388   QToolBar* bar = fToolbarApp;
5427   if (! fDefaultIcons) {                         5389   if (! fDefaultIcons) {
5428     bar = fToolbarUser;                          5390     bar = fToolbarUser;
5429   }                                              5391   }
5430                                                  5392 
5431   if (bar == nullptr) return;                    5393   if (bar == nullptr) return;
5432                                                  5394 
5433   QList<QAction*> list = bar->actions();         5395   QList<QAction*> list = bar->actions();
5434   for (auto i : list) {                          5396   for (auto i : list) {
5435     if (i->data().toString() == "ortho") {       5397     if (i->data().toString() == "ortho") {
5436       i->setChecked(true);                       5398       i->setChecked(true);
5437     }                                            5399     }
5438     else if (i->data().toString() == "perspec    5400     else if (i->data().toString() == "perspective") {
5439       i->setChecked(false);                      5401       i->setChecked(false);
5440     }                                            5402     }
5441   }                                              5403   }
5442 }                                                5404 }
5443                                                  5405 
5444 #if QT_VERSION < 0x060000                     << 
5445 G4QTabWidget::G4QTabWidget(QWidget* aParent,     5406 G4QTabWidget::G4QTabWidget(QWidget* aParent, G4int sizeX, G4int sizeY)
5446   : QTabWidget(aParent),                         5407   : QTabWidget(aParent),
5447     fTabSelected(false),                         5408     fTabSelected(false),
5448     fLastCreated(-1),                            5409     fLastCreated(-1),
5449     fPreferedSizeX(sizeX + 6)  // margin left    5410     fPreferedSizeX(sizeX + 6)  // margin left+right
5450     ,                                            5411     ,
5451     fPreferedSizeY(sizeY + 58)  // tab label     5412     fPreferedSizeY(sizeY + 58)  // tab label height + margin left+right
5452 {                                                5413 {
5453   setMinimumSize(100, 100);                      5414   setMinimumSize(100, 100);
5454   QSizePolicy policy = QSizePolicy(QSizePolic    5415   QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
5455   setSizePolicy(policy);                         5416   setSizePolicy(policy);
5456 }                                                5417 }
5457                                                  5418 
5458 G4QTabWidget::G4QTabWidget()                     5419 G4QTabWidget::G4QTabWidget()
5459   : QTabWidget(), fTabSelected(false), fLastC    5420   : QTabWidget(), fTabSelected(false), fLastCreated(-1), fPreferedSizeX(0), fPreferedSizeY(0)
5460 {}                                               5421 {}
5461 #endif                                        << 
5462                                                  5422 
5463 G4UIOutputString::G4UIOutputString(const QStr << 5423 G4UIOutputString::G4UIOutputString(QString text, G4String origine, G4String outputStream)
5464   : fText(text), fThread(origine)                5424   : fText(text), fThread(origine)
5465 {                                                5425 {
5466   if (! GetOutputList().contains(QString(" ")    5426   if (! GetOutputList().contains(QString(" ") + outputStream + " ")) {
5467     fOutputStream = "info";                      5427     fOutputStream = "info";
5468   }                                              5428   }
5469   else {                                         5429   else {
5470     fOutputStream = outputStream;                5430     fOutputStream = outputStream;
5471   }                                              5431   }
5472 }                                                5432 }
5473                                                  5433 
5474                                                  5434 
5475 void G4UIQt::TabCloseCallback(int a)             5435 void G4UIQt::TabCloseCallback(int a)
5476 {                                                5436 {
5477   if (fViewerTabWidget == nullptr) return;       5437   if (fViewerTabWidget == nullptr) return;
5478                                                  5438 
5479   // get the address of the widget               5439   // get the address of the widget
5480   QWidget* temp = fViewerTabWidget->widget(a)    5440   QWidget* temp = fViewerTabWidget->widget(a);
5481                                               << 
5482 #if QT_VERSION < 0x060000                     << 
5483   // remove the tab                              5441   // remove the tab
5484   fViewerTabWidget->removeTab(a);                5442   fViewerTabWidget->removeTab(a);
5485                                                  5443 
5486   // if last QWidget : Add empty string          5444   // if last QWidget : Add empty string
5487   G4bool lastTab = true;                         5445   G4bool lastTab = true;
5488   for (G4int c = 0; c < fViewerTabWidget->cou    5446   for (G4int c = 0; c < fViewerTabWidget->count(); ++c) {
5489     if (fViewerTabWidget->tabText(c).contains    5447     if (fViewerTabWidget->tabText(c).contains("viewer")) {
5490       lastTab = false;                           5448       lastTab = false;
5491     }                                            5449     }
5492   }                                              5450   }
5493                                                  5451 
5494   if (lastTab) {                                 5452   if (lastTab) {
5495     CreateEmptyViewerPropertiesWidget();         5453     CreateEmptyViewerPropertiesWidget();
5496   }                                              5454   }
5497   // delete the widget                           5455   // delete the widget
5498   delete temp;                                   5456   delete temp;
5499 #else                                         << 
5500   // remove the tab                           << 
5501   QObject::disconnect(fViewerTabWidget, SIGNA << 
5502   fViewerTabWidget->removeTab(a);             << 
5503   QObject::connect(fViewerTabWidget, SIGNAL(c << 
5504                                               << 
5505   G4int lastViewerTabIndex = -1;              << 
5506   for (G4int c = 0; c < fViewerTabWidget->cou << 
5507     if (fViewerTabWidget->tabText(c).contains << 
5508       lastViewerTabIndex = c;                 << 
5509     }                                         << 
5510   }                                           << 
5511                                               << 
5512   // delete the widget                        << 
5513   delete temp;                                << 
5514                                               << 
5515   // if last QWidget : Add empty string       << 
5516   if (lastViewerTabIndex==(-1)) {             << 
5517     CreateEmptyViewerPropertiesWidget();      << 
5518   } else {                                    << 
5519     UpdateTabWidget(lastViewerTabIndex); //ha << 
5520   }                                           << 
5521 #endif                                        << 
5522 }                                                5457 }
5523                                                  5458 
5524 void G4UIQt::ToolBoxActivated(int a)             5459 void G4UIQt::ToolBoxActivated(int a)
5525 {                                                5460 {
5526   if (fUITabWidget->widget(a) == fHelpTBWidge    5461   if (fUITabWidget->widget(a) == fHelpTBWidget) {
5527     // Rebuild the help tree                     5462     // Rebuild the help tree
5528     FillHelpTree();                              5463     FillHelpTree();
5529   }                                              5464   }
5530   else if (fUITabWidget->widget(a) == fSceneT    5465   else if (fUITabWidget->widget(a) == fSceneTreeWidget) {
5531     fSceneTreeWidget->setVisible(true);          5466     fSceneTreeWidget->setVisible(true);
5532   }                                              5467   }
5533 }                                                5468 }
5534                                                  5469 
5535 #if QT_VERSION < 0x060000                     << 
5536 void G4QTabWidget::paintEvent(QPaintEvent*)      5470 void G4QTabWidget::paintEvent(QPaintEvent*)
5537 {                                                5471 {
5538   if (currentWidget() != nullptr) {              5472   if (currentWidget() != nullptr) {
5539     if (isTabSelected()) {                       5473     if (isTabSelected()) {
5540       //      QCoreApplication::sendPostedEve    5474       //      QCoreApplication::sendPostedEvents () ;
5541                                                  5475 
5542       QString text = tabText(currentIndex());    5476       QString text = tabText(currentIndex());
5543                                                  5477 
5544       if (fLastCreated == -1) {                  5478       if (fLastCreated == -1) {
5545         auto edit = dynamic_cast<QTextEdit*>(    5479         auto edit = dynamic_cast<QTextEdit*>(currentWidget());
5546         if (edit == nullptr) {                   5480         if (edit == nullptr) {
5547           QString paramSelect = QString("/vis    5481           QString paramSelect = QString("/vis/viewer/select ") + text;
5548           G4UImanager* UI = G4UImanager::GetU    5482           G4UImanager* UI = G4UImanager::GetUIpointer();
5549           if (UI != nullptr) {                   5483           if (UI != nullptr) {
5550             UI->ApplyCommand(paramSelect.toSt    5484             UI->ApplyCommand(paramSelect.toStdString().c_str());
5551           }                                      5485           }
5552         }                                        5486         }
5553       }                                          5487       }
5554       else {                                     5488       else {
5555         fLastCreated = -1;                       5489         fLastCreated = -1;
5556       }                                          5490       }
5557       setTabSelected(false);                     5491       setTabSelected(false);
5558     }                                            5492     }
5559   }                                              5493   }
5560 }                                                5494 }
5561 #endif                                        << 
5562                                                  5495 
5563 G4UIDockWidget::G4UIDockWidget(const QString& << 5496 G4UIDockWidget::G4UIDockWidget(QString txt) : QDockWidget(txt) {}
5564                                                  5497 
5565 void G4UIDockWidget::closeEvent(QCloseEvent*     5498 void G4UIDockWidget::closeEvent(QCloseEvent* aEvent)
5566 {                                                5499 {
5567   setFloating(false);                            5500   setFloating(false);
5568                                                  5501 
5569   // prevent from closing                        5502   // prevent from closing
5570   aEvent->ignore();                              5503   aEvent->ignore();
5571   // hide them instead                           5504   // hide them instead
5572   hide();                                        5505   hide();
5573 }                                                5506 }
5574                                                  5507