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();
211 fMainWindow->setAttribute(Qt::WA_DeleteOnClose);
213 fMainWindow->setCorner( Qt::TopLeftCorner, Qt::LeftDockWidgetArea );
214 fMainWindow->setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
215 fMainWindow->setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
216 fMainWindow->setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
218 CreateViewerWidget();
219 fMainWindow->addDockWidget(Qt::LeftDockWidgetArea, CreateUITabWidget());
220 fMainWindow->addDockWidget(Qt::BottomDockWidgetArea, CreateCoutTBWidget());
224 SetDefaultIconsToolbar();
228 #ifdef G4MULTITHREADED
230 masterG4coutDestination =
this;
233 fMainWindow->setWindowTitle(QFileInfo( QCoreApplication::applicationFilePath() ).fileName());
234 fMainWindow->move(QPoint(50,50));
239 fMainWindow->resize(fUIDockWidget->width()+fCoutDockWidget->width()+20,
240 fUIDockWidget->height()+fCoutDockWidget->height()+20);
243 fCommandArea->setFocus(Qt::TabFocusReason);
247 qRegisterMetaType<QTextCursor>(
"QTextCursor");
250 AddTabWidget(fStartPage,
"Useful tips");
253 #if QT_VERSION < 0x040200
256 fMainWindow->setVisible(
false);
270 #ifdef G4MULTITHREADED
271 masterG4coutDestination = 0;
277 void G4UIQt::DefaultIcons(
bool aVal)
279 fDefaultIcons = aVal;
281 #if QT_VERSION < 0x040200
282 if (!fMainWindow->isHidden()) {
284 if (!fMainWindow->isVisible()) {
291 #if QT_VERSION < 0x040200
294 fToolbarApp->setVisible(
true);
298 #if QT_VERSION < 0x040200
301 fToolbarApp->setVisible(
false);
308 void G4UIQt::SetDefaultIconsToolbar(
312 if (fToolbarApp == NULL) {
313 fToolbarApp =
new QToolBar();
314 fToolbarApp->setIconSize (QSize(20,20));
315 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
319 AddIcon(
"Open macro file",
"open",
"/control/execute");
320 AddIcon(
"Save viewer state",
"save",
"/vis/viewer/save");
323 QSignalMapper *signalMapperViewerProperties =
new QSignalMapper(
this);
324 QAction *actionViewerProperties = fToolbarApp->addAction(QIcon(*fParamIcon),
"Viewer properties", signalMapperViewerProperties, SLOT(map()));
325 connect(signalMapperViewerProperties, SIGNAL(mapped(
int)),
this, SLOT(ViewerPropertiesIconCallback(
int)));
327 signalMapperViewerProperties->setMapping(actionViewerProperties, intVP);
330 AddIcon(
"Move",
"move",
"");
331 AddIcon(
"Pick",
"pick",
"");
332 AddIcon(
"Zoom out",
"zoom_out",
"");
333 AddIcon(
"Zoom in",
"zoom_in",
"");
334 AddIcon(
"Rotate",
"rotate",
"");
337 AddIcon(
"Hidden line removal",
"hidden_line_removal",
"");
338 AddIcon(
"Hidden line and hidden surface removal",
"hidden_line_and_surface_removal",
"");
339 AddIcon(
"Surfaces",
"solid",
"");
340 AddIcon(
"Wireframe",
"wireframe",
"");
343 AddIcon(
"Perspective",
"perspective",
"");
344 AddIcon(
"Orthographic",
"ortho",
"");
345 AddIcon(
"Run beam on",
"runBeamOn",
"/run/beamOn 1");
350 void G4UIQt::CreateIcons(
353 const char *
const save[]={
381 " +++++++++++++++++++++++++ ",
382 " +@##+$%%%%%%%%%%%%%%%&*$%&+ ",
383 " +=-;@>,,''',,,,,,,',,)&!,)+ ",
384 " +;-~@>,,,,,,,,,,,,,,,>$!,)+ ",
385 " +=-~@>,,,,,{]]]]]^,,,>*&$&+ ",
386 " +=-~@>,,,,,'{^{^^{,,,>*#=#+ ",
387 " +=-~@>,,,,,,,,,,,,,,,>@~/=+ ",
388 " +=-~@>,,,{{{''''{',,,>@~-=+ ",
389 " +=-~@>,,'^]]]]]]({,,,>@~-=+ ",
390 " +=-~@>,,,{{{{{{{{{,,,>@~-=+ ",
391 " +=-~@>,,,,,'{^{{^{,,,>@~-=+ ",
392 " +=-~@>,,,,,]]]]]]],,,>@~-=+ ",
393 " +=-~*>,,,,,,,,,,,,,,,>@~-=+ ",
394 " +=-~@>,,,,,,,,,,,,,,,>@~-=+ ",
395 " +=-/=$%%%%%%%%%%%%%%%$=/-=+ ",
396 " +=---;###############;---=+ ",
397 " +=---////////////////----=+ ",
398 " +=----------------///----=+ ",
399 " +=---=@##############@#--=+ ",
400 " +=---@+++++++++++*%))_+~-=+ ",
401 " +=---#+++++++++++&:,,>@~-=+ ",
402 " +=---#+++++++++++$',,>@~-=+ ",
403 " +=---#+++++++++++&!,,>@~-=+ ",
404 " +=/--#+++++++++++&',,>@~-=+ ",
405 " @;--#+++++++++++$',,>@~-=+ ",
406 " @;;@+++++++++++*)!>%@=;#+ ",
407 " @++++++++++++++*&**++@++ ",
412 fSaveIcon =
new QPixmap(save);
414 const char *
const search[] = {
426 "OOOOOOOOOOOOOOOOOOO",
427 "OOOOOOOOOOOOOOOOOOO",
428 "OOOOOOOo. .oOOOOOO",
431 "OOOOO. XOOOOX .OOOO",
434 "OOOOO. XOOOOo .OOOO",
438 "OOOOOOOOOOOOO. XOO",
439 "OOOOOOOOOOOOOO. XOO",
440 "OOOOOOOOOOOOOOOoOOO",
441 "OOOOOOOOOOOOOOOOOOO",
442 "OOOOOOOOOOOOOOOOOOO",
443 "OOOOOOOOOOOOOOOOOOO",
444 "OOOOOOOOOOOOOOOOOOO"
446 fSearchIcon =
new QPixmap(search);
448 const char *
const clear[] = {
460 "OOOOOOOOOOOOOOOOOOOO",
463 "OOOOOOOOOOOOOOOOOOOO",
464 "OOOOOOOOOOOOOOOOOOOO",
465 "OOOO XXXXXXXXXX OOOO",
466 "OOO XOOOOOOOOOO OOO",
467 "OOOOXOooOooOooO OOOO",
468 "OOOOXOooOooOooO OOOO",
469 "OOOOXOooOooOooO OOOO",
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 "OOOOOooooooooooOOOOO",
479 "OOOOOO........OOOOOO"
482 fClearIcon =
new QPixmap(clear);
485 const char *
const open[]={
529 " {]^/((_({- %%%%%%%%%%% ",
530 " {(^_^^^^:<{{{{{{{{{{{{{[& ",
531 " {/_/(((((/]]]]]]]]]]]/]!# ",
532 " {/^(((((_^^^^^^^^^^^^^^:# ",
533 " {/^(((_^^____________^^}$ ",
534 " {/^(((((/////////////((!# ",
535 " {/^/^_:<|||||||||||||||@@****1 ",
536 " {/^/^(<[)||||||||||||||))!!}<; ",
537 " {/^_(:|234444444444444444432)1 ",
538 " {/_^/<)34444444444444444443}, ",
539 " {/^(2{:41111111111111111142|5 ",
540 " {3^3<:31111111111111111143}- ",
541 " {/^2<:31111111111111111441|' ",
542 " {_/<:41111111111111111143}, ",
543 " {(4<:31111111111111111144!# ",
544 " )4))44111111111111111144}, ",
545 " )2<:31111111111111111144{# ",
546 " @|:14444444444444444444}* ",
547 " ;@434444444444444444434<# ",
548 " ;[))))))))))))))))))))!~ ",
549 " ++++++++++++++++++++++;% ",
553 fOpenIcon =
new QPixmap(open);
556 const char *
const move[]={
589 " ')&$$$$*@@ @@*$$$$&)' ",
590 " ')&$$$$*@@ @@*$$$$&+' ",
607 fMoveIcon =
new QPixmap(move);
609 const char *
const rotate[]={
645 " --------!*{{{*&, ",
646 " -------=){*{{{>>{) ",
647 " ,!-----= ){& ,&{{@",
655 " !-!!======!!(((---! ",
656 " ='--------------! ",
671 fRotateIcon =
new QPixmap(rotate);
673 const char *
const pick[]={
689 "*********oo*********",
690 "*********oo*********",
691 "******$O. .O%******",
692 "****&o .O..O O*****",
693 "***&X @**oo**@ X****",
694 "***o $***oo***$ O***",
695 "**% @**********@ %**",
696 "**O.***********& +**",
697 "**.O*****@@*****o.**",
698 "oo .oo**@ #*&XX. oo",
699 "oo .oo**@ #*&oo. oO",
700 "**.O*****##*****oX**",
701 "**O ***********& +**",
702 "**% @****&&****+ &**",
703 "***O $***Xo***# +***",
704 "****X @&*Xo*&+ o****",
705 "*****O o..o +*****",
706 "******%+. X+&******",
707 "*********oo*********",
708 "*********oO*********"
710 fPickIcon =
new QPixmap(pick);
712 const char *
const zoom_in[]={
734 " ++.%%%+&&&*%%.++ ",
735 " .+#%%%%+&&&*%%.#+ ",
736 " ++..%%%+&&&*%%%.++ ",
737 " +#.+++++&&&*++++.+ ",
738 " @.+&&&&&&&&&&&&&+@ ",
739 " @#+&&&&&&&&&&&&&+@ ",
740 " @.+&&&&&&&&&&&&&+. ",
741 " +++@***+&&&****@+. ",
742 " ....++++&&&*++++.. ",
743 " ++.===+&&&*%=.++ ",
744 " @..==+&&&*=..@#& ",
745 " .@+#.+&&&@-+@@*@ ",
758 fZoomInIcon =
new QPixmap(zoom_in);
760 const char *
const zoom_out[]={
782 " ++.$$$$$$$$$$.++ ",
783 " .+#$$$$$$$$$$$.#+ ",
784 " ++..$$$$$$$$$$$.++ ",
785 " +#.+++++++++++++.+ ",
786 " @.+&&&&&&&&&&&&&+@ ",
787 " @#+&&&&&&&&&&&&&+@ ",
788 " @.+&&&&&&&&&&&&&+. ",
789 " +++@***********@+. ",
790 " ....++++++++++++.. ",
791 " ++.===$$$$$$=.++ ",
792 " @..===$$$$=..@#& ",
793 " .@+#.$$$..-+@@*@ ",
806 fZoomOutIcon =
new QPixmap(zoom_out);
808 const char *
const wireframe[]={
837 " +&********&@-***; ",
838 " +@@@&**&@@@@@@$ @*-&>&+ ",
839 " +*****&+ %*@ ,**'# ",
840 " @***)!~ @*{&*****+ ",
841 " @*!]***&+ +-*^**'~!*@ ",
842 " @*~ +@&**&@@@@@@&****&+ ~*@ ",
843 " @*@ +&********&-*= @*@ ",
844 " @*@ $%@-*-@$ @*@ @*@ ",
852 " @*@ =*-+ @*@ @*@ ",
853 " @*@ $%@@&****&@-*-+ @*@ ",
854 " @*@ $@&*****&@@&******&~~!*@ ",
855 " @*{/***&@@%$ $@-*-&*****+ ",
856 " @*)*)(-~ @*@ ~)**] ",
857 " +*******&@@@@+ %*_+]**] ",
858 " +@@@@@&******&@%+_*^**]# ",
867 fWireframeIcon =
new QPixmap(wireframe);
869 const char *
const solid[]={
907 " +-;>>>>>>>>>,')!~ ",
908 " {]@@-;>>>>>>>>>>>>^/(_= ",
909 " {:>>>>>>>>>>>>>>>>><//[)!= ",
910 " ]>>>>>>>>>>>>>>>>>><////[)} ",
911 " @>>>>>>>>>>>>>>>>>><//////| ",
912 " @>>>>>>>>>>>>>>>>>><//////| ",
913 " @>>>>>>>>>>>>>>>>>><//////| ",
914 " @>>>>>>>>>>>>>>>>>><//////| ",
915 " @>>>>>>>>>>>>>>>>>><//////| ",
916 " @>>>>>>>>>>>>>>>>>><//////| ",
917 " @>>>>>>>>>>>>>>>>>><//////| ",
918 " @>>>>>>>>>>>>>>>>>><//////| ",
919 " @>>>>>>>>>>>>>>>>>><//////| ",
920 " @>>>>>>>>>>>>>>>>>><//////| ",
921 " @>>>>>>>>>>>>>>>>>><//////| ",
922 " @>>>>>>>>>>>>>>>>>><//////| ",
923 " @>>>>>>>>>>>>>>>>>><//////| ",
924 " @>>>>>>>>>>>>>>>>>><//////| ",
925 " @>>>>>>>>>>>>>>>>>></////[1 ",
926 " @>>>>>>>>>>>>>>>>>><////[*2 ",
927 " {:>>>>>>>>>>>>>>>>><//[)12 ",
928 " +@@@@@-;>>>>>>>>>><[)13 ",
937 fSolidIcon =
new QPixmap(solid);
939 const char *
const hidden_line_removal[]={
959 " +#$$$$$$$$#@&$$$* ",
960 " =-@@#$$#@@@@@-= @$&#;>= ",
961 " =$$$$$#+ -$@ *$$%+ ",
962 " -$&@-= -$- #$$$= ",
978 " -$&@@@-= -$- =>;, ",
979 " =$$$$$$$#@@@-= -$'+#$$, ",
980 " =-@@@@#$$$$$$#@-+'$)$$#+ ",
989 fHiddenLineRemovalIcon =
new QPixmap(hidden_line_removal);
991 const char *
const hidden_line_and_surface_removal[]={
1037 " ++@%####&*=-#+;>, ",
1038 " +++++@'=)))))))!)~+{]^++ ",
1039 " +$%&*=)!!!!!!!!!)~+/(]_+++ ",
1040 " +#-))!!!!!!!!!!!)~+/(::<[+ ",
1041 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1042 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1043 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1044 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1045 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1046 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1047 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1048 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1049 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1050 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1051 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1052 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1053 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1054 " +#)!!!!!!!!!!!!!!}+/:::|1+ ",
1055 " +$#}}~23!!!!!!!!)~+/(]45, ",
1056 " +++++++@#}}~23!!)~+678++ ",
1057 " ++++++@#~90+a++ ",
1066 fHiddenLineAndSurfaceRemovalIcon =
new QPixmap(hidden_line_and_surface_removal);
1068 const char *
const perspective[]={
1078 " ................ ",
1079 " ....+++++++++++++++. ",
1080 " ...++++..+.........+++. ",
1081 " ..++..............++..+. ",
1082 " .+++++++++++++++++.. .+. ",
1083 " .+...............+. .+. ",
1084 " .+. .+. .+. .+. ",
1085 " .+. .+. .+. .+. ",
1086 " .+. .+. .+. .+. ",
1087 " .+. .+. .+. .+. ",
1088 " .+. .+. .+. .+. ",
1089 " .+. .+. .+. .+. ",
1090 " .+. .+. .+. .+. ",
1091 " .+. .+. .+. .+. ",
1092 " .+. .+......+....+. ",
1093 " .+. ..++++++.+.++++. ",
1094 " .+. .++.......+...+.. ",
1095 " .+. .++. .+..++. ",
1096 " .+. ..+.. .+..+. ",
1099 " .+++.............++. ",
1100 " .+++++++++++++++++. ",
1101 " ................... ",
1106 fPerspectiveIcon =
new QPixmap(perspective);
1108 const char *
const ortho[]={
1116 " ................... ",
1117 " ..@@@@@@@@@@@@@@@@@. ",
1118 " ..@@@.............@@@. ",
1119 " ..@@.@. ..@..@. ",
1120 " ..@@ ..@. .@@...@. ",
1121 " ..@@..............@@.. .@. ",
1122 " .@@@@@@@@@@@@@@@@@.. .@. ",
1123 " .@...............@. .@. ",
1124 " .@. .@. .@. .@. ",
1125 " .@. .@. .@. .@. ",
1126 " .@. .@. .@. .@. ",
1127 " .@. .@. .@. .@. ",
1128 " .@. .@. .@. .@. ",
1129 " .@. .@. .@. .@. ",
1130 " .@. .@. .@. .@. ",
1131 " .@. .@. .@. .@. ",
1132 " .@. .@. .@. .@. ",
1133 " .@. .@. .@. .@. ",
1134 " .@. .@........@......@. ",
1135 " .@. .@@@@@@@@@.@.@@@@@@. ",
1136 " .@. .@@+........@....@@.. ",
1137 " .@...@. .@...@... ",
1139 " .@@@.............@@@.. ",
1140 " .@@@@@@@@@@@@@@@@@... ",
1141 " ................... ",
1146 fOrthoIcon =
new QPixmap(ortho);
1148 const char *
const commandIcon[]={
1176 "66666666666666666666",
1177 "66%++++++++++++++&56",
1178 "6$ o..o......o..o *6",
1179 "6+o...o*<441;@.o..+6",
1180 "6+..o@1553<354$..o+6",
1181 "6+..o<5<@ .*54#o.+6",
1190 "6+..O25<@ X=54#o.+6",
1191 "6+.o.@1553<354$...@6",
1192 "6+o..oo*<44<;@o..o+6",
1193 "6$ .o..o.....o..o *6",
1194 "66%+++++OOOO+++++*66",
1195 "66666666666666666666"
1197 fCommandIcon =
new QPixmap(commandIcon);
1199 const char *
const dirIcon[]={
1227 "66666666666666666666",
1228 "66$oOOOOOOOOOOOOo%66",
1231 "6o =635533666$ o6",
1232 "6o -65:+ +165X o6",
1241 "6o -65:+ @265X o6",
1242 "6o =635543665# O6",
1245 "66$OOOoo....OOOOo%66",
1246 "66666666666666666666"}
1248 fDirIcon =
new QPixmap(dirIcon);
1251 const char *
const runIcon[]={
1288 "rrrrrrrr%<<2rrrrrrrr",
1289 "rrrrr5=$$$$===rrrrrr",
1290 "rrrr<##$$$$$---&rrrr",
1291 "rrr=###$$$$-----%rrr",
1292 "rr=####$$$$------&rr",
1293 "r2@####7##$-------rr",
1294 "r.@####048$-------Or",
1295 "r.@####q4ee=----$@.r",
1296 " .@@###w4eee5%$#@@@X",
1297 " .@@@..w4eeeeqo..@@X",
1298 " .@..ooe<eeee7Oooo@X",
1299 " ..oooOe2eee6OOOooo ",
1300 "rOooOO+e2ew2+++++O+r",
1301 "r:oO+++e30,;;;;;++Or",
1302 "r :++;:9,>,,>>:;;1rr",
1303 "rr*1;:>,333333,>32rr",
1304 "rrr66,1367777637<rrr",
1305 "rrrr509799999905rrrr",
1306 "rrrrr=8wqwwww8-rrrrr",
1307 "rrrrrrrr4444rrrrrrrr"
1309 fRunIcon =
new QPixmap(runIcon);
1311 const char *
const paramIcon[]={
1350 "wwwwwwww5 5wwwwwwww",
1351 "wwwwwwww, ,wwwwwwww",
1352 "www&;ww7+ +9ww=-www",
1358 "5<+ .wwwwwww0. +<5",
1361 "5<+ .wwwwwww0X +<5",
1367 "www*>ww7+ +7ww=:www",
1368 "wwwwwwww1 1wwwwwwww",
1369 "wwwwwwww5 5wwwwwwww"
1371 fParamIcon =
new QPixmap(paramIcon);
1378 QWidget* G4UIQt::CreateHistoryTBWidget(
1381 fHistoryTBWidget =
new QWidget();
1383 QVBoxLayout *layoutHistoryTB =
new QVBoxLayout();
1384 fHistoryTBTableList =
new QListWidget();
1385 fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
1386 connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
1388 layoutHistoryTB->addWidget(fHistoryTBTableList);
1390 fHistoryTBWidget->setLayout(layoutHistoryTB);
1391 return fHistoryTBWidget;
1397 QWidget* G4UIQt::CreateHelpTBWidget(
1400 fHelpTBWidget =
new QWidget();
1402 QWidget *helpWidget =
new QWidget();
1403 QHBoxLayout *helpLayout =
new QHBoxLayout();
1404 QVBoxLayout *vLayout =
new QVBoxLayout();
1405 fHelpVSplitter =
new QSplitter(Qt::Vertical);
1406 fHelpLine =
new QLineEdit();
1407 helpLayout->addWidget(
new QLabel(
"Search :"));
1408 helpLayout->addWidget(fHelpLine);
1409 connect( fHelpLine, SIGNAL( editingFinished () ),
this, SLOT( LookForHelpStringCallback() ) );
1414 fParameterHelpLabel =
new QTextEdit();
1415 fParameterHelpLabel->setReadOnly(
true);
1416 fParameterHelpTable =
new QTableWidget();
1420 if (fHelpTreeWidget) {
1421 fHelpVSplitter->addWidget(fHelpTreeWidget);
1423 fHelpVSplitter->addWidget(fParameterHelpLabel);
1424 fHelpVSplitter->addWidget(fParameterHelpTable);
1426 fParameterHelpLabel->setVisible(
false);
1427 fParameterHelpTable->setVisible(
false);
1428 QSizePolicy policy = QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
1429 policy.setVerticalStretch(4);
1430 if (fHelpTreeWidget) {
1431 fHelpTreeWidget->setSizePolicy(policy);
1433 policy = QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
1434 policy.setVerticalStretch(1);
1435 fParameterHelpLabel->setSizePolicy(policy);
1436 fParameterHelpTable->setSizePolicy(policy);
1438 vLayout->addWidget(helpWidget);
1439 vLayout->addWidget(fHelpVSplitter,1);
1440 vLayout->setContentsMargins(5,5,5,5);
1442 helpWidget->setLayout(helpLayout);
1443 fHelpTBWidget->setLayout(vLayout);
1445 return fHelpTBWidget;
1451 G4UIDockWidget* G4UIQt::CreateCoutTBWidget(
1454 QWidget* coutTBWidget =
new QWidget();
1456 QVBoxLayout *layoutCoutTB =
new QVBoxLayout();
1458 fCoutTBTextArea =
new QTextEdit();
1461 fCoutTBTextArea->setFontFamily(
"Courier");
1462 fCoutTBTextArea->setFontPointSize(12);
1464 fCoutFilter =
new QLineEdit();
1465 fCoutFilter->setToolTip(
"Filter output by...");
1467 #if QT_VERSION > 0x050100
1468 fCoutFilter->addAction(*fSearchIcon,QLineEdit::TrailingPosition);
1469 fCoutFilter->setStyleSheet (
"border-radius:7px;");
1471 QPushButton *coutTBFilterButton =
new QPushButton();
1472 coutTBFilterButton->setIcon(QIcon(*fSearchIcon));
1473 coutTBFilterButton->setStyleSheet (
"padding-left: 0px; border:0px;");
1474 fCoutFilter->setStyleSheet (
"padding-right: 0px;");
1477 QPushButton *coutTBClearButton =
new QPushButton();
1478 coutTBClearButton->setIcon(*fClearIcon);
1479 coutTBClearButton->setToolTip(
"Clear console output");
1480 coutTBClearButton->setStyleSheet (
"border-radius:7px;");
1481 connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
1482 connect(fCoutFilter, SIGNAL(textEdited (
const QString &)), SLOT(CoutFilterCallback(
const QString &)));
1484 QPushButton *coutTBSaveOutputButton =
new QPushButton();
1485 coutTBSaveOutputButton->setIcon(*fSaveIcon);
1486 coutTBSaveOutputButton->setToolTip(
"Save console output");
1487 coutTBSaveOutputButton->setStyleSheet (
"border-radius:7px;");
1488 connect(coutTBSaveOutputButton, SIGNAL(clicked()), SLOT(SaveOutputCallback()));
1490 fCoutTBTextArea->setReadOnly(
true);
1492 QWidget* coutButtonWidget =
new QWidget();
1493 QHBoxLayout* layoutCoutTBButtons =
new QHBoxLayout();
1495 #ifdef G4MULTITHREADED
1497 fThreadsFilterComboBox =
new QComboBox();
1498 fThreadsFilterComboBox->setInsertPolicy(QComboBox::InsertAlphabetically);
1499 connect(fThreadsFilterComboBox, SIGNAL(activated(
int)),
this, SLOT(ThreadComboBoxCallback(
int)));
1501 UpdateCoutThreadFilter();
1503 fThreadsFilterComboBox->setToolTip(
"Thread selection in output");
1504 layoutCoutTBButtons->addWidget(
new QLabel(
" Threads:"));
1505 layoutCoutTBButtons->addWidget(fThreadsFilterComboBox);
1508 layoutCoutTBButtons->addWidget(fCoutFilter);
1509 #if QT_VERSION <= 0x050100
1510 layoutCoutTBButtons->addWidget(coutTBFilterButton);
1512 layoutCoutTBButtons->addWidget(coutTBClearButton);
1513 layoutCoutTBButtons->addWidget(coutTBSaveOutputButton);
1514 coutButtonWidget->setLayout(layoutCoutTBButtons);
1517 layoutCoutTBButtons->setContentsMargins(3,3,3,0);
1519 layoutCoutTB->addWidget(coutButtonWidget);
1520 layoutCoutTB->addWidget(fCoutTBTextArea);
1522 coutTBWidget->setLayout(layoutCoutTB);
1524 fCoutTBTextArea->setMinimumSize(100,100);
1527 QWidget* commandLineWidget =
new QWidget();
1528 QHBoxLayout *layoutCommandLine =
new QHBoxLayout();
1532 fCommandLabel =
new QLabel(
"");
1533 fCommandArea =
new QLineEdit();
1537 fCommandArea->activateWindow();
1539 fCommandArea->setFocusPolicy ( Qt::StrongFocus );
1540 fCommandArea->setFocus(Qt::TabFocusReason);
1541 fCommandArea->setToolTip(
"Apply command");
1544 layoutCommandLine->addWidget(fCommandLabel);
1545 layoutCommandLine->addWidget(fCommandArea);
1548 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
1549 connect(fCommandArea, SIGNAL(textEdited(
const QString &)), SLOT(CommandEditedCallback(
const QString &)));
1552 commandLineWidget->setLayout(layoutCommandLine);
1553 commandLineWidget->setMinimumSize(50,50);
1555 layoutCoutTB->addWidget(commandLineWidget);
1557 fCoutDockWidget =
new G4UIDockWidget (
"Output");
1558 fCoutDockWidget->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
1560 fCoutDockWidget->setWidget(coutTBWidget);
1561 return fCoutDockWidget;
1567 QWidget* G4UIQt::CreateVisParametersTBWidget(
1576 G4UIDockWidget* G4UIQt::CreateUITabWidget(
1579 fUITabWidget =
new QTabWidget();
1582 fUITabWidget->addTab(CreateSceneTreeWidget(),
"Scene tree");
1583 fUITabWidget->addTab(CreateHelpTBWidget(),
"Help");
1584 fUITabWidget->addTab(CreateHistoryTBWidget(),
"History");
1585 fUITabWidget->setCurrentWidget(fHelpTBWidget);
1587 fUITabWidget->setTabToolTip (0,
"Scene component tree. Only available in Stored mode");
1588 fUITabWidget->setTabToolTip (1,
"Help widget");
1589 fUITabWidget->setTabToolTip (2,
"All commands history");
1590 connect(fUITabWidget, SIGNAL(currentChanged(
int)), SLOT(ToolBoxActivated(
int)));
1592 fUIDockWidget =
new G4UIDockWidget (
"Scene tree, Help, History");
1593 fUIDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1595 fUIDockWidget->setWidget(fUITabWidget);
1597 return fUIDockWidget;
1601 QWidget* G4UIQt::CreateSceneTreeWidget(){
1603 fSceneTreeWidget =
new QWidget();
1604 QVBoxLayout* layout =
new QVBoxLayout();
1605 fSceneTreeWidget->setLayout(layout);
1607 #if QT_VERSION < 0x040200
1608 fSceneTreeWidget->hide();
1610 fSceneTreeWidget->setVisible(
false);
1613 return fSceneTreeWidget;
1617 void G4UIQt::CreateViewerWidget(){
1621 SetStartPage(std::string(
"<table width='100%'><tr><td width='30%'></td><td><div ")+
1622 "style='color: rgb(140, 31, 31); font-size: xx-large; font-family: Garamond, serif; padding-bottom: 0px; font-weight: normal'>Geant4: "+
1623 QApplication::applicationName ().toStdString()+
1624 "</div></td><td width='40%'> <br/><i>http://geant4.web.cern.ch/geant4/</i></td></tr></table>"+
1626 "<div style='background:#EEEEEE;'><b>Tooltips :</b><ul>"+
1627 "<li><b>Start a new viewer :</b><br />"+
1628 "<i>'/vis/open/...'<br />"+
1629 "For example '/vis/open OGL'</i></li>"+
1630 "<li><b>Execute a macro file :</b><br />"+
1631 "<i>'/control/execute my_macro_file'</i></li>"+
1634 "<div style='background:#EEEEEE;'><b>Documentation :</b><ul>"+
1635 "<li><b>Visualization tutorial :</b><br />"+
1636 "<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>"+
1637 "<li><b>Visualisation publication :</b><br />"+
1638 "<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>"+
1641 "<div style='background:#EEEEEE;'><b>Getting Help :</b><ul>"+
1642 "<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"+
1643 "<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>"+
1649 if (fViewerTabWidget == NULL) {
1650 fViewerTabWidget =
new G4QTabWidget();
1651 fMainWindow->setCentralWidget(fViewerTabWidget);
1652 #if QT_VERSION < 0x040500
1654 fViewerTabWidget->setTabsClosable (
true);
1657 #if QT_VERSION < 0x040200
1659 fViewerTabWidget->setUsesScrollButtons (
true);
1662 #if QT_VERSION < 0x040500
1664 connect(fViewerTabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(TabCloseCallback(
int)));
1666 connect(fViewerTabWidget, SIGNAL(currentChanged (
int ) ), SLOT(UpdateTabWidget(
int)));
1670 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
1671 policy.setVerticalStretch(4);
1672 fViewerTabWidget->setSizePolicy(policy);
1674 fViewerTabWidget->setMinimumSize(40,40);
1680 QWidget* G4UIQt::GetSceneTreeWidget(
1683 return fSceneTreeWidget;
1688 QWidget* G4UIQt::GetViewerPropertiesWidget(
1691 if (!fViewerPropertiesDialog) {
1692 CreateViewerPropertiesDialog();
1694 return fViewerPropertiesWidget;
1699 QWidget* G4UIQt::GetPickInfosWidget(
1702 if (!fPickInfosDialog) {
1703 CreatePickInfosDialog();
1705 return fPickInfosWidget;
1711 bool G4UIQt::AddViewerTab(
1716 if (fViewerTabWidget == NULL) {
1719 fViewerTabWidget->addTab(aWidget,title.c_str());
1727 bool G4UIQt::AddViewerTabFromFile(
1728 std::string fileName
1732 if (fViewerTabWidget == NULL) {
1737 if(UI==NULL)
return 0;
1741 std::string content( (std::istreambuf_iterator<char>(file) ),
1742 (std::istreambuf_iterator<char>() ) );
1744 QTextEdit* text =
new QTextEdit();
1745 text->setAcceptRichText (
true);
1746 text->setContentsMargins(5,5,5,5);
1747 text->setText(QString(
"<pre>")+content.c_str()+
"</pre>");
1748 text->setReadOnly(
true);
1749 fViewerTabWidget->addTab(text,title.c_str());
1760 bool G4UIQt::AddTabWidget(
1771 #if QT_VERSION < 0x050100
1772 #if QT_VERSION >= 0x050000
1773 QString message = QString(
1774 "This Qt version [")+qVersion ()+
"] has some issues with the OpenGL viewer.\n"+
1775 "To prevent problems, you are not allowed to open a Stored nor Immediate viewer.\n" +
1777 "Please upgrade to Qt version >= 5.1\n";
1779 QMessageBox::warning(fMainWindow, tr(
"Warning"),
1780 tr(message.toStdString().c_str()),
1787 if (fViewerTabWidget == NULL) {
1788 CreateViewerWidget();
1795 aWidget->setParent(fViewerTabWidget);
1798 fViewerTabWidget->addTab(aWidget,name);
1800 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
1803 #if QT_VERSION < 0x040200
1804 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
1806 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
1817 void G4UIQt::SetStartPage(
1818 const std::string& text)
1821 fDefaultViewerFirstPageHTMLText = text;
1824 fStartPage =
new QTextEdit();
1825 fStartPage->setAcceptRichText (
true);
1826 fStartPage->setContentsMargins(5,5,5,5);
1827 fStartPage->setReadOnly(
true);
1829 fStartPage->setText(fDefaultViewerFirstPageHTMLText.c_str());
1833 void G4UIQt::UpdateTabWidget(
int tabNumber) {
1834 if ( fViewerTabWidget == NULL) {
1835 fViewerTabWidget =
new G4QTabWidget;
1838 fViewerTabWidget->setCurrentIndex(tabNumber);
1841 fViewerTabWidget->setTabSelected(
false);
1843 #if QT_VERSION < 0x040200
1844 fViewerTabWidget->show();
1846 fViewerTabWidget->setVisible(
true);
1850 fViewerTabWidget->setTabSelected(
true);
1856 void G4UIQt::ResizeTabWidget( QResizeEvent* e) {
1857 if ( fViewerTabWidget) {
1858 for (
G4int a=0;a<fViewerTabWidget->count() ;a++) {
1859 fViewerTabWidget->widget(a)->resize(e->size());
1870 G4Qt* interactorManager = G4Qt::getInstance ();
1871 Prompt(
"Session :");
1872 exitSession =
false;
1874 QCoreApplication::sendPostedEvents () ;
1876 #if QT_VERSION < 0x040200
1877 fMainWindow->show();
1879 fMainWindow->setVisible(
true);
1882 if (fDefaultIcons) {
1883 #if QT_VERSION < 0x040200
1884 fToolbarApp->show();
1886 fToolbarApp->setVisible(
true);
1890 #if QT_VERSION < 0x040200
1891 fToolbarApp->hide();
1893 fToolbarApp->setVisible(
false);
1900 UpdateCommandCompleter();
1903 fHistoryTBTableList->installEventFilter(
this);
1904 fCommandArea->installEventFilter(
this);
1907 fCommandArea->setFocus();
1909 interactorManager->DisableSecondaryLoop ();
1910 if ((QApplication*)interactorManager->GetMainInteractor())
1911 ((QApplication*)interactorManager->GetMainInteractor())->exec();
1913 interactorManager->EnableSecondaryLoop ();
1923 void G4UIQt::Prompt (
1927 if (!aPrompt)
return;
1929 fCommandLabel->setText((
char*)aPrompt.
data());
1934 void G4UIQt::SessionTerminate (
1937 G4Qt* interactorManager = G4Qt::getInstance ();
1938 fMainWindow->close();
1939 ((QApplication*)interactorManager->GetMainInteractor())->exit();
1952 void G4UIQt::PauseSessionStart (
1956 if (!aState)
return;
1958 if(aState==
"G4_pause> ") {
1959 SecondaryLoop (
"Pause, type continue to exit this state");
1962 if(aState==
"EndOfEvent") {
1964 SecondaryLoop (
"End of event, type continue to exit this state");
1974 void G4UIQt::SecondaryLoop (
1978 if (!aPrompt)
return;
1980 G4Qt* interactorManager = G4Qt::getInstance ();
1984 ((QApplication*)interactorManager)->processEvents(QEventLoop::WaitForMoreEvents);
1985 if(exitPause==
true)
break;
1987 Prompt(
"Session :");
1990 #ifdef G4MULTITHREADED
2004 G4int G4UIQt::ReceiveG4cout (
2008 if (!aString)
return 0;
2010 #ifdef G4MULTITHREADED
2016 if (aString.
contains(
"*** This is just a warning message. ***")) {
2017 return ReceiveG4cerr(aString);
2023 G4UIOutputString txt = G4UIOutputString(QString((
char*)aString.
data()).trimmed(),GetThreadPrefix());
2024 fG4OutputString.push_back(txt);
2026 #ifdef G4MULTITHREADED
2027 QString
result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
2029 QString result = FilterOutput(txt,
"",fCoutFilter->text());
2032 if (result.isEmpty()) {
2035 QColor previousColor = fCoutTBTextArea->textColor();
2036 fCoutTBTextArea->setTextColor(Qt::black);
2037 fCoutTBTextArea->append(result);
2038 fCoutTBTextArea->setTextColor(previousColor);
2039 fCoutTBTextArea->ensureCursorVisible ();
2041 #ifdef G4MULTITHREADED
2042 UpdateCoutThreadFilter();
2053 G4int G4UIQt::ReceiveG4cerr (
2057 if (!aString)
return 0;
2059 #ifdef G4MULTITHREADED
2066 G4UIOutputString txt = G4UIOutputString(QString((
char*)aString.
data()).trimmed(),
2069 fG4OutputString.push_back(txt);
2071 #ifdef G4MULTITHREADED
2072 QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
2074 QString result = FilterOutput(txt,
"",fCoutFilter->text());
2076 if (result.isEmpty()) {
2081 if (QString(aString.
data()).trimmed() !=
"") {
2085 QMessageBox::critical(fMainWindow,
"Error",QString(fLastErrMessage.data())+
"\n"+aString.
data());
2088 QColor previousColor = fCoutTBTextArea->textColor();
2089 fCoutTBTextArea->setTextColor(Qt::red);
2090 fCoutTBTextArea->append(result);
2091 fCoutTBTextArea->setTextColor(previousColor);
2092 fCoutTBTextArea->ensureCursorVisible ();
2094 if (QString(aString.
data()).trimmed() !=
"") {
2095 fLastErrMessage = aString;
2097 #ifdef G4MULTITHREADED
2098 UpdateCoutThreadFilter();
2104 G4String G4UIQt::GetThreadPrefix() {
2106 #ifdef G4MULTITHREADED
2108 if(UI==NULL)
return "";
2116 return threadPrefix;
2120 #ifdef G4MULTITHREADED
2121 void G4UIQt::UpdateCoutThreadFilter() {
2123 if(UI==NULL)
return;
2126 if (fThreadsFilterComboBox->count() < 2) {
2127 if ( fThreadsFilterComboBox->findText(
"All", Qt::MatchExactly) == -1) {
2128 fThreadsFilterComboBox->addItem(
"All");
2131 if (fThreadsFilterComboBox->count() < 2) {
2132 if ( fThreadsFilterComboBox->findText(
"Master", Qt::MatchExactly) == -1) {
2133 fThreadsFilterComboBox->addItem(
"Master");
2139 if ( fThreadsFilterComboBox->findText(prefix.
data(), Qt::MatchExactly) == -1) {
2140 fThreadsFilterComboBox->addItem(prefix.
data());
2152 void G4UIQt::AddMenu (
2157 if (aName == NULL)
return;
2158 if (aLabel == NULL)
return;
2160 QMenu *fileMenu =
new QMenu(aLabel);
2161 fMainWindow->menuBar()->addMenu(fileMenu);
2173 void G4UIQt::AddButton (
2176 ,
const char* aCommand
2179 if(aMenu==NULL)
return;
2180 if(aLabel==NULL)
return;
2181 if(aCommand==NULL)
return;
2183 QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
2185 if(parentTmp==NULL) {
2190 G4cout <<
"Menu name " << aMenu<<
" does not exist, please define it before using it."<<
G4endl;
2197 if(UI==NULL)
return;
2201 G4int cmdEndPos = cmd.find_first_of(
" \t");
2202 if(cmdEndPos!=
G4int(std::string::npos)) {
2203 cmd.erase(cmdEndPos);
2206 if(treeTop->
FindPath(cmd) == NULL) {
2208 cmd(0,3) !=
"ls " &&
2211 cmd(0,3) !=
"cd " &&
2213 cmd(0,5) !=
"help " &&
2225 G4cout <<
"Warning: command '"<< cmd <<
"' does not exist, please define it before using it."<<
G4endl;
2230 QSignalMapper *signalMapper =
new QSignalMapper(
this);
2231 QAction *action = parentTmp->addAction(aLabel, signalMapper, SLOT(map()));
2233 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
2234 signalMapper->setMapping(action, QString(aCommand));
2243 void G4UIQt::AddIcon(
const char* aLabel,
const char* aIconFile,
const char* aCommand,
const char* aFileName){
2244 if(aLabel==NULL)
return;
2246 if (aCommand==NULL) {
2247 if (std::string(aIconFile) ==
"user_icon") {
2252 bool userToolBar =
false;
2254 if (!fDefaultIcons) {
2257 if (std::string(aIconFile) ==
"user_icon") {
2261 if (pix->isNull()) {
2265 G4cout <<
"Warning: file '"<< aFileName <<
"' is incorrect or does not exist, this command will not be build"<<
G4endl;
2269 }
else if (std::string(aIconFile) ==
"open") {
2271 }
else if (std::string(aIconFile) ==
"save") {
2273 }
else if (std::string(aIconFile) ==
"move") {
2275 }
else if (std::string(aIconFile) ==
"rotate") {
2277 }
else if (std::string(aIconFile) ==
"pick") {
2279 }
else if (std::string(aIconFile) ==
"zoom_in") {
2281 }
else if (std::string(aIconFile) ==
"zoom_out") {
2283 }
else if (std::string(aIconFile) ==
"wireframe") {
2284 pix = fWireframeIcon;
2285 }
else if (std::string(aIconFile) ==
"solid") {
2287 }
else if (std::string(aIconFile) ==
"hidden_line_removal") {
2288 pix = fHiddenLineRemovalIcon;
2289 }
else if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
2290 pix = fHiddenLineAndSurfaceRemovalIcon;
2291 }
else if (std::string(aIconFile) ==
"perspective") {
2292 pix = fPerspectiveIcon;
2293 }
else if (std::string(aIconFile) ==
"ortho") {
2295 }
else if (std::string(aIconFile) ==
"runBeamOn") {
2302 G4cout <<
"Parameter"<< aIconFile <<
" not defined"<<
G4endl;
2306 QToolBar *currentToolbar = NULL;
2308 if (fToolbarUser == NULL) {
2309 fToolbarUser =
new QToolBar();
2310 fToolbarUser->setIconSize (QSize(20,20));
2311 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
2313 currentToolbar = fToolbarUser;
2315 if (fToolbarApp == NULL) {
2316 fToolbarApp =
new QToolBar();
2317 fToolbarApp->setIconSize (QSize(20,20));
2318 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
2320 currentToolbar = fToolbarApp;
2325 QList<QAction*> list = currentToolbar->actions();
2327 for (
int i = 0; i < list.size(); ++i) {
2328 if (list.at(i)->text() == QString(aLabel)) {
2330 if(UI==NULL)
return;
2333 G4cout <<
"Warning: A toolBar icon \""<< aLabel<<
"\" already exists with the same name!" <<
G4endl;
2338 QSignalMapper *signalMapper =
new QSignalMapper(
this);
2339 QAction *action = currentToolbar->addAction(QIcon(*pix),aLabel, signalMapper, SLOT(map()));
2342 if (std::string(aIconFile) ==
"open") {
2343 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(OpenIconCallback(
const QString &)));
2344 QString txt = aCommand + fStringSeparator + aLabel;
2345 signalMapper->setMapping(action, QString(txt));
2348 }
else if (std::string(aIconFile) ==
"save") {
2349 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(SaveIconCallback(
const QString&)));
2350 QString txt = aCommand + fStringSeparator + aLabel;
2351 signalMapper->setMapping(action, QString(txt));
2354 }
else if ((std::string(aIconFile) ==
"move") ||
2355 (std::string(aIconFile) ==
"rotate") ||
2356 (std::string(aIconFile) ==
"pick") ||
2357 (std::string(aIconFile) ==
"zoom_out") ||
2358 (std::string(aIconFile) ==
"zoom_in")) {
2359 action->setCheckable(
TRUE);
2360 action->setChecked(
TRUE);
2361 action->setData(aIconFile);
2363 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeCursorAction(
const QString&)));
2364 signalMapper->setMapping(action, QString(aIconFile));
2366 if (std::string(aIconFile) ==
"move") {
2367 SetIconMoveSelected();
2369 if (std::string(aIconFile) ==
"rotate") {
2370 SetIconRotateSelected();
2372 if (std::string(aIconFile) ==
"pick") {
2373 SetIconPickSelected();
2375 if (std::string(aIconFile) ==
"zoom_in") {
2376 SetIconZoomInSelected();
2378 if (std::string(aIconFile) ==
"zoom_out") {
2379 SetIconZoomOutSelected();
2383 }
else if ((std::string(aIconFile) ==
"hidden_line_removal") ||
2384 (std::string(aIconFile) ==
"hidden_line_and_surface_removal") ||
2385 (std::string(aIconFile) ==
"solid") ||
2386 (std::string(aIconFile) ==
"wireframe")) {
2387 action->setCheckable(
TRUE);
2388 action->setChecked(
TRUE);
2389 action->setData(aIconFile);
2390 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeSurfaceStyle(
const QString&)));
2391 signalMapper->setMapping(action, QString(aIconFile));
2393 if (std::string(aIconFile) ==
"hidden_line_removal") {
2394 SetIconHLRSelected();
2396 if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
2397 SetIconHLHSRSelected();
2399 if (std::string(aIconFile) ==
"solid") {
2400 SetIconSolidSelected();
2402 if (std::string(aIconFile) ==
"wireframe") {
2403 SetIconWireframeSelected();
2407 }
else if ((std::string(aIconFile) ==
"perspective") ||
2408 (std::string(aIconFile) ==
"ortho")) {
2409 action->setCheckable(
TRUE);
2410 action->setChecked(
TRUE);
2411 action->setData(aIconFile);
2412 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangePerspectiveOrtho(
const QString&)));
2413 signalMapper->setMapping(action, QString(aIconFile));
2415 if (std::string(aIconFile) ==
"perspective") {
2416 SetIconPerspectiveSelected();
2418 if (std::string(aIconFile) ==
"ortho") {
2419 SetIconOrthoSelected();
2426 if(UI==NULL)
return;
2428 if (aCommand != NULL) {
2429 std::string str = aCommand;
2430 std::string::size_type
pos = str.find(
" ");
2431 if (pos != std::string::npos)
2433 str = str.substr(0,pos).c_str();
2435 if(treeTop->
FindPath(str.c_str()) == NULL) {
2440 G4cout <<
"Warning: command '"<< aCommand <<
"' does not exist, please define it before using it."<<
G4endl;
2445 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
2446 signalMapper->setMapping(action, QString(aCommand));
2452 void G4UIQt::ActivateCommand(
2456 if (!fHelpTreeWidget) {
2460 size_t i = newCommand.
index(
" ");
2462 if( i != std::string::npos )
2464 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
2466 targetCom = ModifyToFullPathCommand( newValue );
2468 if (targetCom !=
"") {
2469 OpenHelpTreeOnCommand(targetCom.
data());
2472 fUITabWidget->setCurrentWidget(fHelpTBWidget);
2483 void G4UIQt::InitHelpTreeAndVisParametersWidget()
2486 if (! fHelpTreeWidget ) {
2487 fHelpTreeWidget =
new QTreeWidget();
2491 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2493 labels << QString(
"Command");
2494 fHelpTreeWidget->setHeaderLabels(labels);
2497 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),
this, SLOT(HelpTreeClicCallback()));
2498 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,
int)),
this, SLOT(HelpTreeDoubleClicCallback()));
2507 void G4UIQt::FillHelpTree()
2509 if (! fHelpTreeWidget ) {
2510 InitHelpTreeAndVisParametersWidget();
2513 QString searchText = fHelpLine->text();
2515 if (searchText ==
"") {
2522 if (fParameterHelpLabel) {
2523 fParameterHelpLabel->setText(
"Choose a command in the command tree");
2524 fParameterHelpTable->setVisible(
false);
2528 #if QT_VERSION < 0x040200
2531 fHelpLine->setText(
"");
2536 if(UI==NULL)
return;
2540 QTreeWidgetItem * newItem = NULL;
2541 QString commandText =
"";
2542 for (
int a=0;a<treeSize;a++) {
2549 for (
int b=0;b<fHelpTreeWidget->topLevelItemCount();b++) {
2551 newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b),commandText);
2554 if (newItem == NULL) {
2556 newItem =
new QTreeWidgetItem();
2557 newItem->setText(0,GetShortCommandPath(commandText));
2558 fHelpTreeWidget->addTopLevelItem(newItem);
2562 CreateHelpTree(newItem,treeTop->
GetTree(a+1));
2573 void G4UIQt::CreateHelpTree(
2574 QTreeWidgetItem *aParent
2578 if (aParent == NULL)
return;
2579 if (aCommandTree == NULL)
return;
2583 QTreeWidgetItem * newItem;
2585 QString commandText =
"";
2592 newItem = FindTreeItem(aParent,commandText);
2593 if (newItem == NULL) {
2594 newItem =
new QTreeWidgetItem();
2595 newItem->setText(0,GetShortCommandPath(commandText));
2596 aParent->addChild(newItem);
2598 CreateHelpTree(newItem,aCommandTree->
GetTree(a+1));
2605 QStringList stringList;
2609 newItem = FindTreeItem(aParent,commandText);
2610 if (newItem == NULL) {
2611 newItem =
new QTreeWidgetItem();
2612 newItem->setText(0,GetShortCommandPath(commandText));
2613 aParent->addChild(newItem);
2615 #if QT_VERSION < 0x040202
2616 fHelpTreeWidget->setItemExpanded(newItem,
false);
2618 newItem->setExpanded(
false);
2632 bool G4UIQt::CreateVisCommandGroupAndToolBox(
2639 QString commandText = QString((
char*)(aCommand->
GetCommandPath().
data())).section(
"/",-aDepthLevel);
2641 if (commandText == NULL) {
2647 QWidget* newParentWidget = NULL;
2649 QString commandSection = commandText.left(commandText.indexOf(
"/"));
2651 if (aDepthLevel == 1) {
2652 QToolBox* currentParent =
dynamic_cast<QToolBox*
>(aParent);
2653 if (currentParent != 0){
2656 for (
int a=0; a<currentParent->count(); a++) {
2657 if (currentParent->itemText(a) == commandSection) {
2659 newParentWidget = currentParent->widget(a);
2665 newParentWidget =
new QGroupBox();
2666 newParentWidget->setLayout(
new QVBoxLayout());
2667 if (currentParent != 0){
2668 currentParent->addItem(newParentWidget,commandSection);
2670 if (!aParent->layout()) {
2671 aParent->setLayout(
new QVBoxLayout());
2673 aParent->layout()->addWidget(newParentWidget);
2676 if (commandText.indexOf(
"/") == -1) {
2681 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2684 newParentWidget->setToolTip(guidance);
2687 QScrollArea* sc =
dynamic_cast<QScrollArea*
>(newParentWidget->parent()->parent());
2689 sc->ensureWidgetVisible(newParentWidget);
2696 QGroupBox* currentParent =
dynamic_cast<QGroupBox*
>(aParent);
2697 if (currentParent != 0){
2701 if (aDepthLevel == 2){
2702 QToolBox* parentToolBox =
dynamic_cast<QToolBox*
>(currentParent->parent()->parent()->parent());
2703 if (parentToolBox != 0) {
2707 for (
int a=0; a<aParent->layout()->count(); a++) {
2708 QGroupBox* gb =
dynamic_cast<QGroupBox*
>(aParent->layout()->itemAt(a)->widget());
2710 if (gb->title() == commandSection) {
2712 newParentWidget = gb;
2720 newParentWidget =
new QGroupBox();
2721 newParentWidget->setLayout(
new QVBoxLayout());
2722 if (!aParent->layout()) {
2723 aParent->setLayout(
new QVBoxLayout());
2725 aParent->layout()->addWidget(newParentWidget);
2731 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2734 newParentWidget->setToolTip(guidance);
2739 if (commandText.indexOf(
"/") == -1) {
2740 if (CreateCommandWidget(aCommand, newParentWidget,isDialog)) {
2744 CreateVisCommandGroupAndToolBox(aCommand,newParentWidget, aDepthLevel-1,isDialog);
2757 bool G4UIQt::CreateCommandWidget(
G4UIcommand* aCommand, QWidget* aParent,
bool isDialog) {
2759 if (aCommand == NULL) {
2766 if( n_parameterEntry > 0 ) {
2770 QWidget* paramWidget =
new QWidget();
2771 QGridLayout* gridLayout =
new QGridLayout();
2772 paramWidget->setLayout(gridLayout);
2775 unsigned int nbColorParameter = 0;
2776 bool isStillColorParameter =
false;
2777 bool isColorDialogAdded =
false;
2778 QLabel* redLabel = NULL;
2779 QLabel* greenLabel = NULL;
2780 QString redDefaultStr =
"";
2781 QString greenDefaultStr =
"";
2782 QString blueDefaultStr =
"";
2783 QWidget* redInput = NULL;
2784 QWidget* greenInput = NULL;
2786 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2791 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")){
2792 nbColorParameter ++;
2793 isStillColorParameter =
true;
2794 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2795 nbColorParameter ++;
2796 }
else if ((label->text() ==
"blue") && isStillColorParameter) {
2797 nbColorParameter ++;
2798 }
else if (!isColorDialogAdded) {
2801 if (nbColorParameter == 1) {
2802 gridLayout->addWidget(redLabel,i_thParameter-1,0);
2803 gridLayout->addWidget(redInput,i_thParameter-1,1);
2804 }
else if (nbColorParameter == 2) {
2805 gridLayout->addWidget(redLabel,i_thParameter-2,0);
2806 gridLayout->addWidget(redInput,i_thParameter-2,1);
2807 gridLayout->addWidget(greenLabel,i_thParameter-1,0);
2808 gridLayout->addWidget(greenInput,i_thParameter-1,1);
2810 nbColorParameter = 0;
2813 QWidget* input = NULL;
2815 input =
new QLineEdit();
2817 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2819 if (((label->text() ==
"red") || (label->text() ==
"red_or_string")) && isStillColorParameter) {
2821 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2823 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2828 input =
new QWidget();
2829 QHBoxLayout* layout =
new QHBoxLayout();
2830 input->setLayout(layout);
2832 QButtonGroup* buttons =
new QButtonGroup();
2833 QRadioButton* radioOff =
new QRadioButton(
"0");
2834 QRadioButton* radioOn =
new QRadioButton(
"1");
2835 buttons->addButton(radioOn);
2836 buttons->addButton(radioOff);
2837 layout->addWidget(radioOn);
2838 layout->addWidget(radioOff);
2842 if (defaultValue ==
"0") {
2843 radioOff->setChecked(
true);
2844 }
else if (defaultValue ==
"1") {
2845 radioOn->setChecked(
true);
2848 input =
new QComboBox();
2850 QStringList list = candidates.split (
" ");
2854 for (
int a=0; a<list.size(); a++) {
2855 dynamic_cast<QComboBox*
>(input)->addItem(list.at(a));
2856 if (list.at(a) == defaultValue) {
2857 dynamic_cast<QComboBox*
>(input)->setCurrentIndex(a);
2862 input =
new QLineEdit();
2864 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2867 input =
new QWidget();
2868 QHBoxLayout* layout =
new QHBoxLayout();
2869 input->setLayout(layout);
2871 QButtonGroup* buttons =
new QButtonGroup();
2872 QRadioButton* radioOff =
new QRadioButton(
"off");
2873 QRadioButton* radioOn =
new QRadioButton(
"on");
2874 buttons->addButton(radioOn);
2875 buttons->addButton(radioOff);
2876 layout->addWidget(radioOn);
2877 layout->addWidget(radioOff);
2881 if (defaultValue ==
"off") {
2882 radioOff->setChecked(
true);
2883 }
else if (defaultValue ==
"on") {
2884 radioOn->setChecked(
true);
2888 input =
new QLineEdit();
2889 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2896 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2898 txt +=
" Omittable : True\n";
2900 txt +=
" Omittable : False\n";
2903 txt +=
" Default value : taken from the current value\n";
2914 if (isStillColorParameter && (nbColorParameter != 0)) {
2915 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")) {
2918 }
else if (label->text() ==
"green") {
2921 }
else if (label->text() ==
"blue") {
2927 if ((redDefaultStr !=
"") && (redDefaultStr !=
"") && (redDefaultStr !=
"")) {
2928 qc.setRgbF(redDefaultStr.toDouble(),
2929 greenDefaultStr.toDouble(),
2930 blueDefaultStr.toDouble());
2932 QPixmap pixmap = QPixmap(QSize(16, 16));
2934 QPainter painter(&pixmap);
2935 painter.setPen(Qt::black);
2936 painter.drawRect(0,0,15,15);
2938 input =
new QPushButton(
"Change color");
2939 dynamic_cast<QPushButton*
>(input)->setIcon(pixmap);
2940 dynamic_cast<QPushButton*
>(input)->setAccessibleName(redDefaultStr+
" "+greenDefaultStr+
" "+blueDefaultStr);
2941 label =
new QLabel(
"Choose color");
2945 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2946 input->setToolTip(
"Select the current color");
2947 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2950 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2951 signalMapper->setMapping(input,input);
2952 connect(input, SIGNAL(clicked()), signalMapper, SLOT(map()));
2953 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(ChangeColorCallback(QWidget*)));
2955 isColorDialogAdded =
true;
2956 isStillColorParameter =
false;
2959 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2960 input->setToolTip(txt);
2961 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2967 gridLayout->addWidget(name,n_parameterEntry-nbColorParameter,0);
2969 QPushButton* applyButton =
new QPushButton(
"Apply");
2972 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,1);
2974 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2975 signalMapper->setMapping(applyButton, paramWidget);
2976 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2977 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2981 applyButton->setAutoDefault(
TRUE );
2982 applyButton->setDefault(
TRUE );
2984 QPushButton* cancelButton =
new QPushButton( tr(
"&Cancel" ));
2985 cancelButton->setAutoDefault(
TRUE );
2986 gridLayout->addWidget(cancelButton,n_parameterEntry-nbColorParameter,1);
2987 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,0);
2989 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2990 signalMapper->setMapping(applyButton, paramWidget);
2991 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2992 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2994 QWidget * parentCheck = aParent;
2995 QDialog* parentDialog = NULL;
2997 while ((parentCheck->parentWidget()) != NULL) {
2998 parentCheck = parentCheck->parentWidget();
2999 parentDialog =
dynamic_cast<QDialog*
>(parentCheck);
3001 connect( applyButton, SIGNAL( clicked() ), parentDialog, SLOT( accept() ) );
3002 connect( cancelButton, SIGNAL( clicked() ), parentDialog, SLOT( reject() ) );
3011 if (!aParent->layout()) {
3012 aParent->setLayout(
new QVBoxLayout());
3014 aParent->layout()->addWidget(paramWidget);
3025 QTreeWidgetItem* G4UIQt::FindTreeItem(
3026 QTreeWidgetItem *aParent
3027 ,
const QString& aCommand
3030 if (aParent == NULL)
return NULL;
3033 QString myCommand = aCommand;
3035 if (myCommand.lastIndexOf(
"/") == (myCommand.size()-1)) {
3036 myCommand = myCommand.left(myCommand.size()-1);
3039 if (GetLongCommandPath(aParent) == myCommand)
3042 QTreeWidgetItem * tmp = NULL;
3043 for (
int a=0;a<aParent->childCount();a++) {
3045 tmp = FindTreeItem(aParent->child(a),myCommand);
3059 QString G4UIQt::GetCommandList (
3065 if (aCommand == NULL)
3073 if ((commandPath ==
"") &&
3074 (rangeString ==
"") &&
3075 (n_guidanceEntry == 0) &&
3076 (n_parameterEntry == 0)) {
3080 if((commandPath.length()-1)!=
'/') {
3081 txt +=
"Command " + QString((
char*)(commandPath).
data()) +
"\n";
3083 txt +=
"Guidance :\n";
3085 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3088 if( ! rangeString.
isNull() ) {
3089 txt +=
" Range of parameters : " + QString((
char*)(rangeString).
data()) +
"\n";
3091 if( n_parameterEntry > 0 ) {
3096 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
3101 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
3103 txt +=
" Omittable : True\n";
3105 txt +=
" Omittable : False\n";
3108 txt +=
" Default value : taken from the current value\n";
3131 void G4UIQt::updateHelpArea (
3135 if (!fParameterHelpLabel)
3137 if (!fParameterHelpTable)
3140 fParameterHelpLabel->setTextInteractionFlags(Qt::NoTextInteraction);
3142 if (aCommand == NULL)
3150 if ((commandPath ==
"") &&
3151 (rangeString ==
"") &&
3152 (n_guidanceEntry == 0) &&
3153 (n_parameterEntry == 0)) {
3157 if((commandPath.length()-1)!=
'/') {
3158 txt +=
"<b>Command </b> " + QString((
char*)(commandPath).
data()) +
"<br />";
3160 txt +=
"<b>Guidance :</b> ";
3162 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3165 if( ! rangeString.
isNull() ) {
3166 txt +=
"<b>Range of parameters : </b> " + QString((
char*)(rangeString).
data()) +
"<br />";
3170 fParameterHelpLabel->setHtml(txt);
3172 if( n_parameterEntry > 0 ) {
3177 fParameterHelpTable->clear();
3178 fParameterHelpTable->setRowCount(n_parameterEntry);
3179 fParameterHelpTable->setColumnCount(8);
3180 fParameterHelpTable->setHorizontalHeaderLabels(QStringList() <<
3189 fParameterHelpTable->setColumnWidth(2,60);
3191 fParameterHelpTable->verticalHeader()->setVisible(
false);
3192 fParameterHelpTable->setAlternatingRowColors (
true);
3193 #if QT_VERSION < 0x050000
3194 fParameterHelpTable->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
3195 fParameterHelpTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
3197 fParameterHelpTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
3198 fParameterHelpTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
3200 fParameterHelpTable->setWordWrap(
true);
3202 QTableWidgetItem* t = fParameterHelpTable->horizontalHeaderItem(1);
3203 QFont fnt = t->font();
3204 int size = fnt.pointSize();
3205 fnt.setPointSize(size-2);
3207 for(
G4int a=0; a<n_parameterEntry; a++ ) {
3209 fParameterHelpTable->setItem(a, 0,
new QTableWidgetItem(QString::number(a+1)));
3211 fParameterHelpTable->setItem(a, 1,
new QTableWidgetItem(QString((
char*)(param->
GetParameterName()).
data())));
3215 fParameterHelpTable->setItem(a, 3,
new QTableWidgetItem(QString(QChar(param->
GetParameterType()))));
3218 fParameterHelpTable->setItem(a, 4,
new QTableWidgetItem(QString(
"True")));
3220 fParameterHelpTable->setItem(a, 4,
new QTableWidgetItem(QString(
"False")));
3223 fParameterHelpTable->setItem(a, 5,
new QTableWidgetItem(QString(
"taken from the current value")));
3225 fParameterHelpTable->setItem(a, 5,
new QTableWidgetItem(QString((
char*)(param->
GetDefaultValue()).
data())));
3228 fParameterHelpTable->setItem(a, 6,
new QTableWidgetItem(QString((
char*)(param->
GetParameterRange()).
data())));
3234 for (
int b=0; b<8; b++) {
3235 QTableWidgetItem* tmp = fParameterHelpTable->item(a,b);
3237 tmp->setToolTip(tmp->text());
3238 tmp->setFlags(Qt::NoItemFlags);
3239 tmp->setForeground(QBrush());
3243 fParameterHelpTable->resizeRowToContents(a);
3245 for (
int c=0; c<8; c++) {
3247 fParameterHelpTable->resizeColumnToContents(c);
3250 fParameterHelpLabel->setVisible(
true);
3251 fParameterHelpTable->setVisible(
true);
3262 G4bool G4UIQt::IsGUICommand(
3266 if (aCommand == NULL)
3271 if( n_parameterEntry > 0 ) {
3276 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
3298 G4bool G4UIQt::GetHelpChoice(
3313 bool G4UIQt::eventFilter(
3318 bool tabKeyPress =
false;
3319 bool moveCommandCursor =
false;
3320 if (aObj == NULL)
return false;
3321 if (aEvent == NULL)
return false;
3323 if (aObj == fHistoryTBTableList) {
3324 if (aEvent->type() == QEvent::KeyPress) {
3325 fCommandArea->setFocus();
3329 if (aObj == fCompleter->popup()) {
3330 if (aEvent->type() == QEvent::KeyPress) {
3331 QKeyEvent *e =
static_cast<QKeyEvent*
>(aEvent);
3332 if (e->key() == (Qt::Key_Tab)) {
3338 if (aObj == fCommandArea) {
3339 if (aEvent->type() == QEvent::KeyPress) {
3340 QKeyEvent *e =
static_cast<QKeyEvent*
>(aEvent);
3341 if ((e->key() == (Qt::Key_Down)) ||
3342 (e->key() == (Qt::Key_PageDown)) ||
3343 (e->key() == (Qt::Key_Up)) ||
3344 (e->key() == (Qt::Key_PageUp))) {
3345 int selection = fHistoryTBTableList->currentRow();
3346 if (fHistoryTBTableList->count()) {
3347 if (selection == -1) {
3348 selection = fHistoryTBTableList->count()-1;
3350 if (e->key() == (Qt::Key_Down)) {
3351 if (selection <(fHistoryTBTableList->count()-1))
3353 }
else if (e->key() == (Qt::Key_PageDown)) {
3354 selection = fHistoryTBTableList->count()-1;
3355 }
else if (e->key() == (Qt::Key_Up)) {
3358 }
else if (e->key() == (Qt::Key_PageUp)) {
3362 fHistoryTBTableList->clearSelection();
3363 #if QT_VERSION < 0x040202
3364 fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),
true);
3366 fHistoryTBTableList->item(selection)->setSelected(
true);
3368 fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
3370 moveCommandCursor =
true;
3371 }
else if (e->key() == (Qt::Key_Tab)) {
3373 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
3374 fCommandArea->home(
false);
3376 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
3377 fCommandArea->end(
false);
3382 if (tabKeyPress ==
true) {
3383 G4String ss = Complete(fCommandArea->text().toStdString().c_str());
3384 fCommandArea->setText((
char*)(ss.
data()));
3385 fCommandArea->setFocus();
3394 if (moveCommandCursor ==
true) {
3395 fCommandArea->setCursorPosition ( fCommandArea->text().length() );
3396 fCommandArea->setCursorPosition (4);
3399 res = QObject::eventFilter(aObj, aEvent);
3405 void G4UIQt::UpdateCommandCompleter() {
3406 if (!fCommandArea)
return;
3409 fCommandArea->setCompleter(NULL);
3411 if (fCompleter->popup()) {
3412 fCompleter->popup()->removeEventFilter(
this);
3416 QStandardItemModel*
model = CreateCompleterModel(
"/");
3417 fCompleter =
new QCompleter(model);
3424 int Ndir= aTree-> GetTreeEntry();
3425 fCompleter->setMaxVisibleItems(Ndir);
3427 fCommandArea->setCompleter(fCompleter);
3428 fCompleter->popup()->installEventFilter(
this);
3432 QStandardItemModel* G4UIQt::CreateCompleterModel(
G4String aCmd) {
3434 QList< QStandardItem*> dirModelList;
3435 QList< QStandardItem*> commandModelList;
3436 QList< QStandardItem*> subDirModelList;
3437 QList< QStandardItem*> subCommandModelList;
3449 if(jpre !=
G4int(G4String::npos)) pName.
remove(jpre+1);
3454 int Ndir= aTree-> GetTreeEntry();
3455 int Ncmd= aTree-> GetCommandEntry();
3458 for(
G4int idir=1; idir<=Ndir; idir++) {
3459 G4String fpdir= aTree-> GetTree(idir)-> GetPathName();
3461 if( fpdir.
index(remainingPath, 0) == 0) {
3463 matchingPath = fpdir;
3470 QStandardItem* item1 =
new QStandardItem(fpdir.
data());
3471 QIcon i = QIcon(*fDirIcon);
3473 item1->setIcon(QIcon(*fDirIcon));
3474 dirModelList.append(item1);
3477 QStandardItemModel* subModel = CreateCompleterModel(fpdir.
data());
3478 for (
int a=0; a< subModel->rowCount(); a++) {
3481 QStandardItem* tempItem =
new QStandardItem(subModel->item(a)->text());
3482 tempItem->setIcon(subModel->item(a)->icon());
3483 tempItem->setToolTip(subModel->item(a)->toolTip());
3484 tempItem->setData(subModel->item(a)->data());
3487 if (tempItem->data() == 1) {
3489 subDirModelList.append(tempItem);
3492 else if (tempItem->data() == 0) {
3493 subCommandModelList.append(tempItem);
3500 G4int n_parameterEntry;
3502 G4int n_guidanceEntry;
3505 std::string tooltip;
3508 for(
G4int icmd=1; icmd<=Ncmd; icmd++){
3511 command = aTree-> GetCommand(icmd);
3512 G4String longCommandName= aTree-> GetPathName() +
3513 command -> GetCommandName();
3520 if( longCommandName.
index(remainingPath, 0) ==0) {
3522 matchingPath= longCommandName +
" ";
3524 strtmp= longCommandName +
" ";
3529 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3531 if (i_thGuidance < n_guidanceEntry-1 ) {
3537 for(
G4int a=0; a<n_parameterEntry; a++ ) {
3544 QStandardItem* item =
new QStandardItem(
G4String(longCommandName + params).
data());
3546 item->setIcon(QIcon(*fCommandIcon));
3547 item->setToolTip(tooltip.c_str());
3549 commandModelList.append(item);
3554 QStandardItemModel* model =
new QStandardItemModel();
3556 model->setColumnCount(1);
3559 for (
int a= 0; a< dirModelList.size(); a++) {
3560 model->appendRow(dirModelList.at(a));
3562 for (
int a= 0; a< subDirModelList.size(); a++) {
3563 model->appendRow(subDirModelList.at(a));
3565 for (
int a= 0; a< commandModelList.size(); a++) {
3566 model->appendRow(commandModelList.at(a));
3568 for (
int a= 0; a< subCommandModelList.size(); a++) {
3569 model->appendRow(subCommandModelList.at(a));
3584 void G4UIQt::ShowHelpCallback (
3593 void G4UIQt::ClearButtonCallback (
3596 fCoutTBTextArea->clear();
3597 fG4OutputString.clear();
3602 void G4UIQt::ExitSession (
3608 void G4UIQt::ExitHelp(
3616 void G4UIQt::CommandEnteredCallback (
3620 fCommandArea->setText(fCommandArea->text().trimmed());
3621 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
3624 for (
int a=0; a< list.size(); a++) {
3625 QString txt (list[a].trimmed());
3627 fHistoryTBTableList->addItem(txt);
3628 fHistoryTBTableList->clearSelection();
3629 fHistoryTBTableList->setCurrentItem(NULL);
3630 fCommandArea->setText(
"");
3631 G4Qt* interactorManager = G4Qt::getInstance ();
3632 if (interactorManager) {
3633 interactorManager->FlushAndWaitExecution();
3636 G4String command = txt.toStdString().c_str();
3637 if (command(0,4) !=
"help") {
3638 ApplyShellCommand (command,exitSession,exitPause);
3640 ActivateCommand(command);
3645 fCommandArea->setFocus();
3651 UpdateCommandCompleter();
3653 if(exitSession==
true)
3662 void G4UIQt::CommandEditedCallback(
const QString &)
3664 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
3666 if (list.size() > 1) {
3667 for (
int a=0; a<list.size()-1; a++) {
3669 fCommandArea->setText(list[a]);
3671 CommandEnteredCallback();
3674 fCommandArea->setText(list[list.size()-1]);
3681 void G4UIQt::VisParameterCallback(QWidget* widget){
3682 if (widget == NULL) {
3687 QGridLayout* grid =
dynamic_cast<QGridLayout*
>(widget->layout());
3692 #if QT_VERSION < 0x040400
3693 QWidget* name = grid->itemAt(grid->columnCount()*(grid->rowCount()-2))->widget();
3695 QWidget* name = grid->itemAtPosition(grid->rowCount()-1,0)->widget();
3697 if (dynamic_cast<QLabel*>(name) == 0) {
3700 command += (
dynamic_cast<QLabel*
>(
name))->text()+
" ";
3702 for (
int a=0;a<grid->rowCount()-1; a++) {
3703 #if QT_VERSION < 0x040400
3704 QWidget* widgetTmp = grid->itemAt(a*grid->columnCount()+1)->widget();
3706 QWidget* widgetTmp = grid->itemAtPosition(a,1)->widget();
3710 if (widgetTmp != NULL) {
3712 if (dynamic_cast<QLineEdit*>(widgetTmp) != 0) {
3713 command += (
dynamic_cast<QLineEdit*
>(widgetTmp))->text()+
" ";
3715 }
else if (dynamic_cast<QComboBox*>(widgetTmp) != 0){
3716 command += (
dynamic_cast<QComboBox*
>(widgetTmp))->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex())+
" ";
3719 }
else if (dynamic_cast<QPushButton*>(widgetTmp) != 0){
3720 command += widgetTmp->accessibleName()+
" ";
3723 }
else if (dynamic_cast<QWidget*>(widgetTmp) != 0){
3724 if (widgetTmp->layout()->count() > 0){
3725 if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != 0) {
3726 QAbstractButton * checked = (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton();
3728 command += (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton()->text()+
" ";
3736 if (command !=
"") {
3750 void G4UIQt::ButtonCallback (
3751 const QString& aCommand
3758 if(UI==NULL)
return;
3765 if (IsGUICommand(command)) {
3766 QDialog* menuParameterDialog =
new QDialog();
3768 if (CreateVisCommandGroupAndToolBox(command,menuParameterDialog,1,
true)) {
3769 menuParameterDialog->setWindowTitle (aCommand);
3770 menuParameterDialog->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
3773 menuParameterDialog->exec();
3776 delete menuParameterDialog;
3780 ApplyShellCommand(ss,exitSession,exitPause);
3785 if(exitSession==
true)
3793 void G4UIQt::HelpTreeClicCallback (
3796 QTreeWidgetItem* item = NULL;
3797 if (!fHelpTreeWidget)
3800 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
3803 item = list.first();
3808 if(UI==NULL)
return;
3811 std::string itemText = GetLongCommandPath(item).toStdString();
3814 if (item->childCount() > 0) {
3820 updateHelpArea(command);
3826 fParameterHelpLabel->setVisible(
true);
3828 fParameterHelpTable->setVisible(
false);
3835 void G4UIQt::HelpTreeDoubleClicCallback (
3838 HelpTreeClicCallback();
3840 QTreeWidgetItem* item = NULL;
3841 if (!fHelpTreeWidget)
3844 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
3847 item = list.first();
3851 fCommandArea->clear();
3852 fCommandArea->setText(GetLongCommandPath(item));
3859 void G4UIQt::CommandHistoryCallback(
3862 QListWidgetItem* item = NULL;
3863 if (!fHistoryTBTableList)
3867 QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
3870 item = list.first();
3873 fCommandArea->setText(item->text());
3877 void G4UIQt::ThreadComboBoxCallback(
int) {
3878 CoutFilterCallback(
"");
3882 void G4UIQt::CoutFilterCallback(
3885 FilterAllOutputTextArea();
3887 fCoutTBTextArea->repaint();
3888 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
3893 void G4UIQt::SaveOutputCallback(){
3894 QString fileName = QFileDialog::getSaveFileName(fMainWindow,
"Save console output as...", fLastOpenPath,
"Save output as...");
3895 if (fileName !=
"") {
3897 QFile
data(fileName);
3898 if (
data.open(QFile::WriteOnly | QFile::Truncate)) {
3899 QTextStream out(&
data);
3900 out << fCoutTBTextArea->toPlainText();
3908 QString G4UIQt::FilterOutput(
3909 const G4UIOutputString& output
3910 ,
const QString& currentThread
3911 ,
const QString& filter
3914 #ifdef G4MULTITHREADED
3915 if ((currentThread ==
"All") ||
3916 (currentThread == output.fThread)) {
3918 if (currentThread ==
"") {
3920 if (output.fText.contains(QRegExp(filter))) {
3921 return output.fText;
3928 void G4UIQt::FilterAllOutputTextArea() {
3930 QString currentThread =
"";
3931 #ifdef G4MULTITHREADED
3932 currentThread = fThreadsFilterComboBox->currentText();
3933 if (currentThread ==
"Master") {
3937 QString filter = fCoutFilter->text();
3938 G4String previousOutputStream =
"";
3940 fCoutTBTextArea->clear();
3941 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3943 for (
unsigned int a=0; a<fG4OutputString.size(); a++) {
3944 G4UIOutputString out = fG4OutputString[a];
3945 if (FilterOutput(out,currentThread,filter) !=
"") {
3948 if (out.fOutputStream != previousOutputStream) {
3949 previousOutputStream = out.fOutputStream;
3950 if (out.fOutputStream ==
"info") {
3951 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3953 fCoutTBTextArea->setTextColor(QColor(Qt::red));
3956 fCoutTBTextArea->
append(out.fText);
3959 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3967 void G4UIQt::LookForHelpStringCallback(
3970 fHelpLine->setText(fHelpLine->text().trimmed());
3971 QString searchText = fHelpLine->text();
3973 fParameterHelpLabel->setText(
"");
3974 fParameterHelpTable->setVisible(
false);
3975 if (searchText ==
"") {
3977 fHelpTreeWidget->clear();
3983 OpenHelpTreeOnCommand(searchText);
3988 void G4UIQt::OpenHelpTreeOnCommand(
3989 const QString & searchText
3994 if(UI==NULL)
return;
4000 fHelpTreeWidget->clear();
4006 QMap<int,QString> commandResultMap;
4007 QMap<int,QString> commandChildResultMap;
4009 for (
int a=0;a<treeSize;a++) {
4011 tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
4016 commandChildResultMap = LookForHelpStringInChildTree(treeTop->
GetTree(a+1),searchText);
4018 if (!commandChildResultMap.empty()) {
4019 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
4020 while (i != commandChildResultMap.constEnd()) {
4021 commandResultMap.insertMulti(i.key(),i.value());
4024 commandChildResultMap.clear();
4029 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
4030 fHelpTreeWidget->setColumnCount(2);
4032 labels << QString(
"Command") << QString(
"Match");
4033 fHelpTreeWidget->setHeaderLabels(labels);
4035 if (commandResultMap.empty()) {
4036 fParameterHelpLabel->setText(
"No match found");
4037 fParameterHelpTable->setVisible(
false);
4041 QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
4044 float multValue = 10.0/(float)(i.key());
4045 QString progressChar =
"|";
4046 QString progressStr =
"|";
4048 QTreeWidgetItem * newItem;
4051 if (i == commandResultMap.constBegin()) {
4054 for(
int a=0;a<
int(i.key()*multValue);a++) {
4055 progressStr += progressChar;
4057 newItem =
new QTreeWidgetItem();
4058 QString commandStr = i.value().trimmed();
4060 if (commandStr.indexOf(
"/") == 0) {
4061 commandStr = commandStr.right(commandStr.size()-1);
4064 newItem->setText(0,commandStr);
4065 newItem->setText(1,progressStr);
4066 fHelpTreeWidget->addTopLevelItem(newItem);
4067 #if QT_VERSION < 0x040200
4069 newItem->setForeground ( 1, QBrush(Qt::blue) );
4074 fHelpTreeWidget->resizeColumnToContents (0);
4075 fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
4082 QMap<int,QString> G4UIQt::LookForHelpStringInChildTree(
4084 ,
const QString & text
4087 QMap<int,QString> commandResultMap;
4088 if (aCommandTree == NULL)
return commandResultMap;
4093 QMap<int,QString> commandChildResultMap;
4097 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
4102 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->
GetTree(a+1),text);
4104 if (!commandChildResultMap.empty()) {
4106 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
4107 while (i != commandChildResultMap.constEnd()) {
4108 commandResultMap.insertMulti(i.key(),i.value());
4111 commandChildResultMap.clear();
4118 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
4124 return commandResultMap;
4128 QString G4UIQt::GetShortCommandPath(
4132 if (commandPath.indexOf(
"/") == 0) {
4133 commandPath = commandPath.right(commandPath.size()-1);
4136 commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf(
"/",-2)-1);
4138 if (commandPath.lastIndexOf(
"/") == (commandPath.size()-1)) {
4139 commandPath = commandPath.left(commandPath.size()-1);
4146 QString G4UIQt::GetLongCommandPath(
4147 QTreeWidgetItem* item
4150 if (item == NULL)
return "";
4153 QString itemText =
"";
4154 itemText = item->text(0);
4156 while (item->parent() != NULL) {
4157 itemText = item->parent()->text(0)+
"/"+itemText;
4158 item = item->parent();
4160 itemText =
"/"+itemText;
4166 void G4UIQt::ChangeColorCallback(QWidget* widget) {
4167 if (widget == NULL) {
4171 QPushButton* button =
dynamic_cast<QPushButton*
>(widget);
4175 QString
value = button->accessibleName();
4178 old.setRgbF(value.section(
" ",0,1).toDouble(),
4179 value.section(
" ",1,2).toDouble(),
4180 value.section(
" ",2,3).toDouble());
4181 #if QT_VERSION < 0x040500
4183 QColor color = QColor(QColorDialog::getRgba (old.rgba(),&a,fUITabWidget));
4185 QColor color = QColorDialog::getColor(old,
4188 QColorDialog::ShowAlphaChannel);
4192 if (color.isValid()) {
4194 QPixmap pixmap = QPixmap(QSize(16, 16));
4195 pixmap.fill (color);
4196 QPainter painter(&pixmap);
4197 painter.setPen(Qt::black);
4198 painter.drawRect(0,0,15,15);
4200 button->setAccessibleName(QString::number(color.redF())+
" "+
4201 QString::number(color.greenF())+
" "+
4202 QString::number(color.blueF())+
" "
4204 button->setIcon(pixmap);
4211 void G4UIQt::ChangeCursorAction(
const QString& action) {
4215 fMoveSelected =
true;
4216 fPickSelected =
true;
4217 fRotateSelected =
true;
4218 fZoomInSelected =
true;
4219 fZoomOutSelected =
true;
4221 if (fToolbarApp == NULL)
return;
4222 QList<QAction *> list = fToolbarApp->actions ();
4223 for (
int i = 0; i < list.size(); ++i) {
4224 if (list.at(i)->data().toString () == action) {
4225 list.at(i)->setChecked(
TRUE);
4226 if (list.at(i)->data().toString () ==
"pick") {
4228 CreatePickInfosDialog();
4230 fPickInfosDialog->show();
4231 fPickInfosDialog->raise();
4232 fPickInfosDialog->activateWindow();
4234 }
else if (list.at(i)->data().toString () ==
"move") {
4235 fMoveSelected =
false;
4236 list.at(i)->setChecked(
FALSE);
4237 }
else if (list.at(i)->data().toString () ==
"pick") {
4238 fPickSelected =
false;
4239 list.at(i)->setChecked(
FALSE);
4241 if (fPickInfosDialog) {
4242 fPickInfosDialog->hide();
4244 }
else if (list.at(i)->data().toString () ==
"rotate") {
4245 fRotateSelected =
false;
4246 list.at(i)->setChecked(
FALSE);
4247 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4248 fZoomInSelected =
false;
4249 list.at(i)->setChecked(
FALSE);
4250 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4251 fZoomOutSelected =
false;
4252 list.at(i)->setChecked(
FALSE);
4265 void G4UIQt::ChangeSurfaceStyle(
const QString& action) {
4269 if (fToolbarApp == NULL)
return;
4270 QList<QAction *> list = fToolbarApp->actions ();
4271 for (
int i = 0; i < list.size(); ++i) {
4272 if (list.at(i)->data().toString () == action) {
4273 list.at(i)->setChecked(
TRUE);
4274 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4275 list.at(i)->setChecked(
FALSE);
4276 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4277 list.at(i)->setChecked(
FALSE);
4278 }
else if (list.at(i)->data().toString () ==
"solid") {
4279 list.at(i)->setChecked(
FALSE);
4280 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4281 list.at(i)->setChecked(
FALSE);
4286 if (action ==
"hidden_line_removal") {
4290 }
else if (action ==
"hidden_line_and_surface_removal") {
4294 }
else if (action ==
"solid") {
4298 }
else if (action ==
"wireframe") {
4305 void G4UIQt::OpenIconCallback(
const QString& aParam) {
4307 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4308 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
4310 QString nomFich = QFileDialog::getOpenFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
4311 if (nomFich !=
"") {
4314 fLastOpenPath = dir.absoluteFilePath(nomFich);
4319 void G4UIQt::SaveIconCallback(
const QString& aParam) {
4321 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4322 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
4324 QString nomFich = QFileDialog::getSaveFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
4325 if (nomFich !=
"") {
4328 fLastOpenPath = dir.absoluteFilePath(nomFich);
4333 void G4UIQt::CreateViewerPropertiesDialog() {
4335 if (fViewerPropertiesDialog != NULL) {
4338 fViewerPropertiesDialog =
new QDialog();
4340 fViewerPropertiesDialog->setWindowTitle(
"Viewer properties");
4341 fViewerPropertiesDialog->setSizePolicy (QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
4343 if (!fViewerPropertiesWidget) {
4344 fViewerPropertiesWidget =
new QWidget();
4345 QVBoxLayout* layoutPropertiesWidget =
new QVBoxLayout();
4346 fViewerPropertiesWidget->setLayout(layoutPropertiesWidget);
4348 CreateEmptyViewerPropertiesWidget();
4351 QVBoxLayout* layoutDialog =
new QVBoxLayout();
4353 layoutDialog->addWidget(fViewerPropertiesWidget);
4354 layoutDialog->setContentsMargins(0,0,0,0);
4355 fViewerPropertiesDialog->setLayout(layoutDialog);
4359 void G4UIQt::CreatePickInfosDialog() {
4361 if (fPickInfosDialog != NULL) {
4364 fPickInfosDialog =
new QDialog();
4366 fPickInfosDialog->setWindowTitle(
"Pick infos");
4367 fPickInfosDialog->setSizePolicy (QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
4369 if (!fPickInfosWidget) {
4370 fPickInfosWidget =
new QWidget();
4371 QVBoxLayout* layoutPickInfos =
new QVBoxLayout();
4372 fPickInfosWidget->setLayout(layoutPickInfos);
4374 CreateEmptyPickInfosWidget();
4377 QVBoxLayout* layoutDialog =
new QVBoxLayout();
4379 layoutDialog->addWidget(fPickInfosWidget);
4380 layoutDialog->setContentsMargins(0,0,0,0);
4381 fPickInfosDialog->setLayout(layoutDialog);
4385 void G4UIQt::CreateEmptyViewerPropertiesWidget() {
4386 QLayoutItem * wItem;
4387 if (fViewerPropertiesWidget->layout()->count()) {
4388 while ((wItem = fViewerPropertiesWidget->layout()->takeAt(0)) != 0) {
4389 delete wItem->widget();
4394 QLabel* label =
new QLabel(
"No viewer - Please open a viewer first");
4395 fViewerPropertiesWidget->layout()->addWidget(label);
4396 fViewerPropertiesDialog->setWindowTitle(
"No viewer");
4400 void G4UIQt::CreateEmptyPickInfosWidget() {
4401 QLayoutItem * wItem;
4402 if (fPickInfosWidget->layout()->count()) {
4403 while ((wItem = fPickInfosWidget->layout()->takeAt(0)) != 0) {
4404 delete wItem->widget();
4409 QLabel* label =
new QLabel(
"Click on the object you want to pick");
4410 fPickInfosWidget->layout()->addWidget(label);
4411 fPickInfosDialog->setWindowTitle(
"Nothing to pick");
4415 void G4UIQt::ViewerPropertiesIconCallback(
int) {
4417 CreateViewerPropertiesDialog();
4419 fViewerPropertiesDialog->show();
4420 fViewerPropertiesDialog->raise();
4421 fViewerPropertiesDialog->activateWindow();
4425 void G4UIQt::ChangePerspectiveOrtho(
const QString& action) {
4429 if (fToolbarApp == NULL)
return;
4430 QList<QAction *> list = fToolbarApp->actions ();
4431 QString checked =
"";
4432 for (
int i = 0; i < list.size(); ++i) {
4433 if (list.at(i)->data().toString () == action) {
4434 list.at(i)->setChecked(
TRUE);
4435 checked = list.at(i)->data().toString ();
4436 }
else if (list.at(i)->data().toString () ==
"persepective") {
4437 list.at(i)->setChecked(
FALSE);
4438 }
else if (list.at(i)->data().toString () ==
"ortho") {
4439 list.at(i)->setChecked(
FALSE);
4443 if ((action ==
"ortho") && (checked ==
"ortho")) {
4445 }
else if ((action ==
"perspective") && (checked ==
"perspective")) {
4452 void G4UIQt::SetIconMoveSelected() {
4454 fMoveSelected =
true;
4455 fRotateSelected =
false;
4456 fPickSelected =
false;
4457 fZoomInSelected =
false;
4458 fZoomOutSelected =
false;
4460 if (fToolbarApp == NULL)
return;
4461 QList<QAction *> list = fToolbarApp->actions ();
4462 for (
int i = 0; i < list.size(); ++i) {
4463 if (list.at(i)->data().toString () ==
"move") {
4464 list.at(i)->setChecked(
TRUE);
4465 }
else if (list.at(i)->data().toString () ==
"rotate") {
4466 list.at(i)->setChecked(
FALSE);
4467 }
else if (list.at(i)->data().toString () ==
"pick") {
4468 list.at(i)->setChecked(
FALSE);
4469 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4470 list.at(i)->setChecked(
FALSE);
4471 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4472 list.at(i)->setChecked(
FALSE);
4478 void G4UIQt::SetIconRotateSelected() {
4480 fRotateSelected =
true;
4481 fMoveSelected =
false;
4482 fPickSelected =
false;
4483 fZoomInSelected =
false;
4484 fZoomOutSelected =
false;
4486 if (fToolbarApp == NULL)
return;
4487 QList<QAction *> list = fToolbarApp->actions ();
4488 for (
int i = 0; i < list.size(); ++i) {
4489 if (list.at(i)->data().toString () ==
"rotate") {
4490 list.at(i)->setChecked(
TRUE);
4491 }
else if (list.at(i)->data().toString () ==
"move") {
4492 list.at(i)->setChecked(
FALSE);
4493 }
else if (list.at(i)->data().toString () ==
"pick") {
4494 list.at(i)->setChecked(
FALSE);
4495 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4496 list.at(i)->setChecked(
FALSE);
4497 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4498 list.at(i)->setChecked(
FALSE);
4504 void G4UIQt::SetIconPickSelected() {
4506 fPickSelected =
true;
4507 fMoveSelected =
false;
4508 fRotateSelected =
false;
4509 fZoomInSelected =
false;
4510 fZoomOutSelected =
false;
4512 QToolBar*
bar = fToolbarApp;
4513 if (!fDefaultIcons) {
4518 QList<QAction *> list = bar->actions ();
4519 for (
int i = 0; i < list.size(); ++i) {
4520 if (list.at(i)->data().toString () ==
"pick") {
4521 list.at(i)->setChecked(
TRUE);
4522 }
else if (list.at(i)->data().toString () ==
"move") {
4523 list.at(i)->setChecked(
FALSE);
4524 }
else if (list.at(i)->data().toString () ==
"rotate") {
4525 list.at(i)->setChecked(
FALSE);
4526 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4527 list.at(i)->setChecked(
FALSE);
4528 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4529 list.at(i)->setChecked(
FALSE);
4535 void G4UIQt::SetIconZoomInSelected() {
4537 fZoomInSelected =
true;
4538 fMoveSelected =
false;
4539 fRotateSelected =
false;
4540 fPickSelected =
false;
4541 fZoomOutSelected =
false;
4543 QToolBar* bar = fToolbarApp;
4544 if (!fDefaultIcons) {
4549 QList<QAction *> list = bar->actions ();
4550 for (
int i = 0; i < list.size(); ++i) {
4551 if (list.at(i)->data().toString () ==
"zoom_in") {
4552 list.at(i)->setChecked(
TRUE);
4553 }
else if (list.at(i)->data().toString () ==
"move") {
4554 list.at(i)->setChecked(
FALSE);
4555 }
else if (list.at(i)->data().toString () ==
"rotate") {
4556 list.at(i)->setChecked(
FALSE);
4557 }
else if (list.at(i)->data().toString () ==
"pick") {
4558 list.at(i)->setChecked(
FALSE);
4559 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4560 list.at(i)->setChecked(
FALSE);
4566 void G4UIQt::SetIconZoomOutSelected() {
4568 fZoomOutSelected =
true;
4569 fMoveSelected =
false;
4570 fRotateSelected =
false;
4571 fPickSelected =
false;
4572 fZoomInSelected =
false;
4574 QToolBar* bar = fToolbarApp;
4575 if (!fDefaultIcons) {
4580 QList<QAction *> list = bar->actions ();
4581 for (
int i = 0; i < list.size(); ++i) {
4582 if (list.at(i)->data().toString () ==
"zoom_out") {
4583 list.at(i)->setChecked(
TRUE);
4584 }
else if (list.at(i)->data().toString () ==
"move") {
4585 list.at(i)->setChecked(
FALSE);
4586 }
else if (list.at(i)->data().toString () ==
"rotate") {
4587 list.at(i)->setChecked(
FALSE);
4588 }
else if (list.at(i)->data().toString () ==
"pick") {
4589 list.at(i)->setChecked(
FALSE);
4590 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4591 list.at(i)->setChecked(
FALSE);
4597 void G4UIQt::SetIconSolidSelected() {
4600 QToolBar* bar = fToolbarApp;
4601 if (!fDefaultIcons) {
4606 QList<QAction *> list = bar->actions ();
4607 for (
int i = 0; i < list.size(); ++i) {
4608 if (list.at(i)->data().toString () ==
"solid") {
4609 list.at(i)->setChecked(
TRUE);
4610 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4611 list.at(i)->setChecked(
FALSE);
4612 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4613 list.at(i)->setChecked(
FALSE);
4614 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4615 list.at(i)->setChecked(
FALSE);
4621 void G4UIQt::SetIconWireframeSelected() {
4624 QToolBar* bar = fToolbarApp;
4625 if (!fDefaultIcons) {
4630 QList<QAction *> list = bar->actions ();
4631 for (
int i = 0; i < list.size(); ++i) {
4632 if (list.at(i)->data().toString () ==
"wireframe") {
4633 list.at(i)->setChecked(
TRUE);
4634 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4635 list.at(i)->setChecked(
FALSE);
4636 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4637 list.at(i)->setChecked(
FALSE);
4638 }
else if (list.at(i)->data().toString () ==
"solid") {
4639 list.at(i)->setChecked(
FALSE);
4645 void G4UIQt::SetIconHLRSelected() {
4648 QToolBar* bar = fToolbarApp;
4649 if (!fDefaultIcons) {
4655 QList<QAction *> list = bar->actions ();
4656 for (
int i = 0; i < list.size(); ++i) {
4657 if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4658 list.at(i)->setChecked(
TRUE);
4659 }
else if (list.at(i)->data().toString () ==
"solid") {
4660 list.at(i)->setChecked(
FALSE);
4661 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4662 list.at(i)->setChecked(
FALSE);
4663 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4664 list.at(i)->setChecked(
FALSE);
4670 void G4UIQt::SetIconHLHSRSelected() {
4673 QToolBar* bar = fToolbarApp;
4674 if (!fDefaultIcons) {
4680 QList<QAction *> list = bar->actions ();
4681 for (
int i = 0; i < list.size(); ++i) {
4682 if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4683 list.at(i)->setChecked(
TRUE);
4684 }
else if (list.at(i)->data().toString () ==
"solid") {
4685 list.at(i)->setChecked(
FALSE);
4686 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4687 list.at(i)->setChecked(
FALSE);
4688 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4689 list.at(i)->setChecked(
FALSE);
4695 void G4UIQt::SetIconPerspectiveSelected() {
4698 QToolBar* bar = fToolbarApp;
4699 if (!fDefaultIcons) {
4705 QList<QAction *> list = bar->actions ();
4706 for (
int i = 0; i < list.size(); ++i) {
4707 if (list.at(i)->data().toString () ==
"perspective") {
4708 list.at(i)->setChecked(
TRUE);
4709 }
else if (list.at(i)->data().toString () ==
"ortho") {
4710 list.at(i)->setChecked(
FALSE);
4717 void G4UIQt::SetIconOrthoSelected() {
4720 QToolBar* bar = fToolbarApp;
4721 if (!fDefaultIcons) {
4727 QList<QAction *> list = bar->actions ();
4728 for (
int i = 0; i < list.size(); ++i) {
4729 if (list.at(i)->data().toString () ==
"ortho") {
4730 list.at(i)->setChecked(
TRUE);
4731 }
else if (list.at(i)->data().toString () ==
"perspective") {
4732 list.at(i)->setChecked(
FALSE);
4739 G4QTabWidget::G4QTabWidget(
4743 ):QTabWidget(aParent)
4744 ,fTabSelected(false)
4746 ,fPreferedSizeX(sizeX+6)
4747 ,fPreferedSizeY(sizeY+58)
4749 setMinimumSize(100,100);
4750 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
4751 setSizePolicy(policy);
4754 G4QTabWidget::G4QTabWidget(
4756 ,fTabSelected(false)
4764 G4UIOutputString::G4UIOutputString(
4772 if (!GetOutputList().contains(QString(
" ")+outputStream+
" ")) {
4773 fOutputStream =
"info";
4775 fOutputStream = outputStream;
4780 #if QT_VERSION < 0x040500
4781 void G4UIQt::TabCloseCallback(
int){
4783 void G4UIQt::TabCloseCallback(
int a){
4785 #if QT_VERSION < 0x040500
4787 if (fViewerTabWidget == NULL)
return;
4790 QWidget* temp = fViewerTabWidget->widget(a);
4792 fViewerTabWidget->removeTab (a);
4795 bool lastTab =
true;
4796 for (
int c=0; c<fViewerTabWidget->count(); c++) {
4797 if (fViewerTabWidget->tabText(c).contains(
"viewer")) {
4803 CreateEmptyViewerPropertiesWidget();
4811 void G4UIQt::ToolBoxActivated(
int a){
4813 if (fUITabWidget->widget(a) == fHelpTBWidget) {
4816 }
else if (fUITabWidget->widget(a) == fSceneTreeWidget) {
4817 #if QT_VERSION < 0x040200
4818 fSceneTreeWidget->show();
4820 fSceneTreeWidget->setVisible(
true);
4826 void G4QTabWidget::paintEvent(
4831 if (currentWidget()) {
4833 if ( isTabSelected()) {
4837 QString text = tabText (currentIndex());
4839 if (fLastCreated == -1) {
4840 QTextEdit* edit =
dynamic_cast<QTextEdit*
>(currentWidget());
4842 QString paramSelect = QString(
"/vis/viewer/select ")+text;
4851 setTabSelected(
false);
4857 G4UIDockWidget::G4UIDockWidget(QString txt):
4862 void G4UIDockWidget::closeEvent(QCloseEvent *aEvent) {
4863 setFloating (
false);
G4double G4ParticleHPJENDLHEData::G4double result
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4MTcoutDestination * GetThreadCout()
G4String GetParameterCandidates() const
const G4String & GetRange() const
G4String & remove(str_size)
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
G4int GetVerboseLevel() const
void SetSession(G4UIsession *const value)
const G4String & GetGuidanceLine(G4int i) const
#define G4MUTEX_INITIALIZER
void SetG4UIWindow(G4UIsession *const value)
const XML_Char const XML_Char * data
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
const XML_Char int const XML_Char * value
G4UIcommandTree * GetTree(G4int i)
G4UIparameter * GetParameter(G4int i) const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
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
const XML_Char XML_Content * model
G4int GetParameterEntries() const
G4String FindMacroPath(const G4String &fname) const
G4bool GetCurrentAsDefault() const
static const G4double pos
G4int ApplyCommand(const char *aCommand)