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 ,fLastCompleteCommand(
"")
171 ,fMoveSelected(false)
172 ,fRotateSelected(true)
173 ,fPickSelected(false)
174 ,fZoomInSelected(false)
175 ,fZoomOutSelected(false)
178 G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(
char*)
"Qt");
179 if (!(QApplication*)interactorManager->GetMainInteractor()) {
184 G4cout <<
"G4UIQt : Unable to init Qt. Aborted" <<
G4endl;
194 Q_FOREACH (QWidget *
widget, QApplication::allWidgets()) {
195 if ((found==
false) && (widget->inherits(
"QMainWindow"))) {
205 G4cout <<
"G4UIQt : Found an external App with a QMainWindow already defined. Aborted" <<
G4endl;
211 fMainWindow =
new QMainWindow();
212 fMainWindow->setAttribute(Qt::WA_DeleteOnClose);
214 fMainWindow->setCorner( Qt::TopLeftCorner, Qt::LeftDockWidgetArea );
215 fMainWindow->setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
216 fMainWindow->setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
217 fMainWindow->setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
219 CreateViewerWidget();
220 fMainWindow->addDockWidget(Qt::LeftDockWidgetArea, CreateUITabWidget());
221 fMainWindow->addDockWidget(Qt::BottomDockWidgetArea, CreateCoutTBWidget());
225 SetDefaultIconsToolbar();
229 #ifdef G4MULTITHREADED
231 masterG4coutDestination =
this;
234 fMainWindow->setWindowTitle(QFileInfo( QCoreApplication::applicationFilePath() ).fileName());
235 fMainWindow->move(QPoint(50,50));
240 fMainWindow->resize(fUIDockWidget->width()+fCoutDockWidget->width()+20,
241 fUIDockWidget->height()+fCoutDockWidget->height()+20);
244 fCommandArea->setFocus(Qt::TabFocusReason);
248 qRegisterMetaType<QTextCursor>(
"QTextCursor");
251 AddTabWidget(fStartPage,
"Useful tips");
254 #if QT_VERSION < 0x040200
257 fMainWindow->setVisible(
false);
271 #ifdef G4MULTITHREADED
272 masterG4coutDestination = 0;
278 void G4UIQt::DefaultIcons(
bool aVal)
280 fDefaultIcons = aVal;
282 #if QT_VERSION < 0x040200
283 if (!fMainWindow->isHidden()) {
285 if (!fMainWindow->isVisible()) {
292 #if QT_VERSION < 0x040200
295 fToolbarApp->setVisible(
true);
299 #if QT_VERSION < 0x040200
302 fToolbarApp->setVisible(
false);
309 void G4UIQt::SetDefaultIconsToolbar(
313 if (fToolbarApp == NULL) {
314 fToolbarApp =
new QToolBar();
315 fToolbarApp->setIconSize (QSize(20,20));
316 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
320 AddIcon(
"Open macro file",
"open",
"/control/execute");
321 AddIcon(
"Save viewer state",
"save",
"/vis/viewer/save");
324 QSignalMapper *signalMapperViewerProperties =
new QSignalMapper(
this);
325 QAction *actionViewerProperties = fToolbarApp->addAction(QIcon(*fParamIcon),
"Viewer properties", signalMapperViewerProperties, SLOT(map()));
326 connect(signalMapperViewerProperties, SIGNAL(mapped(
int)),
this, SLOT(ViewerPropertiesIconCallback(
int)));
328 signalMapperViewerProperties->setMapping(actionViewerProperties, intVP);
331 AddIcon(
"Move",
"move",
"");
332 AddIcon(
"Pick",
"pick",
"");
333 AddIcon(
"Zoom out",
"zoom_out",
"");
334 AddIcon(
"Zoom in",
"zoom_in",
"");
335 AddIcon(
"Rotate",
"rotate",
"");
338 AddIcon(
"Hidden line removal",
"hidden_line_removal",
"");
339 AddIcon(
"Hidden line and hidden surface removal",
"hidden_line_and_surface_removal",
"");
340 AddIcon(
"Surfaces",
"solid",
"");
341 AddIcon(
"Wireframe",
"wireframe",
"");
344 AddIcon(
"Perspective",
"perspective",
"");
345 AddIcon(
"Orthographic",
"ortho",
"");
346 AddIcon(
"Run beam on",
"runBeamOn",
"/run/beamOn 1");
351 void G4UIQt::CreateIcons(
354 const char *
const save[]={
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 " @;;@+++++++++++*)!>%@=;#+ ",
408 " @++++++++++++++*&**++@++ ",
413 fSaveIcon =
new QPixmap(save);
415 const char *
const search[] = {
427 "OOOOOOOOOOOOOOOOOOO",
428 "OOOOOOOOOOOOOOOOOOO",
429 "OOOOOOOo. .oOOOOOO",
432 "OOOOO. XOOOOX .OOOO",
435 "OOOOO. XOOOOo .OOOO",
439 "OOOOOOOOOOOOO. XOO",
440 "OOOOOOOOOOOOOO. XOO",
441 "OOOOOOOOOOOOOOOoOOO",
442 "OOOOOOOOOOOOOOOOOOO",
443 "OOOOOOOOOOOOOOOOOOO",
444 "OOOOOOOOOOOOOOOOOOO",
445 "OOOOOOOOOOOOOOOOOOO"
447 fSearchIcon =
new QPixmap(search);
449 const char *
const clear[] = {
461 "OOOOOOOOOOOOOOOOOOOO",
464 "OOOOOOOOOOOOOOOOOOOO",
465 "OOOOOOOOOOOOOOOOOOOO",
466 "OOOO XXXXXXXXXX OOOO",
467 "OOO XOOOOOOOOOO OOO",
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 "OOOOXOOOOOOOOOO OOOO",
479 "OOOOOooooooooooOOOOO",
480 "OOOOOO........OOOOOO"
483 fClearIcon =
new QPixmap(clear);
486 const char *
const open[]={
530 " {]^/((_({- %%%%%%%%%%% ",
531 " {(^_^^^^:<{{{{{{{{{{{{{[& ",
532 " {/_/(((((/]]]]]]]]]]]/]!# ",
533 " {/^(((((_^^^^^^^^^^^^^^:# ",
534 " {/^(((_^^____________^^}$ ",
535 " {/^(((((/////////////((!# ",
536 " {/^/^_:<|||||||||||||||@@****1 ",
537 " {/^/^(<[)||||||||||||||))!!}<; ",
538 " {/^_(:|234444444444444444432)1 ",
539 " {/_^/<)34444444444444444443}, ",
540 " {/^(2{:41111111111111111142|5 ",
541 " {3^3<:31111111111111111143}- ",
542 " {/^2<:31111111111111111441|' ",
543 " {_/<:41111111111111111143}, ",
544 " {(4<:31111111111111111144!# ",
545 " )4))44111111111111111144}, ",
546 " )2<:31111111111111111144{# ",
547 " @|:14444444444444444444}* ",
548 " ;@434444444444444444434<# ",
549 " ;[))))))))))))))))))))!~ ",
550 " ++++++++++++++++++++++;% ",
554 fOpenIcon =
new QPixmap(open);
557 const char *
const move[]={
590 " ')&$$$$*@@ @@*$$$$&)' ",
591 " ')&$$$$*@@ @@*$$$$&+' ",
608 fMoveIcon =
new QPixmap(move);
610 const char *
const rotate[]={
646 " --------!*{{{*&, ",
647 " -------=){*{{{>>{) ",
648 " ,!-----= ){& ,&{{@",
656 " !-!!======!!(((---! ",
657 " ='--------------! ",
672 fRotateIcon =
new QPixmap(rotate);
674 const char *
const pick[]={
690 "*********oo*********",
691 "*********oo*********",
692 "******$O. .O%******",
693 "****&o .O..O O*****",
694 "***&X @**oo**@ X****",
695 "***o $***oo***$ O***",
696 "**% @**********@ %**",
697 "**O.***********& +**",
698 "**.O*****@@*****o.**",
699 "oo .oo**@ #*&XX. oo",
700 "oo .oo**@ #*&oo. oO",
701 "**.O*****##*****oX**",
702 "**O ***********& +**",
703 "**% @****&&****+ &**",
704 "***O $***Xo***# +***",
705 "****X @&*Xo*&+ o****",
706 "*****O o..o +*****",
707 "******%+. X+&******",
708 "*********oo*********",
709 "*********oO*********"
711 fPickIcon =
new QPixmap(pick);
713 const char *
const zoom_in[]={
735 " ++.%%%+&&&*%%.++ ",
736 " .+#%%%%+&&&*%%.#+ ",
737 " ++..%%%+&&&*%%%.++ ",
738 " +#.+++++&&&*++++.+ ",
739 " @.+&&&&&&&&&&&&&+@ ",
740 " @#+&&&&&&&&&&&&&+@ ",
741 " @.+&&&&&&&&&&&&&+. ",
742 " +++@***+&&&****@+. ",
743 " ....++++&&&*++++.. ",
744 " ++.===+&&&*%=.++ ",
745 " @..==+&&&*=..@#& ",
746 " .@+#.+&&&@-+@@*@ ",
759 fZoomInIcon =
new QPixmap(zoom_in);
761 const char *
const zoom_out[]={
783 " ++.$$$$$$$$$$.++ ",
784 " .+#$$$$$$$$$$$.#+ ",
785 " ++..$$$$$$$$$$$.++ ",
786 " +#.+++++++++++++.+ ",
787 " @.+&&&&&&&&&&&&&+@ ",
788 " @#+&&&&&&&&&&&&&+@ ",
789 " @.+&&&&&&&&&&&&&+. ",
790 " +++@***********@+. ",
791 " ....++++++++++++.. ",
792 " ++.===$$$$$$=.++ ",
793 " @..===$$$$=..@#& ",
794 " .@+#.$$$..-+@@*@ ",
807 fZoomOutIcon =
new QPixmap(zoom_out);
809 const char *
const wireframe[]={
838 " +&********&@-***; ",
839 " +@@@&**&@@@@@@$ @*-&>&+ ",
840 " +*****&+ %*@ ,**'# ",
841 " @***)!~ @*{&*****+ ",
842 " @*!]***&+ +-*^**'~!*@ ",
843 " @*~ +@&**&@@@@@@&****&+ ~*@ ",
844 " @*@ +&********&-*= @*@ ",
845 " @*@ $%@-*-@$ @*@ @*@ ",
853 " @*@ =*-+ @*@ @*@ ",
854 " @*@ $%@@&****&@-*-+ @*@ ",
855 " @*@ $@&*****&@@&******&~~!*@ ",
856 " @*{/***&@@%$ $@-*-&*****+ ",
857 " @*)*)(-~ @*@ ~)**] ",
858 " +*******&@@@@+ %*_+]**] ",
859 " +@@@@@&******&@%+_*^**]# ",
868 fWireframeIcon =
new QPixmap(wireframe);
870 const char *
const solid[]={
908 " +-;>>>>>>>>>,')!~ ",
909 " {]@@-;>>>>>>>>>>>>^/(_= ",
910 " {:>>>>>>>>>>>>>>>>><//[)!= ",
911 " ]>>>>>>>>>>>>>>>>>><////[)} ",
912 " @>>>>>>>>>>>>>>>>>><//////| ",
913 " @>>>>>>>>>>>>>>>>>><//////| ",
914 " @>>>>>>>>>>>>>>>>>><//////| ",
915 " @>>>>>>>>>>>>>>>>>><//////| ",
916 " @>>>>>>>>>>>>>>>>>><//////| ",
917 " @>>>>>>>>>>>>>>>>>><//////| ",
918 " @>>>>>>>>>>>>>>>>>><//////| ",
919 " @>>>>>>>>>>>>>>>>>><//////| ",
920 " @>>>>>>>>>>>>>>>>>><//////| ",
921 " @>>>>>>>>>>>>>>>>>><//////| ",
922 " @>>>>>>>>>>>>>>>>>><//////| ",
923 " @>>>>>>>>>>>>>>>>>><//////| ",
924 " @>>>>>>>>>>>>>>>>>><//////| ",
925 " @>>>>>>>>>>>>>>>>>><//////| ",
926 " @>>>>>>>>>>>>>>>>>></////[1 ",
927 " @>>>>>>>>>>>>>>>>>><////[*2 ",
928 " {:>>>>>>>>>>>>>>>>><//[)12 ",
929 " +@@@@@-;>>>>>>>>>><[)13 ",
938 fSolidIcon =
new QPixmap(solid);
940 const char *
const hidden_line_removal[]={
960 " +#$$$$$$$$#@&$$$* ",
961 " =-@@#$$#@@@@@-= @$&#;>= ",
962 " =$$$$$#+ -$@ *$$%+ ",
963 " -$&@-= -$- #$$$= ",
979 " -$&@@@-= -$- =>;, ",
980 " =$$$$$$$#@@@-= -$'+#$$, ",
981 " =-@@@@#$$$$$$#@-+'$)$$#+ ",
990 fHiddenLineRemovalIcon =
new QPixmap(hidden_line_removal);
992 const char *
const hidden_line_and_surface_removal[]={
1038 " ++@%####&*=-#+;>, ",
1039 " +++++@'=)))))))!)~+{]^++ ",
1040 " +$%&*=)!!!!!!!!!)~+/(]_+++ ",
1041 " +#-))!!!!!!!!!!!)~+/(::<[+ ",
1042 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1043 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1044 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1045 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1046 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1047 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1048 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1049 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1050 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1051 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1052 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1053 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1054 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1055 " +#)!!!!!!!!!!!!!!}+/:::|1+ ",
1056 " +$#}}~23!!!!!!!!)~+/(]45, ",
1057 " +++++++@#}}~23!!)~+678++ ",
1058 " ++++++@#~90+a++ ",
1067 fHiddenLineAndSurfaceRemovalIcon =
new QPixmap(hidden_line_and_surface_removal);
1069 const char *
const perspective[]={
1079 " ................ ",
1080 " ....+++++++++++++++. ",
1081 " ...++++..+.........+++. ",
1082 " ..++..............++..+. ",
1083 " .+++++++++++++++++.. .+. ",
1084 " .+...............+. .+. ",
1085 " .+. .+. .+. .+. ",
1086 " .+. .+. .+. .+. ",
1087 " .+. .+. .+. .+. ",
1088 " .+. .+. .+. .+. ",
1089 " .+. .+. .+. .+. ",
1090 " .+. .+. .+. .+. ",
1091 " .+. .+. .+. .+. ",
1092 " .+. .+. .+. .+. ",
1093 " .+. .+......+....+. ",
1094 " .+. ..++++++.+.++++. ",
1095 " .+. .++.......+...+.. ",
1096 " .+. .++. .+..++. ",
1097 " .+. ..+.. .+..+. ",
1100 " .+++.............++. ",
1101 " .+++++++++++++++++. ",
1102 " ................... ",
1107 fPerspectiveIcon =
new QPixmap(perspective);
1109 const char *
const ortho[]={
1117 " ................... ",
1118 " ..@@@@@@@@@@@@@@@@@. ",
1119 " ..@@@.............@@@. ",
1120 " ..@@.@. ..@..@. ",
1121 " ..@@ ..@. .@@...@. ",
1122 " ..@@..............@@.. .@. ",
1123 " .@@@@@@@@@@@@@@@@@.. .@. ",
1124 " .@...............@. .@. ",
1125 " .@. .@. .@. .@. ",
1126 " .@. .@. .@. .@. ",
1127 " .@. .@. .@. .@. ",
1128 " .@. .@. .@. .@. ",
1129 " .@. .@. .@. .@. ",
1130 " .@. .@. .@. .@. ",
1131 " .@. .@. .@. .@. ",
1132 " .@. .@. .@. .@. ",
1133 " .@. .@. .@. .@. ",
1134 " .@. .@. .@. .@. ",
1135 " .@. .@........@......@. ",
1136 " .@. .@@@@@@@@@.@.@@@@@@. ",
1137 " .@. .@@+........@....@@.. ",
1138 " .@...@. .@...@... ",
1140 " .@@@.............@@@.. ",
1141 " .@@@@@@@@@@@@@@@@@... ",
1142 " ................... ",
1147 fOrthoIcon =
new QPixmap(ortho);
1149 const char *
const commandIcon[]={
1177 "66666666666666666666",
1178 "66%++++++++++++++&56",
1179 "6$ o..o......o..o *6",
1180 "6+o...o*<441;@.o..+6",
1181 "6+..o@1553<354$..o+6",
1182 "6+..o<5<@ .*54#o.+6",
1191 "6+..O25<@ X=54#o.+6",
1192 "6+.o.@1553<354$...@6",
1193 "6+o..oo*<44<;@o..o+6",
1194 "6$ .o..o.....o..o *6",
1195 "66%+++++OOOO+++++*66",
1196 "66666666666666666666"
1198 fCommandIcon =
new QPixmap(commandIcon);
1200 const char *
const dirIcon[]={
1228 "66666666666666666666",
1229 "66$oOOOOOOOOOOOOo%66",
1232 "6o =635533666$ o6",
1233 "6o -65:+ +165X o6",
1242 "6o -65:+ @265X o6",
1243 "6o =635543665# O6",
1246 "66$OOOoo....OOOOo%66",
1247 "66666666666666666666"}
1249 fDirIcon =
new QPixmap(dirIcon);
1252 const char *
const runIcon[]={
1289 "rrrrrrrr%<<2rrrrrrrr",
1290 "rrrrr5=$$$$===rrrrrr",
1291 "rrrr<##$$$$$---&rrrr",
1292 "rrr=###$$$$-----%rrr",
1293 "rr=####$$$$------&rr",
1294 "r2@####7##$-------rr",
1295 "r.@####048$-------Or",
1296 "r.@####q4ee=----$@.r",
1297 " .@@###w4eee5%$#@@@X",
1298 " .@@@..w4eeeeqo..@@X",
1299 " .@..ooe<eeee7Oooo@X",
1300 " ..oooOe2eee6OOOooo ",
1301 "rOooOO+e2ew2+++++O+r",
1302 "r:oO+++e30,;;;;;++Or",
1303 "r :++;:9,>,,>>:;;1rr",
1304 "rr*1;:>,333333,>32rr",
1305 "rrr66,1367777637<rrr",
1306 "rrrr509799999905rrrr",
1307 "rrrrr=8wqwwww8-rrrrr",
1308 "rrrrrrrr4444rrrrrrrr"
1310 fRunIcon =
new QPixmap(runIcon);
1312 const char *
const paramIcon[]={
1351 "wwwwwwww5 5wwwwwwww",
1352 "wwwwwwww, ,wwwwwwww",
1353 "www&;ww7+ +9ww=-www",
1359 "5<+ .wwwwwww0. +<5",
1362 "5<+ .wwwwwww0X +<5",
1368 "www*>ww7+ +7ww=:www",
1369 "wwwwwwww1 1wwwwwwww",
1370 "wwwwwwww5 5wwwwwwww"
1372 fParamIcon =
new QPixmap(paramIcon);
1379 QWidget* G4UIQt::CreateHistoryTBWidget(
1382 fHistoryTBWidget =
new QWidget();
1384 QVBoxLayout *layoutHistoryTB =
new QVBoxLayout();
1385 fHistoryTBTableList =
new QListWidget();
1386 fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
1387 connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
1389 layoutHistoryTB->addWidget(fHistoryTBTableList);
1391 fHistoryTBWidget->setLayout(layoutHistoryTB);
1392 return fHistoryTBWidget;
1398 QWidget* G4UIQt::CreateHelpTBWidget(
1401 fHelpTBWidget =
new QWidget();
1403 QWidget *helpWidget =
new QWidget();
1404 QHBoxLayout *helpLayout =
new QHBoxLayout();
1405 QVBoxLayout *vLayout =
new QVBoxLayout();
1406 fHelpVSplitter =
new QSplitter(Qt::Vertical);
1407 fHelpLine =
new QLineEdit();
1408 helpLayout->addWidget(
new QLabel(
"Search :"));
1409 helpLayout->addWidget(fHelpLine);
1410 connect( fHelpLine, SIGNAL( editingFinished () ),
this, SLOT( LookForHelpStringCallback() ) );
1415 fParameterHelpLabel =
new QTextEdit();
1416 fParameterHelpLabel->setReadOnly(
true);
1417 fParameterHelpTable =
new QTableWidget();
1421 if (fHelpTreeWidget) {
1422 fHelpVSplitter->addWidget(fHelpTreeWidget);
1424 fHelpVSplitter->addWidget(fParameterHelpLabel);
1425 fHelpVSplitter->addWidget(fParameterHelpTable);
1427 fParameterHelpLabel->setVisible(
false);
1428 fParameterHelpTable->setVisible(
false);
1429 QSizePolicy policy = QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
1430 policy.setVerticalStretch(4);
1431 if (fHelpTreeWidget) {
1432 fHelpTreeWidget->setSizePolicy(policy);
1434 policy = QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
1435 policy.setVerticalStretch(1);
1436 fParameterHelpLabel->setSizePolicy(policy);
1437 fParameterHelpTable->setSizePolicy(policy);
1439 vLayout->addWidget(helpWidget);
1440 vLayout->addWidget(fHelpVSplitter,1);
1441 vLayout->setContentsMargins(5,5,5,5);
1443 helpWidget->setLayout(helpLayout);
1444 fHelpTBWidget->setLayout(vLayout);
1446 return fHelpTBWidget;
1452 G4UIDockWidget* G4UIQt::CreateCoutTBWidget(
1455 QWidget* coutTBWidget =
new QWidget();
1457 QVBoxLayout *layoutCoutTB =
new QVBoxLayout();
1459 fCoutTBTextArea =
new QTextEdit();
1462 fCoutTBTextArea->setFontFamily(
"Courier");
1463 fCoutTBTextArea->setFontPointSize(12);
1465 fCoutFilter =
new QLineEdit();
1466 fCoutFilter->setToolTip(
"Filter output by...");
1468 #if QT_VERSION > 0x050100
1469 fCoutFilter->addAction(*fSearchIcon,QLineEdit::TrailingPosition);
1470 fCoutFilter->setStyleSheet (
"border-radius:7px;");
1472 QPushButton *coutTBFilterButton =
new QPushButton();
1473 coutTBFilterButton->setIcon(QIcon(*fSearchIcon));
1474 coutTBFilterButton->setStyleSheet (
"padding-left: 0px; border:0px;");
1475 fCoutFilter->setStyleSheet (
"padding-right: 0px;");
1478 QPushButton *coutTBClearButton =
new QPushButton();
1479 coutTBClearButton->setIcon(*fClearIcon);
1480 coutTBClearButton->setToolTip(
"Clear console output");
1481 coutTBClearButton->setStyleSheet (
"border-radius:7px;");
1482 connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
1483 connect(fCoutFilter, SIGNAL(textEdited (
const QString &)), SLOT(CoutFilterCallback(
const QString &)));
1485 QPushButton *coutTBSaveOutputButton =
new QPushButton();
1486 coutTBSaveOutputButton->setIcon(*fSaveIcon);
1487 coutTBSaveOutputButton->setToolTip(
"Save console output");
1488 coutTBSaveOutputButton->setStyleSheet (
"border-radius:7px;");
1489 connect(coutTBSaveOutputButton, SIGNAL(clicked()), SLOT(SaveOutputCallback()));
1491 fCoutTBTextArea->setReadOnly(
true);
1493 QWidget* coutButtonWidget =
new QWidget();
1494 QHBoxLayout* layoutCoutTBButtons =
new QHBoxLayout();
1496 #ifdef G4MULTITHREADED
1498 fThreadsFilterComboBox =
new QComboBox();
1499 fThreadsFilterComboBox->setInsertPolicy(QComboBox::InsertAlphabetically);
1500 connect(fThreadsFilterComboBox, SIGNAL(activated(
int)),
this, SLOT(ThreadComboBoxCallback(
int)));
1502 UpdateCoutThreadFilter();
1504 fThreadsFilterComboBox->setToolTip(
"Thread selection in output");
1505 layoutCoutTBButtons->addWidget(
new QLabel(
" Threads:"));
1506 layoutCoutTBButtons->addWidget(fThreadsFilterComboBox);
1509 layoutCoutTBButtons->addWidget(fCoutFilter);
1510 #if QT_VERSION <= 0x050100
1511 layoutCoutTBButtons->addWidget(coutTBFilterButton);
1513 layoutCoutTBButtons->addWidget(coutTBClearButton);
1514 layoutCoutTBButtons->addWidget(coutTBSaveOutputButton);
1515 coutButtonWidget->setLayout(layoutCoutTBButtons);
1518 layoutCoutTBButtons->setContentsMargins(3,3,3,0);
1520 layoutCoutTB->addWidget(coutButtonWidget);
1521 layoutCoutTB->addWidget(fCoutTBTextArea);
1523 coutTBWidget->setLayout(layoutCoutTB);
1525 fCoutTBTextArea->setMinimumSize(100,100);
1528 QWidget* commandLineWidget =
new QWidget();
1529 QHBoxLayout *layoutCommandLine =
new QHBoxLayout();
1533 fCommandLabel =
new QLabel(
"");
1534 fCommandArea =
new QLineEdit();
1538 fCommandArea->activateWindow();
1540 fCommandArea->setFocusPolicy ( Qt::StrongFocus );
1541 fCommandArea->setFocus(Qt::TabFocusReason);
1542 fCommandArea->setToolTip(
"Apply command");
1545 layoutCommandLine->addWidget(fCommandLabel);
1546 layoutCommandLine->addWidget(fCommandArea);
1549 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
1550 connect(fCommandArea, SIGNAL(textEdited(
const QString &)), SLOT(CommandEditedCallback(
const QString &)));
1553 commandLineWidget->setLayout(layoutCommandLine);
1554 commandLineWidget->setMinimumSize(50,50);
1556 layoutCoutTB->addWidget(commandLineWidget);
1558 fCoutDockWidget =
new G4UIDockWidget (
"Output");
1559 fCoutDockWidget->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
1561 fCoutDockWidget->setWidget(coutTBWidget);
1562 return fCoutDockWidget;
1568 QWidget* G4UIQt::CreateVisParametersTBWidget(
1577 G4UIDockWidget* G4UIQt::CreateUITabWidget(
1580 fUITabWidget =
new QTabWidget();
1583 fUITabWidget->addTab(CreateSceneTreeWidget(),
"Scene tree");
1584 fUITabWidget->addTab(CreateHelpTBWidget(),
"Help");
1585 fUITabWidget->addTab(CreateHistoryTBWidget(),
"History");
1586 fUITabWidget->setCurrentWidget(fHelpTBWidget);
1588 fUITabWidget->setTabToolTip (0,
"Scene component tree. Only available in Stored mode");
1589 fUITabWidget->setTabToolTip (1,
"Help widget");
1590 fUITabWidget->setTabToolTip (2,
"All commands history");
1591 connect(fUITabWidget, SIGNAL(currentChanged(
int)), SLOT(ToolBoxActivated(
int)));
1593 fUIDockWidget =
new G4UIDockWidget (
"Scene tree, Help, History");
1594 fUIDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1596 fUIDockWidget->setWidget(fUITabWidget);
1598 return fUIDockWidget;
1602 QWidget* G4UIQt::CreateSceneTreeWidget(){
1604 fSceneTreeWidget =
new QWidget();
1605 QVBoxLayout* layout =
new QVBoxLayout();
1606 fSceneTreeWidget->setLayout(layout);
1608 #if QT_VERSION < 0x040200
1609 fSceneTreeWidget->hide();
1611 fSceneTreeWidget->setVisible(
false);
1614 return fSceneTreeWidget;
1618 void G4UIQt::CreateViewerWidget(){
1622 SetStartPage(std::string(
"<table width='100%'><tr><td width='30%'></td><td><div ")+
1623 "style='color: rgb(140, 31, 31); font-size: xx-large; font-family: Garamond, serif; padding-bottom: 0px; font-weight: normal'>Geant4: "+
1624 QApplication::applicationName ().toStdString()+
1625 "</div></td><td width='40%'> <br/><i>http://geant4.web.cern.ch/geant4/</i></td></tr></table>"+
1627 "<div style='background:#EEEEEE;'><b>Tooltips :</b><ul>"+
1628 "<li><b>Start a new viewer :</b><br />"+
1629 "<i>'/vis/open/...'<br />"+
1630 "For example '/vis/open OGL'</i></li>"+
1631 "<li><b>Execute a macro file :</b><br />"+
1632 "<i>'/control/execute my_macro_file'</i></li>"+
1635 "<div style='background:#EEEEEE;'><b>Documentation :</b><ul>"+
1636 "<li><b>Visualization tutorial :</b><br />"+
1637 "<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>"+
1638 "<li><b>Visualisation publication :</b><br />"+
1639 "<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>"+
1642 "<div style='background:#EEEEEE;'><b>Getting Help :</b><ul>"+
1643 "<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"+
1644 "<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>"+
1650 if (fViewerTabWidget == NULL) {
1651 fViewerTabWidget =
new G4QTabWidget();
1652 fMainWindow->setCentralWidget(fViewerTabWidget);
1653 #if QT_VERSION < 0x040500
1655 fViewerTabWidget->setTabsClosable (
true);
1658 #if QT_VERSION < 0x040200
1660 fViewerTabWidget->setUsesScrollButtons (
true);
1663 #if QT_VERSION < 0x040500
1665 connect(fViewerTabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(TabCloseCallback(
int)));
1667 connect(fViewerTabWidget, SIGNAL(currentChanged (
int ) ), SLOT(UpdateTabWidget(
int)));
1671 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
1672 policy.setVerticalStretch(4);
1673 fViewerTabWidget->setSizePolicy(policy);
1675 fViewerTabWidget->setMinimumSize(40,40);
1681 QWidget* G4UIQt::GetSceneTreeWidget(
1684 return fSceneTreeWidget;
1689 QWidget* G4UIQt::GetViewerPropertiesWidget(
1692 if (!fViewerPropertiesDialog) {
1693 CreateViewerPropertiesDialog();
1695 return fViewerPropertiesWidget;
1700 QWidget* G4UIQt::GetPickInfosWidget(
1703 if (!fPickInfosDialog) {
1704 CreatePickInfosDialog();
1706 return fPickInfosWidget;
1712 bool G4UIQt::AddViewerTab(
1717 if (fViewerTabWidget == NULL) {
1720 fViewerTabWidget->addTab(aWidget,title.c_str());
1728 bool G4UIQt::AddViewerTabFromFile(
1729 std::string fileName
1733 if (fViewerTabWidget == NULL) {
1738 if(UI==NULL)
return 0;
1742 std::string content( (std::istreambuf_iterator<char>(
file) ),
1743 (std::istreambuf_iterator<char>() ) );
1745 QTextEdit* text =
new QTextEdit();
1746 text->setAcceptRichText (
true);
1747 text->setContentsMargins(5,5,5,5);
1748 text->setText(QString(
"<pre>")+content.c_str()+
"</pre>");
1749 text->setReadOnly(
true);
1750 fViewerTabWidget->addTab(text,title.c_str());
1761 bool G4UIQt::AddTabWidget(
1772 #if QT_VERSION < 0x050100
1773 #if QT_VERSION >= 0x050000
1775 "This Qt version [")+qVersion ()+
"] has some issues with the OpenGL viewer.\n"+
1776 "To prevent problems, you are not allowed to open a Stored nor Immediate viewer.\n" +
1778 "Please upgrade to Qt version >= 5.1\n";
1780 QMessageBox::warning(fMainWindow, tr(
"Warning"),
1781 tr(message.toStdString().c_str()),
1788 if (fViewerTabWidget == NULL) {
1789 CreateViewerWidget();
1796 aWidget->setParent(fViewerTabWidget);
1799 fViewerTabWidget->addTab(aWidget,name);
1801 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
1804 #if QT_VERSION < 0x040200
1805 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
1807 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
1818 void G4UIQt::SetStartPage(
1819 const std::string& text)
1822 fDefaultViewerFirstPageHTMLText = text;
1825 fStartPage =
new QTextEdit();
1826 fStartPage->setAcceptRichText (
true);
1827 fStartPage->setContentsMargins(5,5,5,5);
1828 fStartPage->setReadOnly(
true);
1830 fStartPage->setText(fDefaultViewerFirstPageHTMLText.c_str());
1834 void G4UIQt::UpdateTabWidget(
int tabNumber) {
1835 if ( fViewerTabWidget == NULL) {
1836 fViewerTabWidget =
new G4QTabWidget;
1839 fViewerTabWidget->setCurrentIndex(tabNumber);
1842 fViewerTabWidget->setTabSelected(
false);
1844 #if QT_VERSION < 0x040200
1845 fViewerTabWidget->show();
1847 fViewerTabWidget->setVisible(
true);
1851 fViewerTabWidget->setTabSelected(
true);
1857 void G4UIQt::ResizeTabWidget( QResizeEvent*
e) {
1858 if ( fViewerTabWidget) {
1859 for (
G4int a=0;
a<fViewerTabWidget->count() ;
a++) {
1860 fViewerTabWidget->widget(
a)->resize(e->size());
1871 G4Qt* interactorManager = G4Qt::getInstance ();
1872 Prompt(
"Session :");
1873 exitSession =
false;
1875 QCoreApplication::sendPostedEvents () ;
1877 #if QT_VERSION < 0x040200
1878 fMainWindow->show();
1880 fMainWindow->setVisible(
true);
1883 if (fDefaultIcons) {
1884 #if QT_VERSION < 0x040200
1885 fToolbarApp->show();
1887 fToolbarApp->setVisible(
true);
1891 #if QT_VERSION < 0x040200
1892 fToolbarApp->hide();
1894 fToolbarApp->setVisible(
false);
1901 UpdateCommandCompleter();
1904 fHistoryTBTableList->installEventFilter(
this);
1905 fCommandArea->installEventFilter(
this);
1908 fCommandArea->setFocus();
1910 interactorManager->DisableSecondaryLoop ();
1911 if ((QApplication*)interactorManager->GetMainInteractor())
1912 ((QApplication*)interactorManager->GetMainInteractor())->exec();
1914 interactorManager->EnableSecondaryLoop ();
1924 void G4UIQt::Prompt (
1928 if (!aPrompt)
return;
1930 fCommandLabel->setText((
char*)aPrompt.
data());
1935 void G4UIQt::SessionTerminate (
1938 G4Qt* interactorManager = G4Qt::getInstance ();
1939 fMainWindow->close();
1940 ((QApplication*)interactorManager->GetMainInteractor())->exit();
1953 void G4UIQt::PauseSessionStart (
1957 if (!aState)
return;
1959 if(aState==
"G4_pause> ") {
1960 SecondaryLoop (
"Pause, type continue to exit this state");
1963 if(aState==
"EndOfEvent") {
1965 SecondaryLoop (
"End of event, type continue to exit this state");
1975 void G4UIQt::SecondaryLoop (
1979 if (!aPrompt)
return;
1981 G4Qt* interactorManager = G4Qt::getInstance ();
1985 ((QApplication*)interactorManager)->processEvents(QEventLoop::WaitForMoreEvents);
1986 if(exitPause==
true)
break;
1988 Prompt(
"Session :");
1991 #ifdef G4MULTITHREADED
2005 G4int G4UIQt::ReceiveG4cout (
2009 if (!aString)
return 0;
2011 #ifdef G4MULTITHREADED
2017 if (aString.
contains(
"*** This is just a warning message. ***")) {
2018 return ReceiveG4cerr(aString);
2024 G4UIOutputString txt = G4UIOutputString(QString((
char*)aString.
data()).trimmed(),GetThreadPrefix());
2025 fG4OutputString.push_back(txt);
2027 #ifdef G4MULTITHREADED
2028 QString
result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
2030 QString result = FilterOutput(txt,
"",fCoutFilter->text());
2033 if (result.isEmpty()) {
2036 QColor previousColor = fCoutTBTextArea->textColor();
2037 fCoutTBTextArea->setTextColor(Qt::black);
2038 fCoutTBTextArea->append(result);
2039 fCoutTBTextArea->setTextColor(previousColor);
2040 fCoutTBTextArea->ensureCursorVisible ();
2042 #ifdef G4MULTITHREADED
2043 UpdateCoutThreadFilter();
2047 fLastErrMessage = aString;
2057 G4int G4UIQt::ReceiveG4cerr (
2061 if (!aString)
return 0;
2063 #ifdef G4MULTITHREADED
2070 G4UIOutputString txt = G4UIOutputString(QString((
char*)aString.
data()).trimmed(),
2073 fG4OutputString.push_back(txt);
2075 #ifdef G4MULTITHREADED
2076 QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
2078 QString result = FilterOutput(txt,
"",fCoutFilter->text());
2080 if (result.isEmpty()) {
2085 if (QString(aString.
data()).trimmed() !=
"") {
2089 fLastErrMessage +=
"\n"+aString;
2090 QString criticalMessage = fLastErrMessage.
data();
2091 #if QT_VERSION < 0x050000
2092 criticalMessage = Qt::escape(criticalMessage);
2094 criticalMessage = criticalMessage.toHtmlEscaped();
2096 QMessageBox::critical(fMainWindow,
"Error",QString(fLastErrMessage));
2099 QColor previousColor = fCoutTBTextArea->textColor();
2100 fCoutTBTextArea->setTextColor(
Qt::red);
2101 fCoutTBTextArea->append(result);
2102 fCoutTBTextArea->setTextColor(previousColor);
2103 fCoutTBTextArea->ensureCursorVisible ();
2105 if (QString(aString.
data()).trimmed() !=
"") {
2106 fLastErrMessage += aString;
2108 #ifdef G4MULTITHREADED
2109 UpdateCoutThreadFilter();
2115 G4String G4UIQt::GetThreadPrefix() {
2117 #ifdef G4MULTITHREADED
2119 if(UI==NULL)
return "";
2127 return threadPrefix;
2131 #ifdef G4MULTITHREADED
2132 void G4UIQt::UpdateCoutThreadFilter() {
2134 if(UI==NULL)
return;
2137 if (fThreadsFilterComboBox->count() < 2) {
2138 if ( fThreadsFilterComboBox->findText(
"All", Qt::MatchExactly) == -1) {
2139 fThreadsFilterComboBox->addItem(
"All");
2142 if (fThreadsFilterComboBox->count() < 2) {
2143 if ( fThreadsFilterComboBox->findText(
"Master", Qt::MatchExactly) == -1) {
2144 fThreadsFilterComboBox->addItem(
"Master");
2150 if ( fThreadsFilterComboBox->findText(prefix.
data(), Qt::MatchExactly) == -1) {
2151 fThreadsFilterComboBox->addItem(prefix.
data());
2163 void G4UIQt::AddMenu (
2168 if (aName == NULL)
return;
2169 if (aLabel == NULL)
return;
2171 QMenu *fileMenu =
new QMenu(aLabel);
2172 fMainWindow->menuBar()->addMenu(fileMenu);
2184 void G4UIQt::AddButton (
2187 ,
const char* aCommand
2190 if(aMenu==NULL)
return;
2191 if(aLabel==NULL)
return;
2192 if(aCommand==NULL)
return;
2194 QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
2196 if(parentTmp==NULL) {
2201 G4cout <<
"Menu name " << aMenu<<
" does not exist, please define it before using it."<<
G4endl;
2208 if(UI==NULL)
return;
2212 G4int cmdEndPos = cmd.find_first_of(
" \t");
2213 if(cmdEndPos!=
G4int(std::string::npos)) {
2214 cmd.erase(cmdEndPos);
2217 if(treeTop->
FindPath(cmd) == NULL) {
2219 cmd(0,3) !=
"ls " &&
2222 cmd(0,3) !=
"cd " &&
2224 cmd(0,5) !=
"help " &&
2236 G4cout <<
"Warning: command '"<< cmd <<
"' does not exist, please define it before using it."<<
G4endl;
2241 QSignalMapper *signalMapper =
new QSignalMapper(
this);
2242 QAction *action = parentTmp->addAction(aLabel, signalMapper, SLOT(map()));
2244 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
2245 signalMapper->setMapping(action, QString(aCommand));
2254 void G4UIQt::AddIcon(
const char* aLabel,
const char* aIconFile,
const char* aCommand,
const char* aFileName){
2255 if(aLabel==NULL)
return;
2257 if (aCommand==NULL) {
2258 if (std::string(aIconFile) ==
"user_icon") {
2263 bool userToolBar =
false;
2265 if (!fDefaultIcons) {
2268 if (std::string(aIconFile) ==
"user_icon") {
2272 if (pix->isNull()) {
2276 G4cout <<
"Warning: file '"<< aFileName <<
"' is incorrect or does not exist, this command will not be build"<<
G4endl;
2280 }
else if (std::string(aIconFile) ==
"open") {
2282 }
else if (std::string(aIconFile) ==
"save") {
2284 }
else if (std::string(aIconFile) ==
"move") {
2286 }
else if (std::string(aIconFile) ==
"rotate") {
2288 }
else if (std::string(aIconFile) ==
"pick") {
2290 }
else if (std::string(aIconFile) ==
"zoom_in") {
2292 }
else if (std::string(aIconFile) ==
"zoom_out") {
2294 }
else if (std::string(aIconFile) ==
"wireframe") {
2295 pix = fWireframeIcon;
2296 }
else if (std::string(aIconFile) ==
"solid") {
2298 }
else if (std::string(aIconFile) ==
"hidden_line_removal") {
2299 pix = fHiddenLineRemovalIcon;
2300 }
else if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
2301 pix = fHiddenLineAndSurfaceRemovalIcon;
2302 }
else if (std::string(aIconFile) ==
"perspective") {
2303 pix = fPerspectiveIcon;
2304 }
else if (std::string(aIconFile) ==
"ortho") {
2306 }
else if (std::string(aIconFile) ==
"runBeamOn") {
2313 G4cout <<
"Parameter"<< aIconFile <<
" not defined"<<
G4endl;
2317 QToolBar *currentToolbar = NULL;
2319 if (fToolbarUser == NULL) {
2320 fToolbarUser =
new QToolBar();
2321 fToolbarUser->setIconSize (QSize(20,20));
2322 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
2324 currentToolbar = fToolbarUser;
2326 if (fToolbarApp == NULL) {
2327 fToolbarApp =
new QToolBar();
2328 fToolbarApp->setIconSize (QSize(20,20));
2329 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
2331 currentToolbar = fToolbarApp;
2336 QList<QAction*> list = currentToolbar->actions();
2338 for (
int i = 0; i < list.size(); ++i) {
2339 if (list.at(i)->text() == QString(aLabel)) {
2341 if(UI==NULL)
return;
2344 G4cout <<
"Warning: A toolBar icon \""<< aLabel<<
"\" already exists with the same name!" <<
G4endl;
2349 QSignalMapper *signalMapper =
new QSignalMapper(
this);
2350 QAction *action = currentToolbar->addAction(QIcon(*pix),aLabel, signalMapper, SLOT(map()));
2353 if (std::string(aIconFile) ==
"open") {
2354 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(OpenIconCallback(
const QString &)));
2355 QString txt = aCommand + fStringSeparator + aLabel;
2356 signalMapper->setMapping(action, QString(txt));
2359 }
else if (std::string(aIconFile) ==
"save") {
2360 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(SaveIconCallback(
const QString&)));
2361 QString txt = aCommand + fStringSeparator + aLabel;
2362 signalMapper->setMapping(action, QString(txt));
2365 }
else if ((std::string(aIconFile) ==
"move") ||
2366 (std::string(aIconFile) ==
"rotate") ||
2367 (std::string(aIconFile) ==
"pick") ||
2368 (std::string(aIconFile) ==
"zoom_out") ||
2369 (std::string(aIconFile) ==
"zoom_in")) {
2370 action->setCheckable(
TRUE);
2371 action->setChecked(
TRUE);
2372 action->setData(aIconFile);
2374 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeCursorAction(
const QString&)));
2375 signalMapper->setMapping(action, QString(aIconFile));
2377 if (std::string(aIconFile) ==
"move") {
2378 SetIconMoveSelected();
2380 if (std::string(aIconFile) ==
"rotate") {
2381 SetIconRotateSelected();
2383 if (std::string(aIconFile) ==
"pick") {
2384 SetIconPickSelected();
2386 if (std::string(aIconFile) ==
"zoom_in") {
2387 SetIconZoomInSelected();
2389 if (std::string(aIconFile) ==
"zoom_out") {
2390 SetIconZoomOutSelected();
2394 }
else if ((std::string(aIconFile) ==
"hidden_line_removal") ||
2395 (std::string(aIconFile) ==
"hidden_line_and_surface_removal") ||
2396 (std::string(aIconFile) ==
"solid") ||
2397 (std::string(aIconFile) ==
"wireframe")) {
2398 action->setCheckable(
TRUE);
2399 action->setChecked(
TRUE);
2400 action->setData(aIconFile);
2401 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeSurfaceStyle(
const QString&)));
2402 signalMapper->setMapping(action, QString(aIconFile));
2404 if (std::string(aIconFile) ==
"hidden_line_removal") {
2405 SetIconHLRSelected();
2407 if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
2408 SetIconHLHSRSelected();
2410 if (std::string(aIconFile) ==
"solid") {
2411 SetIconSolidSelected();
2413 if (std::string(aIconFile) ==
"wireframe") {
2414 SetIconWireframeSelected();
2418 }
else if ((std::string(aIconFile) ==
"perspective") ||
2419 (std::string(aIconFile) ==
"ortho")) {
2420 action->setCheckable(
TRUE);
2421 action->setChecked(
TRUE);
2422 action->setData(aIconFile);
2423 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangePerspectiveOrtho(
const QString&)));
2424 signalMapper->setMapping(action, QString(aIconFile));
2426 if (std::string(aIconFile) ==
"perspective") {
2427 SetIconPerspectiveSelected();
2429 if (std::string(aIconFile) ==
"ortho") {
2430 SetIconOrthoSelected();
2437 if(UI==NULL)
return;
2439 if (aCommand != NULL) {
2440 std::string str = aCommand;
2441 std::string::size_type
pos = str.find(
" ");
2442 if (pos != std::string::npos)
2444 str = str.substr(0,pos).c_str();
2446 if(treeTop->
FindPath(str.c_str()) == NULL) {
2451 G4cout <<
"Warning: command '"<< aCommand <<
"' does not exist, please define it before using it."<<
G4endl;
2456 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
2457 signalMapper->setMapping(action, QString(aCommand));
2463 void G4UIQt::ActivateCommand(
2467 if (!fHelpTreeWidget) {
2471 size_t i = newCommand.
index(
" ");
2473 if( i != std::string::npos )
2475 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
2477 targetCom = ModifyToFullPathCommand( newValue );
2479 if (targetCom !=
"") {
2480 OpenHelpTreeOnCommand(targetCom.
data());
2483 fUITabWidget->setCurrentWidget(fHelpTBWidget);
2494 void G4UIQt::InitHelpTreeAndVisParametersWidget()
2497 if (! fHelpTreeWidget ) {
2498 fHelpTreeWidget =
new QTreeWidget();
2502 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2504 labels << QString(
"Command");
2505 fHelpTreeWidget->setHeaderLabels(labels);
2508 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),
this, SLOT(HelpTreeClicCallback()));
2509 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,
int)),
this, SLOT(HelpTreeDoubleClicCallback()));
2518 void G4UIQt::FillHelpTree()
2520 if (! fHelpTreeWidget ) {
2521 InitHelpTreeAndVisParametersWidget();
2524 QString searchText = fHelpLine->text();
2526 if (searchText ==
"") {
2533 if (fParameterHelpLabel) {
2534 fParameterHelpLabel->setText(
"Choose a command in the command tree");
2535 fParameterHelpTable->setVisible(
false);
2539 #if QT_VERSION < 0x040200
2542 fHelpLine->setText(
"");
2547 if(UI==NULL)
return;
2551 QTreeWidgetItem * newItem = NULL;
2552 QString commandText =
"";
2553 for (
int a=0;
a<treeSize;
a++) {
2560 for (
int b=0;b<fHelpTreeWidget->topLevelItemCount();b++) {
2562 newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b),commandText);
2565 if (newItem == NULL) {
2567 newItem =
new QTreeWidgetItem();
2568 newItem->setText(0,GetShortCommandPath(commandText));
2569 fHelpTreeWidget->addTopLevelItem(newItem);
2573 CreateHelpTree(newItem,treeTop->
GetTree(
a+1));
2584 void G4UIQt::CreateHelpTree(
2585 QTreeWidgetItem *aParent
2589 if (aParent == NULL)
return;
2590 if (aCommandTree == NULL)
return;
2594 QTreeWidgetItem * newItem;
2596 QString commandText =
"";
2603 newItem = FindTreeItem(aParent,commandText);
2604 if (newItem == NULL) {
2605 newItem =
new QTreeWidgetItem();
2606 newItem->setText(0,GetShortCommandPath(commandText));
2607 aParent->addChild(newItem);
2609 CreateHelpTree(newItem,aCommandTree->
GetTree(
a+1));
2616 QStringList stringList;
2620 newItem = FindTreeItem(aParent,commandText);
2621 if (newItem == NULL) {
2622 newItem =
new QTreeWidgetItem();
2623 newItem->setText(0,GetShortCommandPath(commandText));
2624 aParent->addChild(newItem);
2626 #if QT_VERSION < 0x040202
2627 fHelpTreeWidget->setItemExpanded(newItem,
false);
2629 newItem->setExpanded(
false);
2643 bool G4UIQt::CreateVisCommandGroupAndToolBox(
2650 QString commandText = QString((
char*)(aCommand->
GetCommandPath().
data())).section(
"/",-aDepthLevel);
2652 if (commandText == NULL) {
2658 QWidget* newParentWidget = NULL;
2660 QString commandSection = commandText.left(commandText.indexOf(
"/"));
2662 if (aDepthLevel == 1) {
2663 QToolBox* currentParent =
dynamic_cast<QToolBox*
>(aParent);
2664 if (currentParent != 0){
2667 for (
int a=0;
a<currentParent->count();
a++) {
2668 if (currentParent->itemText(
a) == commandSection) {
2670 newParentWidget = currentParent->widget(
a);
2676 newParentWidget =
new QGroupBox();
2677 newParentWidget->setLayout(
new QVBoxLayout());
2678 if (currentParent != 0){
2679 currentParent->addItem(newParentWidget,commandSection);
2681 if (!aParent->layout()) {
2682 aParent->setLayout(
new QVBoxLayout());
2684 aParent->layout()->addWidget(newParentWidget);
2687 if (commandText.indexOf(
"/") == -1) {
2692 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2695 newParentWidget->setToolTip(guidance);
2698 QScrollArea* sc =
dynamic_cast<QScrollArea*
>(newParentWidget->parent()->parent());
2700 sc->ensureWidgetVisible(newParentWidget);
2707 QGroupBox* currentParent =
dynamic_cast<QGroupBox*
>(aParent);
2708 if (currentParent != 0){
2712 if (aDepthLevel == 2){
2713 QToolBox* parentToolBox =
dynamic_cast<QToolBox*
>(currentParent->parent()->parent()->parent());
2714 if (parentToolBox != 0) {
2718 for (
int a=0;
a<aParent->layout()->count();
a++) {
2719 QGroupBox* gb =
dynamic_cast<QGroupBox*
>(aParent->layout()->itemAt(
a)->widget());
2721 if (gb->title() == commandSection) {
2723 newParentWidget = gb;
2731 newParentWidget =
new QGroupBox();
2732 newParentWidget->setLayout(
new QVBoxLayout());
2733 if (!aParent->layout()) {
2734 aParent->setLayout(
new QVBoxLayout());
2736 aParent->layout()->addWidget(newParentWidget);
2742 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2745 newParentWidget->setToolTip(guidance);
2750 if (commandText.indexOf(
"/") == -1) {
2751 if (CreateCommandWidget(aCommand, newParentWidget,isDialog)) {
2755 CreateVisCommandGroupAndToolBox(aCommand,newParentWidget, aDepthLevel-1,isDialog);
2768 bool G4UIQt::CreateCommandWidget(
G4UIcommand* aCommand, QWidget* aParent,
bool isDialog) {
2770 if (aCommand == NULL) {
2777 if( n_parameterEntry > 0 ) {
2781 QWidget* paramWidget =
new QWidget();
2782 QGridLayout* gridLayout =
new QGridLayout();
2783 paramWidget->setLayout(gridLayout);
2786 unsigned int nbColorParameter = 0;
2787 bool isStillColorParameter =
false;
2788 bool isColorDialogAdded =
false;
2789 QLabel* redLabel = NULL;
2790 QLabel* greenLabel = NULL;
2791 QString redDefaultStr =
"";
2792 QString greenDefaultStr =
"";
2793 QString blueDefaultStr =
"";
2794 QWidget* redInput = NULL;
2795 QWidget* greenInput = NULL;
2797 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2802 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")){
2803 nbColorParameter ++;
2804 isStillColorParameter =
true;
2805 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2806 nbColorParameter ++;
2807 }
else if ((label->text() ==
"blue") && isStillColorParameter) {
2808 nbColorParameter ++;
2809 }
else if (!isColorDialogAdded) {
2812 if (nbColorParameter == 1) {
2813 gridLayout->addWidget(redLabel,i_thParameter-1,0);
2814 gridLayout->addWidget(redInput,i_thParameter-1,1);
2815 }
else if (nbColorParameter == 2) {
2816 gridLayout->addWidget(redLabel,i_thParameter-2,0);
2817 gridLayout->addWidget(redInput,i_thParameter-2,1);
2818 gridLayout->addWidget(greenLabel,i_thParameter-1,0);
2819 gridLayout->addWidget(greenInput,i_thParameter-1,1);
2821 nbColorParameter = 0;
2824 QWidget* input = NULL;
2826 input =
new QLineEdit();
2828 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2830 if (((label->text() ==
"red") || (label->text() ==
"red_or_string")) && isStillColorParameter) {
2832 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2834 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2839 input =
new QWidget();
2840 QHBoxLayout* layout =
new QHBoxLayout();
2841 input->setLayout(layout);
2843 QButtonGroup* buttons =
new QButtonGroup();
2844 QRadioButton* radioOff =
new QRadioButton(
"0");
2845 QRadioButton* radioOn =
new QRadioButton(
"1");
2846 buttons->addButton(radioOn);
2847 buttons->addButton(radioOff);
2848 layout->addWidget(radioOn);
2849 layout->addWidget(radioOff);
2853 if (defaultValue ==
"0") {
2854 radioOff->setChecked(
true);
2855 }
else if (defaultValue ==
"1") {
2856 radioOn->setChecked(
true);
2859 input =
new QComboBox();
2861 QStringList list = candidates.split (
" ");
2865 for (
int a=0;
a<list.size();
a++) {
2866 dynamic_cast<QComboBox*
>(input)->addItem(list.at(
a));
2867 if (list.at(
a) == defaultValue) {
2868 dynamic_cast<QComboBox*
>(input)->setCurrentIndex(
a);
2873 input =
new QLineEdit();
2875 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2878 input =
new QWidget();
2879 QHBoxLayout* layout =
new QHBoxLayout();
2880 input->setLayout(layout);
2882 QButtonGroup* buttons =
new QButtonGroup();
2883 QRadioButton* radioOff =
new QRadioButton(
"off");
2884 QRadioButton* radioOn =
new QRadioButton(
"on");
2885 buttons->addButton(radioOn);
2886 buttons->addButton(radioOff);
2887 layout->addWidget(radioOn);
2888 layout->addWidget(radioOff);
2892 if (defaultValue ==
"off") {
2893 radioOff->setChecked(
true);
2894 }
else if (defaultValue ==
"on") {
2895 radioOn->setChecked(
true);
2899 input =
new QLineEdit();
2900 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2907 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2909 txt +=
" Omittable : True\n";
2911 txt +=
" Omittable : False\n";
2914 txt +=
" Default value : taken from the current value\n";
2925 if (isStillColorParameter && (nbColorParameter != 0)) {
2926 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")) {
2929 }
else if (label->text() ==
"green") {
2932 }
else if (label->text() ==
"blue") {
2938 if ((redDefaultStr !=
"") && (redDefaultStr !=
"") && (redDefaultStr !=
"")) {
2939 qc.setRgbF(redDefaultStr.toDouble(),
2940 greenDefaultStr.toDouble(),
2941 blueDefaultStr.toDouble());
2943 QPixmap pixmap = QPixmap(QSize(16, 16));
2945 QPainter painter(&pixmap);
2946 painter.setPen(Qt::black);
2947 painter.drawRect(0,0,15,15);
2949 input =
new QPushButton(
"Change color");
2950 dynamic_cast<QPushButton*
>(input)->setIcon(pixmap);
2951 dynamic_cast<QPushButton*
>(input)->setAccessibleName(redDefaultStr+
" "+greenDefaultStr+
" "+blueDefaultStr);
2952 label =
new QLabel(
"Choose color");
2956 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2957 input->setToolTip(
"Select the current color");
2958 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2961 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2962 signalMapper->setMapping(input,input);
2963 connect(input, SIGNAL(clicked()), signalMapper, SLOT(map()));
2964 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(ChangeColorCallback(QWidget*)));
2966 isColorDialogAdded =
true;
2967 isStillColorParameter =
false;
2970 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2971 input->setToolTip(txt);
2972 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2978 gridLayout->addWidget(name,n_parameterEntry-nbColorParameter,0);
2980 QPushButton* applyButton =
new QPushButton(
"Apply");
2983 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,1);
2985 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2986 signalMapper->setMapping(applyButton, paramWidget);
2987 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2988 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2992 applyButton->setAutoDefault(
TRUE );
2993 applyButton->setDefault(
TRUE );
2995 QPushButton* cancelButton =
new QPushButton( tr(
"&Cancel" ));
2996 cancelButton->setAutoDefault(
TRUE );
2997 gridLayout->addWidget(cancelButton,n_parameterEntry-nbColorParameter,1);
2998 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,0);
3000 QSignalMapper* signalMapper =
new QSignalMapper(
this);
3001 signalMapper->setMapping(applyButton, paramWidget);
3002 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
3003 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
3005 QWidget * parentCheck = aParent;
3006 QDialog* parentDialog = NULL;
3008 while ((parentCheck->parentWidget()) != NULL) {
3009 parentCheck = parentCheck->parentWidget();
3010 parentDialog =
dynamic_cast<QDialog*
>(parentCheck);
3012 connect( applyButton, SIGNAL( clicked() ), parentDialog, SLOT( accept() ) );
3013 connect( cancelButton, SIGNAL( clicked() ), parentDialog, SLOT( reject() ) );
3022 if (!aParent->layout()) {
3023 aParent->setLayout(
new QVBoxLayout());
3025 aParent->layout()->addWidget(paramWidget);
3036 QTreeWidgetItem* G4UIQt::FindTreeItem(
3037 QTreeWidgetItem *aParent
3038 ,
const QString& aCommand
3041 if (aParent == NULL)
return NULL;
3044 QString myCommand = aCommand;
3046 if (myCommand.lastIndexOf(
"/") == (myCommand.size()-1)) {
3047 myCommand = myCommand.left(myCommand.size()-1);
3050 if (GetLongCommandPath(aParent) == myCommand)
3053 QTreeWidgetItem *
tmp = NULL;
3054 for (
int a=0;
a<aParent->childCount();
a++) {
3056 tmp = FindTreeItem(aParent->child(
a),myCommand);
3070 QString G4UIQt::GetCommandList (
3076 if (aCommand == NULL)
3084 if ((commandPath ==
"") &&
3085 (rangeString ==
"") &&
3086 (n_guidanceEntry == 0) &&
3087 (n_parameterEntry == 0)) {
3091 if((commandPath.length()-1)!=
'/') {
3092 txt +=
"Command " + QString((
char*)(commandPath).
data()) +
"\n";
3094 txt +=
"Guidance :\n";
3096 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3099 if( ! rangeString.
isNull() ) {
3100 txt +=
" Range of parameters : " + QString((
char*)(rangeString).
data()) +
"\n";
3102 if( n_parameterEntry > 0 ) {
3107 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
3112 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
3114 txt +=
" Omittable : True\n";
3116 txt +=
" Omittable : False\n";
3119 txt +=
" Default value : taken from the current value\n";
3142 void G4UIQt::updateHelpArea (
3146 if (!fParameterHelpLabel)
3148 if (!fParameterHelpTable)
3151 fParameterHelpLabel->setTextInteractionFlags(Qt::NoTextInteraction);
3153 if (aCommand == NULL)
3161 if ((commandPath ==
"") &&
3162 (rangeString ==
"") &&
3163 (n_guidanceEntry == 0) &&
3164 (n_parameterEntry == 0)) {
3168 if((commandPath.length()-1)!=
'/') {
3169 txt +=
"<b>Command </b> " + QString((
char*)(commandPath).
data()) +
"<br />";
3171 txt +=
"<b>Guidance :</b> ";
3172 QString tmpGuidance =
"";
3173 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3175 #if QT_VERSION < 0x050000
3176 tmpGuidance = Qt::escape(tmpGuidance);
3178 tmpGuidance = tmpGuidance.toHtmlEscaped();
3180 tmpGuidance.replace(
"\n",
"<br />");
3181 txt += tmpGuidance +
"<br />";
3183 if( ! rangeString.
isNull() ) {
3184 QString
range = QString((
char*)(rangeString).
data());
3185 #if QT_VERSION < 0x050000
3186 range = Qt::escape(range);
3188 range = range.toHtmlEscaped();
3191 txt +=
"<b>Range of parameters : </b> " + range +
"<br />";
3195 fParameterHelpLabel->setHtml(txt);
3197 if( n_parameterEntry > 0 ) {
3202 fParameterHelpTable->clear();
3203 fParameterHelpTable->setRowCount(n_parameterEntry);
3204 fParameterHelpTable->setColumnCount(8);
3205 fParameterHelpTable->setHorizontalHeaderLabels(QStringList() <<
3214 fParameterHelpTable->setColumnWidth(2,60);
3216 fParameterHelpTable->verticalHeader()->setVisible(
false);
3217 fParameterHelpTable->setAlternatingRowColors (
true);
3218 #if QT_VERSION < 0x050000
3219 fParameterHelpTable->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
3220 fParameterHelpTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
3222 fParameterHelpTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
3223 fParameterHelpTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
3225 fParameterHelpTable->setWordWrap(
true);
3227 QTableWidgetItem* t = fParameterHelpTable->horizontalHeaderItem(1);
3228 QFont fnt = t->font();
3229 int size = fnt.pointSize();
3230 fnt.setPointSize(size-2);
3232 for(
G4int a=0;
a<n_parameterEntry;
a++ ) {
3234 fParameterHelpTable->setItem(
a, 0,
new QTableWidgetItem(QString::number(
a+1)));
3236 fParameterHelpTable->setItem(
a, 1,
new QTableWidgetItem(QString((
char*)(param->
GetParameterName()).
data())));
3240 fParameterHelpTable->setItem(
a, 3,
new QTableWidgetItem(QString(QChar(param->
GetParameterType()))));
3243 fParameterHelpTable->setItem(
a, 4,
new QTableWidgetItem(QString(
"True")));
3245 fParameterHelpTable->setItem(
a, 4,
new QTableWidgetItem(QString(
"False")));
3248 fParameterHelpTable->setItem(
a, 5,
new QTableWidgetItem(QString(
"taken from the current value")));
3250 fParameterHelpTable->setItem(
a, 5,
new QTableWidgetItem(QString((
char*)(param->
GetDefaultValue()).
data())));
3253 fParameterHelpTable->setItem(
a, 6,
new QTableWidgetItem(QString((
char*)(param->
GetParameterRange()).
data())));
3259 for (
int b=0; b<8; b++) {
3260 QTableWidgetItem* tmp = fParameterHelpTable->item(
a,b);
3262 tmp->setToolTip(tmp->text());
3263 tmp->setFlags(Qt::NoItemFlags);
3264 tmp->setForeground(QBrush());
3268 fParameterHelpTable->resizeRowToContents(
a);
3270 for (
int c=0; c<8; c++) {
3272 fParameterHelpTable->resizeColumnToContents(c);
3275 fParameterHelpLabel->setVisible(
true);
3276 fParameterHelpTable->setVisible(
true);
3287 G4bool G4UIQt::IsGUICommand(
3291 if (aCommand == NULL)
3296 if( n_parameterEntry > 0 ) {
3301 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
3323 G4bool G4UIQt::GetHelpChoice(
3338 bool G4UIQt::eventFilter(
3343 bool tabKeyPress =
false;
3344 bool moveCommandCursor =
false;
3345 if (aObj == NULL)
return false;
3346 if (aEvent == NULL)
return false;
3348 if (aObj == fHistoryTBTableList) {
3349 if (aEvent->type() == QEvent::KeyPress) {
3350 fCommandArea->setFocus();
3354 if (aObj == fCompleter->popup()) {
3355 if (aEvent->type() == QEvent::KeyPress) {
3356 QKeyEvent *e =
static_cast<QKeyEvent*
>(aEvent);
3357 if (e->key() == (Qt::Key_Tab)) {
3360 }
else if ( aEvent->type() == QEvent::Hide ) {
3362 QString c = fCommandArea->text();
3363 fLastCompleteCommand = c.left(c.indexOf(
"<"));
3367 if (aObj == fCommandArea) {
3368 if (aEvent->type() == QEvent::KeyPress) {
3369 QKeyEvent *e =
static_cast<QKeyEvent*
>(aEvent);
3370 if ((e->key() == (Qt::Key_Down)) ||
3371 (e->key() == (Qt::Key_PageDown)) ||
3372 (e->key() == (Qt::Key_Up)) ||
3373 (e->key() == (Qt::Key_PageUp))) {
3374 int selection = fHistoryTBTableList->currentRow();
3375 if (fHistoryTBTableList->count()) {
3376 if (selection == -1) {
3377 selection = fHistoryTBTableList->count()-1;
3379 if (e->key() == (Qt::Key_Down)) {
3380 if (selection <(fHistoryTBTableList->count()-1))
3382 }
else if (e->key() == (Qt::Key_PageDown)) {
3383 selection = fHistoryTBTableList->count()-1;
3384 }
else if (e->key() == (Qt::Key_Up)) {
3387 }
else if (e->key() == (Qt::Key_PageUp)) {
3391 fHistoryTBTableList->clearSelection();
3392 #if QT_VERSION < 0x040202
3393 fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),
true);
3395 fHistoryTBTableList->item(selection)->setSelected(
true);
3397 fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
3399 moveCommandCursor =
true;
3400 }
else if (e->key() == (Qt::Key_Tab)) {
3402 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
3403 fCommandArea->home(
false);
3405 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
3406 fCommandArea->end(
false);
3409 }
else if (aEvent->type() == QEvent::Paint) {
3410 if (fLastCompleteCommand !=
"") {
3411 fCommandArea->setText(fLastCompleteCommand);
3412 fLastCompleteCommand =
"";
3416 if (tabKeyPress ==
true) {
3417 G4String ss = Complete(fCommandArea->text().toStdString().c_str());
3418 fCommandArea->setText((
char*)(ss.
data()));
3419 fCommandArea->setFocus();
3428 if (moveCommandCursor ==
true) {
3429 fCommandArea->setCursorPosition ( fCommandArea->text().length() );
3430 fCommandArea->setCursorPosition (4);
3433 res = QObject::eventFilter(aObj, aEvent);
3439 void G4UIQt::UpdateCommandCompleter() {
3440 if (!fCommandArea)
return;
3443 fCommandArea->setCompleter(NULL);
3445 if (fCompleter->popup()) {
3446 fCompleter->popup()->removeEventFilter(
this);
3450 QStandardItemModel*
model = CreateCompleterModel(
"/");
3451 fCompleter =
new QCompleter(model);
3458 int Ndir= aTree-> GetTreeEntry();
3459 fCompleter->setMaxVisibleItems(Ndir);
3461 fCommandArea->setCompleter(fCompleter);
3462 fCompleter->popup()->installEventFilter(
this);
3466 QStandardItemModel* G4UIQt::CreateCompleterModel(
G4String aCmd) {
3468 QList< QStandardItem*> dirModelList;
3469 QList< QStandardItem*> commandModelList;
3470 QList< QStandardItem*> subDirModelList;
3471 QList< QStandardItem*> subCommandModelList;
3483 if(jpre !=
G4int(G4String::npos)) pName.
remove(jpre+1);
3488 int Ndir= aTree-> GetTreeEntry();
3489 int Ncmd= aTree-> GetCommandEntry();
3492 for(
G4int idir=1; idir<=Ndir; idir++) {
3493 G4String fpdir= aTree-> GetTree(idir)-> GetPathName();
3495 if( fpdir.
index(remainingPath, 0) == 0) {
3497 matchingPath = fpdir;
3504 QStandardItem* item1 =
new QStandardItem(fpdir.
data());
3505 QIcon i = QIcon(*fDirIcon);
3507 item1->setIcon(QIcon(*fDirIcon));
3508 dirModelList.append(item1);
3511 QStandardItemModel* subModel = CreateCompleterModel(fpdir.
data());
3512 for (
int a=0;
a< subModel->rowCount();
a++) {
3515 QStandardItem* tempItem =
new QStandardItem(subModel->item(
a)->text());
3516 tempItem->setIcon(subModel->item(
a)->icon());
3517 tempItem->setToolTip(subModel->item(
a)->toolTip());
3518 tempItem->setData(subModel->item(
a)->data());
3521 if (tempItem->data() == 1) {
3523 subDirModelList.append(tempItem);
3526 else if (tempItem->data() == 0) {
3527 subCommandModelList.append(tempItem);
3534 G4int n_parameterEntry;
3536 G4int n_guidanceEntry;
3539 std::string tooltip;
3542 for(
G4int icmd=1; icmd<=Ncmd; icmd++){
3545 command = aTree-> GetCommand(icmd);
3546 G4String longCommandName= aTree-> GetPathName() +
3547 command -> GetCommandName();
3554 if( longCommandName.
index(remainingPath, 0) ==0) {
3556 matchingPath= longCommandName +
" ";
3558 strtmp= longCommandName +
" ";
3563 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3565 if (i_thGuidance < n_guidanceEntry-1 ) {
3571 for(
G4int a=0;
a<n_parameterEntry;
a++ ) {
3578 QStandardItem* item =
new QStandardItem(
G4String(longCommandName + params).
data());
3580 item->setIcon(QIcon(*fCommandIcon));
3581 item->setToolTip(tooltip.c_str());
3583 commandModelList.append(item);
3588 QStandardItemModel* model =
new QStandardItemModel();
3590 model->setColumnCount(1);
3593 for (
int a= 0;
a< dirModelList.size();
a++) {
3594 model->appendRow(dirModelList.at(
a));
3596 for (
int a= 0;
a< subDirModelList.size();
a++) {
3597 model->appendRow(subDirModelList.at(
a));
3599 for (
int a= 0;
a< commandModelList.size();
a++) {
3600 model->appendRow(commandModelList.at(
a));
3602 for (
int a= 0;
a< subCommandModelList.size();
a++) {
3603 model->appendRow(subCommandModelList.at(
a));
3618 void G4UIQt::ShowHelpCallback (
3627 void G4UIQt::ClearButtonCallback (
3630 fCoutTBTextArea->clear();
3631 fG4OutputString.clear();
3636 void G4UIQt::ExitSession (
3642 void G4UIQt::ExitHelp(
3650 void G4UIQt::CommandEnteredCallback (
3654 fCommandArea->setText(fCommandArea->text().trimmed());
3655 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
3658 for (
int a=0;
a< list.size();
a++) {
3659 QString txt (list[
a].trimmed());
3661 fHistoryTBTableList->addItem(txt);
3662 fHistoryTBTableList->clearSelection();
3663 fHistoryTBTableList->setCurrentItem(NULL);
3664 fCommandArea->setText(
"");
3665 G4Qt* interactorManager = G4Qt::getInstance ();
3666 if (interactorManager) {
3667 interactorManager->FlushAndWaitExecution();
3670 G4String command = txt.toStdString().c_str();
3671 if (command(0,4) !=
"help") {
3672 ApplyShellCommand (command,exitSession,exitPause);
3674 ActivateCommand(command);
3679 fCommandArea->setFocus();
3685 UpdateCommandCompleter();
3687 if(exitSession==
true)
3696 void G4UIQt::CommandEditedCallback(
const QString &)
3698 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
3700 if (list.size() > 1) {
3701 for (
int a=0;
a<list.size()-1;
a++) {
3703 fCommandArea->setText(list[
a]);
3705 CommandEnteredCallback();
3708 fCommandArea->setText(list[list.size()-1]);
3715 void G4UIQt::VisParameterCallback(QWidget* widget){
3716 if (widget == NULL) {
3721 QGridLayout* grid =
dynamic_cast<QGridLayout*
>(widget->layout());
3726 #if QT_VERSION < 0x040400
3727 QWidget* name = grid->itemAt(grid->columnCount()*(grid->rowCount()-2))->widget();
3729 QWidget* name = grid->itemAtPosition(grid->rowCount()-1,0)->widget();
3731 if (dynamic_cast<QLabel*>(name) == 0) {
3734 command += (
dynamic_cast<QLabel*
>(
name))->text()+
" ";
3736 for (
int a=0;
a<grid->rowCount()-1;
a++) {
3737 #if QT_VERSION < 0x040400
3738 QWidget* widgetTmp = grid->itemAt(
a*grid->columnCount()+1)->widget();
3740 QWidget* widgetTmp = grid->itemAtPosition(
a,1)->widget();
3744 if (widgetTmp != NULL) {
3746 if (dynamic_cast<QLineEdit*>(widgetTmp) != 0) {
3747 command += (
dynamic_cast<QLineEdit*
>(widgetTmp))->text()+
" ";
3749 }
else if (dynamic_cast<QComboBox*>(widgetTmp) != 0){
3750 command += (
dynamic_cast<QComboBox*
>(widgetTmp))->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex())+
" ";
3753 }
else if (dynamic_cast<QPushButton*>(widgetTmp) != 0){
3754 command += widgetTmp->accessibleName()+
" ";
3757 }
else if (dynamic_cast<QWidget*>(widgetTmp) != 0){
3758 if (widgetTmp->layout()->count() > 0){
3759 if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != 0) {
3760 QAbstractButton * checked = (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton();
3762 command += (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton()->text()+
" ";
3770 if (command !=
"") {
3784 void G4UIQt::ButtonCallback (
3785 const QString& aCommand
3792 if(UI==NULL)
return;
3799 if (IsGUICommand(command)) {
3800 QDialog* menuParameterDialog =
new QDialog();
3802 if (CreateVisCommandGroupAndToolBox(command,menuParameterDialog,1,
true)) {
3803 menuParameterDialog->setWindowTitle (aCommand);
3804 menuParameterDialog->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
3807 menuParameterDialog->exec();
3810 delete menuParameterDialog;
3814 ApplyShellCommand(ss,exitSession,exitPause);
3819 if(exitSession==
true)
3827 void G4UIQt::HelpTreeClicCallback (
3830 QTreeWidgetItem* item = NULL;
3831 if (!fHelpTreeWidget)
3834 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
3837 item = list.first();
3842 if(UI==NULL)
return;
3845 std::string itemText = GetLongCommandPath(item).toStdString();
3848 if (item->childCount() > 0) {
3854 updateHelpArea(command);
3860 fParameterHelpLabel->setVisible(
true);
3862 fParameterHelpTable->setVisible(
false);
3869 void G4UIQt::HelpTreeDoubleClicCallback (
3872 HelpTreeClicCallback();
3874 QTreeWidgetItem* item = NULL;
3875 if (!fHelpTreeWidget)
3878 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
3881 item = list.first();
3885 fCommandArea->clear();
3886 fCommandArea->setText(GetLongCommandPath(item));
3893 void G4UIQt::CommandHistoryCallback(
3896 QListWidgetItem* item = NULL;
3897 if (!fHistoryTBTableList)
3901 QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
3904 item = list.first();
3907 fCommandArea->setText(item->text());
3911 void G4UIQt::ThreadComboBoxCallback(
int) {
3912 CoutFilterCallback(
"");
3916 void G4UIQt::CoutFilterCallback(
3919 FilterAllOutputTextArea();
3921 fCoutTBTextArea->repaint();
3922 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
3927 void G4UIQt::SaveOutputCallback(){
3928 QString fileName = QFileDialog::getSaveFileName(fMainWindow,
"Save console output as...", fLastOpenPath,
"Save output as...");
3929 if (fileName !=
"") {
3931 QFile
data(fileName);
3932 if (
data.open(QFile::WriteOnly | QFile::Truncate)) {
3933 QTextStream out(&
data);
3934 out << fCoutTBTextArea->toPlainText();
3942 QString G4UIQt::FilterOutput(
3943 const G4UIOutputString& output
3944 ,
const QString& currentThread
3945 ,
const QString& filter
3948 #ifdef G4MULTITHREADED
3949 if ((currentThread ==
"All") ||
3950 (currentThread == output.fThread)) {
3952 if (currentThread ==
"") {
3954 if (output.fText.contains(QRegExp(filter))) {
3955 return output.fText;
3962 void G4UIQt::FilterAllOutputTextArea() {
3964 QString currentThread =
"";
3965 #ifdef G4MULTITHREADED
3966 currentThread = fThreadsFilterComboBox->currentText();
3967 if (currentThread ==
"Master") {
3971 QString filter = fCoutFilter->text();
3972 G4String previousOutputStream =
"";
3974 fCoutTBTextArea->clear();
3975 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3977 for (
unsigned int a=0;
a<fG4OutputString.size();
a++) {
3978 G4UIOutputString out = fG4OutputString[
a];
3979 if (FilterOutput(out,currentThread,filter) !=
"") {
3982 if (out.fOutputStream != previousOutputStream) {
3983 previousOutputStream = out.fOutputStream;
3984 if (out.fOutputStream ==
"info") {
3985 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3987 fCoutTBTextArea->setTextColor(QColor(
Qt::red));
3990 fCoutTBTextArea->
append(out.fText);
3993 fCoutTBTextArea->setTextColor(QColor(Qt::black));
4001 void G4UIQt::LookForHelpStringCallback(
4004 fHelpLine->setText(fHelpLine->text().trimmed());
4005 QString searchText = fHelpLine->text();
4007 fParameterHelpLabel->setText(
"");
4008 fParameterHelpTable->setVisible(
false);
4009 if (searchText ==
"") {
4011 fHelpTreeWidget->clear();
4017 OpenHelpTreeOnCommand(searchText);
4022 void G4UIQt::OpenHelpTreeOnCommand(
4023 const QString & searchText
4028 if(UI==NULL)
return;
4034 fHelpTreeWidget->clear();
4040 QMap<int,QString> commandResultMap;
4041 QMap<int,QString> commandChildResultMap;
4043 for (
int a=0;
a<treeSize;
a++) {
4045 tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
4050 commandChildResultMap = LookForHelpStringInChildTree(treeTop->
GetTree(
a+1),searchText);
4052 if (!commandChildResultMap.empty()) {
4053 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
4054 while (i != commandChildResultMap.constEnd()) {
4055 commandResultMap.insertMulti(i.key(),i.value());
4058 commandChildResultMap.clear();
4063 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
4064 fHelpTreeWidget->setColumnCount(2);
4066 labels << QString(
"Command") << QString(
"Match");
4067 fHelpTreeWidget->setHeaderLabels(labels);
4069 if (commandResultMap.empty()) {
4070 fParameterHelpLabel->setText(
"No match found");
4071 fParameterHelpTable->setVisible(
false);
4075 QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
4078 float multValue = 10.0/(float)(i.key());
4079 QString progressChar =
"|";
4080 QString progressStr =
"|";
4082 QTreeWidgetItem * newItem;
4085 if (i == commandResultMap.constBegin()) {
4088 for(
int a=0;
a<
int(i.key()*multValue);
a++) {
4089 progressStr += progressChar;
4091 newItem =
new QTreeWidgetItem();
4092 QString commandStr = i.value().trimmed();
4094 if (commandStr.indexOf(
"/") == 0) {
4095 commandStr = commandStr.right(commandStr.size()-1);
4098 newItem->setText(0,commandStr);
4099 newItem->setText(1,progressStr);
4100 fHelpTreeWidget->addTopLevelItem(newItem);
4101 #if QT_VERSION < 0x040200
4103 newItem->setForeground ( 1, QBrush(
Qt::blue) );
4108 fHelpTreeWidget->resizeColumnToContents (0);
4109 fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
4116 QMap<int,QString> G4UIQt::LookForHelpStringInChildTree(
4118 ,
const QString & text
4121 QMap<int,QString> commandResultMap;
4122 if (aCommandTree == NULL)
return commandResultMap;
4127 QMap<int,QString> commandChildResultMap;
4131 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
4136 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->
GetTree(
a+1),text);
4138 if (!commandChildResultMap.empty()) {
4140 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
4141 while (i != commandChildResultMap.constEnd()) {
4142 commandResultMap.insertMulti(i.key(),i.value());
4145 commandChildResultMap.clear();
4152 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
4158 return commandResultMap;
4162 QString G4UIQt::GetShortCommandPath(
4166 if (commandPath.indexOf(
"/") == 0) {
4167 commandPath = commandPath.right(commandPath.size()-1);
4170 commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf(
"/",-2)-1);
4172 if (commandPath.lastIndexOf(
"/") == (commandPath.size()-1)) {
4173 commandPath = commandPath.left(commandPath.size()-1);
4180 QString G4UIQt::GetLongCommandPath(
4181 QTreeWidgetItem* item
4184 if (item == NULL)
return "";
4187 QString itemText =
"";
4188 itemText = item->text(0);
4190 while (item->parent() != NULL) {
4191 itemText = item->parent()->text(0)+
"/"+itemText;
4192 item = item->parent();
4194 itemText =
"/"+itemText;
4200 void G4UIQt::ChangeColorCallback(QWidget* widget) {
4201 if (widget == NULL) {
4205 QPushButton* button =
dynamic_cast<QPushButton*
>(widget);
4209 QString
value = button->accessibleName();
4212 old.setRgbF(value.section(
" ",0,1).toDouble(),
4213 value.section(
" ",1,2).toDouble(),
4214 value.section(
" ",2,3).toDouble());
4215 #if QT_VERSION < 0x040500
4217 QColor color = QColor(QColorDialog::getRgba (old.rgba(),&
a,fUITabWidget));
4219 QColor color = QColorDialog::getColor(old,
4222 QColorDialog::ShowAlphaChannel);
4226 if (color.isValid()) {
4228 QPixmap pixmap = QPixmap(QSize(16, 16));
4229 pixmap.fill (color);
4230 QPainter painter(&pixmap);
4231 painter.setPen(Qt::black);
4232 painter.drawRect(0,0,15,15);
4234 button->setAccessibleName(QString::number(color.redF())+
" "+
4235 QString::number(color.greenF())+
" "+
4236 QString::number(color.blueF())+
" "
4238 button->setIcon(pixmap);
4245 void G4UIQt::ChangeCursorAction(
const QString& action) {
4249 fMoveSelected =
true;
4250 fPickSelected =
true;
4251 fRotateSelected =
true;
4252 fZoomInSelected =
true;
4253 fZoomOutSelected =
true;
4255 if (fToolbarApp == NULL)
return;
4256 QList<QAction *> list = fToolbarApp->actions ();
4257 for (
int i = 0; i < list.size(); ++i) {
4258 if (list.at(i)->data().toString () == action) {
4259 list.at(i)->setChecked(
TRUE);
4260 if (list.at(i)->data().toString () ==
"pick") {
4262 CreatePickInfosDialog();
4264 fPickInfosDialog->show();
4265 fPickInfosDialog->raise();
4266 fPickInfosDialog->activateWindow();
4268 }
else if (list.at(i)->data().toString () ==
"move") {
4269 fMoveSelected =
false;
4270 list.at(i)->setChecked(
FALSE);
4271 }
else if (list.at(i)->data().toString () ==
"pick") {
4272 fPickSelected =
false;
4273 list.at(i)->setChecked(
FALSE);
4275 if (fPickInfosDialog) {
4276 fPickInfosDialog->hide();
4278 }
else if (list.at(i)->data().toString () ==
"rotate") {
4279 fRotateSelected =
false;
4280 list.at(i)->setChecked(
FALSE);
4281 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4282 fZoomInSelected =
false;
4283 list.at(i)->setChecked(
FALSE);
4284 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4285 fZoomOutSelected =
false;
4286 list.at(i)->setChecked(
FALSE);
4299 void G4UIQt::ChangeSurfaceStyle(
const QString& action) {
4303 if (fToolbarApp == NULL)
return;
4304 QList<QAction *> list = fToolbarApp->actions ();
4305 for (
int i = 0; i < list.size(); ++i) {
4306 if (list.at(i)->data().toString () == action) {
4307 list.at(i)->setChecked(
TRUE);
4308 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4309 list.at(i)->setChecked(
FALSE);
4310 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4311 list.at(i)->setChecked(
FALSE);
4312 }
else if (list.at(i)->data().toString () ==
"solid") {
4313 list.at(i)->setChecked(
FALSE);
4314 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4315 list.at(i)->setChecked(
FALSE);
4320 if (action ==
"hidden_line_removal") {
4324 }
else if (action ==
"hidden_line_and_surface_removal") {
4328 }
else if (action ==
"solid") {
4332 }
else if (action ==
"wireframe") {
4339 void G4UIQt::OpenIconCallback(
const QString& aParam) {
4341 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4342 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
4344 QString nomFich = QFileDialog::getOpenFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
4345 if (nomFich !=
"") {
4348 fLastOpenPath = dir.absoluteFilePath(nomFich);
4353 void G4UIQt::SaveIconCallback(
const QString& aParam) {
4355 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4356 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
4358 QString nomFich = QFileDialog::getSaveFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
4359 if (nomFich !=
"") {
4362 fLastOpenPath = dir.absoluteFilePath(nomFich);
4367 void G4UIQt::CreateViewerPropertiesDialog() {
4369 if (fViewerPropertiesDialog != NULL) {
4372 fViewerPropertiesDialog =
new QDialog();
4374 fViewerPropertiesDialog->setWindowTitle(
"Viewer properties");
4375 fViewerPropertiesDialog->setSizePolicy (QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
4377 if (!fViewerPropertiesWidget) {
4378 fViewerPropertiesWidget =
new QWidget();
4379 QVBoxLayout* layoutPropertiesWidget =
new QVBoxLayout();
4380 fViewerPropertiesWidget->setLayout(layoutPropertiesWidget);
4382 CreateEmptyViewerPropertiesWidget();
4385 QVBoxLayout* layoutDialog =
new QVBoxLayout();
4387 layoutDialog->addWidget(fViewerPropertiesWidget);
4388 layoutDialog->setContentsMargins(0,0,0,0);
4389 fViewerPropertiesDialog->setLayout(layoutDialog);
4393 void G4UIQt::CreatePickInfosDialog() {
4395 if (fPickInfosDialog != NULL) {
4398 fPickInfosDialog =
new QDialog();
4400 fPickInfosDialog->setWindowTitle(
"Pick infos");
4401 fPickInfosDialog->setSizePolicy (QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
4403 if (!fPickInfosWidget) {
4404 fPickInfosWidget =
new QWidget();
4405 QVBoxLayout* layoutPickInfos =
new QVBoxLayout();
4406 fPickInfosWidget->setLayout(layoutPickInfos);
4408 CreateEmptyPickInfosWidget();
4411 QVBoxLayout* layoutDialog =
new QVBoxLayout();
4413 layoutDialog->addWidget(fPickInfosWidget);
4414 layoutDialog->setContentsMargins(0,0,0,0);
4415 fPickInfosDialog->setLayout(layoutDialog);
4416 fPickInfosDialog->setWindowFlags(Qt::WindowStaysOnTopHint);
4421 void G4UIQt::CreateEmptyViewerPropertiesWidget() {
4422 QLayoutItem * wItem;
4423 if (fViewerPropertiesWidget->layout()->count()) {
4424 while ((wItem = fViewerPropertiesWidget->layout()->takeAt(0)) != 0) {
4425 delete wItem->widget();
4430 QLabel* label =
new QLabel(
"No viewer - Please open a viewer first");
4431 fViewerPropertiesWidget->layout()->addWidget(label);
4432 fViewerPropertiesDialog->setWindowTitle(
"No viewer");
4436 void G4UIQt::CreateEmptyPickInfosWidget() {
4437 QLayoutItem * wItem;
4438 if (fPickInfosWidget->layout()->count()) {
4439 while ((wItem = fPickInfosWidget->layout()->takeAt(0)) != 0) {
4440 delete wItem->widget();
4445 QLabel* label =
new QLabel(
"Click on the object you want to pick");
4446 fPickInfosWidget->layout()->addWidget(label);
4447 fPickInfosDialog->setWindowTitle(
"Nothing to pick");
4451 void G4UIQt::ViewerPropertiesIconCallback(
int) {
4453 CreateViewerPropertiesDialog();
4455 fViewerPropertiesDialog->show();
4456 fViewerPropertiesDialog->raise();
4457 fViewerPropertiesDialog->activateWindow();
4461 void G4UIQt::ChangePerspectiveOrtho(
const QString& action) {
4465 if (fToolbarApp == NULL)
return;
4466 QList<QAction *> list = fToolbarApp->actions ();
4467 QString checked =
"";
4468 for (
int i = 0; i < list.size(); ++i) {
4469 if (list.at(i)->data().toString () == action) {
4470 list.at(i)->setChecked(
TRUE);
4471 checked = list.at(i)->data().toString ();
4472 }
else if (list.at(i)->data().toString () ==
"persepective") {
4473 list.at(i)->setChecked(
FALSE);
4474 }
else if (list.at(i)->data().toString () ==
"ortho") {
4475 list.at(i)->setChecked(
FALSE);
4479 if ((action ==
"ortho") && (checked ==
"ortho")) {
4481 }
else if ((action ==
"perspective") && (checked ==
"perspective")) {
4488 void G4UIQt::SetIconMoveSelected() {
4490 fMoveSelected =
true;
4491 fRotateSelected =
false;
4492 fPickSelected =
false;
4493 fZoomInSelected =
false;
4494 fZoomOutSelected =
false;
4496 if (fToolbarApp == NULL)
return;
4497 QList<QAction *> list = fToolbarApp->actions ();
4498 for (
int i = 0; i < list.size(); ++i) {
4499 if (list.at(i)->data().toString () ==
"move") {
4500 list.at(i)->setChecked(
TRUE);
4501 }
else if (list.at(i)->data().toString () ==
"rotate") {
4502 list.at(i)->setChecked(
FALSE);
4503 }
else if (list.at(i)->data().toString () ==
"pick") {
4504 list.at(i)->setChecked(
FALSE);
4505 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4506 list.at(i)->setChecked(
FALSE);
4507 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4508 list.at(i)->setChecked(
FALSE);
4514 void G4UIQt::SetIconRotateSelected() {
4516 fRotateSelected =
true;
4517 fMoveSelected =
false;
4518 fPickSelected =
false;
4519 fZoomInSelected =
false;
4520 fZoomOutSelected =
false;
4522 if (fToolbarApp == NULL)
return;
4523 QList<QAction *> list = fToolbarApp->actions ();
4524 for (
int i = 0; i < list.size(); ++i) {
4525 if (list.at(i)->data().toString () ==
"rotate") {
4526 list.at(i)->setChecked(
TRUE);
4527 }
else if (list.at(i)->data().toString () ==
"move") {
4528 list.at(i)->setChecked(
FALSE);
4529 }
else if (list.at(i)->data().toString () ==
"pick") {
4530 list.at(i)->setChecked(
FALSE);
4531 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4532 list.at(i)->setChecked(
FALSE);
4533 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4534 list.at(i)->setChecked(
FALSE);
4540 void G4UIQt::SetIconPickSelected() {
4542 fPickSelected =
true;
4543 fMoveSelected =
false;
4544 fRotateSelected =
false;
4545 fZoomInSelected =
false;
4546 fZoomOutSelected =
false;
4548 QToolBar*
bar = fToolbarApp;
4549 if (!fDefaultIcons) {
4554 QList<QAction *> list = bar->actions ();
4555 for (
int i = 0; i < list.size(); ++i) {
4556 if (list.at(i)->data().toString () ==
"pick") {
4557 list.at(i)->setChecked(
TRUE);
4558 }
else if (list.at(i)->data().toString () ==
"move") {
4559 list.at(i)->setChecked(
FALSE);
4560 }
else if (list.at(i)->data().toString () ==
"rotate") {
4561 list.at(i)->setChecked(
FALSE);
4562 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4563 list.at(i)->setChecked(
FALSE);
4564 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4565 list.at(i)->setChecked(
FALSE);
4571 void G4UIQt::SetIconZoomInSelected() {
4573 fZoomInSelected =
true;
4574 fMoveSelected =
false;
4575 fRotateSelected =
false;
4576 fPickSelected =
false;
4577 fZoomOutSelected =
false;
4579 QToolBar* bar = fToolbarApp;
4580 if (!fDefaultIcons) {
4585 QList<QAction *> list = bar->actions ();
4586 for (
int i = 0; i < list.size(); ++i) {
4587 if (list.at(i)->data().toString () ==
"zoom_in") {
4588 list.at(i)->setChecked(
TRUE);
4589 }
else if (list.at(i)->data().toString () ==
"move") {
4590 list.at(i)->setChecked(
FALSE);
4591 }
else if (list.at(i)->data().toString () ==
"rotate") {
4592 list.at(i)->setChecked(
FALSE);
4593 }
else if (list.at(i)->data().toString () ==
"pick") {
4594 list.at(i)->setChecked(
FALSE);
4595 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
4596 list.at(i)->setChecked(
FALSE);
4602 void G4UIQt::SetIconZoomOutSelected() {
4604 fZoomOutSelected =
true;
4605 fMoveSelected =
false;
4606 fRotateSelected =
false;
4607 fPickSelected =
false;
4608 fZoomInSelected =
false;
4610 QToolBar* bar = fToolbarApp;
4611 if (!fDefaultIcons) {
4616 QList<QAction *> list = bar->actions ();
4617 for (
int i = 0; i < list.size(); ++i) {
4618 if (list.at(i)->data().toString () ==
"zoom_out") {
4619 list.at(i)->setChecked(
TRUE);
4620 }
else if (list.at(i)->data().toString () ==
"move") {
4621 list.at(i)->setChecked(
FALSE);
4622 }
else if (list.at(i)->data().toString () ==
"rotate") {
4623 list.at(i)->setChecked(
FALSE);
4624 }
else if (list.at(i)->data().toString () ==
"pick") {
4625 list.at(i)->setChecked(
FALSE);
4626 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
4627 list.at(i)->setChecked(
FALSE);
4633 void G4UIQt::SetIconSolidSelected() {
4636 QToolBar* bar = fToolbarApp;
4637 if (!fDefaultIcons) {
4642 QList<QAction *> list = bar->actions ();
4643 for (
int i = 0; i < list.size(); ++i) {
4644 if (list.at(i)->data().toString () ==
"solid") {
4645 list.at(i)->setChecked(
TRUE);
4646 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4647 list.at(i)->setChecked(
FALSE);
4648 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4649 list.at(i)->setChecked(
FALSE);
4650 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4651 list.at(i)->setChecked(
FALSE);
4657 void G4UIQt::SetIconWireframeSelected() {
4660 QToolBar* bar = fToolbarApp;
4661 if (!fDefaultIcons) {
4666 QList<QAction *> list = bar->actions ();
4667 for (
int i = 0; i < list.size(); ++i) {
4668 if (list.at(i)->data().toString () ==
"wireframe") {
4669 list.at(i)->setChecked(
TRUE);
4670 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4671 list.at(i)->setChecked(
FALSE);
4672 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4673 list.at(i)->setChecked(
FALSE);
4674 }
else if (list.at(i)->data().toString () ==
"solid") {
4675 list.at(i)->setChecked(
FALSE);
4681 void G4UIQt::SetIconHLRSelected() {
4684 QToolBar* bar = fToolbarApp;
4685 if (!fDefaultIcons) {
4691 QList<QAction *> list = bar->actions ();
4692 for (
int i = 0; i < list.size(); ++i) {
4693 if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4694 list.at(i)->setChecked(
TRUE);
4695 }
else if (list.at(i)->data().toString () ==
"solid") {
4696 list.at(i)->setChecked(
FALSE);
4697 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4698 list.at(i)->setChecked(
FALSE);
4699 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4700 list.at(i)->setChecked(
FALSE);
4706 void G4UIQt::SetIconHLHSRSelected() {
4709 QToolBar* bar = fToolbarApp;
4710 if (!fDefaultIcons) {
4716 QList<QAction *> list = bar->actions ();
4717 for (
int i = 0; i < list.size(); ++i) {
4718 if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
4719 list.at(i)->setChecked(
TRUE);
4720 }
else if (list.at(i)->data().toString () ==
"solid") {
4721 list.at(i)->setChecked(
FALSE);
4722 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
4723 list.at(i)->setChecked(
FALSE);
4724 }
else if (list.at(i)->data().toString () ==
"wireframe") {
4725 list.at(i)->setChecked(
FALSE);
4731 void G4UIQt::SetIconPerspectiveSelected() {
4734 QToolBar* bar = fToolbarApp;
4735 if (!fDefaultIcons) {
4741 QList<QAction *> list = bar->actions ();
4742 for (
int i = 0; i < list.size(); ++i) {
4743 if (list.at(i)->data().toString () ==
"perspective") {
4744 list.at(i)->setChecked(
TRUE);
4745 }
else if (list.at(i)->data().toString () ==
"ortho") {
4746 list.at(i)->setChecked(
FALSE);
4753 void G4UIQt::SetIconOrthoSelected() {
4756 QToolBar* bar = fToolbarApp;
4757 if (!fDefaultIcons) {
4763 QList<QAction *> list = bar->actions ();
4764 for (
int i = 0; i < list.size(); ++i) {
4765 if (list.at(i)->data().toString () ==
"ortho") {
4766 list.at(i)->setChecked(
TRUE);
4767 }
else if (list.at(i)->data().toString () ==
"perspective") {
4768 list.at(i)->setChecked(
FALSE);
4775 G4QTabWidget::G4QTabWidget(
4779 ):QTabWidget(aParent)
4780 ,fTabSelected(false)
4782 ,fPreferedSizeX(sizeX+6)
4783 ,fPreferedSizeY(sizeY+58)
4785 setMinimumSize(100,100);
4786 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
4787 setSizePolicy(policy);
4790 G4QTabWidget::G4QTabWidget(
4792 ,fTabSelected(false)
4800 G4UIOutputString::G4UIOutputString(
4808 if (!GetOutputList().contains(QString(
" ")+outputStream+
" ")) {
4809 fOutputStream =
"info";
4811 fOutputStream = outputStream;
4816 #if QT_VERSION < 0x040500
4817 void G4UIQt::TabCloseCallback(
int){
4819 void G4UIQt::TabCloseCallback(
int a){
4821 #if QT_VERSION < 0x040500
4823 if (fViewerTabWidget == NULL)
return;
4826 QWidget* temp = fViewerTabWidget->widget(a);
4828 fViewerTabWidget->removeTab (a);
4831 bool lastTab =
true;
4832 for (
int c=0; c<fViewerTabWidget->count(); c++) {
4833 if (fViewerTabWidget->tabText(c).contains(
"viewer")) {
4839 CreateEmptyViewerPropertiesWidget();
4847 void G4UIQt::ToolBoxActivated(
int a){
4849 if (fUITabWidget->widget(a) == fHelpTBWidget) {
4852 }
else if (fUITabWidget->widget(a) == fSceneTreeWidget) {
4853 #if QT_VERSION < 0x040200
4854 fSceneTreeWidget->show();
4856 fSceneTreeWidget->setVisible(
true);
4862 void G4QTabWidget::paintEvent(
4867 if (currentWidget()) {
4869 if ( isTabSelected()) {
4873 QString text = tabText (currentIndex());
4875 if (fLastCreated == -1) {
4876 QTextEdit* edit =
dynamic_cast<QTextEdit*
>(currentWidget());
4878 QString paramSelect = QString(
"/vis/viewer/select ")+text;
4887 setTabSelected(
false);
4893 G4UIDockWidget::G4UIDockWidget(QString txt):
4898 void G4UIDockWidget::closeEvent(QCloseEvent *aEvent) {
4899 setFloating (
false);
G4UIcommandTree * GetTree() const
G4String GetPrefixString() const
G4String & remove(str_size)
std::vector< ExP01TrackerHit * > a
G4UIcommandTree * FindCommandTree(const char *commandPath)
static const G4double pos
G4MTcoutDestination * GetThreadCout()
G4int ApplyCommand(const char *aCommand)
void message(RunManager *runmanager)
const G4String GetPathName() const
const G4String & GetGuidanceLine(G4int i) const
G4String FindMacroPath(const G4String &fname) const
char GetParameterType() const
G4String GetDefaultValue() const
G4UIparameter * GetParameter(G4int i) const
G4String GetFullPrefixString() const
G4String GetParameterCandidates() const
str_size index(const char *, G4int pos=0) const
G4int GetGuidanceEntries() const
G4String GetParameterRange() const
static G4UImanager * GetUIpointer()
const XML_Char const XML_Char * data
G4UIcommand * GetCommand(G4int i)
G4String GetFirstMatchedString(const G4String &, const G4String &) const
#define G4MUTEX_INITIALIZER
const XML_Char int const XML_Char * value
const G4ParticleDefinition const G4Material *G4double range
const G4String GetParameterGuidance() const
const char * data() const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
G4String strip(G4int strip_Type=trailing, char c=' ')
G4bool contains(const std::string &) const
const G4String & GetCommandPath() const
void SetG4UIWindow(G4UIsession *const value)
G4double G4ParticleHPJENDLHEData::G4double result
void SetCoutDestination(G4UIsession *const value)
G4ApplicationState GetCurrentState() const
G4int GetVerboseLevel() const
G4int GetCommandEntry() const
G4bool GetCurrentAsDefault() const
G4bool IsOmittable() const
G4int GetParameterEntries() const
G4GLOB_DLL std::ostream G4cout
G4int GetTreeEntry() const
const G4String GetTitle() const
G4String & append(const G4String &)
G4UIcommand * FindPath(const char *commandPath) const
static constexpr double bar
const XML_Char XML_Content * model
const G4UIcommand * GetGuidance() const
G4String GetParameterName() const
const G4String & GetRange() const
void SetSession(G4UIsession *const value)
static G4StateManager * GetStateManager()
G4UIcommandTree * GetTree(G4int i)