45#include <qapplication.h>
52#include <qmessagebox.h>
53#include <qpushbutton.h>
54#include <qscrollbar.h>
56#include <qtextbrowser.h>
61#include <qboxlayout.h>
62#include <qbuttongroup.h>
63#include <qcolordialog.h>
65#include <qcompleter.h>
66#include <qfiledialog.h>
68#include <qheaderview.h>
69#include <qlistwidget.h>
70#include <qmainwindow.h>
73#include <qradiobutton.h>
74#include <qscrollarea.h>
75#include <qstandarditemmodel.h>
76#include <qstringlist.h>
78#include <qtablewidget.h>
79#include <qtabwidget.h>
80#include <qtextstream.h>
84#include <QInputDialog>
91# include "moc_G4UIQt.cpp"
95static G4bool exitSession =
true;
96static G4bool exitPause =
true;
119 : fMainWindow(nullptr),
120 fCommandLabel(nullptr),
121 fCommandArea(nullptr),
122 fCoutTBTextArea(nullptr),
123 fUITabWidget(nullptr),
124 fCoutFilter(nullptr),
127 fHistoryTBTableList(nullptr),
128 fHelpTreeWidget(nullptr),
129 fHelpTBWidget(nullptr),
130 fHistoryTBWidget(nullptr),
131 fCoutDockWidget(nullptr),
132 fUIDockWidget(nullptr),
133 fSceneTreeWidget(nullptr),
134 fNewSceneTreeWidget(nullptr),
135 fNewSceneTreeItemTreeWidget(nullptr),
136 fViewerPropertiesWidget(nullptr),
137 fPickInfosWidget(nullptr),
139 fViewerTabWidget(nullptr),
142 fHelpVSplitter(nullptr),
143 fParameterHelpLabel(nullptr),
144 fParameterHelpTable(nullptr),
145 fToolbarApp(nullptr),
146 fToolbarUser(nullptr),
147 fStringSeparator(
"__$$$@%%###__"),
149 fSearchIcon(nullptr),
154 fRotateIcon(nullptr),
156 fZoomInIcon(nullptr),
157 fZoomOutIcon(nullptr),
158 fWireframeIcon(nullptr),
160 fHiddenLineRemovalIcon(nullptr),
161 fHiddenLineAndSurfaceRemovalIcon(nullptr),
162 fPerspectiveIcon(nullptr),
164 fCommandIcon(nullptr),
168 fPickTargetIcon(nullptr),
170#ifdef G4MULTITHREADED
172 fThreadsFilterComboBox(nullptr)
175 fDefaultViewerFirstPageHTMLText(
""),
176 fViewerPropertiesDialog(nullptr),
177 fPickInfosDialog(nullptr),
178 fLastCompleteCommand(
""),
179 fMoveSelected(false),
180 fRotateSelected(true),
181 fPickSelected(false),
182 fZoomInSelected(false),
183 fZoomOutSelected(false)
191 G4cout <<
"G4UIQt : Unable to init Qt. Aborted" <<
G4endl;
201 Q_FOREACH (QWidget* widget, QApplication::allWidgets()) {
202 if ((!found) && (widget->inherits(
"QMainWindow"))) {
212 G4cout <<
"G4UIQt : Found an external App with a QMainWindow already defined. Aborted"
219 fMainWindow =
new QMainWindow();
220 fMainWindow->setAttribute(Qt::WA_DeleteOnClose);
222 fMainWindow->setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
223 fMainWindow->setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
224 fMainWindow->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
225 fMainWindow->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
227 CreateViewerWidget();
228 fMainWindow->addDockWidget(Qt::LeftDockWidgetArea, CreateUITabWidget());
229 fMainWindow->addDockWidget(Qt::BottomDockWidgetArea, CreateCoutTBWidget());
232 fNewSceneTreeWidget =
new QWidget;
233 fNewSceneTreeWidget->setStyleSheet (
"padding: 0px ");
234 fNewSceneTreeWidget->setLayout(
new QVBoxLayout);
235 fNewSceneTreeWidget->layout()->setContentsMargins(5,5,5,5);
236 fNewSceneTreeWidget->setWindowTitle(
"some name");
238 fSceneTreeWidget->layout()->addWidget(fNewSceneTreeWidget);
239 CreateNewSceneTreeWidget();
242 SetDefaultIconsToolbar();
246#ifdef G4MULTITHREADED
251 fMainWindow->setWindowTitle(QFileInfo(QCoreApplication::applicationFilePath()).fileName());
252 fMainWindow->move(QPoint(50, 50));
257 fMainWindow->resize(fUIDockWidget->width() + fCoutDockWidget->width() + 20,
258 fUIDockWidget->height() + fCoutDockWidget->height() + 20);
261 fCommandArea->setFocus(Qt::TabFocusReason);
265 qRegisterMetaType<QTextCursor>(
"QTextCursor");
271 fMainWindow->setVisible(
false);
281#ifdef G4MULTITHREADED
289 fDefaultIcons = aVal;
291 if (! fMainWindow->isVisible()) {
295 if (fToolbarApp !=
nullptr) {
297 fToolbarApp->setVisible(
true);
301 fToolbarApp->setVisible(
false);
306void G4UIQt::SetDefaultIconsToolbar()
309 if (fToolbarApp ==
nullptr) {
310 fToolbarApp =
new QToolBar();
311 fToolbarApp->setIconSize(QSize(20, 20));
312 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
316 AddIcon(
"Open macro file",
"open",
"/control/execute");
317 AddIcon(
"Save viewer state",
"save",
"/vis/viewer/save");
320 fToolbarApp->addAction(QIcon(*fParamIcon),
"Viewer properties",
this,
321 [
this]() { this->ViewerPropertiesIconCallback(0); });
326 AddIcon(
"Zoom out",
"zoom_out",
"");
327 AddIcon(
"Zoom in",
"zoom_in",
"");
328 AddIcon(
"Rotate",
"rotate",
"");
331 AddIcon(
"Hidden line removal",
"hidden_line_removal",
"");
332 AddIcon(
"Hidden line and hidden surface removal",
"hidden_line_and_surface_removal",
"");
333 AddIcon(
"Surfaces",
"solid",
"");
334 AddIcon(
"Wireframe",
"wireframe",
"");
337 AddIcon(
"Perspective",
"perspective",
"");
338 AddIcon(
"Orthographic",
"ortho",
"");
339 AddIcon(
"Run beam on",
"runBeamOn",
"/run/beamOn 1");
340 AddIcon(
"Exit Application",
"exit",
"exit");
345void G4UIQt::CreateIcons()
347 const char *
const save[]={
375 " +++++++++++++++++++++++++ ",
376 " +@##+$%%%%%%%%%%%%%%%&*$%&+ ",
377 " +=-;@>,,''',,,,,,,',,)&!,)+ ",
378 " +;-~@>,,,,,,,,,,,,,,,>$!,)+ ",
379 " +=-~@>,,,,,{]]]]]^,,,>*&$&+ ",
380 " +=-~@>,,,,,'{^{^^{,,,>*#=#+ ",
381 " +=-~@>,,,,,,,,,,,,,,,>@~/=+ ",
382 " +=-~@>,,,{{{''''{',,,>@~-=+ ",
383 " +=-~@>,,'^]]]]]]({,,,>@~-=+ ",
384 " +=-~@>,,,{{{{{{{{{,,,>@~-=+ ",
385 " +=-~@>,,,,,'{^{{^{,,,>@~-=+ ",
386 " +=-~@>,,,,,]]]]]]],,,>@~-=+ ",
387 " +=-~*>,,,,,,,,,,,,,,,>@~-=+ ",
388 " +=-~@>,,,,,,,,,,,,,,,>@~-=+ ",
389 " +=-/=$%%%%%%%%%%%%%%%$=/-=+ ",
390 " +=---;###############;---=+ ",
391 " +=---////////////////----=+ ",
392 " +=----------------///----=+ ",
393 " +=---=@##############@#--=+ ",
394 " +=---@+++++++++++*%))_+~-=+ ",
395 " +=---#+++++++++++&:,,>@~-=+ ",
396 " +=---#+++++++++++$',,>@~-=+ ",
397 " +=---#+++++++++++&!,,>@~-=+ ",
398 " +=/--#+++++++++++&',,>@~-=+ ",
399 " @;--#+++++++++++$',,>@~-=+ ",
400 " @;;@+++++++++++*)!>%@=;#+ ",
401 " @++++++++++++++*&**++@++ ",
406 fSaveIcon =
new QPixmap(save);
408 const char *
const search[] = {
420 "OOOOOOOOOOOOOOOOOOO",
421 "OOOOOOOOOOOOOOOOOOO",
422 "OOOOOOOo. .oOOOOOO",
425 "OOOOO. XOOOOX .OOOO",
428 "OOOOO. XOOOOo .OOOO",
432 "OOOOOOOOOOOOO. XOO",
433 "OOOOOOOOOOOOOO. XOO",
434 "OOOOOOOOOOOOOOOoOOO",
435 "OOOOOOOOOOOOOOOOOOO",
436 "OOOOOOOOOOOOOOOOOOO",
437 "OOOOOOOOOOOOOOOOOOO",
438 "OOOOOOOOOOOOOOOOOOO"
440 fSearchIcon =
new QPixmap(search);
442 const char *
const clear[] = {
454 "OOOOOOOOOOOOOOOOOOOO",
457 "OOOOOOOOOOOOOOOOOOOO",
458 "OOOOOOOOOOOOOOOOOOOO",
459 "OOOO XXXXXXXXXX OOOO",
460 "OOO XOOOOOOOOOO OOO",
461 "OOOOXOooOooOooO OOOO",
462 "OOOOXOooOooOooO OOOO",
463 "OOOOXOooOooOooO OOOO",
464 "OOOOXOooOooOooO OOOO",
465 "OOOOXOooOooOooO OOOO",
466 "OOOOXOooOooOooO OOOO",
467 "OOOOXOooOooOooO OOOO",
468 "OOOOXOooOooOooO OOOO",
469 "OOOOXOooOooOooO OOOO",
470 "OOOOXOooOooOooO OOOO",
471 "OOOOXOOOOOOOOOO OOOO",
472 "OOOOOooooooooooOOOOO",
473 "OOOOOO........OOOOOO"
476 fClearIcon =
new QPixmap(clear);
479 const char *
const open[]={
523 " {]^/((_({- %%%%%%%%%%% ",
524 " {(^_^^^^:<{{{{{{{{{{{{{[& ",
525 " {/_/(((((/]]]]]]]]]]]/]!# ",
526 " {/^(((((_^^^^^^^^^^^^^^:# ",
527 " {/^(((_^^____________^^}$ ",
528 " {/^(((((/////////////((!# ",
529 " {/^/^_:<|||||||||||||||@@****1 ",
530 " {/^/^(<[)||||||||||||||))!!}<; ",
531 " {/^_(:|234444444444444444432)1 ",
532 " {/_^/<)34444444444444444443}, ",
533 " {/^(2{:41111111111111111142|5 ",
534 " {3^3<:31111111111111111143}- ",
535 " {/^2<:31111111111111111441|' ",
536 " {_/<:41111111111111111143}, ",
537 " {(4<:31111111111111111144!# ",
538 " )4))44111111111111111144}, ",
539 " )2<:31111111111111111144{# ",
540 " @|:14444444444444444444}* ",
541 " ;@434444444444444444434<# ",
542 " ;[))))))))))))))))))))!~ ",
543 " ++++++++++++++++++++++;% ",
547 fOpenIcon =
new QPixmap(open);
550 const char *
const move[]={
583 " ')&$$$$*@@ @@*$$$$&)' ",
584 " ')&$$$$*@@ @@*$$$$&+' ",
601 fMoveIcon =
new QPixmap(move);
603 const char *
const rotate[]={
639 " --------!*{{{*&, ",
640 " -------=){*{{{>>{) ",
641 " ,!-----= ){& ,&{{@",
649 " !-!!======!!(((---! ",
650 " ='--------------! ",
665 fRotateIcon =
new QPixmap(rotate);
667 const char *
const pick[]={
683 "*********oo*********",
684 "*********oo*********",
685 "******$O. .O%******",
686 "****&o .O..O O*****",
687 "***&X @**oo**@ X****",
688 "***o $***oo***$ O***",
689 "**% @**********@ %**",
690 "**O.***********& +**",
691 "**.O*****@@*****o.**",
692 "oo .oo**@ #*&XX. oo",
693 "oo .oo**@ #*&oo. oO",
694 "**.O*****##*****oX**",
695 "**O ***********& +**",
696 "**% @****&&****+ &**",
697 "***O $***Xo***# +***",
698 "****X @&*Xo*&+ o****",
699 "*****O o..o +*****",
700 "******%+. X+&******",
701 "*********oo*********",
702 "*********oO*********"
704 fPickIcon =
new QPixmap(pick);
706 const char *
const zoom_in[]={
728 " ++.%%%+&&&*%%.++ ",
729 " .+#%%%%+&&&*%%.#+ ",
730 " ++..%%%+&&&*%%%.++ ",
731 " +#.+++++&&&*++++.+ ",
732 " @.+&&&&&&&&&&&&&+@ ",
733 " @#+&&&&&&&&&&&&&+@ ",
734 " @.+&&&&&&&&&&&&&+. ",
735 " +++@***+&&&****@+. ",
736 " ....++++&&&*++++.. ",
737 " ++.===+&&&*%=.++ ",
738 " @..==+&&&*=..@#& ",
739 " .@+#.+&&&@-+@@*@ ",
752 fZoomInIcon =
new QPixmap(zoom_in);
754 const char *
const zoom_out[]={
776 " ++.$$$$$$$$$$.++ ",
777 " .+#$$$$$$$$$$$.#+ ",
778 " ++..$$$$$$$$$$$.++ ",
779 " +#.+++++++++++++.+ ",
780 " @.+&&&&&&&&&&&&&+@ ",
781 " @#+&&&&&&&&&&&&&+@ ",
782 " @.+&&&&&&&&&&&&&+. ",
783 " +++@***********@+. ",
784 " ....++++++++++++.. ",
785 " ++.===$$$$$$=.++ ",
786 " @..===$$$$=..@#& ",
787 " .@+#.$$$..-+@@*@ ",
800 fZoomOutIcon =
new QPixmap(zoom_out);
802 const char *
const wireframe[]={
831 " +&********&@-***; ",
832 " +@@@&**&@@@@@@$ @*-&>&+ ",
833 " +*****&+ %*@ ,**'# ",
834 " @***)!~ @*{&*****+ ",
835 " @*!]***&+ +-*^**'~!*@ ",
836 " @*~ +@&**&@@@@@@&****&+ ~*@ ",
837 " @*@ +&********&-*= @*@ ",
838 " @*@ $%@-*-@$ @*@ @*@ ",
846 " @*@ =*-+ @*@ @*@ ",
847 " @*@ $%@@&****&@-*-+ @*@ ",
848 " @*@ $@&*****&@@&******&~~!*@ ",
849 " @*{/***&@@%$ $@-*-&*****+ ",
850 " @*)*)(-~ @*@ ~)**] ",
851 " +*******&@@@@+ %*_+]**] ",
852 " +@@@@@&******&@%+_*^**]# ",
861 fWireframeIcon =
new QPixmap(wireframe);
863 const char *
const solid[]={
901 " +-;>>>>>>>>>,')!~ ",
902 " {]@@-;>>>>>>>>>>>>^/(_= ",
903 " {:>>>>>>>>>>>>>>>>><//[)!= ",
904 " ]>>>>>>>>>>>>>>>>>><////[)} ",
905 " @>>>>>>>>>>>>>>>>>><//////| ",
906 " @>>>>>>>>>>>>>>>>>><//////| ",
907 " @>>>>>>>>>>>>>>>>>><//////| ",
908 " @>>>>>>>>>>>>>>>>>><//////| ",
909 " @>>>>>>>>>>>>>>>>>><//////| ",
910 " @>>>>>>>>>>>>>>>>>><//////| ",
911 " @>>>>>>>>>>>>>>>>>><//////| ",
912 " @>>>>>>>>>>>>>>>>>><//////| ",
913 " @>>>>>>>>>>>>>>>>>><//////| ",
914 " @>>>>>>>>>>>>>>>>>><//////| ",
915 " @>>>>>>>>>>>>>>>>>><//////| ",
916 " @>>>>>>>>>>>>>>>>>><//////| ",
917 " @>>>>>>>>>>>>>>>>>><//////| ",
918 " @>>>>>>>>>>>>>>>>>><//////| ",
919 " @>>>>>>>>>>>>>>>>>></////[1 ",
920 " @>>>>>>>>>>>>>>>>>><////[*2 ",
921 " {:>>>>>>>>>>>>>>>>><//[)12 ",
922 " +@@@@@-;>>>>>>>>>><[)13 ",
931 fSolidIcon =
new QPixmap(solid);
933 const char *
const hidden_line_removal[]={
953 " +#$$$$$$$$#@&$$$* ",
954 " =-@@#$$#@@@@@-= @$&#;>= ",
955 " =$$$$$#+ -$@ *$$%+ ",
956 " -$&@-= -$- #$$$= ",
972 " -$&@@@-= -$- =>;, ",
973 " =$$$$$$$#@@@-= -$'+#$$, ",
974 " =-@@@@#$$$$$$#@-+'$)$$#+ ",
983 fHiddenLineRemovalIcon =
new QPixmap(hidden_line_removal);
985 const char *
const hidden_line_and_surface_removal[]={
1031 " ++@%####&*=-#+;>, ",
1032 " +++++@'=)))))))!)~+{]^++ ",
1033 " +$%&*=)!!!!!!!!!)~+/(]_+++ ",
1034 " +#-))!!!!!!!!!!!)~+/(::<[+ ",
1035 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1036 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1037 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1038 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1039 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1040 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1041 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1042 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1043 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1044 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1045 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1046 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1047 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1048 " +#)!!!!!!!!!!!!!!}+/:::|1+ ",
1049 " +$#}}~23!!!!!!!!)~+/(]45, ",
1050 " +++++++@#}}~23!!)~+678++ ",
1051 " ++++++@#~90+a++ ",
1060 fHiddenLineAndSurfaceRemovalIcon =
new QPixmap(hidden_line_and_surface_removal);
1062 const char *
const perspective[]={
1072 " ................ ",
1073 " ....+++++++++++++++. ",
1074 " ...++++..+.........+++. ",
1075 " ..++..............++..+. ",
1076 " .+++++++++++++++++.. .+. ",
1077 " .+...............+. .+. ",
1078 " .+. .+. .+. .+. ",
1079 " .+. .+. .+. .+. ",
1080 " .+. .+. .+. .+. ",
1081 " .+. .+. .+. .+. ",
1082 " .+. .+. .+. .+. ",
1083 " .+. .+. .+. .+. ",
1084 " .+. .+. .+. .+. ",
1085 " .+. .+. .+. .+. ",
1086 " .+. .+......+....+. ",
1087 " .+. ..++++++.+.++++. ",
1088 " .+. .++.......+...+.. ",
1089 " .+. .++. .+..++. ",
1090 " .+. ..+.. .+..+. ",
1093 " .+++.............++. ",
1094 " .+++++++++++++++++. ",
1095 " ................... ",
1100 fPerspectiveIcon =
new QPixmap(perspective);
1102 const char *
const ortho[]={
1110 " ................... ",
1111 " ..@@@@@@@@@@@@@@@@@. ",
1112 " ..@@@.............@@@. ",
1113 " ..@@.@. ..@..@. ",
1114 " ..@@ ..@. .@@...@. ",
1115 " ..@@..............@@.. .@. ",
1116 " .@@@@@@@@@@@@@@@@@.. .@. ",
1117 " .@...............@. .@. ",
1118 " .@. .@. .@. .@. ",
1119 " .@. .@. .@. .@. ",
1120 " .@. .@. .@. .@. ",
1121 " .@. .@. .@. .@. ",
1122 " .@. .@. .@. .@. ",
1123 " .@. .@. .@. .@. ",
1124 " .@. .@. .@. .@. ",
1125 " .@. .@. .@. .@. ",
1126 " .@. .@. .@. .@. ",
1127 " .@. .@. .@. .@. ",
1128 " .@. .@........@......@. ",
1129 " .@. .@@@@@@@@@.@.@@@@@@. ",
1130 " .@. .@@+........@....@@.. ",
1131 " .@...@. .@...@... ",
1133 " .@@@.............@@@.. ",
1134 " .@@@@@@@@@@@@@@@@@... ",
1135 " ................... ",
1140 fOrthoIcon =
new QPixmap(ortho);
1142 const char *
const commandIcon[]={
1170 "66666666666666666666",
1171 "66%++++++++++++++&56",
1172 "6$ o..o......o..o *6",
1173 "6+o...o*<441;@.o..+6",
1174 "6+..o@1553<354$..o+6",
1175 "6+..o<5<@ .*54#o.+6",
1184 "6+..O25<@ X=54#o.+6",
1185 "6+.o.@1553<354$...@6",
1186 "6+o..oo*<44<;@o..o+6",
1187 "6$ .o..o.....o..o *6",
1188 "66%+++++OOOO+++++*66",
1189 "66666666666666666666"
1191 fCommandIcon =
new QPixmap(commandIcon);
1193 const char *
const dirIcon[]={
1221 "66666666666666666666",
1222 "66$oOOOOOOOOOOOOo%66",
1225 "6o =635533666$ o6",
1226 "6o -65:+ +165X o6",
1235 "6o -65:+ @265X o6",
1236 "6o =635543665# O6",
1239 "66$OOOoo....OOOOo%66",
1240 "66666666666666666666"}
1242 fDirIcon =
new QPixmap(dirIcon);
1245 const char *
const runIcon[]={
1282 "rrrrrrrr%<<2rrrrrrrr",
1283 "rrrrr5=$$$$===rrrrrr",
1284 "rrrr<##$$$$$---&rrrr",
1285 "rrr=###$$$$-----%rrr",
1286 "rr=####$$$$------&rr",
1287 "r2@####7##$-------rr",
1288 "r.@####048$-------Or",
1290 " .@@###w4eee5%$#@@@X",
1291 " .@@@..w4eeeeqo..@@X",
1293 " ..oooOe2eee6OOOooo ",
1294 "rOooOO+e2ew2+++++O+r",
1295 "r:oO+++e30,;;;;;++Or",
1296 "r :++;:9,>,,>>:;;1rr",
1297 "rr*1;:>,333333,>32rr",
1298 "rrr66,1367777637<rrr",
1299 "rrrr509799999905rrrr",
1300 "rrrrr=8wqwwww8-rrrrr",
1301 "rrrrrrrr4444rrrrrrrr"
1303 fRunIcon =
new QPixmap(runIcon);
1305 const char *
const paramIcon[]={
1344 "wwwwwwww5 5wwwwwwww",
1345 "wwwwwwww, ,wwwwwwww",
1346 "www&;ww7+ +9ww=-www",
1352 "5<+ .wwwwwww0. +<5",
1355 "5<+ .wwwwwww0X +<5",
1361 "www*>ww7+ +7ww=:www",
1362 "wwwwwwww1 1wwwwwwww",
1363 "wwwwwwww5 5wwwwwwww"
1365 fParamIcon =
new QPixmap(paramIcon);
1367 const char *
const exitIcon[]={
1433 " rMMMM# jMMM MMMMx ",
1434 " OMMMMk jMMM 8MMMM9 ",
1435 " xMMMM jMMM pMMMM ",
1436 " MMMM jMMM xMMM8 ",
1447 " <MMMMMp: $rMMMMMp ",
1448 " yMMMMMMMMMMMMMMk ",
1455 fExitIcon=
new QPixmap(exitIcon);
1462 auto qVariant = item->data(0, Qt::UserRole);
1463 std::istringstream iss(qVariant.toString().toStdString());
1464 void* itemAddress; iss >> itemAddress;
1468 QColor ConvertG4ColourToQColor(
const G4Colour& g4Colour)
1470 return QColor((
int)(g4Colour.
GetRed()*255),
1472 (
int)(g4Colour.
GetBlue()*255),
1476 G4Colour ConvertQColorToG4Colour(
const QColor& qColor)
1478 return G4Color(qColor.red()/255.,
1479 qColor.green()/255.,
1481 qColor.alpha()/255.);
1485void G4UIQt::CreateNewSceneTreeWidget()
1487 auto vLayout = fNewSceneTreeWidget->layout();
1489 vLayout->setContentsMargins(0,0,0,0);
1491 fNewSceneTreeItemTreeWidget =
new NewSceneTreeItemTreeWidget;
1492 fNewSceneTreeItemTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
1493 vLayout->addWidget(fNewSceneTreeItemTreeWidget);
1497 connect(fNewSceneTreeItemTreeWidget, &QTreeWidget::itemClicked,
1498 [&](QTreeWidgetItem* item){SceneTreeItemClicked(item);});
1500 connect(fNewSceneTreeItemTreeWidget, &QTreeWidget::itemDoubleClicked,
1501 [&](QTreeWidgetItem* item){SceneTreeItemDoubleClicked(item);});
1504 connect(fNewSceneTreeItemTreeWidget, &QTreeWidget::itemExpanded,
1505 [&](QTreeWidgetItem* item){SceneTreeItemExpanded(item);});
1506 connect(fNewSceneTreeItemTreeWidget, &QTreeWidget::itemCollapsed,
1507 [&](QTreeWidgetItem* item){SceneTreeItemCollapsed(item);});
1518 fNewSceneTreeItemTreeWidget->clear();
1522 fNewSceneTreeItemTreeWidget->setHeaderLabel (root.
GetDescription().c_str());
1525 auto item =
new QTreeWidgetItem(fNewSceneTreeItemTreeWidget);
1528 fNewSceneTreeItemTreeWidget->insertTopLevelItem(0,item);
1531 item->setText(0, model.GetModelType().c_str());
1537 std::ostringstream oss; oss << std::hex << &model;
1538 auto data = QVariant(oss.str().c_str());
1539 item->setData(0, Qt::UserRole, data);
1542 item->setToolTip(0, model.GetModelDescription().c_str());
1546 (0, model.GetVisAttributes().IsVisible()? Qt::Checked: Qt::Unchecked);
1549 item->setExpanded(model.IsExpanded());
1552 BuildPVQTree(model,item);
1558void G4UIQt::BuildPVQTree(
const G4SceneTreeItem& g4stItem, QTreeWidgetItem* qtwItem)
1560 const auto& g4stChildren = g4stItem.
GetChildren();
1561 for (
const auto& g4stChild: g4stChildren) {
1562 QStringList qStringList;
1563 qStringList.append(g4stChild.GetDescription().c_str());
1564 auto newQTWItem =
new QTreeWidgetItem(qStringList);
1567 qtwItem->addChild(newQTWItem);
1573 std::ostringstream oss; oss << std::hex << &g4stChild;
1574 auto data = QVariant(oss.str().c_str());
1575 newQTWItem->setData(0, Qt::UserRole, data);
1579 auto& nameCopyNo = g4stChild.GetDescription();
1580 auto name = nameCopyNo.substr(0,nameCopyNo.find(
':'));
1581 oss.str(
""); oss << nameCopyNo <<
1582 ": Click to make visible and get more information."
1583 "\n This may not work if the volume is in the \"base path\". (Hover on"
1584 "\n the model to see base path.) If this is the case,"
1585 "\n \"/vis/scene/add/volume " << name <<
"\" to bring into the displayed tree.)";
1586 newQTWItem->setToolTip(0, oss.str().c_str());
1588 oss.str(
""); oss << g4stChild.GetPVPath() <<
1589 "\nTo see properties, right-click/dump.";
1590 newQTWItem->setToolTip(0, oss.str().c_str());
1594 newQTWItem->setCheckState
1595 (0, g4stChild.GetVisAttributes().IsVisible()? Qt::Checked: Qt::Unchecked);
1598 newQTWItem->setExpanded(g4stChild.IsExpanded());
1601 QPixmap pixmap = QPixmap(QSize(16, 16));
1602 pixmap.fill(ConvertG4ColourToQColor(g4stChild.GetVisAttributes().GetColour()));
1603 QPainter painter(&pixmap);
1604 painter.setPen(Qt::black);
1605 painter.drawRect(0,0,15,15);
1606 newQTWItem->setIcon(0,pixmap);
1609 BuildPVQTree(g4stChild,newQTWItem);
1613void G4UIQt::SceneTreeItemClicked(QTreeWidgetItem* item)
1615 if (item ==
nullptr)
return;
1616 auto sceneTreeItem = ConvertToG4SceneTreeItem(item);
1617 if (sceneTreeItem ==
nullptr)
return;
1622 G4String argument =
"false", inverse =
"true";
1623 auto newCheckState = item->checkState(0);
1625 = sceneTreeItem->GetVisAttributes().IsVisible()? Qt::Checked: Qt::Unchecked;
1626 switch (sceneTreeItem->GetType()) {
1633 if (newCheckState != oldCheckState) {
1634 if (newCheckState == Qt::Checked) argument =
"true";
1636 std::istringstream iss(sceneTreeItem->GetModelDescription());
1637 iss >> modelName >> text;
1638 if (modelName.find(
"Text") != std::string::npos) {
1640 uiMan->ApplyCommand(
"/vis/scene/activateModel " + text +
' ' + argument);
1642 uiMan->ApplyCommand(
"/vis/scene/activateModel " + modelName +
' ' + argument);
1648 if (newCheckState != oldCheckState) {
1649 if (newCheckState == Qt::Checked) argument =
"true";
1651 std::istringstream iss(sceneTreeItem->GetModelDescription());
1652 iss >> modelName >> pvName;
1653 uiMan->ApplyCommand(
"/vis/scene/activateModel " + pvName +
' ' + argument);
1661 if (newCheckState != oldCheckState) {
1662 if (newCheckState == Qt::Checked) {
1663 argument =
"true"; inverse =
"false";
1665 uiMan->ApplyCommand(
"/vis/set/touchable" + sceneTreeItem->GetPVPath());
1666 uiMan->ApplyCommand(
"/vis/touchable/set/visibility " + argument);
1668 if (sceneTreeItem->GetChildren().size() > 0 ) {
1669 uiMan->ApplyCommand(
"/vis/touchable/set/daughtersInvisible " + inverse);
1672 static G4bool wanted =
true;
1673 if (wanted && sceneTreeItem->GetChildren().size() > 0 && argument ==
"false") {
1676 (
"This action makes this volume and all descendants invisible."
1677 " To see descendants, right-click and select daughtersInvisible/false"
1678 " and check visibility of descendants individually.");
1679 msgBox.setInformativeText
1680 (
"To suppress this message click \"Discard\" or \"Don't Save\"");
1681 msgBox.setStandardButtons(QMessageBox::Discard | QMessageBox::Ok);
1682 msgBox.setDefaultButton(QMessageBox::Ok);
1683 auto action = msgBox.exec();
1684 if (action == QMessageBox::Discard) {
1693void G4UIQt::SceneTreeItemDoubleClicked(QTreeWidgetItem* item)
1695 if (item ==
nullptr)
return;
1696 auto sceneTreeItem = ConvertToG4SceneTreeItem(item);
1697 if (sceneTreeItem ==
nullptr)
return;
1700 auto oldQColor = ConvertG4ColourToQColor(sceneTreeItem->GetVisAttributes().GetColour());
1701 auto newQColor = QColorDialog::getColor(oldQColor, fNewSceneTreeItemTreeWidget,
"", QColorDialog::ShowAlphaChannel);
1702 if (!newQColor.isValid())
return;
1703 if (newQColor == oldQColor)
return;
1705 auto newColour = ConvertQColorToG4Colour(newQColor);
1706 std::ostringstream oss; oss << std::setprecision(2)
1707 << newColour.GetRed() <<
' ' << newColour.GetGreen()
1708 <<
' ' << newColour.GetBlue() <<
' ' << newColour.GetAlpha();
1710 uiMan->ApplyCommand(
"/vis/set/touchable" + sceneTreeItem->GetPVPath());
1711 uiMan->ApplyCommand(
"/vis/touchable/set/colour " + oss.str());
1714void G4UIQt::SceneTreeItemExpanded(QTreeWidgetItem* item)
1716 if (item ==
nullptr)
return;
1717 auto sceneTreeItem = ConvertToG4SceneTreeItem(item);
1718 if (sceneTreeItem ==
nullptr)
return;
1722 sceneTreeItem->SetExpanded(
true);
1726void G4UIQt::SceneTreeItemCollapsed(QTreeWidgetItem* item)
1728 if (item ==
nullptr)
return;
1729 auto sceneTreeItem = ConvertToG4SceneTreeItem(item);
1730 if (sceneTreeItem ==
nullptr)
return;
1734 sceneTreeItem->SetExpanded(
false);
1738void G4UIQt::NewSceneTreeItemTreeWidget::mousePressEvent(QMouseEvent* ev)
1740#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
1741 auto currentMousePressPosition = ev->globalPos();
1743 auto currentMousePressPosition = ev->globalPosition().toPoint();
1746 if (ev->button() == Qt::RightButton) {
1747 auto item = currentItem();
1749 auto sceneTreeItem = ConvertToG4SceneTreeItem(item);
1750 if (sceneTreeItem) {
1758 enum CommandType {withoutParameter, withABool, withAnInteger, withADouble, withAString};
1759 static std::map<G4String,CommandType> alphabetical;
1760 static G4bool first =
true;
1767 alphabetical[
"centreAndZoomInOn"] = withoutParameter;
1768 alphabetical[
"centreOn"] = withoutParameter;
1769 alphabetical[
"dump"] = withoutParameter;
1770 alphabetical[
"extentForField"] = withoutParameter;
1771 alphabetical[
"localAxes"] = withoutParameter;
1772 alphabetical[
"showExtent"] = withoutParameter;
1773 alphabetical[
"twinkle"] = withoutParameter;
1774 alphabetical[
"volumeForField"] = withoutParameter;
1777 alphabetical[
"daughtersInvisible"] = withABool;
1778 alphabetical[
"forceAuxEdgeVisible"] = withABool;
1779 alphabetical[
"forceCloud"] = withABool;
1780 alphabetical[
"forceSolid"] = withABool;
1781 alphabetical[
"forceWireframe"] = withABool;
1782 alphabetical[
"visibility"] = withABool;
1784 alphabetical[
"lineSegmentsPerCircle"] = withAnInteger;
1785 alphabetical[
"numberOfCloudPoints"] = withAnInteger;
1787 alphabetical[
"lineWidth"] = withADouble;
1789 alphabetical[
"lineStyle"] = withAString;
1793 std::vector<QAction*> actions;
1794 std::vector<QMenu*> menus;
1796 for (
const auto& action : alphabetical) {
1797 const auto& af = action.first;
1799 if (action.second == withoutParameter) {
1801 auto qAction =
new QAction(af.c_str(),
this);
1802 actions.push_back(qAction);
1803 topMenu.addAction(qAction);
1804 connect(qAction, &QAction::triggered,
this,
1805 [
this, &af, &sceneTreeItem]{ActWithoutParameter(af, sceneTreeItem);});
1807 }
else if (action.second == withABool) {
1809 auto menu =
new QMenu(af.c_str());
1810 menus.push_back(menu);
1811 topMenu.addMenu(menu);
1812 auto qActionTrue =
new QAction(
"true",
this);
1813 actions.push_back(qActionTrue);
1814 menu->addAction(qActionTrue);
1815 connect(qActionTrue, &QAction::triggered,
this,
1816 [
this, &af, &sceneTreeItem]{ActWithABool(af, sceneTreeItem,
true);});
1817 auto qActionFalse =
new QAction(
"false",
this);
1818 actions.push_back(qActionFalse);
1819 menu->addAction(qActionFalse);
1820 connect(qActionFalse, &QAction::triggered,
this,
1821 [
this, &af, &sceneTreeItem]{ActWithABool(af, sceneTreeItem,
false);});
1823 }
else if (action.second == withAnInteger) {
1825 auto qAction =
new QAction(af.c_str(),
this);
1826 actions.push_back(qAction);
1827 topMenu.addAction(qAction);
1828 connect(qAction, &QAction::triggered,
this,
1829 [
this, &af, &sceneTreeItem]{ActWithAnInteger(af, sceneTreeItem);});
1831 }
else if (action.second == withADouble) {
1833 auto qAction =
new QAction(af.c_str(),
this);
1834 actions.push_back(qAction);
1835 topMenu.addAction(qAction);
1836 connect(qAction, &QAction::triggered,
this,
1837 [
this, &af, &sceneTreeItem]{ActWithADouble(af, sceneTreeItem);});
1839 }
else if (action.second == withAString) {
1841 auto qAction =
new QAction(af.c_str(),
this);
1842 actions.push_back(qAction);
1843 topMenu.addAction(qAction);
1844 connect(qAction, &QAction::triggered,
this,
1845 [
this, &af, &sceneTreeItem]{ActWithAString(af, sceneTreeItem);});
1849 topMenu.exec(currentMousePressPosition);
1852 for (
auto action : actions) {
1857 for (
auto menu : menus) {
1866 QTreeWidget::mousePressEvent(ev);
1869void G4UIQt::NewSceneTreeItemTreeWidget::ActWithoutParameter
1873 if (action ==
"dump") {
1874 static G4bool wanted =
true;
1877 std::ostringstream oss;
1880 msgBox.setText((oss.str().substr(0,1000)+
"...").c_str());
1881 msgBox.setInformativeText
1882 (
"To suppress this message click \"Discard\" or \"Don't Save\"."
1883 "\nTo get a complete dump to session output click \"Ok\","
1884 "\nElse click \"Close\".");
1885 msgBox.setStandardButtons
1886 (QMessageBox::Discard | QMessageBox::Close | QMessageBox::Ok);
1887 msgBox.setDefaultButton(QMessageBox::Ok);
1888 auto result = msgBox.exec();
1889 if (result == QMessageBox::Discard) {
1891 }
else if (result == QMessageBox::Close) {
1897 uiMan->ApplyCommand(
"/vis/set/touchable" + sceneTreeItem->
GetPVPath());
1898 uiMan->ApplyCommand(
"/vis/touchable/" + action);
1901void G4UIQt::NewSceneTreeItemTreeWidget::ActWithABool
1905 uiMan->ApplyCommand(
"/vis/set/touchable" + sceneTreeItem->
GetPVPath());
1906 G4String which = whatever?
"true":
"false";
1907 uiMan->ApplyCommand(
"/vis/touchable/set/" + action +
' ' + which);
1910void G4UIQt::NewSceneTreeItemTreeWidget::ActWithAnInteger
1914 auto newValue = QInputDialog::getInt(
this, action.c_str(), action.c_str(),
1918 uiMan->ApplyCommand(
"/vis/set/touchable" + sceneTreeItem->
GetPVPath());
1919 uiMan->ApplyCommand(
"/vis/touchable/set/" + action +
' '
1924void G4UIQt::NewSceneTreeItemTreeWidget::ActWithADouble
1928 auto newValue = QInputDialog::getDouble(
this, action.c_str(), action.c_str(),
1932 uiMan->ApplyCommand(
"/vis/set/touchable" + sceneTreeItem->
GetPVPath());
1933 uiMan->ApplyCommand(
"/vis/touchable/set/" + action +
' '
1938void G4UIQt::NewSceneTreeItemTreeWidget::ActWithAString
1942 auto command = uiMan->FindCommand(
"/vis/touchable/set/" + action);
1944 QStringList qStringList;
1945 const auto& candidates = command->GetParameter(0)->GetParameterCandidates();
1946 std::istringstream iss(candidates);
1948 while (iss >> candidate) qStringList.append(candidate.c_str());
1950 auto chosenValue = QInputDialog::getItem(
this, action.c_str(), action.c_str(), qStringList,
1953 uiMan->ApplyCommand(
"/vis/set/touchable" + sceneTreeItem->
GetPVPath());
1954 G4String g4ChosenValue = chosenValue.toStdString();
1955 uiMan->ApplyCommand(
"/vis/touchable/set/" + action +
' ' + g4ChosenValue);
1963QWidget* G4UIQt::CreateHistoryTBWidget()
1965 fHistoryTBWidget =
new QWidget();
1967 auto layoutHistoryTB =
new QVBoxLayout();
1968 fHistoryTBTableList =
new QListWidget();
1969 fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
1970 connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
1972 layoutHistoryTB->addWidget(fHistoryTBTableList);
1974 fHistoryTBWidget->setLayout(layoutHistoryTB);
1975 return fHistoryTBWidget;
1980QWidget* G4UIQt::CreateHelpTBWidget()
1982 fHelpTBWidget =
new QWidget();
1984 auto helpWidget =
new QWidget();
1985 auto helpLayout =
new QHBoxLayout();
1986 auto vLayout =
new QVBoxLayout();
1987 fHelpVSplitter =
new QSplitter(Qt::Vertical);
1988 fHelpLine =
new QLineEdit();
1989 helpLayout->addWidget(
new QLabel(
"Search :"));
1990 helpLayout->addWidget(fHelpLine);
1991 connect(fHelpLine, SIGNAL(editingFinished()),
this, SLOT(LookForHelpStringCallback()));
1996 fParameterHelpLabel =
new QTextEdit();
1997 fParameterHelpLabel->setReadOnly(
true);
1998 fParameterHelpTable =
new QTableWidget();
2002 if (fHelpTreeWidget !=
nullptr) {
2003 fHelpVSplitter->addWidget(fHelpTreeWidget);
2004 fHelpVSplitter->setStretchFactor(0,4);
2006 fHelpVSplitter->addWidget(fParameterHelpLabel);
2007 fHelpVSplitter->addWidget(fParameterHelpTable);
2009 fParameterHelpLabel->setVisible(
false);
2010 fParameterHelpTable->setVisible(
false);
2011 QSizePolicy policy = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
2012 policy.setVerticalStretch(1);
2013 fParameterHelpLabel->setSizePolicy(policy);
2014 fParameterHelpTable->setSizePolicy(policy);
2016 vLayout->addWidget(helpWidget);
2017 vLayout->addWidget(fHelpVSplitter, 1);
2018 vLayout->setContentsMargins(5, 5, 5, 5);
2020 helpWidget->setLayout(helpLayout);
2021 fHelpTBWidget->setLayout(vLayout);
2023 return fHelpTBWidget;
2030 auto coutTBWidget =
new QWidget();
2032 auto layoutCoutTB =
new QVBoxLayout();
2034 fCoutTBTextArea =
new QTextEdit();
2036 fCoutFilter =
new QLineEdit();
2037 fCoutFilter->setToolTip(
"Filter output by...");
2039 fCoutFilter->addAction(*fSearchIcon, QLineEdit::TrailingPosition);
2040 fCoutFilter->setStyleSheet(
"border-radius:7px;");
2042 auto coutTBClearButton =
new QPushButton();
2043 coutTBClearButton->setIcon(*fClearIcon);
2044 coutTBClearButton->setToolTip(
"Clear console output");
2045 coutTBClearButton->setStyleSheet(
"border-radius:7px;");
2046 connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
2048 fCoutFilter, SIGNAL(textEdited(
const QString&)), SLOT(CoutFilterCallback(
const QString&)));
2050 auto coutTBSaveOutputButton =
new QPushButton();
2051 coutTBSaveOutputButton->setIcon(*fSaveIcon);
2052 coutTBSaveOutputButton->setToolTip(
"Save console output");
2053 coutTBSaveOutputButton->setStyleSheet(
"border-radius:7px;");
2054 connect(coutTBSaveOutputButton, SIGNAL(clicked()), SLOT(SaveOutputCallback()));
2056 fCoutTBTextArea->setReadOnly(
true);
2058 auto coutButtonWidget =
new QWidget();
2059 auto layoutCoutTBButtons =
new QHBoxLayout();
2061#ifdef G4MULTITHREADED
2063 fThreadsFilterComboBox =
new QComboBox();
2064 fThreadsFilterComboBox->setInsertPolicy(QComboBox::InsertAlphabetically);
2066 fThreadsFilterComboBox, SIGNAL(activated(
int)),
this, SLOT(ThreadComboBoxCallback(
int)));
2068 UpdateCoutThreadFilter();
2070 fThreadsFilterComboBox->setToolTip(
"Thread selection in output");
2071 layoutCoutTBButtons->addWidget(
new QLabel(
" Threads:"));
2072 layoutCoutTBButtons->addWidget(fThreadsFilterComboBox);
2075 layoutCoutTBButtons->addWidget(fCoutFilter);
2076 layoutCoutTBButtons->addWidget(coutTBClearButton);
2077 layoutCoutTBButtons->addWidget(coutTBSaveOutputButton);
2078 coutButtonWidget->setLayout(layoutCoutTBButtons);
2081 layoutCoutTBButtons->setContentsMargins(3, 3, 3, 0);
2083 layoutCoutTB->addWidget(coutButtonWidget);
2084 layoutCoutTB->addWidget(fCoutTBTextArea);
2086 coutTBWidget->setLayout(layoutCoutTB);
2088 fCoutTBTextArea->setMinimumSize(100, 100);
2091 auto commandLineWidget =
new QWidget();
2092 auto layoutCommandLine =
new QHBoxLayout();
2096 fCommandLabel =
new QLabel(
"");
2097 fCommandArea =
new QLineEdit();
2101 fCommandArea->activateWindow();
2103 fCommandArea->setFocusPolicy(Qt::StrongFocus);
2104 fCommandArea->setFocus(Qt::TabFocusReason);
2105 fCommandArea->setToolTip(
"Apply command");
2107 layoutCommandLine->addWidget(fCommandLabel);
2108 layoutCommandLine->addWidget(fCommandArea);
2111 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
2113 fCommandArea, SIGNAL(textEdited(
const QString&)), SLOT(CommandEditedCallback(
const QString&)));
2115 commandLineWidget->setLayout(layoutCommandLine);
2116 commandLineWidget->setMinimumSize(50, 50);
2118 layoutCoutTB->addWidget(commandLineWidget);
2121 fCoutDockWidget->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
2123 fCoutDockWidget->setWidget(coutTBWidget);
2124 return fCoutDockWidget;
2129QWidget* G4UIQt::CreateVisParametersTBWidget() {
return nullptr; }
2135 fUITabWidget =
new QTabWidget();
2138 fUITabWidget->addTab(CreateSceneTreeWidget(),
"Scene tree");
2139 fUITabWidget->addTab(CreateHelpTBWidget(),
"Help");
2140 fUITabWidget->addTab(CreateHistoryTBWidget(),
"History");
2141 fUITabWidget->setCurrentWidget(fHelpTBWidget);
2143 fUITabWidget->setTabToolTip(0,
"Tree of scene items");
2144 fUITabWidget->setTabToolTip(1,
"Help widget");
2145 fUITabWidget->setTabToolTip(2,
"All commands history");
2146 connect(fUITabWidget, SIGNAL(currentChanged(
int)), SLOT(ToolBoxActivated(
int)));
2149 fUIDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
2151 fUIDockWidget->setWidget(fUITabWidget);
2153 return fUIDockWidget;
2156QWidget* G4UIQt::CreateSceneTreeWidget()
2158 fSceneTreeWidget =
new QWidget();
2159 auto layout =
new QVBoxLayout();
2160 fSceneTreeWidget->setLayout(layout);
2162 fSceneTreeWidget->setVisible(
false);
2164 return fSceneTreeWidget;
2167void G4UIQt::CreateViewerWidget()
2172 SetStartPage(std::string(
"<table width='100%'><tr><td width='30%'></td><td><div ")+
2173 "style='color: rgb(140, 31, 31); font-size: xx-large; font-family: Garamond, serif; padding-bottom: 0px; font-weight: normal'>Geant4: "+
2174 QApplication::applicationName ().toStdString()+
2175 "</div></td><td width='40%'> <br/><i>http://cern.ch/geant4/</i></td></tr></table>"+
2177 "<div style='background:#EEEEEE;'><b>Tooltips :</b><ul>"+
2178 "<li><b>Start a new viewer :</b><br />"+
2179 "<i>'/vis/open/...'<br />"+
2180 "For example '/vis/open OGL'</i></li>"+
2181 "<li><b>Execute a macro file :</b><br />"+
2182 "<i>'/control/execute my_macro_file'</i></li>"+
2185 "<div style='background:#EEEEEE;'><b>Documentation :</b><ul>"+
2186 "<li><b>Visualisation publication :</b><br />"+
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>"+
2190 "<div style='background:#EEEEEE;'><b>Getting Help :</b><ul>"+
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 look at <a href='http://cern.ch/geant4/support'>Geant4 User support pages</a>: <i>http://cern.ch/geant4/support</i></b></li>"+
2198 if (fViewerTabWidget ==
nullptr) {
2200 fMainWindow->setCentralWidget(fViewerTabWidget);
2201 fViewerTabWidget->setTabsClosable(
true);
2203 fViewerTabWidget->setUsesScrollButtons(
true);
2205 connect(fViewerTabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(TabCloseCallback(
int)));
2206 connect(fViewerTabWidget, SIGNAL(currentChanged(
int)), SLOT(UpdateTabWidget(
int)));
2210 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
2211 policy.setVerticalStretch(4);
2212 fViewerTabWidget->setSizePolicy(policy);
2214 fViewerTabWidget->setMinimumSize(40, 40);
2225 if (fViewerPropertiesDialog ==
nullptr) {
2226 CreateViewerPropertiesDialog();
2228 return fViewerPropertiesWidget;
2235 if (fPickInfosDialog ==
nullptr) {
2236 CreatePickInfosDialog();
2238 return fPickInfosWidget;
2245 if (fViewerTabWidget ==
nullptr) {
2248 fViewerTabWidget->addTab(aWidget, title.c_str());
2257 if (fViewerTabWidget ==
nullptr) {
2262 if (UI ==
nullptr)
return false;
2263 std::ifstream file(UI->
FindMacroPath(fileName.c_str()).data());
2265 std::string content((std::istreambuf_iterator<char>(file)), (std::istreambuf_iterator<char>()));
2267 auto text =
new QTextEdit();
2268 text->setAcceptRichText(
true);
2269 text->setContentsMargins(5, 5, 5, 5);
2270 text->setText(QString(
"<pre>") + content.c_str() +
"</pre>");
2271 text->setReadOnly(
true);
2272 fViewerTabWidget->addTab(text, title.c_str());
2285 if (fViewerTabWidget ==
nullptr) {
2286 CreateViewerWidget();
2289 if (aWidget ==
nullptr) {
2293 aWidget->setParent(fViewerTabWidget);
2296 fViewerTabWidget->addTab(aWidget, name);
2298 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count() - 1);
2313 if (! text.empty()) {
2314 fDefaultViewerFirstPageHTMLText = text;
2316 if (fStartPage ==
nullptr) {
2317 fStartPage =
new QTextBrowser();
2318 fStartPage->setContentsMargins(5, 5, 5, 5);
2319 fStartPage->setReadOnly(
true);
2321 fStartPage->setOpenExternalLinks(
true);
2322 fStartPage->setHtml(fDefaultViewerFirstPageHTMLText.c_str());
2325void G4UIQt::UpdateTabWidget(
int tabNumber)
2327 if (fViewerTabWidget ==
nullptr) {
2331 fViewerTabWidget->setCurrentIndex(tabNumber);
2336 fViewerTabWidget->setVisible(
true);
2344void G4UIQt::ResizeTabWidget(QResizeEvent* e)
2346 if (fViewerTabWidget !=
nullptr) {
2347 for (
G4int a = 0; a < fViewerTabWidget->count(); a++) {
2348 fViewerTabWidget->widget(a)->resize(e->size());
2359 exitSession =
false;
2361 QCoreApplication::sendPostedEvents();
2363 fMainWindow->setVisible(
true);
2365 if (fDefaultIcons) {
2366 fToolbarApp->setVisible(
true);
2370 fToolbarApp->setVisible(
false);
2376 UpdateCommandCompleter();
2379 fHistoryTBTableList->installEventFilter(
this);
2380 fCommandArea->installEventFilter(
this);
2383 fCommandArea->setFocus();
2398 if (aPrompt ==
nullptr)
return;
2400 fCommandLabel->setText((
char*)aPrompt.data());
2406 fMainWindow->close();
2420 if (aState ==
nullptr)
return;
2422 if (aState ==
"G4_pause> ") {
2423 SecondaryLoop(
"Pause, type continue to exit this state");
2426 if (aState ==
"EndOfEvent") {
2428 SecondaryLoop(
"End of event, type continue to exit this state");
2436void G4UIQt::SecondaryLoop(
G4String aPrompt)
2438 if (aPrompt ==
nullptr)
return;
2444 ((QApplication*)interactorManager)->processEvents(QEventLoop::WaitForMoreEvents);
2445 if (exitPause)
break;
2450#ifdef G4MULTITHREADED
2466 if (aString.empty())
return 0;
2468#ifdef G4MULTITHREADED
2478#ifdef G4MULTITHREADED
2481 std::cout << aString << std::flush;
2492 for (
G4int i = 0; i < (
G4int)aString.length() - 1; ++i) {
2493 if (aString[i] ==
'\n') {
2494 aStringWithStyle +=
"<br>";
2496 else if (aString[i] ==
' ') {
2497 aStringWithStyle +=
" ";
2499 else if (aString[i] ==
'\t') {
2500 aStringWithStyle +=
" ";
2502 else if (aString[i] ==
'<') {
2503 aStringWithStyle +=
"<";
2506 aStringWithStyle += aString[i];
2510 aStringWithStyle =
"<span style='font-family:courier;'>" + aStringWithStyle +
"</span>";
2513 aStringWithStyle =
"<span>" + aStringWithStyle +
"</span>";
2518 G4UIOutputString(QString((
char*)aStringWithStyle.data()), GetThreadPrefix());
2519 fG4OutputString.push_back(txt);
2521#ifdef G4MULTITHREADED
2522 QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
2524 QString result = FilterOutput(txt,
"", fCoutFilter->text());
2527 if (result.isEmpty()) {
2533 result = QString(
"<span style='background:") + pal.link().color().name() +
";'> </span>" +
2534 "<span style='background: Pink;'> " + result +
"</span>";
2536 result = QString(
"<font color=\"Green\">") + result + QString(
"</font>");
2538 fCoutTBTextArea->append(result);
2539 fCoutTBTextArea->ensureCursorVisible();
2541#ifdef G4MULTITHREADED
2542 UpdateCoutThreadFilter();
2555 if (aString.empty())
return 0;
2559 if (G4StrUtil::contains(aString,
"*** This is just a warning message. ***")) {
2563#ifdef G4MULTITHREADED
2573#ifdef G4MULTITHREADED
2576 std::cout << aString << std::flush;
2587 for (
G4int i = 0; i < (
G4int)aString.length() - 1; ++i) {
2588 if (aString[i] ==
'\n') {
2589 aStringWithStyle +=
"<br>";
2591 else if (aString[i] ==
' ') {
2592 aStringWithStyle +=
" ";
2594 else if (aString[i] ==
'\t') {
2595 aStringWithStyle +=
" ";
2597 else if (aString[i] ==
'<') {
2598 aStringWithStyle +=
"<";
2601 aStringWithStyle += aString[i];
2605 aStringWithStyle =
"<span style='font-family:courier;'>" + aStringWithStyle +
"</span>";
2608 aStringWithStyle =
"<span>" + aStringWithStyle +
"</span>";
2613 G4UIOutputString(QString((
char*)aStringWithStyle.data()), GetThreadPrefix());
2614 fG4OutputString.push_back(txt);
2616#ifdef G4MULTITHREADED
2617 QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
2619 QString result = FilterOutput(txt,
"", fCoutFilter->text());
2622 if (result.isEmpty()) {
2630 result = QString(
"<span style='background:") + pal.link().color().name() +
2631 ";'> </span>" +
"<span style='background:" + pal.highlight().color().name() +
2632 ";'> " + result +
"</span>";
2637 fCoutTBTextArea->append(result);
2638 fCoutTBTextArea->ensureCursorVisible();
2640#ifdef G4MULTITHREADED
2641 UpdateCoutThreadFilter();
2645 fLastErrMessage = aString;
2656 if (aString.empty())
return 0;
2658#ifdef G4MULTITHREADED
2668#ifdef G4MULTITHREADED
2671 std::cerr << aString << std::flush;
2682 for (
G4int i = 0; i < (
G4int)aString.length() - 1; ++i) {
2683 if (aString[i] ==
'\n') {
2684 aStringWithStyle +=
"<br>";
2686 else if (aString[i] ==
' ') {
2687 aStringWithStyle +=
" ";
2689 else if (aString[i] ==
'\t') {
2690 aStringWithStyle +=
" ";
2692 else if (aString[i] ==
'<') {
2693 aStringWithStyle +=
"<";
2696 aStringWithStyle += aString[i];
2700 aStringWithStyle =
"<span style='font-family:courier;'>" + aStringWithStyle +
"</span>";
2703 aStringWithStyle =
"<span>" + aStringWithStyle +
"</span>";
2709 G4UIOutputString(QString((
char*)aStringWithStyle.data()).trimmed(), GetThreadPrefix(),
"error");
2710 fG4OutputString.push_back(txt);
2712#ifdef G4MULTITHREADED
2713 QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
2715 QString result = FilterOutput(txt,
"", fCoutFilter->text());
2717 if (result.isEmpty()) {
2722 if (QString(aString.data()).trimmed() !=
"") {
2727 fLastErrMessage +=
"\n" + aString;
2728 QString criticalMessage = fLastErrMessage.data();
2729 criticalMessage = criticalMessage.toHtmlEscaped();
2730 QMessageBox::critical(fMainWindow,
"Error", QString(fLastErrMessage));
2733 fCoutTBTextArea->append(QString(
"<font color=\"Red\">") + result + QString(
"</font>"));
2734 fCoutTBTextArea->ensureCursorVisible();
2736 if (QString(aString.data()).trimmed() !=
"") {
2737 fLastErrMessage += aString;
2739#ifdef G4MULTITHREADED
2740 UpdateCoutThreadFilter();
2748#ifdef G4MULTITHREADED
2750 if (UI ==
nullptr)
return "";
2758 return threadPrefix;
2761#ifdef G4MULTITHREADED
2762void G4UIQt::UpdateCoutThreadFilter()
2765 if (UI ==
nullptr)
return;
2768 if (fThreadsFilterComboBox->count() < 2) {
2769 if (fThreadsFilterComboBox->findText(
"All", Qt::MatchExactly) == -1) {
2770 fThreadsFilterComboBox->addItem(
"All");
2773 if (fThreadsFilterComboBox->count() < 2) {
2774 if (fThreadsFilterComboBox->findText(
"Master", Qt::MatchExactly) == -1) {
2775 fThreadsFilterComboBox->addItem(
"Master");
2781 if (fThreadsFilterComboBox->findText(
prefix.data(), Qt::MatchExactly) == -1) {
2782 fThreadsFilterComboBox->addItem(
prefix.data());
2795 if (aName ==
nullptr)
return;
2796 if (aLabel ==
nullptr)
return;
2798 auto fileMenu =
new QMenu(aLabel);
2799 fMainWindow->menuBar()->addMenu(fileMenu);
2812 if (aMenu ==
nullptr)
return;
2813 if (aLabel ==
nullptr)
return;
2814 if (aCommand ==
nullptr)
return;
2818 if (parentTmp ==
nullptr) {
2823 G4cout <<
"Menu name " << aMenu <<
" does not exist, please define it before using it."
2831 if (UI ==
nullptr)
return;
2835 std::size_t cmdEndPos = cmd.find_first_of(
" \t");
2836 if (cmdEndPos != std::string::npos) {
2837 cmd.erase(cmdEndPos);
2840 if (treeTop->
FindPath(cmd) ==
nullptr) {
2841 if (cmd !=
"ls" && cmd.substr(0, 3) !=
"ls " && cmd !=
"pwd" && cmd !=
"cd" &&
2842 cmd.substr(0, 3) !=
"cd " && cmd !=
"help" && cmd.substr(0, 5) !=
"help " &&
2843 cmd[0] !=
'?' && cmd !=
"hist" && cmd !=
"history" && cmd[0] !=
'!' && cmd !=
"exit" &&
2844 cmd !=
"cont" && cmd !=
"continue")
2850 G4cout <<
"Warning: command '" << cmd
2851 <<
"' does not exist, please define it before using it." <<
G4endl;
2856 QString cmd_tmp = QString(aCommand);
2857 parentTmp->addAction(aLabel,
this, [
this, cmd_tmp]() { this->ButtonCallback(cmd_tmp); });
2865 const char* aLabel,
const char* aIconFile,
const char* aCommand,
const char* aFileName)
2867 if (aLabel ==
nullptr)
return;
2869 if (aCommand ==
nullptr) {
2870 if (std::string(aIconFile) ==
"user_icon") {
2875 G4bool userToolBar =
false;
2877 if (! fDefaultIcons) {
2880 if (std::string(aIconFile) ==
"user_icon") {
2883 pix =
new QPixmap(UImanager->
FindMacroPath(aFileName).data());
2884 if (pix->isNull()) {
2888 G4cout <<
"Warning: file '" << aFileName
2889 <<
"' is incorrect or does not exist, this command will not be build" <<
G4endl;
2894 else if (std::string(aIconFile) ==
"open") {
2897 else if (std::string(aIconFile) ==
"save") {
2900 else if (std::string(aIconFile) ==
"move") {
2903 else if (std::string(aIconFile) ==
"rotate") {
2906 else if (std::string(aIconFile) ==
"pick") {
2909 else if (std::string(aIconFile) ==
"zoom_in") {
2912 else if (std::string(aIconFile) ==
"zoom_out") {
2915 else if (std::string(aIconFile) ==
"wireframe") {
2916 pix = fWireframeIcon;
2918 else if (std::string(aIconFile) ==
"solid") {
2921 else if (std::string(aIconFile) ==
"hidden_line_removal") {
2922 pix = fHiddenLineRemovalIcon;
2924 else if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
2925 pix = fHiddenLineAndSurfaceRemovalIcon;
2927 else if (std::string(aIconFile) ==
"perspective") {
2928 pix = fPerspectiveIcon;
2930 else if (std::string(aIconFile) ==
"ortho") {
2933 else if (std::string(aIconFile) ==
"runBeamOn") {
2936 else if (std::string(aIconFile) ==
"exit") {
2944 G4cout <<
"Parameter" << aIconFile <<
" not defined" <<
G4endl;
2948 QToolBar* currentToolbar =
nullptr;
2950 if (fToolbarUser ==
nullptr) {
2951 fToolbarUser =
new QToolBar();
2952 fToolbarUser->setIconSize(QSize(20, 20));
2953 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
2955 currentToolbar = fToolbarUser;
2958 if (fToolbarApp ==
nullptr) {
2959 fToolbarApp =
new QToolBar();
2960 fToolbarApp->setIconSize(QSize(20, 20));
2961 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
2963 currentToolbar = fToolbarApp;
2968 QList<QAction*> list = currentToolbar->actions();
2970 for (
auto i : list) {
2971 if (i->text() == QString(aLabel)) {
2973 if (UI ==
nullptr)
return;
2976 G4cout <<
"Warning: A toolBar icon \"" << aLabel <<
"\" already exists with the same name!"
2983 if (std::string(aIconFile) ==
"open") {
2984 QString txt = aCommand + fStringSeparator + aLabel;
2985 currentToolbar->addAction(
2986 QIcon(*pix), aIconFile,
this, [
this, txt]() { this->OpenIconCallback(txt); });
2990 else if (std::string(aIconFile) ==
"save") {
2991 QString txt = aCommand + fStringSeparator + aLabel;
2992 currentToolbar->addAction(
2993 QIcon(*pix), aIconFile,
this, [
this, txt]() { this->SaveIconCallback(txt); });
2996 else if ((std::string(aIconFile) ==
"move") || (std::string(aIconFile) ==
"rotate") ||
2997 (std::string(aIconFile) ==
"pick") || (std::string(aIconFile) ==
"zoom_out") ||
2998 (std::string(aIconFile) ==
"zoom_in"))
3000 QString txt = QString(aIconFile);
3001 QAction* action = currentToolbar->addAction(
3002 QIcon(*pix), aIconFile,
this, [
this, txt]() { this->ChangeCursorAction(txt); });
3003 action->setCheckable(
true);
3004 action->setChecked(
true);
3005 action->setData(aIconFile);
3007 if (std::string(aIconFile) ==
"move") {
3010 if (std::string(aIconFile) ==
"rotate") {
3013 if (std::string(aIconFile) ==
"pick") {
3016 if (std::string(aIconFile) ==
"zoom_in") {
3019 if (std::string(aIconFile) ==
"zoom_out") {
3025 else if ((std::string(aIconFile) ==
"hidden_line_removal") ||
3026 (std::string(aIconFile) ==
"hidden_line_and_surface_removal") ||
3027 (std::string(aIconFile) ==
"solid") || (std::string(aIconFile) ==
"wireframe"))
3029 QString txt = QString(aIconFile);
3030 QAction* action = currentToolbar->addAction(
3031 QIcon(*pix), aIconFile,
this, [
this, txt]() { this->ChangeSurfaceStyle(txt); });
3032 action->setCheckable(
true);
3033 action->setChecked(
true);
3034 action->setData(aIconFile);
3036 if (std::string(aIconFile) ==
"hidden_line_removal") {
3039 if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
3042 if (std::string(aIconFile) ==
"solid") {
3045 if (std::string(aIconFile) ==
"wireframe") {
3051 else if ((std::string(aIconFile) ==
"perspective") || (std::string(aIconFile) ==
"ortho")) {
3052 QString txt = QString(aIconFile);
3053 QAction* action = currentToolbar->addAction(
3054 QIcon(*pix), aIconFile,
this, [
this, txt]() { this->ChangePerspectiveOrtho(txt); });
3055 action->setCheckable(
true);
3056 action->setChecked(
true);
3057 action->setData(aIconFile);
3059 if (std::string(aIconFile) ==
"perspective") {
3062 if (std::string(aIconFile) ==
"ortho") {
3069 if (UI ==
nullptr)
return;
3071 if (aCommand !=
nullptr) {
3072 std::string str = aCommand;
3073 std::string::size_type pos = str.find(
' ');
3074 if (pos != std::string::npos) {
3075 str = str.substr(0, pos).c_str();
3077 if (treeTop->
FindPath(str.c_str()) ==
nullptr) {
3082 G4cout <<
"Warning: command '" << aCommand
3083 <<
"' does not exist, please define it before using it." <<
G4endl;
3087 QString txt = QString(aCommand);
3088 currentToolbar->addAction(
3089 QIcon(*pix), aCommand,
this, [
this, txt]() { this->ButtonCallback(txt); });
3104 if (fMainWindow->menuBar()->isNativeMenuBar() == aVal)
return;
3107 fMainWindow->menuBar()->setNativeMenuBar(aVal);
3112void G4UIQt::ActivateCommand(
G4String newCommand)
3114 if (fHelpTreeWidget ==
nullptr) {
3118 std::size_t i = newCommand.find(
' ');
3120 if (i != std::string::npos) {
3121 G4String newValue = newCommand.substr(i + 1, newCommand.length() - (i + 1));
3122 G4StrUtil::strip(newValue);
3125 if (! targetCom.empty()) {
3126 OpenHelpTreeOnCommand(targetCom.data());
3129 fUITabWidget->setCurrentWidget(fHelpTBWidget);
3138void G4UIQt::InitHelpTreeAndVisParametersWidget()
3140 if (fHelpTreeWidget ==
nullptr) {
3141 fHelpTreeWidget =
new QTreeWidget();
3145 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
3147 labels << QString(
"Command");
3148 fHelpTreeWidget->setHeaderLabels(labels);
3150 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged()),
this, SLOT(HelpTreeClicCallback()));
3151 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,
int)),
this,
3152 SLOT(HelpTreeDoubleClicCallback()));
3160void G4UIQt::FillHelpTree()
3162 if (fHelpTreeWidget ==
nullptr) {
3163 InitHelpTreeAndVisParametersWidget();
3166 QString searchText = fHelpLine->text();
3168 if (searchText ==
"") {
3176 if (fParameterHelpLabel !=
nullptr) {
3177 fParameterHelpLabel->setText(
"Choose a command in the command tree");
3178 fParameterHelpTable->setVisible(
false);
3181 if (fHelpLine !=
nullptr) {
3182 fHelpLine->setText(
"");
3186 if (UI ==
nullptr)
return;
3190 QTreeWidgetItem* newItem =
nullptr;
3191 QString commandText =
"";
3192 for (
G4int a = 0; a < treeSize; ++a) {
3196 commandText = QString((
char*)(treeTop->
GetTree(a + 1)->
GetPathName()).data()).trimmed();
3199 for (
G4int b = 0; b < fHelpTreeWidget->topLevelItemCount(); ++b) {
3200 if (newItem ==
nullptr) newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b), commandText);
3203 if (newItem ==
nullptr) {
3204 newItem =
new QTreeWidgetItem();
3205 newItem->setText(0, GetShortCommandPath(commandText));
3206 fHelpTreeWidget->addTopLevelItem(newItem);
3210 CreateHelpTree(newItem, treeTop->
GetTree(a + 1));
3218void G4UIQt::CreateHelpTree(QTreeWidgetItem* aParent,
G4UIcommandTree* aCommandTree)
3220 if (aParent ==
nullptr)
return;
3221 if (aCommandTree ==
nullptr)
return;
3224 QTreeWidgetItem* newItem;
3226 QString commandText =
"";
3229 commandText = QString((
char*)(aCommandTree->
GetTree(a + 1)->
GetPathName()).data()).trimmed();
3232 newItem = FindTreeItem(aParent, commandText);
3233 if (newItem ==
nullptr) {
3234 newItem =
new QTreeWidgetItem();
3235 newItem->setText(0, GetShortCommandPath(commandText));
3236 aParent->addChild(newItem);
3238 CreateHelpTree(newItem, aCommandTree->
GetTree(a + 1));
3244 QStringList stringList;
3249 newItem = FindTreeItem(aParent, commandText);
3250 if (newItem ==
nullptr) {
3251 newItem =
new QTreeWidgetItem();
3252 newItem->setText(0, GetShortCommandPath(commandText));
3253 aParent->addChild(newItem);
3254 newItem->setExpanded(
false);
3264G4bool G4UIQt::CreateVisCommandGroupAndToolBox(
3267 QString commandText =
3268 QString((
char*)(aCommand->
GetCommandPath().data())).section(
"/", -aDepthLevel);
3270 if (commandText ==
nullptr) {
3276 QWidget* newParentWidget =
nullptr;
3278 QString commandSection = commandText.left(commandText.indexOf(
"/"));
3280 if (aDepthLevel == 1) {
3281 auto currentParent =
dynamic_cast<QToolBox*
>(aParent);
3282 if (currentParent !=
nullptr) {
3284 for (
G4int a = 0; a < currentParent->count(); ++a) {
3285 if (currentParent->itemText(a) == commandSection) {
3287 newParentWidget = currentParent->widget(a);
3293 newParentWidget =
new QGroupBox();
3294 newParentWidget->setLayout(
new QVBoxLayout());
3295 if (currentParent !=
nullptr) {
3296 currentParent->addItem(newParentWidget, commandSection);
3299 if (aParent->layout() ==
nullptr) {
3300 aParent->setLayout(
new QVBoxLayout());
3302 aParent->layout()->addWidget(newParentWidget);
3305 if (commandText.indexOf(
"/") == -1) {
3309 for (
G4int i_thGuidance = 0; i_thGuidance < n_guidanceEntry; i_thGuidance++) {
3310 guidance += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
3312 newParentWidget->setToolTip(guidance);
3315 auto sc =
dynamic_cast<QScrollArea*
>(newParentWidget->parent()->parent());
3316 if (sc !=
nullptr) {
3317 sc->ensureWidgetVisible(newParentWidget);
3323 auto currentParent =
dynamic_cast<QGroupBox*
>(aParent);
3324 if (currentParent !=
nullptr) {
3327 if (aDepthLevel == 2) {
3328 auto parentToolBox =
dynamic_cast<QToolBox*
>(currentParent->parent()->parent()->parent());
3329 if (parentToolBox !=
nullptr) {
3334 for (
G4int a = 0; a < aParent->layout()->count(); ++a) {
3335 auto gb =
dynamic_cast<QGroupBox*
>(aParent->layout()->itemAt(a)->widget());
3336 if (gb !=
nullptr) {
3337 if (gb->title() == commandSection) {
3339 newParentWidget = gb;
3347 newParentWidget =
new QGroupBox();
3348 newParentWidget->setLayout(
new QVBoxLayout());
3349 if (aParent->layout() ==
nullptr) {
3350 aParent->setLayout(
new QVBoxLayout());
3352 aParent->layout()->addWidget(newParentWidget);
3358 for (
G4int i_thGuidance = 0; i_thGuidance < n_guidanceEntry; i_thGuidance++) {
3359 guidance += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
3361 newParentWidget->setToolTip(guidance);
3366 if (commandText.indexOf(
"/") == -1) {
3367 if (CreateCommandWidget(aCommand, newParentWidget, isDialog)) {
3372 CreateVisCommandGroupAndToolBox(aCommand, newParentWidget, aDepthLevel - 1, isDialog);
3385 if (aCommand ==
nullptr) {
3391 if (n_parameterEntry > 0) {
3395 auto paramWidget =
new QWidget();
3396 auto gridLayout =
new QGridLayout();
3397 paramWidget->setLayout(gridLayout);
3400 unsigned int nbColorParameter = 0;
3401 G4bool isStillColorParameter =
false;
3402 G4bool isColorDialogAdded =
false;
3403 QLabel* redLabel =
nullptr;
3404 QLabel* greenLabel =
nullptr;
3405 QString redDefaultStr =
"";
3406 QString greenDefaultStr =
"";
3407 QString blueDefaultStr =
"";
3408 QWidget* redInput =
nullptr;
3409 QWidget* greenInput =
nullptr;
3411 for (
G4int i_thParameter = 0; i_thParameter < n_parameterEntry; i_thParameter++) {
3414 auto label =
new QLabel(QString((
char*)(param->
GetParameterName()).data()));
3416 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")) {
3418 isStillColorParameter =
true;
3420 else if ((label->text() ==
"green") && isStillColorParameter) {
3423 else if ((label->text() ==
"blue") && isStillColorParameter) {
3426 else if (! isColorDialogAdded) {
3428 if (nbColorParameter == 1) {
3429 gridLayout->addWidget(redLabel, i_thParameter - 1, 0);
3430 gridLayout->addWidget(redInput, i_thParameter - 1, 1);
3432 else if (nbColorParameter == 2) {
3433 gridLayout->addWidget(redLabel, i_thParameter - 2, 0);
3434 gridLayout->addWidget(redInput, i_thParameter - 2, 1);
3435 gridLayout->addWidget(greenLabel, i_thParameter - 1, 0);
3436 gridLayout->addWidget(greenInput, i_thParameter - 1, 1);
3438 nbColorParameter = 0;
3441 QWidget* input =
nullptr;
3445 input =
new QLineEdit();
3447 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
3449 if (((label->text() ==
"red") || (label->text() ==
"red_or_string")) &&
3450 isStillColorParameter)
3454 else if ((label->text() ==
"green") && isStillColorParameter) {
3457 else if ((label->text() ==
"blue") && isStillColorParameter) {
3462 input =
new QWidget();
3463 auto layout =
new QHBoxLayout();
3464 input->setLayout(layout);
3466 auto buttons =
new QButtonGroup();
3467 auto radioOff =
new QRadioButton(
"0");
3468 auto radioOn =
new QRadioButton(
"1");
3469 buttons->addButton(radioOn);
3470 buttons->addButton(radioOff);
3471 layout->addWidget(radioOn);
3472 layout->addWidget(radioOff);
3475 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
3476 if (defaultValue ==
"0") {
3477 radioOff->setChecked(
true);
3479 else if (defaultValue ==
"1") {
3480 radioOn->setChecked(
true);
3486 input =
new QComboBox();
3488 QStringList list = candidates.split(
" ");
3491 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
3492 for (
int a = 0; a < list.size(); a++) {
3493 dynamic_cast<QComboBox*
>(input)->addItem(list.at(a));
3494 if (list.at(a) == defaultValue) {
3495 dynamic_cast<QComboBox*
>(input)->setCurrentIndex(a);
3500 input =
new QLineEdit();
3502 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
3505 input =
new QWidget();
3506 auto layout =
new QHBoxLayout();
3507 input->setLayout(layout);
3509 auto buttons =
new QButtonGroup();
3510 auto radioOff =
new QRadioButton(
"off");
3511 auto radioOn =
new QRadioButton(
"on");
3512 buttons->addButton(radioOn);
3513 buttons->addButton(radioOff);
3514 layout->addWidget(radioOn);
3515 layout->addWidget(radioOff);
3518 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
3519 if (defaultValue ==
"off") {
3520 radioOff->setChecked(
true);
3522 else if (defaultValue ==
"on") {
3523 radioOn->setChecked(
true);
3527 input =
new QLineEdit();
3528 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
3531 txt +=
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) +
"\n";
3535 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
3537 txt +=
" Omittable : True\n";
3540 txt +=
" Omittable : False\n";
3543 txt +=
" Default value : taken from the current value\n";
3546 txt +=
" Default value : " + QString((
char*)(param->
GetDefaultValue()).data()) +
"\n";
3549 txt +=
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data()) +
"\n";
3556 if (isStillColorParameter && (nbColorParameter != 0)) {
3557 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")) {
3561 else if (label->text() ==
"green") {
3565 else if (label->text() ==
"blue") {
3570 if ((redDefaultStr !=
"") && (redDefaultStr !=
"") && (redDefaultStr !=
"")) {
3572 redDefaultStr.toDouble(), greenDefaultStr.toDouble(), blueDefaultStr.toDouble());
3574 QPixmap pixmap = QPixmap(QSize(16, 16));
3576 QPainter painter(&pixmap);
3577 painter.setPen(Qt::black);
3578 painter.drawRect(0, 0, 15, 15);
3580 input =
new QPushButton(
"Change color");
3581 dynamic_cast<QPushButton*
>(input)->setIcon(pixmap);
3582 dynamic_cast<QPushButton*
>(input)->setAccessibleName(
3583 redDefaultStr +
" " + greenDefaultStr +
" " + blueDefaultStr);
3584 label =
new QLabel(
"Choose color");
3588 gridLayout->addWidget(label, i_thParameter - nbColorParameter, 0);
3589 input->setToolTip(
"Select the current color");
3590 gridLayout->addWidget(input, i_thParameter - nbColorParameter, 1);
3593 connect(
dynamic_cast<QPushButton*
>(input), &QPushButton::clicked,
3594 [
this, input]() { this->ChangeColorCallback(input); });
3595 isColorDialogAdded =
true;
3596 isStillColorParameter =
false;
3600 gridLayout->addWidget(label, i_thParameter - nbColorParameter, 0);
3601 input->setToolTip(txt);
3602 gridLayout->addWidget(input, i_thParameter - nbColorParameter, 1);
3608 gridLayout->addWidget(name, n_parameterEntry - nbColorParameter, 0);
3610 auto applyButton =
new QPushButton(
"Apply");
3612 gridLayout->addWidget(applyButton, n_parameterEntry - nbColorParameter, 1);
3613 connect(applyButton, &QPushButton::clicked,
3614 [
this, paramWidget]() { this->VisParameterCallback(paramWidget); });
3619 applyButton->setAutoDefault(
true);
3620 applyButton->setDefault(
true);
3622 auto cancelButton =
new QPushButton(tr(
"&Cancel"));
3623 cancelButton->setAutoDefault(
true);
3624 gridLayout->addWidget(cancelButton, n_parameterEntry - nbColorParameter, 1);
3625 gridLayout->addWidget(applyButton, n_parameterEntry - nbColorParameter, 0);
3627 connect(applyButton, &QPushButton::clicked,
3628 [
this, paramWidget]() { this->VisParameterCallback(paramWidget); });
3630 QWidget* parentCheck = aParent;
3631 QDialog* parentDialog =
nullptr;
3633 while ((parentCheck->parentWidget()) !=
nullptr) {
3634 parentCheck = parentCheck->parentWidget();
3635 parentDialog =
dynamic_cast<QDialog*
>(parentCheck);
3636 if (parentDialog !=
nullptr) {
3637 connect(applyButton, SIGNAL(clicked()), parentDialog, SLOT(accept()));
3638 connect(cancelButton, SIGNAL(clicked()), parentDialog, SLOT(reject()));
3647 if (aParent->layout() ==
nullptr) {
3648 aParent->setLayout(
new QVBoxLayout());
3650 aParent->layout()->addWidget(paramWidget);
3660QTreeWidgetItem* G4UIQt::FindTreeItem(QTreeWidgetItem* aParent,
const QString& aCommand)
3662 if (aParent ==
nullptr)
return nullptr;
3665 QString myCommand = aCommand;
3667 if (myCommand.lastIndexOf(
"/") == (myCommand.size() - 1)) {
3668 myCommand = myCommand.left(myCommand.size() - 1);
3671 if (GetLongCommandPath(aParent) == myCommand)
return aParent;
3673 QTreeWidgetItem* tmp =
nullptr;
3674 for (
G4int a = 0; a < aParent->childCount(); ++a) {
3675 if (tmp ==
nullptr) tmp = FindTreeItem(aParent->child(a), myCommand);
3687QString G4UIQt::GetCommandList(
const G4UIcommand* aCommand)
3690 if (aCommand ==
nullptr)
return txt;
3697 if ((commandPath.empty()) && (rangeString.empty()) && (n_guidanceEntry == 0) &&
3698 (n_parameterEntry == 0))
3703 if ((commandPath.length() - 1) !=
'/') {
3704 txt +=
"Command " + QString((
char*)(commandPath).data()) +
"\n";
3706 txt +=
"Guidance :\n";
3708 for (
G4int i_thGuidance = 0; i_thGuidance < n_guidanceEntry; i_thGuidance++) {
3709 txt += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
3711 if (! rangeString.empty()) {
3712 txt +=
" Range of parameters : " + QString((
char*)(rangeString).data()) +
"\n";
3714 if (n_parameterEntry > 0) {
3719 for (
G4int i_thParameter = 0; i_thParameter < n_parameterEntry; i_thParameter++) {
3721 txt +=
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) +
"\n";
3724 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
3726 txt +=
" Omittable : True\n";
3729 txt +=
" Omittable : False\n";
3732 txt +=
" Default value : taken from the current value\n";
3735 txt +=
" Default value : " + QString((
char*)(param->
GetDefaultValue()).data()) +
"\n";
3738 txt +=
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data()) +
"\n";
3756void G4UIQt::updateHelpArea(
const G4UIcommand* aCommand)
3758 if (fParameterHelpLabel ==
nullptr)
return;
3759 if (fParameterHelpTable ==
nullptr)
return;
3761 fParameterHelpLabel->setTextInteractionFlags(Qt::NoTextInteraction);
3763 if (aCommand ==
nullptr)
return;
3770 if ((commandPath.empty()) && (rangeString.empty()) && (n_guidanceEntry == 0) &&
3771 (n_parameterEntry == 0))
3776 if ((commandPath.length() - 1) !=
'/') {
3777 txt +=
"<b>Command </b> " + QString((
char*)(commandPath).data()) +
"<br />";
3779 txt +=
"<b>Guidance :</b> ";
3780 QString tmpGuidance =
"";
3781 for (
G4int i_thGuidance = 0; i_thGuidance < n_guidanceEntry; i_thGuidance++) {
3782 tmpGuidance = QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data());
3783 tmpGuidance = tmpGuidance.toHtmlEscaped();
3784 tmpGuidance.replace(
"\n",
"<br />");
3785 txt += tmpGuidance +
"<br />";
3787 if (! rangeString.empty()) {
3788 QString range = QString((
char*)(rangeString).data());
3789 range = range.toHtmlEscaped();
3790 txt +=
"<b>Range of parameters : </b> " + range +
"<br />";
3795 fParameterHelpLabel->setHtml(txt);
3797 if (n_parameterEntry > 0) {
3802 fParameterHelpTable->clear();
3803 fParameterHelpTable->setRowCount(n_parameterEntry);
3804 fParameterHelpTable->setColumnCount(8);
3805 fParameterHelpTable->setHorizontalHeaderLabels(
3806 QStringList() << tr(
"") << tr(
"Parameter") << tr(
"Guidance") << tr(
"Type") << tr(
"Ommitable")
3807 << tr(
"Default") << tr(
"Range") << tr(
"Candidate"));
3808 fParameterHelpTable->setColumnWidth(2, 60);
3810 fParameterHelpTable->verticalHeader()->setVisible(
false);
3811 fParameterHelpTable->setAlternatingRowColors(
true);
3812 fParameterHelpTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
3813 fParameterHelpTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
3814 fParameterHelpTable->setWordWrap(
true);
3816 QTableWidgetItem* t = fParameterHelpTable->horizontalHeaderItem(1);
3817 QFont fnt = t->font();
3818 G4int size = fnt.pointSize();
3819 fnt.setPointSize(size - 2);
3821 for (
G4int a = 0; a < n_parameterEntry; a++) {
3823 fParameterHelpTable->setItem(a, 0,
new QTableWidgetItem(QString::number(a + 1)));
3825 fParameterHelpTable->setItem(
3826 a, 1,
new QTableWidgetItem(QString((
char*)(param->
GetParameterName()).data())));
3828 fParameterHelpTable->setItem(
3831 fParameterHelpTable->setItem(
3835 fParameterHelpTable->setItem(a, 4,
new QTableWidgetItem(QString(
"True")));
3838 fParameterHelpTable->setItem(a, 4,
new QTableWidgetItem(QString(
"False")));
3841 fParameterHelpTable->setItem(
3842 a, 5,
new QTableWidgetItem(QString(
"taken from the current value")));
3845 fParameterHelpTable->setItem(
3846 a, 5,
new QTableWidgetItem(QString((
char*)(param->
GetDefaultValue()).data())));
3849 fParameterHelpTable->setItem(
3850 a, 6,
new QTableWidgetItem(QString((
char*)(param->
GetParameterRange()).data())));
3853 fParameterHelpTable->setItem(
3857 for (
G4int b = 0; b < 8; ++b) {
3858 QTableWidgetItem* tmp = fParameterHelpTable->item(a, b);
3859 if (tmp !=
nullptr) {
3860 tmp->setToolTip(tmp->text());
3861 tmp->setFlags(Qt::NoItemFlags);
3864 fParameterHelpTable->resizeRowToContents(a);
3866 for (
G4int c = 0; c < 8; ++c) {
3868 fParameterHelpTable->resizeColumnToContents(c);
3871 fParameterHelpLabel->setVisible(
true);
3872 fParameterHelpTable->setVisible(
true);
3883 if (aCommand ==
nullptr)
return false;
3887 if (n_parameterEntry > 0) {
3892 for (
G4int i_thParameter = 0; i_thParameter < n_parameterEntry; i_thParameter++) {
3913G4bool G4UIQt::GetHelpChoice(
G4int&) {
return true; }
3922G4bool G4UIQt::eventFilter(
3923 QObject* aObj, QEvent* aEvent)
3925 G4bool tabKeyPress =
false;
3926 G4bool moveCommandCursor =
false;
3927 if (aObj ==
nullptr)
return false;
3928 if (aEvent ==
nullptr)
return false;
3930 if (aObj == fHistoryTBTableList) {
3931 if (aEvent->type() == QEvent::KeyPress) {
3932 fCommandArea->setFocus();
3936 if (aObj == fCompleter->popup()) {
3937 if (aEvent->type() == QEvent::KeyPress) {
3938 auto e =
static_cast<QKeyEvent*
>(aEvent);
3939 if (e->key() == (Qt::Key_Tab)) {
3943 else if (aEvent->type() == QEvent::Hide) {
3945 QString c = fCommandArea->text();
3946 fLastCompleteCommand = c.left(c.indexOf(
"<"));
3950 if (aObj == fCommandArea) {
3951 if (aEvent->type() == QEvent::KeyPress) {
3952 auto e =
static_cast<QKeyEvent*
>(aEvent);
3953 if ((e->key() == (Qt::Key_Down)) || (e->key() == (Qt::Key_PageDown)) ||
3954 (e->key() == (Qt::Key_Up)) || (e->key() == (Qt::Key_PageUp)))
3956 G4int selection = fHistoryTBTableList->currentRow();
3957 if (fHistoryTBTableList->count() != 0) {
3958 if (selection == -1) {
3959 selection = fHistoryTBTableList->count() - 1;
3962 if (e->key() == (Qt::Key_Down)) {
3963 if (selection < (fHistoryTBTableList->count() - 1)) selection++;
3965 else if (e->key() == (Qt::Key_PageDown)) {
3966 selection = fHistoryTBTableList->count() - 1;
3968 else if (e->key() == (Qt::Key_Up)) {
3969 if (selection > 0) selection--;
3971 else if (e->key() == (Qt::Key_PageUp)) {
3975 fHistoryTBTableList->clearSelection();
3976 fHistoryTBTableList->item(selection)->setSelected(
true);
3977 fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
3979 moveCommandCursor =
true;
3981 else if (e->key() == (Qt::Key_Tab)) {
3984 else if (((e->modifiers() == Qt::ControlModifier) || (e->modifiers() == Qt::MetaModifier)) &&
3985 (e->key() == Qt::Key_A))
3987 fCommandArea->home(
false);
3990 else if (((e->modifiers() == Qt::ControlModifier) || (e->modifiers() == Qt::MetaModifier)) &&
3991 (e->key() == Qt::Key_E))
3993 fCommandArea->end(
false);
3997 else if (aEvent->type() == QEvent::Paint) {
3998 if (fLastCompleteCommand !=
"") {
3999 fCommandArea->setText(fLastCompleteCommand);
4000 fLastCompleteCommand =
"";
4006 fCommandArea->setText((
char*)(ss.data()));
4007 fCommandArea->setFocus();
4016 if (moveCommandCursor) {
4017 fCommandArea->setCursorPosition((
int)fCommandArea->text().length());
4018 fCommandArea->setCursorPosition(4);
4022 res = QObject::eventFilter(aObj, aEvent);
4027void G4UIQt::UpdateCommandCompleter()
4029 if (fCommandArea ==
nullptr)
return;
4032 fCommandArea->setCompleter(
nullptr);
4033 if (fCompleter !=
nullptr) {
4034 if (fCompleter->popup() !=
nullptr) {
4035 fCompleter->popup()->removeEventFilter(
this);
4039 QStandardItemModel* model = CreateCompleterModel(
"/");
4040 fCompleter =
new QCompleter(model);
4046 if (aTree !=
nullptr) {
4048 fCompleter->setMaxVisibleItems(Ndir);
4050 fCommandArea->setCompleter(fCompleter);
4051 fCompleter->popup()->installEventFilter(
this);
4054QStandardItemModel* G4UIQt::CreateCompleterModel(
G4String aCmd)
4056 QList<QStandardItem*> dirModelList;
4057 QList<QStandardItem*> commandModelList;
4058 QList<QStandardItem*> subDirModelList;
4059 QList<QStandardItem*> subCommandModelList;
4070 auto jpre = pName.rfind(
'/');
4071 if (jpre != G4String::npos) pName.erase(jpre + 1);
4075 if (aTree !=
nullptr) {
4080 for (
G4int idir = 1; idir <= Ndir; ++idir) {
4083 if (fpdir.find(remainingPath, 0) == 0) {
4085 matchingPath = fpdir;
4093 auto item1 =
new QStandardItem(fpdir.data());
4094 QIcon i = QIcon(*fDirIcon);
4096 item1->setIcon(QIcon(*fDirIcon));
4097 dirModelList.append(item1);
4100 QStandardItemModel* subModel = CreateCompleterModel(fpdir.data());
4101 for (
G4int a = 0; a < subModel->rowCount(); ++a) {
4103 auto tempItem =
new QStandardItem(subModel->item(a)->text());
4104 tempItem->setIcon(subModel->item(a)->icon());
4105 tempItem->setToolTip(subModel->item(a)->toolTip());
4106 tempItem->setData(subModel->item(a)->data());
4109 if (tempItem->data() == 1) {
4111 subDirModelList.append(tempItem);
4114 else if (tempItem->data() == 0) {
4115 subCommandModelList.append(tempItem);
4122 G4int n_parameterEntry;
4124 G4int n_guidanceEntry;
4127 std::string tooltip;
4130 for (
G4int icmd = 1; icmd <= Ncmd; ++icmd) {
4140 if (longCommandName.find(remainingPath, 0) == 0) {
4142 matchingPath = longCommandName +
" ";
4145 strtmp = longCommandName +
" ";
4150 for (
G4int i_thGuidance = 0; i_thGuidance < n_guidanceEntry; i_thGuidance++) {
4151 tooltip += std::string((command->
GetGuidanceLine(i_thGuidance)).data());
4152 if (i_thGuidance < n_guidanceEntry - 1) {
4158 for (
G4int a = 0; a < n_parameterEntry; a++) {
4170 auto item =
new QStandardItem(
G4String(longCommandName + params).data());
4172 item->setIcon(QIcon(*fCommandIcon));
4173 item->setToolTip(tooltip.c_str());
4175 commandModelList.append(item);
4180 auto model =
new QStandardItemModel();
4182 model->setColumnCount(1);
4185 for (
auto a : dirModelList) {
4186 model->appendRow(a);
4188 for (
auto a : subDirModelList) {
4189 model->appendRow(a);
4191 for (
auto a : commandModelList) {
4192 model->appendRow(a);
4194 for (
auto a : subCommandModelList) {
4195 model->appendRow(a);
4213void G4UIQt::ClearButtonCallback()
4215 fCoutTBTextArea->clear();
4216 fG4OutputString.clear();
4223void G4UIQt::ExitHelp()
const {}
4228void G4UIQt::CommandEnteredCallback()
4231 fCommandArea->setText(fCommandArea->text().trimmed());
4232#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
4233 QStringList list = fCommandArea->text().split(QRegularExpression(
"[\r\n]"),QString::SkipEmptyParts);
4235 QStringList list = fCommandArea->text().split(QRegularExpression(
"[\r\n]"),Qt::SkipEmptyParts);
4239 for (
G4int a = 0; a < list.size(); ++a) {
4240 QString txt(list[a].trimmed());
4242 fHistoryTBTableList->addItem(txt);
4243 fHistoryTBTableList->clearSelection();
4244 fHistoryTBTableList->setCurrentItem(
nullptr);
4245 fCommandArea->setText(
"");
4247 if (interactorManager !=
nullptr) {
4251 G4String command = txt.toStdString().c_str();
4252 if (command.substr(0, 4) !=
"help") {
4256 ActivateCommand(command);
4261 fCommandArea->setFocus();
4267 UpdateCommandCompleter();
4276void G4UIQt::CommandEditedCallback(
const QString&)
4278#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
4279 QStringList list = fCommandArea->text().split(QRegularExpression(
"[\r\n]"), QString::SkipEmptyParts);
4281 QStringList list = fCommandArea->text().split(QRegularExpression(
"[\r\n]"), Qt::SkipEmptyParts);
4284 if (list.size() > 1) {
4285 for (
G4int a = 0; a < list.size() - 1; ++a) {
4287 fCommandArea->setText(list[a]);
4289 CommandEnteredCallback();
4292 fCommandArea->setText(list[list.size() - 1]);
4298void G4UIQt::VisParameterCallback(QWidget* widget)
4300 if (widget ==
nullptr) {
4305 auto grid =
dynamic_cast<QGridLayout*
>(widget->layout());
4306 if (grid ==
nullptr) {
4310 QWidget*
name = grid->itemAtPosition(grid->rowCount() - 1, 0)->widget();
4311 if (
dynamic_cast<QLabel*
>(name) ==
nullptr) {
4314 command += (
dynamic_cast<QLabel*
>(
name))->text() +
" ";
4316 for (
G4int a = 0; a < grid->rowCount() - 1; ++a) {
4317 QWidget* widgetTmp = grid->itemAtPosition(a, 1)->widget();
4320 if (widgetTmp !=
nullptr) {
4321 if (
dynamic_cast<QLineEdit*
>(widgetTmp) !=
nullptr) {
4322 command += (
dynamic_cast<QLineEdit*
>(widgetTmp))->text() +
" ";
4324 else if (
dynamic_cast<QComboBox*
>(widgetTmp) !=
nullptr) {
4325 command += (
dynamic_cast<QComboBox*
>(widgetTmp))
4326 ->itemText((
dynamic_cast<QComboBox*
>(widgetTmp))->currentIndex()) +
4331 else if (
dynamic_cast<QPushButton*
>(widgetTmp) !=
nullptr) {
4332 command += widgetTmp->accessibleName() +
" ";
4336 else if (
dynamic_cast<QWidget*
>(widgetTmp) !=
nullptr) {
4337 if (widgetTmp->layout()->count() > 0) {
4338 if (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()) !=
nullptr) {
4339 QAbstractButton* checked =
4340 (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))
4343 if (checked !=
nullptr) {
4344 command += (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))
4355 if (command !=
"") {
4357 if (UI !=
nullptr) {
4368void G4UIQt::ButtonCallback(
const QString& aCommand)
4370 G4String ss = G4StrUtil::lstrip_copy(
G4String(aCommand.toStdString().c_str()));
4373 if (UI ==
nullptr)
return;
4378 if (command !=
nullptr) {
4380 if (IsGUICommand(command)) {
4381 auto menuParameterDialog =
new QDialog();
4383 if (CreateVisCommandGroupAndToolBox(command, menuParameterDialog, 1,
true)) {
4384 menuParameterDialog->setWindowTitle(aCommand);
4385 menuParameterDialog->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
4388 menuParameterDialog->exec();
4391 delete menuParameterDialog;
4405void G4UIQt::HelpTreeClicCallback()
4407 QTreeWidgetItem* item =
nullptr;
4408 if (fHelpTreeWidget ==
nullptr)
return;
4410 QList<QTreeWidgetItem*> list = fHelpTreeWidget->selectedItems();
4411 if (list.isEmpty())
return;
4412 item = list.first();
4413 if (item ==
nullptr)
return;
4416 if (UI ==
nullptr)
return;
4419 std::string itemText = GetLongCommandPath(item).toStdString();
4422 if (item->childCount() > 0) {
4427 if (command !=
nullptr) {
4428 updateHelpArea(command);
4432 if (path !=
nullptr) {
4435 fParameterHelpLabel->setVisible(
true);
4436 fParameterHelpLabel->setText(path->
GetTitle().data());
4437 fParameterHelpTable->setVisible(
false);
4444void G4UIQt::HelpTreeDoubleClicCallback()
4446 HelpTreeClicCallback();
4448 QTreeWidgetItem* item =
nullptr;
4449 if (fHelpTreeWidget ==
nullptr)
return;
4451 QList<QTreeWidgetItem*> list = fHelpTreeWidget->selectedItems();
4452 if (list.isEmpty())
return;
4453 item = list.first();
4454 if (item ==
nullptr)
return;
4456 fCommandArea->clear();
4457 fCommandArea->setText(GetLongCommandPath(item));
4463void G4UIQt::CommandHistoryCallback()
4465 QListWidgetItem* item =
nullptr;
4466 if (fHistoryTBTableList ==
nullptr)
return;
4468 QList<QListWidgetItem*> list = fHistoryTBTableList->selectedItems();
4469 if (list.isEmpty())
return;
4470 item = list.first();
4471 if (item ==
nullptr)
return;
4472 fCommandArea->setText(item->text());
4475void G4UIQt::ThreadComboBoxCallback(
int) { CoutFilterCallback(
""); }
4477void G4UIQt::CoutFilterCallback(
const QString&)
4479 FilterAllOutputTextArea();
4481 fCoutTBTextArea->repaint();
4482 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(
4483 fCoutTBTextArea->verticalScrollBar()->maximum());
4486void G4UIQt::SaveOutputCallback()
4488 QString fileName = QFileDialog::getSaveFileName(
4489 fMainWindow,
"Save console output as...", fLastOpenPath,
"Save output as...");
4490 if (fileName !=
"") {
4491 QFile data(fileName);
4492 if (data.open(QFile::WriteOnly | QFile::Truncate)) {
4493 QTextStream out(&data);
4494 out << fCoutTBTextArea->toPlainText();
4501QString G4UIQt::FilterOutput(
4502 const G4UIOutputString& output,
const QString& currentThread,
const QString& filter)
4504#ifdef G4MULTITHREADED
4505 if ((currentThread ==
"All") || (currentThread == output.
fThread)) {
4507 if (currentThread ==
"") {
4509 if (output.
fText.contains(QRegularExpression(filter))) {
4510 return output.
fText;
4516void G4UIQt::FilterAllOutputTextArea()
4518 QString currentThread =
"";
4519#ifdef G4MULTITHREADED
4520 currentThread = fThreadsFilterComboBox->currentText();
4521 if (currentThread ==
"Master") {
4525 QString filter = fCoutFilter->text();
4526 G4String previousOutputStream =
"";
4531 fCoutTBTextArea->clear();
4533 for (
auto& out : fG4OutputString) {
4534 if (FilterOutput(out, currentThread, filter) !=
"") {
4536 if (out.fOutputStream != previousOutputStream) {
4537 previousOutputStream = out.fOutputStream;
4538 if (out.fOutputStream ==
"info") {
4542 else if (out.fOutputStream ==
"warning") {
4543 pref =
"<font color=\"DarkYellow\">";
4547 pref =
"<font color=\"Red\">";
4551 fCoutTBTextArea->append(pref + out.fText + post);
4560void G4UIQt::LookForHelpStringCallback()
4562 fHelpLine->setText(fHelpLine->text().trimmed());
4563 QString searchText = fHelpLine->text();
4565 fParameterHelpLabel->setText(
"");
4566 fParameterHelpTable->setVisible(
false);
4567 if (searchText ==
"") {
4569 fHelpTreeWidget->clear();
4575 OpenHelpTreeOnCommand(searchText);
4578void G4UIQt::OpenHelpTreeOnCommand(
const QString& searchText)
4582 if (UI ==
nullptr)
return;
4588 fHelpTreeWidget->clear();
4594#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
4596 QMap<G4int, QString> commandResultMap;
4597 QMap<G4int, QString> commandChildResultMap;
4598 for (
G4int a = 0; a < treeSize; ++a) {
4600 tmp = GetCommandList(command).count(searchText, Qt::CaseInsensitive);
4602 commandResultMap.insertMulti(
4606 commandChildResultMap = LookForHelpStringInChildTree(treeTop->
GetTree(a + 1), searchText);
4608 if (! commandChildResultMap.empty()) {
4609 QMap<int, QString>::const_iterator i = commandChildResultMap.constBegin();
4610 while (i != commandChildResultMap.constEnd()) {
4611 commandResultMap.insertMulti(i.key(), i.value());
4614 commandChildResultMap.clear();
4619 QMultiMap<G4int, QString> commandResultMap;
4620 QMultiMap<G4int, QString> commandChildResultMap;
4621 for (
G4int a = 0; a < treeSize; ++a) {
4623 tmp = (int)GetCommandList(command).count(searchText, Qt::CaseInsensitive);
4625 commandResultMap.insert(tmp, QString((
char*)(treeTop->
GetTree(a + 1)->
GetPathName()).data()));
4628 commandChildResultMap = LookForHelpStringInChildTree(treeTop->
GetTree(a + 1), searchText);
4630 if (! commandChildResultMap.empty()) {
4631 auto i = commandChildResultMap.constBegin();
4632 while (i != commandChildResultMap.constEnd()) {
4633 commandResultMap.insert(i.key(), i.value());
4636 commandChildResultMap.clear();
4642 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
4643 fHelpTreeWidget->setColumnCount(2);
4645 labels << QString(
"Command") << QString(
"Match");
4646 fHelpTreeWidget->setHeaderLabels(labels);
4648 if (commandResultMap.empty()) {
4649 fParameterHelpLabel->setText(
"No match found");
4650 fParameterHelpTable->setVisible(
false);
4654 auto i = commandResultMap.constEnd();
4658 QString progressChar =
"|";
4659 QString progressStr =
"|";
4661 QTreeWidgetItem* newItem;
4664 if (i == commandResultMap.constBegin()) {
4667 for (
G4int a = 0; a <
G4int(i.key() * multValue); ++a) {
4668 progressStr += progressChar;
4670 newItem =
new QTreeWidgetItem();
4671 QString commandStr = i.value().trimmed();
4673 if (commandStr.indexOf(
"/") == 0) {
4674 commandStr = commandStr.right(commandStr.size() - 1);
4677 newItem->setText(0, commandStr);
4678 newItem->setText(1, progressStr);
4679 fHelpTreeWidget->addTopLevelItem(newItem);
4680 newItem->setForeground(1, QBrush(Qt::blue));
4684 fHelpTreeWidget->resizeColumnToContents(0);
4685 fHelpTreeWidget->sortItems(1, Qt::DescendingOrder);
4689#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
4691QMap<G4int, QString> G4UIQt::LookForHelpStringInChildTree(
4694 QMap<G4int, QString> commandResultMap;
4695 if (aCommandTree == NULL)
return commandResultMap;
4698 QMap<G4int, QString> commandChildResultMap;
4701 tmp = GetCommandList(command).count(text, Qt::CaseInsensitive);
4703 commandResultMap.insertMulti(
4707 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->
GetTree(a + 1), text);
4708 if (! commandChildResultMap.empty()) {
4710 QMap<G4int, QString>::const_iterator i = commandChildResultMap.constBegin();
4711 while (i != commandChildResultMap.constEnd()) {
4712 commandResultMap.insertMulti(i.key(), i.value());
4715 commandChildResultMap.clear();
4721 tmp = GetCommandList(command).count(text, Qt::CaseInsensitive);
4723 commandResultMap.insertMulti(
4727 return commandResultMap;
4731QMultiMap<G4int, QString> G4UIQt::LookForHelpStringInChildTree(
4734 QMultiMap<G4int, QString> commandResultMap;
4735 if (aCommandTree ==
nullptr)
return commandResultMap;
4738 QMultiMap<G4int, QString> commandChildResultMap;
4741 tmp = (int)GetCommandList(command).count(text, Qt::CaseInsensitive);
4743 commandResultMap.insert(
4747 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->
GetTree(a + 1), text);
4748 if (! commandChildResultMap.empty()) {
4750 auto i = commandChildResultMap.constBegin();
4751 while (i != commandChildResultMap.constEnd()) {
4752 commandResultMap.insert(i.key(), i.value());
4755 commandChildResultMap.clear();
4761 tmp = (int)GetCommandList(command).count(text, Qt::CaseInsensitive);
4763 commandResultMap.insert(
4767 return commandResultMap;
4771QString G4UIQt::GetShortCommandPath(QString commandPath)
4773 if (commandPath.indexOf(
"/") == 0) {
4774 commandPath = commandPath.right(commandPath.size() - 1);
4777 commandPath = commandPath.right(commandPath.size() - commandPath.lastIndexOf(
"/", -2) - 1);
4779 if (commandPath.lastIndexOf(
"/") == (commandPath.size() - 1)) {
4780 commandPath = commandPath.left(commandPath.size() - 1);
4786QString G4UIQt::GetLongCommandPath(QTreeWidgetItem* item)
4788 if (item ==
nullptr)
return "";
4791 QString itemText =
"";
4792 itemText = item->text(0);
4794 while (item->parent() !=
nullptr) {
4795 itemText = item->parent()->text(0) +
"/" + itemText;
4796 item = item->parent();
4798 itemText =
"/" + itemText;
4803void G4UIQt::ChangeColorCallback(QWidget* widget)
4805 if (widget ==
nullptr) {
4809 auto button =
dynamic_cast<QPushButton*
>(widget);
4810 if (button ==
nullptr) {
4813 QString value = button->accessibleName();
4816 old.setRgbF(value.section(
" ", 0, 1).toDouble(), value.section(
" ", 1, 2).toDouble(),
4817 value.section(
" ", 2, 3).toDouble());
4819 QColorDialog::getColor(old, fUITabWidget,
"Change color", QColorDialog::ShowAlphaChannel);
4821 if (color.isValid()) {
4823 QPixmap pixmap = QPixmap(QSize(16, 16));
4825 QPainter painter(&pixmap);
4826 painter.setPen(Qt::black);
4827 painter.drawRect(0, 0, 15, 15);
4829 button->setAccessibleName(QString::number(color.redF()) +
" " +
4830 QString::number(color.greenF()) +
" " +
4831 QString::number(color.blueF()) +
" ");
4832 button->setIcon(pixmap);
4836void G4UIQt::ChangeCursorAction(
const QString& action)
4840 fMoveSelected =
true;
4841 fPickSelected =
true;
4842 fRotateSelected =
true;
4843 fZoomInSelected =
true;
4844 fZoomOutSelected =
true;
4846 if (fToolbarApp ==
nullptr)
return;
4847 QList<QAction*> list = fToolbarApp->actions();
4848 for (
auto i : list) {
4849 if (i->data().toString() == action) {
4850 i->setChecked(
true);
4851 if (i->data().toString() ==
"pick") {
4853 CreatePickInfosDialog();
4855 fPickInfosDialog->show();
4856 fPickInfosDialog->raise();
4857 fPickInfosDialog->activateWindow();
4860 else if (i->data().toString() ==
"move") {
4861 fMoveSelected =
false;
4862 i->setChecked(
false);
4864 else if (i->data().toString() ==
"pick") {
4865 fPickSelected =
false;
4866 i->setChecked(
false);
4868 if (fPickInfosDialog !=
nullptr) {
4869 fPickInfosDialog->hide();
4872 else if (i->data().toString() ==
"rotate") {
4873 fRotateSelected =
false;
4874 i->setChecked(
false);
4876 else if (i->data().toString() ==
"zoom_in") {
4877 fZoomInSelected =
false;
4878 i->setChecked(
false);
4880 else if (i->data().toString() ==
"zoom_out") {
4881 fZoomOutSelected =
false;
4882 i->setChecked(
false);
4894void G4UIQt::ChangeSurfaceStyle(
const QString& action)
4898 if (fToolbarApp ==
nullptr)
return;
4899 QList<QAction*> list = fToolbarApp->actions();
4900 for (
auto i : list) {
4901 if (i->data().toString() == action) {
4902 i->setChecked(
true);
4904 else if (i->data().toString() ==
"hidden_line_removal") {
4905 i->setChecked(
false);
4907 else if (i->data().toString() ==
"hidden_line_and_surface_removal") {
4908 i->setChecked(
false);
4910 else if (i->data().toString() ==
"solid") {
4911 i->setChecked(
false);
4913 else if (i->data().toString() ==
"wireframe") {
4914 i->setChecked(
false);
4919 if (action ==
"hidden_line_removal") {
4923 else if (action ==
"hidden_line_and_surface_removal") {
4927 else if (action ==
"solid") {
4931 else if (action ==
"wireframe") {
4937void G4UIQt::OpenIconCallback(
const QString& aParam)
4939 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4940 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator) + fStringSeparator.length());
4942 QString nomFich = QFileDialog::getOpenFileName(fMainWindow, aLabel, fLastOpenPath,
4943 "Macro files (*.mac);;Geant4 files( *.mac *.g4* *.in);;All (*.*)");
4944 if (nomFich !=
"") {
4946 (QString(aCommand) + QString(
" ") + nomFich).toStdString().c_str());
4948 fLastOpenPath = dir.absoluteFilePath(nomFich);
4952void G4UIQt::SaveIconCallback(
const QString& aParam)
4954 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4955 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator) + fStringSeparator.length());
4958 QFileDialog::getSaveFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
4959 if (nomFich !=
"") {
4961 (QString(aCommand) + QString(
" ") + nomFich).toStdString().c_str());
4963 fLastOpenPath = dir.absoluteFilePath(nomFich);
4967void G4UIQt::CreateViewerPropertiesDialog()
4969 if (fViewerPropertiesDialog !=
nullptr) {
4972 fViewerPropertiesDialog =
new QDialog();
4974 fViewerPropertiesDialog->setWindowTitle(
"Viewer properties");
4975 fViewerPropertiesDialog->setSizePolicy(
4976 QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
4978 if (fViewerPropertiesWidget ==
nullptr) {
4979 fViewerPropertiesWidget =
new QWidget();
4980 auto layoutPropertiesWidget =
new QVBoxLayout();
4981 fViewerPropertiesWidget->setLayout(layoutPropertiesWidget);
4983 CreateEmptyViewerPropertiesWidget();
4986 auto layoutDialog =
new QVBoxLayout();
4988 layoutDialog->addWidget(fViewerPropertiesWidget);
4989 layoutDialog->setContentsMargins(0, 0, 0, 0);
4990 fViewerPropertiesDialog->setLayout(layoutDialog);
4993void G4UIQt::CreatePickInfosDialog()
4995 if (fPickInfosDialog !=
nullptr) {
4998 fPickInfosDialog =
new QDialog();
5000 fPickInfosDialog->setWindowTitle(
"Pick infos");
5001 fPickInfosDialog->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
5003 if (fPickInfosWidget ==
nullptr) {
5004 fPickInfosWidget =
new QWidget();
5005 auto layoutPickInfos =
new QVBoxLayout();
5006 fPickInfosWidget->setLayout(layoutPickInfos);
5008 CreateEmptyPickInfosWidget();
5011 auto layoutDialog =
new QVBoxLayout();
5013 layoutDialog->addWidget(fPickInfosWidget);
5014 layoutDialog->setContentsMargins(0, 0, 0, 0);
5015 fPickInfosDialog->setLayout(layoutDialog);
5016 fPickInfosDialog->setWindowFlags(Qt::WindowStaysOnTopHint);
5019void G4UIQt::CreateEmptyViewerPropertiesWidget()
5021 if (fViewerPropertiesWidget ==
nullptr)
return;
5022 if (fViewerPropertiesWidget->layout() ==
nullptr)
return;
5024 if (fViewerPropertiesWidget->layout()->count() != 0) {
5025 while ((wItem = fViewerPropertiesWidget->layout()->takeAt(0)) !=
nullptr) {
5026 delete wItem->widget();
5031 auto label =
new QLabel(
"No viewer - Please open a viewer first");
5032 fViewerPropertiesWidget->layout()->addWidget(label);
5033 fViewerPropertiesDialog->setWindowTitle(
"No viewer");
5034 fViewerPropertiesDialog->setVisible(
false);
5037void G4UIQt::CreateEmptyPickInfosWidget()
5040 if (fPickInfosWidget->layout()->count() != 0) {
5041 while ((wItem = fPickInfosWidget->layout()->takeAt(0)) !=
nullptr) {
5042 delete wItem->widget();
5047 auto label =
new QLabel(
"Click on the object you want to pick");
5048 fPickInfosWidget->layout()->addWidget(label);
5049 fPickInfosDialog->setWindowTitle(
"Nothing to pick");
5052void G4UIQt::ViewerPropertiesIconCallback(
int)
5054 CreateViewerPropertiesDialog();
5056 fViewerPropertiesDialog->show();
5057 fViewerPropertiesDialog->raise();
5058 fViewerPropertiesDialog->activateWindow();
5061void G4UIQt::ChangePerspectiveOrtho(
const QString& action)
5065 if (fToolbarApp ==
nullptr)
return;
5066 QList<QAction*> list = fToolbarApp->actions();
5067 QString checked =
"";
5068 for (
auto i : list) {
5069 if (i->data().toString() == action) {
5070 i->setChecked(
true);
5071 checked = i->data().toString();
5073 else if (i->data().toString() ==
"perspective") {
5074 i->setChecked(
false);
5076 else if (i->data().toString() ==
"ortho") {
5077 i->setChecked(
false);
5081 if ((action ==
"ortho") && (checked ==
"ortho")) {
5084 else if ((action ==
"perspective") && (checked ==
"perspective")) {
5092 fMoveSelected =
true;
5093 fRotateSelected =
false;
5094 fPickSelected =
false;
5095 fZoomInSelected =
false;
5096 fZoomOutSelected =
false;
5098 if (fToolbarApp ==
nullptr)
return;
5099 QList<QAction*> list = fToolbarApp->actions();
5100 for (
auto i : list) {
5101 if (i->data().toString() ==
"move") {
5102 i->setChecked(
true);
5104 else if (i->data().toString() ==
"rotate") {
5105 i->setChecked(
false);
5107 else if (i->data().toString() ==
"pick") {
5108 i->setChecked(
false);
5110 else if (i->data().toString() ==
"zoom_in") {
5111 i->setChecked(
false);
5113 else if (i->data().toString() ==
"zoom_out") {
5114 i->setChecked(
false);
5122 fRotateSelected =
true;
5123 fMoveSelected =
false;
5124 fPickSelected =
false;
5125 fZoomInSelected =
false;
5126 fZoomOutSelected =
false;
5128 if (fToolbarApp ==
nullptr)
return;
5129 QList<QAction*> list = fToolbarApp->actions();
5130 for (
auto i : list) {
5131 if (i->data().toString() ==
"rotate") {
5132 i->setChecked(
true);
5134 else if (i->data().toString() ==
"move") {
5135 i->setChecked(
false);
5137 else if (i->data().toString() ==
"pick") {
5138 i->setChecked(
false);
5140 else if (i->data().toString() ==
"zoom_in") {
5141 i->setChecked(
false);
5143 else if (i->data().toString() ==
"zoom_out") {
5144 i->setChecked(
false);
5152 fPickSelected =
true;
5153 fMoveSelected =
false;
5154 fRotateSelected =
false;
5155 fZoomInSelected =
false;
5156 fZoomOutSelected =
false;
5158 QToolBar* bar = fToolbarApp;
5159 if (! fDefaultIcons) {
5162 if (bar ==
nullptr)
return;
5164 QList<QAction*> list = bar->actions();
5165 for (
auto i : list) {
5166 if (i->data().toString() ==
"pick") {
5167 i->setChecked(
true);
5169 else if (i->data().toString() ==
"move") {
5170 i->setChecked(
false);
5172 else if (i->data().toString() ==
"rotate") {
5173 i->setChecked(
false);
5175 else if (i->data().toString() ==
"zoom_in") {
5176 i->setChecked(
false);
5178 else if (i->data().toString() ==
"zoom_out") {
5179 i->setChecked(
false);
5187 fZoomInSelected =
true;
5188 fMoveSelected =
false;
5189 fRotateSelected =
false;
5190 fPickSelected =
false;
5191 fZoomOutSelected =
false;
5193 QToolBar* bar = fToolbarApp;
5194 if (! fDefaultIcons) {
5197 if (bar ==
nullptr)
return;
5199 QList<QAction*> list = bar->actions();
5200 for (
auto i : list) {
5201 if (i->data().toString() ==
"zoom_in") {
5202 i->setChecked(
true);
5204 else if (i->data().toString() ==
"move") {
5205 i->setChecked(
false);
5207 else if (i->data().toString() ==
"rotate") {
5208 i->setChecked(
false);
5210 else if (i->data().toString() ==
"pick") {
5211 i->setChecked(
false);
5213 else if (i->data().toString() ==
"zoom_out") {
5214 i->setChecked(
false);
5222 fZoomOutSelected =
true;
5223 fMoveSelected =
false;
5224 fRotateSelected =
false;
5225 fPickSelected =
false;
5226 fZoomInSelected =
false;
5228 QToolBar* bar = fToolbarApp;
5229 if (! fDefaultIcons) {
5232 if (bar ==
nullptr)
return;
5234 QList<QAction*> list = bar->actions();
5235 for (
auto i : list) {
5236 if (i->data().toString() ==
"zoom_out") {
5237 i->setChecked(
true);
5239 else if (i->data().toString() ==
"move") {
5240 i->setChecked(
false);
5242 else if (i->data().toString() ==
"rotate") {
5243 i->setChecked(
false);
5245 else if (i->data().toString() ==
"pick") {
5246 i->setChecked(
false);
5248 else if (i->data().toString() ==
"zoom_in") {
5249 i->setChecked(
false);
5258 QToolBar* bar = fToolbarApp;
5259 if (! fDefaultIcons) {
5262 if (bar ==
nullptr)
return;
5264 QList<QAction*> list = bar->actions();
5265 for (
auto i : list) {
5266 if (i->data().toString() ==
"solid") {
5267 i->setChecked(
true);
5269 else if (i->data().toString() ==
"hidden_line_removal") {
5270 i->setChecked(
false);
5272 else if (i->data().toString() ==
"hidden_line_and_surface_removal") {
5273 i->setChecked(
false);
5275 else if (i->data().toString() ==
"wireframe") {
5276 i->setChecked(
false);
5285 QToolBar* bar = fToolbarApp;
5286 if (! fDefaultIcons) {
5289 if (bar ==
nullptr)
return;
5291 QList<QAction*> list = bar->actions();
5292 for (
auto i : list) {
5293 if (i->data().toString() ==
"wireframe") {
5294 i->setChecked(
true);
5296 else if (i->data().toString() ==
"hidden_line_removal") {
5297 i->setChecked(
false);
5299 else if (i->data().toString() ==
"hidden_line_and_surface_removal") {
5300 i->setChecked(
false);
5302 else if (i->data().toString() ==
"solid") {
5303 i->setChecked(
false);
5312 QToolBar* bar = fToolbarApp;
5313 if (! fDefaultIcons) {
5316 if (bar ==
nullptr)
return;
5318 QList<QAction*> list = bar->actions();
5319 for (
auto i : list) {
5320 if (i->data().toString() ==
"hidden_line_removal") {
5321 i->setChecked(
true);
5323 else if (i->data().toString() ==
"solid") {
5324 i->setChecked(
false);
5326 else if (i->data().toString() ==
"hidden_line_and_surface_removal") {
5327 i->setChecked(
false);
5329 else if (i->data().toString() ==
"wireframe") {
5330 i->setChecked(
false);
5339 QToolBar* bar = fToolbarApp;
5340 if (! fDefaultIcons) {
5344 if (bar ==
nullptr)
return;
5346 QList<QAction*> list = bar->actions();
5347 for (
auto i : list) {
5348 if (i->data().toString() ==
"hidden_line_and_surface_removal") {
5349 i->setChecked(
true);
5351 else if (i->data().toString() ==
"solid") {
5352 i->setChecked(
false);
5354 else if (i->data().toString() ==
"hidden_line_removal") {
5355 i->setChecked(
false);
5357 else if (i->data().toString() ==
"wireframe") {
5358 i->setChecked(
false);
5367 QToolBar* bar = fToolbarApp;
5368 if (! fDefaultIcons) {
5371 if (bar ==
nullptr)
return;
5373 QList<QAction*> list = bar->actions();
5374 for (
auto i : list) {
5375 if (i->data().toString() ==
"perspective") {
5376 i->setChecked(
true);
5378 else if (i->data().toString() ==
"ortho") {
5379 i->setChecked(
false);
5388 QToolBar* bar = fToolbarApp;
5389 if (! fDefaultIcons) {
5393 if (bar ==
nullptr)
return;
5395 QList<QAction*> list = bar->actions();
5396 for (
auto i : list) {
5397 if (i->data().toString() ==
"ortho") {
5398 i->setChecked(
true);
5400 else if (i->data().toString() ==
"perspective") {
5401 i->setChecked(
false);
5407 : QTabWidget(aParent),
5408 fTabSelected(false),
5410 fPreferedSizeX(sizeX + 6)
5412 fPreferedSizeY(sizeY + 58)
5414 setMinimumSize(100, 100);
5415 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
5416 setSizePolicy(policy);
5420 : QTabWidget(), fTabSelected(false), fLastCreated(-1), fPreferedSizeX(0), fPreferedSizeY(0)
5424 : fText(text), fThread(origine)
5426 if (!
GetOutputList().contains(QString(
" ") + outputStream +
" ")) {
5435void G4UIQt::TabCloseCallback(
int a)
5437 if (fViewerTabWidget ==
nullptr)
return;
5440 QWidget* temp = fViewerTabWidget->widget(a);
5442 fViewerTabWidget->removeTab(a);
5446 for (
G4int c = 0; c < fViewerTabWidget->count(); ++c) {
5447 if (fViewerTabWidget->tabText(c).contains(
"viewer")) {
5453 CreateEmptyViewerPropertiesWidget();
5459void G4UIQt::ToolBoxActivated(
int a)
5461 if (fUITabWidget->widget(a) == fHelpTBWidget) {
5465 else if (fUITabWidget->widget(a) == fSceneTreeWidget) {
5466 fSceneTreeWidget->setVisible(
true);
5472 if (currentWidget() !=
nullptr) {
5476 QString text = tabText(currentIndex());
5479 auto edit =
dynamic_cast<QTextEdit*
>(currentWidget());
5480 if (edit ==
nullptr) {
5481 QString paramSelect = QString(
"/vis/viewer/select ") + text;
5483 if (UI !=
nullptr) {
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
G4double GetAlpha() const
G4double GetGreen() const
G4String GetFullPrefixString() const
G4String GetPrefixString() const
static G4Qt * getInstance()
void FlushAndWaitExecution() override
const G4String & GetDescription() const
const std::list< G4SceneTreeItem > & GetChildren() const
const G4String & GetPVPath() const
const std::map< G4String, G4AttDef > * GetAttDefs() const
std::vector< G4AttValue > * GetAttValues() const
static G4StateManager * GetStateManager()
G4UIOutputString(QString text, G4String thread="", G4String outputstream="info")
void SetIconPickSelected()
G4bool AddTabWidget(QWidget *, QString)
QWidget * GetViewerPropertiesWidget()
void SetIconOrthoSelected()
void UpdateSceneTree(const G4SceneTreeItem &) override
G4UIsession * SessionStart() override
void SetStartPage(const std::string &)
G4bool AddViewerTabFromFile(std::string fileName, std::string title)
G4int ReceiveG4cout(const G4String &) override
void SetIconZoomInSelected()
void PauseSessionStart(const G4String &) override
void AddMenu(const char *, const char *) override
QWidget * GetSceneTreeWidget()
G4int ReceiveG4cerr(const G4String &) override
void AddButton(const char *, const char *, const char *) override
void SetOutputStyle(const char *destination, const char *style) override
void SetIconZoomOutSelected()
void SetIconHLRSelected()
void ClearMenu() override
void SetIconPerspectiveSelected()
void NativeMenu(G4bool aVal) override
QWidget * GetPickInfosWidget()
void DefaultIcons(G4bool aVal) override
void SetIconSolidSelected()
G4int ReceiveG4debug(const G4String &) override
void SetIconRotateSelected()
void SetIconWireframeSelected()
void SetIconMoveSelected()
G4bool AddViewerTab(QWidget *w, std::string title)
void AddIcon(const char *userLabel, const char *iconFile, const char *command, const char *file_name="") override
void SetIconHLHSRSelected()
G4int GetCommandEntry() const
const G4UIcommand * GetGuidance() const
G4UIcommand * GetCommand(G4int i)
const G4String & GetPathName() const
G4int GetTreeEntry() const
G4UIcommandTree * GetTree(G4int i)
G4UIcommandTree * FindCommandTree(const char *commandPath)
const G4String GetTitle() const
G4String GetFirstMatchedString(const G4String &, const G4String &) const
G4UIcommand * FindPath(const char *commandPath) const
std::size_t GetParameterEntries() const
const G4String & GetGuidanceLine(G4int i) const
G4UIparameter * GetParameter(G4int i) const
static G4String ConvertToString(G4bool boolVal)
const G4String & GetCommandPath() const
std::size_t GetGuidanceEntries() const
const G4String & GetCommandName() const
const G4String & GetRange() const
void SetCoutDestination(G4UIsession *const value)
G4UIcommandTree * GetTree() const
G4int ApplyCommand(const char *aCommand)
bool IsLastCommandOutputTreated()
G4int GetVerboseLevel() const
G4String FindMacroPath(const G4String &fname) const
static G4UImanager * GetUIpointer()
G4MTcoutDestination * GetThreadCout()
void SetSession(G4UIsession *const value)
void SetG4UIWindow(G4UIsession *const value)
void SetLastCommandOutputTreated()
const G4String & GetParameterCandidates() const
const G4String & GetParameterGuidance() const
G4bool IsOmittable() const
const G4String & GetParameterRange() const
G4bool GetCurrentAsDefault() const
char GetParameterType() const
const G4String & GetParameterName() const
const G4String & GetDefaultValue() const
G4String ModifyToFullPathCommand(const char *aCommandLine) const
G4String Complete(const G4String &)
void TerminalHelp(const G4String &)
void ApplyShellCommand(const G4String &, G4bool &, G4bool &)
void SetStyleUtility(const G4String &destination, const G4String &style)
std::map< G4String, OutputStyle > fOutputStyles
void AddInteractor(G4String, G4Interactor)
G4Interactor GetInteractor(G4String)
void EnableSecondaryLoop()
G4Interactor GetMainInteractor()
void DisableSecondaryLoop()
static G4MTGLOB_DLL G4coutDestination * masterG4coutDestination
const char * name(G4int ptype)