31 #ifdef G4UI_BUILD_QT_SESSION
46 #include <qapplication.h>
47 #include <qmessagebox.h>
48 #include <qlineedit.h>
52 #include <qpushbutton.h>
54 #include <qsplitter.h>
55 #include <qscrollbar.h>
58 #include <qtextedit.h>
59 #include <qsignalmapper.h>
60 #include <qtabwidget.h>
62 #include <qstringlist.h>
63 #include <qtextstream.h>
65 #include <qmainwindow.h>
67 #include <qlistwidget.h>
68 #include <qtreewidget.h>
69 #include <qheaderview.h>
70 #include <qgroupbox.h>
71 #include <qscrollarea.h>
73 #include <qradiobutton.h>
74 #include <qbuttongroup.h>
75 #include <qcombobox.h>
76 #include <qsignalmapper.h>
78 #include <qcolordialog.h>
80 #include <qfiledialog.h>
81 #include <qdesktopwidget.h>
82 #include <qtablewidget.h>
83 #include <qcompleter.h>
84 #include <qstandarditemmodel.h>
85 #include <qboxlayout.h>
89 static G4bool exitSession =
true;
90 static G4bool exitPause =
true;
119 ,fCoutTBTextArea(NULL)
124 ,fHistoryTBTableList(NULL)
125 ,fHelpTreeWidget(NULL)
127 ,fHistoryTBWidget(NULL)
128 ,fCoutDockWidget(NULL)
130 ,fSceneTreeWidget(NULL)
131 ,fViewerPropertiesWidget(NULL)
132 ,fPickInfosWidget(NULL)
134 ,fViewerTabWidget(NULL)
137 ,fHelpVSplitter(NULL)
138 ,fParameterHelpLabel(NULL)
139 ,fParameterHelpTable(NULL)
142 ,fStringSeparator(
"__$$$@%%###__")
153 ,fWireframeIcon(NULL)
155 ,fHiddenLineRemovalIcon(NULL)
156 ,fHiddenLineAndSurfaceRemovalIcon(NULL)
157 ,fPerspectiveIcon(NULL)
163 ,fPickTargetIcon(NULL)
164 #ifdef G4MULTITHREADED
165 ,fThreadsFilterComboBox(NULL)
167 ,fDefaultViewerFirstPageHTMLText(
"")
168 ,fViewerPropertiesDialog(NULL)
169 ,fPickInfosDialog(NULL)
170 ,fMoveSelected(false)
171 ,fRotateSelected(true)
172 ,fPickSelected(false)
173 ,fZoomInSelected(false)
174 ,fZoomOutSelected(false)
177 G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(
char*)
"Qt");
178 if (!(QApplication*)interactorManager->GetMainInteractor()) {
183 G4cout <<
"G4UIQt : Unable to init Qt. Aborted" <<
G4endl;
193 Q_FOREACH (QWidget *widget, QApplication::allWidgets()) {
194 if ((found==
false) && (widget->inherits(
"QMainWindow"))) {
204 G4cout <<
"G4UIQt : Found an external App with a QMainWindow already defined. Aborted" <<
G4endl;
210 fMainWindow =
new QMainWindow();
212 fMainWindow->setCorner( Qt::TopLeftCorner, Qt::LeftDockWidgetArea );
213 fMainWindow->setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
214 fMainWindow->setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
215 fMainWindow->setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
217 CreateViewerWidget();
218 fMainWindow->addDockWidget(Qt::LeftDockWidgetArea, CreateUITabWidget());
219 fMainWindow->addDockWidget(Qt::BottomDockWidgetArea, CreateCoutTBWidget());
223 SetDefaultIconsToolbar();
227 #ifdef G4MULTITHREADED
229 masterG4coutDestination =
this;
232 fMainWindow->setWindowTitle(QFileInfo( QCoreApplication::applicationFilePath() ).fileName());
233 fMainWindow->move(QPoint(50,50));
238 fMainWindow->resize(fUIDockWidget->width()+fCoutDockWidget->width()+20,
239 fUIDockWidget->height()+fCoutDockWidget->height()+20);
242 fCommandArea->setFocus(Qt::TabFocusReason);
246 qRegisterMetaType<QTextCursor>(
"QTextCursor");
249 AddTabWidget(fStartPage,
"Useful tips");
252 #if QT_VERSION < 0x040200
255 fMainWindow->setVisible(
false);
269 #ifdef G4MULTITHREADED
270 masterG4coutDestination = 0;
274 if (fMainWindow!=NULL) {
280 void G4UIQt::DefaultIcons(
bool aVal)
282 fDefaultIcons = aVal;
284 #if QT_VERSION < 0x040200
285 if (!fMainWindow->isHidden()) {
287 if (!fMainWindow->isVisible()) {
294 #if QT_VERSION < 0x040200
297 fToolbarApp->setVisible(
true);
301 #if QT_VERSION < 0x040200
304 fToolbarApp->setVisible(
false);
311 void G4UIQt::SetDefaultIconsToolbar(
315 if (fToolbarApp == NULL) {
316 fToolbarApp =
new QToolBar();
317 fToolbarApp->setIconSize (QSize(20,20));
318 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
322 AddIcon(
"Open macro file",
"open",
"/control/execute");
323 AddIcon(
"Save viewer state",
"save",
"/vis/viewer/save");
326 QSignalMapper *signalMapperViewerProperties =
new QSignalMapper(
this);
327 QAction *actionViewerProperties = fToolbarApp->addAction(QIcon(*fParamIcon),
"Viewer properties", signalMapperViewerProperties, SLOT(map()));
328 connect(signalMapperViewerProperties, SIGNAL(mapped(
int)),
this, SLOT(ViewerPropertiesIconCallback(
int)));
330 signalMapperViewerProperties->setMapping(actionViewerProperties, intVP);
333 AddIcon(
"Move",
"move",
"");
334 AddIcon(
"Pick",
"pick",
"");
335 AddIcon(
"Zoom out",
"zoom_out",
"");
336 AddIcon(
"Zoom in",
"zoom_in",
"");
337 AddIcon(
"Rotate",
"rotate",
"");
340 AddIcon(
"Hidden line removal",
"hidden_line_removal",
"");
341 AddIcon(
"Hidden line and hidden surface removal",
"hidden_line_and_surface_removal",
"");
342 AddIcon(
"Surfaces",
"solid",
"");
343 AddIcon(
"Wireframe",
"wireframe",
"");
346 AddIcon(
"Perspective",
"perspective",
"");
347 AddIcon(
"Orthographic",
"ortho",
"");
348 AddIcon(
"Run beam on",
"runBeamOn",
"/run/beamOn 1");
353 void G4UIQt::CreateIcons(
356 const char *
const save[]={
384 " +++++++++++++++++++++++++ ",
385 " +@##+$%%%%%%%%%%%%%%%&*$%&+ ",
386 " +=-;@>,,''',,,,,,,',,)&!,)+ ",
387 " +;-~@>,,,,,,,,,,,,,,,>$!,)+ ",
388 " +=-~@>,,,,,{]]]]]^,,,>*&$&+ ",
389 " +=-~@>,,,,,'{^{^^{,,,>*#=#+ ",
390 " +=-~@>,,,,,,,,,,,,,,,>@~/=+ ",
391 " +=-~@>,,,{{{''''{',,,>@~-=+ ",
392 " +=-~@>,,'^]]]]]]({,,,>@~-=+ ",
393 " +=-~@>,,,{{{{{{{{{,,,>@~-=+ ",
394 " +=-~@>,,,,,'{^{{^{,,,>@~-=+ ",
395 " +=-~@>,,,,,]]]]]]],,,>@~-=+ ",
396 " +=-~*>,,,,,,,,,,,,,,,>@~-=+ ",
397 " +=-~@>,,,,,,,,,,,,,,,>@~-=+ ",
398 " +=-/=$%%%%%%%%%%%%%%%$=/-=+ ",
399 " +=---;###############;---=+ ",
400 " +=---////////////////----=+ ",
401 " +=----------------///----=+ ",
402 " +=---=@##############@#--=+ ",
403 " +=---@+++++++++++*%))_+~-=+ ",
404 " +=---#+++++++++++&:,,>@~-=+ ",
405 " +=---#+++++++++++$',,>@~-=+ ",
406 " +=---#+++++++++++&!,,>@~-=+ ",
407 " +=/--#+++++++++++&',,>@~-=+ ",
408 " @;--#+++++++++++$',,>@~-=+ ",
409 " @;;@+++++++++++*)!>%@=;#+ ",
410 " @++++++++++++++*&**++@++ ",
415 fSaveIcon =
new QPixmap(save);
417 const char *
const search[] = {
429 "OOOOOOOOOOOOOOOOOOO",
430 "OOOOOOOOOOOOOOOOOOO",
431 "OOOOOOOo. .oOOOOOO",
434 "OOOOO. XOOOOX .OOOO",
437 "OOOOO. XOOOOo .OOOO",
441 "OOOOOOOOOOOOO. XOO",
442 "OOOOOOOOOOOOOO. XOO",
443 "OOOOOOOOOOOOOOOoOOO",
444 "OOOOOOOOOOOOOOOOOOO",
445 "OOOOOOOOOOOOOOOOOOO",
446 "OOOOOOOOOOOOOOOOOOO",
447 "OOOOOOOOOOOOOOOOOOO"
449 fSearchIcon =
new QPixmap(search);
451 const char *
const clear[] = {
463 "OOOOOOOOOOOOOOOOOOOO",
466 "OOOOOOOOOOOOOOOOOOOO",
467 "OOOOOOOOOOOOOOOOOOOO",
468 "OOOO XXXXXXXXXX OOOO",
469 "OOO XOOOOOOOOOO OOO",
470 "OOOOXOooOooOooO OOOO",
471 "OOOOXOooOooOooO OOOO",
472 "OOOOXOooOooOooO OOOO",
473 "OOOOXOooOooOooO OOOO",
474 "OOOOXOooOooOooO OOOO",
475 "OOOOXOooOooOooO OOOO",
476 "OOOOXOooOooOooO OOOO",
477 "OOOOXOooOooOooO OOOO",
478 "OOOOXOooOooOooO OOOO",
479 "OOOOXOooOooOooO OOOO",
480 "OOOOXOOOOOOOOOO OOOO",
481 "OOOOOooooooooooOOOOO",
482 "OOOOOO........OOOOOO"
485 fClearIcon =
new QPixmap(clear);
488 const char *
const open[]={
532 " {]^/((_({- %%%%%%%%%%% ",
533 " {(^_^^^^:<{{{{{{{{{{{{{[& ",
534 " {/_/(((((/]]]]]]]]]]]/]!# ",
535 " {/^(((((_^^^^^^^^^^^^^^:# ",
536 " {/^(((_^^____________^^}$ ",
537 " {/^(((((/////////////((!# ",
538 " {/^/^_:<|||||||||||||||@@****1 ",
539 " {/^/^(<[)||||||||||||||))!!}<; ",
540 " {/^_(:|234444444444444444432)1 ",
541 " {/_^/<)34444444444444444443}, ",
542 " {/^(2{:41111111111111111142|5 ",
543 " {3^3<:31111111111111111143}- ",
544 " {/^2<:31111111111111111441|' ",
545 " {_/<:41111111111111111143}, ",
546 " {(4<:31111111111111111144!# ",
547 " )4))44111111111111111144}, ",
548 " )2<:31111111111111111144{# ",
549 " @|:14444444444444444444}* ",
550 " ;@434444444444444444434<# ",
551 " ;[))))))))))))))))))))!~ ",
552 " ++++++++++++++++++++++;% ",
556 fOpenIcon =
new QPixmap(open);
559 const char *
const move[]={
592 " ')&$$$$*@@ @@*$$$$&)' ",
593 " ')&$$$$*@@ @@*$$$$&+' ",
610 fMoveIcon =
new QPixmap(move);
612 const char *
const rotate[]={
648 " --------!*{{{*&, ",
649 " -------=){*{{{>>{) ",
650 " ,!-----= ){& ,&{{@",
658 " !-!!======!!(((---! ",
659 " ='--------------! ",
674 fRotateIcon =
new QPixmap(rotate);
676 const char *
const pick[]={
692 "*********oo*********",
693 "*********oo*********",
694 "******$O. .O%******",
695 "****&o .O..O O*****",
696 "***&X @**oo**@ X****",
697 "***o $***oo***$ O***",
698 "**% @**********@ %**",
699 "**O.***********& +**",
700 "**.O*****@@*****o.**",
701 "oo .oo**@ #*&XX. oo",
702 "oo .oo**@ #*&oo. oO",
703 "**.O*****##*****oX**",
704 "**O ***********& +**",
705 "**% @****&&****+ &**",
706 "***O $***Xo***# +***",
707 "****X @&*Xo*&+ o****",
708 "*****O o..o +*****",
709 "******%+. X+&******",
710 "*********oo*********",
711 "*********oO*********"
713 fPickIcon =
new QPixmap(pick);
715 const char *
const zoom_in[]={
737 " ++.%%%+&&&*%%.++ ",
738 " .+#%%%%+&&&*%%.#+ ",
739 " ++..%%%+&&&*%%%.++ ",
740 " +#.+++++&&&*++++.+ ",
741 " @.+&&&&&&&&&&&&&+@ ",
742 " @#+&&&&&&&&&&&&&+@ ",
743 " @.+&&&&&&&&&&&&&+. ",
744 " +++@***+&&&****@+. ",
745 " ....++++&&&*++++.. ",
746 " ++.===+&&&*%=.++ ",
747 " @..==+&&&*=..@#& ",
748 " .@+#.+&&&@-+@@*@ ",
761 fZoomInIcon =
new QPixmap(zoom_in);
763 const char *
const zoom_out[]={
785 " ++.$$$$$$$$$$.++ ",
786 " .+#$$$$$$$$$$$.#+ ",
787 " ++..$$$$$$$$$$$.++ ",
788 " +#.+++++++++++++.+ ",
789 " @.+&&&&&&&&&&&&&+@ ",
790 " @#+&&&&&&&&&&&&&+@ ",
791 " @.+&&&&&&&&&&&&&+. ",
792 " +++@***********@+. ",
793 " ....++++++++++++.. ",
794 " ++.===$$$$$$=.++ ",
795 " @..===$$$$=..@#& ",
796 " .@+#.$$$..-+@@*@ ",
809 fZoomOutIcon =
new QPixmap(zoom_out);
811 const char *
const wireframe[]={
840 " +&********&@-***; ",
841 " +@@@&**&@@@@@@$ @*-&>&+ ",
842 " +*****&+ %*@ ,**'# ",
843 " @***)!~ @*{&*****+ ",
844 " @*!]***&+ +-*^**'~!*@ ",
845 " @*~ +@&**&@@@@@@&****&+ ~*@ ",
846 " @*@ +&********&-*= @*@ ",
847 " @*@ $%@-*-@$ @*@ @*@ ",
855 " @*@ =*-+ @*@ @*@ ",
856 " @*@ $%@@&****&@-*-+ @*@ ",
857 " @*@ $@&*****&@@&******&~~!*@ ",
858 " @*{/***&@@%$ $@-*-&*****+ ",
859 " @*)*)(-~ @*@ ~)**] ",
860 " +*******&@@@@+ %*_+]**] ",
861 " +@@@@@&******&@%+_*^**]# ",
870 fWireframeIcon =
new QPixmap(wireframe);
872 const char *
const solid[]={
910 " +-;>>>>>>>>>,')!~ ",
911 " {]@@-;>>>>>>>>>>>>^/(_= ",
912 " {:>>>>>>>>>>>>>>>>><//[)!= ",
913 " ]>>>>>>>>>>>>>>>>>><////[)} ",
914 " @>>>>>>>>>>>>>>>>>><//////| ",
915 " @>>>>>>>>>>>>>>>>>><//////| ",
916 " @>>>>>>>>>>>>>>>>>><//////| ",
917 " @>>>>>>>>>>>>>>>>>><//////| ",
918 " @>>>>>>>>>>>>>>>>>><//////| ",
919 " @>>>>>>>>>>>>>>>>>><//////| ",
920 " @>>>>>>>>>>>>>>>>>><//////| ",
921 " @>>>>>>>>>>>>>>>>>><//////| ",
922 " @>>>>>>>>>>>>>>>>>><//////| ",
923 " @>>>>>>>>>>>>>>>>>><//////| ",
924 " @>>>>>>>>>>>>>>>>>><//////| ",
925 " @>>>>>>>>>>>>>>>>>><//////| ",
926 " @>>>>>>>>>>>>>>>>>><//////| ",
927 " @>>>>>>>>>>>>>>>>>><//////| ",
928 " @>>>>>>>>>>>>>>>>>></////[1 ",
929 " @>>>>>>>>>>>>>>>>>><////[*2 ",
930 " {:>>>>>>>>>>>>>>>>><//[)12 ",
931 " +@@@@@-;>>>>>>>>>><[)13 ",
940 fSolidIcon =
new QPixmap(solid);
942 const char *
const hidden_line_removal[]={
962 " +#$$$$$$$$#@&$$$* ",
963 " =-@@#$$#@@@@@-= @$&#;>= ",
964 " =$$$$$#+ -$@ *$$%+ ",
965 " -$&@-= -$- #$$$= ",
981 " -$&@@@-= -$- =>;, ",
982 " =$$$$$$$#@@@-= -$'+#$$, ",
983 " =-@@@@#$$$$$$#@-+'$)$$#+ ",
992 fHiddenLineRemovalIcon =
new QPixmap(hidden_line_removal);
994 const char *
const hidden_line_and_surface_removal[]={
1040 " ++@%####&*=-#+;>, ",
1041 " +++++@'=)))))))!)~+{]^++ ",
1042 " +$%&*=)!!!!!!!!!)~+/(]_+++ ",
1043 " +#-))!!!!!!!!!!!)~+/(::<[+ ",
1044 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1045 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1046 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1047 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1048 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1049 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1050 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1051 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1052 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1053 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1054 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1055 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1056 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1057 " +#)!!!!!!!!!!!!!!}+/:::|1+ ",
1058 " +$#}}~23!!!!!!!!)~+/(]45, ",
1059 " +++++++@#}}~23!!)~+678++ ",
1060 " ++++++@#~90+a++ ",
1069 fHiddenLineAndSurfaceRemovalIcon =
new QPixmap(hidden_line_and_surface_removal);
1071 const char *
const perspective[]={
1081 " ................ ",
1082 " ....+++++++++++++++. ",
1083 " ...++++..+.........+++. ",
1084 " ..++..............++..+. ",
1085 " .+++++++++++++++++.. .+. ",
1086 " .+...............+. .+. ",
1087 " .+. .+. .+. .+. ",
1088 " .+. .+. .+. .+. ",
1089 " .+. .+. .+. .+. ",
1090 " .+. .+. .+. .+. ",
1091 " .+. .+. .+. .+. ",
1092 " .+. .+. .+. .+. ",
1093 " .+. .+. .+. .+. ",
1094 " .+. .+. .+. .+. ",
1095 " .+. .+......+....+. ",
1096 " .+. ..++++++.+.++++. ",
1097 " .+. .++.......+...+.. ",
1098 " .+. .++. .+..++. ",
1099 " .+. ..+.. .+..+. ",
1102 " .+++.............++. ",
1103 " .+++++++++++++++++. ",
1104 " ................... ",
1109 fPerspectiveIcon =
new QPixmap(perspective);
1111 const char *
const ortho[]={
1119 " ................... ",
1120 " ..@@@@@@@@@@@@@@@@@. ",
1121 " ..@@@.............@@@. ",
1122 " ..@@.@. ..@..@. ",
1123 " ..@@ ..@. .@@...@. ",
1124 " ..@@..............@@.. .@. ",
1125 " .@@@@@@@@@@@@@@@@@.. .@. ",
1126 " .@...............@. .@. ",
1127 " .@. .@. .@. .@. ",
1128 " .@. .@. .@. .@. ",
1129 " .@. .@. .@. .@. ",
1130 " .@. .@. .@. .@. ",
1131 " .@. .@. .@. .@. ",
1132 " .@. .@. .@. .@. ",
1133 " .@. .@. .@. .@. ",
1134 " .@. .@. .@. .@. ",
1135 " .@. .@. .@. .@. ",
1136 " .@. .@. .@. .@. ",
1137 " .@. .@........@......@. ",
1138 " .@. .@@@@@@@@@.@.@@@@@@. ",
1139 " .@. .@@+........@....@@.. ",
1140 " .@...@. .@...@... ",
1142 " .@@@.............@@@.. ",
1143 " .@@@@@@@@@@@@@@@@@... ",
1144 " ................... ",
1149 fOrthoIcon =
new QPixmap(ortho);
1151 const char *
const commandIcon[]={
1179 "66666666666666666666",
1180 "66%++++++++++++++&56",
1181 "6$ o..o......o..o *6",
1182 "6+o...o*<441;@.o..+6",
1183 "6+..o@1553<354$..o+6",
1184 "6+..o<5<@ .*54#o.+6",
1193 "6+..O25<@ X=54#o.+6",
1194 "6+.o.@1553<354$...@6",
1195 "6+o..oo*<44<;@o..o+6",
1196 "6$ .o..o.....o..o *6",
1197 "66%+++++OOOO+++++*66",
1198 "66666666666666666666"
1200 fCommandIcon =
new QPixmap(commandIcon);
1202 const char *
const dirIcon[]={
1230 "66666666666666666666",
1231 "66$oOOOOOOOOOOOOo%66",
1234 "6o =635533666$ o6",
1235 "6o -65:+ +165X o6",
1244 "6o -65:+ @265X o6",
1245 "6o =635543665# O6",
1248 "66$OOOoo....OOOOo%66",
1249 "66666666666666666666"}
1251 fDirIcon =
new QPixmap(dirIcon);
1254 const char *
const runIcon[]={
1291 "rrrrrrrr%<<2rrrrrrrr",
1292 "rrrrr5=$$$$===rrrrrr",
1293 "rrrr<##$$$$$---&rrrr",
1294 "rrr=###$$$$-----%rrr",
1295 "rr=####$$$$------&rr",
1296 "r2@####7##$-------rr",
1297 "r.@####048$-------Or",
1298 "r.@####q4ee=----$@.r",
1299 " .@@###w4eee5%$#@@@X",
1300 " .@@@..w4eeeeqo..@@X",
1301 " .@..ooe<eeee7Oooo@X",
1302 " ..oooOe2eee6OOOooo ",
1303 "rOooOO+e2ew2+++++O+r",
1304 "r:oO+++e30,;;;;;++Or",
1305 "r :++;:9,>,,>>:;;1rr",
1306 "rr*1;:>,333333,>32rr",
1307 "rrr66,1367777637<rrr",
1308 "rrrr509799999905rrrr",
1309 "rrrrr=8wqwwww8-rrrrr",
1310 "rrrrrrrr4444rrrrrrrr"
1312 fRunIcon =
new QPixmap(runIcon);
1314 const char *
const paramIcon[]={
1353 "wwwwwwww5 5wwwwwwww",
1354 "wwwwwwww, ,wwwwwwww",
1355 "www&;ww7+ +9ww=-www",
1361 "5<+ .wwwwwww0. +<5",
1364 "5<+ .wwwwwww0X +<5",
1370 "www*>ww7+ +7ww=:www",
1371 "wwwwwwww1 1wwwwwwww",
1372 "wwwwwwww5 5wwwwwwww"
1374 fParamIcon =
new QPixmap(paramIcon);
1381 QWidget* G4UIQt::CreateHistoryTBWidget(
1384 fHistoryTBWidget =
new QWidget();
1386 QVBoxLayout *layoutHistoryTB =
new QVBoxLayout();
1387 fHistoryTBTableList =
new QListWidget();
1388 fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
1389 connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
1391 layoutHistoryTB->addWidget(fHistoryTBTableList);
1393 fHistoryTBWidget->setLayout(layoutHistoryTB);
1394 return fHistoryTBWidget;
1400 QWidget* G4UIQt::CreateHelpTBWidget(
1403 fHelpTBWidget =
new QWidget();
1405 QWidget *helpWidget =
new QWidget();
1406 QHBoxLayout *helpLayout =
new QHBoxLayout();
1407 QVBoxLayout *vLayout =
new QVBoxLayout();
1408 fHelpVSplitter =
new QSplitter(Qt::Vertical);
1409 fHelpLine =
new QLineEdit();
1410 helpLayout->addWidget(
new QLabel(
"Search :"));
1411 helpLayout->addWidget(fHelpLine);
1412 connect( fHelpLine, SIGNAL( editingFinished () ),
this, SLOT( LookForHelpStringCallback() ) );
1417 fParameterHelpLabel =
new QTextEdit();
1418 fParameterHelpLabel->setReadOnly(
true);
1419 fParameterHelpTable =
new QTableWidget();
1423 if (fHelpTreeWidget) {
1424 fHelpVSplitter->addWidget(fHelpTreeWidget);
1426 fHelpVSplitter->addWidget(fParameterHelpLabel);
1427 fHelpVSplitter->addWidget(fParameterHelpTable);
1429 fParameterHelpLabel->setVisible(
false);
1430 fParameterHelpTable->setVisible(
false);
1431 QSizePolicy policy = QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
1432 policy.setVerticalStretch(4);
1433 if (fHelpTreeWidget) {
1434 fHelpTreeWidget->setSizePolicy(policy);
1436 policy = QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
1437 policy.setVerticalStretch(1);
1438 fParameterHelpLabel->setSizePolicy(policy);
1439 fParameterHelpTable->setSizePolicy(policy);
1441 vLayout->addWidget(helpWidget);
1442 vLayout->addWidget(fHelpVSplitter,1);
1443 vLayout->setContentsMargins(5,5,5,5);
1445 helpWidget->setLayout(helpLayout);
1446 fHelpTBWidget->setLayout(vLayout);
1448 return fHelpTBWidget;
1454 G4UIDockWidget* G4UIQt::CreateCoutTBWidget(
1457 QWidget* coutTBWidget =
new QWidget();
1459 QVBoxLayout *layoutCoutTB =
new QVBoxLayout();
1461 fCoutTBTextArea =
new QTextEdit();
1464 fCoutTBTextArea->setFontFamily(
"Courier");
1465 fCoutTBTextArea->setFontPointSize(12);
1467 fCoutFilter =
new QLineEdit();
1468 fCoutFilter->setToolTip(
"Filter output by...");
1470 #if QT_VERSION > 0x050100
1471 fCoutFilter->addAction(*fSearchIcon,QLineEdit::TrailingPosition);
1472 fCoutFilter->setStyleSheet (
"border-radius:7px;");
1474 QPushButton *coutTBFilterButton =
new QPushButton();
1475 coutTBFilterButton->setIcon(QIcon(*fSearchIcon));
1476 coutTBFilterButton->setStyleSheet (
"padding-left: 0px; border:0px;");
1477 fCoutFilter->setStyleSheet (
"padding-right: 0px;");
1480 QPushButton *coutTBClearButton =
new QPushButton();
1481 coutTBClearButton->setIcon(*fClearIcon);
1482 coutTBClearButton->setToolTip(
"Clear console output");
1483 coutTBClearButton->setStyleSheet (
"border-radius:7px;");
1484 connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
1485 connect(fCoutFilter, SIGNAL(textEdited (
const QString &)), SLOT(CoutFilterCallback(
const QString &)));
1487 QPushButton *coutTBSaveOutputButton =
new QPushButton();
1488 coutTBSaveOutputButton->setIcon(*fSaveIcon);
1489 coutTBSaveOutputButton->setToolTip(
"Save console output");
1490 coutTBSaveOutputButton->setStyleSheet (
"border-radius:7px;");
1491 connect(coutTBSaveOutputButton, SIGNAL(clicked()), SLOT(SaveOutputCallback()));
1493 fCoutTBTextArea->setReadOnly(
true);
1495 QWidget* coutButtonWidget =
new QWidget();
1496 QHBoxLayout* layoutCoutTBButtons =
new QHBoxLayout();
1498 #ifdef G4MULTITHREADED
1500 fThreadsFilterComboBox =
new QComboBox();
1501 fThreadsFilterComboBox->setInsertPolicy(QComboBox::InsertAlphabetically);
1502 connect(fThreadsFilterComboBox, SIGNAL(activated(
int)),
this, SLOT(ThreadComboBoxCallback(
int)));
1504 UpdateCoutThreadFilter();
1506 fThreadsFilterComboBox->setToolTip(
"Thread selection in output");
1507 layoutCoutTBButtons->addWidget(
new QLabel(
" Threads:"));
1508 layoutCoutTBButtons->addWidget(fThreadsFilterComboBox);
1511 layoutCoutTBButtons->addWidget(fCoutFilter);
1512 #if QT_VERSION <= 0x050100
1513 layoutCoutTBButtons->addWidget(coutTBFilterButton);
1515 layoutCoutTBButtons->addWidget(coutTBClearButton);
1516 layoutCoutTBButtons->addWidget(coutTBSaveOutputButton);
1517 coutButtonWidget->setLayout(layoutCoutTBButtons);
1520 layoutCoutTBButtons->setContentsMargins(3,3,3,0);
1522 layoutCoutTB->addWidget(coutButtonWidget);
1523 layoutCoutTB->addWidget(fCoutTBTextArea);
1525 coutTBWidget->setLayout(layoutCoutTB);
1527 fCoutTBTextArea->setMinimumSize(100,100);
1530 QWidget* commandLineWidget =
new QWidget();
1531 QHBoxLayout *layoutCommandLine =
new QHBoxLayout();
1535 fCommandLabel =
new QLabel(
"");
1536 fCommandArea =
new QLineEdit();
1540 fCommandArea->activateWindow();
1542 fCommandArea->setFocusPolicy ( Qt::StrongFocus );
1543 fCommandArea->setFocus(Qt::TabFocusReason);
1544 fCommandArea->setToolTip(
"Apply command");
1547 layoutCommandLine->addWidget(fCommandLabel);
1548 layoutCommandLine->addWidget(fCommandArea);
1551 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
1552 connect(fCommandArea, SIGNAL(textEdited(
const QString &)), SLOT(CommandEditedCallback(
const QString &)));
1555 commandLineWidget->setLayout(layoutCommandLine);
1556 commandLineWidget->setMinimumSize(50,50);
1558 layoutCoutTB->addWidget(commandLineWidget);
1560 fCoutDockWidget =
new G4UIDockWidget (
"Output");
1561 fCoutDockWidget->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
1563 fCoutDockWidget->setWidget(coutTBWidget);
1564 return fCoutDockWidget;
1570 QWidget* G4UIQt::CreateVisParametersTBWidget(
1579 G4UIDockWidget* G4UIQt::CreateUITabWidget(
1582 fUITabWidget =
new QTabWidget();
1585 fUITabWidget->addTab(CreateSceneTreeWidget(),
"Scene tree");
1586 fUITabWidget->addTab(CreateHelpTBWidget(),
"Help");
1587 fUITabWidget->addTab(CreateHistoryTBWidget(),
"History");
1588 fUITabWidget->setCurrentWidget(fHelpTBWidget);
1590 fUITabWidget->setTabToolTip (0,
"Scene component tree. Only available in Stored mode");
1591 fUITabWidget->setTabToolTip (1,
"Help widget");
1592 fUITabWidget->setTabToolTip (2,
"All commands history");
1593 connect(fUITabWidget, SIGNAL(currentChanged(
int)), SLOT(ToolBoxActivated(
int)));
1595 fUIDockWidget =
new G4UIDockWidget (
"Scene tree, Help, History");
1596 fUIDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1598 fUIDockWidget->setWidget(fUITabWidget);
1600 return fUIDockWidget;
1604 QWidget* G4UIQt::CreateSceneTreeWidget(){
1606 fSceneTreeWidget =
new QWidget();
1607 QVBoxLayout* layout =
new QVBoxLayout();
1608 fSceneTreeWidget->setLayout(layout);
1610 #if QT_VERSION < 0x040200
1611 fSceneTreeWidget->hide();
1613 fSceneTreeWidget->setVisible(
false);
1616 return fSceneTreeWidget;
1620 void G4UIQt::CreateViewerWidget(){
1624 SetStartPage(std::string(
"<table width='100%'><tr><td width='30%'></td><td><div ")+
1625 "style='color: rgb(140, 31, 31); font-size: xx-large; font-family: Garamond, serif; padding-bottom: 0px; font-weight: normal'>Geant4: "+
1626 QApplication::applicationName ().toStdString()+
1627 "</div></td><td width='40%'> <br/><i>http://geant4.web.cern.ch/geant4/</i></td></tr></table>"+
1629 "<div style='background:#EEEEEE;'><b>Tooltips :</b><ul>"+
1630 "<li><b>Start a new viewer :</b><br />"+
1631 "<i>'/vis/open/...'<br />"+
1632 "For example '/vis/open OGL'</i></li>"+
1633 "<li><b>Execute a macro file :</b><br />"+
1634 "<i>'/control/execute my_macro_file'</i></li>"+
1637 "<div style='background:#EEEEEE;'><b>Documentation :</b><ul>"+
1638 "<li><b>Visualization tutorial :</b><br />"+
1639 "<i><a href='http://geant4.in2p3.fr/spip.php?article60&lang=en'>Geant4 Qt User Interface tutorial </a>: http://geant4.in2p3.fr/spip.php?article60&lang=en</i></li>"+
1640 "<li><b>Visualisation publication :</b><br />"+
1641 "<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>"+
1644 "<div style='background:#EEEEEE;'><b>Getting Help :</b><ul>"+
1645 "<li><b>If problems arise, try <a href='http://geant4-hn.slac.stanford.edu:5090/Geant4-HyperNews/index'>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> http://geant4-hn.slac.stanford.edu:5090/Geant4-HyperNews/index"+
1646 "<li><b>Get a look at <a href='http://geant4.kek.jp/geant4/support/index.shtml'>Geant4 User support pages</a>: <i>http://geant4.kek.jp/geant4/support/index.shtml</i></b></li>"+
1652 if (fViewerTabWidget == NULL) {
1653 fViewerTabWidget =
new G4QTabWidget();
1654 fMainWindow->setCentralWidget(fViewerTabWidget);
1655 #if QT_VERSION < 0x040500
1657 fViewerTabWidget->setTabsClosable (
true);
1660 #if QT_VERSION < 0x040200
1662 fViewerTabWidget->setUsesScrollButtons (
true);
1665 #if QT_VERSION < 0x040500
1667 connect(fViewerTabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(TabCloseCallback(
int)));
1669 connect(fViewerTabWidget, SIGNAL(currentChanged (
int ) ), SLOT(UpdateTabWidget(
int)));
1673 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
1674 policy.setVerticalStretch(4);
1675 fViewerTabWidget->setSizePolicy(policy);
1677 fViewerTabWidget->setMinimumSize(40,40);
1683 QWidget* G4UIQt::GetSceneTreeWidget(
1686 return fSceneTreeWidget;
1691 QWidget* G4UIQt::GetViewerPropertiesWidget(
1694 if (!fViewerPropertiesDialog) {
1695 CreateViewerPropertiesDialog();
1697 return fViewerPropertiesWidget;
1702 QWidget* G4UIQt::GetPickInfosWidget(
1705 if (!fPickInfosDialog) {
1706 CreatePickInfosDialog();
1708 return fPickInfosWidget;
1714 bool G4UIQt::AddViewerTab(
1719 if (fViewerTabWidget == NULL) {
1722 fViewerTabWidget->addTab(aWidget,title.c_str());
1730 bool G4UIQt::AddViewerTabFromFile(
1731 std::string fileName
1735 if (fViewerTabWidget == NULL) {
1740 if(UI==NULL)
return 0;
1741 std::ifstream file(UI->
FindMacroPath(fileName.c_str()).data());
1744 std::string content( (std::istreambuf_iterator<char>(file) ),
1745 (std::istreambuf_iterator<char>() ) );
1747 QTextEdit* text =
new QTextEdit();
1748 text->setAcceptRichText (
true);
1749 text->setContentsMargins(5,5,5,5);
1750 text->setText(QString(
"<pre>")+content.c_str()+
"</pre>");
1751 text->setReadOnly(
true);
1752 fViewerTabWidget->addTab(text,title.c_str());
1763 bool G4UIQt::AddTabWidget(
1774 #if QT_VERSION < 0x050100
1775 #if QT_VERSION >= 0x050000
1776 QString message = QString(
1777 "This Qt version [")+qVersion ()+
"] has some issues with the OpenGL viewer.\n"+
1778 "To prevent problems, you are not allowed to open a Stored nor Immediate viewer.\n" +
1780 "Please upgrade to Qt version >= 5.1\n";
1782 QMessageBox::warning(fMainWindow, tr(
"Warning"),
1783 tr(message.toStdString().c_str()),
1790 if (fViewerTabWidget == NULL) {
1791 CreateViewerWidget();
1798 aWidget->setParent(fViewerTabWidget);
1801 fViewerTabWidget->addTab(aWidget,name);
1803 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
1806 #if QT_VERSION < 0x040200
1807 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
1809 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
1820 void G4UIQt::SetStartPage(
1821 const std::string& text)
1824 fDefaultViewerFirstPageHTMLText = text;
1827 fStartPage =
new QTextEdit();
1828 fStartPage->setAcceptRichText (
true);
1829 fStartPage->setContentsMargins(5,5,5,5);
1830 fStartPage->setReadOnly(
true);
1832 fStartPage->setText(fDefaultViewerFirstPageHTMLText.c_str());
1836 void G4UIQt::UpdateTabWidget(
int tabNumber) {
1837 if ( fViewerTabWidget == NULL) {
1838 fViewerTabWidget =
new G4QTabWidget;
1841 fViewerTabWidget->setCurrentIndex(tabNumber);
1844 fViewerTabWidget->setTabSelected(
false);
1846 #if QT_VERSION < 0x040200
1847 fViewerTabWidget->show();
1849 fViewerTabWidget->setVisible(
true);
1853 fViewerTabWidget->setTabSelected(
true);
1859 void G4UIQt::ResizeTabWidget( QResizeEvent* e) {
1860 if ( fViewerTabWidget) {
1861 for (
G4int a=0;
a<fViewerTabWidget->count() ;
a++) {
1862 fViewerTabWidget->widget(
a)->resize(e->size());
1873 G4Qt* interactorManager = G4Qt::getInstance ();
1874 Prompt(
"Session :");
1875 exitSession =
false;
1877 QCoreApplication::sendPostedEvents () ;
1879 #if QT_VERSION < 0x040200
1880 fMainWindow->show();
1882 fMainWindow->setVisible(
true);
1885 if (fDefaultIcons) {
1886 #if QT_VERSION < 0x040200
1887 fToolbarApp->show();
1889 fToolbarApp->setVisible(
true);
1893 #if QT_VERSION < 0x040200
1894 fToolbarApp->hide();
1896 fToolbarApp->setVisible(
false);
1903 UpdateCommandCompleter();
1906 fHistoryTBTableList->installEventFilter(
this);
1907 fCommandArea->installEventFilter(
this);
1910 fCommandArea->setFocus();
1912 interactorManager->DisableSecondaryLoop ();
1913 if ((QApplication*)interactorManager->GetMainInteractor())
1914 ((QApplication*)interactorManager->GetMainInteractor())->exec();
1916 interactorManager->EnableSecondaryLoop ();
1926 void G4UIQt::Prompt (
1930 if (!aPrompt)
return;
1932 fCommandLabel->setText((
char*)aPrompt.
data());
1937 void G4UIQt::SessionTerminate (
1940 G4Qt* interactorManager = G4Qt::getInstance ();
1941 fMainWindow->close();
1942 ((QApplication*)interactorManager->GetMainInteractor())->exit();
1955 void G4UIQt::PauseSessionStart (
1959 if (!aState)
return;
1961 if(aState==
"G4_pause> ") {
1962 SecondaryLoop (
"Pause, type continue to exit this state");
1965 if(aState==
"EndOfEvent") {
1967 SecondaryLoop (
"End of event, type continue to exit this state");
1977 void G4UIQt::SecondaryLoop (
1981 if (!aPrompt)
return;
1983 G4Qt* interactorManager = G4Qt::getInstance ();
1987 ((QApplication*)interactorManager)->processEvents(QEventLoop::WaitForMoreEvents);
1988 if(exitPause==
true)
break;
1990 Prompt(
"Session :");
1993 #ifdef G4MULTITHREADED
2007 G4int G4UIQt::ReceiveG4cout (
2011 if (!aString)
return 0;
2013 #ifdef G4MULTITHREADED
2019 if (aString.
contains(
"*** This is just a warning message. ***")) {
2020 return ReceiveG4cerr(aString);
2026 G4UIOutputString txt = G4UIOutputString(QString((
char*)aString.
data()).trimmed(),GetThreadPrefix());
2027 fG4OutputString.push_back(txt);
2029 #ifdef G4MULTITHREADED
2030 QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
2032 QString result = FilterOutput(txt,
"",fCoutFilter->text());
2035 if (result.isEmpty()) {
2038 QColor previousColor = fCoutTBTextArea->textColor();
2039 fCoutTBTextArea->setTextColor(Qt::black);
2040 fCoutTBTextArea->append(result);
2041 fCoutTBTextArea->setTextColor(previousColor);
2042 fCoutTBTextArea->ensureCursorVisible ();
2044 #ifdef G4MULTITHREADED
2045 UpdateCoutThreadFilter();
2056 G4int G4UIQt::ReceiveG4cerr (
2060 if (!aString)
return 0;
2062 #ifdef G4MULTITHREADED
2069 G4UIOutputString txt = G4UIOutputString(QString((
char*)aString.
data()).trimmed(),
2072 fG4OutputString.push_back(txt);
2074 #ifdef G4MULTITHREADED
2075 QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
2077 QString result = FilterOutput(txt,
"",fCoutFilter->text());
2079 if (result.isEmpty()) {
2084 if (QString(aString.
data()).trimmed() !=
"") {
2088 QMessageBox::critical(fMainWindow,
"Error",QString(fLastErrMessage.data())+
"\n"+aString.
data());
2091 QColor previousColor = fCoutTBTextArea->textColor();
2092 fCoutTBTextArea->setTextColor(
Qt::red);
2093 fCoutTBTextArea->append(result);
2094 fCoutTBTextArea->setTextColor(previousColor);
2095 fCoutTBTextArea->ensureCursorVisible ();
2097 if (QString(aString.
data()).trimmed() !=
"") {
2098 fLastErrMessage = aString;
2100 #ifdef G4MULTITHREADED
2101 UpdateCoutThreadFilter();
2107 G4String G4UIQt::GetThreadPrefix() {
2109 #ifdef G4MULTITHREADED
2111 if(UI==NULL)
return "";
2119 return threadPrefix;
2123 #ifdef G4MULTITHREADED
2124 void G4UIQt::UpdateCoutThreadFilter() {
2126 if(UI==NULL)
return;
2129 if (fThreadsFilterComboBox->count() < 2) {
2130 if ( fThreadsFilterComboBox->findText(
"All", Qt::MatchExactly) == -1) {
2131 fThreadsFilterComboBox->addItem(
"All");
2134 if (fThreadsFilterComboBox->count() < 2) {
2135 if ( fThreadsFilterComboBox->findText(
"Master", Qt::MatchExactly) == -1) {
2136 fThreadsFilterComboBox->addItem(
"Master");
2142 if ( fThreadsFilterComboBox->findText(prefix.
data(), Qt::MatchExactly) == -1) {
2143 fThreadsFilterComboBox->addItem(prefix.
data());
2155 void G4UIQt::AddMenu (
2160 if (aName == NULL)
return;
2161 if (aLabel == NULL)
return;
2163 QMenu *fileMenu =
new QMenu(aLabel);
2164 fMainWindow->menuBar()->addMenu(fileMenu);
2176 void G4UIQt::AddButton (
2179 ,
const char* aCommand
2182 if(aMenu==NULL)
return;
2183 if(aLabel==NULL)
return;
2184 if(aCommand==NULL)
return;
2186 QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
2188 if(parentTmp==NULL) {
2193 G4cout <<
"Menu name " << aMenu<<
" does not exist, please define it before using it."<<
G4endl;
2200 if(UI==NULL)
return;
2204 G4int cmdEndPos = cmd.find_first_of(
" \t");
2205 if(cmdEndPos!=
G4int(std::string::npos)) {
2206 cmd.erase(cmdEndPos);
2209 if(treeTop->
FindPath(cmd) == NULL) {
2211 cmd(0,3) !=
"ls " &&
2214 cmd(0,3) !=
"cd " &&
2216 cmd(0,5) !=
"help " &&
2228 G4cout <<
"Warning: command '"<< cmd <<
"' does not exist, please define it before using it."<<
G4endl;
2233 QSignalMapper *signalMapper =
new QSignalMapper(
this);
2234 QAction *action = parentTmp->addAction(aLabel, signalMapper, SLOT(map()));
2236 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
2237 signalMapper->setMapping(action, QString(aCommand));
2246 void G4UIQt::AddIcon(
const char* aLabel,
const char* aIconFile,
const char* aCommand,
const char* aFileName){
2247 if(aLabel==NULL)
return;
2249 if (aCommand==NULL) {
2250 if (std::string(aIconFile) ==
"user_icon") {
2255 bool userToolBar =
false;
2257 if (!fDefaultIcons) {
2260 if (std::string(aIconFile) ==
"user_icon") {
2264 if (pix->isNull()) {
2268 G4cout <<
"Warning: file '"<< aFileName <<
"' is incorrect or does not exist, this command will not be build"<<
G4endl;
2272 }
else if (std::string(aIconFile) ==
"open") {
2274 }
else if (std::string(aIconFile) ==
"save") {
2276 }
else if (std::string(aIconFile) ==
"move") {
2278 }
else if (std::string(aIconFile) ==
"rotate") {
2280 }
else if (std::string(aIconFile) ==
"pick") {
2282 }
else if (std::string(aIconFile) ==
"zoom_in") {
2284 }
else if (std::string(aIconFile) ==
"zoom_out") {
2286 }
else if (std::string(aIconFile) ==
"wireframe") {
2287 pix = fWireframeIcon;
2288 }
else if (std::string(aIconFile) ==
"solid") {
2290 }
else if (std::string(aIconFile) ==
"hidden_line_removal") {
2291 pix = fHiddenLineRemovalIcon;
2292 }
else if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
2293 pix = fHiddenLineAndSurfaceRemovalIcon;
2294 }
else if (std::string(aIconFile) ==
"perspective") {
2295 pix = fPerspectiveIcon;
2296 }
else if (std::string(aIconFile) ==
"ortho") {
2298 }
else if (std::string(aIconFile) ==
"runBeamOn") {
2305 G4cout <<
"Parameter"<< aIconFile <<
" not defined"<<
G4endl;
2309 QToolBar *currentToolbar = NULL;
2311 if (fToolbarUser == NULL) {
2312 fToolbarUser =
new QToolBar();
2313 fToolbarUser->setIconSize (QSize(20,20));
2314 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
2316 currentToolbar = fToolbarUser;
2318 if (fToolbarApp == NULL) {
2319 fToolbarApp =
new QToolBar();
2320 fToolbarApp->setIconSize (QSize(20,20));
2321 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
2323 currentToolbar = fToolbarApp;
2328 QList<QAction*> list = currentToolbar->actions();
2330 for (
int i = 0; i < list.size(); ++i) {
2331 if (list.at(i)->text() == QString(aLabel)) {
2333 if(UI==NULL)
return;
2336 G4cout <<
"Warning: A toolBar icon \""<< aLabel<<
"\" already exists with the same name!" <<
G4endl;
2341 QSignalMapper *signalMapper =
new QSignalMapper(
this);
2342 QAction *action = currentToolbar->addAction(QIcon(*pix),aLabel, signalMapper, SLOT(map()));
2345 if (std::string(aIconFile) ==
"open") {
2346 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(OpenIconCallback(
const QString &)));
2347 QString txt = aCommand + fStringSeparator + aLabel;
2348 signalMapper->setMapping(action, QString(txt));
2351 }
else if (std::string(aIconFile) ==
"save") {
2352 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(SaveIconCallback(
const QString&)));
2353 QString txt = aCommand + fStringSeparator + aLabel;
2354 signalMapper->setMapping(action, QString(txt));
2357 }
else if ((std::string(aIconFile) ==
"move") ||
2358 (std::string(aIconFile) ==
"rotate") ||
2359 (std::string(aIconFile) ==
"pick") ||
2360 (std::string(aIconFile) ==
"zoom_out") ||
2361 (std::string(aIconFile) ==
"zoom_in")) {
2362 action->setCheckable(
TRUE);
2363 action->setChecked(
TRUE);
2364 action->setData(aIconFile);
2366 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeCursorAction(
const QString&)));
2367 signalMapper->setMapping(action, QString(aIconFile));
2369 if (std::string(aIconFile) ==
"move") {
2370 SetIconMoveSelected();
2372 if (std::string(aIconFile) ==
"rotate") {
2373 SetIconRotateSelected();
2375 if (std::string(aIconFile) ==
"pick") {
2376 SetIconPickSelected();
2378 if (std::string(aIconFile) ==
"zoom_in") {
2379 SetIconZoomInSelected();
2381 if (std::string(aIconFile) ==
"zoom_out") {
2382 SetIconZoomOutSelected();
2386 }
else if ((std::string(aIconFile) ==
"hidden_line_removal") ||
2387 (std::string(aIconFile) ==
"hidden_line_and_surface_removal") ||
2388 (std::string(aIconFile) ==
"solid") ||
2389 (std::string(aIconFile) ==
"wireframe")) {
2390 action->setCheckable(
TRUE);
2391 action->setChecked(
TRUE);
2392 action->setData(aIconFile);
2393 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeSurfaceStyle(
const QString&)));
2394 signalMapper->setMapping(action, QString(aIconFile));
2396 if (std::string(aIconFile) ==
"hidden_line_removal") {
2397 SetIconHLRSelected();
2399 if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
2400 SetIconHLHSRSelected();
2402 if (std::string(aIconFile) ==
"solid") {
2403 SetIconSolidSelected();
2405 if (std::string(aIconFile) ==
"wireframe") {
2406 SetIconWireframeSelected();
2410 }
else if ((std::string(aIconFile) ==
"perspective") ||
2411 (std::string(aIconFile) ==
"ortho")) {
2412 action->setCheckable(
TRUE);
2413 action->setChecked(
TRUE);
2414 action->setData(aIconFile);
2415 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangePerspectiveOrtho(
const QString&)));
2416 signalMapper->setMapping(action, QString(aIconFile));
2418 if (std::string(aIconFile) ==
"perspective") {
2419 SetIconPerspectiveSelected();
2421 if (std::string(aIconFile) ==
"ortho") {
2422 SetIconOrthoSelected();
2429 if(UI==NULL)
return;
2431 if (aCommand != NULL) {
2432 std::string str = aCommand;
2433 std::string::size_type
pos = str.find(
" ");
2434 if (pos != std::string::npos)
2436 str = str.substr(0,pos).c_str();
2438 if(treeTop->
FindPath(str.c_str()) == NULL) {
2443 G4cout <<
"Warning: command '"<< aCommand <<
"' does not exist, please define it before using it."<<
G4endl;
2448 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
2449 signalMapper->setMapping(action, QString(aCommand));
2455 void G4UIQt::ActivateCommand(
2459 if (!fHelpTreeWidget) {
2463 size_t i = newCommand.
index(
" ");
2465 if( i != std::string::npos )
2467 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
2469 targetCom = ModifyToFullPathCommand( newValue );
2471 if (targetCom !=
"") {
2472 OpenHelpTreeOnCommand(targetCom.
data());
2475 fUITabWidget->setCurrentWidget(fHelpTBWidget);
2486 void G4UIQt::InitHelpTreeAndVisParametersWidget()
2489 if (! fHelpTreeWidget ) {
2490 fHelpTreeWidget =
new QTreeWidget();
2494 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2496 labels << QString(
"Command");
2497 fHelpTreeWidget->setHeaderLabels(labels);
2500 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),
this, SLOT(HelpTreeClicCallback()));
2501 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,
int)),
this, SLOT(HelpTreeDoubleClicCallback()));
2510 void G4UIQt::FillHelpTree()
2512 if (! fHelpTreeWidget ) {
2513 InitHelpTreeAndVisParametersWidget();
2516 QString searchText = fHelpLine->text();
2518 if (searchText ==
"") {
2525 if (fParameterHelpLabel) {
2526 fParameterHelpLabel->setText(
"Choose a command in the command tree");
2527 fParameterHelpTable->setVisible(
false);
2531 #if QT_VERSION < 0x040200
2534 fHelpLine->setText(
"");
2539 if(UI==NULL)
return;
2543 QTreeWidgetItem * newItem = NULL;
2544 QString commandText =
"";
2545 for (
int a=0;
a<treeSize;
a++) {
2552 for (
int b=0;b<fHelpTreeWidget->topLevelItemCount();b++) {
2554 newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b),commandText);
2557 if (newItem == NULL) {
2559 newItem =
new QTreeWidgetItem();
2560 newItem->setText(0,GetShortCommandPath(commandText));
2561 fHelpTreeWidget->addTopLevelItem(newItem);
2565 CreateHelpTree(newItem,treeTop->
GetTree(
a+1));
2576 void G4UIQt::CreateHelpTree(
2577 QTreeWidgetItem *aParent
2581 if (aParent == NULL)
return;
2582 if (aCommandTree == NULL)
return;
2586 QTreeWidgetItem * newItem;
2588 QString commandText =
"";
2592 commandText = QString((
char*)(aCommandTree->
GetTree(
a+1)->
GetPathName()).data()).trimmed();
2595 newItem = FindTreeItem(aParent,commandText);
2596 if (newItem == NULL) {
2597 newItem =
new QTreeWidgetItem();
2598 newItem->setText(0,GetShortCommandPath(commandText));
2599 aParent->addChild(newItem);
2601 CreateHelpTree(newItem,aCommandTree->
GetTree(
a+1));
2608 QStringList stringList;
2612 newItem = FindTreeItem(aParent,commandText);
2613 if (newItem == NULL) {
2614 newItem =
new QTreeWidgetItem();
2615 newItem->setText(0,GetShortCommandPath(commandText));
2616 aParent->addChild(newItem);
2618 #if QT_VERSION < 0x040202
2619 fHelpTreeWidget->setItemExpanded(newItem,
false);
2621 newItem->setExpanded(
false);
2635 bool G4UIQt::CreateVisCommandGroupAndToolBox(
2642 QString commandText = QString((
char*)(aCommand->
GetCommandPath().
data())).section(
"/",-aDepthLevel);
2644 if (commandText == NULL) {
2650 QWidget* newParentWidget = NULL;
2652 QString commandSection = commandText.left(commandText.indexOf(
"/"));
2654 if (aDepthLevel == 1) {
2655 QToolBox* currentParent =
dynamic_cast<QToolBox*
>(aParent);
2656 if (currentParent != 0){
2659 for (
int a=0;
a<currentParent->count();
a++) {
2660 if (currentParent->itemText(
a) == commandSection) {
2662 newParentWidget = currentParent->widget(
a);
2668 newParentWidget =
new QGroupBox();
2669 newParentWidget->setLayout(
new QVBoxLayout());
2670 if (currentParent != 0){
2671 currentParent->addItem(newParentWidget,commandSection);
2673 if (!aParent->layout()) {
2674 aParent->setLayout(
new QVBoxLayout());
2676 aParent->layout()->addWidget(newParentWidget);
2679 if (commandText.indexOf(
"/") == -1) {
2684 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2685 guidance += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
2687 newParentWidget->setToolTip(guidance);
2690 QScrollArea* sc =
dynamic_cast<QScrollArea*
>(newParentWidget->parent()->parent());
2692 sc->ensureWidgetVisible(newParentWidget);
2699 QGroupBox* currentParent =
dynamic_cast<QGroupBox*
>(aParent);
2700 if (currentParent != 0){
2704 if (aDepthLevel == 2){
2705 QToolBox* parentToolBox =
dynamic_cast<QToolBox*
>(currentParent->parent()->parent()->parent());
2706 if (parentToolBox != 0) {
2710 for (
int a=0;
a<aParent->layout()->count();
a++) {
2711 QGroupBox* gb =
dynamic_cast<QGroupBox*
>(aParent->layout()->itemAt(
a)->widget());
2713 if (gb->title() == commandSection) {
2715 newParentWidget = gb;
2723 newParentWidget =
new QGroupBox();
2724 newParentWidget->setLayout(
new QVBoxLayout());
2725 if (!aParent->layout()) {
2726 aParent->setLayout(
new QVBoxLayout());
2728 aParent->layout()->addWidget(newParentWidget);
2734 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2735 guidance += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
2737 newParentWidget->setToolTip(guidance);
2742 if (commandText.indexOf(
"/") == -1) {
2743 if (CreateCommandWidget(aCommand, newParentWidget,isDialog)) {
2747 CreateVisCommandGroupAndToolBox(aCommand,newParentWidget, aDepthLevel-1,isDialog);
2760 bool G4UIQt::CreateCommandWidget(
G4UIcommand* aCommand, QWidget* aParent,
bool isDialog) {
2762 if (aCommand == NULL) {
2769 if( n_parameterEntry > 0 ) {
2773 QWidget* paramWidget =
new QWidget();
2774 QGridLayout* gridLayout =
new QGridLayout();
2775 paramWidget->setLayout(gridLayout);
2778 unsigned int nbColorParameter = 0;
2779 bool isStillColorParameter =
false;
2780 bool isColorDialogAdded =
false;
2781 QLabel* redLabel = NULL;
2782 QLabel* greenLabel = NULL;
2783 QString redDefaultStr =
"";
2784 QString greenDefaultStr =
"";
2785 QString blueDefaultStr =
"";
2786 QWidget* redInput = NULL;
2787 QWidget* greenInput = NULL;
2789 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2792 QLabel* label =
new QLabel(QString((
char*)(param->
GetParameterName()).data()));
2794 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")){
2795 nbColorParameter ++;
2796 isStillColorParameter =
true;
2797 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2798 nbColorParameter ++;
2799 }
else if ((label->text() ==
"blue") && isStillColorParameter) {
2800 nbColorParameter ++;
2801 }
else if (!isColorDialogAdded) {
2804 if (nbColorParameter == 1) {
2805 gridLayout->addWidget(redLabel,i_thParameter-1,0);
2806 gridLayout->addWidget(redInput,i_thParameter-1,1);
2807 }
else if (nbColorParameter == 2) {
2808 gridLayout->addWidget(redLabel,i_thParameter-2,0);
2809 gridLayout->addWidget(redInput,i_thParameter-2,1);
2810 gridLayout->addWidget(greenLabel,i_thParameter-1,0);
2811 gridLayout->addWidget(greenInput,i_thParameter-1,1);
2813 nbColorParameter = 0;
2816 QWidget* input = NULL;
2818 input =
new QLineEdit();
2820 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
2822 if (((label->text() ==
"red") || (label->text() ==
"red_or_string")) && isStillColorParameter) {
2824 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2826 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2831 input =
new QWidget();
2832 QHBoxLayout* layout =
new QHBoxLayout();
2833 input->setLayout(layout);
2835 QButtonGroup* buttons =
new QButtonGroup();
2836 QRadioButton* radioOff =
new QRadioButton(
"0");
2837 QRadioButton* radioOn =
new QRadioButton(
"1");
2838 buttons->addButton(radioOn);
2839 buttons->addButton(radioOff);
2840 layout->addWidget(radioOn);
2841 layout->addWidget(radioOff);
2844 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
2845 if (defaultValue ==
"0") {
2846 radioOff->setChecked(
true);
2847 }
else if (defaultValue ==
"1") {
2848 radioOn->setChecked(
true);
2851 input =
new QComboBox();
2853 QStringList list = candidates.split (
" ");
2856 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
2857 for (
int a=0;
a<list.size();
a++) {
2858 dynamic_cast<QComboBox*
>(input)->addItem(list.at(
a));
2859 if (list.at(
a) == defaultValue) {
2860 dynamic_cast<QComboBox*
>(input)->setCurrentIndex(
a);
2865 input =
new QLineEdit();
2867 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
2870 input =
new QWidget();
2871 QHBoxLayout* layout =
new QHBoxLayout();
2872 input->setLayout(layout);
2874 QButtonGroup* buttons =
new QButtonGroup();
2875 QRadioButton* radioOff =
new QRadioButton(
"off");
2876 QRadioButton* radioOn =
new QRadioButton(
"on");
2877 buttons->addButton(radioOn);
2878 buttons->addButton(radioOff);
2879 layout->addWidget(radioOn);
2880 layout->addWidget(radioOff);
2883 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
2884 if (defaultValue ==
"off") {
2885 radioOff->setChecked(
true);
2886 }
else if (defaultValue ==
"on") {
2887 radioOn->setChecked(
true);
2891 input =
new QLineEdit();
2892 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
2895 txt +=
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) +
"\n";
2899 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2901 txt +=
" Omittable : True\n";
2903 txt +=
" Omittable : False\n";
2906 txt +=
" Default value : taken from the current value\n";
2908 txt +=
" Default value : " + QString((
char*)(param->
GetDefaultValue()).data())+
"\n";
2911 txt +=
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data())+
"\n";
2917 if (isStillColorParameter && (nbColorParameter != 0)) {
2918 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")) {
2921 }
else if (label->text() ==
"green") {
2924 }
else if (label->text() ==
"blue") {
2930 if ((redDefaultStr !=
"") && (redDefaultStr !=
"") && (redDefaultStr !=
"")) {
2931 qc.setRgbF(redDefaultStr.toDouble(),
2932 greenDefaultStr.toDouble(),
2933 blueDefaultStr.toDouble());
2935 QPixmap pixmap = QPixmap(QSize(16, 16));
2937 QPainter painter(&pixmap);
2938 painter.setPen(Qt::black);
2939 painter.drawRect(0,0,15,15);
2941 input =
new QPushButton(
"Change color");
2942 dynamic_cast<QPushButton*
>(input)->setIcon(pixmap);
2943 dynamic_cast<QPushButton*
>(input)->setAccessibleName(redDefaultStr+
" "+greenDefaultStr+
" "+blueDefaultStr);
2944 label =
new QLabel(
"Choose color");
2948 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2949 input->setToolTip(
"Select the current color");
2950 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2953 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2954 signalMapper->setMapping(input,input);
2955 connect(input, SIGNAL(clicked()), signalMapper, SLOT(map()));
2956 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(ChangeColorCallback(QWidget*)));
2958 isColorDialogAdded =
true;
2959 isStillColorParameter =
false;
2962 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2963 input->setToolTip(txt);
2964 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2970 gridLayout->addWidget(name,n_parameterEntry-nbColorParameter,0);
2972 QPushButton* applyButton =
new QPushButton(
"Apply");
2975 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,1);
2977 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2978 signalMapper->setMapping(applyButton, paramWidget);
2979 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2980 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2984 applyButton->setAutoDefault(
TRUE );
2985 applyButton->setDefault(
TRUE );
2987 QPushButton* cancelButton =
new QPushButton( tr(
"&Cancel" ));
2988 cancelButton->setAutoDefault(
TRUE );
2989 gridLayout->addWidget(cancelButton,n_parameterEntry-nbColorParameter,1);
2990 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,0);
2992 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2993 signalMapper->setMapping(applyButton, paramWidget);
2994 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2995 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2997 QWidget * parentCheck = aParent;
2998 QDialog* parentDialog = NULL;
3000 while ((parentCheck->parentWidget()) != NULL) {
3001 parentCheck = parentCheck->parentWidget();
3002 parentDialog =
dynamic_cast<QDialog*
>(parentCheck);
3004 connect( applyButton, SIGNAL( clicked() ), parentDialog, SLOT( accept() ) );
3005 connect( cancelButton, SIGNAL( clicked() ), parentDialog, SLOT( reject() ) );
3014 if (!aParent->layout()) {
3015 aParent->setLayout(
new QVBoxLayout());
3017 aParent->layout()->addWidget(paramWidget);
3028 QTreeWidgetItem* G4UIQt::FindTreeItem(
3029 QTreeWidgetItem *aParent
3030 ,
const QString& aCommand
3033 if (aParent == NULL)
return NULL;
3036 QString myCommand = aCommand;
3038 if (myCommand.lastIndexOf(
"/") == (myCommand.size()-1)) {
3039 myCommand = myCommand.left(myCommand.size()-1);
3042 if (GetLongCommandPath(aParent) == myCommand)
3045 QTreeWidgetItem * tmp = NULL;
3046 for (
int a=0;
a<aParent->childCount();
a++) {
3048 tmp = FindTreeItem(aParent->child(
a),myCommand);
3062 QString G4UIQt::GetCommandList (
3068 if (aCommand == NULL)
3076 if ((commandPath ==
"") &&
3077 (rangeString ==
"") &&
3078 (n_guidanceEntry == 0) &&
3079 (n_parameterEntry == 0)) {
3083 if((commandPath.length()-1)!=
'/') {
3084 txt +=
"Command " + QString((
char*)(commandPath).data()) +
"\n";
3086 txt +=
"Guidance :\n";
3088 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3089 txt += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
3091 if( ! rangeString.
isNull() ) {
3092 txt +=
" Range of parameters : " + QString((
char*)(rangeString).data()) +
"\n";
3094 if( n_parameterEntry > 0 ) {
3099 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
3101 txt +=
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) +
"\n";
3104 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
3106 txt +=
" Omittable : True\n";
3108 txt +=
" Omittable : False\n";
3111 txt +=
" Default value : taken from the current value\n";
3113 txt +=
" Default value : " + QString((
char*)(param->
GetDefaultValue()).data())+
"\n";
3116 txt +=
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data())+
"\n";
3134 void G4UIQt::updateHelpArea (
3138 if (!fParameterHelpLabel)
3140 if (!fParameterHelpTable)
3143 fParameterHelpLabel->setTextInteractionFlags(Qt::NoTextInteraction);
3145 if (aCommand == NULL)
3153 if ((commandPath ==
"") &&
3154 (rangeString ==
"") &&
3155 (n_guidanceEntry == 0) &&
3156 (n_parameterEntry == 0)) {
3160 if((commandPath.length()-1)!=
'/') {
3161 txt +=
"<b>Command </b> " + QString((
char*)(commandPath).data()) +
"<br />";
3163 txt +=
"<b>Guidance :</b> ";
3165 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3166 txt += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"<br />";
3168 if( ! rangeString.
isNull() ) {
3169 txt +=
"<b>Range of parameters : </b> " + QString((
char*)(rangeString).data()) +
"<br />";
3173 fParameterHelpLabel->setHtml(txt);
3175 if( n_parameterEntry > 0 ) {
3180 fParameterHelpTable->clear();
3181 fParameterHelpTable->setRowCount(n_parameterEntry);
3182 fParameterHelpTable->setColumnCount(8);
3183 fParameterHelpTable->setHorizontalHeaderLabels(QStringList() <<
3192 fParameterHelpTable->setColumnWidth(2,60);
3194 fParameterHelpTable->verticalHeader()->setVisible(
false);
3195 fParameterHelpTable->setAlternatingRowColors (
true);
3196 #if QT_VERSION < 0x050000
3197 fParameterHelpTable->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
3198 fParameterHelpTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
3200 fParameterHelpTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
3201 fParameterHelpTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
3203 fParameterHelpTable->setWordWrap(
true);
3205 QTableWidgetItem* t = fParameterHelpTable->horizontalHeaderItem(1);
3206 QFont fnt = t->font();
3207 int size = fnt.pointSize();
3208 fnt.setPointSize(size-2);
3210 for(
G4int a=0;
a<n_parameterEntry;
a++ ) {
3212 fParameterHelpTable->setItem(
a, 0,
new QTableWidgetItem(QString::number(
a+1)));
3214 fParameterHelpTable->setItem(
a, 1,
new QTableWidgetItem(QString((
char*)(param->
GetParameterName()).data())));
3216 fParameterHelpTable->setItem(
a, 2,
new QTableWidgetItem(QString((
char*)(param->
GetParameterGuidance()).data())));
3218 fParameterHelpTable->setItem(
a, 3,
new QTableWidgetItem(QString(QChar(param->
GetParameterType()))));
3221 fParameterHelpTable->setItem(
a, 4,
new QTableWidgetItem(QString(
"True")));
3223 fParameterHelpTable->setItem(
a, 4,
new QTableWidgetItem(QString(
"False")));
3226 fParameterHelpTable->setItem(
a, 5,
new QTableWidgetItem(QString(
"taken from the current value")));
3228 fParameterHelpTable->setItem(
a, 5,
new QTableWidgetItem(QString((
char*)(param->
GetDefaultValue()).data())));
3231 fParameterHelpTable->setItem(
a, 6,
new QTableWidgetItem(QString((
char*)(param->
GetParameterRange()).data())));
3234 fParameterHelpTable->setItem(
a, 7,
new QTableWidgetItem(QString((
char*)(param->
GetParameterCandidates()).data())));
3237 for (
int b=0; b<8; b++) {
3238 QTableWidgetItem* tmp = fParameterHelpTable->item(
a,b);
3240 tmp->setToolTip(tmp->text());
3241 tmp->setFlags(Qt::NoItemFlags);
3242 tmp->setForeground(QBrush());
3246 fParameterHelpTable->resizeRowToContents(
a);
3248 for (
int c=0; c<8; c++) {
3250 fParameterHelpTable->resizeColumnToContents(c);
3253 fParameterHelpLabel->setVisible(
true);
3254 fParameterHelpTable->setVisible(
true);
3265 G4bool G4UIQt::IsGUICommand(
3269 if (aCommand == NULL)
3274 if( n_parameterEntry > 0 ) {
3279 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
3301 G4bool G4UIQt::GetHelpChoice(
3316 bool G4UIQt::eventFilter(
3321 bool tabKeyPress =
false;
3322 bool moveCommandCursor =
false;
3323 if (aObj == NULL)
return false;
3324 if (aEvent == NULL)
return false;
3326 if (aObj == fHistoryTBTableList) {
3327 if (aEvent->type() == QEvent::KeyPress) {
3328 fCommandArea->setFocus();
3332 if (aObj == fCompleter->popup()) {
3333 if (aEvent->type() == QEvent::KeyPress) {
3334 QKeyEvent *e =
static_cast<QKeyEvent*
>(aEvent);
3335 if (e->key() == (Qt::Key_Tab)) {
3341 if (aObj == fCommandArea) {
3342 if (aEvent->type() == QEvent::KeyPress) {
3343 QKeyEvent *e =
static_cast<QKeyEvent*
>(aEvent);
3344 if ((e->key() == (Qt::Key_Down)) ||
3345 (e->key() == (Qt::Key_PageDown)) ||
3346 (e->key() == (Qt::Key_Up)) ||
3347 (e->key() == (Qt::Key_PageUp))) {
3348 int selection = fHistoryTBTableList->currentRow();
3349 if (fHistoryTBTableList->count()) {
3350 if (selection == -1) {
3351 selection = fHistoryTBTableList->count()-1;
3353 if (e->key() == (Qt::Key_Down)) {
3354 if (selection <(fHistoryTBTableList->count()-1))
3356 }
else if (e->key() == (Qt::Key_PageDown)) {
3357 selection = fHistoryTBTableList->count()-1;
3358 }
else if (e->key() == (Qt::Key_Up)) {
3361 }
else if (e->key() == (Qt::Key_PageUp)) {
3365 fHistoryTBTableList->clearSelection();
3366 #if QT_VERSION < 0x040202
3367 fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),
true);
3369 fHistoryTBTableList->item(selection)->setSelected(
true);
3371 fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
3373 moveCommandCursor =
true;
3374 }
else if (e->key() == (Qt::Key_Tab)) {
3376 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
3377 fCommandArea->home(
false);
3379 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
3380 fCommandArea->end(
false);
3385 if (tabKeyPress ==
true) {
3386 G4String ss = Complete(fCommandArea->text().toStdString().c_str());
3387 fCommandArea->setText((
char*)(ss.
data()));
3388 fCommandArea->setFocus();
3397 if (moveCommandCursor ==
true) {
3398 fCommandArea->setCursorPosition ( fCommandArea->text().length() );
3399 fCommandArea->setCursorPosition (4);
3402 res = QObject::eventFilter(aObj, aEvent);
3408 void G4UIQt::UpdateCommandCompleter() {
3409 if (!fCommandArea)
return;
3412 fCommandArea->setCompleter(NULL);
3414 if (fCompleter->popup()) {
3415 fCompleter->popup()->removeEventFilter(
this);
3419 QStandardItemModel* model = CreateCompleterModel(
"/");
3420 fCompleter =
new QCompleter(model);
3427 int Ndir= aTree-> GetTreeEntry();
3428 fCompleter->setMaxVisibleItems(Ndir);
3430 fCommandArea->setCompleter(fCompleter);
3431 fCompleter->popup()->installEventFilter(
this);
3435 QStandardItemModel* G4UIQt::CreateCompleterModel(
G4String aCmd) {
3437 QList< QStandardItem*> dirModelList;
3438 QList< QStandardItem*> commandModelList;
3439 QList< QStandardItem*> subDirModelList;
3440 QList< QStandardItem*> subCommandModelList;
3452 if(jpre !=
G4int(G4String::npos)) pName.
remove(jpre+1);
3457 int Ndir= aTree-> GetTreeEntry();
3458 int Ncmd= aTree-> GetCommandEntry();
3461 for(
G4int idir=1; idir<=Ndir; idir++) {
3462 G4String fpdir= aTree-> GetTree(idir)-> GetPathName();
3464 if( fpdir.
index(remainingPath, 0) == 0) {
3466 matchingPath = fpdir;
3473 QStandardItem* item1 =
new QStandardItem(fpdir.
data());
3474 QIcon i = QIcon(*fDirIcon);
3476 item1->setIcon(QIcon(*fDirIcon));
3477 dirModelList.append(item1);
3480 QStandardItemModel* subModel = CreateCompleterModel(fpdir.
data());
3481 for (
int a=0;
a< subModel->rowCount();
a++) {
3484 QStandardItem* tempItem =
new QStandardItem(subModel->item(
a)->text());
3485 tempItem->setIcon(subModel->item(
a)->icon());
3486 tempItem->setToolTip(subModel->item(
a)->toolTip());
3487 tempItem->setData(subModel->item(
a)->data());
3490 if (tempItem->data() == 1) {
3492 subDirModelList.append(tempItem);
3495 else if (tempItem->data() == 0) {
3496 subCommandModelList.append(tempItem);
3503 G4int n_parameterEntry;
3505 G4int n_guidanceEntry;
3508 std::string tooltip;
3511 for(
G4int icmd=1; icmd<=Ncmd; icmd++){
3514 command = aTree-> GetCommand(icmd);
3515 G4String longCommandName= aTree-> GetPathName() +
3516 command -> GetCommandName();
3523 if( longCommandName.
index(remainingPath, 0) ==0) {
3525 matchingPath= longCommandName +
" ";
3527 strtmp= longCommandName +
" ";
3532 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3533 tooltip += std::string((command->
GetGuidanceLine(i_thGuidance)).data());
3534 if (i_thGuidance < n_guidanceEntry-1 ) {
3540 for(
G4int a=0;
a<n_parameterEntry;
a++ ) {
3547 QStandardItem* item =
new QStandardItem(
G4String(longCommandName + params).data());
3549 item->setIcon(QIcon(*fCommandIcon));
3550 item->setToolTip(tooltip.c_str());
3552 commandModelList.append(item);
3557 QStandardItemModel* model =
new QStandardItemModel();
3559 model->setColumnCount(1);
3562 for (
int a= 0;
a< dirModelList.size();
a++) {
3563 model->appendRow(dirModelList.at(
a));
3565 for (
int a= 0;
a< subDirModelList.size();
a++) {
3566 model->appendRow(subDirModelList.at(
a));
3568 for (
int a= 0;
a< commandModelList.size();
a++) {
3569 model->appendRow(commandModelList.at(
a));
3571 for (
int a= 0;
a< subCommandModelList.size();
a++) {
3572 model->appendRow(subCommandModelList.at(
a));
3587 void G4UIQt::ShowHelpCallback (
3596 void G4UIQt::ClearButtonCallback (
3599 fCoutTBTextArea->clear();
3600 fG4OutputString.clear();
3605 void G4UIQt::ExitSession (
3611 void G4UIQt::ExitHelp(
3619 void G4UIQt::CommandEnteredCallback (
3623 fCommandArea->setText(fCommandArea->text().trimmed());
3624 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
3627 for (
int a=0;
a< list.size();
a++) {
3628 QString txt (list[
a].trimmed());
3630 fHistoryTBTableList->addItem(txt);
3631 fHistoryTBTableList->clearSelection();
3632 fHistoryTBTableList->setCurrentItem(NULL);
3633 fCommandArea->setText(
"");
3634 G4Qt* interactorManager = G4Qt::getInstance ();
3635 if (interactorManager) {
3636 interactorManager->FlushAndWaitExecution();
3639 G4String command = txt.toStdString().c_str();
3640 if (command(0,4) !=
"help") {
3641 ApplyShellCommand (command,exitSession,exitPause);
3643 ActivateCommand(command);
3648 fCommandArea->setFocus();
3654 UpdateCommandCompleter();
3656 if(exitSession==
true)
3665 void G4UIQt::CommandEditedCallback(
const QString &)
3667 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
3669 if (list.size() > 1) {
3670 for (
int a=0;
a<list.size()-1;
a++) {
3672 fCommandArea->setText(list[
a]);
3674 CommandEnteredCallback();
3677 fCommandArea->setText(list[list.size()-1]);
3684 void G4UIQt::VisParameterCallback(QWidget* widget){
3685 if (widget == NULL) {
3690 QGridLayout* grid =
dynamic_cast<QGridLayout*
>(widget->layout());
3695 #if QT_VERSION < 0x040400
3696 QWidget* name = grid->itemAt(grid->columnCount()*(grid->rowCount()-2))->widget();
3698 QWidget* name = grid->itemAtPosition(grid->rowCount()-1,0)->widget();
3700 if (dynamic_cast<QLabel*>(name) == 0) {
3703 command += (
dynamic_cast<QLabel*
>(
name))->text()+
" ";
3705 for (
int a=0;
a<grid->rowCount()-1;
a++) {
3706 #if QT_VERSION < 0x040400
3707 QWidget* widgetTmp = grid->itemAt(
a*grid->columnCount()+1)->widget();
3709 QWidget* widgetTmp = grid->itemAtPosition(
a,1)->widget();
3713 if (widgetTmp != NULL) {
3715 if (dynamic_cast<QLineEdit*>(widgetTmp) != 0) {
3716 command += (
dynamic_cast<QLineEdit*
>(widgetTmp))->text()+
" ";
3718 }
else if (dynamic_cast<QComboBox*>(widgetTmp) != 0){
3719 command += (
dynamic_cast<QComboBox*
>(widgetTmp))->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex())+
" ";
3722 }
else if (dynamic_cast<QPushButton*>(widgetTmp) != 0){
3723 command += widgetTmp->accessibleName()+
" ";
3726 }
else if (dynamic_cast<QWidget*>(widgetTmp) != 0){
3727 if (widgetTmp->layout()->count() > 0){
3728 if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != 0) {
3729 QAbstractButton * checked = (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton();
3731 command += (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton()->text()+
" ";
3739 if (command !=
"") {
3753 void G4UIQt::ButtonCallback (
3754 const QString& aCommand
3761 if(UI==NULL)
return;
3768 if (IsGUICommand(command)) {
3769 QDialog* menuParameterDialog =
new QDialog();
3771 if (CreateVisCommandGroupAndToolBox(command,menuParameterDialog,1,
true)) {
3772 menuParameterDialog->setWindowTitle (aCommand);
3773 menuParameterDialog->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
3776 menuParameterDialog->exec();
3779 delete menuParameterDialog;
3783 ApplyShellCommand(ss,exitSession,exitPause);
3788 if(exitSession==
true)
3796 void G4UIQt::HelpTreeClicCallback (
3799 QTreeWidgetItem* item = NULL;
3800 if (!fHelpTreeWidget)
3803 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
3806 item = list.first();
3811 if(UI==NULL)
return;
3814 std::string itemText = GetLongCommandPath(item).toStdString();
3817 if (item->childCount() > 0) {
3823 updateHelpArea(command);
3829 fParameterHelpLabel->setVisible(
true);
3831 fParameterHelpTable->setVisible(
false);
3838 void G4UIQt::HelpTreeDoubleClicCallback (
3841 HelpTreeClicCallback();
3843 QTreeWidgetItem* item = NULL;
3844 if (!fHelpTreeWidget)
3847 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
3850 item = list.first();
3854 fCommandArea->clear();
3855 fCommandArea->setText(GetLongCommandPath(item));
3862 void G4UIQt::CommandHistoryCallback(
3865 QListWidgetItem* item = NULL;
3866 if (!fHistoryTBTableList)
3870 QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
3873 item = list.first();
3876 fCommandArea->setText(item->text());
3880 void G4UIQt::ThreadComboBoxCallback(
int) {
3881 CoutFilterCallback(
"");
3885 void G4UIQt::CoutFilterCallback(
3888 FilterAllOutputTextArea();
3890 fCoutTBTextArea->repaint();
3891 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
3896 void G4UIQt::SaveOutputCallback(){
3897 QString fileName = QFileDialog::getSaveFileName(fMainWindow,
"Save console output as...", fLastOpenPath,
"Save output as...");
3898 if (fileName !=
"") {
3900 QFile data(fileName);
3901 if (data.open(QFile::WriteOnly | QFile::Truncate)) {
3902 QTextStream out(&data);
3903 out << fCoutTBTextArea->toPlainText();
3911 QString G4UIQt::FilterOutput(
3912 const G4UIOutputString& output
3913 ,
const QString& currentThread
3914 ,
const QString& filter
3917 #ifdef G4MULTITHREADED
3918 if ((currentThread ==
"All") ||
3919 (currentThread == output.fThread)) {
3921 if (currentThread ==
"") {
3923 if (output.fText.contains(QRegExp(filter))) {
3924 return output.fText;
3931 void G4UIQt::FilterAllOutputTextArea() {
3933 QString currentThread =
"";
3934 #ifdef G4MULTITHREADED
3935 currentThread = fThreadsFilterComboBox->currentText();
3936 if (currentThread ==
"Master") {
3940 QString filter = fCoutFilter->text();
3941 G4String previousOutputStream =
"";
3943 fCoutTBTextArea->clear();
3944 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3946 for (
unsigned int a=0;
a<fG4OutputString.size();
a++) {
3947 G4UIOutputString out = fG4OutputString[
a];
3948 if (FilterOutput(out,currentThread,filter) !=
"") {
3951 if (out.fOutputStream != previousOutputStream) {
3952 previousOutputStream = out.fOutputStream;
3953 if (out.fOutputStream ==
"info") {
3954 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3956 fCoutTBTextArea->setTextColor(QColor(
Qt::red));
3959 fCoutTBTextArea->
append(out.fText);
3962 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3970 void G4UIQt::LookForHelpStringCallback(
3973 fHelpLine->setText(fHelpLine->text().trimmed());
3974 QString searchText = fHelpLine->text();
3976 fParameterHelpLabel->setText(
"");
3977 fParameterHelpTable->setVisible(
false);
3978 if (searchText ==
"") {
3980 fHelpTreeWidget->clear();
3986 OpenHelpTreeOnCommand(searchText);
3991 void G4UIQt::OpenHelpTreeOnCommand(
3992 const QString & searchText
3997 if(UI==NULL)
return;
4003 fHelpTreeWidget->clear();
4009 QMap<int,QString> commandResultMap;
4010 QMap<int,QString> commandChildResultMap;
4012 for (
int a=0;
a<treeSize;
a++) {
4014 tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
4016 commandResultMap.insertMulti(tmp,QString((
char*)(treeTop->
GetTree(
a+1)->
GetPathName()).data()));
4019 commandChildResultMap = LookForHelpStringInChildTree(treeTop->
GetTree(
a+1),searchText);
4021 if (!commandChildResultMap.empty()) {
4022 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
4023 while (i != commandChildResultMap.constEnd()) {
4024 commandResultMap.insertMulti(i.key(),i.value());
4027 commandChildResultMap.clear();
4032 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
4033 fHelpTreeWidget->setColumnCount(2);
4035 labels << QString(
"Command") << QString(
"Match");
4036 fHelpTreeWidget->setHeaderLabels(labels);
4038 if (commandResultMap.empty()) {
4039 fParameterHelpLabel->setText(
"No match found");
4040 fParameterHelpTable->setVisible(
false);
4044 QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
4047 float multValue = 10.0/(float)(i.key());
4048 QString progressChar =
"|";
4049 QString progressStr =
"|";
4051 QTreeWidgetItem * newItem;
4054 if (i == commandResultMap.constBegin()) {
4057 for(
int a=0;
a<int(i.key()*multValue);
a++) {
4058 progressStr += progressChar;
4060 newItem =
new QTreeWidgetItem();
4061 QString commandStr = i.value().trimmed();
4063 if (commandStr.indexOf(
"/") == 0) {
4064 commandStr = commandStr.right(commandStr.size()-1);
4067 newItem->setText(0,commandStr);
4068 newItem->setText(1,progressStr);
4069 fHelpTreeWidget->addTopLevelItem(newItem);
4070 #if QT_VERSION < 0x040200
4072 newItem->setForeground ( 1, QBrush(
Qt::blue) );
4077 fHelpTreeWidget->resizeColumnToContents (0);
4078 fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
4085 QMap<int,QString> G4UIQt::LookForHelpStringInChildTree(
4087 ,
const QString & text
4090 QMap<int,QString> commandResultMap;
4091 if (aCommandTree == NULL)
return commandResultMap;
4096 QMap<int,QString> commandChildResultMap;
4100 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
4102 commandResultMap.insertMulti(tmp,QString((
char*)(aCommandTree->
GetTree(
a+1)->
GetPathName()).data()));
4105 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->
GetTree(
a+1),text);
4107 if (!commandChildResultMap.empty()) {
4109 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
4110 while (i != commandChildResultMap.constEnd()) {
4111 commandResultMap.insertMulti(i.key(),i.value());
4114 commandChildResultMap.clear();
4121 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
4127 return commandResultMap;
4131 QString G4UIQt::GetShortCommandPath(
4135 if (commandPath.indexOf(
"/") == 0) {
4136 commandPath = commandPath.right(commandPath.size()-1);
4139 commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf(
"/",-2)-1);
4141 if (commandPath.lastIndexOf(
"/") == (commandPath.size()-1)) {
4142 commandPath = commandPath.left(commandPath.size()-1);
4149 QString G4UIQt::GetLongCommandPath(
4150 QTreeWidgetItem* item
4153 if (item == NULL)
return "";
4156 QString itemText =
"";
4157 itemText = item->text(0);
4159 while (item->parent() != NULL) {
4160 itemText = item->parent()->text(0)+
"/"+itemText;
4161 item = item->parent();
4163 itemText =
"/"+itemText;
4169 void G4UIQt::ChangeColorCallback(QWidget* widget) {
4170 if (widget == NULL) {
4174 QPushButton* button =
dynamic_cast<QPushButton*
>(widget);
4178 QString value = button->accessibleName();
4181 old.setRgbF(value.section(
" ",0,1).toDouble(),
4182 value.section(
" ",1,2).toDouble(),
4183 value.section(
" ",2,3).toDouble());
4184 #if QT_VERSION < 0x040500
4186 QColor color = QColor(QColorDialog::getRgba (old.rgba(),&
a,fUITabWidget));
4188 QColor color = QColorDialog::getColor(old,
4191 QColorDialog::ShowAlphaChannel);
4195 if (color.isValid()) {
4197 QPixmap pixmap = QPixmap(QSize(16, 16));
4198 pixmap.fill (color);
4199 QPainter painter(&pixmap);
4200 painter.setPen(Qt::black);
4201 painter.drawRect(0,0,15,15);
4203 button->setAccessibleName(QString::number(color.redF())+
" "+
4204 QString::number(color.greenF())+
" "+
4205 QString::number(color.blueF())+
" "
4207 button->setIcon(pixmap);
4214 void G4UIQt::ChangeCursorAction(
const QString& action) {
4218 fMoveSelected =
true;
4219 fPickSelected =
true;
4220 fRotateSelected =
true;
4221 fZoomInSelected =
true;
4222 fZoomOutSelected =
true;
4224 if (fToolbarApp == NULL)
return;
4225 QList<QAction *> list = fToolbarApp->actions ();
4226 for (
int i = 0; i < list.size(); ++i) {
4227 if (list.at(i)->data().toString () == action) {
4228 list.at(i)->setChecked(
TRUE);
4229 if (list.at(i)->data().toString () ==
"pick") {
4231 CreatePickInfosDialog();
4233 fPickInfosDialog->show();
4234 fPickInfosDialog->raise();
4235 fPickInfosDialog->activateWindow();
4237 }
else if (list.at(i)->data().toString () ==
"move") {
4238 fMoveSelected =
false;
4239 list.at(i)->setChecked(
FALSE);
4240 }
else if (list.at(i)->data().toString () ==
"pick") {
4241 fPickSelected =
false;
4242 list.at(i)->setChecked(
FALSE);
4244 fPickInfosDialog->hide();
4245 }
else if (list.at(i)->data().toString () ==
"rotate") {
4246 fRotateSelected =
false;
4247 list.at(i)->setChecked(
FALSE);
4248 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4249 fZoomInSelected =
false;
4250 list.at(i)->setChecked(
FALSE);
4251 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4252 fZoomOutSelected =
false;
4253 list.at(i)->setChecked(
FALSE);
4266 void G4UIQt::ChangeSurfaceStyle(
const QString& action) {
4270 if (fToolbarApp == NULL)
return;
4271 QList<QAction *> list = fToolbarApp->actions ();
4272 for (
int i = 0; i < list.size(); ++i) {
4273 if (list.at(i)->data().toString () == action) {
4274 list.at(i)->setChecked(
TRUE);
4275 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4276 list.at(i)->setChecked(
FALSE);
4277 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4278 list.at(i)->setChecked(
FALSE);
4279 }
else if (list.at(i)->data().toString () ==
"solid") {
4280 list.at(i)->setChecked(
FALSE);
4281 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4282 list.at(i)->setChecked(
FALSE);
4287 if (action ==
"hidden_line_removal") {
4291 }
else if (action ==
"hidden_line_and_surface_removal") {
4295 }
else if (action ==
"solid") {
4299 }
else if (action ==
"wireframe") {
4306 void G4UIQt::OpenIconCallback(
const QString& aParam) {
4308 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4309 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
4311 QString nomFich = QFileDialog::getOpenFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
4312 if (nomFich !=
"") {
4315 fLastOpenPath = dir.absoluteFilePath(nomFich);
4320 void G4UIQt::SaveIconCallback(
const QString& aParam) {
4322 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4323 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
4325 QString nomFich = QFileDialog::getSaveFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
4326 if (nomFich !=
"") {
4329 fLastOpenPath = dir.absoluteFilePath(nomFich);
4334 void G4UIQt::CreateViewerPropertiesDialog() {
4336 if (fViewerPropertiesDialog != NULL) {
4339 fViewerPropertiesDialog =
new QDialog();
4341 fViewerPropertiesDialog->setWindowTitle(
"Viewer properties");
4342 fViewerPropertiesDialog->setSizePolicy (QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
4344 if (!fViewerPropertiesWidget) {
4345 fViewerPropertiesWidget =
new QWidget();
4346 QVBoxLayout* layoutPropertiesWidget =
new QVBoxLayout();
4347 fViewerPropertiesWidget->setLayout(layoutPropertiesWidget);
4349 CreateEmptyViewerPropertiesWidget();
4352 QVBoxLayout* layoutDialog =
new QVBoxLayout();
4354 layoutDialog->addWidget(fViewerPropertiesWidget);
4355 layoutDialog->setContentsMargins(0,0,0,0);
4356 fViewerPropertiesDialog->setLayout(layoutDialog);
4360 void G4UIQt::CreatePickInfosDialog() {
4362 if (fPickInfosDialog != NULL) {
4365 fPickInfosDialog =
new QDialog();
4367 fPickInfosDialog->setWindowTitle(
"Pick infos");
4368 fPickInfosDialog->setSizePolicy (QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
4370 if (!fPickInfosWidget) {
4371 fPickInfosWidget =
new QWidget();
4372 QVBoxLayout* layoutPickInfos =
new QVBoxLayout();
4373 fPickInfosWidget->setLayout(layoutPickInfos);
4375 CreateEmptyPickInfosWidget();
4378 QVBoxLayout* layoutDialog =
new QVBoxLayout();
4380 layoutDialog->addWidget(fPickInfosWidget);
4381 layoutDialog->setContentsMargins(0,0,0,0);
4382 fPickInfosDialog->setLayout(layoutDialog);
4386 void G4UIQt::CreateEmptyViewerPropertiesWidget() {
4387 QLayoutItem * wItem;
4388 if (fViewerPropertiesWidget->layout()->count()) {
4389 while ((wItem = fViewerPropertiesWidget->layout()->takeAt(0)) != 0) {
4390 delete wItem->widget();
4395 QLabel* label =
new QLabel(
"No viewer - Please open a viewer first");
4396 fViewerPropertiesWidget->layout()->addWidget(label);
4397 fViewerPropertiesDialog->setWindowTitle(
"No viewer");
4401 void G4UIQt::CreateEmptyPickInfosWidget() {
4402 QLayoutItem * wItem;
4403 if (fPickInfosWidget->layout()->count()) {
4404 while ((wItem = fPickInfosWidget->layout()->takeAt(0)) != 0) {
4405 delete wItem->widget();
4410 QLabel* label =
new QLabel(
"Click on the object you want to pick");
4411 fPickInfosWidget->layout()->addWidget(label);
4412 fPickInfosDialog->setWindowTitle(
"Nothing to pick");
4416 void G4UIQt::ViewerPropertiesIconCallback(
int) {
4418 CreateViewerPropertiesDialog();
4420 fViewerPropertiesDialog->show();
4421 fViewerPropertiesDialog->raise();
4422 fViewerPropertiesDialog->activateWindow();
4426 void G4UIQt::ChangePerspectiveOrtho(
const QString& action) {
4430 if (fToolbarApp == NULL)
return;
4431 QList<QAction *> list = fToolbarApp->actions ();
4432 QString checked =
"";
4433 for (
int i = 0; i < list.size(); ++i) {
4434 if (list.at(i)->data().toString () == action) {
4435 list.at(i)->setChecked(
TRUE);
4436 checked = list.at(i)->data().toString ();
4437 }
else if (list.at(i)->data().toString () ==
"persepective") {
4438 list.at(i)->setChecked(
FALSE);
4439 }
else if (list.at(i)->data().toString () ==
"ortho") {
4440 list.at(i)->setChecked(
FALSE);
4444 if ((action ==
"ortho") && (checked ==
"ortho")) {
4446 }
else if ((action ==
"perspective") && (checked ==
"perspective")) {
4453 void G4UIQt::SetIconMoveSelected() {
4455 fMoveSelected =
true;
4456 fRotateSelected =
false;
4457 fPickSelected =
false;
4458 fZoomInSelected =
false;
4459 fZoomOutSelected =
false;
4461 if (fToolbarApp == NULL)
return;
4462 QList<QAction *> list = fToolbarApp->actions ();
4463 for (
int i = 0; i < list.size(); ++i) {
4464 if (list.at(i)->data().toString () ==
"move") {
4465 list.at(i)->setChecked(
TRUE);
4466 }
else if (list.at(i)->data().toString () ==
"rotate") {
4467 list.at(i)->setChecked(
FALSE);
4468 }
else if (list.at(i)->data().toString () ==
"pick") {
4469 list.at(i)->setChecked(
FALSE);
4470 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4471 list.at(i)->setChecked(
FALSE);
4472 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4473 list.at(i)->setChecked(
FALSE);
4479 void G4UIQt::SetIconRotateSelected() {
4481 fRotateSelected =
true;
4482 fMoveSelected =
false;
4483 fPickSelected =
false;
4484 fZoomInSelected =
false;
4485 fZoomOutSelected =
false;
4487 if (fToolbarApp == NULL)
return;
4488 QList<QAction *> list = fToolbarApp->actions ();
4489 for (
int i = 0; i < list.size(); ++i) {
4490 if (list.at(i)->data().toString () ==
"rotate") {
4491 list.at(i)->setChecked(
TRUE);
4492 }
else if (list.at(i)->data().toString () ==
"move") {
4493 list.at(i)->setChecked(
FALSE);
4494 }
else if (list.at(i)->data().toString () ==
"pick") {
4495 list.at(i)->setChecked(
FALSE);
4496 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4497 list.at(i)->setChecked(
FALSE);
4498 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4499 list.at(i)->setChecked(
FALSE);
4505 void G4UIQt::SetIconPickSelected() {
4507 fPickSelected =
true;
4508 fMoveSelected =
false;
4509 fRotateSelected =
false;
4510 fZoomInSelected =
false;
4511 fZoomOutSelected =
false;
4513 QToolBar*
bar = fToolbarApp;
4514 if (!fDefaultIcons) {
4519 QList<QAction *> list = bar->actions ();
4520 for (
int i = 0; i < list.size(); ++i) {
4521 if (list.at(i)->data().toString () ==
"pick") {
4522 list.at(i)->setChecked(
TRUE);
4523 }
else if (list.at(i)->data().toString () ==
"move") {
4524 list.at(i)->setChecked(
FALSE);
4525 }
else if (list.at(i)->data().toString () ==
"rotate") {
4526 list.at(i)->setChecked(
FALSE);
4527 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4528 list.at(i)->setChecked(
FALSE);
4529 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4530 list.at(i)->setChecked(
FALSE);
4536 void G4UIQt::SetIconZoomInSelected() {
4538 fZoomInSelected =
true;
4539 fMoveSelected =
false;
4540 fRotateSelected =
false;
4541 fPickSelected =
false;
4542 fZoomOutSelected =
false;
4544 QToolBar* bar = fToolbarApp;
4545 if (!fDefaultIcons) {
4550 QList<QAction *> list = bar->actions ();
4551 for (
int i = 0; i < list.size(); ++i) {
4552 if (list.at(i)->data().toString () ==
"zoom_in") {
4553 list.at(i)->setChecked(
TRUE);
4554 }
else if (list.at(i)->data().toString () ==
"move") {
4555 list.at(i)->setChecked(
FALSE);
4556 }
else if (list.at(i)->data().toString () ==
"rotate") {
4557 list.at(i)->setChecked(
FALSE);
4558 }
else if (list.at(i)->data().toString () ==
"pick") {
4559 list.at(i)->setChecked(
FALSE);
4560 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4561 list.at(i)->setChecked(
FALSE);
4567 void G4UIQt::SetIconZoomOutSelected() {
4569 fZoomOutSelected =
true;
4570 fMoveSelected =
false;
4571 fRotateSelected =
false;
4572 fPickSelected =
false;
4573 fZoomInSelected =
false;
4575 QToolBar* bar = fToolbarApp;
4576 if (!fDefaultIcons) {
4581 QList<QAction *> list = bar->actions ();
4582 for (
int i = 0; i < list.size(); ++i) {
4583 if (list.at(i)->data().toString () ==
"zoom_out") {
4584 list.at(i)->setChecked(
TRUE);
4585 }
else if (list.at(i)->data().toString () ==
"move") {
4586 list.at(i)->setChecked(
FALSE);
4587 }
else if (list.at(i)->data().toString () ==
"rotate") {
4588 list.at(i)->setChecked(
FALSE);
4589 }
else if (list.at(i)->data().toString () ==
"pick") {
4590 list.at(i)->setChecked(
FALSE);
4591 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4592 list.at(i)->setChecked(
FALSE);
4598 void G4UIQt::SetIconSolidSelected() {
4601 QToolBar* bar = fToolbarApp;
4602 if (!fDefaultIcons) {
4607 QList<QAction *> list = bar->actions ();
4608 for (
int i = 0; i < list.size(); ++i) {
4609 if (list.at(i)->data().toString () ==
"solid") {
4610 list.at(i)->setChecked(
TRUE);
4611 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4612 list.at(i)->setChecked(
FALSE);
4613 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4614 list.at(i)->setChecked(
FALSE);
4615 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4616 list.at(i)->setChecked(
FALSE);
4622 void G4UIQt::SetIconWireframeSelected() {
4625 QToolBar* bar = fToolbarApp;
4626 if (!fDefaultIcons) {
4631 QList<QAction *> list = bar->actions ();
4632 for (
int i = 0; i < list.size(); ++i) {
4633 if (list.at(i)->data().toString () ==
"wireframe") {
4634 list.at(i)->setChecked(
TRUE);
4635 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4636 list.at(i)->setChecked(
FALSE);
4637 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4638 list.at(i)->setChecked(
FALSE);
4639 }
else if (list.at(i)->data().toString () ==
"solid") {
4640 list.at(i)->setChecked(
FALSE);
4646 void G4UIQt::SetIconHLRSelected() {
4649 QToolBar* bar = fToolbarApp;
4650 if (!fDefaultIcons) {
4656 QList<QAction *> list = bar->actions ();
4657 for (
int i = 0; i < list.size(); ++i) {
4658 if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4659 list.at(i)->setChecked(
TRUE);
4660 }
else if (list.at(i)->data().toString () ==
"solid") {
4661 list.at(i)->setChecked(
FALSE);
4662 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4663 list.at(i)->setChecked(
FALSE);
4664 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4665 list.at(i)->setChecked(
FALSE);
4671 void G4UIQt::SetIconHLHSRSelected() {
4674 QToolBar* bar = fToolbarApp;
4675 if (!fDefaultIcons) {
4681 QList<QAction *> list = bar->actions ();
4682 for (
int i = 0; i < list.size(); ++i) {
4683 if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4684 list.at(i)->setChecked(
TRUE);
4685 }
else if (list.at(i)->data().toString () ==
"solid") {
4686 list.at(i)->setChecked(
FALSE);
4687 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4688 list.at(i)->setChecked(
FALSE);
4689 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4690 list.at(i)->setChecked(
FALSE);
4696 void G4UIQt::SetIconPerspectiveSelected() {
4699 QToolBar* bar = fToolbarApp;
4700 if (!fDefaultIcons) {
4706 QList<QAction *> list = bar->actions ();
4707 for (
int i = 0; i < list.size(); ++i) {
4708 if (list.at(i)->data().toString () ==
"perspective") {
4709 list.at(i)->setChecked(
TRUE);
4710 }
else if (list.at(i)->data().toString () ==
"ortho") {
4711 list.at(i)->setChecked(
FALSE);
4718 void G4UIQt::SetIconOrthoSelected() {
4721 QToolBar* bar = fToolbarApp;
4722 if (!fDefaultIcons) {
4728 QList<QAction *> list = bar->actions ();
4729 for (
int i = 0; i < list.size(); ++i) {
4730 if (list.at(i)->data().toString () ==
"ortho") {
4731 list.at(i)->setChecked(
TRUE);
4732 }
else if (list.at(i)->data().toString () ==
"perspective") {
4733 list.at(i)->setChecked(
FALSE);
4740 G4QTabWidget::G4QTabWidget(
4744 ):QTabWidget(aParent)
4745 ,fTabSelected(false)
4747 ,fPreferedSizeX(sizeX+6)
4748 ,fPreferedSizeY(sizeY+58)
4750 setMinimumSize(100,100);
4751 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
4752 setSizePolicy(policy);
4755 G4QTabWidget::G4QTabWidget(
4757 ,fTabSelected(false)
4765 G4UIOutputString::G4UIOutputString(
4773 if (!GetOutputList().contains(QString(
" ")+outputStream+
" ")) {
4774 fOutputStream =
"info";
4776 fOutputStream = outputStream;
4781 #if QT_VERSION < 0x040500
4782 void G4UIQt::TabCloseCallback(
int){
4784 void G4UIQt::TabCloseCallback(
int a){
4786 #if QT_VERSION < 0x040500
4788 if (fViewerTabWidget == NULL)
return;
4791 QWidget* temp = fViewerTabWidget->widget(a);
4793 fViewerTabWidget->removeTab (a);
4796 bool lastTab =
true;
4797 for (
int c=0; c<fViewerTabWidget->count(); c++) {
4798 if (fViewerTabWidget->tabText(c).contains(
"viewer")) {
4804 CreateEmptyViewerPropertiesWidget();
4812 void G4UIQt::ToolBoxActivated(
int a){
4814 if (fUITabWidget->widget(a) == fHelpTBWidget) {
4817 }
else if (fUITabWidget->widget(a) == fSceneTreeWidget) {
4818 #if QT_VERSION < 0x040200
4819 fSceneTreeWidget->show();
4821 fSceneTreeWidget->setVisible(
true);
4827 void G4QTabWidget::paintEvent(
4832 if (currentWidget()) {
4834 if ( isTabSelected()) {
4838 QString text = tabText (currentIndex());
4840 if (fLastCreated == -1) {
4841 QTextEdit* edit =
dynamic_cast<QTextEdit*
>(currentWidget());
4843 QString paramSelect = QString(
"/vis/viewer/select ")+text;
4852 setTabSelected(
false);
4858 G4UIDockWidget::G4UIDockWidget(QString txt):
4863 void G4UIDockWidget::closeEvent(QCloseEvent *aEvent) {
4864 setFloating (
false);
G4UIcommandTree * FindCommandTree(const char *commandPath)
Try to match a command or a path with the one given.
G4MTcoutDestination * GetThreadCout()
G4String GetParameterCandidates() const
const G4String & GetRange() const
G4String & remove(str_size)
std::vector< ExP01TrackerHit * > a
G4UIcommand * FindPath(const char *commandPath) const
G4String strip(G4int strip_Type=trailing, char c=' ')
G4int GetCommandEntry() const
G4String GetParameterName() const
G4UIcommand * GetCommand(G4int i)
G4String GetFullPrefixString() const
G4int GetTreeEntry() const
const char * name(G4int ptype)
G4int GetVerboseLevel() const
void SetSession(G4UIsession *const value)
const G4String & GetGuidanceLine(G4int i) const
#define G4MUTEX_INITIALIZER
void SetG4UIWindow(G4UIsession *const value)
static G4UImanager * GetUIpointer()
G4bool IsOmittable() const
G4String GetPrefixString() const
static G4StateManager * GetStateManager()
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4UIcommandTree * GetTree(G4int i)
G4UIparameter * GetParameter(G4int i) const
const G4String & GetCommandPath() const
G4ApplicationState GetCurrentState() const
G4String GetFirstMatchedString(const G4String &, const G4String &) const
const G4String GetPathName() const
G4bool contains(const std::string &) const
const char * data() const
const G4String GetTitle() const
G4UIcommandTree * GetTree() const
G4String & append(const G4String &)
G4String GetDefaultValue() const
void SetCoutDestination(G4UIsession *const value)
const G4UIcommand * GetGuidance() const
char GetParameterType() const
const G4String GetParameterGuidance() const
static constexpr double bar
G4String GetParameterRange() const
G4int GetGuidanceEntries() const
G4int GetParameterEntries() const
G4String FindMacroPath(const G4String &fname) const
G4bool GetCurrentAsDefault() const
static const G4double pos
G4int ApplyCommand(const char *aCommand)