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);
437 fViewerTabHandleWidget->setMinimumSize(40,40);
439 commandLineWidget->setMinimumSize(50,50);
442 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
443 connect(fCommandArea, SIGNAL(textEdited(
const QString &)), SLOT(CommandEditedCallback(
const QString &)));
445 fRightSplitterWidget->resize(200,200);
446 return fRightSplitterWidget;
452 QTabWidget* G4UIQt::GetSceneTreeComponentsTBWidget(
455 return fSceneTreeComponentsTBWidget;
462 bool G4UIQt::AddTabWidget(
475 #if QT_VERSION < 0x050100
476 #if QT_VERSION >= 0x050000
477 QString message = QString(
478 "This Qt version [")+qVersion ()+
"] has some issues with the OpenGL viewer.\n"+
479 "To prevent problems, you are not allowed to open a Store nor Immediate viewer.\n" +
481 "Please upgrade to Qt version >= 5.1\n";
483 QMessageBox::warning(fMainWindow, tr(
"Warning"),
484 tr(message.toStdString().c_str()),
491 if (fViewerTabWidget == NULL) {
492 fViewerTabWidget =
new G4QTabWidget(fViewerTabHandleWidget, sizeX, sizeY);
493 #if QT_VERSION < 0x040500
495 fViewerTabWidget->setTabsClosable (
true);
498 #if QT_VERSION < 0x040200
500 fViewerTabWidget->setUsesScrollButtons (
true);
503 #if QT_VERSION < 0x040500
505 connect(fViewerTabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(TabCloseCallback(
int)));
507 connect(fViewerTabWidget, SIGNAL(currentChanged (
int ) ), SLOT(UpdateTabWidget(
int)));
514 fViewerTabWidget->addTab(aWidget,name);
520 if (fEmptyViewerTabLabel != NULL) {
522 index = fViewerTabHandleWidget->layout()->indexOf(fEmptyViewerTabLabel);
524 fViewerTabHandleWidget->layout()->removeWidget(fEmptyViewerTabLabel);
525 delete fEmptyViewerTabLabel;
526 fEmptyViewerTabLabel = NULL;
527 printf(
"fViewerTabHandleWidget :%d %d\n",fViewerTabHandleWidget->width(), fViewerTabHandleWidget->height());
529 fViewerTabHandleWidget->layout()->addWidget(fViewerTabWidget);
530 printf(
"fViewerTabHandleWidget :%d %d\n",fViewerTabHandleWidget->width(), fViewerTabHandleWidget->height());
536 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
539 #if QT_VERSION < 0x040200
540 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
542 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
550 QSize
s = QSize(sizeX,sizeY);
552 QRect screen = QApplication::desktop()->screenGeometry();
554 if (fMainWindow->width()-fViewerTabWidget->width()+sizeX > screen.width()) {
555 s.setWidth(screen.width()-fMainWindow->width()+fViewerTabWidget->width());
557 if (fMainWindow->height()-fViewerTabWidget->height()+sizeY > screen.height()-24) {
558 s.setHeight(screen.height()-fMainWindow->height()+fViewerTabWidget->height()-24);
560 int winWidth = fMainWindow->width();
561 int winHeight = fMainWindow->height();
562 int oldTabWidth = fViewerTabWidget->width();
563 int oldTabHeight = fViewerTabWidget->height();
564 int newTabWidth = fViewerTabWidget->sizeHint().width();
565 int newTabHeight = fViewerTabWidget->sizeHint().height();
567 fViewerTabWidget->setPreferredSize(s);
568 fMainWindow->resize(winWidth-oldTabWidth+newTabWidth,
569 winHeight-oldTabHeight+newTabHeight);
574 void G4UIQt::UpdateTabWidget(
int tabNumber) {
575 if ( fViewerTabWidget == NULL) {
576 fViewerTabWidget =
new G4QTabWidget;
579 fViewerTabWidget->setCurrentIndex(tabNumber);
582 fViewerTabWidget->setTabSelected(
false);
584 #if QT_VERSION < 0x040200
585 fViewerTabWidget->show();
587 fViewerTabWidget->setVisible(
true);
591 fViewerTabWidget->setTabSelected(
true);
597 void G4UIQt::ResizeTabWidget( QResizeEvent* e) {
598 if ( fViewerTabWidget) {
599 for (
G4int a=0;
a<fViewerTabWidget->count() ;
a++) {
600 fViewerTabWidget->widget(
a)->resize(e->size());
611 G4Qt* interactorManager = G4Qt::getInstance ();
615 QCoreApplication::sendPostedEvents () ;
617 #if QT_VERSION < 0x040200
620 fMainWindow->setVisible(
true);
622 interactorManager->DisableSecondaryLoop ();
623 if ((QApplication*)interactorManager->GetMainInteractor())
624 ((QApplication*)interactorManager->GetMainInteractor())->exec();
626 interactorManager->EnableSecondaryLoop ();
636 void G4UIQt::Prompt (
640 if (!aPrompt)
return;
642 fCommandLabel->setText((
char*)aPrompt.
data());
647 void G4UIQt::SessionTerminate (
650 G4Qt* interactorManager = G4Qt::getInstance ();
651 fMainWindow->close();
652 ((QApplication*)interactorManager->GetMainInteractor())->exit();
665 void G4UIQt::PauseSessionStart (
671 if(aState==
"G4_pause> ") {
672 SecondaryLoop (
"Pause, type continue to exit this state");
675 if(aState==
"EndOfEvent") {
677 SecondaryLoop (
"End of event, type continue to exit this state");
687 void G4UIQt::SecondaryLoop (
691 if (!aPrompt)
return;
693 G4Qt* interactorManager = G4Qt::getInstance ();
697 ((QApplication*)interactorManager)->processEvents(QEventLoop::WaitForMoreEvents);
698 if(exitPause==
true)
break;
710 G4int G4UIQt::ReceiveG4cout (
714 if (!aString)
return 0;
719 newStr = QStringList(QString((
char*)aString.
data()).trimmed());
722 QStringList
result = newStr.filter(fCoutFilter->text());
724 if (result.join(
"").isEmpty()) {
727 fCoutTBTextArea->append(result.join(
""));
728 fCoutTBTextArea->repaint();
730 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
741 G4int G4UIQt::ReceiveG4cerr (
745 if (!aString)
return 0;
750 newStr = QStringList(QString((
char*)aString.
data()).trimmed());
753 QStringList result = newStr.filter(fCoutFilter->text());
756 if (QString(aString.
data()).trimmed() !=
"") {
760 QMessageBox::critical(fMainWindow,
"Error",QString(fLastErrMessage.data())+
"\n"+aString.
data());
763 QColor previousColor = fCoutTBTextArea->textColor();
764 fCoutTBTextArea->setTextColor(
Qt::red);
765 fCoutTBTextArea->append(result.join(
"\n"));
766 fCoutTBTextArea->setTextColor(previousColor);
767 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
768 fCoutTBTextArea->repaint();
770 if (QString(aString.
data()).trimmed() !=
"") {
771 fLastErrMessage = aString;
783 void G4UIQt::AddMenu (
788 if (aName == NULL)
return;
789 if (aLabel == NULL)
return;
791 QMenu *fileMenu =
new QMenu(aLabel);
792 fMainWindow->menuBar()->addMenu(fileMenu);
804 void G4UIQt::AddButton (
807 ,
const char* aCommand
810 if(aMenu==NULL)
return;
811 if(aLabel==NULL)
return;
812 if(aCommand==NULL)
return;
814 QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
816 if(parentTmp==NULL) {
821 G4cout <<
"Menu name " << aMenu<<
" does not exist, please define it before using it."<<
G4endl;
832 G4int cmdEndPos = cmd.find_first_of(
" \t");
833 if(cmdEndPos!=
G4int(std::string::npos)) {
834 cmd.erase(cmdEndPos);
837 if(treeTop->
FindPath(cmd) == NULL) {
842 G4cout <<
"Warning: command '"<< cmd <<
"' does not exist, please define it before using it."<<
G4endl;
846 QSignalMapper *signalMapper =
new QSignalMapper(
this);
847 QAction *action = parentTmp->addAction(aLabel, signalMapper, SLOT(map()));
849 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
850 signalMapper->setMapping(action, QString(aCommand));
859 void G4UIQt::AddIcon(
const char* aLabel,
const char* aIconFile,
const char* aCommand,
const char* aFileName){
860 if(aLabel==NULL)
return;
862 if (aCommand==NULL) {
863 if (std::string(aIconFile) ==
"user_icon") {
868 bool userToolBar =
false;
870 if (std::string(aIconFile) ==
"user_icon") {
872 pix = QPixmap(aFileName);
878 G4cout <<
"Warning: file '"<< aFileName <<
"' is incorrect or does not exist, this command will not be build"<<
G4endl;
883 }
else if (std::string(aIconFile) ==
"open") {
884 const char *
const xpm[]={
928 " {]^/((_({- %%%%%%%%%%% ",
929 " {(^_^^^^:<{{{{{{{{{{{{{[& ",
930 " {/_/(((((/]]]]]]]]]]]/]!# ",
931 " {/^(((((_^^^^^^^^^^^^^^:# ",
932 " {/^(((_^^____________^^}$ ",
933 " {/^(((((/////////////((!# ",
934 " {/^/^_:<|||||||||||||||@@****1 ",
935 " {/^/^(<[)||||||||||||||))!!}<; ",
936 " {/^_(:|234444444444444444432)1 ",
937 " {/_^/<)34444444444444444443}, ",
938 " {/^(2{:41111111111111111142|5 ",
939 " {3^3<:31111111111111111143}- ",
940 " {/^2<:31111111111111111441|' ",
941 " {_/<:41111111111111111143}, ",
942 " {(4<:31111111111111111144!# ",
943 " )4))44111111111111111144}, ",
944 " )2<:31111111111111111144{# ",
945 " @|:14444444444444444444}* ",
946 " ;@434444444444444444434<# ",
947 " ;[))))))))))))))))))))!~ ",
948 " ++++++++++++++++++++++;% ",
954 }
else if (std::string(aIconFile) ==
"save") {
955 const char *
const xpm[]={
983 " +++++++++++++++++++++++++ ",
984 " +@##+$%%%%%%%%%%%%%%%&*$%&+ ",
985 " +=-;@>,,''',,,,,,,',,)&!,)+ ",
986 " +;-~@>,,,,,,,,,,,,,,,>$!,)+ ",
987 " +=-~@>,,,,,{]]]]]^,,,>*&$&+ ",
988 " +=-~@>,,,,,'{^{^^{,,,>*#=#+ ",
989 " +=-~@>,,,,,,,,,,,,,,,>@~/=+ ",
990 " +=-~@>,,,{{{''''{',,,>@~-=+ ",
991 " +=-~@>,,'^]]]]]]({,,,>@~-=+ ",
992 " +=-~@>,,,{{{{{{{{{,,,>@~-=+ ",
993 " +=-~@>,,,,,'{^{{^{,,,>@~-=+ ",
994 " +=-~@>,,,,,]]]]]]],,,>@~-=+ ",
995 " +=-~*>,,,,,,,,,,,,,,,>@~-=+ ",
996 " +=-~@>,,,,,,,,,,,,,,,>@~-=+ ",
997 " +=-/=$%%%%%%%%%%%%%%%$=/-=+ ",
998 " +=---;###############;---=+ ",
999 " +=---////////////////----=+ ",
1000 " +=----------------///----=+ ",
1001 " +=---=@##############@#--=+ ",
1002 " +=---@+++++++++++*%))_+~-=+ ",
1003 " +=---#+++++++++++&:,,>@~-=+ ",
1004 " +=---#+++++++++++$',,>@~-=+ ",
1005 " +=---#+++++++++++&!,,>@~-=+ ",
1006 " +=/--#+++++++++++&',,>@~-=+ ",
1007 " @;--#+++++++++++$',,>@~-=+ ",
1008 " @;;@+++++++++++*)!>%@=;#+ ",
1009 " @++++++++++++++*&**++@++ ",
1015 }
else if (std::string(aIconFile) ==
"move") {
1016 const char *
const xpm[]={
1049 " ')&$$$$*@@ @@*$$$$&)' ",
1050 " ')&$$$$*@@ @@*$$$$&+' ",
1069 }
else if (std::string(aIconFile) ==
"rotate") {
1070 const char *
const xpm[]={
1106 " --------!*{{{*&, ",
1107 " -------=){*{{{>>{) ",
1108 " ,!-----= ){& ,&{{@",
1109 " ,*>!----= &>& )@",
1112 " @{* '! ,-!=~^,@ ",
1113 " @& == {/(----!^ ",
1116 " !-!!======!!(((---! ",
1117 " ='--------------! ",
1134 }
else if (std::string(aIconFile) ==
"pick") {
1135 const char *
const xpm[]={
1173 }
else if (std::string(aIconFile) ==
"zoom_in") {
1174 const char *
const xpm[]={
1196 " ++.%%%+&&&*%%.++ ",
1197 " .+#%%%%+&&&*%%.#+ ",
1198 " ++..%%%+&&&*%%%.++ ",
1199 " +#.+++++&&&*++++.+ ",
1200 " @.+&&&&&&&&&&&&&+@ ",
1201 " @#+&&&&&&&&&&&&&+@ ",
1202 " @.+&&&&&&&&&&&&&+. ",
1203 " +++@***+&&&****@+. ",
1204 " ....++++&&&*++++.. ",
1205 " ++.===+&&&*%=.++ ",
1206 " @..==+&&&*=..@#& ",
1207 " .@+#.+&&&@-+@@*@ ",
1208 " +++.++++++ *+@* ",
1221 }
else if (std::string(aIconFile) ==
"zoom_out") {
1222 const char *
const xpm[]={
1244 " ++.$$$$$$$$$$.++ ",
1245 " .+#$$$$$$$$$$$.#+ ",
1246 " ++..$$$$$$$$$$$.++ ",
1247 " +#.+++++++++++++.+ ",
1248 " @.+&&&&&&&&&&&&&+@ ",
1249 " @#+&&&&&&&&&&&&&+@ ",
1250 " @.+&&&&&&&&&&&&&+. ",
1251 " +++@***********@+. ",
1252 " ....++++++++++++.. ",
1253 " ++.===$$$$$$=.++ ",
1254 " @..===$$$$=..@#& ",
1255 " .@+#.$$$..-+@@*@ ",
1256 " +++#--.+++ *+@* ",
1269 }
else if (std::string(aIconFile) ==
"wireframe") {
1270 const char *
const xpm[]={
1299 " +&********&@-***; ",
1300 " +@@@&**&@@@@@@$ @*-&>&+ ",
1301 " +*****&+ %*@ ,**'# ",
1302 " @***)!~ @*{&*****+ ",
1303 " @*!]***&+ +-*^**'~!*@ ",
1304 " @*~ +@&**&@@@@@@&****&+ ~*@ ",
1305 " @*@ +&********&-*= @*@ ",
1306 " @*@ $%@-*-@$ @*@ @*@ ",
1307 " @*@ @*@ %*% @*@ ",
1308 " @*@ %*% %*% @*@ ",
1309 " @*@ %*% %*% @*@ ",
1310 " @*@ %*% %*% @*@ ",
1311 " @*@ %*% %*% @*@ ",
1312 " @*@ %*% %*% @*@ ",
1313 " @*@ @*@ %*% @*@ ",
1314 " @*@ =*-+ @*@ @*@ ",
1315 " @*@ $%@@&****&@-*-+ @*@ ",
1316 " @*@ $@&*****&@@&******&~~!*@ ",
1317 " @*{/***&@@%$ $@-*-&*****+ ",
1318 " @*)*)(-~ @*@ ~)**] ",
1319 " +*******&@@@@+ %*_+]**] ",
1320 " +@@@@@&******&@%+_*^**]# ",
1321 " $%@@@&****:**&+ ",
1330 }
else if (std::string(aIconFile) ==
"solid") {
1331 const char *
const xpm[]={
1369 " +-;>>>>>>>>>,')!~ ",
1370 " {]@@-;>>>>>>>>>>>>^/(_= ",
1371 " {:>>>>>>>>>>>>>>>>><//[)!= ",
1372 " ]>>>>>>>>>>>>>>>>>><////[)} ",
1373 " @>>>>>>>>>>>>>>>>>><//////| ",
1374 " @>>>>>>>>>>>>>>>>>><//////| ",
1375 " @>>>>>>>>>>>>>>>>>><//////| ",
1376 " @>>>>>>>>>>>>>>>>>><//////| ",
1377 " @>>>>>>>>>>>>>>>>>><//////| ",
1378 " @>>>>>>>>>>>>>>>>>><//////| ",
1379 " @>>>>>>>>>>>>>>>>>><//////| ",
1380 " @>>>>>>>>>>>>>>>>>><//////| ",
1381 " @>>>>>>>>>>>>>>>>>><//////| ",
1382 " @>>>>>>>>>>>>>>>>>><//////| ",
1383 " @>>>>>>>>>>>>>>>>>><//////| ",
1384 " @>>>>>>>>>>>>>>>>>><//////| ",
1385 " @>>>>>>>>>>>>>>>>>><//////| ",
1386 " @>>>>>>>>>>>>>>>>>><//////| ",
1387 " @>>>>>>>>>>>>>>>>>></////[1 ",
1388 " @>>>>>>>>>>>>>>>>>><////[*2 ",
1389 " {:>>>>>>>>>>>>>>>>><//[)12 ",
1390 " +@@@@@-;>>>>>>>>>><[)13 ",
1400 }
else if (std::string(aIconFile) ==
"hidden_line_removal") {
1401 const char *
const xpm[]={
1421 " +#$$$$$$$$#@&$$$* ",
1422 " =-@@#$$#@@@@@-= @$&#;>= ",
1423 " =$$$$$#+ -$@ *$$%+ ",
1424 " -$&@-= -$- #$$$= ",
1440 " -$&@@@-= -$- =>;, ",
1441 " =$$$$$$$#@@@-= -$'+#$$, ",
1442 " =-@@@@#$$$$$$#@-+'$)$$#+ ",
1443 " =-@@@#$$$$)$$#+ ",
1452 }
else if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
1453 const char *
const xpm[]={
1499 " ++@%####&*=-#+;>, ",
1500 " +++++@'=)))))))!)~+{]^++ ",
1501 " +$%&*=)!!!!!!!!!)~+/(]_+++ ",
1502 " +#-))!!!!!!!!!!!)~+/(::<[+ ",
1503 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1504 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1505 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1506 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1507 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1508 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1509 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1510 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1511 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1512 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1513 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1514 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1515 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1516 " +#)!!!!!!!!!!!!!!}+/:::|1+ ",
1517 " +$#}}~23!!!!!!!!)~+/(]45, ",
1518 " +++++++@#}}~23!!)~+678++ ",
1519 " ++++++@#~90+a++ ",
1529 }
else if (std::string(aIconFile) ==
"perspective") {
1530 const char *
const xpm[]={
1540 " ................ ",
1541 " ....+++++++++++++++. ",
1542 " ...++++..+.........+++. ",
1543 " ..++..............++..+. ",
1544 " .+++++++++++++++++.. .+. ",
1545 " .+...............+. .+. ",
1546 " .+. .+. .+. .+. ",
1547 " .+. .+. .+. .+. ",
1548 " .+. .+. .+. .+. ",
1549 " .+. .+. .+. .+. ",
1550 " .+. .+. .+. .+. ",
1551 " .+. .+. .+. .+. ",
1552 " .+. .+. .+. .+. ",
1553 " .+. .+. .+. .+. ",
1554 " .+. .+......+....+. ",
1555 " .+. ..++++++.+.++++. ",
1556 " .+. .++.......+...+.. ",
1557 " .+. .++. .+..++. ",
1558 " .+. ..+.. .+..+. ",
1561 " .+++.............++. ",
1562 " .+++++++++++++++++. ",
1563 " ................... ",
1569 }
else if (std::string(aIconFile) ==
"ortho") {
1570 const char *
const xpm[]={
1578 " ................... ",
1579 " ..@@@@@@@@@@@@@@@@@. ",
1580 " ..@@@.............@@@. ",
1581 " ..@@.@. ..@..@. ",
1582 " ..@@ ..@. .@@...@. ",
1583 " ..@@..............@@.. .@. ",
1584 " .@@@@@@@@@@@@@@@@@.. .@. ",
1585 " .@...............@. .@. ",
1586 " .@. .@. .@. .@. ",
1587 " .@. .@. .@. .@. ",
1588 " .@. .@. .@. .@. ",
1589 " .@. .@. .@. .@. ",
1590 " .@. .@. .@. .@. ",
1591 " .@. .@. .@. .@. ",
1592 " .@. .@. .@. .@. ",
1593 " .@. .@. .@. .@. ",
1594 " .@. .@. .@. .@. ",
1595 " .@. .@. .@. .@. ",
1596 " .@. .@........@......@. ",
1597 " .@. .@@@@@@@@@.@.@@@@@@. ",
1598 " .@. .@@+........@....@@.. ",
1599 " .@...@. .@...@... ",
1601 " .@@@.............@@@.. ",
1602 " .@@@@@@@@@@@@@@@@@... ",
1603 " ................... ",
1614 G4cout <<
"Parameter"<< aIconFile <<
" not defined"<<
G4endl;
1618 QToolBar *currentToolbar = NULL;
1620 if (fToolbarUser == NULL) {
1621 fToolbarUser =
new QToolBar();
1622 fToolbarUser->setIconSize (QSize(20,20));
1623 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
1625 currentToolbar = fToolbarUser;
1627 if (fToolbarApp == NULL) {
1628 fToolbarApp =
new QToolBar();
1629 fToolbarApp->setIconSize (QSize(20,20));
1630 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
1632 currentToolbar = fToolbarApp;
1635 QSignalMapper *signalMapper =
new QSignalMapper(
this);
1636 QAction *action = currentToolbar->addAction(pix,aLabel, signalMapper, SLOT(map()));
1640 if (std::string(aIconFile) ==
"open") {
1641 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(OpenIconCallback(
const QString &)));
1642 QString txt = aCommand + fStringSeparator + aLabel;
1643 signalMapper->setMapping(action, QString(txt));
1646 }
else if (std::string(aIconFile) ==
"save") {
1647 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(SaveIconCallback(
const QString&)));
1648 QString txt = aCommand + fStringSeparator + aLabel;
1649 signalMapper->setMapping(action, QString(txt));
1652 }
else if ((std::string(aIconFile) ==
"move") ||
1653 (std::string(aIconFile) ==
"rotate") ||
1654 (std::string(aIconFile) ==
"pick") ||
1655 (std::string(aIconFile) ==
"zoom_out") ||
1656 (std::string(aIconFile) ==
"zoom_in")) {
1657 action->setCheckable(
TRUE);
1658 action->setChecked(
TRUE);
1659 action->setData(aIconFile);
1661 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeCursorStyle(
const QString&)));
1662 signalMapper->setMapping(action, QString(aIconFile));
1664 if (std::string(aIconFile) ==
"move") {
1665 SetIconMoveSelected();
1667 if (std::string(aIconFile) ==
"rotate") {
1668 SetIconRotateSelected();
1670 if (std::string(aIconFile) ==
"pick") {
1671 SetIconPickSelected();
1673 if (std::string(aIconFile) ==
"zoom_in") {
1674 SetIconZoomInSelected();
1676 if (std::string(aIconFile) ==
"zoom_out") {
1677 SetIconZoomOutSelected();
1681 }
else if ((std::string(aIconFile) ==
"hidden_line_removal") ||
1682 (std::string(aIconFile) ==
"hidden_line_and_surface_removal") ||
1683 (std::string(aIconFile) ==
"solid") ||
1684 (std::string(aIconFile) ==
"wireframe")) {
1685 action->setCheckable(
TRUE);
1686 action->setChecked(
TRUE);
1687 action->setData(aIconFile);
1688 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeSurfaceStyle(
const QString&)));
1689 signalMapper->setMapping(action, QString(aIconFile));
1691 if (std::string(aIconFile) ==
"hidden_line_removal") {
1692 SetIconHLRSelected();
1694 if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
1695 SetIconHLHSRSelected();
1697 if (std::string(aIconFile) ==
"solid") {
1698 SetIconSolidSelected();
1700 if (std::string(aIconFile) ==
"wireframe") {
1701 SetIconWireframeSelected();
1705 }
else if ((std::string(aIconFile) ==
"perspective") ||
1706 (std::string(aIconFile) ==
"ortho")) {
1707 action->setCheckable(
TRUE);
1708 action->setChecked(
TRUE);
1709 action->setData(aIconFile);
1710 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangePerspectiveOrtho(
const QString&)));
1711 signalMapper->setMapping(action, QString(aIconFile));
1713 if (std::string(aIconFile) ==
"perspective") {
1714 SetIconPerspectiveSelected();
1716 if (std::string(aIconFile) ==
"ortho") {
1717 SetIconOrthoSelected();
1724 if(UI==NULL)
return;
1726 if (aCommand != NULL) {
1727 if(treeTop->
FindPath(aCommand) == NULL) {
1732 G4cout <<
"Warning: command '"<< aCommand <<
"' does not exist, please define it before using it."<<
G4endl;
1737 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
1738 signalMapper->setMapping(action, QString(aCommand));
1744 void G4UIQt::ActivateCommand(
1748 if (!fHelpTreeWidget) {
1752 size_t i = newCommand.
index(
" ");
1754 if( i != std::string::npos )
1756 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
1758 targetCom = ModifyToFullPathCommand( newValue );
1760 if (targetCom !=
"") {
1761 OpenHelpTreeOnCommand(targetCom.
data());
1764 fUITabWidget->setCurrentWidget(fHelpTBWidget);
1775 void G4UIQt::InitHelpTreeAndVisParametersWidget()
1778 if (! fHelpTreeWidget ) {
1779 fHelpTreeWidget =
new QTreeWidget();
1783 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
1785 labels << QString(
"Command");
1786 fHelpTreeWidget->setHeaderLabels(labels);
1789 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),
this, SLOT(HelpTreeClicCallback()));
1790 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,
int)),
this, SLOT(HelpTreeDoubleClicCallback()));
1799 void G4UIQt::FillHelpTree()
1801 if (! fHelpTreeWidget ) {
1802 InitHelpTreeAndVisParametersWidget();
1805 QString searchText = fHelpLine->text();
1807 if (searchText ==
"") {
1815 #if QT_VERSION < 0x040200
1818 fHelpArea->setText(
"");
1823 #if QT_VERSION < 0x040200
1826 fHelpLine->setText(
"");
1831 if(UI==NULL)
return;
1835 QTreeWidgetItem * newItem = NULL;
1836 QString commandText =
"";
1837 for (
int a=0;
a<treeSize;
a++) {
1844 for (
int b=0;
b<fHelpTreeWidget->topLevelItemCount();
b++) {
1846 newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(
b),commandText);
1849 if (newItem == NULL) {
1851 newItem =
new QTreeWidgetItem();
1852 newItem->setText(0,GetShortCommandPath(commandText));
1853 fHelpTreeWidget->addTopLevelItem(newItem);
1857 CreateHelpTree(newItem,treeTop->
GetTree(
a+1));
1868 void G4UIQt::CreateHelpTree(
1869 QTreeWidgetItem *aParent
1873 if (aParent == NULL)
return;
1874 if (aCommandTree == NULL)
return;
1878 QTreeWidgetItem * newItem;
1880 QString commandText =
"";
1887 newItem = FindTreeItem(aParent,commandText);
1888 if (newItem == NULL) {
1889 newItem =
new QTreeWidgetItem();
1890 newItem->setText(0,GetShortCommandPath(commandText));
1891 aParent->addChild(newItem);
1893 CreateHelpTree(newItem,aCommandTree->
GetTree(
a+1));
1900 QStringList stringList;
1904 newItem = FindTreeItem(aParent,commandText);
1905 if (newItem == NULL) {
1906 newItem =
new QTreeWidgetItem();
1907 newItem->setText(0,GetShortCommandPath(commandText));
1908 aParent->addChild(newItem);
1910 #if QT_VERSION < 0x040202
1911 fHelpTreeWidget->setItemExpanded(newItem,
false);
1913 newItem->setExpanded(
false);
1927 bool G4UIQt::CreateVisCommandGroupAndToolBox(
1934 QString commandText = QString((
char*)(aCommand->
GetCommandPath().
data())).section(
"/",-aDepthLevel);
1936 if (commandText == NULL) {
1942 QWidget* newParentWidget = NULL;
1944 QString commandSection = commandText.left(commandText.indexOf(
"/"));
1946 if (aDepthLevel == 1) {
1947 QToolBox* currentParent =
dynamic_cast<QToolBox*
>(aParent);
1948 if (currentParent != 0){
1951 for (
int a=0;
a<currentParent->count();
a++) {
1952 if (currentParent->itemText(
a) == commandSection) {
1954 newParentWidget = currentParent->widget(
a);
1960 newParentWidget =
new QGroupBox();
1961 newParentWidget->setLayout(
new QVBoxLayout());
1962 if (currentParent != 0){
1963 currentParent->addItem(newParentWidget,commandSection);
1965 if (!aParent->layout()) {
1966 aParent->setLayout(
new QVBoxLayout());
1968 aParent->layout()->addWidget(newParentWidget);
1971 if (commandText.indexOf(
"/") == -1) {
1976 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
1979 newParentWidget->setToolTip(guidance);
1982 QScrollArea* sc =
dynamic_cast<QScrollArea*
>(newParentWidget->parent()->parent());
1984 sc->ensureWidgetVisible(newParentWidget);
1991 QGroupBox* currentParent =
dynamic_cast<QGroupBox*
>(aParent);
1992 if (currentParent != 0){
1996 if (aDepthLevel == 2){
1997 QToolBox* parentToolBox =
dynamic_cast<QToolBox*
>(currentParent->parent()->parent()->parent());
1998 if (parentToolBox != 0) {
2002 for (
int a=0;
a<aParent->layout()->count();
a++) {
2003 QGroupBox* gb =
dynamic_cast<QGroupBox*
>(aParent->layout()->itemAt(
a)->widget());
2005 if (gb->title() == commandSection) {
2007 newParentWidget = gb;
2015 newParentWidget =
new QGroupBox();
2016 newParentWidget->setLayout(
new QVBoxLayout());
2017 if (!aParent->layout()) {
2018 aParent->setLayout(
new QVBoxLayout());
2020 aParent->layout()->addWidget(newParentWidget);
2026 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2029 newParentWidget->setToolTip(guidance);
2034 if (commandText.indexOf(
"/") == -1) {
2035 if (CreateCommandWidget(aCommand, newParentWidget,isDialog)) {
2039 CreateVisCommandGroupAndToolBox(aCommand,newParentWidget, aDepthLevel-1,isDialog);
2052 bool G4UIQt::CreateCommandWidget(
G4UIcommand* aCommand, QWidget* aParent,
bool isDialog) {
2054 if (aCommand == NULL) {
2061 if( n_parameterEntry > 0 ) {
2065 QWidget* paramWidget =
new QWidget();
2066 QGridLayout* gridLayout =
new QGridLayout();
2067 paramWidget->setLayout(gridLayout);
2070 unsigned int nbColorParameter = 0;
2071 bool isStillColorParameter =
false;
2072 bool isColorDialogAdded =
false;
2073 QLabel* redLabel = NULL;
2074 QLabel* greenLabel = NULL;
2075 QString redDefaultStr =
"";
2076 QString greenDefaultStr =
"";
2077 QString blueDefaultStr =
"";
2078 QWidget* redInput = NULL;
2079 QWidget* greenInput = NULL;
2081 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2086 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")){
2087 nbColorParameter ++;
2088 isStillColorParameter =
true;
2089 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2090 nbColorParameter ++;
2091 }
else if ((label->text() ==
"blue") && isStillColorParameter) {
2092 nbColorParameter ++;
2093 }
else if (!isColorDialogAdded) {
2096 if (nbColorParameter == 1) {
2097 gridLayout->addWidget(redLabel,i_thParameter-1,0);
2098 gridLayout->addWidget(redInput,i_thParameter-1,1);
2099 }
else if (nbColorParameter == 2) {
2100 gridLayout->addWidget(redLabel,i_thParameter-2,0);
2101 gridLayout->addWidget(redInput,i_thParameter-2,1);
2102 gridLayout->addWidget(greenLabel,i_thParameter-1,0);
2103 gridLayout->addWidget(greenInput,i_thParameter-1,1);
2105 nbColorParameter = 0;
2108 QWidget* input = NULL;
2110 input =
new QLineEdit();
2112 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2114 if (((label->text() ==
"red") || (label->text() ==
"red_or_string")) && isStillColorParameter) {
2116 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2118 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2123 input =
new QWidget();
2124 QHBoxLayout* layout =
new QHBoxLayout();
2125 input->setLayout(layout);
2127 QButtonGroup* buttons =
new QButtonGroup();
2128 QRadioButton* radioOff =
new QRadioButton(
"0");
2129 QRadioButton* radioOn =
new QRadioButton(
"1");
2130 buttons->addButton(radioOn);
2131 buttons->addButton(radioOff);
2132 layout->addWidget(radioOn);
2133 layout->addWidget(radioOff);
2137 if (defaultValue ==
"0") {
2138 radioOff->setChecked(
true);
2139 }
else if (defaultValue ==
"1") {
2140 radioOn->setChecked(
true);
2143 input =
new QComboBox();
2145 QStringList list = candidates.split (
" ");
2149 for (
int a=0;
a<list.size();
a++) {
2150 dynamic_cast<QComboBox*
>(input)->addItem(list.at(
a));
2151 if (list.at(
a) == defaultValue) {
2152 dynamic_cast<QComboBox*
>(input)->setCurrentIndex(
a);
2157 input =
new QLineEdit();
2159 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2162 input =
new QWidget();
2163 QHBoxLayout* layout =
new QHBoxLayout();
2164 input->setLayout(layout);
2166 QButtonGroup* buttons =
new QButtonGroup();
2167 QRadioButton* radioOff =
new QRadioButton(
"off");
2168 QRadioButton* radioOn =
new QRadioButton(
"on");
2169 buttons->addButton(radioOn);
2170 buttons->addButton(radioOff);
2171 layout->addWidget(radioOn);
2172 layout->addWidget(radioOff);
2176 if (defaultValue ==
"off") {
2177 radioOff->setChecked(
true);
2178 }
else if (defaultValue ==
"on") {
2179 radioOn->setChecked(
true);
2183 input =
new QLineEdit();
2184 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).
data()));
2191 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2193 txt +=
" Omittable : True\n";
2195 txt +=
" Omittable : False\n";
2198 txt +=
" Default value : taken from the current value\n";
2209 if (isStillColorParameter && (nbColorParameter != 0)) {
2210 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")) {
2213 }
else if (label->text() ==
"green") {
2216 }
else if (label->text() ==
"blue") {
2222 if ((redDefaultStr !=
"") && (redDefaultStr !=
"") && (redDefaultStr !=
"")) {
2223 qc.setRgbF(redDefaultStr.toDouble(),
2224 greenDefaultStr.toDouble(),
2225 blueDefaultStr.toDouble());
2227 QPixmap pixmap = QPixmap(QSize(16, 16));
2229 QPainter painter(&pixmap);
2230 painter.setPen(Qt::black);
2231 painter.drawRect(0,0,15,15);
2233 input =
new QPushButton(
"Change color");
2234 dynamic_cast<QPushButton*
>(input)->setIcon(pixmap);
2235 dynamic_cast<QPushButton*
>(input)->setAccessibleName(redDefaultStr+
" "+greenDefaultStr+
" "+blueDefaultStr);
2236 label =
new QLabel(
"Choose color");
2240 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2241 input->setToolTip(
"Select the current color");
2242 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2245 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2246 signalMapper->setMapping(input,input);
2247 connect(input, SIGNAL(clicked()), signalMapper, SLOT(map()));
2248 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(ChangeColorCallback(QWidget*)));
2250 isColorDialogAdded =
true;
2251 isStillColorParameter =
false;
2254 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2255 input->setToolTip(txt);
2256 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2262 gridLayout->addWidget(name,n_parameterEntry-nbColorParameter,0);
2264 QPushButton* applyButton =
new QPushButton(
"Apply");
2267 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,1);
2269 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2270 signalMapper->setMapping(applyButton, paramWidget);
2271 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2272 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2276 applyButton->setAutoDefault(
TRUE );
2277 applyButton->setDefault(
TRUE );
2278 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,0);
2280 QPushButton* cancelButton =
new QPushButton( tr(
"&Cancel" ));
2281 cancelButton->setAutoDefault(
TRUE );
2282 gridLayout->addWidget(cancelButton,n_parameterEntry-nbColorParameter,1);
2284 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2285 signalMapper->setMapping(applyButton, paramWidget);
2286 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2287 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2289 QWidget * parentCheck = aParent;
2290 QDialog* parentDialog = NULL;
2292 while ((parentCheck->parentWidget()) != NULL) {
2293 parentCheck = parentCheck->parentWidget();
2294 parentDialog =
dynamic_cast<QDialog*
>(parentCheck);
2296 connect( applyButton, SIGNAL( clicked() ), parentDialog, SLOT( accept() ) );
2297 connect( cancelButton, SIGNAL( clicked() ), parentDialog, SLOT( reject() ) );
2306 if (!aParent->layout()) {
2307 aParent->setLayout(
new QVBoxLayout());
2309 aParent->layout()->addWidget(paramWidget);
2320 QTreeWidgetItem* G4UIQt::FindTreeItem(
2321 QTreeWidgetItem *aParent
2322 ,
const QString& aCommand
2325 if (aParent == NULL)
return NULL;
2328 QString myCommand = aCommand;
2330 if (myCommand.lastIndexOf(
"/") == (myCommand.size()-1)) {
2331 myCommand = myCommand.left(myCommand.size()-1);
2334 if (GetLongCommandPath(aParent) == myCommand)
2337 QTreeWidgetItem *
tmp = NULL;
2338 for (
int a=0;
a<aParent->childCount();
a++) {
2340 tmp = FindTreeItem(aParent->child(
a),myCommand);
2354 QString G4UIQt::GetCommandList (
2360 if (aCommand == NULL)
2368 if ((commandPath ==
"") &&
2369 (rangeString ==
"") &&
2370 (n_guidanceEntry == 0) &&
2371 (n_parameterEntry == 0)) {
2375 if((commandPath.length()-1)!=
'/') {
2376 txt +=
"Command " + QString((
char*)(commandPath).
data()) +
"\n";
2378 txt +=
"Guidance :\n";
2380 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2383 if( ! rangeString.
isNull() ) {
2384 txt +=
" Range of parameters : " + QString((
char*)(rangeString).
data()) +
"\n";
2386 if( n_parameterEntry > 0 ) {
2391 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2396 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2398 txt +=
" Omittable : True\n";
2400 txt +=
" Omittable : False\n";
2403 txt +=
" Default value : taken from the current value\n";
2424 G4bool G4UIQt::IsGUICommand(
2428 if (aCommand == NULL)
2433 if( n_parameterEntry > 0 ) {
2438 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2460 G4bool G4UIQt::GetHelpChoice(
2475 bool G4UIQt::eventFilter(
2480 bool moveCommandCursor =
false;
2481 if (aObj == NULL)
return false;
2482 if (aEvent == NULL)
return false;
2484 if (aObj == fHistoryTBTableList) {
2485 if (aEvent->type() == QEvent::KeyPress) {
2486 fCommandArea->setFocus();
2489 if (aObj == fCommandArea) {
2490 if (aEvent->type() == QEvent::KeyPress) {
2491 QKeyEvent *e =
static_cast<QKeyEvent*
>(aEvent);
2492 if ((e->key() == (Qt::Key_Down)) ||
2493 (e->key() == (Qt::Key_PageDown)) ||
2494 (e->key() == (Qt::Key_Up)) ||
2495 (e->key() == (Qt::Key_PageUp))) {
2496 int selection = fHistoryTBTableList->currentRow();
2497 if (fHistoryTBTableList->count()) {
2498 if (selection == -1) {
2499 selection = fHistoryTBTableList->count()-1;
2501 if (e->key() == (Qt::Key_Down)) {
2502 if (selection <(fHistoryTBTableList->count()-1))
2504 }
else if (e->key() == (Qt::Key_PageDown)) {
2505 selection = fHistoryTBTableList->count()-1;
2506 }
else if (e->key() == (Qt::Key_Up)) {
2509 }
else if (e->key() == (Qt::Key_PageUp)) {
2513 fHistoryTBTableList->clearSelection();
2514 #if QT_VERSION < 0x040202
2515 fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),
true);
2517 fHistoryTBTableList->item(selection)->setSelected(
true);
2519 fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
2521 moveCommandCursor =
true;
2522 }
else if (e->key() == (Qt::Key_Tab)) {
2523 G4String ss = Complete(fCommandArea->text().toStdString().c_str());
2524 fCommandArea->setText((
char*)(ss.
data()));
2530 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
2531 fCommandArea->home(
false);
2533 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
2534 fCommandArea->end(
false);
2541 if (moveCommandCursor ==
true) {
2542 fCommandArea->setCursorPosition ( fCommandArea->text().length() );
2543 fCommandArea->setCursorPosition (4);
2546 res = QObject::eventFilter(aObj, aEvent);
2562 void G4UIQt::ShowHelpCallback (
2571 void G4UIQt::ClearButtonCallback (
2574 fCoutTBTextArea->clear();
2580 void G4UIQt::ExitSession (
2586 void G4UIQt::ExitHelp(
2594 void G4UIQt::CommandEnteredCallback (
2598 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
2601 for (
int a=0;
a< list.size();
a++) {
2602 QString txt (list[
a].trimmed());
2604 fHistoryTBTableList->addItem(txt);
2605 fHistoryTBTableList->clearSelection();
2606 fHistoryTBTableList->setCurrentItem(NULL);
2607 fCommandArea->setText(
"");
2608 G4Qt* interactorManager = G4Qt::getInstance ();
2609 if (interactorManager) {
2610 interactorManager->FlushAndWaitExecution();
2613 G4String command = txt.toStdString().c_str();
2614 if (command(0,4) !=
"help") {
2615 ApplyShellCommand (command,exitSession,exitPause);
2617 ActivateCommand(command);
2625 if(exitSession==
true)
2634 void G4UIQt::CommandEditedCallback(
const QString &)
2636 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
2638 if (list.size() > 1) {
2639 for (
int a=0;
a<list.size()-1;
a++) {
2641 fCommandArea->setText(list[
a]);
2643 CommandEnteredCallback();
2646 fCommandArea->setText(list[list.size()-1]);
2653 void G4UIQt::VisParameterCallback(QWidget* widget){
2654 if (widget == NULL) {
2659 QGridLayout* grid =
dynamic_cast<QGridLayout*
>(widget->layout());
2664 #if QT_VERSION < 0x040400
2665 QWidget* name = grid->itemAt(grid->columnCount()*(grid->rowCount()-2))->widget();
2667 QWidget* name = grid->itemAtPosition(grid->rowCount()-1,0)->widget();
2669 if (dynamic_cast<QLabel*>(name) == 0) {
2672 command += (
dynamic_cast<QLabel*
>(
name))->text()+
" ";
2674 for (
int a=0;
a<grid->rowCount()-1;
a++) {
2675 #if QT_VERSION < 0x040400
2676 QWidget* widgetTmp = grid->itemAt(
a*grid->columnCount()+1)->widget();
2678 QWidget* widgetTmp = grid->itemAtPosition(
a,1)->widget();
2682 if (widgetTmp != NULL) {
2684 if (dynamic_cast<QLineEdit*>(widgetTmp) != 0) {
2685 command += (
dynamic_cast<QLineEdit*
>(widgetTmp))->text()+
" ";
2687 }
else if (dynamic_cast<QComboBox*>(widgetTmp) != 0){
2688 command += (
dynamic_cast<QComboBox*
>(widgetTmp))->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex())+
" ";
2691 }
else if (dynamic_cast<QPushButton*>(widgetTmp) != 0){
2692 command += widgetTmp->accessibleName()+
" ";
2695 }
else if (dynamic_cast<QWidget*>(widgetTmp) != 0){
2696 if (widgetTmp->layout()->count() > 0){
2697 if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != 0) {
2698 QAbstractButton * checked = (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton();
2700 command += (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton()->text()+
" ";
2708 if (command !=
"") {
2722 void G4UIQt::ButtonCallback (
2723 const QString& aCommand
2730 if(UI==NULL)
return;
2737 if (IsGUICommand(command)) {
2738 QDialog* menuParameterDialog =
new QDialog();
2740 if (CreateVisCommandGroupAndToolBox(command,menuParameterDialog,1,
true)) {
2741 menuParameterDialog->setWindowTitle (aCommand);
2742 menuParameterDialog->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
2745 menuParameterDialog->exec();
2751 ApplyShellCommand(ss,exitSession,exitPause);
2756 if(exitSession==
true)
2764 void G4UIQt::HelpTreeClicCallback (
2767 QTreeWidgetItem* item = NULL;
2768 if (!fHelpTreeWidget)
2774 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
2777 item = list.first();
2782 if(UI==NULL)
return;
2785 std::string itemText = GetLongCommandPath(item).toStdString();
2788 if (item->childCount() > 0) {
2794 #if QT_VERSION < 0x040200
2796 fHelpArea->append(GetCommandList(command));
2798 fHelpArea->setText(GetCommandList(command));
2805 #if QT_VERSION < 0x040200
2817 void G4UIQt::HelpTreeDoubleClicCallback (
2820 HelpTreeClicCallback();
2822 QTreeWidgetItem* item = NULL;
2823 if (!fHelpTreeWidget)
2829 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
2832 item = list.first();
2836 fCommandArea->clear();
2837 fCommandArea->setText(GetLongCommandPath(item));
2844 void G4UIQt::CommandHistoryCallback(
2847 QListWidgetItem* item = NULL;
2848 if (!fHistoryTBTableList)
2852 QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
2855 item = list.first();
2858 fCommandArea->setText(item->text());
2862 void G4UIQt::CoutFilterCallback(
2863 const QString & text) {
2865 QStringList result = fG4cout.filter(text);
2866 fCoutTBTextArea->setPlainText(result.join(
"\n"));
2868 fCoutTBTextArea->repaint();
2869 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
2877 void G4UIQt::LookForHelpStringCallback(
2880 QString searchText = fHelpLine->text();
2882 #if QT_VERSION < 0x040200
2885 fHelpArea->setText(
"");
2887 if (searchText ==
"") {
2889 fHelpTreeWidget->clear();
2895 OpenHelpTreeOnCommand(searchText);
2900 void G4UIQt::OpenHelpTreeOnCommand(
2901 const QString & searchText
2906 if(UI==NULL)
return;
2912 fHelpTreeWidget->clear();
2918 QMap<int,QString> commandResultMap;
2919 QMap<int,QString> commandChildResultMap;
2921 for (
int a=0;
a<treeSize;
a++) {
2923 tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
2928 commandChildResultMap = LookForHelpStringInChildTree(treeTop->
GetTree(
a+1),searchText);
2930 if (!commandChildResultMap.empty()) {
2931 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
2932 while (i != commandChildResultMap.constEnd()) {
2933 commandResultMap.insertMulti(i.key(),i.value());
2936 commandChildResultMap.clear();
2941 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2942 fHelpTreeWidget->setColumnCount(2);
2944 labels << QString(
"Command") << QString(
"Match");
2945 fHelpTreeWidget->setHeaderLabels(labels);
2947 if (commandResultMap.empty()) {
2948 #if QT_VERSION < 0x040200
2950 fHelpArea->append(
"No match found");
2952 fHelpArea->setText(
"No match found");
2957 QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
2960 float multValue = 10.0/(float)(i.key());
2961 QString progressChar =
"|";
2962 QString progressStr =
"|";
2964 QTreeWidgetItem * newItem;
2967 if (i == commandResultMap.constBegin()) {
2970 for(
int a=0;
a<
int(i.key()*multValue);
a++) {
2971 progressStr += progressChar;
2973 newItem =
new QTreeWidgetItem();
2974 QString commandStr = i.value().trimmed();
2976 if (commandStr.indexOf(
"/") == 0) {
2977 commandStr = commandStr.right(commandStr.size()-1);
2980 newItem->setText(0,commandStr);
2981 newItem->setText(1,progressStr);
2982 fHelpTreeWidget->addTopLevelItem(newItem);
2983 #if QT_VERSION < 0x040200
2985 newItem->setForeground ( 1, QBrush(
Qt::blue) );
2990 fHelpTreeWidget->resizeColumnToContents (0);
2991 fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
2998 QMap<int,QString> G4UIQt::LookForHelpStringInChildTree(
3000 ,
const QString & text
3003 QMap<int,QString> commandResultMap;
3004 if (aCommandTree == NULL)
return commandResultMap;
3009 QMap<int,QString> commandChildResultMap;
3013 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
3018 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->
GetTree(
a+1),text);
3020 if (!commandChildResultMap.empty()) {
3022 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
3023 while (i != commandChildResultMap.constEnd()) {
3024 commandResultMap.insertMulti(i.key(),i.value());
3027 commandChildResultMap.clear();
3034 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
3040 return commandResultMap;
3044 QString G4UIQt::GetShortCommandPath(
3048 if (commandPath.indexOf(
"/") == 0) {
3049 commandPath = commandPath.right(commandPath.size()-1);
3052 commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf(
"/",-2)-1);
3054 if (commandPath.lastIndexOf(
"/") == (commandPath.size()-1)) {
3055 commandPath = commandPath.left(commandPath.size()-1);
3062 QString G4UIQt::GetLongCommandPath(
3063 QTreeWidgetItem* item
3066 if (item == NULL)
return "";
3069 QString itemText =
"";
3070 itemText = item->text(0);
3072 while (item->parent() != NULL) {
3073 itemText = item->parent()->text(0)+
"/"+itemText;
3074 item = item->parent();
3076 itemText =
"/"+itemText;
3082 void G4UIQt::ChangeColorCallback(QWidget* widget) {
3083 if (widget == NULL) {
3087 QPushButton* button =
dynamic_cast<QPushButton*
>(widget);
3091 QString
value = button->accessibleName();
3094 old.setRgbF(value.section(
" ",0,1).toDouble(),
3095 value.section(
" ",1,2).toDouble(),
3096 value.section(
" ",2,3).toDouble());
3097 #if QT_VERSION < 0x040500
3099 QColor color = QColor(QColorDialog::getRgba (old.rgba(),&
a,fUITabWidget));
3101 QColor color = QColorDialog::getColor(old,
3104 QColorDialog::ShowAlphaChannel);
3108 if (color.isValid()) {
3110 QPixmap pixmap = QPixmap(QSize(16, 16));
3111 pixmap.fill (color);
3112 QPainter painter(&pixmap);
3113 painter.setPen(Qt::black);
3114 painter.drawRect(0,0,15,15);
3116 button->setAccessibleName(QString::number(color.redF())+
" "+
3117 QString::number(color.greenF())+
" "+
3118 QString::number(color.blueF())+
" "
3120 button->setIcon(pixmap);
3127 void G4UIQt::ChangeCursorStyle(
const QString& action) {
3131 fMoveSelected =
true;
3132 fPickSelected =
true;
3133 fRotateSelected =
true;
3134 fZoomInSelected =
true;
3135 fZoomOutSelected =
true;
3137 if (fToolbarApp == NULL)
return;
3138 QList<QAction *> list = fToolbarApp->actions ();
3139 for (
int i = 0; i < list.size(); ++i) {
3140 if (list.at(i)->data().toString () == action) {
3141 list.at(i)->setChecked(
TRUE);
3142 }
else if (list.at(i)->data().toString () ==
"move") {
3143 fMoveSelected =
false;
3144 list.at(i)->setChecked(
FALSE);
3145 }
else if (list.at(i)->data().toString () ==
"pick") {
3146 fPickSelected =
false;
3147 list.at(i)->setChecked(
FALSE);
3148 }
else if (list.at(i)->data().toString () ==
"rotate") {
3149 fRotateSelected =
false;
3150 list.at(i)->setChecked(
FALSE);
3151 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3152 fZoomInSelected =
false;
3153 list.at(i)->setChecked(
FALSE);
3154 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3155 fZoomOutSelected =
false;
3156 list.at(i)->setChecked(
FALSE);
3169 void G4UIQt::ChangeSurfaceStyle(
const QString& action) {
3173 if (fToolbarApp == NULL)
return;
3174 QList<QAction *> list = fToolbarApp->actions ();
3175 for (
int i = 0; i < list.size(); ++i) {
3176 if (list.at(i)->data().toString () == action) {
3177 list.at(i)->setChecked(
TRUE);
3178 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3179 list.at(i)->setChecked(
FALSE);
3180 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3181 list.at(i)->setChecked(
FALSE);
3182 }
else if (list.at(i)->data().toString () ==
"solid") {
3183 list.at(i)->setChecked(
FALSE);
3184 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3185 list.at(i)->setChecked(
FALSE);
3190 if (action ==
"hidden_line_removal") {
3194 }
else if (action ==
"hidden_line_and_surface_removal") {
3198 }
else if (action ==
"solid") {
3202 }
else if (action ==
"wireframe") {
3209 void G4UIQt::OpenIconCallback(
const QString& aParam) {
3211 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
3212 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
3214 QString nomFich = QFileDialog::getOpenFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
3215 if (nomFich !=
"") {
3218 fLastOpenPath = dir.absoluteFilePath(nomFich);
3223 void G4UIQt::SaveIconCallback(
const QString& aParam) {
3225 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
3226 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
3228 QString nomFich = QFileDialog::getSaveFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
3229 if (nomFich !=
"") {
3232 fLastOpenPath = dir.absoluteFilePath(nomFich);
3238 void G4UIQt::ChangePerspectiveOrtho(
const QString& action) {
3242 if (fToolbarApp == NULL)
return;
3243 QList<QAction *> list = fToolbarApp->actions ();
3244 QString checked =
"";
3245 for (
int i = 0; i < list.size(); ++i) {
3246 if (list.at(i)->data().toString () == action) {
3247 list.at(i)->setChecked(
TRUE);
3248 checked = list.at(i)->data().toString ();
3249 }
else if (list.at(i)->data().toString () ==
"persepective") {
3250 list.at(i)->setChecked(
FALSE);
3251 }
else if (list.at(i)->data().toString () ==
"ortho") {
3252 list.at(i)->setChecked(
FALSE);
3256 if ((action ==
"ortho") && (checked ==
"ortho")) {
3258 }
else if ((action ==
"perspective") && (checked ==
"perspective")) {
3265 void G4UIQt::SetIconMoveSelected() {
3267 fMoveSelected =
true;
3268 fRotateSelected =
false;
3269 fPickSelected =
false;
3270 fZoomInSelected =
false;
3271 fZoomOutSelected =
false;
3273 if (fToolbarApp == NULL)
return;
3274 QList<QAction *> list = fToolbarApp->actions ();
3275 for (
int i = 0; i < list.size(); ++i) {
3276 if (list.at(i)->data().toString () ==
"move") {
3277 list.at(i)->setChecked(
TRUE);
3278 }
else if (list.at(i)->data().toString () ==
"rotate") {
3279 list.at(i)->setChecked(
FALSE);
3280 }
else if (list.at(i)->data().toString () ==
"pick") {
3281 list.at(i)->setChecked(
FALSE);
3282 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3283 list.at(i)->setChecked(
FALSE);
3284 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3285 list.at(i)->setChecked(
FALSE);
3291 void G4UIQt::SetIconRotateSelected() {
3293 fRotateSelected =
true;
3294 fMoveSelected =
false;
3295 fPickSelected =
false;
3296 fZoomInSelected =
false;
3297 fZoomOutSelected =
false;
3299 if (fToolbarApp == NULL)
return;
3300 QList<QAction *> list = fToolbarApp->actions ();
3301 for (
int i = 0; i < list.size(); ++i) {
3302 if (list.at(i)->data().toString () ==
"rotate") {
3303 list.at(i)->setChecked(
TRUE);
3304 }
else if (list.at(i)->data().toString () ==
"move") {
3305 list.at(i)->setChecked(
FALSE);
3306 }
else if (list.at(i)->data().toString () ==
"pick") {
3307 list.at(i)->setChecked(
FALSE);
3308 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3309 list.at(i)->setChecked(
FALSE);
3310 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3311 list.at(i)->setChecked(
FALSE);
3317 void G4UIQt::SetIconPickSelected() {
3319 fPickSelected =
true;
3320 fMoveSelected =
false;
3321 fRotateSelected =
false;
3322 fZoomInSelected =
false;
3323 fZoomOutSelected =
false;
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 () ==
"pick") {
3329 list.at(i)->setChecked(
TRUE);
3330 }
else if (list.at(i)->data().toString () ==
"move") {
3331 list.at(i)->setChecked(
FALSE);
3332 }
else if (list.at(i)->data().toString () ==
"rotate") {
3333 list.at(i)->setChecked(
FALSE);
3334 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3335 list.at(i)->setChecked(
FALSE);
3336 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3337 list.at(i)->setChecked(
FALSE);
3343 void G4UIQt::SetIconZoomInSelected() {
3345 fZoomInSelected =
true;
3346 fMoveSelected =
false;
3347 fRotateSelected =
false;
3348 fPickSelected =
false;
3349 fZoomOutSelected =
false;
3351 if (fToolbarApp == NULL)
return;
3352 QList<QAction *> list = fToolbarApp->actions ();
3353 for (
int i = 0; i < list.size(); ++i) {
3354 if (list.at(i)->data().toString () ==
"zoom_in") {
3355 list.at(i)->setChecked(
TRUE);
3356 }
else if (list.at(i)->data().toString () ==
"move") {
3357 list.at(i)->setChecked(
FALSE);
3358 }
else if (list.at(i)->data().toString () ==
"rotate") {
3359 list.at(i)->setChecked(
FALSE);
3360 }
else if (list.at(i)->data().toString () ==
"pick") {
3361 list.at(i)->setChecked(
FALSE);
3362 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3363 list.at(i)->setChecked(
FALSE);
3369 void G4UIQt::SetIconZoomOutSelected() {
3371 fZoomOutSelected =
true;
3372 fMoveSelected =
false;
3373 fRotateSelected =
false;
3374 fPickSelected =
false;
3375 fZoomInSelected =
false;
3377 if (fToolbarApp == NULL)
return;
3378 QList<QAction *> list = fToolbarApp->actions ();
3379 for (
int i = 0; i < list.size(); ++i) {
3380 if (list.at(i)->data().toString () ==
"zoom_out") {
3381 list.at(i)->setChecked(
TRUE);
3382 }
else if (list.at(i)->data().toString () ==
"move") {
3383 list.at(i)->setChecked(
FALSE);
3384 }
else if (list.at(i)->data().toString () ==
"rotate") {
3385 list.at(i)->setChecked(
FALSE);
3386 }
else if (list.at(i)->data().toString () ==
"pick") {
3387 list.at(i)->setChecked(
FALSE);
3388 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3389 list.at(i)->setChecked(
FALSE);
3395 void G4UIQt::SetIconSolidSelected() {
3398 if (fToolbarApp == NULL)
return;
3399 QList<QAction *> list = fToolbarApp->actions ();
3400 for (
int i = 0; i < list.size(); ++i) {
3401 if (list.at(i)->data().toString () ==
"solid") {
3402 list.at(i)->setChecked(
TRUE);
3403 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3404 list.at(i)->setChecked(
FALSE);
3405 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3406 list.at(i)->setChecked(
FALSE);
3407 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3408 list.at(i)->setChecked(
FALSE);
3414 void G4UIQt::SetIconWireframeSelected() {
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 () ==
"wireframe") {
3421 list.at(i)->setChecked(
TRUE);
3422 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3423 list.at(i)->setChecked(
FALSE);
3424 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3425 list.at(i)->setChecked(
FALSE);
3426 }
else if (list.at(i)->data().toString () ==
"solid") {
3427 list.at(i)->setChecked(
FALSE);
3433 void G4UIQt::SetIconHLRSelected() {
3436 if (fToolbarApp == NULL)
return;
3437 QList<QAction *> list = fToolbarApp->actions ();
3438 for (
int i = 0; i < list.size(); ++i) {
3439 if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3440 list.at(i)->setChecked(
TRUE);
3441 }
else if (list.at(i)->data().toString () ==
"solid") {
3442 list.at(i)->setChecked(
FALSE);
3443 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3444 list.at(i)->setChecked(
FALSE);
3445 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3446 list.at(i)->setChecked(
FALSE);
3452 void G4UIQt::SetIconHLHSRSelected() {
3455 if (fToolbarApp == NULL)
return;
3456 QList<QAction *> list = fToolbarApp->actions ();
3457 for (
int i = 0; i < list.size(); ++i) {
3458 if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3459 list.at(i)->setChecked(
TRUE);
3460 }
else if (list.at(i)->data().toString () ==
"solid") {
3461 list.at(i)->setChecked(
FALSE);
3462 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3463 list.at(i)->setChecked(
FALSE);
3464 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3465 list.at(i)->setChecked(
FALSE);
3471 void G4UIQt::SetIconPerspectiveSelected() {
3474 if (fToolbarApp == NULL)
return;
3475 QList<QAction *> list = fToolbarApp->actions ();
3476 for (
int i = 0; i < list.size(); ++i) {
3477 if (list.at(i)->data().toString () ==
"perspective") {
3478 list.at(i)->setChecked(
TRUE);
3479 }
else if (list.at(i)->data().toString () ==
"ortho") {
3480 list.at(i)->setChecked(
FALSE);
3487 void G4UIQt::SetIconOrthoSelected() {
3490 if (fToolbarApp == NULL)
return;
3491 QList<QAction *> list = fToolbarApp->actions ();
3492 for (
int i = 0; i < list.size(); ++i) {
3493 if (list.at(i)->data().toString () ==
"ortho") {
3494 list.at(i)->setChecked(
TRUE);
3495 }
else if (list.at(i)->data().toString () ==
"perspective") {
3496 list.at(i)->setChecked(
FALSE);
3503 G4QTabWidget::G4QTabWidget(
3507 ):QTabWidget(aParent)
3508 ,fTabSelected(false)
3510 ,fPreferedSizeX(sizeX+6)
3511 ,fPreferedSizeY(sizeY+58)
3513 setMinimumSize(100,100);
3514 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
3515 setSizePolicy(policy);
3518 G4QTabWidget::G4QTabWidget(
3520 ,fTabSelected(false)
3529 #if QT_VERSION < 0x040500
3530 void G4UIQt::TabCloseCallback(
int){
3532 void G4UIQt::TabCloseCallback(
int a){
3534 #if QT_VERSION < 0x040500
3536 if (fViewerTabWidget == NULL)
return;
3539 QWidget* temp = fViewerTabWidget->widget(a);
3541 fViewerTabWidget->removeTab (a);
3547 if (fViewerTabWidget->count() == 0) {
3548 if (fEmptyViewerTabLabel == NULL) {
3549 fEmptyViewerTabLabel =
new QLabel(
"If you want to have a Viewer, please use /vis/open commands.");
3552 fViewerTabHandleWidget->layout()->removeWidget(fViewerTabWidget);
3554 fViewerTabHandleWidget->layout()->addWidget(fEmptyViewerTabLabel);
3556 fEmptyViewerTabLabel->show();
3562 void G4UIQt::ToolBoxActivated(
int a){
3564 if (fUITabWidget->widget(a) == fHelpTBWidget) {
3567 }
else if (fUITabWidget->widget(a) == fSceneTreeComponentsTBWidget) {
3568 #if QT_VERSION < 0x040200
3569 fSceneTreeComponentsTBWidget->show();
3571 fSceneTreeComponentsTBWidget->setVisible(
true);
3577 void G4QTabWidget::paintEvent(
3582 if (currentWidget()) {
3584 if ( isTabSelected()) {
3588 QString text = tabText (currentIndex());
3590 if (fLastCreated == -1) {
3591 QString paramSelect = QString(
"/vis/viewer/select ")+text;
3599 setTabSelected(
false);
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4String GetParameterCandidates() const
const G4String & GetRange() const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
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
G4double G4NeutronHPJENDLHEData::G4double result
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 XML_Char int const XML_Char * value
printf("%d Experimental points found\n", nlines)
const G4String GetParameterGuidance() const
G4String GetParameterRange() const
G4int GetGuidanceEntries() const
G4int GetParameterEntries() const
G4bool GetCurrentAsDefault() const
const XML_Char const XML_Char * data
G4int ApplyCommand(const char *aCommand)