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 <qheaderview.h>
68 #include <qgroupbox.h>
69 #include <qscrollarea.h>
71 #include <qradiobutton.h>
72 #include <qbuttongroup.h>
73 #include <qcombobox.h>
74 #include <qsignalmapper.h>
76 #include <qcolordialog.h>
78 #include <qfiledialog.h>
79 #include <qdesktopwidget.h>
80 #include <qtablewidget.h>
85 static G4bool exitSession =
true;
86 static G4bool exitPause =
true;
115 ,fCoutTBTextArea(NULL)
118 ,fHistoryTBTableList(NULL)
119 ,fHelpTreeWidget(NULL)
121 ,fHistoryTBWidget(NULL)
122 ,fCoutDockWidget(NULL)
124 ,fSceneTreeComponentsTBWidget(NULL)
126 ,fViewerTabWidget(NULL)
129 ,fHelpVSplitter(NULL)
130 ,fParameterHelpLabel(NULL)
131 ,fParameterHelpTable(NULL)
134 ,fStringSeparator(
"__$$$@%%###__")
138 #ifdef G4MULTITHREADED
139 ,fThreadsFilterComboBox(NULL)
141 ,fDefaultViewerFirstPageHTMLText(
"")
142 ,fMoveSelected(false)
143 ,fRotateSelected(true)
144 ,fPickSelected(false)
145 ,fZoomInSelected(false)
146 ,fZoomOutSelected(false)
149 G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(
char*)
"Qt");
150 if (!(QApplication*)interactorManager->GetMainInteractor()) {
155 G4cout <<
"G4UIQt : Unable to init Qt. Aborted" <<
G4endl;
165 Q_FOREACH (QWidget *widget, QApplication::allWidgets()) {
166 if ((found==
false) && (widget->inherits(
"QMainWindow"))) {
176 G4cout <<
"G4UIQt : Found an external App with a QMainWindow already defined. Aborted" <<
G4endl;
180 fMainWindow =
new QMainWindow();
182 fMainWindow->setCorner( Qt::TopLeftCorner, Qt::LeftDockWidgetArea );
183 fMainWindow->setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
184 fMainWindow->setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
185 fMainWindow->setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
187 fMainWindow->setCentralWidget(CreateViewerWidget());
188 fMainWindow->addDockWidget(Qt::LeftDockWidgetArea, CreateUITabWidget());
189 fMainWindow->addDockWidget(Qt::BottomDockWidgetArea, CreateCoutTBWidget());
196 masterG4coutDestination =
this;
198 fMainWindow->setWindowTitle(QFileInfo( QCoreApplication::applicationFilePath() ).fileName());
199 fMainWindow->move(QPoint(50,50));
204 fMainWindow->resize(fUIDockWidget->width()+fCoutDockWidget->width()+20,
205 fUIDockWidget->height()+fCoutDockWidget->height()+20);
208 fCommandArea->setFocus(Qt::TabFocusReason);
212 qRegisterMetaType<QTextCursor>(
"QTextCursor");
215 AddTabWidget(fStartPage,
"Useful tips");
218 #if QT_VERSION < 0x040200
221 fMainWindow->setVisible(
false);
235 masterG4coutDestination = 0;
238 if (fMainWindow!=NULL) {
245 QWidget* G4UIQt::CreateHistoryTBWidget(
248 fHistoryTBWidget =
new QWidget();
250 QVBoxLayout *layoutHistoryTB =
new QVBoxLayout();
251 fHistoryTBTableList =
new QListWidget();
252 fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
253 connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
254 fHistoryTBTableList->installEventFilter(
this);
256 layoutHistoryTB->addWidget(fHistoryTBTableList);
258 fHistoryTBWidget->setLayout(layoutHistoryTB);
259 return fHistoryTBWidget;
265 QWidget* G4UIQt::CreateHelpTBWidget(
268 fHelpTBWidget =
new QWidget();
270 QWidget *helpWidget =
new QWidget();
271 QHBoxLayout *helpLayout =
new QHBoxLayout();
272 QVBoxLayout *vLayout =
new QVBoxLayout();
273 fHelpVSplitter =
new QSplitter(Qt::Vertical);
274 fHelpLine =
new QLineEdit();
275 helpLayout->addWidget(
new QLabel(
"Search :"));
276 helpLayout->addWidget(fHelpLine);
277 connect( fHelpLine, SIGNAL( editingFinished () ),
this, SLOT( LookForHelpStringCallback() ) );
282 fParameterHelpLabel =
new QTextEdit();
283 fParameterHelpLabel->setReadOnly(
true);
284 fParameterHelpTable =
new QTableWidget();
288 if (fHelpTreeWidget) {
289 fHelpVSplitter->addWidget(fHelpTreeWidget);
291 fHelpVSplitter->addWidget(fParameterHelpLabel);
292 fHelpVSplitter->addWidget(fParameterHelpTable);
294 fParameterHelpLabel->setVisible(
false);
295 fParameterHelpTable->setVisible(
false);
296 QSizePolicy policy = QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
297 policy.setVerticalStretch(4);
298 if (fHelpTreeWidget) {
299 fHelpTreeWidget->setSizePolicy(policy);
301 policy = QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
302 policy.setVerticalStretch(1);
303 fParameterHelpLabel->setSizePolicy(policy);
304 fParameterHelpTable->setSizePolicy(policy);
306 vLayout->addWidget(helpWidget);
307 vLayout->addWidget(fHelpVSplitter,1);
308 vLayout->setContentsMargins(5,5,5,5);
310 helpWidget->setLayout(helpLayout);
311 fHelpTBWidget->setLayout(vLayout);
313 return fHelpTBWidget;
319 G4UIDockWidget* G4UIQt::CreateCoutTBWidget(
322 const char *
const search[] = {
334 "OOOOOOOOOOOOOOOOOOO",
335 "OOOOOOOOOOOOOOOOOOO",
336 "OOOOOOOo. .oOOOOOO",
339 "OOOOO. XOOOOX .OOOO",
342 "OOOOO. XOOOOo .OOOO",
346 "OOOOOOOOOOOOO. XOO",
347 "OOOOOOOOOOOOOO. XOO",
348 "OOOOOOOOOOOOOOOoOOO",
349 "OOOOOOOOOOOOOOOOOOO",
350 "OOOOOOOOOOOOOOOOOOO",
351 "OOOOOOOOOOOOOOOOOOO",
352 "OOOOOOOOOOOOOOOOOOO"
355 const char *
const clear[] = {
367 "OOOOOOOOOOOOOOOOOOOO",
370 "OOOOOOOOOOOOOOOOOOOO",
371 "OOOOOOOOOOOOOOOOOOOO",
372 "OOOO XXXXXXXXXX OOOO",
373 "OOO XOOOOOOOOOO OOO",
374 "OOOOXOooOooOooO OOOO",
375 "OOOOXOooOooOooO OOOO",
376 "OOOOXOooOooOooO OOOO",
377 "OOOOXOooOooOooO OOOO",
378 "OOOOXOooOooOooO OOOO",
379 "OOOOXOooOooOooO OOOO",
380 "OOOOXOooOooOooO OOOO",
381 "OOOOXOooOooOooO OOOO",
382 "OOOOXOooOooOooO OOOO",
383 "OOOOXOooOooOooO OOOO",
384 "OOOOXOOOOOOOOOO OOOO",
385 "OOOOOooooooooooOOOOO",
386 "OOOOOO........OOOOOO"
389 fSearchIcon =
new QPixmap(search);
390 fClearIcon =
new QPixmap(clear);
392 QWidget* coutTBWidget =
new QWidget();
394 QVBoxLayout *layoutCoutTB =
new QVBoxLayout();
396 fCoutTBTextArea =
new QTextEdit();
399 fCoutTBTextArea->setFontFamily(
"Courier");
400 fCoutTBTextArea->setFontPointSize(12);
402 fCoutFilter =
new QLineEdit();
403 fCoutFilter->setToolTip(
"Filter output by...");
405 #if QT_VERSION > 0x050100
406 fCoutFilter->addAction(*fSearchIcon,QLineEdit::TrailingPosition);
407 fCoutFilter->setStyleSheet (
"border-radius:7px;");
409 QPushButton *coutTBFilterButton =
new QPushButton();
410 coutTBFilterButton->setIcon(*fSearchIcon);
411 coutTBFilterButton->setStyleSheet (
"padding-left: 0px; border:0px;");
412 fCoutFilter->setStyleSheet (
"padding-right: 0px;");
415 QPushButton *coutTBClearButton =
new QPushButton();
416 coutTBClearButton->setIcon(*fClearIcon);
417 coutTBClearButton->setToolTip(
"Clear console output");
418 coutTBClearButton->setStyleSheet (
"border-radius:7px;");
419 connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
420 connect(fCoutFilter, SIGNAL(textEdited (
const QString &)), SLOT(CoutFilterCallback(
const QString &)));
422 fCoutTBTextArea->setReadOnly(
true);
424 QWidget* coutButtonWidget =
new QWidget();
425 QHBoxLayout* layoutCoutTBButtons =
new QHBoxLayout();
427 #ifdef G4MULTITHREADED
429 fThreadsFilterComboBox =
new QComboBox();
430 fThreadsFilterComboBox->setInsertPolicy(QComboBox::InsertAlphabetically);
431 connect(fThreadsFilterComboBox, SIGNAL(activated(
int)),
this, SLOT(ThreadComboBoxCallback(
int)));
433 UpdateCoutThreadFilter();
435 fThreadsFilterComboBox->setToolTip(
"Thread selection in output");
436 layoutCoutTBButtons->addWidget(
new QLabel(
" Threads:"));
437 layoutCoutTBButtons->addWidget(fThreadsFilterComboBox);
440 layoutCoutTBButtons->addWidget(fCoutFilter);
441 #if QT_VERSION <= 0x050100
442 layoutCoutTBButtons->addWidget(coutTBFilterButton);
444 layoutCoutTBButtons->addWidget(coutTBClearButton);
445 coutButtonWidget->setLayout(layoutCoutTBButtons);
448 layoutCoutTBButtons->setContentsMargins(3,3,3,0);
450 layoutCoutTB->addWidget(coutButtonWidget);
451 layoutCoutTB->addWidget(fCoutTBTextArea);
453 coutTBWidget->setLayout(layoutCoutTB);
455 fCoutTBTextArea->setMinimumSize(100,100);
458 QWidget* commandLineWidget =
new QWidget();
459 QHBoxLayout *layoutCommandLine =
new QHBoxLayout();
463 fCommandLabel =
new QLabel(
"");
465 fCommandArea =
new QLineEdit();
466 fCommandArea->installEventFilter(
this);
467 fCommandArea->activateWindow();
469 fCommandArea->setFocusPolicy ( Qt::StrongFocus );
470 fCommandArea->setFocus(Qt::TabFocusReason);
471 fCommandArea->setToolTip(
"Apply command");
474 layoutCommandLine->addWidget(fCommandLabel);
475 layoutCommandLine->addWidget(fCommandArea);
478 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
479 connect(fCommandArea, SIGNAL(textEdited(
const QString &)), SLOT(CommandEditedCallback(
const QString &)));
482 commandLineWidget->setLayout(layoutCommandLine);
483 commandLineWidget->setMinimumSize(50,50);
485 layoutCoutTB->addWidget(commandLineWidget);
487 fCoutDockWidget =
new G4UIDockWidget (
"Output");
488 fCoutDockWidget->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
490 fCoutDockWidget->setWidget(coutTBWidget);
491 return fCoutDockWidget;
497 QWidget* G4UIQt::CreateVisParametersTBWidget(
506 G4UIDockWidget* G4UIQt::CreateUITabWidget(
509 fUITabWidget =
new QTabWidget();
512 fUITabWidget->addTab(CreateSceneTreeComponentsTBWidget(),
"Scene tree");
513 fUITabWidget->addTab(CreateHelpTBWidget(),
"Help");
514 fUITabWidget->addTab(CreateHistoryTBWidget(),
"History");
515 fUITabWidget->setCurrentWidget(fHelpTBWidget);
517 fUITabWidget->setTabToolTip (0,
"Scene component tree. Only available in Stored mode");
518 fUITabWidget->setTabToolTip (1,
"Help widget");
519 fUITabWidget->setTabToolTip (2,
"All commands history");
520 connect(fUITabWidget, SIGNAL(currentChanged(
int)), SLOT(ToolBoxActivated(
int)));
522 fUIDockWidget =
new G4UIDockWidget (
"Scene tree, Help, History");
523 fUIDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
525 fUIDockWidget->setWidget(fUITabWidget);
527 return fUIDockWidget;
531 QWidget* G4UIQt::CreateSceneTreeComponentsTBWidget(){
533 fSceneTreeComponentsTBWidget =
new QTabWidget();
535 #if QT_VERSION < 0x040200
536 fSceneTreeComponentsTBWidget->hide();
538 fSceneTreeComponentsTBWidget->setVisible(
false);
541 return fSceneTreeComponentsTBWidget;
545 QWidget* G4UIQt::CreateViewerWidget(){
549 SetStartPage(std::string(
"<table width='100%'><tr><td width='30%'></td><td><div ")+
550 "style='color: rgb(140, 31, 31); font-size: xx-large; font-family: Garamond, serif; padding-bottom: 0px; font-weight: normal'>Geant4: "+
551 QApplication::applicationName ().toStdString()+
552 "</div></td><td width='40%'> <br/><i>http://geant4.web.cern.ch/geant4/</i></td></tr></table>"+
554 "<div style='background:#EEEEEE;'><b>Tooltips :</b><ul>"+
555 "<li><b>Start a new viewer :</b><br />"+
556 "<i>'/vis/open/...'<br />"+
557 "For example '/vis/open OGL'</i></li>"+
558 "<li><b>Execute a macro file :</b><br />"+
559 "<i>'/control/execute my_macro_file'</i></li>"+
562 "<div style='background:#EEEEEE;'><b>Documentation :</b><ul>"+
563 "<li><b>Visualization tutorial :</b><br />"+
564 "<i><a href='http://geant4.in2p3.fr/spip.php?article60&lang=en'>Geant4 Qt User Interface tutorial </a>: http://geant4.in2p3.fr/spip.php?article60&lang=en</i></li>"+
565 "<li><b>Visualisation publication :</b><br />"+
566 "<i><a href='http://www.worldscientific.com/doi/abs/10.1142/S1793962313400011'>The Geant4 Visualization System - A Multi-Driver Graphics System</b><br />, Allison, J. et al., International Journal of Modeling, Simulation, and Scientific Computing, Vol. 4, Suppl. 1 (2013) 1340001</a>:<br/> http://www.worldscientific.com/doi/abs/10.1142/S1793962313400011</i></li>"+
569 "<div style='background:#EEEEEE;'><b>Getting Help :</b><ul>"+
570 "<li><b>If problems arise, try <a href='http://geant4-hn.slac.stanford.edu:5090/Geant4-HyperNews/index'>browsing the user forum</a> to see whether or not your problem has already been encountered.<br /> If it hasn't, you can post it and Geant4 developers will do their best to find a solution. This is also a good place to<br /> discuss Geant4 topics in general.</b> http://geant4-hn.slac.stanford.edu:5090/Geant4-HyperNews/index"+
571 "<li><b>Get a look at <a href='http://geant4.kek.jp/geant4/support/index.shtml'>Geant4 User support pages</a>: <i>http://geant4.kek.jp/geant4/support/index.shtml</i></b></li>"+
577 if (fViewerTabWidget == NULL) {
578 fViewerTabWidget =
new G4QTabWidget();
579 #if QT_VERSION < 0x040500
581 fViewerTabWidget->setTabsClosable (
true);
584 #if QT_VERSION < 0x040200
586 fViewerTabWidget->setUsesScrollButtons (
true);
589 #if QT_VERSION < 0x040500
591 connect(fViewerTabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(TabCloseCallback(
int)));
593 connect(fViewerTabWidget, SIGNAL(currentChanged (
int ) ), SLOT(UpdateTabWidget(
int)));
597 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
598 policy.setVerticalStretch(4);
599 fViewerTabWidget->setSizePolicy(policy);
601 fViewerTabWidget->setMinimumSize(40,40);
603 return fViewerTabWidget;
609 QTabWidget* G4UIQt::GetSceneTreeComponentsTBWidget(
612 return fSceneTreeComponentsTBWidget;
620 bool G4UIQt::AddViewerTab(
625 if (fViewerTabWidget == NULL) {
628 fViewerTabWidget->addTab(aWidget,title.c_str());
636 bool G4UIQt::AddViewerTabFromFile(
641 if (fViewerTabWidget == NULL) {
646 if(UI==NULL)
return 0;
647 std::ifstream file(UI->
FindMacroPath(fileName.c_str()).data());
650 std::string content( (std::istreambuf_iterator<char>(file) ),
651 (std::istreambuf_iterator<char>() ) );
653 QTextEdit* text =
new QTextEdit();
654 text->setAcceptRichText (
true);
655 text->setContentsMargins(5,5,5,5);
656 text->setText(QString(
"<pre>")+content.c_str()+
"</pre>");
657 text->setReadOnly(
true);
658 fViewerTabWidget->addTab(text,title.c_str());
669 bool G4UIQt::AddTabWidget(
680 #if QT_VERSION < 0x050100
681 #if QT_VERSION >= 0x050000
682 QString message = QString(
683 "This Qt version [")+qVersion ()+
"] has some issues with the OpenGL viewer.\n"+
684 "To prevent problems, you are not allowed to open a Store nor Immediate viewer.\n" +
686 "Please upgrade to Qt version >= 5.1\n";
688 QMessageBox::warning(fMainWindow, tr(
"Warning"),
689 tr(message.toStdString().c_str()),
696 if (fViewerTabWidget == NULL) {
697 fViewerTabWidget =
new G4QTabWidget();
698 #if QT_VERSION < 0x040500
700 fViewerTabWidget->setTabsClosable (
true);
703 #if QT_VERSION < 0x040200
705 fViewerTabWidget->setUsesScrollButtons (
true);
708 #if QT_VERSION < 0x040500
710 connect(fViewerTabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(TabCloseCallback(
int)));
712 connect(fViewerTabWidget, SIGNAL(currentChanged (
int ) ), SLOT(UpdateTabWidget(
int)));
719 aWidget->setParent(fViewerTabWidget);
722 fViewerTabWidget->addTab(aWidget,name);
724 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
727 #if QT_VERSION < 0x040200
728 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
730 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
741 void G4UIQt::SetStartPage(
742 const std::string& text)
745 fDefaultViewerFirstPageHTMLText = text;
748 fStartPage =
new QTextEdit();
749 fStartPage->setAcceptRichText (
true);
750 fStartPage->setContentsMargins(5,5,5,5);
751 fStartPage->setReadOnly(
true);
753 fStartPage->setText(fDefaultViewerFirstPageHTMLText.c_str());
757 void G4UIQt::UpdateTabWidget(
int tabNumber) {
758 if ( fViewerTabWidget == NULL) {
759 fViewerTabWidget =
new G4QTabWidget;
762 fViewerTabWidget->setCurrentIndex(tabNumber);
765 fViewerTabWidget->setTabSelected(
false);
767 #if QT_VERSION < 0x040200
768 fViewerTabWidget->show();
770 fViewerTabWidget->setVisible(
true);
774 fViewerTabWidget->setTabSelected(
true);
780 void G4UIQt::ResizeTabWidget( QResizeEvent* e) {
781 if ( fViewerTabWidget) {
782 for (
G4int a=0;
a<fViewerTabWidget->count() ;
a++) {
783 fViewerTabWidget->widget(
a)->resize(e->size());
794 G4Qt* interactorManager = G4Qt::getInstance ();
798 QCoreApplication::sendPostedEvents () ;
800 #if QT_VERSION < 0x040200
803 fMainWindow->setVisible(
true);
807 fCommandArea->setFocus();
809 interactorManager->DisableSecondaryLoop ();
810 if ((QApplication*)interactorManager->GetMainInteractor())
811 ((QApplication*)interactorManager->GetMainInteractor())->exec();
813 interactorManager->EnableSecondaryLoop ();
823 void G4UIQt::Prompt (
827 if (!aPrompt)
return;
829 fCommandLabel->setText((
char*)aPrompt.
data());
834 void G4UIQt::SessionTerminate (
837 G4Qt* interactorManager = G4Qt::getInstance ();
838 fMainWindow->close();
839 ((QApplication*)interactorManager->GetMainInteractor())->exit();
852 void G4UIQt::PauseSessionStart (
858 if(aState==
"G4_pause> ") {
859 SecondaryLoop (
"Pause, type continue to exit this state");
862 if(aState==
"EndOfEvent") {
864 SecondaryLoop (
"End of event, type continue to exit this state");
874 void G4UIQt::SecondaryLoop (
878 if (!aPrompt)
return;
880 G4Qt* interactorManager = G4Qt::getInstance ();
884 ((QApplication*)interactorManager)->processEvents(QEventLoop::WaitForMoreEvents);
885 if(exitPause==
true)
break;
890 #ifdef G4MULTITHREADED
904 G4int G4UIQt::ReceiveG4cout (
908 if (!aString)
return 0;
910 #ifdef G4MULTITHREADED
916 if (aString.
contains(
"*** This is just a warning message. ***")) {
917 return ReceiveG4cerr(aString);
923 G4UIOutputString txt = G4UIOutputString(QString((
char*)aString.
data()).trimmed(),GetThreadPrefix());
924 fG4OutputString.push_back(txt);
926 #ifdef G4MULTITHREADED
927 QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
929 QString result = FilterOutput(txt,
"",fCoutFilter->text());
932 if (result.isEmpty()) {
935 QColor previousColor = fCoutTBTextArea->textColor();
936 fCoutTBTextArea->setTextColor(Qt::black);
937 fCoutTBTextArea->append(result);
938 fCoutTBTextArea->setTextColor(previousColor);
939 fCoutTBTextArea->ensureCursorVisible ();
941 #ifdef G4MULTITHREADED
942 UpdateCoutThreadFilter();
953 G4int G4UIQt::ReceiveG4cerr (
957 if (!aString)
return 0;
959 #ifdef G4MULTITHREADED
966 G4UIOutputString txt = G4UIOutputString(QString((
char*)aString.
data()).trimmed(),
969 fG4OutputString.push_back(txt);
971 #ifdef G4MULTITHREADED
972 QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
974 QString result = FilterOutput(txt,
"",fCoutFilter->text());
976 if (result.isEmpty()) {
981 if (QString(aString.
data()).trimmed() !=
"") {
985 QMessageBox::critical(fMainWindow,
"Error",QString(fLastErrMessage.data())+
"\n"+aString.
data());
988 QColor previousColor = fCoutTBTextArea->textColor();
989 fCoutTBTextArea->setTextColor(
Qt::red);
990 fCoutTBTextArea->append(result);
991 fCoutTBTextArea->setTextColor(previousColor);
992 fCoutTBTextArea->ensureCursorVisible ();
994 if (QString(aString.
data()).trimmed() !=
"") {
995 fLastErrMessage = aString;
997 #ifdef G4MULTITHREADED
998 UpdateCoutThreadFilter();
1004 G4String G4UIQt::GetThreadPrefix() {
1006 #ifdef G4MULTITHREADED
1008 if(UI==NULL)
return "";
1016 return threadPrefix;
1020 #ifdef G4MULTITHREADED
1021 void G4UIQt::UpdateCoutThreadFilter() {
1023 if(UI==NULL)
return;
1026 if (fThreadsFilterComboBox->count() < 2) {
1027 if ( fThreadsFilterComboBox->findText(
"All", Qt::MatchExactly) == -1) {
1028 fThreadsFilterComboBox->addItem(
"All");
1031 if (fThreadsFilterComboBox->count() < 2) {
1032 if ( fThreadsFilterComboBox->findText(
"Master", Qt::MatchExactly) == -1) {
1033 fThreadsFilterComboBox->addItem(
"Master");
1039 if ( fThreadsFilterComboBox->findText(prefix.
data(), Qt::MatchExactly) == -1) {
1040 fThreadsFilterComboBox->addItem(prefix.
data());
1052 void G4UIQt::AddMenu (
1057 if (aName == NULL)
return;
1058 if (aLabel == NULL)
return;
1060 QMenu *fileMenu =
new QMenu(aLabel);
1061 fMainWindow->menuBar()->addMenu(fileMenu);
1073 void G4UIQt::AddButton (
1076 ,
const char* aCommand
1079 if(aMenu==NULL)
return;
1080 if(aLabel==NULL)
return;
1081 if(aCommand==NULL)
return;
1083 QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
1085 if(parentTmp==NULL) {
1090 G4cout <<
"Menu name " << aMenu<<
" does not exist, please define it before using it."<<
G4endl;
1097 if(UI==NULL)
return;
1101 G4int cmdEndPos = cmd.find_first_of(
" \t");
1102 if(cmdEndPos!=
G4int(std::string::npos)) {
1103 cmd.erase(cmdEndPos);
1106 if(treeTop->
FindPath(cmd) == NULL) {
1111 G4cout <<
"Warning: command '"<< cmd <<
"' does not exist, please define it before using it."<<
G4endl;
1115 QSignalMapper *signalMapper =
new QSignalMapper(
this);
1116 QAction *action = parentTmp->addAction(aLabel, signalMapper, SLOT(map()));
1118 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
1119 signalMapper->setMapping(action, QString(aCommand));
1128 void G4UIQt::AddIcon(
const char* aLabel,
const char* aIconFile,
const char* aCommand,
const char* aFileName){
1129 if(aLabel==NULL)
return;
1131 if (aCommand==NULL) {
1132 if (std::string(aIconFile) ==
"user_icon") {
1137 bool userToolBar =
false;
1139 if (std::string(aIconFile) ==
"user_icon") {
1147 G4cout <<
"Warning: file '"<< aFileName <<
"' is incorrect or does not exist, this command will not be build"<<
G4endl;
1152 }
else if (std::string(aIconFile) ==
"open") {
1153 const char *
const xpm[]={
1196 " =)!)!!!!~ *#$'' ",
1197 " {]^/((_({- %%%%%%%%%%% ",
1198 " {(^_^^^^:<{{{{{{{{{{{{{[& ",
1199 " {/_/(((((/]]]]]]]]]]]/]!# ",
1200 " {/^(((((_^^^^^^^^^^^^^^:# ",
1201 " {/^(((_^^____________^^}$ ",
1202 " {/^(((((/////////////((!# ",
1203 " {/^/^_:<|||||||||||||||@@****1 ",
1204 " {/^/^(<[)||||||||||||||))!!}<; ",
1205 " {/^_(:|234444444444444444432)1 ",
1206 " {/_^/<)34444444444444444443}, ",
1207 " {/^(2{:41111111111111111142|5 ",
1208 " {3^3<:31111111111111111143}- ",
1209 " {/^2<:31111111111111111441|' ",
1210 " {_/<:41111111111111111143}, ",
1211 " {(4<:31111111111111111144!# ",
1212 " )4))44111111111111111144}, ",
1213 " )2<:31111111111111111144{# ",
1214 " @|:14444444444444444444}* ",
1215 " ;@434444444444444444434<# ",
1216 " ;[))))))))))))))))))))!~ ",
1217 " ++++++++++++++++++++++;% ",
1223 }
else if (std::string(aIconFile) ==
"save") {
1224 const char *
const xpm[]={
1252 " +++++++++++++++++++++++++ ",
1253 " +@##+$%%%%%%%%%%%%%%%&*$%&+ ",
1254 " +=-;@>,,''',,,,,,,',,)&!,)+ ",
1255 " +;-~@>,,,,,,,,,,,,,,,>$!,)+ ",
1256 " +=-~@>,,,,,{]]]]]^,,,>*&$&+ ",
1257 " +=-~@>,,,,,'{^{^^{,,,>*#=#+ ",
1258 " +=-~@>,,,,,,,,,,,,,,,>@~/=+ ",
1259 " +=-~@>,,,{{{''''{',,,>@~-=+ ",
1260 " +=-~@>,,'^]]]]]]({,,,>@~-=+ ",
1261 " +=-~@>,,,{{{{{{{{{,,,>@~-=+ ",
1262 " +=-~@>,,,,,'{^{{^{,,,>@~-=+ ",
1263 " +=-~@>,,,,,]]]]]]],,,>@~-=+ ",
1264 " +=-~*>,,,,,,,,,,,,,,,>@~-=+ ",
1265 " +=-~@>,,,,,,,,,,,,,,,>@~-=+ ",
1266 " +=-/=$%%%%%%%%%%%%%%%$=/-=+ ",
1267 " +=---;###############;---=+ ",
1268 " +=---////////////////----=+ ",
1269 " +=----------------///----=+ ",
1270 " +=---=@##############@#--=+ ",
1271 " +=---@+++++++++++*%))_+~-=+ ",
1272 " +=---#+++++++++++&:,,>@~-=+ ",
1273 " +=---#+++++++++++$',,>@~-=+ ",
1274 " +=---#+++++++++++&!,,>@~-=+ ",
1275 " +=/--#+++++++++++&',,>@~-=+ ",
1276 " @;--#+++++++++++$',,>@~-=+ ",
1277 " @;;@+++++++++++*)!>%@=;#+ ",
1278 " @++++++++++++++*&**++@++ ",
1284 }
else if (std::string(aIconFile) ==
"move") {
1285 const char *
const xpm[]={
1318 " ')&$$$$*@@ @@*$$$$&)' ",
1319 " ')&$$$$*@@ @@*$$$$&+' ",
1338 }
else if (std::string(aIconFile) ==
"rotate") {
1339 const char *
const xpm[]={
1375 " --------!*{{{*&, ",
1376 " -------=){*{{{>>{) ",
1377 " ,!-----= ){& ,&{{@",
1378 " ,*>!----= &>& )@",
1381 " @{* '! ,-!=~^,@ ",
1382 " @& == {/(----!^ ",
1385 " !-!!======!!(((---! ",
1386 " ='--------------! ",
1403 }
else if (std::string(aIconFile) ==
"pick") {
1404 const char *
const xpm[]={
1442 }
else if (std::string(aIconFile) ==
"zoom_in") {
1443 const char *
const xpm[]={
1465 " ++.%%%+&&&*%%.++ ",
1466 " .+#%%%%+&&&*%%.#+ ",
1467 " ++..%%%+&&&*%%%.++ ",
1468 " +#.+++++&&&*++++.+ ",
1469 " @.+&&&&&&&&&&&&&+@ ",
1470 " @#+&&&&&&&&&&&&&+@ ",
1471 " @.+&&&&&&&&&&&&&+. ",
1472 " +++@***+&&&****@+. ",
1473 " ....++++&&&*++++.. ",
1474 " ++.===+&&&*%=.++ ",
1475 " @..==+&&&*=..@#& ",
1476 " .@+#.+&&&@-+@@*@ ",
1477 " +++.++++++ *+@* ",
1490 }
else if (std::string(aIconFile) ==
"zoom_out") {
1491 const char *
const xpm[]={
1513 " ++.$$$$$$$$$$.++ ",
1514 " .+#$$$$$$$$$$$.#+ ",
1515 " ++..$$$$$$$$$$$.++ ",
1516 " +#.+++++++++++++.+ ",
1517 " @.+&&&&&&&&&&&&&+@ ",
1518 " @#+&&&&&&&&&&&&&+@ ",
1519 " @.+&&&&&&&&&&&&&+. ",
1520 " +++@***********@+. ",
1521 " ....++++++++++++.. ",
1522 " ++.===$$$$$$=.++ ",
1523 " @..===$$$$=..@#& ",
1524 " .@+#.$$$..-+@@*@ ",
1525 " +++#--.+++ *+@* ",
1538 }
else if (std::string(aIconFile) ==
"wireframe") {
1539 const char *
const xpm[]={
1568 " +&********&@-***; ",
1569 " +@@@&**&@@@@@@$ @*-&>&+ ",
1570 " +*****&+ %*@ ,**'# ",
1571 " @***)!~ @*{&*****+ ",
1572 " @*!]***&+ +-*^**'~!*@ ",
1573 " @*~ +@&**&@@@@@@&****&+ ~*@ ",
1574 " @*@ +&********&-*= @*@ ",
1575 " @*@ $%@-*-@$ @*@ @*@ ",
1576 " @*@ @*@ %*% @*@ ",
1577 " @*@ %*% %*% @*@ ",
1578 " @*@ %*% %*% @*@ ",
1579 " @*@ %*% %*% @*@ ",
1580 " @*@ %*% %*% @*@ ",
1581 " @*@ %*% %*% @*@ ",
1582 " @*@ @*@ %*% @*@ ",
1583 " @*@ =*-+ @*@ @*@ ",
1584 " @*@ $%@@&****&@-*-+ @*@ ",
1585 " @*@ $@&*****&@@&******&~~!*@ ",
1586 " @*{/***&@@%$ $@-*-&*****+ ",
1587 " @*)*)(-~ @*@ ~)**] ",
1588 " +*******&@@@@+ %*_+]**] ",
1589 " +@@@@@&******&@%+_*^**]# ",
1590 " $%@@@&****:**&+ ",
1599 }
else if (std::string(aIconFile) ==
"solid") {
1600 const char *
const xpm[]={
1638 " +-;>>>>>>>>>,')!~ ",
1639 " {]@@-;>>>>>>>>>>>>^/(_= ",
1640 " {:>>>>>>>>>>>>>>>>><//[)!= ",
1641 " ]>>>>>>>>>>>>>>>>>><////[)} ",
1642 " @>>>>>>>>>>>>>>>>>><//////| ",
1643 " @>>>>>>>>>>>>>>>>>><//////| ",
1644 " @>>>>>>>>>>>>>>>>>><//////| ",
1645 " @>>>>>>>>>>>>>>>>>><//////| ",
1646 " @>>>>>>>>>>>>>>>>>><//////| ",
1647 " @>>>>>>>>>>>>>>>>>><//////| ",
1648 " @>>>>>>>>>>>>>>>>>><//////| ",
1649 " @>>>>>>>>>>>>>>>>>><//////| ",
1650 " @>>>>>>>>>>>>>>>>>><//////| ",
1651 " @>>>>>>>>>>>>>>>>>><//////| ",
1652 " @>>>>>>>>>>>>>>>>>><//////| ",
1653 " @>>>>>>>>>>>>>>>>>><//////| ",
1654 " @>>>>>>>>>>>>>>>>>><//////| ",
1655 " @>>>>>>>>>>>>>>>>>><//////| ",
1656 " @>>>>>>>>>>>>>>>>>></////[1 ",
1657 " @>>>>>>>>>>>>>>>>>><////[*2 ",
1658 " {:>>>>>>>>>>>>>>>>><//[)12 ",
1659 " +@@@@@-;>>>>>>>>>><[)13 ",
1669 }
else if (std::string(aIconFile) ==
"hidden_line_removal") {
1670 const char *
const xpm[]={
1690 " +#$$$$$$$$#@&$$$* ",
1691 " =-@@#$$#@@@@@-= @$&#;>= ",
1692 " =$$$$$#+ -$@ *$$%+ ",
1693 " -$&@-= -$- #$$$= ",
1709 " -$&@@@-= -$- =>;, ",
1710 " =$$$$$$$#@@@-= -$'+#$$, ",
1711 " =-@@@@#$$$$$$#@-+'$)$$#+ ",
1712 " =-@@@#$$$$)$$#+ ",
1721 }
else if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
1722 const char *
const xpm[]={
1768 " ++@%####&*=-#+;>, ",
1769 " +++++@'=)))))))!)~+{]^++ ",
1770 " +$%&*=)!!!!!!!!!)~+/(]_+++ ",
1771 " +#-))!!!!!!!!!!!)~+/(::<[+ ",
1772 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1773 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1774 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1775 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1776 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1777 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1778 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1779 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1780 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1781 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1782 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1783 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1784 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1785 " +#)!!!!!!!!!!!!!!}+/:::|1+ ",
1786 " +$#}}~23!!!!!!!!)~+/(]45, ",
1787 " +++++++@#}}~23!!)~+678++ ",
1788 " ++++++@#~90+a++ ",
1798 }
else if (std::string(aIconFile) ==
"perspective") {
1799 const char *
const xpm[]={
1809 " ................ ",
1810 " ....+++++++++++++++. ",
1811 " ...++++..+.........+++. ",
1812 " ..++..............++..+. ",
1813 " .+++++++++++++++++.. .+. ",
1814 " .+...............+. .+. ",
1815 " .+. .+. .+. .+. ",
1816 " .+. .+. .+. .+. ",
1817 " .+. .+. .+. .+. ",
1818 " .+. .+. .+. .+. ",
1819 " .+. .+. .+. .+. ",
1820 " .+. .+. .+. .+. ",
1821 " .+. .+. .+. .+. ",
1822 " .+. .+. .+. .+. ",
1823 " .+. .+......+....+. ",
1824 " .+. ..++++++.+.++++. ",
1825 " .+. .++.......+...+.. ",
1826 " .+. .++. .+..++. ",
1827 " .+. ..+.. .+..+. ",
1830 " .+++.............++. ",
1831 " .+++++++++++++++++. ",
1832 " ................... ",
1838 }
else if (std::string(aIconFile) ==
"ortho") {
1839 const char *
const xpm[]={
1847 " ................... ",
1848 " ..@@@@@@@@@@@@@@@@@. ",
1849 " ..@@@.............@@@. ",
1850 " ..@@.@. ..@..@. ",
1851 " ..@@ ..@. .@@...@. ",
1852 " ..@@..............@@.. .@. ",
1853 " .@@@@@@@@@@@@@@@@@.. .@. ",
1854 " .@...............@. .@. ",
1855 " .@. .@. .@. .@. ",
1856 " .@. .@. .@. .@. ",
1857 " .@. .@. .@. .@. ",
1858 " .@. .@. .@. .@. ",
1859 " .@. .@. .@. .@. ",
1860 " .@. .@. .@. .@. ",
1861 " .@. .@. .@. .@. ",
1862 " .@. .@. .@. .@. ",
1863 " .@. .@. .@. .@. ",
1864 " .@. .@. .@. .@. ",
1865 " .@. .@........@......@. ",
1866 " .@. .@@@@@@@@@.@.@@@@@@. ",
1867 " .@. .@@+........@....@@.. ",
1868 " .@...@. .@...@... ",
1870 " .@@@.............@@@.. ",
1871 " .@@@@@@@@@@@@@@@@@... ",
1872 " ................... ",
1883 G4cout <<
"Parameter"<< aIconFile <<
" not defined"<<
G4endl;
1887 QToolBar *currentToolbar = NULL;
1889 if (fToolbarUser == NULL) {
1890 fToolbarUser =
new QToolBar();
1891 fToolbarUser->setIconSize (QSize(20,20));
1892 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
1894 currentToolbar = fToolbarUser;
1896 if (fToolbarApp == NULL) {
1897 fToolbarApp =
new QToolBar();
1898 fToolbarApp->setIconSize (QSize(20,20));
1899 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
1901 currentToolbar = fToolbarApp;
1904 QSignalMapper *signalMapper =
new QSignalMapper(
this);
1905 QAction *action = currentToolbar->addAction(pix,aLabel, signalMapper, SLOT(map()));
1909 if (std::string(aIconFile) ==
"open") {
1910 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(OpenIconCallback(
const QString &)));
1911 QString txt = aCommand + fStringSeparator + aLabel;
1912 signalMapper->setMapping(action, QString(txt));
1915 }
else if (std::string(aIconFile) ==
"save") {
1916 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(SaveIconCallback(
const QString&)));
1917 QString txt = aCommand + fStringSeparator + aLabel;
1918 signalMapper->setMapping(action, QString(txt));
1921 }
else if ((std::string(aIconFile) ==
"move") ||
1922 (std::string(aIconFile) ==
"rotate") ||
1923 (std::string(aIconFile) ==
"pick") ||
1924 (std::string(aIconFile) ==
"zoom_out") ||
1925 (std::string(aIconFile) ==
"zoom_in")) {
1926 action->setCheckable(
TRUE);
1927 action->setChecked(
TRUE);
1928 action->setData(aIconFile);
1930 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeCursorStyle(
const QString&)));
1931 signalMapper->setMapping(action, QString(aIconFile));
1933 if (std::string(aIconFile) ==
"move") {
1934 SetIconMoveSelected();
1936 if (std::string(aIconFile) ==
"rotate") {
1937 SetIconRotateSelected();
1939 if (std::string(aIconFile) ==
"pick") {
1940 SetIconPickSelected();
1942 if (std::string(aIconFile) ==
"zoom_in") {
1943 SetIconZoomInSelected();
1945 if (std::string(aIconFile) ==
"zoom_out") {
1946 SetIconZoomOutSelected();
1950 }
else if ((std::string(aIconFile) ==
"hidden_line_removal") ||
1951 (std::string(aIconFile) ==
"hidden_line_and_surface_removal") ||
1952 (std::string(aIconFile) ==
"solid") ||
1953 (std::string(aIconFile) ==
"wireframe")) {
1954 action->setCheckable(
TRUE);
1955 action->setChecked(
TRUE);
1956 action->setData(aIconFile);
1957 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeSurfaceStyle(
const QString&)));
1958 signalMapper->setMapping(action, QString(aIconFile));
1960 if (std::string(aIconFile) ==
"hidden_line_removal") {
1961 SetIconHLRSelected();
1963 if (std::string(aIconFile) ==
"hidden_line_and_surface_removal") {
1964 SetIconHLHSRSelected();
1966 if (std::string(aIconFile) ==
"solid") {
1967 SetIconSolidSelected();
1969 if (std::string(aIconFile) ==
"wireframe") {
1970 SetIconWireframeSelected();
1974 }
else if ((std::string(aIconFile) ==
"perspective") ||
1975 (std::string(aIconFile) ==
"ortho")) {
1976 action->setCheckable(
TRUE);
1977 action->setChecked(
TRUE);
1978 action->setData(aIconFile);
1979 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangePerspectiveOrtho(
const QString&)));
1980 signalMapper->setMapping(action, QString(aIconFile));
1982 if (std::string(aIconFile) ==
"perspective") {
1983 SetIconPerspectiveSelected();
1985 if (std::string(aIconFile) ==
"ortho") {
1986 SetIconOrthoSelected();
1993 if(UI==NULL)
return;
1995 if (aCommand != NULL) {
1996 if(treeTop->
FindPath(aCommand) == NULL) {
2001 G4cout <<
"Warning: command '"<< aCommand <<
"' does not exist, please define it before using it."<<
G4endl;
2006 connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
2007 signalMapper->setMapping(action, QString(aCommand));
2013 void G4UIQt::ActivateCommand(
2017 if (!fHelpTreeWidget) {
2021 size_t i = newCommand.
index(
" ");
2023 if( i != std::string::npos )
2025 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
2027 targetCom = ModifyToFullPathCommand( newValue );
2029 if (targetCom !=
"") {
2030 OpenHelpTreeOnCommand(targetCom.
data());
2033 fUITabWidget->setCurrentWidget(fHelpTBWidget);
2044 void G4UIQt::InitHelpTreeAndVisParametersWidget()
2047 if (! fHelpTreeWidget ) {
2048 fHelpTreeWidget =
new QTreeWidget();
2052 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2054 labels << QString(
"Command");
2055 fHelpTreeWidget->setHeaderLabels(labels);
2058 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),
this, SLOT(HelpTreeClicCallback()));
2059 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,
int)),
this, SLOT(HelpTreeDoubleClicCallback()));
2068 void G4UIQt::FillHelpTree()
2070 if (! fHelpTreeWidget ) {
2071 InitHelpTreeAndVisParametersWidget();
2074 QString searchText = fHelpLine->text();
2076 if (searchText ==
"") {
2083 if (fParameterHelpLabel) {
2084 fParameterHelpLabel->setText(
"Choose a command in the command tree");
2085 fParameterHelpTable->setVisible(
false);
2089 #if QT_VERSION < 0x040200
2092 fHelpLine->setText(
"");
2097 if(UI==NULL)
return;
2101 QTreeWidgetItem * newItem = NULL;
2102 QString commandText =
"";
2103 for (
int a=0;
a<treeSize;
a++) {
2110 for (
int b=0;b<fHelpTreeWidget->topLevelItemCount();b++) {
2112 newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b),commandText);
2115 if (newItem == NULL) {
2117 newItem =
new QTreeWidgetItem();
2118 newItem->setText(0,GetShortCommandPath(commandText));
2119 fHelpTreeWidget->addTopLevelItem(newItem);
2123 CreateHelpTree(newItem,treeTop->
GetTree(
a+1));
2134 void G4UIQt::CreateHelpTree(
2135 QTreeWidgetItem *aParent
2139 if (aParent == NULL)
return;
2140 if (aCommandTree == NULL)
return;
2144 QTreeWidgetItem * newItem;
2146 QString commandText =
"";
2150 commandText = QString((
char*)(aCommandTree->
GetTree(
a+1)->
GetPathName()).data()).trimmed();
2153 newItem = FindTreeItem(aParent,commandText);
2154 if (newItem == NULL) {
2155 newItem =
new QTreeWidgetItem();
2156 newItem->setText(0,GetShortCommandPath(commandText));
2157 aParent->addChild(newItem);
2159 CreateHelpTree(newItem,aCommandTree->
GetTree(
a+1));
2166 QStringList stringList;
2170 newItem = FindTreeItem(aParent,commandText);
2171 if (newItem == NULL) {
2172 newItem =
new QTreeWidgetItem();
2173 newItem->setText(0,GetShortCommandPath(commandText));
2174 aParent->addChild(newItem);
2176 #if QT_VERSION < 0x040202
2177 fHelpTreeWidget->setItemExpanded(newItem,
false);
2179 newItem->setExpanded(
false);
2193 bool G4UIQt::CreateVisCommandGroupAndToolBox(
2200 QString commandText = QString((
char*)(aCommand->
GetCommandPath().
data())).section(
"/",-aDepthLevel);
2202 if (commandText == NULL) {
2208 QWidget* newParentWidget = NULL;
2210 QString commandSection = commandText.left(commandText.indexOf(
"/"));
2212 if (aDepthLevel == 1) {
2213 QToolBox* currentParent =
dynamic_cast<QToolBox*
>(aParent);
2214 if (currentParent != 0){
2217 for (
int a=0;
a<currentParent->count();
a++) {
2218 if (currentParent->itemText(
a) == commandSection) {
2220 newParentWidget = currentParent->widget(
a);
2226 newParentWidget =
new QGroupBox();
2227 newParentWidget->setLayout(
new QVBoxLayout());
2228 if (currentParent != 0){
2229 currentParent->addItem(newParentWidget,commandSection);
2231 if (!aParent->layout()) {
2232 aParent->setLayout(
new QVBoxLayout());
2234 aParent->layout()->addWidget(newParentWidget);
2237 if (commandText.indexOf(
"/") == -1) {
2242 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2243 guidance += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
2245 newParentWidget->setToolTip(guidance);
2248 QScrollArea* sc =
dynamic_cast<QScrollArea*
>(newParentWidget->parent()->parent());
2250 sc->ensureWidgetVisible(newParentWidget);
2257 QGroupBox* currentParent =
dynamic_cast<QGroupBox*
>(aParent);
2258 if (currentParent != 0){
2262 if (aDepthLevel == 2){
2263 QToolBox* parentToolBox =
dynamic_cast<QToolBox*
>(currentParent->parent()->parent()->parent());
2264 if (parentToolBox != 0) {
2268 for (
int a=0;
a<aParent->layout()->count();
a++) {
2269 QGroupBox* gb =
dynamic_cast<QGroupBox*
>(aParent->layout()->itemAt(
a)->widget());
2271 if (gb->title() == commandSection) {
2273 newParentWidget = gb;
2281 newParentWidget =
new QGroupBox();
2282 newParentWidget->setLayout(
new QVBoxLayout());
2283 if (!aParent->layout()) {
2284 aParent->setLayout(
new QVBoxLayout());
2286 aParent->layout()->addWidget(newParentWidget);
2292 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2293 guidance += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
2295 newParentWidget->setToolTip(guidance);
2300 if (commandText.indexOf(
"/") == -1) {
2301 if (CreateCommandWidget(aCommand, newParentWidget,isDialog)) {
2305 CreateVisCommandGroupAndToolBox(aCommand,newParentWidget, aDepthLevel-1,isDialog);
2318 bool G4UIQt::CreateCommandWidget(
G4UIcommand* aCommand, QWidget* aParent,
bool isDialog) {
2320 if (aCommand == NULL) {
2327 if( n_parameterEntry > 0 ) {
2331 QWidget* paramWidget =
new QWidget();
2332 QGridLayout* gridLayout =
new QGridLayout();
2333 paramWidget->setLayout(gridLayout);
2336 unsigned int nbColorParameter = 0;
2337 bool isStillColorParameter =
false;
2338 bool isColorDialogAdded =
false;
2339 QLabel* redLabel = NULL;
2340 QLabel* greenLabel = NULL;
2341 QString redDefaultStr =
"";
2342 QString greenDefaultStr =
"";
2343 QString blueDefaultStr =
"";
2344 QWidget* redInput = NULL;
2345 QWidget* greenInput = NULL;
2347 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2350 QLabel* label =
new QLabel(QString((
char*)(param->
GetParameterName()).data()));
2352 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")){
2353 nbColorParameter ++;
2354 isStillColorParameter =
true;
2355 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2356 nbColorParameter ++;
2357 }
else if ((label->text() ==
"blue") && isStillColorParameter) {
2358 nbColorParameter ++;
2359 }
else if (!isColorDialogAdded) {
2362 if (nbColorParameter == 1) {
2363 gridLayout->addWidget(redLabel,i_thParameter-1,0);
2364 gridLayout->addWidget(redInput,i_thParameter-1,1);
2365 }
else if (nbColorParameter == 2) {
2366 gridLayout->addWidget(redLabel,i_thParameter-2,0);
2367 gridLayout->addWidget(redInput,i_thParameter-2,1);
2368 gridLayout->addWidget(greenLabel,i_thParameter-1,0);
2369 gridLayout->addWidget(greenInput,i_thParameter-1,1);
2371 nbColorParameter = 0;
2374 QWidget* input = NULL;
2376 input =
new QLineEdit();
2378 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
2380 if (((label->text() ==
"red") || (label->text() ==
"red_or_string")) && isStillColorParameter) {
2382 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2384 }
else if ((label->text() ==
"green") && isStillColorParameter) {
2389 input =
new QWidget();
2390 QHBoxLayout* layout =
new QHBoxLayout();
2391 input->setLayout(layout);
2393 QButtonGroup* buttons =
new QButtonGroup();
2394 QRadioButton* radioOff =
new QRadioButton(
"0");
2395 QRadioButton* radioOn =
new QRadioButton(
"1");
2396 buttons->addButton(radioOn);
2397 buttons->addButton(radioOff);
2398 layout->addWidget(radioOn);
2399 layout->addWidget(radioOff);
2402 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
2403 if (defaultValue ==
"0") {
2404 radioOff->setChecked(
true);
2405 }
else if (defaultValue ==
"1") {
2406 radioOn->setChecked(
true);
2409 input =
new QComboBox();
2411 QStringList list = candidates.split (
" ");
2414 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
2415 for (
int a=0;
a<list.size();
a++) {
2416 dynamic_cast<QComboBox*
>(input)->addItem(list.at(
a));
2417 if (list.at(
a) == defaultValue) {
2418 dynamic_cast<QComboBox*
>(input)->setCurrentIndex(
a);
2423 input =
new QLineEdit();
2425 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
2428 input =
new QWidget();
2429 QHBoxLayout* layout =
new QHBoxLayout();
2430 input->setLayout(layout);
2432 QButtonGroup* buttons =
new QButtonGroup();
2433 QRadioButton* radioOff =
new QRadioButton(
"off");
2434 QRadioButton* radioOn =
new QRadioButton(
"on");
2435 buttons->addButton(radioOn);
2436 buttons->addButton(radioOff);
2437 layout->addWidget(radioOn);
2438 layout->addWidget(radioOff);
2441 QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
2442 if (defaultValue ==
"off") {
2443 radioOff->setChecked(
true);
2444 }
else if (defaultValue ==
"on") {
2445 radioOn->setChecked(
true);
2449 input =
new QLineEdit();
2450 dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
2453 txt +=
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) +
"\n";
2457 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2459 txt +=
" Omittable : True\n";
2461 txt +=
" Omittable : False\n";
2464 txt +=
" Default value : taken from the current value\n";
2466 txt +=
" Default value : " + QString((
char*)(param->
GetDefaultValue()).data())+
"\n";
2469 txt +=
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data())+
"\n";
2475 if (isStillColorParameter && (nbColorParameter != 0)) {
2476 if ((label->text() ==
"red") || (label->text() ==
"red_or_string")) {
2479 }
else if (label->text() ==
"green") {
2482 }
else if (label->text() ==
"blue") {
2488 if ((redDefaultStr !=
"") && (redDefaultStr !=
"") && (redDefaultStr !=
"")) {
2489 qc.setRgbF(redDefaultStr.toDouble(),
2490 greenDefaultStr.toDouble(),
2491 blueDefaultStr.toDouble());
2493 QPixmap pixmap = QPixmap(QSize(16, 16));
2495 QPainter painter(&pixmap);
2496 painter.setPen(Qt::black);
2497 painter.drawRect(0,0,15,15);
2499 input =
new QPushButton(
"Change color");
2500 dynamic_cast<QPushButton*
>(input)->setIcon(pixmap);
2501 dynamic_cast<QPushButton*
>(input)->setAccessibleName(redDefaultStr+
" "+greenDefaultStr+
" "+blueDefaultStr);
2502 label =
new QLabel(
"Choose color");
2506 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2507 input->setToolTip(
"Select the current color");
2508 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2511 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2512 signalMapper->setMapping(input,input);
2513 connect(input, SIGNAL(clicked()), signalMapper, SLOT(map()));
2514 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(ChangeColorCallback(QWidget*)));
2516 isColorDialogAdded =
true;
2517 isStillColorParameter =
false;
2520 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
2521 input->setToolTip(txt);
2522 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
2528 gridLayout->addWidget(name,n_parameterEntry-nbColorParameter,0);
2530 QPushButton* applyButton =
new QPushButton(
"Apply");
2533 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,1);
2535 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2536 signalMapper->setMapping(applyButton, paramWidget);
2537 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2538 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2542 applyButton->setAutoDefault(
TRUE );
2543 applyButton->setDefault(
TRUE );
2544 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,0);
2546 QPushButton* cancelButton =
new QPushButton( tr(
"&Cancel" ));
2547 cancelButton->setAutoDefault(
TRUE );
2548 gridLayout->addWidget(cancelButton,n_parameterEntry-nbColorParameter,1);
2550 QSignalMapper* signalMapper =
new QSignalMapper(
this);
2551 signalMapper->setMapping(applyButton, paramWidget);
2552 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
2553 connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
2555 QWidget * parentCheck = aParent;
2556 QDialog* parentDialog = NULL;
2558 while ((parentCheck->parentWidget()) != NULL) {
2559 parentCheck = parentCheck->parentWidget();
2560 parentDialog =
dynamic_cast<QDialog*
>(parentCheck);
2562 connect( applyButton, SIGNAL( clicked() ), parentDialog, SLOT( accept() ) );
2563 connect( cancelButton, SIGNAL( clicked() ), parentDialog, SLOT( reject() ) );
2572 if (!aParent->layout()) {
2573 aParent->setLayout(
new QVBoxLayout());
2575 aParent->layout()->addWidget(paramWidget);
2586 QTreeWidgetItem* G4UIQt::FindTreeItem(
2587 QTreeWidgetItem *aParent
2588 ,
const QString& aCommand
2591 if (aParent == NULL)
return NULL;
2594 QString myCommand = aCommand;
2596 if (myCommand.lastIndexOf(
"/") == (myCommand.size()-1)) {
2597 myCommand = myCommand.left(myCommand.size()-1);
2600 if (GetLongCommandPath(aParent) == myCommand)
2603 QTreeWidgetItem * tmp = NULL;
2604 for (
int a=0;
a<aParent->childCount();
a++) {
2606 tmp = FindTreeItem(aParent->child(
a),myCommand);
2620 QString G4UIQt::GetCommandList (
2626 if (aCommand == NULL)
2634 if ((commandPath ==
"") &&
2635 (rangeString ==
"") &&
2636 (n_guidanceEntry == 0) &&
2637 (n_parameterEntry == 0)) {
2641 if((commandPath.length()-1)!=
'/') {
2642 txt +=
"Command " + QString((
char*)(commandPath).data()) +
"\n";
2644 txt +=
"Guidance :\n";
2646 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2647 txt += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"\n";
2649 if( ! rangeString.
isNull() ) {
2650 txt +=
" Range of parameters : " + QString((
char*)(rangeString).data()) +
"\n";
2652 if( n_parameterEntry > 0 ) {
2657 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2659 txt +=
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) +
"\n";
2662 txt +=
" Parameter type : " + QString(QChar(param->
GetParameterType())) +
"\n";
2664 txt +=
" Omittable : True\n";
2666 txt +=
" Omittable : False\n";
2669 txt +=
" Default value : taken from the current value\n";
2671 txt +=
" Default value : " + QString((
char*)(param->
GetDefaultValue()).data())+
"\n";
2674 txt +=
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data())+
"\n";
2692 void G4UIQt::updateHelpArea (
2696 if (!fParameterHelpLabel)
2698 if (!fParameterHelpTable)
2701 fParameterHelpLabel->setTextInteractionFlags(Qt::NoTextInteraction);
2703 if (aCommand == NULL)
2711 if ((commandPath ==
"") &&
2712 (rangeString ==
"") &&
2713 (n_guidanceEntry == 0) &&
2714 (n_parameterEntry == 0)) {
2718 if((commandPath.length()-1)!=
'/') {
2719 txt +=
"<b>Command </b> " + QString((
char*)(commandPath).data()) +
"<br />";
2721 txt +=
"<b>Guidance :</b> ";
2723 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2724 txt += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) +
"<br />";
2726 if( ! rangeString.
isNull() ) {
2727 txt +=
"<b>Range of parameters : </b> " + QString((
char*)(rangeString).data()) +
"<br />";
2731 fParameterHelpLabel->setHtml(txt);
2733 if( n_parameterEntry > 0 ) {
2738 fParameterHelpTable->clear();
2739 fParameterHelpTable->setRowCount(n_parameterEntry);
2740 fParameterHelpTable->setColumnCount(8);
2741 fParameterHelpTable->setHorizontalHeaderLabels(QStringList() <<
2750 fParameterHelpTable->setColumnWidth(2,60);
2752 fParameterHelpTable->verticalHeader()->setVisible(
false);
2753 fParameterHelpTable->setAlternatingRowColors (
true);
2754 #if QT_VERSION < 0x050000
2755 fParameterHelpTable->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
2756 fParameterHelpTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
2758 fParameterHelpTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
2759 fParameterHelpTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
2761 fParameterHelpTable->setWordWrap(
true);
2763 QTableWidgetItem* t = fParameterHelpTable->horizontalHeaderItem(1);
2764 QFont fnt = t->font();
2765 int size = fnt.pointSize();
2766 fnt.setPointSize(size-2);
2768 for(
G4int a=0;
a<n_parameterEntry;
a++ ) {
2770 fParameterHelpTable->setItem(
a, 0,
new QTableWidgetItem(QString::number(
a+1)));
2772 fParameterHelpTable->setItem(
a, 1,
new QTableWidgetItem(QString((
char*)(param->
GetParameterName()).data())));
2774 fParameterHelpTable->setItem(
a, 2,
new QTableWidgetItem(QString((
char*)(param->
GetParameterGuidance()).data())));
2776 fParameterHelpTable->setItem(
a, 3,
new QTableWidgetItem(QString(QChar(param->
GetParameterType()))));
2779 fParameterHelpTable->setItem(
a, 4,
new QTableWidgetItem(QString(
"True")));
2781 fParameterHelpTable->setItem(
a, 4,
new QTableWidgetItem(QString(
"False")));
2784 fParameterHelpTable->setItem(
a, 5,
new QTableWidgetItem(QString(
"taken from the current value")));
2786 fParameterHelpTable->setItem(
a, 5,
new QTableWidgetItem(QString((
char*)(param->
GetDefaultValue()).data())));
2789 fParameterHelpTable->setItem(
a, 6,
new QTableWidgetItem(QString((
char*)(param->
GetParameterRange()).data())));
2792 fParameterHelpTable->setItem(
a, 7,
new QTableWidgetItem(QString((
char*)(param->
GetParameterCandidates()).data())));
2795 for (
int b=0; b<8; b++) {
2796 QTableWidgetItem* tmp = fParameterHelpTable->item(
a,b);
2798 tmp->setToolTip(tmp->text());
2799 tmp->setFlags(Qt::NoItemFlags);
2800 tmp->setForeground(QBrush());
2804 fParameterHelpTable->resizeRowToContents(
a);
2806 for (
int c=0; c<8; c++) {
2808 fParameterHelpTable->resizeColumnToContents(c);
2812 fParameterHelpTable->setVisible(
true);
2823 G4bool G4UIQt::IsGUICommand(
2827 if (aCommand == NULL)
2832 if( n_parameterEntry > 0 ) {
2837 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
2859 G4bool G4UIQt::GetHelpChoice(
2874 bool G4UIQt::eventFilter(
2879 bool moveCommandCursor =
false;
2880 if (aObj == NULL)
return false;
2881 if (aEvent == NULL)
return false;
2883 if (aObj == fHistoryTBTableList) {
2884 if (aEvent->type() == QEvent::KeyPress) {
2885 fCommandArea->setFocus();
2888 if (aObj == fCommandArea) {
2889 if (aEvent->type() == QEvent::KeyPress) {
2890 QKeyEvent *e =
static_cast<QKeyEvent*
>(aEvent);
2891 if ((e->key() == (Qt::Key_Down)) ||
2892 (e->key() == (Qt::Key_PageDown)) ||
2893 (e->key() == (Qt::Key_Up)) ||
2894 (e->key() == (Qt::Key_PageUp))) {
2895 int selection = fHistoryTBTableList->currentRow();
2896 if (fHistoryTBTableList->count()) {
2897 if (selection == -1) {
2898 selection = fHistoryTBTableList->count()-1;
2900 if (e->key() == (Qt::Key_Down)) {
2901 if (selection <(fHistoryTBTableList->count()-1))
2903 }
else if (e->key() == (Qt::Key_PageDown)) {
2904 selection = fHistoryTBTableList->count()-1;
2905 }
else if (e->key() == (Qt::Key_Up)) {
2908 }
else if (e->key() == (Qt::Key_PageUp)) {
2912 fHistoryTBTableList->clearSelection();
2913 #if QT_VERSION < 0x040202
2914 fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),
true);
2916 fHistoryTBTableList->item(selection)->setSelected(
true);
2918 fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
2920 moveCommandCursor =
true;
2921 }
else if (e->key() == (Qt::Key_Tab)) {
2922 G4String ss = Complete(fCommandArea->text().toStdString().c_str());
2923 fCommandArea->setText((
char*)(ss.
data()));
2929 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
2930 fCommandArea->home(
false);
2932 }
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
2933 fCommandArea->end(
false);
2940 if (moveCommandCursor ==
true) {
2941 fCommandArea->setCursorPosition ( fCommandArea->text().length() );
2942 fCommandArea->setCursorPosition (4);
2945 res = QObject::eventFilter(aObj, aEvent);
2961 void G4UIQt::ShowHelpCallback (
2970 void G4UIQt::ClearButtonCallback (
2973 fCoutTBTextArea->clear();
2974 fG4OutputString.clear();
2979 void G4UIQt::ExitSession (
2985 void G4UIQt::ExitHelp(
2993 void G4UIQt::CommandEnteredCallback (
2997 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
3000 for (
int a=0;
a< list.size();
a++) {
3001 QString txt (list[
a].trimmed());
3003 fHistoryTBTableList->addItem(txt);
3004 fHistoryTBTableList->clearSelection();
3005 fHistoryTBTableList->setCurrentItem(NULL);
3006 fCommandArea->setText(
"");
3007 G4Qt* interactorManager = G4Qt::getInstance ();
3008 if (interactorManager) {
3009 interactorManager->FlushAndWaitExecution();
3012 G4String command = txt.toStdString().c_str();
3013 if (command(0,4) !=
"help") {
3014 ApplyShellCommand (command,exitSession,exitPause);
3016 ActivateCommand(command);
3021 fCommandArea->setFocus();
3026 if(exitSession==
true)
3035 void G4UIQt::CommandEditedCallback(
const QString &)
3037 QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
3039 if (list.size() > 1) {
3040 for (
int a=0;
a<list.size()-1;
a++) {
3042 fCommandArea->setText(list[
a]);
3044 CommandEnteredCallback();
3047 fCommandArea->setText(list[list.size()-1]);
3054 void G4UIQt::VisParameterCallback(QWidget* widget){
3055 if (widget == NULL) {
3060 QGridLayout* grid =
dynamic_cast<QGridLayout*
>(widget->layout());
3065 #if QT_VERSION < 0x040400
3066 QWidget* name = grid->itemAt(grid->columnCount()*(grid->rowCount()-2))->widget();
3068 QWidget* name = grid->itemAtPosition(grid->rowCount()-1,0)->widget();
3070 if (dynamic_cast<QLabel*>(name) == 0) {
3073 command += (
dynamic_cast<QLabel*
>(
name))->text()+
" ";
3075 for (
int a=0;
a<grid->rowCount()-1;
a++) {
3076 #if QT_VERSION < 0x040400
3077 QWidget* widgetTmp = grid->itemAt(
a*grid->columnCount()+1)->widget();
3079 QWidget* widgetTmp = grid->itemAtPosition(
a,1)->widget();
3083 if (widgetTmp != NULL) {
3085 if (dynamic_cast<QLineEdit*>(widgetTmp) != 0) {
3086 command += (
dynamic_cast<QLineEdit*
>(widgetTmp))->text()+
" ";
3088 }
else if (dynamic_cast<QComboBox*>(widgetTmp) != 0){
3089 command += (
dynamic_cast<QComboBox*
>(widgetTmp))->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex())+
" ";
3092 }
else if (dynamic_cast<QPushButton*>(widgetTmp) != 0){
3093 command += widgetTmp->accessibleName()+
" ";
3096 }
else if (dynamic_cast<QWidget*>(widgetTmp) != 0){
3097 if (widgetTmp->layout()->count() > 0){
3098 if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != 0) {
3099 QAbstractButton * checked = (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton();
3101 command += (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton()->text()+
" ";
3109 if (command !=
"") {
3123 void G4UIQt::ButtonCallback (
3124 const QString& aCommand
3131 if(UI==NULL)
return;
3138 if (IsGUICommand(command)) {
3139 QDialog* menuParameterDialog =
new QDialog();
3141 if (CreateVisCommandGroupAndToolBox(command,menuParameterDialog,1,
true)) {
3142 menuParameterDialog->setWindowTitle (aCommand);
3143 menuParameterDialog->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
3146 menuParameterDialog->exec();
3152 ApplyShellCommand(ss,exitSession,exitPause);
3157 if(exitSession==
true)
3165 void G4UIQt::HelpTreeClicCallback (
3168 QTreeWidgetItem* item = NULL;
3169 if (!fHelpTreeWidget)
3172 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
3175 item = list.first();
3180 if(UI==NULL)
return;
3183 std::string itemText = GetLongCommandPath(item).toStdString();
3186 if (item->childCount() > 0) {
3192 updateHelpArea(command);
3198 fParameterHelpLabel->setVisible(
true);
3200 fParameterHelpTable->setVisible(
false);
3207 void G4UIQt::HelpTreeDoubleClicCallback (
3210 HelpTreeClicCallback();
3212 QTreeWidgetItem* item = NULL;
3213 if (!fHelpTreeWidget)
3216 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
3219 item = list.first();
3223 fCommandArea->clear();
3224 fCommandArea->setText(GetLongCommandPath(item));
3231 void G4UIQt::CommandHistoryCallback(
3234 QListWidgetItem* item = NULL;
3235 if (!fHistoryTBTableList)
3239 QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
3242 item = list.first();
3245 fCommandArea->setText(item->text());
3249 void G4UIQt::ThreadComboBoxCallback(
int) {
3250 CoutFilterCallback(
"");
3254 void G4UIQt::CoutFilterCallback(
3257 FilterAllOutputTextArea();
3259 fCoutTBTextArea->repaint();
3260 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
3265 QString G4UIQt::FilterOutput(
3266 const G4UIOutputString& output
3267 ,
const QString& currentThread
3268 ,
const QString& filter
3271 #ifdef G4MULTITHREADED
3272 if ((currentThread ==
"All") ||
3273 (currentThread == output.fThread)) {
3275 if (currentThread ==
"") {
3277 if (output.fText.contains(QRegExp(filter))) {
3278 return output.fText;
3285 void G4UIQt::FilterAllOutputTextArea() {
3287 QString currentThread =
"";
3288 #ifdef G4MULTITHREADED
3289 currentThread = fThreadsFilterComboBox->currentText();
3290 if (currentThread ==
"Master") {
3294 QString filter = fCoutFilter->text();
3295 G4String previousOutputStream =
"";
3297 fCoutTBTextArea->clear();
3298 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3300 for (
unsigned int a=0;
a<fG4OutputString.size();
a++) {
3301 G4UIOutputString out = fG4OutputString[
a];
3302 if (FilterOutput(out,currentThread,filter) !=
"") {
3305 if (out.fOutputStream != previousOutputStream) {
3306 previousOutputStream = out.fOutputStream;
3307 if (out.fOutputStream ==
"info") {
3308 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3310 fCoutTBTextArea->setTextColor(QColor(
Qt::red));
3313 fCoutTBTextArea->
append(out.fText);
3316 fCoutTBTextArea->setTextColor(QColor(Qt::black));
3324 void G4UIQt::LookForHelpStringCallback(
3327 QString searchText = fHelpLine->text();
3329 fParameterHelpLabel->setText(
"");
3330 fParameterHelpTable->setVisible(
false);
3331 if (searchText ==
"") {
3333 fHelpTreeWidget->clear();
3339 OpenHelpTreeOnCommand(searchText);
3344 void G4UIQt::OpenHelpTreeOnCommand(
3345 const QString & searchText
3350 if(UI==NULL)
return;
3356 fHelpTreeWidget->clear();
3362 QMap<int,QString> commandResultMap;
3363 QMap<int,QString> commandChildResultMap;
3365 for (
int a=0;
a<treeSize;
a++) {
3367 tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
3369 commandResultMap.insertMulti(tmp,QString((
char*)(treeTop->
GetTree(
a+1)->
GetPathName()).data()));
3372 commandChildResultMap = LookForHelpStringInChildTree(treeTop->
GetTree(
a+1),searchText);
3374 if (!commandChildResultMap.empty()) {
3375 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
3376 while (i != commandChildResultMap.constEnd()) {
3377 commandResultMap.insertMulti(i.key(),i.value());
3380 commandChildResultMap.clear();
3385 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
3386 fHelpTreeWidget->setColumnCount(2);
3388 labels << QString(
"Command") << QString(
"Match");
3389 fHelpTreeWidget->setHeaderLabels(labels);
3391 if (commandResultMap.empty()) {
3392 fParameterHelpLabel->setText(
"No match found");
3393 fParameterHelpTable->setVisible(
false);
3397 QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
3400 float multValue = 10.0/(float)(i.key());
3401 QString progressChar =
"|";
3402 QString progressStr =
"|";
3404 QTreeWidgetItem * newItem;
3407 if (i == commandResultMap.constBegin()) {
3410 for(
int a=0;
a<int(i.key()*multValue);
a++) {
3411 progressStr += progressChar;
3413 newItem =
new QTreeWidgetItem();
3414 QString commandStr = i.value().trimmed();
3416 if (commandStr.indexOf(
"/") == 0) {
3417 commandStr = commandStr.right(commandStr.size()-1);
3420 newItem->setText(0,commandStr);
3421 newItem->setText(1,progressStr);
3422 fHelpTreeWidget->addTopLevelItem(newItem);
3423 #if QT_VERSION < 0x040200
3425 newItem->setForeground ( 1, QBrush(
Qt::blue) );
3430 fHelpTreeWidget->resizeColumnToContents (0);
3431 fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
3438 QMap<int,QString> G4UIQt::LookForHelpStringInChildTree(
3440 ,
const QString & text
3443 QMap<int,QString> commandResultMap;
3444 if (aCommandTree == NULL)
return commandResultMap;
3449 QMap<int,QString> commandChildResultMap;
3453 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
3455 commandResultMap.insertMulti(tmp,QString((
char*)(aCommandTree->
GetTree(
a+1)->
GetPathName()).data()));
3458 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->
GetTree(
a+1),text);
3460 if (!commandChildResultMap.empty()) {
3462 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
3463 while (i != commandChildResultMap.constEnd()) {
3464 commandResultMap.insertMulti(i.key(),i.value());
3467 commandChildResultMap.clear();
3474 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
3480 return commandResultMap;
3484 QString G4UIQt::GetShortCommandPath(
3488 if (commandPath.indexOf(
"/") == 0) {
3489 commandPath = commandPath.right(commandPath.size()-1);
3492 commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf(
"/",-2)-1);
3494 if (commandPath.lastIndexOf(
"/") == (commandPath.size()-1)) {
3495 commandPath = commandPath.left(commandPath.size()-1);
3502 QString G4UIQt::GetLongCommandPath(
3503 QTreeWidgetItem* item
3506 if (item == NULL)
return "";
3509 QString itemText =
"";
3510 itemText = item->text(0);
3512 while (item->parent() != NULL) {
3513 itemText = item->parent()->text(0)+
"/"+itemText;
3514 item = item->parent();
3516 itemText =
"/"+itemText;
3522 void G4UIQt::ChangeColorCallback(QWidget* widget) {
3523 if (widget == NULL) {
3527 QPushButton* button =
dynamic_cast<QPushButton*
>(widget);
3531 QString value = button->accessibleName();
3534 old.setRgbF(value.section(
" ",0,1).toDouble(),
3535 value.section(
" ",1,2).toDouble(),
3536 value.section(
" ",2,3).toDouble());
3537 #if QT_VERSION < 0x040500
3539 QColor color = QColor(QColorDialog::getRgba (old.rgba(),&
a,fUITabWidget));
3541 QColor color = QColorDialog::getColor(old,
3544 QColorDialog::ShowAlphaChannel);
3548 if (color.isValid()) {
3550 QPixmap pixmap = QPixmap(QSize(16, 16));
3551 pixmap.fill (color);
3552 QPainter painter(&pixmap);
3553 painter.setPen(Qt::black);
3554 painter.drawRect(0,0,15,15);
3556 button->setAccessibleName(QString::number(color.redF())+
" "+
3557 QString::number(color.greenF())+
" "+
3558 QString::number(color.blueF())+
" "
3560 button->setIcon(pixmap);
3567 void G4UIQt::ChangeCursorStyle(
const QString& action) {
3571 fMoveSelected =
true;
3572 fPickSelected =
true;
3573 fRotateSelected =
true;
3574 fZoomInSelected =
true;
3575 fZoomOutSelected =
true;
3577 if (fToolbarApp == NULL)
return;
3578 QList<QAction *> list = fToolbarApp->actions ();
3579 for (
int i = 0; i < list.size(); ++i) {
3580 if (list.at(i)->data().toString () == action) {
3581 list.at(i)->setChecked(
TRUE);
3582 if (list.at(i)->data().toString () ==
"pick") {
3585 }
else if (list.at(i)->data().toString () ==
"move") {
3586 fMoveSelected =
false;
3587 list.at(i)->setChecked(
FALSE);
3588 }
else if (list.at(i)->data().toString () ==
"pick") {
3589 fPickSelected =
false;
3590 list.at(i)->setChecked(
FALSE);
3592 }
else if (list.at(i)->data().toString () ==
"rotate") {
3593 fRotateSelected =
false;
3594 list.at(i)->setChecked(
FALSE);
3595 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3596 fZoomInSelected =
false;
3597 list.at(i)->setChecked(
FALSE);
3598 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3599 fZoomOutSelected =
false;
3600 list.at(i)->setChecked(
FALSE);
3613 void G4UIQt::ChangeSurfaceStyle(
const QString& action) {
3617 if (fToolbarApp == NULL)
return;
3618 QList<QAction *> list = fToolbarApp->actions ();
3619 for (
int i = 0; i < list.size(); ++i) {
3620 if (list.at(i)->data().toString () == action) {
3621 list.at(i)->setChecked(
TRUE);
3622 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3623 list.at(i)->setChecked(
FALSE);
3624 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3625 list.at(i)->setChecked(
FALSE);
3626 }
else if (list.at(i)->data().toString () ==
"solid") {
3627 list.at(i)->setChecked(
FALSE);
3628 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3629 list.at(i)->setChecked(
FALSE);
3634 if (action ==
"hidden_line_removal") {
3638 }
else if (action ==
"hidden_line_and_surface_removal") {
3642 }
else if (action ==
"solid") {
3646 }
else if (action ==
"wireframe") {
3653 void G4UIQt::OpenIconCallback(
const QString& aParam) {
3655 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
3656 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
3658 QString nomFich = QFileDialog::getOpenFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
3659 if (nomFich !=
"") {
3662 fLastOpenPath = dir.absoluteFilePath(nomFich);
3667 void G4UIQt::SaveIconCallback(
const QString& aParam) {
3669 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
3670 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
3672 QString nomFich = QFileDialog::getSaveFileName(fMainWindow, aLabel, fLastOpenPath,
"Macro files (*.mac)");
3673 if (nomFich !=
"") {
3676 fLastOpenPath = dir.absoluteFilePath(nomFich);
3682 void G4UIQt::ChangePerspectiveOrtho(
const QString& action) {
3686 if (fToolbarApp == NULL)
return;
3687 QList<QAction *> list = fToolbarApp->actions ();
3688 QString checked =
"";
3689 for (
int i = 0; i < list.size(); ++i) {
3690 if (list.at(i)->data().toString () == action) {
3691 list.at(i)->setChecked(
TRUE);
3692 checked = list.at(i)->data().toString ();
3693 }
else if (list.at(i)->data().toString () ==
"persepective") {
3694 list.at(i)->setChecked(
FALSE);
3695 }
else if (list.at(i)->data().toString () ==
"ortho") {
3696 list.at(i)->setChecked(
FALSE);
3700 if ((action ==
"ortho") && (checked ==
"ortho")) {
3702 }
else if ((action ==
"perspective") && (checked ==
"perspective")) {
3709 void G4UIQt::SetIconMoveSelected() {
3711 fMoveSelected =
true;
3712 fRotateSelected =
false;
3713 fPickSelected =
false;
3714 fZoomInSelected =
false;
3715 fZoomOutSelected =
false;
3717 if (fToolbarApp == NULL)
return;
3718 QList<QAction *> list = fToolbarApp->actions ();
3719 for (
int i = 0; i < list.size(); ++i) {
3720 if (list.at(i)->data().toString () ==
"move") {
3721 list.at(i)->setChecked(
TRUE);
3722 }
else if (list.at(i)->data().toString () ==
"rotate") {
3723 list.at(i)->setChecked(
FALSE);
3724 }
else if (list.at(i)->data().toString () ==
"pick") {
3725 list.at(i)->setChecked(
FALSE);
3726 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3727 list.at(i)->setChecked(
FALSE);
3728 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3729 list.at(i)->setChecked(
FALSE);
3735 void G4UIQt::SetIconRotateSelected() {
3737 fRotateSelected =
true;
3738 fMoveSelected =
false;
3739 fPickSelected =
false;
3740 fZoomInSelected =
false;
3741 fZoomOutSelected =
false;
3743 if (fToolbarApp == NULL)
return;
3744 QList<QAction *> list = fToolbarApp->actions ();
3745 for (
int i = 0; i < list.size(); ++i) {
3746 if (list.at(i)->data().toString () ==
"rotate") {
3747 list.at(i)->setChecked(
TRUE);
3748 }
else if (list.at(i)->data().toString () ==
"move") {
3749 list.at(i)->setChecked(
FALSE);
3750 }
else if (list.at(i)->data().toString () ==
"pick") {
3751 list.at(i)->setChecked(
FALSE);
3752 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3753 list.at(i)->setChecked(
FALSE);
3754 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3755 list.at(i)->setChecked(
FALSE);
3761 void G4UIQt::SetIconPickSelected() {
3763 fPickSelected =
true;
3764 fMoveSelected =
false;
3765 fRotateSelected =
false;
3766 fZoomInSelected =
false;
3767 fZoomOutSelected =
false;
3769 if (fToolbarApp == NULL)
return;
3770 QList<QAction *> list = fToolbarApp->actions ();
3771 for (
int i = 0; i < list.size(); ++i) {
3772 if (list.at(i)->data().toString () ==
"pick") {
3773 list.at(i)->setChecked(
TRUE);
3774 }
else if (list.at(i)->data().toString () ==
"move") {
3775 list.at(i)->setChecked(
FALSE);
3776 }
else if (list.at(i)->data().toString () ==
"rotate") {
3777 list.at(i)->setChecked(
FALSE);
3778 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3779 list.at(i)->setChecked(
FALSE);
3780 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3781 list.at(i)->setChecked(
FALSE);
3787 void G4UIQt::SetIconZoomInSelected() {
3789 fZoomInSelected =
true;
3790 fMoveSelected =
false;
3791 fRotateSelected =
false;
3792 fPickSelected =
false;
3793 fZoomOutSelected =
false;
3795 if (fToolbarApp == NULL)
return;
3796 QList<QAction *> list = fToolbarApp->actions ();
3797 for (
int i = 0; i < list.size(); ++i) {
3798 if (list.at(i)->data().toString () ==
"zoom_in") {
3799 list.at(i)->setChecked(
TRUE);
3800 }
else if (list.at(i)->data().toString () ==
"move") {
3801 list.at(i)->setChecked(
FALSE);
3802 }
else if (list.at(i)->data().toString () ==
"rotate") {
3803 list.at(i)->setChecked(
FALSE);
3804 }
else if (list.at(i)->data().toString () ==
"pick") {
3805 list.at(i)->setChecked(
FALSE);
3806 }
else if (list.at(i)->data().toString () ==
"zoom_out") {
3807 list.at(i)->setChecked(
FALSE);
3813 void G4UIQt::SetIconZoomOutSelected() {
3815 fZoomOutSelected =
true;
3816 fMoveSelected =
false;
3817 fRotateSelected =
false;
3818 fPickSelected =
false;
3819 fZoomInSelected =
false;
3821 if (fToolbarApp == NULL)
return;
3822 QList<QAction *> list = fToolbarApp->actions ();
3823 for (
int i = 0; i < list.size(); ++i) {
3824 if (list.at(i)->data().toString () ==
"zoom_out") {
3825 list.at(i)->setChecked(
TRUE);
3826 }
else if (list.at(i)->data().toString () ==
"move") {
3827 list.at(i)->setChecked(
FALSE);
3828 }
else if (list.at(i)->data().toString () ==
"rotate") {
3829 list.at(i)->setChecked(
FALSE);
3830 }
else if (list.at(i)->data().toString () ==
"pick") {
3831 list.at(i)->setChecked(
FALSE);
3832 }
else if (list.at(i)->data().toString () ==
"zoom_in") {
3833 list.at(i)->setChecked(
FALSE);
3839 void G4UIQt::SetIconSolidSelected() {
3842 if (fToolbarApp == NULL)
return;
3843 QList<QAction *> list = fToolbarApp->actions ();
3844 for (
int i = 0; i < list.size(); ++i) {
3845 if (list.at(i)->data().toString () ==
"solid") {
3846 list.at(i)->setChecked(
TRUE);
3847 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3848 list.at(i)->setChecked(
FALSE);
3849 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3850 list.at(i)->setChecked(
FALSE);
3851 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3852 list.at(i)->setChecked(
FALSE);
3858 void G4UIQt::SetIconWireframeSelected() {
3861 if (fToolbarApp == NULL)
return;
3862 QList<QAction *> list = fToolbarApp->actions ();
3863 for (
int i = 0; i < list.size(); ++i) {
3864 if (list.at(i)->data().toString () ==
"wireframe") {
3865 list.at(i)->setChecked(
TRUE);
3866 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3867 list.at(i)->setChecked(
FALSE);
3868 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3869 list.at(i)->setChecked(
FALSE);
3870 }
else if (list.at(i)->data().toString () ==
"solid") {
3871 list.at(i)->setChecked(
FALSE);
3877 void G4UIQt::SetIconHLRSelected() {
3880 if (fToolbarApp == NULL)
return;
3881 QList<QAction *> list = fToolbarApp->actions ();
3882 for (
int i = 0; i < list.size(); ++i) {
3883 if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3884 list.at(i)->setChecked(
TRUE);
3885 }
else if (list.at(i)->data().toString () ==
"solid") {
3886 list.at(i)->setChecked(
FALSE);
3887 }
else if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3888 list.at(i)->setChecked(
FALSE);
3889 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3890 list.at(i)->setChecked(
FALSE);
3896 void G4UIQt::SetIconHLHSRSelected() {
3899 if (fToolbarApp == NULL)
return;
3900 QList<QAction *> list = fToolbarApp->actions ();
3901 for (
int i = 0; i < list.size(); ++i) {
3902 if (list.at(i)->data().toString () ==
"hidden_line_and_surface_removal") {
3903 list.at(i)->setChecked(
TRUE);
3904 }
else if (list.at(i)->data().toString () ==
"solid") {
3905 list.at(i)->setChecked(
FALSE);
3906 }
else if (list.at(i)->data().toString () ==
"hidden_line_removal") {
3907 list.at(i)->setChecked(
FALSE);
3908 }
else if (list.at(i)->data().toString () ==
"wireframe") {
3909 list.at(i)->setChecked(
FALSE);
3915 void G4UIQt::SetIconPerspectiveSelected() {
3918 if (fToolbarApp == NULL)
return;
3919 QList<QAction *> list = fToolbarApp->actions ();
3920 for (
int i = 0; i < list.size(); ++i) {
3921 if (list.at(i)->data().toString () ==
"perspective") {
3922 list.at(i)->setChecked(
TRUE);
3923 }
else if (list.at(i)->data().toString () ==
"ortho") {
3924 list.at(i)->setChecked(
FALSE);
3931 void G4UIQt::SetIconOrthoSelected() {
3934 if (fToolbarApp == NULL)
return;
3935 QList<QAction *> list = fToolbarApp->actions ();
3936 for (
int i = 0; i < list.size(); ++i) {
3937 if (list.at(i)->data().toString () ==
"ortho") {
3938 list.at(i)->setChecked(
TRUE);
3939 }
else if (list.at(i)->data().toString () ==
"perspective") {
3940 list.at(i)->setChecked(
FALSE);
3947 G4QTabWidget::G4QTabWidget(
3951 ):QTabWidget(aParent)
3952 ,fTabSelected(false)
3954 ,fPreferedSizeX(sizeX+6)
3955 ,fPreferedSizeY(sizeY+58)
3957 setMinimumSize(100,100);
3958 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
3959 setSizePolicy(policy);
3962 G4QTabWidget::G4QTabWidget(
3964 ,fTabSelected(false)
3972 G4UIOutputString::G4UIOutputString(
3980 if (!GetOutputList().contains(QString(
" ")+outputStream+
" ")) {
3981 fOutputStream =
"info";
3983 fOutputStream = outputStream;
3988 #if QT_VERSION < 0x040500
3989 void G4UIQt::TabCloseCallback(
int){
3991 void G4UIQt::TabCloseCallback(
int a){
3993 #if QT_VERSION < 0x040500
3995 if (fViewerTabWidget == NULL)
return;
3998 QWidget* temp = fViewerTabWidget->widget(a);
4000 fViewerTabWidget->removeTab (a);
4008 void G4UIQt::ToolBoxActivated(
int a){
4010 if (fUITabWidget->widget(a) == fHelpTBWidget) {
4013 }
else if (fUITabWidget->widget(a) == fSceneTreeComponentsTBWidget) {
4014 #if QT_VERSION < 0x040200
4015 fSceneTreeComponentsTBWidget->show();
4017 fSceneTreeComponentsTBWidget->setVisible(
true);
4023 void G4QTabWidget::paintEvent(
4028 if (currentWidget()) {
4030 if ( isTabSelected()) {
4034 QString text = tabText (currentIndex());
4036 if (fLastCreated == -1) {
4037 QTextEdit* edit =
dynamic_cast<QTextEdit*
>(currentWidget());
4039 QString paramSelect = QString(
"/vis/viewer/select ")+text;
4048 setTabSelected(
false);
4054 G4UIDockWidget::G4UIDockWidget(QString txt):
4059 void G4UIDockWidget::closeEvent(QCloseEvent *aEvent) {
4060 setFloating (
false);
G4UIcommandTree * FindCommandTree(const char *commandPath)
Try to match a command or a path with the one given.
G4MTcoutDestination * GetThreadCout()
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)
G4String GetFullPrefixString() const
G4int GetTreeEntry() const
G4int GetVerboseLevel() const
void SetSession(G4UIsession *const value)
const G4String & GetGuidanceLine(G4int i) const
#define G4MUTEX_INITIALIZER
void SetG4UIWindow(G4UIsession *const value)
static G4UImanager * GetUIpointer()
G4bool IsOmittable() const
G4String GetPrefixString() const
static G4StateManager * GetStateManager()
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4UIcommandTree * GetTree(G4int i)
G4UIparameter * GetParameter(G4int i) const
const G4String & GetCommandPath() const
G4ApplicationState GetCurrentState() const
const G4String GetPathName() const
G4bool contains(const std::string &) const
const char * data() const
const G4String GetTitle() const
G4UIcommandTree * GetTree() const
G4String & append(const G4String &)
G4String GetDefaultValue() const
void SetCoutDestination(G4UIsession *const value)
const G4UIcommand * GetGuidance() const
char GetParameterType() const
const G4String GetParameterGuidance() const
G4String GetParameterRange() const
G4int GetGuidanceEntries() const
G4int GetParameterEntries() const
G4String FindMacroPath(const G4String &fname) const
G4bool GetCurrentAsDefault() const
G4int ApplyCommand(const char *aCommand)