31 #ifdef G4UI_BUILD_QT_SESSION
45 #include <qapplication.h>
46 #include <qmessagebox.h>
47 #include <qlineedit.h>
51 #include <qpushbutton.h>
53 #include <qsplitter.h>
54 #include <qscrollbar.h>
57 #include <qtextedit.h>
58 #include <qsignalmapper.h>
59 #include <qtabwidget.h>
61 #include <qstringlist.h>
63 #include <qmainwindow.h>
65 #include <qlistwidget.h>
66 #include <qtreewidget.h>
67 #include <qgroupbox.h>
68 #include <qscrollarea.h>
70 #include <qradiobutton.h>
71 #include <qbuttongroup.h>
72 #include <qcombobox.h>
73 #include <qsignalmapper.h>
75 #include <qcolordialog.h>
77 #include <qfiledialog.h>
84 static G4bool exitSession =
true;
85 static G4bool exitPause =
true;
114 ,fCoutTBTextArea(NULL)
117 ,fHelpTreeWidget(NULL)
119 ,fHistoryTBWidget(NULL)
121 ,fSceneTreeComponentsTBWidget(NULL)
123 ,fViewerTabWidget(NULL)
129 ,fMoveSelected(false)
130 ,fRotateSelected(true)
131 ,fPickSelected(false)
132 ,fZoomInSelected(false)
133 ,fZoomOutSelected(false)
136 G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(
char*)
"Qt");
137 if (!(QApplication*)interactorManager->GetMainInteractor()) {
138 G4cout <<
"G4UIQt : Unable to init Qt. Aborted" <<
G4endl;
147 Q_FOREACH (QWidget *widget, QApplication::allWidgets()) {
148 if ((found==
false) && (widget->inherits(
"QMainWindow"))) {
154 G4cout <<
"G4UIQt : Found an external App with a QMainWindow already defined. Aborted" <<
G4endl;
157 fMainWindow =
new QMainWindow();
160 #ifdef G4DEBUG_INTERFACES_BASIC
161 printf(
"G4UIQt::Initialise after main window creation +++++++++++\n");
166 fMainSplitterWidget =
new QSplitter(Qt::Horizontal,fMainWindow);
168 QWidget *leftSplitterWidget =
new QWidget(fMainSplitterWidget);
169 QVBoxLayout * layoutLeftSplitterWidget =
new QVBoxLayout();
170 leftSplitterWidget->setLayout(layoutLeftSplitterWidget);
171 fRightSplitterWidget =
new QSplitter(Qt::Vertical,fMainSplitterWidget);
174 fUITabWidget =
new QTabWidget();
178 QWidget* commandLineWidget =
new QWidget();
179 QVBoxLayout *layoutCommandLine =
new QVBoxLayout();
180 commandLineWidget->setLayout(layoutCommandLine);
184 fCommandLabel =
new QLabel(
"",commandLineWidget);
186 fCommandArea =
new QLineEdit(commandLineWidget);
187 fCommandArea->installEventFilter(
this);
188 fCommandArea->activateWindow();
190 fCommandArea->setFocusPolicy ( Qt::StrongFocus );
191 fCommandArea->setFocus(Qt::TabFocusReason);
193 commandLineWidget->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
196 layoutCommandLine->addWidget(fCommandLabel);
197 layoutCommandLine->addWidget(fCommandArea);
199 fHelpTBWidget =
new QWidget(fUITabWidget);
200 fHistoryTBWidget =
new QWidget(fUITabWidget);
201 fSceneTreeComponentsTBWidget =
new QTabWidget(fUITabWidget);
203 #if QT_VERSION < 0x040200
204 fSceneTreeComponentsTBWidget->hide();
206 fSceneTreeComponentsTBWidget->setVisible(
false);
209 fEmptyViewerTabLabel =
new QLabel(
" If you want to have a Viewer, please use /vis/open commands. ");
211 layoutLeftSplitterWidget->addWidget(fUITabWidget);
213 fCoutTBWidget =
new QGroupBox(
"Output");
216 fRightSplitterWidget->addWidget(fEmptyViewerTabLabel);
217 fRightSplitterWidget->addWidget(fCoutTBWidget);
218 fRightSplitterWidget->addWidget(commandLineWidget);
227 CreateVisParametersTBWidget();
228 CreateHelpTBWidget();
229 CreateHistoryTBWidget();
231 CreateCoutTBWidget();
238 fUITabWidget->addTab(fSceneTreeComponentsTBWidget,
"Scene tree");
239 fUITabWidget->addTab(fHelpTBWidget,
"Help");
240 fUITabWidget->addTab(fHistoryTBWidget,
"History");
241 fUITabWidget->setCurrentWidget(fSceneTreeComponentsTBWidget);
244 #if QT_VERSION < 0x040200
245 fEmptyViewerTabLabel->hide();
247 fEmptyViewerTabLabel->setVisible(
false);
251 fMainSplitterWidget->addWidget(leftSplitterWidget);
252 fMainSplitterWidget->addWidget(fRightSplitterWidget);
257 fMainSplitterWidget->setSizes(list);
260 #ifdef G4DEBUG_INTERFACES_BASIC
261 printf(
"G4UIQt::G4UIQt :: 5\n");
265 fMainWindow->setCentralWidget(fMainSplitterWidget);
267 #ifdef G4DEBUG_INTERFACES_BASIC
268 printf(
"G4UIQt::G4UIQt :: 6\n");
272 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
273 connect(fUITabWidget, SIGNAL(currentChanged(
int)), SLOT(ToolBoxActivated(
int)));
277 fMainWindow->setWindowTitle(QFileInfo( QCoreApplication::applicationFilePath() ).fileName());
278 fMainWindow->resize(300,600);
279 fMainWindow->move(QPoint(50,50));
282 #if QT_VERSION < 0x040200
285 fMainWindow->setVisible(
false);
288 #ifdef G4DEBUG_INTERFACES_BASIC
289 printf(
"G4UIQt::G4UIQt END\n");
298 #ifdef G4DEBUG_INTERFACES_BASIC
299 printf(
"G4UIQt::~G4UIQt Delete\n");
308 if (fMainWindow!=NULL) {
309 #ifdef G4DEBUG_INTERFACES_BASIC
310 printf(
"G4UIQt::~G4UIQt DELETE fMainWindow\n");
318 void G4UIQt::CreateHistoryTBWidget(
322 QVBoxLayout *layoutHistoryTB =
new QVBoxLayout();
323 fHistoryTBTableList =
new QListWidget();
324 fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
325 connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
326 fHistoryTBTableList->installEventFilter(
this);
328 layoutHistoryTB->addWidget(fHistoryTBTableList);
330 fHistoryTBWidget->setLayout(layoutHistoryTB);
335 void G4UIQt::CreateHelpTBWidget(
340 QWidget *helpWidget =
new QWidget();
341 QHBoxLayout *helpLayout =
new QHBoxLayout();
342 QVBoxLayout *vLayout =
new QVBoxLayout();
343 fHelpVSplitter =
new QSplitter(Qt::Horizontal);
344 fHelpLine =
new QLineEdit(fHelpTBWidget);
345 helpLayout->addWidget(
new QLabel(
"Search :",helpWidget));
346 helpLayout->addWidget(fHelpLine);
347 connect( fHelpLine, SIGNAL( editingFinished () ),
this, SLOT( LookForHelpStringCallback() ) );
352 fHelpArea =
new QTextEdit();
353 fHelpArea->setReadOnly(
true);
357 if (fHelpTreeWidget) {
358 fHelpVSplitter->addWidget(fHelpTreeWidget);
360 fHelpVSplitter->addWidget(fHelpArea);
362 vLayout->addWidget(helpWidget);
363 vLayout->addWidget(fHelpVSplitter,1);
365 fHelpTBWidget->setMinimumSize(50,50);
366 fHelpTBWidget->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
372 fHelpVSplitter->setSizes(list);
374 helpWidget->setLayout(helpLayout);
375 fHelpTBWidget->setLayout(vLayout);
381 void G4UIQt::CreateCoutTBWidget(
384 QVBoxLayout *layoutCoutTB =
new QVBoxLayout();
386 fCoutTBTextArea =
new QTextEdit(fCoutTBWidget);
387 fCoutFilter =
new QLineEdit(fCoutTBWidget);
388 QLabel* coutFilterLabel =
new QLabel(
"Filter : ",fCoutTBWidget);
390 QPushButton *coutTBClearButton =
new QPushButton(
"clear",fCoutTBWidget);
391 connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
392 connect(fCoutFilter, SIGNAL(textEdited (
const QString &)), SLOT(CoutFilterCallback(
const QString &)));
394 fCoutTBTextArea->setReadOnly(
true);
396 QWidget* coutButtonWidget =
new QWidget(fCoutTBWidget);
397 QHBoxLayout* layoutCoutTBButtons =
new QHBoxLayout(coutButtonWidget);
398 layoutCoutTBButtons->addWidget(coutTBClearButton);
399 layoutCoutTBButtons->addWidget(coutFilterLabel);
400 layoutCoutTBButtons->addWidget(fCoutFilter);
402 layoutCoutTB->addWidget(fCoutTBTextArea);
403 layoutCoutTB->addWidget(coutButtonWidget);
405 fCoutTBWidget->resize(100,100);
406 fCoutTBTextArea->setMinimumHeight(10);
407 fCoutTBWidget->setMinimumHeight(150);
409 fCoutTBWidget->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
410 fCoutTBWidget->setLayout(layoutCoutTB);
416 void G4UIQt::CreateVisParametersTBWidget(
424 QTabWidget* G4UIQt::GetSceneTreeComponentsTBWidget(
427 return fSceneTreeComponentsTBWidget;
434 bool G4UIQt::AddTabWidget(
441 #ifdef G4DEBUG_INTERFACES_BASIC
442 printf(
"G4UIQt::AddTabWidget %d %d\n",sizeX, sizeY);
445 if (fViewerTabWidget == NULL) {
446 #ifdef G4DEBUG_INTERFACES_BASIC
447 printf(
"G4UIQt::AddTabWidget +++++\n");
450 fViewerTabWidget =
new G4QTabWidget(fRightSplitterWidget);
451 #if QT_VERSION < 0x040500
453 fViewerTabWidget->setTabsClosable (
true);
456 #if QT_VERSION < 0x040200
458 fViewerTabWidget->setUsesScrollButtons (
true);
460 QSizePolicy policy = fViewerTabWidget->sizePolicy();
461 policy.setHorizontalStretch(1);
462 policy.setVerticalStretch(1);
463 fViewerTabWidget->setSizePolicy(policy);
465 #if QT_VERSION < 0x040500
467 connect(fViewerTabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(TabCloseCallback(
int)));
469 connect(fViewerTabWidget, SIGNAL(currentChanged (
int ) ), SLOT(UpdateTabWidget(
int)));
472 fLastQTabSizeX = sizeX;
473 fLastQTabSizeY = sizeY;
483 if (fEmptyViewerTabLabel != NULL) {
484 int index = fRightSplitterWidget->indexOf(fEmptyViewerTabLabel);
486 fEmptyViewerTabLabel->hide();
487 fEmptyViewerTabLabel->setParent(NULL);
488 delete fEmptyViewerTabLabel;
489 fEmptyViewerTabLabel = NULL;
491 fRightSplitterWidget->insertWidget(index,fViewerTabWidget);
493 aWidget->setParent(fViewerTabWidget);
497 #ifdef G4DEBUG_INTERFACES_BASIC
498 printf(
"G4UIQt::AddTabWidget ADD %d %d + %d %d---------------------------------------------------\n",sizeX, sizeY,sizeX-fViewerTabWidget->width(),sizeY-fViewerTabWidget->height());
505 fViewerTabWidget->insertTab(fViewerTabWidget->count(),aWidget,
name);
507 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
510 #if QT_VERSION < 0x040200
511 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
513 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
516 fViewerTabWidget->resize(sizeX,sizeY);
522 void G4UIQt::UpdateTabWidget(
int tabNumber) {
523 #ifdef G4DEBUG_INTERFACES_BASIC
524 printf(
"G4UIQt::UpdateTabWidget %d\n",tabNumber);
526 if ( fViewerTabWidget == NULL) {
527 fViewerTabWidget =
new G4QTabWidget;
530 #ifdef G4DEBUG_INTERFACES_BASIC
531 printf(
"G4UIQt::UpdateTabWidget CALL REPAINT tabGL\n");
534 fViewerTabWidget->setCurrentIndex(tabNumber);
537 fViewerTabWidget->setTabSelected(
false);
539 #if QT_VERSION < 0x040200
540 fViewerTabWidget->show();
542 fViewerTabWidget->setVisible(
true);
546 fViewerTabWidget->setTabSelected(
true);
548 QCoreApplication::sendPostedEvents () ;
550 #ifdef G4DEBUG_INTERFACES_BASIC
551 printf(
"G4UIQt::UpdateTabWidget END\n");
558 void G4UIQt::ResizeTabWidget( QResizeEvent*
e) {
559 for (
G4int a=0;
a<fViewerTabWidget->count() ;
a++) {
560 #ifdef G4DEBUG_INTERFACES_BASIC
561 printf(
"G4UIQt::ResizeTabWidget +++++++++++++++++++++++++++++++++++++++\n");
563 fViewerTabWidget->widget(
a)->resize(e->size());
573 #ifdef G4DEBUG_INTERFACES_BASIC
574 printf(
"G4UIQt::G4UIQt SessionStart\n");
577 G4Qt* interactorManager = G4Qt::getInstance ();
591 #if QT_VERSION < 0x040200
594 fMainWindow->setVisible(
true);
600 if (fViewerTabWidget != NULL) {
601 tabBarX = -fViewerTabWidget->widget(0)->width();
602 tabBarY = -fViewerTabWidget->widget(0)->height();
604 fMainWindow->resize(tabBarX+fMainWindow->width()+fLastQTabSizeX,tabBarY+fMainWindow->height()+fLastQTabSizeY);
606 QCoreApplication::sendPostedEvents () ;
608 #ifdef G4DEBUG_INTERFACES_BASIC
609 printf(
"G4UIQt::G4UIQt SessionStart2\n");
611 interactorManager->DisableSecondaryLoop ();
612 if ((QApplication*)interactorManager->GetMainInteractor())
613 ((QApplication*)interactorManager->GetMainInteractor())->exec();
624 interactorManager->EnableSecondaryLoop ();
634 void G4UIQt::Prompt (
638 if (!aPrompt)
return;
640 fCommandLabel->setText((
char*)aPrompt.
data());
645 void G4UIQt::SessionTerminate (
648 G4Qt* interactorManager = G4Qt::getInstance ();
649 fMainWindow->close();
650 ((QApplication*)interactorManager->GetMainInteractor())->exit();
663 void G4UIQt::PauseSessionStart (
669 if(aState==
"G4_pause> ") {
670 SecondaryLoop (
"Pause, type continue to exit this state");
673 if(aState==
"EndOfEvent") {
675 SecondaryLoop (
"End of event, type continue to exit this state");
685 void G4UIQt::SecondaryLoop (
689 if (!aPrompt)
return;
691 G4Qt* interactorManager = G4Qt::getInstance ();
695 while((eventTmp = interactorManager->GetEvent())!=NULL) {
696 interactorManager->DispatchEvent(eventTmp);
697 if(exitPause==
true)
break;
709 G4int G4UIQt::ReceiveG4cout (
713 if (!aString)
return 0;
718 newStr = QStringList(QString((
char*)aString.
data()).trimmed());
721 QStringList result = newStr.filter(fCoutFilter->text());
723 if (result.join(
"\n").isEmpty()) {
726 fCoutTBTextArea->append(result.join(
"\n"));
727 fCoutTBTextArea->repaint();
729 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
740 G4int G4UIQt::ReceiveG4cerr (
744 if (!aString)
return 0;
749 newStr = QStringList(QString((
char*)aString.
data()).trimmed());
752 QStringList result = newStr.filter(fCoutFilter->text());
755 if (QString(aString.
data()).trimmed() !=
"") {
756 QMessageBox::critical(fMainWindow,
"Error",aString.
data());
758 QColor previousColor = fCoutTBTextArea->textColor();
759 fCoutTBTextArea->setTextColor(
Qt::red);
760 fCoutTBTextArea->append(result.join(
"\n"));
761 fCoutTBTextArea->setTextColor(previousColor);
762 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
763 fCoutTBTextArea->repaint();
774 void G4UIQt::AddMenu (
779 if (aName == NULL)
return;
780 if (aLabel == NULL)
return;
782 QMenu *fileMenu =
new QMenu(aLabel);
783 fMainWindow->menuBar()->addMenu(fileMenu);
795 void G4UIQt::AddButton (
798 ,
const char* aCommand
801 if(aMenu==NULL)
return;
802 if(aLabel==NULL)
return;
803 if(aCommand==NULL)
return;
805 QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
807 if(parentTmp==NULL) {
808 G4cout <<
"Menu name " << aMenu<<
" does not exist, please define it before using it."<<
G4endl;
817 G4int cmdEndPos = cmd.find_first_of(
" \t");
818 if(cmdEndPos!=
G4int(std::string::npos)) {
819 cmd.erase(cmdEndPos);
822 if(treeTop->
FindPath(aCommand) == NULL) {
823 G4cout <<
"Warning: command '"<< aCommand <<
"' does not exist, please define it before using it."<<
G4endl;
826 QSignalMapper *signalMapper =
new QSignalMapper(
this);
827 QAction *action = parentTmp->addAction(aLabel, signalMapper, SLOT(map()));
829 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
830 signalMapper->setMapping(action, QString(aCommand));
839 void G4UIQt::AddIcon(
const char* aLabel,
const char* aIconFile,
const char* aCommand,
const char* aFileName){
840 if(aLabel==NULL)
return;
842 if ((aCommand==NULL) && (std::string(aIconFile) ==
"user_icon"))
return;
845 bool userToolBar =
false;
847 if (std::string(aIconFile) ==
"user_icon") {
849 pix = QPixmap(aFileName);
851 G4cout <<
"Warning: file '"<< aFileName <<
"' is incorrect or does not exist, this command will not be build"<<
G4endl;
855 }
else if (std::string(aIconFile) ==
"open") {
856 const char *
const xpm[]={
900 " {]^/((_({- %%%%%%%%%%% ",
901 " {(^_^^^^:<{{{{{{{{{{{{{[& ",
902 " {/_/(((((/]]]]]]]]]]]/]!# ",
903 " {/^(((((_^^^^^^^^^^^^^^:# ",
904 " {/^(((_^^____________^^}$ ",
905 " {/^(((((/////////////((!# ",
906 " {/^/^_:<|||||||||||||||@@****1 ",
907 " {/^/^(<[)||||||||||||||))!!}<; ",
908 " {/^_(:|234444444444444444432)1 ",
909 " {/_^/<)34444444444444444443}, ",
910 " {/^(2{:41111111111111111142|5 ",
911 " {3^3<:31111111111111111143}- ",
912 " {/^2<:31111111111111111441|' ",
913 " {_/<:41111111111111111143}, ",
914 " {(4<:31111111111111111144!# ",
915 " )4))44111111111111111144}, ",
916 " )2<:31111111111111111144{# ",
917 " @|:14444444444444444444}* ",
918 " ;@434444444444444444434<# ",
919 " ;[))))))))))))))))))))!~ ",
920 " ++++++++++++++++++++++;% ",
926 }
else if (std::string(aIconFile) ==
"save") {
927 const char *
const xpm[]={
955 " +++++++++++++++++++++++++ ",
956 " +@##+$%%%%%%%%%%%%%%%&*$%&+ ",
957 " +=-;@>,,''',,,,,,,',,)&!,)+ ",
958 " +;-~@>,,,,,,,,,,,,,,,>$!,)+ ",
959 " +=-~@>,,,,,{]]]]]^,,,>*&$&+ ",
960 " +=-~@>,,,,,'{^{^^{,,,>*#=#+ ",
961 " +=-~@>,,,,,,,,,,,,,,,>@~/=+ ",
962 " +=-~@>,,,{{{''''{',,,>@~-=+ ",
963 " +=-~@>,,'^]]]]]]({,,,>@~-=+ ",
964 " +=-~@>,,,{{{{{{{{{,,,>@~-=+ ",
965 " +=-~@>,,,,,'{^{{^{,,,>@~-=+ ",
966 " +=-~@>,,,,,]]]]]]],,,>@~-=+ ",
967 " +=-~*>,,,,,,,,,,,,,,,>@~-=+ ",
968 " +=-~@>,,,,,,,,,,,,,,,>@~-=+ ",
969 " +=-/=$%%%%%%%%%%%%%%%$=/-=+ ",
970 " +=---;###############;---=+ ",
971 " +=---////////////////----=+ ",
972 " +=----------------///----=+ ",
973 " +=---=@##############@#--=+ ",
974 " +=---@+++++++++++*%))_+~-=+ ",
975 " +=---#+++++++++++&:,,>@~-=+ ",
976 " +=---#+++++++++++$',,>@~-=+ ",
977 " +=---#+++++++++++&!,,>@~-=+ ",
978 " +=/--#+++++++++++&',,>@~-=+ ",
979 " @;--#+++++++++++$',,>@~-=+ ",
980 " @;;@+++++++++++*)!>%@=;#+ ",
981 " @++++++++++++++*&**++@++ ",
987 }
else if (std::string(aIconFile) ==
"move") {
988 const char *
const xpm[]={
1021 " ')&$$$$*@@ @@*$$$$&)' ",
1022 " ')&$$$$*@@ @@*$$$$&+' ",
1041 }
else if (std::string(aIconFile) ==
"rotate") {
1042 const char *
const xpm[]={
1078 " --------!*{{{*&, ",
1079 " -------=){*{{{>>{) ",
1080 " ,!-----= ){& ,&{{@",
1081 " ,*>!----= &>& )@",
1084 " @{* '! ,-!=~^,@ ",
1085 " @& == {/(----!^ ",
1088 " !-!!======!!(((---! ",
1089 " ='--------------! ",
1106 }
else if (std::string(aIconFile) ==
"pick") {
1107 const char *
const xpm[]={
1145 }
else if (std::string(aIconFile) ==
"zoom_in") {
1146 const char *
const xpm[]={
1168 " ++.%%%+&&&*%%.++ ",
1169 " .+#%%%%+&&&*%%.#+ ",
1170 " ++..%%%+&&&*%%%.++ ",
1171 " +#.+++++&&&*++++.+ ",
1172 " @.+&&&&&&&&&&&&&+@ ",
1173 " @#+&&&&&&&&&&&&&+@ ",
1174 " @.+&&&&&&&&&&&&&+. ",
1175 " +++@***+&&&****@+. ",
1176 " ....++++&&&*++++.. ",
1177 " ++.===+&&&*%=.++ ",
1178 " @..==+&&&*=..@#& ",
1179 " .@+#.+&&&@-+@@*@ ",
1180 " +++.++++++ *+@* ",
1193 }
else if (std::string(aIconFile) ==
"zoom_out") {
1194 const char *
const xpm[]={
1216 " ++.$$$$$$$$$$.++ ",
1217 " .+#$$$$$$$$$$$.#+ ",
1218 " ++..$$$$$$$$$$$.++ ",
1219 " +#.+++++++++++++.+ ",
1220 " @.+&&&&&&&&&&&&&+@ ",
1221 " @#+&&&&&&&&&&&&&+@ ",
1222 " @.+&&&&&&&&&&&&&+. ",
1223 " +++@***********@+. ",
1224 " ....++++++++++++.. ",
1225 " ++.===$$$$$$=.++ ",
1226 " @..===$$$$=..@#& ",
1227 " .@+#.$$$..-+@@*@ ",
1228 " +++#--.+++ *+@* ",
1241 }
else if (std::string(aIconFile) ==
"wireframe") {
1242 const char *
const xpm[]={
1271 " +&********&@-***; ",
1272 " +@@@&**&@@@@@@$ @*-&>&+ ",
1273 " +*****&+ %*@ ,**'# ",
1274 " @***)!~ @*{&*****+ ",
1275 " @*!]***&+ +-*^**'~!*@ ",
1276 " @*~ +@&**&@@@@@@&****&+ ~*@ ",
1277 " @*@ +&********&-*= @*@ ",
1278 " @*@ $%@-*-@$ @*@ @*@ ",
1279 " @*@ @*@ %*% @*@ ",
1280 " @*@ %*% %*% @*@ ",
1281 " @*@ %*% %*% @*@ ",
1282 " @*@ %*% %*% @*@ ",
1283 " @*@ %*% %*% @*@ ",
1284 " @*@ %*% %*% @*@ ",
1285 " @*@ @*@ %*% @*@ ",
1286 " @*@ =*-+ @*@ @*@ ",
1287 " @*@ $%@@&****&@-*-+ @*@ ",
1288 " @*@ $@&*****&@@&******&~~!*@ ",
1289 " @*{/***&@@%$ $@-*-&*****+ ",
1290 " @*)*)(-~ @*@ ~)**] ",
1291 " +*******&@@@@+ %*_+]**] ",
1292 " +@@@@@&******&@%+_*^**]# ",
1293 " $%@@@&****:**&+ ",
1302 }
else if (std::string(aIconFile) ==
"solid") {
1303 const char *
const xpm[]={
1341 " +-;>>>>>>>>>,')!~ ",
1342 " {]@@-;>>>>>>>>>>>>^/(_= ",
1343 " {:>>>>>>>>>>>>>>>>><//[)!= ",
1344 " ]>>>>>>>>>>>>>>>>>><////[)} ",
1345 " @>>>>>>>>>>>>>>>>>><//////| ",
1346 " @>>>>>>>>>>>>>>>>>><//////| ",
1347 " @>>>>>>>>>>>>>>>>>><//////| ",
1348 " @>>>>>>>>>>>>>>>>>><//////| ",
1349 " @>>>>>>>>>>>>>>>>>><//////| ",
1350 " @>>>>>>>>>>>>>>>>>><//////| ",
1351 " @>>>>>>>>>>>>>>>>>><//////| ",
1352 " @>>>>>>>>>>>>>>>>>><//////| ",
1353 " @>>>>>>>>>>>>>>>>>><//////| ",
1354 " @>>>>>>>>>>>>>>>>>><//////| ",
1355 " @>>>>>>>>>>>>>>>>>><//////| ",
1356 " @>>>>>>>>>>>>>>>>>><//////| ",
1357 " @>>>>>>>>>>>>>>>>>><//////| ",
1358 " @>>>>>>>>>>>>>>>>>><//////| ",
1359 " @>>>>>>>>>>>>>>>>>></////[1 ",
1360 " @>>>>>>>>>>>>>>>>>><////[*2 ",
1361 " {:>>>>>>>>>>>>>>>>><//[)12 ",
1362 " +@@@@@-;>>>>>>>>>><[)13 ",
1372 }
else if (std::string(aIconFile) ==
"hidden_line_removal") {
1373 const char *
const xpm[]={
1393 " +#$$$$$$$$#@&$$$* ",
1394 " =-@@#$$#@@@@@-= @$&#;>= ",
1395 " =$$$$$#+ -$@ *$$%+ ",
1396 " -$&@-= -$- #$$$= ",
1412 " -$&@@@-= -$- =>;, ",
1413 " =$$$$$$$#@@@-= -$'+#$$, ",
1414 " =-@@@@#$$$$$$#@-+'$)$$#+ ",
1415 " =-@@@#$$$$)$$#+ ",
1424 }
else if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
1425 const char *
const xpm[]={
1471 " ++@%####&*=-#+;>, ",
1472 " +++++@'=)))))))!)~+{]^++ ",
1473 " +$%&*=)!!!!!!!!!)~+/(]_+++ ",
1474 " +#-))!!!!!!!!!!!)~+/(::<[+ ",
1475 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1476 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1477 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1478 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1479 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1480 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1481 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1482 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1483 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1484 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1485 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1486 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1487 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1488 " +#)!!!!!!!!!!!!!!}+/:::|1+ ",
1489 " +$#}}~23!!!!!!!!)~+/(]45, ",
1490 " +++++++@#}}~23!!)~+678++ ",
1491 " ++++++@#~90+a++ ",
1501 }
else if (std::string(aIconFile) ==
"perspective") {
1502 const char *
const xpm[]={
1512 " ................ ",
1513 " ....+++++++++++++++. ",
1514 " ...++++..+.........+++. ",
1515 " ..++..............++..+. ",
1516 " .+++++++++++++++++.. .+. ",
1517 " .+...............+. .+. ",
1518 " .+. .+. .+. .+. ",
1519 " .+. .+. .+. .+. ",
1520 " .+. .+. .+. .+. ",
1521 " .+. .+. .+. .+. ",
1522 " .+. .+. .+. .+. ",
1523 " .+. .+. .+. .+. ",
1524 " .+. .+. .+. .+. ",
1525 " .+. .+. .+. .+. ",
1526 " .+. .+......+....+. ",
1527 " .+. ..++++++.+.++++. ",
1528 " .+. .++.......+...+.. ",
1529 " .+. .++. .+..++. ",
1530 " .+. ..+.. .+..+. ",
1533 " .+++.............++. ",
1534 " .+++++++++++++++++. ",
1535 " ................... ",
1541 }
else if (std::string(aIconFile) ==
"ortho") {
1542 const char *
const xpm[]={
1550 " ................... ",
1551 " ..@@@@@@@@@@@@@@@@@. ",
1552 " ..@@@.............@@@. ",
1553 " ..@@.@. ..@..@. ",
1554 " ..@@ ..@. .@@...@. ",
1555 " ..@@..............@@.. .@. ",
1556 " .@@@@@@@@@@@@@@@@@.. .@. ",
1557 " .@...............@. .@. ",
1558 " .@. .@. .@. .@. ",
1559 " .@. .@. .@. .@. ",
1560 " .@. .@. .@. .@. ",
1561 " .@. .@. .@. .@. ",
1562 " .@. .@. .@. .@. ",
1563 " .@. .@. .@. .@. ",
1564 " .@. .@. .@. .@. ",
1565 " .@. .@. .@. .@. ",
1566 " .@. .@. .@. .@. ",
1567 " .@. .@. .@. .@. ",
1568 " .@. .@........@......@. ",
1569 " .@. .@@@@@@@@@.@.@@@@@@. ",
1570 " .@. .@@+........@....@@.. ",
1571 " .@...@. .@...@... ",
1573 " .@@@.............@@@.. ",
1574 " .@@@@@@@@@@@@@@@@@... ",
1575 " ................... ",
1582 G4cout <<
"Parameter"<< aIconFile <<
" not defined"<<
G4endl;
1585 QToolBar *currentToolbar = NULL;
1587 if (fToolbarUser == NULL) {
1588 fToolbarUser =
new QToolBar(fMainWindow);
1589 fToolbarUser->setIconSize (QSize(20,20));
1590 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
1592 currentToolbar = fToolbarUser;
1594 if (fToolbarApp == NULL) {
1595 fToolbarApp =
new QToolBar(fMainWindow);
1596 fToolbarApp->setIconSize (QSize(20,20));
1597 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
1599 currentToolbar = fToolbarApp;
1602 QSignalMapper *signalMapper =
new QSignalMapper(
this);
1603 QAction *action = currentToolbar->addAction(pix,aLabel, signalMapper, SLOT(map()));
1607 if (std::string(aIconFile) ==
"open") {
1608 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(OpenIconCallback(
const QString&)));
1609 signalMapper->setMapping(action, QString(aCommand));
1612 }
else if (std::string(aIconFile) ==
"save") {
1613 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(SaveIconCallback(
const QString&)));
1614 signalMapper->setMapping(action, QString(aCommand));
1617 }
else if ((std::string(aIconFile) ==
"move") ||
1618 (std::string(aIconFile) ==
"rotate") ||
1619 (std::string(aIconFile) ==
"pick") ||
1620 (std::string(aIconFile) ==
"zoom_out") ||
1621 (std::string(aIconFile) ==
"zoom_in")) {
1622 action->setCheckable(
TRUE);
1623 action->setChecked(
TRUE);
1624 action->setData(aIconFile);
1626 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeCursorStyle(
const QString&)));
1627 signalMapper->setMapping(action, QString(aIconFile));
1629 if (std::string(aIconFile) ==
"move") {
1630 SetIconMoveSelected();
1632 if (std::string(aIconFile) ==
"rotate") {
1633 SetIconRotateSelected();
1635 if (std::string(aIconFile) ==
"pick") {
1636 SetIconPickSelected();
1638 if (std::string(aIconFile) ==
"zoom_in") {
1639 SetIconZoomInSelected();
1641 if (std::string(aIconFile) ==
"zoom_out") {
1642 SetIconZoomOutSelected();
1646 }
else if ((std::string(aIconFile) ==
"hidden_line_removal") ||
1647 (std::string(aIconFile) ==
"hidden_line_and_surface_removal") ||
1648 (std::string(aIconFile) ==
"solid") ||
1649 (std::string(aIconFile) ==
"wireframe")) {
1650 action->setCheckable(
TRUE);
1651 action->setChecked(
TRUE);
1652 action->setData(aIconFile);
1653 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeSurfaceStyle(
const QString&)));
1654 signalMapper->setMapping(action, QString(aIconFile));
1656 if (std::string(aIconFile) ==
"hidden_line_removal") {
1657 SetIconHLRSelected();
1659 if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
1660 SetIconHLHSRSelected();
1662 if (std::string(aIconFile) ==
"solid") {
1663 SetIconSolidSelected();
1665 if (std::string(aIconFile) ==
"wireframe") {
1666 SetIconWireframeSelected();
1670 }
else if ((std::string(aIconFile) ==
"perspective") ||
1671 (std::string(aIconFile) ==
"ortho")) {
1672 action->setCheckable(
TRUE);
1673 action->setChecked(
TRUE);
1674 action->setData(aIconFile);
1675 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangePerspectiveOrtho(
const QString&)));
1676 signalMapper->setMapping(action, QString(aIconFile));
1678 if (std::string(aIconFile) ==
"perspective") {
1679 SetIconPerspectiveSelected();
1681 if (std::string(aIconFile) ==
"ortho") {
1682 SetIconOrthoSelected();
1689 if(UI==NULL)
return;
1692 if(treeTop->
FindPath(aCommand) == NULL) {
1693 G4cout <<
"Warning: command '"<< aCommand <<
"' does not exist, please define it before using it."<<
G4endl;
1696 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
1697 signalMapper->setMapping(action, QString(aCommand));
1703 void G4UIQt::ActivateCommand(
1707 if (!fHelpTreeWidget) {
1711 size_t i = newCommand.
index(
" ");
1713 if( i != std::string::npos )
1715 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
1717 targetCom = ModifyToFullPathCommand( newValue );
1719 #ifdef G4DEBUG_INTERFACES_BASIC
1720 printf(
"G4UIQt::ActivateCommand found : %s \n",targetCom.
data());
1722 if (targetCom !=
"") {
1723 OpenHelpTreeOnCommand(targetCom.
data());
1726 fUITabWidget->setCurrentWidget(fHelpTBWidget);
1737 void G4UIQt::InitHelpTreeAndVisParametersWidget()
1740 if (! fHelpTreeWidget ) {
1741 fHelpTreeWidget =
new QTreeWidget();
1745 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
1747 labels << QString(
"Command");
1748 fHelpTreeWidget->setHeaderLabels(labels);
1751 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),
this, SLOT(HelpTreeClicCallback()));
1752 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,
int)),
this, SLOT(HelpTreeDoubleClicCallback()));
1761 void G4UIQt::FillHelpTree()
1763 if (! fHelpTreeWidget ) {
1764 InitHelpTreeAndVisParametersWidget();
1767 QString searchText = fHelpLine->text();
1769 if (searchText ==
"") {
1777 #if QT_VERSION < 0x040200
1780 fHelpArea->setText(
"");
1785 #if QT_VERSION < 0x040200
1788 fHelpLine->setText(
"");
1793 if(UI==NULL)
return;
1797 QTreeWidgetItem * newItem = NULL;
1798 QString commandText =
"";
1799 for (
int a=0;
a<treeSize;
a++) {
1806 for (
int b=0;
b<fHelpTreeWidget->topLevelItemCount();
b++) {
1808 newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(
b),commandText);
1811 if (newItem == NULL) {
1813 newItem =
new QTreeWidgetItem(fHelpTreeWidget);
1814 newItem->setText(0,GetShortCommandPath(commandText));
1818 CreateHelpTree(newItem,treeTop->
GetTree(
a+1));
1829 void G4UIQt::CreateHelpTree(
1830 QTreeWidgetItem *aParent
1834 if (aParent == NULL)
return;
1835 if (aCommandTree == NULL)
return;
1839 QTreeWidgetItem * newItem;
1841 QString commandText =
"";
1848 newItem = FindTreeItem(aParent,commandText);
1849 if (newItem == NULL) {
1850 newItem =
new QTreeWidgetItem(aParent);
1851 newItem->setText(0,GetShortCommandPath(commandText));
1853 CreateHelpTree(newItem,aCommandTree->
GetTree(
a+1));
1860 QStringList stringList;
1864 newItem = FindTreeItem(aParent,commandText);
1865 if (newItem == NULL) {
1866 newItem =
new QTreeWidgetItem(aParent);
1867 newItem->setText(0,GetShortCommandPath(commandText));
1869 #if QT_VERSION < 0x040202
1870 fHelpTreeWidget->setItemExpanded(newItem,
false);
1872 newItem->setExpanded(
false);
1886 bool G4UIQt::CreateVisCommandGroupAndToolBox(
1893 QString commandText = QString((
char*)(aCommand->
GetCommandPath().
data())).section(
"/",-aDepthLevel);
1895 if (commandText == NULL) {
1901 QWidget* newParentWidget = NULL;
1903 QString commandSection = commandText.left(commandText.indexOf(
"/"));
1905 if (aDepthLevel == 1) {
1906 QToolBox* currentParent =
dynamic_cast<QToolBox*
>(aParent);
1907 if (currentParent != 0){
1910 for (
int a=0;
a<currentParent->count();
a++) {
1911 if (currentParent->itemText(
a) == commandSection) {
1913 newParentWidget = currentParent->widget(
a);
1919 newParentWidget =
new QGroupBox();
1921 newParentWidget->setLayout(
new QVBoxLayout());
1922 if (currentParent != 0){
1923 currentParent->addItem(newParentWidget,commandSection);
1925 if (!aParent->layout()) {
1926 aParent->setLayout(
new QVBoxLayout());
1928 aParent->layout()->addWidget(newParentWidget);
1931 if (commandText.indexOf(
"/") == -1) {
1936 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
1939 newParentWidget->setToolTip(guidance);
1942 QScrollArea* sc =
dynamic_cast<QScrollArea*
>(newParentWidget->parent()->parent());
1944 sc->ensureWidgetVisible(newParentWidget);
1952 QGroupBox* currentParent =
dynamic_cast<QGroupBox*
>(aParent);
1953 if (currentParent != 0){
1957 if (aDepthLevel == 2){
1958 QToolBox* parentToolBox =
dynamic_cast<QToolBox*
>(currentParent->parent()->parent()->parent());
1959 if (parentToolBox != 0) {
1963 for (
int a=0;
a<aParent->layout()->count();
a++) {
1964 QGroupBox* gb =
dynamic_cast<QGroupBox*
>(aParent->layout()->itemAt(
a)->widget());
1966 if (gb->title() == commandSection) {
1968 newParentWidget = gb;
1976 newParentWidget =
new QGroupBox(commandSection);
1977 newParentWidget->setLayout(
new QVBoxLayout());
1978 if (!aParent->layout()) {
1979 aParent->setLayout(
new QVBoxLayout());
1981 aParent->layout()->addWidget(newParentWidget);
1987 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
1990 newParentWidget->setToolTip(guidance);
1995 if (commandText.indexOf(
"/") == -1) {
1996 if (CreateCommandWidget(aCommand, newParentWidget,isDialog)) {
2000 CreateVisCommandGroupAndToolBox(aCommand,newParentWidget, aDepthLevel-1,isDialog);
2013 bool G4UIQt::CreateCommandWidget(
G4UIcommand* aCommand, QWidget* aParent,
bool isDialog) {
2015 if (aCommand == NULL) {
2022 if( n_parameterEntry > 0 ) {
2026 QWidget* paramWidget =
new QWidget();
2027 QGridLayout* gridLayout =
new QGridLayout(paramWidget);
2030 unsigned int nbColorParameter = 0;
2031 bool isStillColorParameter =
false;
2032 bool isColorDialogAdded =
false;
2033 QLabel* redLabel = NULL;
2034 QLabel* greenLabel = NULL;
2035 QString redDefaultStr =
"";
2036 QString greenDefaultStr =
"";
2037 QString blueDefaultStr =
"";
2038 QWidget* redInput = NULL;
2039 QWidget* greenInput = NULL;
2041 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2046 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")){
2047 nbColorParameter ++;
2048 isStillColorParameter =
true;
2049 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2050 nbColorParameter ++;
2051 }
else if ((label->text() ==
"blue") && isStillColorParameter) {
2052 nbColorParameter ++;
2053 }
else if (!isColorDialogAdded) {
2056 if (nbColorParameter == 1) {
2057 gridLayout->addWidget(redLabel,i_thParameter-1,0);
2058 gridLayout->addWidget(redInput,i_thParameter-1,1);
2059 }
else if (nbColorParameter == 2) {
2060 gridLayout->addWidget(redLabel,i_thParameter-2,0);
2061 gridLayout->addWidget(redInput,i_thParameter-2,1);
2062 gridLayout->addWidget(greenLabel,i_thParameter-1,0);
2063 gridLayout->addWidget(greenInput,i_thParameter-1,1);
2065 nbColorParameter = 0;
2068 QWidget* input = NULL;
2070 input =
new QLineEdit();
2072 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2074 if (((label->text() ==
"red") || (label->text() ==
"red_or_string")) && isStillColorParameter) {
2076 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2078 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2083 input =
new QWidget();
2084 QHBoxLayout* layout =
new QHBoxLayout(input);
2086 QButtonGroup* buttons =
new QButtonGroup();
2087 QRadioButton* radioOff =
new QRadioButton(
"0");
2088 QRadioButton* radioOn =
new QRadioButton(
"1");
2089 buttons->addButton(radioOn);
2090 buttons->addButton(radioOff);
2091 layout->addWidget(radioOn);
2092 layout->addWidget(radioOff);
2096 if (defaultValue ==
"0") {
2097 radioOff->setChecked(
true);
2098 }
else if (defaultValue ==
"1") {
2099 radioOn->setChecked(
true);
2102 input =
new QComboBox();
2104 QStringList list = candidates.split (
" ");
2108 for (
int a=0;
a<list.size();
a++) {
2109 dynamic_cast<QComboBox*
>(input)->addItem(list.at(
a));
2110 if (list.at(
a) == defaultValue) {
2111 dynamic_cast<QComboBox*
>(input)->setCurrentIndex(
a);
2116 input =
new QLineEdit();
2118 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2121 input =
new QWidget();
2122 QHBoxLayout* layout =
new QHBoxLayout(input);
2124 QButtonGroup* buttons =
new QButtonGroup();
2125 QRadioButton* radioOff =
new QRadioButton(
"off");
2126 QRadioButton* radioOn =
new QRadioButton(
"on");
2127 buttons->addButton(radioOn);
2128 buttons->addButton(radioOff);
2129 layout->addWidget(radioOn);
2130 layout->addWidget(radioOff);
2134 if (defaultValue ==
"off") {
2135 radioOff->setChecked(
true);
2136 }
else if (defaultValue ==
"on") {
2137 radioOn->setChecked(
true);
2141 input =
new QLineEdit();
2142 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2149 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2151 txt +=
" Omittable : True\n";
2153 txt +=
" Omittable : False\n";
2156 txt +=
" Default value : taken from the current value\n";
2167 if (isStillColorParameter && (nbColorParameter != 0)) {
2168 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")) {
2171 }
else if (label->text() ==
"green") {
2174 }
else if (label->text() ==
"blue") {
2180 if ((redDefaultStr !=
"") && (redDefaultStr !=
"") && (redDefaultStr !=
"")) {
2181 qc.setRgbF(redDefaultStr.toDouble(),
2182 greenDefaultStr.toDouble(),
2183 blueDefaultStr.toDouble());
2185 QPixmap pixmap = QPixmap(QSize(16, 16));
2187 QPainter painter(&pixmap);
2188 painter.setPen(Qt::black);
2189 painter.drawRect(0,0,15,15);
2191 input =
new QPushButton(
"Change color");
2192 dynamic_cast<QPushButton*
>(input)->setIcon(pixmap);
2193 dynamic_cast<QPushButton*
>(input)->setAccessibleName(redDefaultStr+
" "+greenDefaultStr+
" "+blueDefaultStr);
2194 label =
new QLabel(
"Choose color");
2198 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2199 input->setToolTip(
"Select the current color");
2200 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2203 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2204 signalMapper->setMapping(input,input);
2205 connect(input, SIGNAL(clicked()), signalMapper, SLOT(map()));
2206 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(ChangeColorCallback(QWidget*)));
2208 isColorDialogAdded =
true;
2209 isStillColorParameter =
false;
2212 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2213 input->setToolTip(txt);
2214 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2220 gridLayout->addWidget(name,n_parameterEntry-nbColorParameter,0);
2222 QPushButton* applyButton =
new QPushButton(
"Apply");
2225 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,1);
2227 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2228 signalMapper->setMapping(applyButton, paramWidget);
2229 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2230 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2234 applyButton->setAutoDefault(
TRUE );
2235 applyButton->setDefault(
TRUE );
2236 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,0);
2238 QPushButton* cancelButton =
new QPushButton( tr(
"&Cancel" ));
2239 cancelButton->setAutoDefault(
TRUE );
2240 gridLayout->addWidget(cancelButton,n_parameterEntry-nbColorParameter,1);
2242 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2243 signalMapper->setMapping(applyButton, paramWidget);
2244 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2245 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2247 QWidget * parentCheck = aParent;
2248 QDialog* parentDialog = NULL;
2250 while ((parentCheck->parentWidget()) != NULL) {
2251 parentCheck = parentCheck->parentWidget();
2252 parentDialog =
dynamic_cast<QDialog*
>(parentCheck);
2254 connect( applyButton, SIGNAL( clicked() ), parentDialog, SLOT( accept() ) );
2255 connect( cancelButton, SIGNAL( clicked() ), parentDialog, SLOT( reject() ) );
2264 if (!aParent->layout()) {
2265 aParent->setLayout(
new QVBoxLayout());
2267 aParent->layout()->addWidget(paramWidget);
2278 QTreeWidgetItem* G4UIQt::FindTreeItem(
2279 QTreeWidgetItem *aParent
2280 ,
const QString& aCommand
2283 if (aParent == NULL)
return NULL;
2286 QString myCommand = aCommand;
2288 if (myCommand.lastIndexOf(
"/") == (myCommand.size()-1)) {
2289 myCommand = myCommand.left(myCommand.size()-1);
2292 if (GetLongCommandPath(aParent) == myCommand)
2295 QTreeWidgetItem *
tmp = NULL;
2296 for (
int a=0;
a<aParent->childCount();
a++) {
2298 tmp = FindTreeItem(aParent->child(
a),myCommand);
2312 QString G4UIQt::GetCommandList (
2318 if (aCommand == NULL)
2326 if ((commandPath ==
"") &&
2327 (rangeString ==
"") &&
2328 (n_guidanceEntry == 0) &&
2329 (n_parameterEntry == 0)) {
2333 if((commandPath.length()-1)!=
'/') {
2334 txt +=
"Command " + QString((
char*)(commandPath).
data()) +
"\n";
2336 txt +=
"Guidance :\n";
2338 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2341 if( ! rangeString.
isNull() ) {
2342 txt +=
" Range of parameters : " + QString((
char*)(rangeString).
data()) +
"\n";
2344 if( n_parameterEntry > 0 ) {
2349 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2354 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2356 txt +=
" Omittable : True\n";
2358 txt +=
" Omittable : False\n";
2361 txt +=
" Default value : taken from the current value\n";
2382 G4bool G4UIQt::IsGUICommand(
2386 if (aCommand == NULL)
2391 if( n_parameterEntry > 0 ) {
2396 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2418 G4bool G4UIQt::GetHelpChoice(
2422 #ifdef G4DEBUG_INTERFACES_BASIC
2423 printf(
"G4UIQt::GetHelpChoice SHOULD NEVER GO HERE");
2436 bool G4UIQt::eventFilter(
2441 bool moveCommandCursor =
false;
2442 if (aObj == NULL)
return false;
2443 if (aEvent == NULL)
return false;
2445 if (aObj == fHistoryTBTableList) {
2446 if (aEvent->type() == QEvent::KeyPress) {
2447 fCommandArea->setFocus();
2450 if (aObj == fCommandArea) {
2451 if (aEvent->type() == QEvent::KeyPress) {
2452 QKeyEvent *e =
static_cast<QKeyEvent*
>(aEvent);
2453 if ((e->key() == (Qt::Key_Down)) ||
2454 (e->key() == (Qt::Key_PageDown)) ||
2455 (e->key() == (Qt::Key_Up)) ||
2456 (e->key() == (Qt::Key_PageUp))) {
2457 int selection = fHistoryTBTableList->currentRow();
2458 if (fHistoryTBTableList->count()) {
2459 if (selection == -1) {
2460 selection = fHistoryTBTableList->count()-1;
2462 if (e->key() == (Qt::Key_Down)) {
2463 if (selection <(fHistoryTBTableList->count()-1))
2465 }
else if (e->key() == (Qt::Key_PageDown)) {
2466 selection = fHistoryTBTableList->count()-1;
2467 }
else if (e->key() == (Qt::Key_Up)) {
2470 }
else if (e->key() == (Qt::Key_PageUp)) {
2474 fHistoryTBTableList->clearSelection();
2475 #if QT_VERSION < 0x040202
2476 fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),
true);
2478 fHistoryTBTableList->item(selection)->setSelected(
true);
2480 fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
2482 moveCommandCursor =
true;
2483 }
else if (e->key() == (Qt::Key_Tab)) {
2484 G4String ss = Complete(fCommandArea->text().toStdString().c_str());
2485 fCommandArea->setText((
char*)(ss.
data()));
2491 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
2492 fCommandArea->home(
false);
2494 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
2495 fCommandArea->end(
false);
2502 if (moveCommandCursor ==
true) {
2503 #ifdef G4DEBUG_INTERFACES_BASIC
2504 printf(
"G4UIQt::eventFilter setCursor Position\n");
2506 fCommandArea->setCursorPosition ( fCommandArea->text().length() );
2507 fCommandArea->setCursorPosition (4);
2510 res = QObject::eventFilter(aObj, aEvent);
2526 void G4UIQt::ShowHelpCallback (
2535 void G4UIQt::ClearButtonCallback (
2538 fCoutTBTextArea->clear();
2544 void G4UIQt::ExitSession (
2550 void G4UIQt::ExitHelp(
2558 void G4UIQt::CommandEnteredCallback (
2561 G4String command (fCommandArea->text().toStdString().c_str());
2562 if (fCommandArea->text().trimmed() !=
"") {
2563 fHistoryTBTableList->addItem(fCommandArea->text());
2564 fHistoryTBTableList->clearSelection();
2565 fHistoryTBTableList->setCurrentItem(NULL);
2566 fCommandArea->setText(
"");
2568 G4Qt* interactorManager = G4Qt::getInstance ();
2569 if (interactorManager) {
2570 interactorManager->FlushAndWaitExecution();
2572 if (command(0,4) !=
"help") {
2573 ApplyShellCommand (command,exitSession,exitPause);
2575 ActivateCommand(command);
2580 if(exitSession==
true)
2588 void G4UIQt::VisParameterCallback(QWidget* widget){
2589 if (widget == NULL) {
2594 QGridLayout* grid =
dynamic_cast<QGridLayout*
>(widget->layout());
2599 #if QT_VERSION < 0x040400
2600 QWidget* name = grid->itemAt(grid->columnCount()*(grid->rowCount()-2))->widget();
2602 QWidget* name = grid->itemAtPosition(grid->rowCount()-1,0)->widget();
2604 if (widget == NULL) {
2607 if (dynamic_cast<QLabel*>(name) == 0) {
2610 command += (
dynamic_cast<QLabel*
>(
name))->text()+
" ";
2612 for (
int a=0;
a<grid->rowCount()-1;
a++) {
2613 #if QT_VERSION < 0x040400
2614 QWidget* widgetTmp = grid->itemAt(
a*grid->columnCount()+1)->widget();
2616 QWidget* widgetTmp = grid->itemAtPosition(
a,1)->widget();
2620 if (widgetTmp != NULL) {
2622 if (dynamic_cast<QLineEdit*>(widgetTmp) != 0) {
2623 command += (
dynamic_cast<QLineEdit*
>(widgetTmp))->text()+
" ";
2625 }
else if (dynamic_cast<QComboBox*>(widgetTmp) != 0){
2626 command += (
dynamic_cast<QComboBox*
>(widgetTmp))->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex())+
" ";
2629 }
else if (dynamic_cast<QPushButton*>(widgetTmp) != 0){
2630 command += widgetTmp->accessibleName()+
" ";
2633 }
else if (dynamic_cast<QWidget*>(widgetTmp) != 0){
2634 if (widgetTmp->layout()->count() > 0){
2635 if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != 0) {
2636 QAbstractButton * checked = (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton();
2638 command += (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton()->text()+
" ";
2646 if (command !=
"") {
2660 void G4UIQt::ButtonCallback (
2661 const QString& aCommand
2668 if(UI==NULL)
return;
2675 if (IsGUICommand(command)) {
2676 QDialog* menuParameterDialog =
new QDialog();
2678 if (CreateVisCommandGroupAndToolBox(command,menuParameterDialog,1,
true)) {
2679 menuParameterDialog->setWindowTitle (aCommand);
2680 menuParameterDialog->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
2683 menuParameterDialog->exec();
2689 ApplyShellCommand(ss,exitSession,exitPause);
2694 if(exitSession==
true)
2702 void G4UIQt::HelpTreeClicCallback (
2705 QTreeWidgetItem* item = NULL;
2706 if (!fHelpTreeWidget)
2712 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
2715 item = list.first();
2720 if(UI==NULL)
return;
2723 std::string itemText = GetLongCommandPath(item).toStdString();
2728 #if QT_VERSION < 0x040200
2730 fHelpArea->append(GetCommandList(command));
2732 fHelpArea->setText(GetCommandList(command));
2739 #if QT_VERSION < 0x040200
2751 void G4UIQt::HelpTreeDoubleClicCallback (
2754 HelpTreeClicCallback();
2756 QTreeWidgetItem* item = NULL;
2757 if (!fHelpTreeWidget)
2763 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
2766 item = list.first();
2770 fCommandArea->clear();
2771 fCommandArea->setText(GetLongCommandPath(item));
2778 void G4UIQt::CommandHistoryCallback(
2781 QListWidgetItem* item = NULL;
2782 if (!fHistoryTBTableList)
2786 QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
2789 item = list.first();
2792 fCommandArea->setText(item->text());
2793 #ifdef G4DEBUG_INTERFACES_BASIC
2794 printf(
"G4UIQt::CommandHistoryCallback change text\n");
2799 void G4UIQt::CoutFilterCallback(
2800 const QString & text) {
2802 QStringList result = fG4cout.filter(text);
2803 fCoutTBTextArea->setPlainText(result.join(
"\n"));
2805 fCoutTBTextArea->repaint();
2806 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
2814 void G4UIQt::LookForHelpStringCallback(
2817 QString searchText = fHelpLine->text();
2819 #if QT_VERSION < 0x040200
2822 fHelpArea->setText(
"");
2824 if (searchText ==
"") {
2826 fHelpTreeWidget->clear();
2832 OpenHelpTreeOnCommand(searchText);
2837 void G4UIQt::OpenHelpTreeOnCommand(
2838 const QString & searchText
2843 if(UI==NULL)
return;
2849 fHelpTreeWidget->clear();
2855 QMap<int,QString> commandResultMap;
2856 QMap<int,QString> commandChildResultMap;
2858 for (
int a=0;
a<treeSize;
a++) {
2860 tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
2865 commandChildResultMap = LookForHelpStringInChildTree(treeTop->
GetTree(
a+1),searchText);
2867 if (!commandChildResultMap.empty()) {
2868 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
2869 while (i != commandChildResultMap.constEnd()) {
2870 commandResultMap.insertMulti(i.key(),i.value());
2873 commandChildResultMap.clear();
2878 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2879 fHelpTreeWidget->setColumnCount(2);
2881 labels << QString(
"Command") << QString(
"Match");
2882 fHelpTreeWidget->setHeaderLabels(labels);
2884 if (commandResultMap.empty()) {
2885 #if QT_VERSION < 0x040200
2887 fHelpArea->append(
"No match found");
2889 fHelpArea->setText(
"No match found");
2894 QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
2897 float multValue = 10.0/(float)(i.key());
2898 QString progressChar =
"|";
2899 QString progressStr =
"|";
2901 QTreeWidgetItem * newItem;
2904 if (i == commandResultMap.constBegin()) {
2907 for(
int a=0;
a<
int(i.key()*multValue);
a++) {
2908 progressStr += progressChar;
2910 newItem =
new QTreeWidgetItem(fHelpTreeWidget);
2911 QString commandStr = i.value().trimmed();
2913 if (commandStr.indexOf(
"/") == 0) {
2914 commandStr = commandStr.right(commandStr.size()-1);
2917 newItem->setText(0,commandStr);
2918 newItem->setText(1,progressStr);
2920 #if QT_VERSION < 0x040200
2922 newItem->setForeground ( 1, QBrush(
Qt::blue) );
2927 fHelpTreeWidget->resizeColumnToContents (0);
2928 fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
2935 QMap<int,QString> G4UIQt::LookForHelpStringInChildTree(
2937 ,
const QString & text
2940 QMap<int,QString> commandResultMap;
2941 if (aCommandTree == NULL)
return commandResultMap;
2946 QMap<int,QString> commandChildResultMap;
2950 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
2955 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->
GetTree(
a+1),text);
2957 if (!commandChildResultMap.empty()) {
2959 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
2960 while (i != commandChildResultMap.constEnd()) {
2961 commandResultMap.insertMulti(i.key(),i.value());
2964 commandChildResultMap.clear();
2971 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
2977 return commandResultMap;
2981 QString G4UIQt::GetShortCommandPath(
2985 if (commandPath.indexOf(
"/") == 0) {
2986 commandPath = commandPath.right(commandPath.size()-1);
2989 commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf(
"/",-2)-1);
2991 if (commandPath.lastIndexOf(
"/") == (commandPath.size()-1)) {
2992 commandPath = commandPath.left(commandPath.size()-1);
2999 QString G4UIQt::GetLongCommandPath(
3000 QTreeWidgetItem* item
3003 if (item == NULL)
return "";
3006 QString itemText =
"";
3007 itemText = item->text(0);
3009 while (item->parent() != NULL) {
3010 itemText = item->parent()->text(0)+
"/"+itemText;
3011 item = item->parent();
3013 itemText =
"/"+itemText;
3019 void G4UIQt::ChangeColorCallback(QWidget* widget) {
3020 if (widget == NULL) {
3024 QPushButton* button =
dynamic_cast<QPushButton*
>(widget);
3028 QString
value = button->accessibleName();
3031 old.setRgbF(value.section(
" ",0,1).toDouble(),
3032 value.section(
" ",1,2).toDouble(),
3033 value.section(
" ",2,3).toDouble());
3034 #if QT_VERSION < 0x040500
3036 QColor color = QColor(QColorDialog::getRgba (old.rgba(),&
a,fUITabWidget));
3038 QColor color = QColorDialog::getColor(old,
3041 QColorDialog::ShowAlphaChannel);
3045 if (color.isValid()) {
3047 QPixmap pixmap = QPixmap(QSize(16, 16));
3048 pixmap.fill (color);
3049 QPainter painter(&pixmap);
3050 painter.setPen(Qt::black);
3051 painter.drawRect(0,0,15,15);
3053 button->setAccessibleName(QString::number(color.redF())+
" "+
3054 QString::number(color.greenF())+
" "+
3055 QString::number(color.blueF())+
" "
3057 button->setIcon(pixmap);
3064 void G4UIQt::ChangeCursorStyle(
const QString& action) {
3068 fMoveSelected =
true;
3069 fPickSelected =
true;
3070 fRotateSelected =
true;
3071 fZoomInSelected =
true;
3072 fZoomOutSelected =
true;
3074 if (fToolbarApp == NULL)
return;
3075 QList<QAction *> list = fToolbarApp->actions ();
3076 for (
int i = 0; i < list.size(); ++i) {
3077 if (list.at(i)->data().toString () == action) {
3078 list.at(i)->setChecked(
TRUE);
3079 }
else if (list.at(i)->data().toString () ==
"move") {
3080 fMoveSelected =
false;
3081 list.at(i)->setChecked(
FALSE);
3082 }
else if (list.at(i)->data().toString () ==
"pick") {
3083 fPickSelected =
false;
3084 list.at(i)->setChecked(
FALSE);
3085 }
else if (list.at(i)->data().toString () ==
"rotate") {
3086 fRotateSelected =
false;
3087 list.at(i)->setChecked(
FALSE);
3088 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3089 fZoomInSelected =
false;
3090 list.at(i)->setChecked(
FALSE);
3091 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3092 fZoomOutSelected =
false;
3093 list.at(i)->setChecked(
FALSE);
3106 void G4UIQt::ChangeSurfaceStyle(
const QString& action) {
3110 if (fToolbarApp == NULL)
return;
3111 QList<QAction *> list = fToolbarApp->actions ();
3112 for (
int i = 0; i < list.size(); ++i) {
3113 if (list.at(i)->data().toString () == action) {
3114 list.at(i)->setChecked(
TRUE);
3115 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3116 list.at(i)->setChecked(
FALSE);
3117 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3118 list.at(i)->setChecked(
FALSE);
3119 }
else if (list.at(i)->data().toString () ==
"solid") {
3120 list.at(i)->setChecked(
FALSE);
3121 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3122 list.at(i)->setChecked(
FALSE);
3127 if (action ==
"hidden_line_removal") {
3131 }
else if (action ==
"hidden_line_and_surface_removal") {
3135 }
else if (action ==
"solid") {
3139 }
else if (action ==
"wireframe") {
3146 void G4UIQt::OpenIconCallback(
const QString& aCommand) {
3148 QString nomFich = QFileDialog::getOpenFileName(fMainWindow,
"Load",
"vis",
"Macro files (*.mac)");
3149 if (nomFich !=
"") {
3155 void G4UIQt::SaveIconCallback(
const QString& aCommand) {
3157 QString nomFich = QFileDialog::getSaveFileName(fMainWindow,
"Save",
"viewerState",
"Macro files (*.mac)");
3158 if (nomFich !=
"") {
3165 void G4UIQt::ChangePerspectiveOrtho(
const QString& action) {
3169 if (fToolbarApp == NULL)
return;
3170 QList<QAction *> list = fToolbarApp->actions ();
3171 QString checked =
"";
3172 for (
int i = 0; i < list.size(); ++i) {
3173 if (list.at(i)->data().toString () == action) {
3174 list.at(i)->setChecked(
TRUE);
3175 checked = list.at(i)->data().toString ();
3176 }
else if (list.at(i)->data().toString () ==
"persepective") {
3177 list.at(i)->setChecked(
FALSE);
3178 }
else if (list.at(i)->data().toString () ==
"ortho") {
3179 list.at(i)->setChecked(
FALSE);
3183 if ((action ==
"ortho") && (checked ==
"ortho")) {
3185 }
else if ((action ==
"perspective") && (checked ==
"perspective")) {
3192 void G4UIQt::SetIconMoveSelected() {
3194 fMoveSelected =
true;
3195 fRotateSelected =
false;
3196 fPickSelected =
false;
3197 fZoomInSelected =
false;
3198 fZoomOutSelected =
false;
3200 if (fToolbarApp == NULL)
return;
3201 QList<QAction *> list = fToolbarApp->actions ();
3202 for (
int i = 0; i < list.size(); ++i) {
3203 if (list.at(i)->data().toString () ==
"move") {
3204 list.at(i)->setChecked(
TRUE);
3205 }
else if (list.at(i)->data().toString () ==
"rotate") {
3206 list.at(i)->setChecked(
FALSE);
3207 }
else if (list.at(i)->data().toString () ==
"pick") {
3208 list.at(i)->setChecked(
FALSE);
3209 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3210 list.at(i)->setChecked(
FALSE);
3211 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3212 list.at(i)->setChecked(
FALSE);
3218 void G4UIQt::SetIconRotateSelected() {
3220 fRotateSelected =
true;
3221 fMoveSelected =
false;
3222 fPickSelected =
false;
3223 fZoomInSelected =
false;
3224 fZoomOutSelected =
false;
3226 if (fToolbarApp == NULL)
return;
3227 QList<QAction *> list = fToolbarApp->actions ();
3228 for (
int i = 0; i < list.size(); ++i) {
3229 if (list.at(i)->data().toString () ==
"rotate") {
3230 list.at(i)->setChecked(
TRUE);
3231 }
else if (list.at(i)->data().toString () ==
"move") {
3232 list.at(i)->setChecked(
FALSE);
3233 }
else if (list.at(i)->data().toString () ==
"pick") {
3234 list.at(i)->setChecked(
FALSE);
3235 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3236 list.at(i)->setChecked(
FALSE);
3237 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3238 list.at(i)->setChecked(
FALSE);
3244 void G4UIQt::SetIconPickSelected() {
3246 fPickSelected =
true;
3247 fMoveSelected =
false;
3248 fRotateSelected =
false;
3249 fZoomInSelected =
false;
3250 fZoomOutSelected =
false;
3252 if (fToolbarApp == NULL)
return;
3253 QList<QAction *> list = fToolbarApp->actions ();
3254 for (
int i = 0; i < list.size(); ++i) {
3255 if (list.at(i)->data().toString () ==
"pick") {
3256 list.at(i)->setChecked(
TRUE);
3257 }
else if (list.at(i)->data().toString () ==
"move") {
3258 list.at(i)->setChecked(
FALSE);
3259 }
else if (list.at(i)->data().toString () ==
"rotate") {
3260 list.at(i)->setChecked(
FALSE);
3261 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3262 list.at(i)->setChecked(
FALSE);
3263 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3264 list.at(i)->setChecked(
FALSE);
3270 void G4UIQt::SetIconZoomInSelected() {
3272 fZoomInSelected =
true;
3273 fMoveSelected =
false;
3274 fRotateSelected =
false;
3275 fPickSelected =
false;
3276 fZoomOutSelected =
false;
3278 if (fToolbarApp == NULL)
return;
3279 QList<QAction *> list = fToolbarApp->actions ();
3280 for (
int i = 0; i < list.size(); ++i) {
3281 if (list.at(i)->data().toString () ==
"zoom_in") {
3282 list.at(i)->setChecked(
TRUE);
3283 }
else if (list.at(i)->data().toString () ==
"move") {
3284 list.at(i)->setChecked(
FALSE);
3285 }
else if (list.at(i)->data().toString () ==
"rotate") {
3286 list.at(i)->setChecked(
FALSE);
3287 }
else if (list.at(i)->data().toString () ==
"pick") {
3288 list.at(i)->setChecked(
FALSE);
3289 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3290 list.at(i)->setChecked(
FALSE);
3296 void G4UIQt::SetIconZoomOutSelected() {
3298 fZoomOutSelected =
true;
3299 fMoveSelected =
false;
3300 fRotateSelected =
false;
3301 fPickSelected =
false;
3302 fZoomInSelected =
false;
3304 if (fToolbarApp == NULL)
return;
3305 QList<QAction *> list = fToolbarApp->actions ();
3306 for (
int i = 0; i < list.size(); ++i) {
3307 if (list.at(i)->data().toString () ==
"zoom_out") {
3308 list.at(i)->setChecked(
TRUE);
3309 }
else if (list.at(i)->data().toString () ==
"move") {
3310 list.at(i)->setChecked(
FALSE);
3311 }
else if (list.at(i)->data().toString () ==
"rotate") {
3312 list.at(i)->setChecked(
FALSE);
3313 }
else if (list.at(i)->data().toString () ==
"pick") {
3314 list.at(i)->setChecked(
FALSE);
3315 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3316 list.at(i)->setChecked(
FALSE);
3322 void G4UIQt::SetIconSolidSelected() {
3325 if (fToolbarApp == NULL)
return;
3326 QList<QAction *> list = fToolbarApp->actions ();
3327 for (
int i = 0; i < list.size(); ++i) {
3328 if (list.at(i)->data().toString () ==
"solid") {
3329 list.at(i)->setChecked(
TRUE);
3330 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3331 list.at(i)->setChecked(
FALSE);
3332 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3333 list.at(i)->setChecked(
FALSE);
3334 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3335 list.at(i)->setChecked(
FALSE);
3341 void G4UIQt::SetIconWireframeSelected() {
3344 if (fToolbarApp == NULL)
return;
3345 QList<QAction *> list = fToolbarApp->actions ();
3346 for (
int i = 0; i < list.size(); ++i) {
3347 if (list.at(i)->data().toString () ==
"wireframe") {
3348 list.at(i)->setChecked(
TRUE);
3349 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3350 list.at(i)->setChecked(
FALSE);
3351 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3352 list.at(i)->setChecked(
FALSE);
3353 }
else if (list.at(i)->data().toString () ==
"solid") {
3354 list.at(i)->setChecked(
FALSE);
3360 void G4UIQt::SetIconHLRSelected() {
3363 if (fToolbarApp == NULL)
return;
3364 QList<QAction *> list = fToolbarApp->actions ();
3365 for (
int i = 0; i < list.size(); ++i) {
3366 if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3367 list.at(i)->setChecked(
TRUE);
3368 }
else if (list.at(i)->data().toString () ==
"solid") {
3369 list.at(i)->setChecked(
FALSE);
3370 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3371 list.at(i)->setChecked(
FALSE);
3372 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3373 list.at(i)->setChecked(
FALSE);
3379 void G4UIQt::SetIconHLHSRSelected() {
3382 if (fToolbarApp == NULL)
return;
3383 QList<QAction *> list = fToolbarApp->actions ();
3384 for (
int i = 0; i < list.size(); ++i) {
3385 if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3386 list.at(i)->setChecked(
TRUE);
3387 }
else if (list.at(i)->data().toString () ==
"solid") {
3388 list.at(i)->setChecked(
FALSE);
3389 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3390 list.at(i)->setChecked(
FALSE);
3391 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3392 list.at(i)->setChecked(
FALSE);
3398 void G4UIQt::SetIconPerspectiveSelected() {
3401 if (fToolbarApp == NULL)
return;
3402 QList<QAction *> list = fToolbarApp->actions ();
3403 for (
int i = 0; i < list.size(); ++i) {
3404 if (list.at(i)->data().toString () ==
"perspective") {
3405 list.at(i)->setChecked(
TRUE);
3406 }
else if (list.at(i)->data().toString () ==
"ortho") {
3407 list.at(i)->setChecked(
FALSE);
3414 void G4UIQt::SetIconOrthoSelected() {
3417 if (fToolbarApp == NULL)
return;
3418 QList<QAction *> list = fToolbarApp->actions ();
3419 for (
int i = 0; i < list.size(); ++i) {
3420 if (list.at(i)->data().toString () ==
"ortho") {
3421 list.at(i)->setChecked(
TRUE);
3422 }
else if (list.at(i)->data().toString () ==
"perspective") {
3423 list.at(i)->setChecked(
FALSE);
3430 G4QTabWidget::G4QTabWidget(
3438 G4QTabWidget::G4QTabWidget(
3447 #if QT_VERSION < 0x040500
3448 void G4UIQt::TabCloseCallback(
int){
3450 void G4UIQt::TabCloseCallback(
int a){
3452 #if QT_VERSION < 0x040500
3454 QWidget* temp = fViewerTabWidget->widget(a);
3455 fViewerTabWidget->removeTab (a);
3459 if (fViewerTabWidget->count() == 0) {
3460 if (fEmptyViewerTabLabel == NULL) {
3461 fEmptyViewerTabLabel =
new QLabel(
" If you want to have a Viewer, please use /vis/open commands. ");
3465 fRightSplitterWidget->insertWidget(0,fEmptyViewerTabLabel);
3467 fMainSplitterWidget->show();
3468 fEmptyViewerTabLabel->show();
3469 fViewerTabWidget->setParent(0);
3470 fViewerTabWidget->setVisible(
false);
3471 delete fViewerTabWidget;
3472 fViewerTabWidget = NULL;
3478 void G4UIQt::ToolBoxActivated(
int a){
3480 if (fUITabWidget->widget(a) == fHelpTBWidget) {
3483 }
else if (fUITabWidget->widget(a) == fSceneTreeComponentsTBWidget) {
3484 #if QT_VERSION < 0x040200
3485 fSceneTreeComponentsTBWidget->show();
3487 fSceneTreeComponentsTBWidget->setVisible(
true);
3493 void G4QTabWidget::paintEvent(
3498 if (currentWidget()) {
3500 if ( isTabSelected()) {
3502 QCoreApplication::sendPostedEvents () ;
3504 #ifdef G4DEBUG_INTERFACES_BASIC
3505 printf(
"G4QTabWidget::paintEvent OK\n");
3507 QString text = tabText (currentIndex());
3509 if (lastCreated == -1) {
3510 QString paramSelect = QString(
"/vis/viewer/select ")+text;
3518 setTabSelected(
false);