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>
78 #include <qdesktopwidget.h>
79 #include <qmessagebox.h>
85 static G4bool exitSession =
true;
86 static G4bool exitPause =
true;
115 ,fCoutTBTextArea(NULL)
120 ,fHistoryTBTableList(NULL)
121 ,fHelpTreeWidget(NULL)
123 ,fHistoryTBWidget(NULL)
125 ,fSceneTreeComponentsTBWidget(NULL)
127 ,fViewerTabWidget(NULL)
129 ,fEmptyViewerTabLabel(NULL)
130 ,fMainSplitterWidget(NULL)
131 ,fRightSplitterWidget(NULL)
132 ,fLeftSplitterWidget(NULL)
133 ,fHelpVSplitter(NULL)
134 ,fViewerTabHandleWidget(NULL)
137 ,fStringSeparator(
"__$$$@%%###__")
139 ,fMoveSelected(false)
140 ,fRotateSelected(true)
141 ,fPickSelected(false)
142 ,fZoomInSelected(false)
143 ,fZoomOutSelected(false)
146 G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(
char*)
"Qt");
147 if (!(QApplication*)interactorManager->GetMainInteractor()) {
152 G4cout <<
"G4UIQt : Unable to init Qt. Aborted" <<
G4endl;
162 Q_FOREACH (QWidget *widget, QApplication::allWidgets()) {
163 if ((found==
false) && (widget->inherits(
"QMainWindow"))) {
173 G4cout <<
"G4UIQt : Found an external App with a QMainWindow already defined. Aborted" <<
G4endl;
177 fMainWindow =
new QMainWindow();
180 fMainSplitterWidget =
new QSplitter(Qt::Horizontal);
182 fMainSplitterWidget->addWidget(CreateLeftSplitterWidget());
183 fMainSplitterWidget->addWidget(CreateRightSplitterWidget());
185 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
186 policy.setHorizontalStretch(2);
187 fRightSplitterWidget->setSizePolicy(policy);
189 policy = QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
190 policy.setHorizontalStretch(1);
191 fLeftSplitterWidget->setSizePolicy(policy);
193 fMainWindow->setCentralWidget(fMainSplitterWidget);
197 fMainWindow->setWindowTitle(QFileInfo( QCoreApplication::applicationFilePath() ).fileName());
198 fMainWindow->move(QPoint(50,50));
203 fMainWindow->resize(fLeftSplitterWidget->width()+fRightSplitterWidget->width()+20,
204 fLeftSplitterWidget->height()+fRightSplitterWidget->height()+20);
207 #if QT_VERSION < 0x040200
210 fMainWindow->setVisible(
false);
226 if (fMainWindow!=NULL) {
233 QWidget* G4UIQt::CreateHistoryTBWidget(
236 fHistoryTBWidget =
new QWidget();
238 QVBoxLayout *layoutHistoryTB =
new QVBoxLayout();
239 fHistoryTBTableList =
new QListWidget();
240 fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
241 connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
242 fHistoryTBTableList->installEventFilter(
this);
244 layoutHistoryTB->addWidget(fHistoryTBTableList);
246 fHistoryTBWidget->setLayout(layoutHistoryTB);
247 return fHistoryTBWidget;
253 QWidget* G4UIQt::CreateHelpTBWidget(
256 fHelpTBWidget =
new QWidget();
258 QWidget *helpWidget =
new QWidget();
259 QHBoxLayout *helpLayout =
new QHBoxLayout();
260 QVBoxLayout *vLayout =
new QVBoxLayout();
261 fHelpVSplitter =
new QSplitter(Qt::Horizontal);
262 fHelpLine =
new QLineEdit();
263 helpLayout->addWidget(
new QLabel(
"Search :"));
264 helpLayout->addWidget(fHelpLine);
265 connect( fHelpLine, SIGNAL( editingFinished () ),
this, SLOT( LookForHelpStringCallback() ) );
270 fHelpArea =
new QTextEdit();
271 fHelpArea->setReadOnly(
true);
275 if (fHelpTreeWidget) {
276 fHelpVSplitter->addWidget(fHelpTreeWidget);
278 fHelpVSplitter->addWidget(fHelpArea);
280 vLayout->addWidget(helpWidget);
281 vLayout->addWidget(fHelpVSplitter,1);
283 helpWidget->setLayout(helpLayout);
284 fHelpTBWidget->setLayout(vLayout);
286 return fHelpTBWidget;
292 QWidget* G4UIQt::CreateCoutTBWidget(
295 fCoutTBWidget =
new QGroupBox(
"Output");
297 QVBoxLayout *layoutCoutTB =
new QVBoxLayout();
299 fCoutTBTextArea =
new QTextEdit();
302 fCoutTBTextArea->setFontFamily(
"Courier");
303 fCoutTBTextArea->setFontPointSize(12);
305 fCoutFilter =
new QLineEdit();
306 QLabel* coutFilterLabel =
new QLabel(
"Filter : ");
307 coutFilterLabel->setToolTip(
"filter output by...");
309 QPushButton *coutTBClearButton =
new QPushButton(
"clear output");
310 coutTBClearButton->setToolTip(
"clear output");
311 connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
312 connect(fCoutFilter, SIGNAL(textEdited (
const QString &)), SLOT(CoutFilterCallback(
const QString &)));
314 fCoutTBTextArea->setReadOnly(
true);
316 QWidget* coutButtonWidget =
new QWidget();
317 QHBoxLayout* layoutCoutTBButtons =
new QHBoxLayout();
318 layoutCoutTBButtons->addWidget(coutTBClearButton);
319 layoutCoutTBButtons->addWidget(coutFilterLabel);
320 layoutCoutTBButtons->addWidget(fCoutFilter);
321 coutButtonWidget->setLayout(layoutCoutTBButtons);
324 layoutCoutTBButtons->setContentsMargins(3,3,3,0);
326 layoutCoutTB->addWidget(fCoutTBTextArea);
327 layoutCoutTB->addWidget(coutButtonWidget);
329 fCoutTBWidget->setLayout(layoutCoutTB);
331 fCoutTBTextArea->setMinimumSize(100,100);
333 return fCoutTBWidget;
339 QWidget* G4UIQt::CreateVisParametersTBWidget(
348 QWidget* G4UIQt::CreateUITabWidget(
351 fUITabWidget =
new QTabWidget();
354 fUITabWidget->addTab(CreateSceneTreeComponentsTBWidget(),
"Scene tree");
355 fUITabWidget->addTab(CreateHelpTBWidget(),
"Help");
356 fUITabWidget->addTab(CreateHistoryTBWidget(),
"History");
359 connect(fUITabWidget, SIGNAL(currentChanged(
int)), SLOT(ToolBoxActivated(
int)));
365 QWidget* G4UIQt::CreateSceneTreeComponentsTBWidget(){
367 fSceneTreeComponentsTBWidget =
new QTabWidget();
369 #if QT_VERSION < 0x040200
370 fSceneTreeComponentsTBWidget->hide();
372 fSceneTreeComponentsTBWidget->setVisible(
false);
375 return fSceneTreeComponentsTBWidget;
379 QWidget* G4UIQt::CreateLeftSplitterWidget(){
381 fLeftSplitterWidget =
new QWidget();
382 QVBoxLayout * layoutLeftSplitterWidget =
new QVBoxLayout();
383 layoutLeftSplitterWidget->addWidget(CreateUITabWidget());
385 fLeftSplitterWidget->setLayout(layoutLeftSplitterWidget);
387 fLeftSplitterWidget->resize(200,200);
389 return fLeftSplitterWidget;
393 QWidget* G4UIQt::CreateRightSplitterWidget(){
395 fRightSplitterWidget =
new QSplitter(Qt::Vertical);
398 QWidget* commandLineWidget =
new QWidget();
399 QHBoxLayout *layoutCommandLine =
new QHBoxLayout();
403 fCommandLabel =
new QLabel(
"");
405 fCommandArea =
new QLineEdit();
406 fCommandArea->installEventFilter(
this);
407 fCommandArea->activateWindow();
409 fCommandArea->setFocusPolicy ( Qt::StrongFocus );
410 fCommandArea->setFocus(Qt::TabFocusReason);
411 fCommandArea->setToolTip(
"Apply command");
414 layoutCommandLine->addWidget(fCommandLabel);
415 layoutCommandLine->addWidget(fCommandArea);
417 commandLineWidget->setLayout(layoutCommandLine);
419 fEmptyViewerTabLabel =
new QLabel(
"If you want to have a Viewer, please use /vis/open commands.");
427 fViewerTabHandleWidget =
new QWidget();
428 QVBoxLayout * viewerTabHandleLayout =
new QVBoxLayout();
429 viewerTabHandleLayout->addWidget(fEmptyViewerTabLabel);
430 fViewerTabHandleWidget->setLayout(viewerTabHandleLayout);
433 fRightSplitterWidget->addWidget(fViewerTabHandleWidget);
434 fRightSplitterWidget->addWidget(CreateCoutTBWidget());
435 fRightSplitterWidget->addWidget(commandLineWidget);
438 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
439 policy.setVerticalStretch(4);
440 fViewerTabHandleWidget->setSizePolicy(policy);
442 fViewerTabHandleWidget->setMinimumSize(40,40);
444 commandLineWidget->setMinimumSize(50,50);
447 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
448 connect(fCommandArea, SIGNAL(textEdited(
const QString &)), SLOT(CommandEditedCallback(
const QString &)));
450 fRightSplitterWidget->resize(200,200);
451 return fRightSplitterWidget;
457 QTabWidget* G4UIQt::GetSceneTreeComponentsTBWidget(
460 return fSceneTreeComponentsTBWidget;
467 bool G4UIQt::AddTabWidget(
480 #if QT_VERSION < 0x050100
481 #if QT_VERSION >= 0x050000
482 QString message = QString(
483 "This Qt version [")+qVersion ()+
"] has some issues with the OpenGL viewer.\n"+
484 "To prevent problems, you are not allowed to open a Store nor Immediate viewer.\n" +
486 "Please upgrade to Qt version >= 5.1\n";
488 QMessageBox::warning(fMainWindow, tr(
"Warning"),
489 tr(message.toStdString().c_str()),
496 if (fViewerTabWidget == NULL) {
497 fViewerTabWidget =
new G4QTabWidget(fViewerTabHandleWidget, sizeX, sizeY);
498 #if QT_VERSION < 0x040500
500 fViewerTabWidget->setTabsClosable (
true);
503 #if QT_VERSION < 0x040200
505 fViewerTabWidget->setUsesScrollButtons (
true);
508 #if QT_VERSION < 0x040500
510 connect(fViewerTabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(TabCloseCallback(
int)));
512 connect(fViewerTabWidget, SIGNAL(currentChanged (
int ) ), SLOT(UpdateTabWidget(
int)));
519 fViewerTabWidget->addTab(aWidget,name);
525 if (fEmptyViewerTabLabel != NULL) {
527 index = fViewerTabHandleWidget->layout()->indexOf(fEmptyViewerTabLabel);
529 fViewerTabHandleWidget->layout()->removeWidget(fEmptyViewerTabLabel);
530 delete fEmptyViewerTabLabel;
531 fEmptyViewerTabLabel = NULL;
533 fViewerTabHandleWidget->layout()->addWidget(fViewerTabWidget);
539 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
542 #if QT_VERSION < 0x040200
543 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
545 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
553 QSize
s = QSize(sizeX,sizeY);
555 QRect screen = QApplication::desktop()->screenGeometry();
557 if (fMainWindow->width()-fViewerTabWidget->width()+sizeX > screen.width()) {
558 s.setWidth(screen.width()-fMainWindow->width()+fViewerTabWidget->width());
560 if (fMainWindow->height()-fViewerTabWidget->height()+sizeY > screen.height()-24) {
561 s.setHeight(screen.height()-fMainWindow->height()+fViewerTabWidget->height()-24);
563 int winWidth = fMainWindow->width();
564 int winHeight = fMainWindow->height();
565 int oldTabWidth = fViewerTabWidget->width();
566 int oldTabHeight = fViewerTabWidget->height();
567 int newTabWidth = fViewerTabWidget->sizeHint().width();
568 int newTabHeight = fViewerTabWidget->sizeHint().height();
570 fViewerTabWidget->setPreferredSize(s);
571 fMainWindow->resize(winWidth-oldTabWidth+newTabWidth,
572 winHeight-oldTabHeight+newTabHeight);
577 void G4UIQt::UpdateTabWidget(
int tabNumber) {
578 if ( fViewerTabWidget == NULL) {
579 fViewerTabWidget =
new G4QTabWidget;
582 fViewerTabWidget->setCurrentIndex(tabNumber);
585 fViewerTabWidget->setTabSelected(
false);
587 #if QT_VERSION < 0x040200
588 fViewerTabWidget->show();
590 fViewerTabWidget->setVisible(
true);
594 fViewerTabWidget->setTabSelected(
true);
600 void G4UIQt::ResizeTabWidget( QResizeEvent* e) {
601 if ( fViewerTabWidget) {
602 for (
G4int a=0;
a<fViewerTabWidget->count() ;
a++) {
603 fViewerTabWidget->widget(
a)->resize(e->size());
614 G4Qt* interactorManager = G4Qt::getInstance ();
618 QCoreApplication::sendPostedEvents () ;
620 #if QT_VERSION < 0x040200
623 fMainWindow->setVisible(
true);
625 interactorManager->DisableSecondaryLoop ();
626 if ((QApplication*)interactorManager->GetMainInteractor())
627 ((QApplication*)interactorManager->GetMainInteractor())->exec();
629 interactorManager->EnableSecondaryLoop ();
639 void G4UIQt::Prompt (
643 if (!aPrompt)
return;
645 fCommandLabel->setText((
char*)aPrompt.
data());
650 void G4UIQt::SessionTerminate (
653 G4Qt* interactorManager = G4Qt::getInstance ();
654 fMainWindow->close();
655 ((QApplication*)interactorManager->GetMainInteractor())->exit();
668 void G4UIQt::PauseSessionStart (
674 if(aState==
"G4_pause> ") {
675 SecondaryLoop (
"Pause, type continue to exit this state");
678 if(aState==
"EndOfEvent") {
680 SecondaryLoop (
"End of event, type continue to exit this state");
690 void G4UIQt::SecondaryLoop (
694 if (!aPrompt)
return;
696 G4Qt* interactorManager = G4Qt::getInstance ();
700 ((QApplication*)interactorManager)->processEvents(QEventLoop::WaitForMoreEvents);
701 if(exitPause==
true)
break;
713 G4int G4UIQt::ReceiveG4cout (
717 if (!aString)
return 0;
722 newStr = QStringList(QString((
char*)aString.
data()).trimmed());
725 QStringList result = newStr.filter(fCoutFilter->text());
727 if (result.join(
"").isEmpty()) {
730 fCoutTBTextArea->append(result.join(
""));
731 fCoutTBTextArea->repaint();
733 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
744 G4int G4UIQt::ReceiveG4cerr (
748 if (!aString)
return 0;
753 newStr = QStringList(QString((
char*)aString.
data()).trimmed());
756 QStringList result = newStr.filter(fCoutFilter->text());
759 if (QString(aString.
data()).trimmed() !=
"") {
763 QMessageBox::critical(fMainWindow,
"Error",QString(fLastErrMessage.data())+
"\n"+aString.
data());
766 QColor previousColor = fCoutTBTextArea->textColor();
767 fCoutTBTextArea->setTextColor(
Qt::red);
768 fCoutTBTextArea->append(result.join(
"\n"));
769 fCoutTBTextArea->setTextColor(previousColor);
770 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
771 fCoutTBTextArea->repaint();
773 if (QString(aString.
data()).trimmed() !=
"") {
774 fLastErrMessage = aString;
786 void G4UIQt::AddMenu (
791 if (aName == NULL)
return;
792 if (aLabel == NULL)
return;
794 QMenu *fileMenu =
new QMenu(aLabel);
795 fMainWindow->menuBar()->addMenu(fileMenu);
807 void G4UIQt::AddButton (
810 ,
const char* aCommand
813 if(aMenu==NULL)
return;
814 if(aLabel==NULL)
return;
815 if(aCommand==NULL)
return;
817 QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
819 if(parentTmp==NULL) {
824 G4cout <<
"Menu name " << aMenu<<
" does not exist, please define it before using it."<<
G4endl;
835 G4int cmdEndPos = cmd.find_first_of(
" \t");
836 if(cmdEndPos!=
G4int(std::string::npos)) {
837 cmd.erase(cmdEndPos);
840 if(treeTop->
FindPath(cmd) == NULL) {
845 G4cout <<
"Warning: command '"<< cmd <<
"' does not exist, please define it before using it."<<
G4endl;
849 QSignalMapper *signalMapper =
new QSignalMapper(
this);
850 QAction *action = parentTmp->addAction(aLabel, signalMapper, SLOT(map()));
852 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
853 signalMapper->setMapping(action, QString(aCommand));
862 void G4UIQt::AddIcon(
const char* aLabel,
const char* aIconFile,
const char* aCommand,
const char* aFileName){
863 if(aLabel==NULL)
return;
865 if (aCommand==NULL) {
866 if (std::string(aIconFile) ==
"user_icon") {
871 bool userToolBar =
false;
873 if (std::string(aIconFile) ==
"user_icon") {
875 pix = QPixmap(aFileName);
881 G4cout <<
"Warning: file '"<< aFileName <<
"' is incorrect or does not exist, this command will not be build"<<
G4endl;
886 }
else if (std::string(aIconFile) ==
"open") {
887 const char *
const xpm[]={
931 " {]^/((_({- %%%%%%%%%%% ",
932 " {(^_^^^^:<{{{{{{{{{{{{{[& ",
933 " {/_/(((((/]]]]]]]]]]]/]!# ",
934 " {/^(((((_^^^^^^^^^^^^^^:# ",
935 " {/^(((_^^____________^^}$ ",
936 " {/^(((((/////////////((!# ",
937 " {/^/^_:<|||||||||||||||@@****1 ",
938 " {/^/^(<[)||||||||||||||))!!}<; ",
939 " {/^_(:|234444444444444444432)1 ",
940 " {/_^/<)34444444444444444443}, ",
941 " {/^(2{:41111111111111111142|5 ",
942 " {3^3<:31111111111111111143}- ",
943 " {/^2<:31111111111111111441|' ",
944 " {_/<:41111111111111111143}, ",
945 " {(4<:31111111111111111144!# ",
946 " )4))44111111111111111144}, ",
947 " )2<:31111111111111111144{# ",
948 " @|:14444444444444444444}* ",
949 " ;@434444444444444444434<# ",
950 " ;[))))))))))))))))))))!~ ",
951 " ++++++++++++++++++++++;% ",
957 }
else if (std::string(aIconFile) ==
"save") {
958 const char *
const xpm[]={
986 " +++++++++++++++++++++++++ ",
987 " +@##+$%%%%%%%%%%%%%%%&*$%&+ ",
988 " +=-;@>,,''',,,,,,,',,)&!,)+ ",
989 " +;-~@>,,,,,,,,,,,,,,,>$!,)+ ",
990 " +=-~@>,,,,,{]]]]]^,,,>*&$&+ ",
991 " +=-~@>,,,,,'{^{^^{,,,>*#=#+ ",
992 " +=-~@>,,,,,,,,,,,,,,,>@~/=+ ",
993 " +=-~@>,,,{{{''''{',,,>@~-=+ ",
994 " +=-~@>,,'^]]]]]]({,,,>@~-=+ ",
995 " +=-~@>,,,{{{{{{{{{,,,>@~-=+ ",
996 " +=-~@>,,,,,'{^{{^{,,,>@~-=+ ",
997 " +=-~@>,,,,,]]]]]]],,,>@~-=+ ",
998 " +=-~*>,,,,,,,,,,,,,,,>@~-=+ ",
999 " +=-~@>,,,,,,,,,,,,,,,>@~-=+ ",
1000 " +=-/=$%%%%%%%%%%%%%%%$=/-=+ ",
1001 " +=---;###############;---=+ ",
1002 " +=---////////////////----=+ ",
1003 " +=----------------///----=+ ",
1004 " +=---=@##############@#--=+ ",
1005 " +=---@+++++++++++*%))_+~-=+ ",
1006 " +=---#+++++++++++&:,,>@~-=+ ",
1007 " +=---#+++++++++++$',,>@~-=+ ",
1008 " +=---#+++++++++++&!,,>@~-=+ ",
1009 " +=/--#+++++++++++&',,>@~-=+ ",
1010 " @;--#+++++++++++$',,>@~-=+ ",
1011 " @;;@+++++++++++*)!>%@=;#+ ",
1012 " @++++++++++++++*&**++@++ ",
1018 }
else if (std::string(aIconFile) ==
"move") {
1019 const char *
const xpm[]={
1052 " ')&$$$$*@@ @@*$$$$&)' ",
1053 " ')&$$$$*@@ @@*$$$$&+' ",
1072 }
else if (std::string(aIconFile) ==
"rotate") {
1073 const char *
const xpm[]={
1109 " --------!*{{{*&, ",
1110 " -------=){*{{{>>{) ",
1111 " ,!-----= ){& ,&{{@",
1112 " ,*>!----= &>& )@",
1115 " @{* '! ,-!=~^,@ ",
1116 " @& == {/(----!^ ",
1119 " !-!!======!!(((---! ",
1120 " ='--------------! ",
1137 }
else if (std::string(aIconFile) ==
"pick") {
1138 const char *
const xpm[]={
1176 }
else if (std::string(aIconFile) ==
"zoom_in") {
1177 const char *
const xpm[]={
1199 " ++.%%%+&&&*%%.++ ",
1200 " .+#%%%%+&&&*%%.#+ ",
1201 " ++..%%%+&&&*%%%.++ ",
1202 " +#.+++++&&&*++++.+ ",
1203 " @.+&&&&&&&&&&&&&+@ ",
1204 " @#+&&&&&&&&&&&&&+@ ",
1205 " @.+&&&&&&&&&&&&&+. ",
1206 " +++@***+&&&****@+. ",
1207 " ....++++&&&*++++.. ",
1208 " ++.===+&&&*%=.++ ",
1209 " @..==+&&&*=..@#& ",
1210 " .@+#.+&&&@-+@@*@ ",
1211 " +++.++++++ *+@* ",
1224 }
else if (std::string(aIconFile) ==
"zoom_out") {
1225 const char *
const xpm[]={
1247 " ++.$$$$$$$$$$.++ ",
1248 " .+#$$$$$$$$$$$.#+ ",
1249 " ++..$$$$$$$$$$$.++ ",
1250 " +#.+++++++++++++.+ ",
1251 " @.+&&&&&&&&&&&&&+@ ",
1252 " @#+&&&&&&&&&&&&&+@ ",
1253 " @.+&&&&&&&&&&&&&+. ",
1254 " +++@***********@+. ",
1255 " ....++++++++++++.. ",
1256 " ++.===$$$$$$=.++ ",
1257 " @..===$$$$=..@#& ",
1258 " .@+#.$$$..-+@@*@ ",
1259 " +++#--.+++ *+@* ",
1272 }
else if (std::string(aIconFile) ==
"wireframe") {
1273 const char *
const xpm[]={
1302 " +&********&@-***; ",
1303 " +@@@&**&@@@@@@$ @*-&>&+ ",
1304 " +*****&+ %*@ ,**'# ",
1305 " @***)!~ @*{&*****+ ",
1306 " @*!]***&+ +-*^**'~!*@ ",
1307 " @*~ +@&**&@@@@@@&****&+ ~*@ ",
1308 " @*@ +&********&-*= @*@ ",
1309 " @*@ $%@-*-@$ @*@ @*@ ",
1310 " @*@ @*@ %*% @*@ ",
1311 " @*@ %*% %*% @*@ ",
1312 " @*@ %*% %*% @*@ ",
1313 " @*@ %*% %*% @*@ ",
1314 " @*@ %*% %*% @*@ ",
1315 " @*@ %*% %*% @*@ ",
1316 " @*@ @*@ %*% @*@ ",
1317 " @*@ =*-+ @*@ @*@ ",
1318 " @*@ $%@@&****&@-*-+ @*@ ",
1319 " @*@ $@&*****&@@&******&~~!*@ ",
1320 " @*{/***&@@%$ $@-*-&*****+ ",
1321 " @*)*)(-~ @*@ ~)**] ",
1322 " +*******&@@@@+ %*_+]**] ",
1323 " +@@@@@&******&@%+_*^**]# ",
1324 " $%@@@&****:**&+ ",
1333 }
else if (std::string(aIconFile) ==
"solid") {
1334 const char *
const xpm[]={
1372 " +-;>>>>>>>>>,')!~ ",
1373 " {]@@-;>>>>>>>>>>>>^/(_= ",
1374 " {:>>>>>>>>>>>>>>>>><//[)!= ",
1375 " ]>>>>>>>>>>>>>>>>>><////[)} ",
1376 " @>>>>>>>>>>>>>>>>>><//////| ",
1377 " @>>>>>>>>>>>>>>>>>><//////| ",
1378 " @>>>>>>>>>>>>>>>>>><//////| ",
1379 " @>>>>>>>>>>>>>>>>>><//////| ",
1380 " @>>>>>>>>>>>>>>>>>><//////| ",
1381 " @>>>>>>>>>>>>>>>>>><//////| ",
1382 " @>>>>>>>>>>>>>>>>>><//////| ",
1383 " @>>>>>>>>>>>>>>>>>><//////| ",
1384 " @>>>>>>>>>>>>>>>>>><//////| ",
1385 " @>>>>>>>>>>>>>>>>>><//////| ",
1386 " @>>>>>>>>>>>>>>>>>><//////| ",
1387 " @>>>>>>>>>>>>>>>>>><//////| ",
1388 " @>>>>>>>>>>>>>>>>>><//////| ",
1389 " @>>>>>>>>>>>>>>>>>><//////| ",
1390 " @>>>>>>>>>>>>>>>>>></////[1 ",
1391 " @>>>>>>>>>>>>>>>>>><////[*2 ",
1392 " {:>>>>>>>>>>>>>>>>><//[)12 ",
1393 " +@@@@@-;>>>>>>>>>><[)13 ",
1403 }
else if (std::string(aIconFile) ==
"hidden_line_removal") {
1404 const char *
const xpm[]={
1424 " +#$$$$$$$$#@&$$$* ",
1425 " =-@@#$$#@@@@@-= @$&#;>= ",
1426 " =$$$$$#+ -$@ *$$%+ ",
1427 " -$&@-= -$- #$$$= ",
1443 " -$&@@@-= -$- =>;, ",
1444 " =$$$$$$$#@@@-= -$'+#$$, ",
1445 " =-@@@@#$$$$$$#@-+'$)$$#+ ",
1446 " =-@@@#$$$$)$$#+ ",
1455 }
else if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
1456 const char *
const xpm[]={
1502 " ++@%####&*=-#+;>, ",
1503 " +++++@'=)))))))!)~+{]^++ ",
1504 " +$%&*=)!!!!!!!!!)~+/(]_+++ ",
1505 " +#-))!!!!!!!!!!!)~+/(::<[+ ",
1506 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1507 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1508 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1509 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1510 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1511 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1512 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1513 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1514 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1515 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1516 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1517 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1518 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1519 " +#)!!!!!!!!!!!!!!}+/:::|1+ ",
1520 " +$#}}~23!!!!!!!!)~+/(]45, ",
1521 " +++++++@#}}~23!!)~+678++ ",
1522 " ++++++@#~90+a++ ",
1532 }
else if (std::string(aIconFile) ==
"perspective") {
1533 const char *
const xpm[]={
1543 " ................ ",
1544 " ....+++++++++++++++. ",
1545 " ...++++..+.........+++. ",
1546 " ..++..............++..+. ",
1547 " .+++++++++++++++++.. .+. ",
1548 " .+...............+. .+. ",
1549 " .+. .+. .+. .+. ",
1550 " .+. .+. .+. .+. ",
1551 " .+. .+. .+. .+. ",
1552 " .+. .+. .+. .+. ",
1553 " .+. .+. .+. .+. ",
1554 " .+. .+. .+. .+. ",
1555 " .+. .+. .+. .+. ",
1556 " .+. .+. .+. .+. ",
1557 " .+. .+......+....+. ",
1558 " .+. ..++++++.+.++++. ",
1559 " .+. .++.......+...+.. ",
1560 " .+. .++. .+..++. ",
1561 " .+. ..+.. .+..+. ",
1564 " .+++.............++. ",
1565 " .+++++++++++++++++. ",
1566 " ................... ",
1572 }
else if (std::string(aIconFile) ==
"ortho") {
1573 const char *
const xpm[]={
1581 " ................... ",
1582 " ..@@@@@@@@@@@@@@@@@. ",
1583 " ..@@@.............@@@. ",
1584 " ..@@.@. ..@..@. ",
1585 " ..@@ ..@. .@@...@. ",
1586 " ..@@..............@@.. .@. ",
1587 " .@@@@@@@@@@@@@@@@@.. .@. ",
1588 " .@...............@. .@. ",
1589 " .@. .@. .@. .@. ",
1590 " .@. .@. .@. .@. ",
1591 " .@. .@. .@. .@. ",
1592 " .@. .@. .@. .@. ",
1593 " .@. .@. .@. .@. ",
1594 " .@. .@. .@. .@. ",
1595 " .@. .@. .@. .@. ",
1596 " .@. .@. .@. .@. ",
1597 " .@. .@. .@. .@. ",
1598 " .@. .@. .@. .@. ",
1599 " .@. .@........@......@. ",
1600 " .@. .@@@@@@@@@.@.@@@@@@. ",
1601 " .@. .@@+........@....@@.. ",
1602 " .@...@. .@...@... ",
1604 " .@@@.............@@@.. ",
1605 " .@@@@@@@@@@@@@@@@@... ",
1606 " ................... ",
1617 G4cout <<
"Parameter"<< aIconFile <<
" not defined"<<
G4endl;
1621 QToolBar *currentToolbar = NULL;
1623 if (fToolbarUser == NULL) {
1624 fToolbarUser =
new QToolBar();
1625 fToolbarUser->setIconSize (QSize(20,20));
1626 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
1628 currentToolbar = fToolbarUser;
1630 if (fToolbarApp == NULL) {
1631 fToolbarApp =
new QToolBar();
1632 fToolbarApp->setIconSize (QSize(20,20));
1633 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
1635 currentToolbar = fToolbarApp;
1638 QSignalMapper *signalMapper =
new QSignalMapper(
this);
1639 QAction *action = currentToolbar->addAction(pix,aLabel, signalMapper, SLOT(map()));
1643 if (std::string(aIconFile) ==
"open") {
1644 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(OpenIconCallback(
const QString &)));
1645 QString txt = aCommand + fStringSeparator + aLabel;
1646 signalMapper->setMapping(action, QString(txt));
1649 }
else if (std::string(aIconFile) ==
"save") {
1650 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(SaveIconCallback(
const QString&)));
1651 QString txt = aCommand + fStringSeparator + aLabel;
1652 signalMapper->setMapping(action, QString(txt));
1655 }
else if ((std::string(aIconFile) ==
"move") ||
1656 (std::string(aIconFile) ==
"rotate") ||
1657 (std::string(aIconFile) ==
"pick") ||
1658 (std::string(aIconFile) ==
"zoom_out") ||
1659 (std::string(aIconFile) ==
"zoom_in")) {
1660 action->setCheckable(
TRUE);
1661 action->setChecked(
TRUE);
1662 action->setData(aIconFile);
1664 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeCursorStyle(
const QString&)));
1665 signalMapper->setMapping(action, QString(aIconFile));
1667 if (std::string(aIconFile) ==
"move") {
1668 SetIconMoveSelected();
1670 if (std::string(aIconFile) ==
"rotate") {
1671 SetIconRotateSelected();
1673 if (std::string(aIconFile) ==
"pick") {
1674 SetIconPickSelected();
1676 if (std::string(aIconFile) ==
"zoom_in") {
1677 SetIconZoomInSelected();
1679 if (std::string(aIconFile) ==
"zoom_out") {
1680 SetIconZoomOutSelected();
1684 }
else if ((std::string(aIconFile) ==
"hidden_line_removal") ||
1685 (std::string(aIconFile) ==
"hidden_line_and_surface_removal") ||
1686 (std::string(aIconFile) ==
"solid") ||
1687 (std::string(aIconFile) ==
"wireframe")) {
1688 action->setCheckable(
TRUE);
1689 action->setChecked(
TRUE);
1690 action->setData(aIconFile);
1691 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeSurfaceStyle(
const QString&)));
1692 signalMapper->setMapping(action, QString(aIconFile));
1694 if (std::string(aIconFile) ==
"hidden_line_removal") {
1695 SetIconHLRSelected();
1697 if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
1698 SetIconHLHSRSelected();
1700 if (std::string(aIconFile) ==
"solid") {
1701 SetIconSolidSelected();
1703 if (std::string(aIconFile) ==
"wireframe") {
1704 SetIconWireframeSelected();
1708 }
else if ((std::string(aIconFile) ==
"perspective") ||
1709 (std::string(aIconFile) ==
"ortho")) {
1710 action->setCheckable(
TRUE);
1711 action->setChecked(
TRUE);
1712 action->setData(aIconFile);
1713 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangePerspectiveOrtho(
const QString&)));
1714 signalMapper->setMapping(action, QString(aIconFile));
1716 if (std::string(aIconFile) ==
"perspective") {
1717 SetIconPerspectiveSelected();
1719 if (std::string(aIconFile) ==
"ortho") {
1720 SetIconOrthoSelected();
1727 if(UI==NULL)
return;
1729 if (aCommand != NULL) {
1730 if(treeTop->
FindPath(aCommand) == NULL) {
1735 G4cout <<
"Warning: command '"<< aCommand <<
"' does not exist, please define it before using it."<<
G4endl;
1740 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
1741 signalMapper->setMapping(action, QString(aCommand));
1747 void G4UIQt::ActivateCommand(
1751 if (!fHelpTreeWidget) {
1755 size_t i = newCommand.
index(
" ");
1757 if( i != std::string::npos )
1759 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
1761 targetCom = ModifyToFullPathCommand( newValue );
1763 if (targetCom !=
"") {
1764 OpenHelpTreeOnCommand(targetCom.
data());
1767 fUITabWidget->setCurrentWidget(fHelpTBWidget);
1778 void G4UIQt::InitHelpTreeAndVisParametersWidget()
1781 if (! fHelpTreeWidget ) {
1782 fHelpTreeWidget =
new QTreeWidget();
1786 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
1788 labels << QString(
"Command");
1789 fHelpTreeWidget->setHeaderLabels(labels);
1792 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),
this, SLOT(HelpTreeClicCallback()));
1793 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,
int)),
this, SLOT(HelpTreeDoubleClicCallback()));
1802 void G4UIQt::FillHelpTree()
1804 if (! fHelpTreeWidget ) {
1805 InitHelpTreeAndVisParametersWidget();
1808 QString searchText = fHelpLine->text();
1810 if (searchText ==
"") {
1818 #if QT_VERSION < 0x040200
1821 fHelpArea->setText(
"");
1826 #if QT_VERSION < 0x040200
1829 fHelpLine->setText(
"");
1834 if(UI==NULL)
return;
1838 QTreeWidgetItem * newItem = NULL;
1839 QString commandText =
"";
1840 for (
int a=0;
a<treeSize;
a++) {
1847 for (
int b=0;b<fHelpTreeWidget->topLevelItemCount();b++) {
1849 newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b),commandText);
1852 if (newItem == NULL) {
1854 newItem =
new QTreeWidgetItem();
1855 newItem->setText(0,GetShortCommandPath(commandText));
1856 fHelpTreeWidget->addTopLevelItem(newItem);
1860 CreateHelpTree(newItem,treeTop->
GetTree(
a+1));
1871 void G4UIQt::CreateHelpTree(
1872 QTreeWidgetItem *aParent
1876 if (aParent == NULL)
return;
1877 if (aCommandTree == NULL)
return;
1881 QTreeWidgetItem * newItem;
1883 QString commandText =
"";
1887 commandText = QString((
char*)(aCommandTree->
GetTree(
a+1)->
GetPathName()).data()).trimmed();
1890 newItem = FindTreeItem(aParent,commandText);
1891 if (newItem == NULL) {
1892 newItem =
new QTreeWidgetItem();
1893 newItem->setText(0,GetShortCommandPath(commandText));
1894 aParent->addChild(newItem);
1896 CreateHelpTree(newItem,aCommandTree->
GetTree(
a+1));
1903 QStringList stringList;
1907 newItem = FindTreeItem(aParent,commandText);
1908 if (newItem == NULL) {
1909 newItem =
new QTreeWidgetItem();
1910 newItem->setText(0,GetShortCommandPath(commandText));
1911 aParent->addChild(newItem);
1913 #if QT_VERSION < 0x040202
1914 fHelpTreeWidget->setItemExpanded(newItem,
false);
1916 newItem->setExpanded(
false);
1930 bool G4UIQt::CreateVisCommandGroupAndToolBox(
1937 QString commandText = QString((
char*)(aCommand->
GetCommandPath().
data())).section(
"/",-aDepthLevel);
1939 if (commandText == NULL) {
1945 QWidget* newParentWidget = NULL;
1947 QString commandSection = commandText.left(commandText.indexOf(
"/"));
1949 if (aDepthLevel == 1) {
1950 QToolBox* currentParent =
dynamic_cast<QToolBox*
>(aParent);
1951 if (currentParent != 0){
1954 for (
int a=0;
a<currentParent->count();
a++) {
1955 if (currentParent->itemText(
a) == commandSection) {
1957 newParentWidget = currentParent->widget(
a);
1963 newParentWidget =
new QGroupBox();
1964 newParentWidget->setLayout(
new QVBoxLayout());
1965 if (currentParent != 0){
1966 currentParent->addItem(newParentWidget,commandSection);
1968 if (!aParent->layout()) {
1969 aParent->setLayout(
new QVBoxLayout());
1971 aParent->layout()->addWidget(newParentWidget);
1974 if (commandText.indexOf(
"/") == -1) {
1979 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
1980 guidance += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
1982 newParentWidget->setToolTip(guidance);
1985 QScrollArea* sc =
dynamic_cast<QScrollArea*
>(newParentWidget->parent()->parent());
1987 sc->ensureWidgetVisible(newParentWidget);
1994 QGroupBox* currentParent =
dynamic_cast<QGroupBox*
>(aParent);
1995 if (currentParent != 0){
1999 if (aDepthLevel == 2){
2000 QToolBox* parentToolBox =
dynamic_cast<QToolBox*
>(currentParent->parent()->parent()->parent());
2001 if (parentToolBox != 0) {
2005 for (
int a=0;
a<aParent->layout()->count();
a++) {
2006 QGroupBox* gb =
dynamic_cast<QGroupBox*
>(aParent->layout()->itemAt(
a)->widget());
2008 if (gb->title() == commandSection) {
2010 newParentWidget = gb;
2018 newParentWidget =
new QGroupBox();
2019 newParentWidget->setLayout(
new QVBoxLayout());
2020 if (!aParent->layout()) {
2021 aParent->setLayout(
new QVBoxLayout());
2023 aParent->layout()->addWidget(newParentWidget);
2029 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2030 guidance += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
2032 newParentWidget->setToolTip(guidance);
2037 if (commandText.indexOf(
"/") == -1) {
2038 if (CreateCommandWidget(aCommand, newParentWidget,isDialog)) {
2042 CreateVisCommandGroupAndToolBox(aCommand,newParentWidget, aDepthLevel-1,isDialog);
2055 bool G4UIQt::CreateCommandWidget(
G4UIcommand* aCommand, QWidget* aParent,
bool isDialog) {
2057 if (aCommand == NULL) {
2064 if( n_parameterEntry > 0 ) {
2068 QWidget* paramWidget =
new QWidget();
2069 QGridLayout* gridLayout =
new QGridLayout();
2070 paramWidget->setLayout(gridLayout);
2073 unsigned int nbColorParameter = 0;
2074 bool isStillColorParameter =
false;
2075 bool isColorDialogAdded =
false;
2076 QLabel* redLabel = NULL;
2077 QLabel* greenLabel = NULL;
2078 QString redDefaultStr =
"";
2079 QString greenDefaultStr =
"";
2080 QString blueDefaultStr =
"";
2081 QWidget* redInput = NULL;
2082 QWidget* greenInput = NULL;
2084 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2087 QLabel* label =
new QLabel(QString((
char*)(param->
GetParameterName()).data()));
2089 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")){
2090 nbColorParameter ++;
2091 isStillColorParameter =
true;
2092 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2093 nbColorParameter ++;
2094 }
else if ((label->text() ==
"blue") && isStillColorParameter) {
2095 nbColorParameter ++;
2096 }
else if (!isColorDialogAdded) {
2099 if (nbColorParameter == 1) {
2100 gridLayout->addWidget(redLabel,i_thParameter-1,0);
2101 gridLayout->addWidget(redInput,i_thParameter-1,1);
2102 }
else if (nbColorParameter == 2) {
2103 gridLayout->addWidget(redLabel,i_thParameter-2,0);
2104 gridLayout->addWidget(redInput,i_thParameter-2,1);
2105 gridLayout->addWidget(greenLabel,i_thParameter-1,0);
2106 gridLayout->addWidget(greenInput,i_thParameter-1,1);
2108 nbColorParameter = 0;
2111 QWidget* input = NULL;
2113 input =
new QLineEdit();
2115 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
2117 if (((label->text() ==
"red") || (label->text() ==
"red_or_string")) && isStillColorParameter) {
2119 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2121 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2126 input =
new QWidget();
2127 QHBoxLayout* layout =
new QHBoxLayout();
2128 input->setLayout(layout);
2130 QButtonGroup* buttons =
new QButtonGroup();
2131 QRadioButton* radioOff =
new QRadioButton(
"0");
2132 QRadioButton* radioOn =
new QRadioButton(
"1");
2133 buttons->addButton(radioOn);
2134 buttons->addButton(radioOff);
2135 layout->addWidget(radioOn);
2136 layout->addWidget(radioOff);
2139 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
2140 if (defaultValue ==
"0") {
2141 radioOff->setChecked(
true);
2142 }
else if (defaultValue ==
"1") {
2143 radioOn->setChecked(
true);
2146 input =
new QComboBox();
2148 QStringList list = candidates.split (
" ");
2151 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
2152 for (
int a=0;
a<list.size();
a++) {
2153 dynamic_cast<QComboBox*
>(input)->addItem(list.at(
a));
2154 if (list.at(
a) == defaultValue) {
2155 dynamic_cast<QComboBox*
>(input)->setCurrentIndex(
a);
2160 input =
new QLineEdit();
2162 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
2165 input =
new QWidget();
2166 QHBoxLayout* layout =
new QHBoxLayout();
2167 input->setLayout(layout);
2169 QButtonGroup* buttons =
new QButtonGroup();
2170 QRadioButton* radioOff =
new QRadioButton(
"off");
2171 QRadioButton* radioOn =
new QRadioButton(
"on");
2172 buttons->addButton(radioOn);
2173 buttons->addButton(radioOff);
2174 layout->addWidget(radioOn);
2175 layout->addWidget(radioOff);
2178 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
2179 if (defaultValue ==
"off") {
2180 radioOff->setChecked(
true);
2181 }
else if (defaultValue ==
"on") {
2182 radioOn->setChecked(
true);
2186 input =
new QLineEdit();
2187 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
2190 txt +=
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) +
"\n";
2194 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2196 txt +=
" Omittable : True\n";
2198 txt +=
" Omittable : False\n";
2201 txt +=
" Default value : taken from the current value\n";
2203 txt +=
" Default value : " + QString((
char*)(param->
GetDefaultValue()).data())+
"\n";
2206 txt +=
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data())+
"\n";
2212 if (isStillColorParameter && (nbColorParameter != 0)) {
2213 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")) {
2216 }
else if (label->text() ==
"green") {
2219 }
else if (label->text() ==
"blue") {
2225 if ((redDefaultStr !=
"") && (redDefaultStr !=
"") && (redDefaultStr !=
"")) {
2226 qc.setRgbF(redDefaultStr.toDouble(),
2227 greenDefaultStr.toDouble(),
2228 blueDefaultStr.toDouble());
2230 QPixmap pixmap = QPixmap(QSize(16, 16));
2232 QPainter painter(&pixmap);
2233 painter.setPen(Qt::black);
2234 painter.drawRect(0,0,15,15);
2236 input =
new QPushButton(
"Change color");
2237 dynamic_cast<QPushButton*
>(input)->setIcon(pixmap);
2238 dynamic_cast<QPushButton*
>(input)->setAccessibleName(redDefaultStr+
" "+greenDefaultStr+
" "+blueDefaultStr);
2239 label =
new QLabel(
"Choose color");
2243 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2244 input->setToolTip(
"Select the current color");
2245 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2248 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2249 signalMapper->setMapping(input,input);
2250 connect(input, SIGNAL(clicked()), signalMapper, SLOT(map()));
2251 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(ChangeColorCallback(QWidget*)));
2253 isColorDialogAdded =
true;
2254 isStillColorParameter =
false;
2257 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2258 input->setToolTip(txt);
2259 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2265 gridLayout->addWidget(name,n_parameterEntry-nbColorParameter,0);
2267 QPushButton* applyButton =
new QPushButton(
"Apply");
2270 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,1);
2272 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2273 signalMapper->setMapping(applyButton, paramWidget);
2274 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2275 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2279 applyButton->setAutoDefault(
TRUE );
2280 applyButton->setDefault(
TRUE );
2281 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,0);
2283 QPushButton* cancelButton =
new QPushButton( tr(
"&Cancel" ));
2284 cancelButton->setAutoDefault(
TRUE );
2285 gridLayout->addWidget(cancelButton,n_parameterEntry-nbColorParameter,1);
2287 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2288 signalMapper->setMapping(applyButton, paramWidget);
2289 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2290 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2292 QWidget * parentCheck = aParent;
2293 QDialog* parentDialog = NULL;
2295 while ((parentCheck->parentWidget()) != NULL) {
2296 parentCheck = parentCheck->parentWidget();
2297 parentDialog =
dynamic_cast<QDialog*
>(parentCheck);
2299 connect( applyButton, SIGNAL( clicked() ), parentDialog, SLOT( accept() ) );
2300 connect( cancelButton, SIGNAL( clicked() ), parentDialog, SLOT( reject() ) );
2309 if (!aParent->layout()) {
2310 aParent->setLayout(
new QVBoxLayout());
2312 aParent->layout()->addWidget(paramWidget);
2323 QTreeWidgetItem* G4UIQt::FindTreeItem(
2324 QTreeWidgetItem *aParent
2325 ,
const QString& aCommand
2328 if (aParent == NULL)
return NULL;
2331 QString myCommand = aCommand;
2333 if (myCommand.lastIndexOf(
"/") == (myCommand.size()-1)) {
2334 myCommand = myCommand.left(myCommand.size()-1);
2337 if (GetLongCommandPath(aParent) == myCommand)
2340 QTreeWidgetItem * tmp = NULL;
2341 for (
int a=0;
a<aParent->childCount();
a++) {
2343 tmp = FindTreeItem(aParent->child(
a),myCommand);
2357 QString G4UIQt::GetCommandList (
2363 if (aCommand == NULL)
2371 if ((commandPath ==
"") &&
2372 (rangeString ==
"") &&
2373 (n_guidanceEntry == 0) &&
2374 (n_parameterEntry == 0)) {
2378 if((commandPath.length()-1)!=
'/') {
2379 txt +=
"Command " + QString((
char*)(commandPath).data()) +
"\n";
2381 txt +=
"Guidance :\n";
2383 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2384 txt += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
2386 if( ! rangeString.
isNull() ) {
2387 txt +=
" Range of parameters : " + QString((
char*)(rangeString).data()) +
"\n";
2389 if( n_parameterEntry > 0 ) {
2394 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2396 txt +=
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) +
"\n";
2399 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2401 txt +=
" Omittable : True\n";
2403 txt +=
" Omittable : False\n";
2406 txt +=
" Default value : taken from the current value\n";
2408 txt +=
" Default value : " + QString((
char*)(param->
GetDefaultValue()).data())+
"\n";
2411 txt +=
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data())+
"\n";
2427 G4bool G4UIQt::IsGUICommand(
2431 if (aCommand == NULL)
2436 if( n_parameterEntry > 0 ) {
2441 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2463 G4bool G4UIQt::GetHelpChoice(
2478 bool G4UIQt::eventFilter(
2483 bool moveCommandCursor =
false;
2484 if (aObj == NULL)
return false;
2485 if (aEvent == NULL)
return false;
2487 if (aObj == fHistoryTBTableList) {
2488 if (aEvent->type() == QEvent::KeyPress) {
2489 fCommandArea->setFocus();
2492 if (aObj == fCommandArea) {
2493 if (aEvent->type() == QEvent::KeyPress) {
2494 QKeyEvent *e =
static_cast<QKeyEvent*
>(aEvent);
2495 if ((e->key() == (Qt::Key_Down)) ||
2496 (e->key() == (Qt::Key_PageDown)) ||
2497 (e->key() == (Qt::Key_Up)) ||
2498 (e->key() == (Qt::Key_PageUp))) {
2499 int selection = fHistoryTBTableList->currentRow();
2500 if (fHistoryTBTableList->count()) {
2501 if (selection == -1) {
2502 selection = fHistoryTBTableList->count()-1;
2504 if (e->key() == (Qt::Key_Down)) {
2505 if (selection <(fHistoryTBTableList->count()-1))
2507 }
else if (e->key() == (Qt::Key_PageDown)) {
2508 selection = fHistoryTBTableList->count()-1;
2509 }
else if (e->key() == (Qt::Key_Up)) {
2512 }
else if (e->key() == (Qt::Key_PageUp)) {
2516 fHistoryTBTableList->clearSelection();
2517 #if QT_VERSION < 0x040202
2518 fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),
true);
2520 fHistoryTBTableList->item(selection)->setSelected(
true);
2522 fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
2524 moveCommandCursor =
true;
2525 }
else if (e->key() == (Qt::Key_Tab)) {
2526 G4String ss = Complete(fCommandArea->text().toStdString().c_str());
2527 fCommandArea->setText((
char*)(ss.
data()));
2533 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
2534 fCommandArea->home(
false);
2536 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
2537 fCommandArea->end(
false);
2544 if (moveCommandCursor ==
true) {
2545 fCommandArea->setCursorPosition ( fCommandArea->text().length() );
2546 fCommandArea->setCursorPosition (4);
2549 res = QObject::eventFilter(aObj, aEvent);
2565 void G4UIQt::ShowHelpCallback (
2574 void G4UIQt::ClearButtonCallback (
2577 fCoutTBTextArea->clear();
2583 void G4UIQt::ExitSession (
2589 void G4UIQt::ExitHelp(
2597 void G4UIQt::CommandEnteredCallback (
2601 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
2604 for (
int a=0;
a< list.size();
a++) {
2605 QString txt (list[
a].trimmed());
2607 fHistoryTBTableList->addItem(txt);
2608 fHistoryTBTableList->clearSelection();
2609 fHistoryTBTableList->setCurrentItem(NULL);
2610 fCommandArea->setText(
"");
2611 G4Qt* interactorManager = G4Qt::getInstance ();
2612 if (interactorManager) {
2613 interactorManager->FlushAndWaitExecution();
2616 G4String command = txt.toStdString().c_str();
2617 if (command(0,4) !=
"help") {
2618 ApplyShellCommand (command,exitSession,exitPause);
2620 ActivateCommand(command);
2628 if(exitSession==
true)
2637 void G4UIQt::CommandEditedCallback(
const QString &)
2639 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
2641 if (list.size() > 1) {
2642 for (
int a=0;
a<list.size()-1;
a++) {
2644 fCommandArea->setText(list[
a]);
2646 CommandEnteredCallback();
2649 fCommandArea->setText(list[list.size()-1]);
2656 void G4UIQt::VisParameterCallback(QWidget* widget){
2657 if (widget == NULL) {
2662 QGridLayout* grid =
dynamic_cast<QGridLayout*
>(widget->layout());
2667 #if QT_VERSION < 0x040400
2668 QWidget* name = grid->itemAt(grid->columnCount()*(grid->rowCount()-2))->widget();
2670 QWidget* name = grid->itemAtPosition(grid->rowCount()-1,0)->widget();
2672 if (dynamic_cast<QLabel*>(name) == 0) {
2675 command += (
dynamic_cast<QLabel*
>(
name))->text()+
" ";
2677 for (
int a=0;
a<grid->rowCount()-1;
a++) {
2678 #if QT_VERSION < 0x040400
2679 QWidget* widgetTmp = grid->itemAt(
a*grid->columnCount()+1)->widget();
2681 QWidget* widgetTmp = grid->itemAtPosition(
a,1)->widget();
2685 if (widgetTmp != NULL) {
2687 if (dynamic_cast<QLineEdit*>(widgetTmp) != 0) {
2688 command += (
dynamic_cast<QLineEdit*
>(widgetTmp))->text()+
" ";
2690 }
else if (dynamic_cast<QComboBox*>(widgetTmp) != 0){
2691 command += (
dynamic_cast<QComboBox*
>(widgetTmp))->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex())+
" ";
2694 }
else if (dynamic_cast<QPushButton*>(widgetTmp) != 0){
2695 command += widgetTmp->accessibleName()+
" ";
2698 }
else if (dynamic_cast<QWidget*>(widgetTmp) != 0){
2699 if (widgetTmp->layout()->count() > 0){
2700 if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != 0) {
2701 QAbstractButton * checked = (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton();
2703 command += (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton()->text()+
" ";
2711 if (command !=
"") {
2725 void G4UIQt::ButtonCallback (
2726 const QString& aCommand
2733 if(UI==NULL)
return;
2740 if (IsGUICommand(command)) {
2741 QDialog* menuParameterDialog =
new QDialog();
2743 if (CreateVisCommandGroupAndToolBox(command,menuParameterDialog,1,
true)) {
2744 menuParameterDialog->setWindowTitle (aCommand);
2745 menuParameterDialog->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
2748 menuParameterDialog->exec();
2754 ApplyShellCommand(ss,exitSession,exitPause);
2759 if(exitSession==
true)
2767 void G4UIQt::HelpTreeClicCallback (
2770 QTreeWidgetItem* item = NULL;
2771 if (!fHelpTreeWidget)
2777 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
2780 item = list.first();
2785 if(UI==NULL)
return;
2788 std::string itemText = GetLongCommandPath(item).toStdString();
2791 if (item->childCount() > 0) {
2797 #if QT_VERSION < 0x040200
2799 fHelpArea->append(GetCommandList(command));
2801 fHelpArea->setText(GetCommandList(command));
2808 #if QT_VERSION < 0x040200
2820 void G4UIQt::HelpTreeDoubleClicCallback (
2823 HelpTreeClicCallback();
2825 QTreeWidgetItem* item = NULL;
2826 if (!fHelpTreeWidget)
2832 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
2835 item = list.first();
2839 fCommandArea->clear();
2840 fCommandArea->setText(GetLongCommandPath(item));
2847 void G4UIQt::CommandHistoryCallback(
2850 QListWidgetItem* item = NULL;
2851 if (!fHistoryTBTableList)
2855 QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
2858 item = list.first();
2861 fCommandArea->setText(item->text());
2865 void G4UIQt::CoutFilterCallback(
2866 const QString & text) {
2868 QStringList result = fG4cout.filter(text);
2869 fCoutTBTextArea->setPlainText(result.join(
"\n"));
2871 fCoutTBTextArea->repaint();
2872 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
2880 void G4UIQt::LookForHelpStringCallback(
2883 QString searchText = fHelpLine->text();
2885 #if QT_VERSION < 0x040200
2888 fHelpArea->setText(
"");
2890 if (searchText ==
"") {
2892 fHelpTreeWidget->clear();
2898 OpenHelpTreeOnCommand(searchText);
2903 void G4UIQt::OpenHelpTreeOnCommand(
2904 const QString & searchText
2909 if(UI==NULL)
return;
2915 fHelpTreeWidget->clear();
2921 QMap<int,QString> commandResultMap;
2922 QMap<int,QString> commandChildResultMap;
2924 for (
int a=0;
a<treeSize;
a++) {
2926 tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
2928 commandResultMap.insertMulti(tmp,QString((
char*)(treeTop->
GetTree(
a+1)->
GetPathName()).data()));
2931 commandChildResultMap = LookForHelpStringInChildTree(treeTop->
GetTree(
a+1),searchText);
2933 if (!commandChildResultMap.empty()) {
2934 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
2935 while (i != commandChildResultMap.constEnd()) {
2936 commandResultMap.insertMulti(i.key(),i.value());
2939 commandChildResultMap.clear();
2944 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2945 fHelpTreeWidget->setColumnCount(2);
2947 labels << QString(
"Command") << QString(
"Match");
2948 fHelpTreeWidget->setHeaderLabels(labels);
2950 if (commandResultMap.empty()) {
2951 #if QT_VERSION < 0x040200
2953 fHelpArea->append(
"No match found");
2955 fHelpArea->setText(
"No match found");
2960 QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
2963 float multValue = 10.0/(float)(i.key());
2964 QString progressChar =
"|";
2965 QString progressStr =
"|";
2967 QTreeWidgetItem * newItem;
2970 if (i == commandResultMap.constBegin()) {
2973 for(
int a=0;
a<int(i.key()*multValue);
a++) {
2974 progressStr += progressChar;
2976 newItem =
new QTreeWidgetItem();
2977 QString commandStr = i.value().trimmed();
2979 if (commandStr.indexOf(
"/") == 0) {
2980 commandStr = commandStr.right(commandStr.size()-1);
2983 newItem->setText(0,commandStr);
2984 newItem->setText(1,progressStr);
2985 fHelpTreeWidget->addTopLevelItem(newItem);
2986 #if QT_VERSION < 0x040200
2988 newItem->setForeground ( 1, QBrush(
Qt::blue) );
2993 fHelpTreeWidget->resizeColumnToContents (0);
2994 fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
3001 QMap<int,QString> G4UIQt::LookForHelpStringInChildTree(
3003 ,
const QString & text
3006 QMap<int,QString> commandResultMap;
3007 if (aCommandTree == NULL)
return commandResultMap;
3012 QMap<int,QString> commandChildResultMap;
3016 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
3018 commandResultMap.insertMulti(tmp,QString((
char*)(aCommandTree->
GetTree(
a+1)->
GetPathName()).data()));
3021 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->
GetTree(
a+1),text);
3023 if (!commandChildResultMap.empty()) {
3025 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
3026 while (i != commandChildResultMap.constEnd()) {
3027 commandResultMap.insertMulti(i.key(),i.value());
3030 commandChildResultMap.clear();
3037 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
3043 return commandResultMap;
3047 QString G4UIQt::GetShortCommandPath(
3051 if (commandPath.indexOf(
"/") == 0) {
3052 commandPath = commandPath.right(commandPath.size()-1);
3055 commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf(
"/",-2)-1);
3057 if (commandPath.lastIndexOf(
"/") == (commandPath.size()-1)) {
3058 commandPath = commandPath.left(commandPath.size()-1);
3065 QString G4UIQt::GetLongCommandPath(
3066 QTreeWidgetItem* item
3069 if (item == NULL)
return "";
3072 QString itemText =
"";
3073 itemText = item->text(0);
3075 while (item->parent() != NULL) {
3076 itemText = item->parent()->text(0)+
"/"+itemText;
3077 item = item->parent();
3079 itemText =
"/"+itemText;
3085 void G4UIQt::ChangeColorCallback(QWidget* widget) {
3086 if (widget == NULL) {
3090 QPushButton* button =
dynamic_cast<QPushButton*
>(widget);
3094 QString value = button->accessibleName();
3097 old.setRgbF(value.section(
" ",0,1).toDouble(),
3098 value.section(
" ",1,2).toDouble(),
3099 value.section(
" ",2,3).toDouble());
3100 #if QT_VERSION < 0x040500
3102 QColor color = QColor(QColorDialog::getRgba (old.rgba(),&
a,fUITabWidget));
3104 QColor color = QColorDialog::getColor(old,
3107 QColorDialog::ShowAlphaChannel);
3111 if (color.isValid()) {
3113 QPixmap pixmap = QPixmap(QSize(16, 16));
3114 pixmap.fill (color);
3115 QPainter painter(&pixmap);
3116 painter.setPen(Qt::black);
3117 painter.drawRect(0,0,15,15);
3119 button->setAccessibleName(QString::number(color.redF())+
" "+
3120 QString::number(color.greenF())+
" "+
3121 QString::number(color.blueF())+
" "
3123 button->setIcon(pixmap);
3130 void G4UIQt::ChangeCursorStyle(
const QString& action) {
3134 fMoveSelected =
true;
3135 fPickSelected =
true;
3136 fRotateSelected =
true;
3137 fZoomInSelected =
true;
3138 fZoomOutSelected =
true;
3140 if (fToolbarApp == NULL)
return;
3141 QList<QAction *> list = fToolbarApp->actions ();
3142 for (
int i = 0; i < list.size(); ++i) {
3143 if (list.at(i)->data().toString () == action) {
3144 list.at(i)->setChecked(
TRUE);
3145 }
else if (list.at(i)->data().toString () ==
"move") {
3146 fMoveSelected =
false;
3147 list.at(i)->setChecked(
FALSE);
3148 }
else if (list.at(i)->data().toString () ==
"pick") {
3149 fPickSelected =
false;
3150 list.at(i)->setChecked(
FALSE);
3151 }
else if (list.at(i)->data().toString () ==
"rotate") {
3152 fRotateSelected =
false;
3153 list.at(i)->setChecked(
FALSE);
3154 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3155 fZoomInSelected =
false;
3156 list.at(i)->setChecked(
FALSE);
3157 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3158 fZoomOutSelected =
false;
3159 list.at(i)->setChecked(
FALSE);
3172 void G4UIQt::ChangeSurfaceStyle(
const QString& action) {
3176 if (fToolbarApp == NULL)
return;
3177 QList<QAction *> list = fToolbarApp->actions ();
3178 for (
int i = 0; i < list.size(); ++i) {
3179 if (list.at(i)->data().toString () == action) {
3180 list.at(i)->setChecked(
TRUE);
3181 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3182 list.at(i)->setChecked(
FALSE);
3183 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3184 list.at(i)->setChecked(
FALSE);
3185 }
else if (list.at(i)->data().toString () ==
"solid") {
3186 list.at(i)->setChecked(
FALSE);
3187 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3188 list.at(i)->setChecked(
FALSE);
3193 if (action ==
"hidden_line_removal") {
3197 }
else if (action ==
"hidden_line_and_surface_removal") {
3201 }
else if (action ==
"solid") {
3205 }
else if (action ==
"wireframe") {
3212 void G4UIQt::OpenIconCallback(
const QString& aParam) {
3214 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
3215 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
3217 QString nomFich = QFileDialog::getOpenFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
3218 if (nomFich !=
"") {
3221 fLastOpenPath = dir.absoluteFilePath(nomFich);
3226 void G4UIQt::SaveIconCallback(
const QString& aParam) {
3228 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
3229 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
3231 QString nomFich = QFileDialog::getSaveFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
3232 if (nomFich !=
"") {
3235 fLastOpenPath = dir.absoluteFilePath(nomFich);
3241 void G4UIQt::ChangePerspectiveOrtho(
const QString& action) {
3245 if (fToolbarApp == NULL)
return;
3246 QList<QAction *> list = fToolbarApp->actions ();
3247 QString checked =
"";
3248 for (
int i = 0; i < list.size(); ++i) {
3249 if (list.at(i)->data().toString () == action) {
3250 list.at(i)->setChecked(
TRUE);
3251 checked = list.at(i)->data().toString ();
3252 }
else if (list.at(i)->data().toString () ==
"persepective") {
3253 list.at(i)->setChecked(
FALSE);
3254 }
else if (list.at(i)->data().toString () ==
"ortho") {
3255 list.at(i)->setChecked(
FALSE);
3259 if ((action ==
"ortho") && (checked ==
"ortho")) {
3261 }
else if ((action ==
"perspective") && (checked ==
"perspective")) {
3268 void G4UIQt::SetIconMoveSelected() {
3270 fMoveSelected =
true;
3271 fRotateSelected =
false;
3272 fPickSelected =
false;
3273 fZoomInSelected =
false;
3274 fZoomOutSelected =
false;
3276 if (fToolbarApp == NULL)
return;
3277 QList<QAction *> list = fToolbarApp->actions ();
3278 for (
int i = 0; i < list.size(); ++i) {
3279 if (list.at(i)->data().toString () ==
"move") {
3280 list.at(i)->setChecked(
TRUE);
3281 }
else if (list.at(i)->data().toString () ==
"rotate") {
3282 list.at(i)->setChecked(
FALSE);
3283 }
else if (list.at(i)->data().toString () ==
"pick") {
3284 list.at(i)->setChecked(
FALSE);
3285 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3286 list.at(i)->setChecked(
FALSE);
3287 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3288 list.at(i)->setChecked(
FALSE);
3294 void G4UIQt::SetIconRotateSelected() {
3296 fRotateSelected =
true;
3297 fMoveSelected =
false;
3298 fPickSelected =
false;
3299 fZoomInSelected =
false;
3300 fZoomOutSelected =
false;
3302 if (fToolbarApp == NULL)
return;
3303 QList<QAction *> list = fToolbarApp->actions ();
3304 for (
int i = 0; i < list.size(); ++i) {
3305 if (list.at(i)->data().toString () ==
"rotate") {
3306 list.at(i)->setChecked(
TRUE);
3307 }
else if (list.at(i)->data().toString () ==
"move") {
3308 list.at(i)->setChecked(
FALSE);
3309 }
else if (list.at(i)->data().toString () ==
"pick") {
3310 list.at(i)->setChecked(
FALSE);
3311 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3312 list.at(i)->setChecked(
FALSE);
3313 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3314 list.at(i)->setChecked(
FALSE);
3320 void G4UIQt::SetIconPickSelected() {
3322 fPickSelected =
true;
3323 fMoveSelected =
false;
3324 fRotateSelected =
false;
3325 fZoomInSelected =
false;
3326 fZoomOutSelected =
false;
3328 if (fToolbarApp == NULL)
return;
3329 QList<QAction *> list = fToolbarApp->actions ();
3330 for (
int i = 0; i < list.size(); ++i) {
3331 if (list.at(i)->data().toString () ==
"pick") {
3332 list.at(i)->setChecked(
TRUE);
3333 }
else if (list.at(i)->data().toString () ==
"move") {
3334 list.at(i)->setChecked(
FALSE);
3335 }
else if (list.at(i)->data().toString () ==
"rotate") {
3336 list.at(i)->setChecked(
FALSE);
3337 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3338 list.at(i)->setChecked(
FALSE);
3339 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3340 list.at(i)->setChecked(
FALSE);
3346 void G4UIQt::SetIconZoomInSelected() {
3348 fZoomInSelected =
true;
3349 fMoveSelected =
false;
3350 fRotateSelected =
false;
3351 fPickSelected =
false;
3352 fZoomOutSelected =
false;
3354 if (fToolbarApp == NULL)
return;
3355 QList<QAction *> list = fToolbarApp->actions ();
3356 for (
int i = 0; i < list.size(); ++i) {
3357 if (list.at(i)->data().toString () ==
"zoom_in") {
3358 list.at(i)->setChecked(
TRUE);
3359 }
else if (list.at(i)->data().toString () ==
"move") {
3360 list.at(i)->setChecked(
FALSE);
3361 }
else if (list.at(i)->data().toString () ==
"rotate") {
3362 list.at(i)->setChecked(
FALSE);
3363 }
else if (list.at(i)->data().toString () ==
"pick") {
3364 list.at(i)->setChecked(
FALSE);
3365 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3366 list.at(i)->setChecked(
FALSE);
3372 void G4UIQt::SetIconZoomOutSelected() {
3374 fZoomOutSelected =
true;
3375 fMoveSelected =
false;
3376 fRotateSelected =
false;
3377 fPickSelected =
false;
3378 fZoomInSelected =
false;
3380 if (fToolbarApp == NULL)
return;
3381 QList<QAction *> list = fToolbarApp->actions ();
3382 for (
int i = 0; i < list.size(); ++i) {
3383 if (list.at(i)->data().toString () ==
"zoom_out") {
3384 list.at(i)->setChecked(
TRUE);
3385 }
else if (list.at(i)->data().toString () ==
"move") {
3386 list.at(i)->setChecked(
FALSE);
3387 }
else if (list.at(i)->data().toString () ==
"rotate") {
3388 list.at(i)->setChecked(
FALSE);
3389 }
else if (list.at(i)->data().toString () ==
"pick") {
3390 list.at(i)->setChecked(
FALSE);
3391 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3392 list.at(i)->setChecked(
FALSE);
3398 void G4UIQt::SetIconSolidSelected() {
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 () ==
"solid") {
3405 list.at(i)->setChecked(
TRUE);
3406 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3407 list.at(i)->setChecked(
FALSE);
3408 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3409 list.at(i)->setChecked(
FALSE);
3410 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3411 list.at(i)->setChecked(
FALSE);
3417 void G4UIQt::SetIconWireframeSelected() {
3420 if (fToolbarApp == NULL)
return;
3421 QList<QAction *> list = fToolbarApp->actions ();
3422 for (
int i = 0; i < list.size(); ++i) {
3423 if (list.at(i)->data().toString () ==
"wireframe") {
3424 list.at(i)->setChecked(
TRUE);
3425 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3426 list.at(i)->setChecked(
FALSE);
3427 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3428 list.at(i)->setChecked(
FALSE);
3429 }
else if (list.at(i)->data().toString () ==
"solid") {
3430 list.at(i)->setChecked(
FALSE);
3436 void G4UIQt::SetIconHLRSelected() {
3439 if (fToolbarApp == NULL)
return;
3440 QList<QAction *> list = fToolbarApp->actions ();
3441 for (
int i = 0; i < list.size(); ++i) {
3442 if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3443 list.at(i)->setChecked(
TRUE);
3444 }
else if (list.at(i)->data().toString () ==
"solid") {
3445 list.at(i)->setChecked(
FALSE);
3446 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3447 list.at(i)->setChecked(
FALSE);
3448 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3449 list.at(i)->setChecked(
FALSE);
3455 void G4UIQt::SetIconHLHSRSelected() {
3458 if (fToolbarApp == NULL)
return;
3459 QList<QAction *> list = fToolbarApp->actions ();
3460 for (
int i = 0; i < list.size(); ++i) {
3461 if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3462 list.at(i)->setChecked(
TRUE);
3463 }
else if (list.at(i)->data().toString () ==
"solid") {
3464 list.at(i)->setChecked(
FALSE);
3465 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3466 list.at(i)->setChecked(
FALSE);
3467 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3468 list.at(i)->setChecked(
FALSE);
3474 void G4UIQt::SetIconPerspectiveSelected() {
3477 if (fToolbarApp == NULL)
return;
3478 QList<QAction *> list = fToolbarApp->actions ();
3479 for (
int i = 0; i < list.size(); ++i) {
3480 if (list.at(i)->data().toString () ==
"perspective") {
3481 list.at(i)->setChecked(
TRUE);
3482 }
else if (list.at(i)->data().toString () ==
"ortho") {
3483 list.at(i)->setChecked(
FALSE);
3490 void G4UIQt::SetIconOrthoSelected() {
3493 if (fToolbarApp == NULL)
return;
3494 QList<QAction *> list = fToolbarApp->actions ();
3495 for (
int i = 0; i < list.size(); ++i) {
3496 if (list.at(i)->data().toString () ==
"ortho") {
3497 list.at(i)->setChecked(
TRUE);
3498 }
else if (list.at(i)->data().toString () ==
"perspective") {
3499 list.at(i)->setChecked(
FALSE);
3506 G4QTabWidget::G4QTabWidget(
3510 ):QTabWidget(aParent)
3511 ,fTabSelected(false)
3513 ,fPreferedSizeX(sizeX+6)
3514 ,fPreferedSizeY(sizeY+58)
3516 setMinimumSize(100,100);
3517 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
3518 setSizePolicy(policy);
3521 G4QTabWidget::G4QTabWidget(
3523 ,fTabSelected(false)
3532 #if QT_VERSION < 0x040500
3533 void G4UIQt::TabCloseCallback(
int){
3535 void G4UIQt::TabCloseCallback(
int a){
3537 #if QT_VERSION < 0x040500
3539 if (fViewerTabWidget == NULL)
return;
3542 QWidget* temp = fViewerTabWidget->widget(a);
3544 fViewerTabWidget->removeTab (a);
3550 if (fViewerTabWidget->count() == 0) {
3551 if (fEmptyViewerTabLabel == NULL) {
3552 fEmptyViewerTabLabel =
new QLabel(
"If you want to have a Viewer, please use /vis/open commands.");
3555 fViewerTabHandleWidget->layout()->removeWidget(fViewerTabWidget);
3557 fViewerTabHandleWidget->layout()->addWidget(fEmptyViewerTabLabel);
3559 fEmptyViewerTabLabel->show();
3565 void G4UIQt::ToolBoxActivated(
int a){
3567 if (fUITabWidget->widget(a) == fHelpTBWidget) {
3570 }
else if (fUITabWidget->widget(a) == fSceneTreeComponentsTBWidget) {
3571 #if QT_VERSION < 0x040200
3572 fSceneTreeComponentsTBWidget->show();
3574 fSceneTreeComponentsTBWidget->setVisible(
true);
3580 void G4QTabWidget::paintEvent(
3585 if (currentWidget()) {
3587 if ( isTabSelected()) {
3591 QString text = tabText (currentIndex());
3593 if (fLastCreated == -1) {
3594 QString paramSelect = QString(
"/vis/viewer/select ")+text;
3602 setTabSelected(
false);
G4UIcommandTree * FindCommandTree(const char *commandPath)
Try to match a command or a path with the one given.
G4String GetParameterCandidates() const
const G4String & GetRange() const
G4UIcommand * FindPath(const char *commandPath) const
G4String strip(G4int strip_Type=trailing, char c=' ')
G4int GetCommandEntry() const
G4String GetParameterName() const
G4UIcommand * GetCommand(G4int i)
G4int GetTreeEntry() const
G4int GetVerboseLevel() const
void SetSession(G4UIsession *const value)
const G4String & GetGuidanceLine(G4int i) const
void SetG4UIWindow(G4UIsession *const value)
static G4UImanager * GetUIpointer()
G4bool IsOmittable() const
static G4StateManager * GetStateManager()
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4UIcommandTree * GetTree(G4int i)
G4UIparameter * GetParameter(G4int i) const
const G4String & GetCommandPath() const
G4ApplicationState GetCurrentState() const
const G4String GetPathName() const
const char * data() const
const G4String GetTitle() const
G4UIcommandTree * GetTree() const
G4String GetDefaultValue() const
void SetCoutDestination(G4UIsession *const value)
const G4UIcommand * GetGuidance() const
char GetParameterType() const
const G4String GetParameterGuidance() const
G4String GetParameterRange() const
G4int GetGuidanceEntries() const
G4int GetParameterEntries() const
G4bool GetCurrentAsDefault() const
G4int ApplyCommand(const char *aCommand)