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   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 void 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     fMainWindow->setCentralWidget(fViewerTabWidget);
   580 #if QT_VERSION < 0x040500   582     fViewerTabWidget->setTabsClosable (
true);
   585 #if QT_VERSION < 0x040200   587     fViewerTabWidget->setUsesScrollButtons (
true);
   590 #if QT_VERSION < 0x040500   592     connect(fViewerTabWidget,   SIGNAL(tabCloseRequested(
int)), 
this, SLOT(TabCloseCallback(
int)));
   594     connect(fViewerTabWidget, SIGNAL(currentChanged ( 
int ) ), SLOT(UpdateTabWidget(
int)));
   598   QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
   599   policy.setVerticalStretch(4);
   600   fViewerTabWidget->setSizePolicy(policy);
   602   fViewerTabWidget->setMinimumSize(40,40);
   608 QTabWidget* G4UIQt::GetSceneTreeComponentsTBWidget(
   611   return fSceneTreeComponentsTBWidget;
   619 bool G4UIQt::AddViewerTab(
   624   if (fViewerTabWidget == NULL) {
   627   fViewerTabWidget->addTab(aWidget,title.c_str());
   635 bool G4UIQt::AddViewerTabFromFile(
   640   if (fViewerTabWidget == NULL) {
   645   if(UI==NULL) 
return 0;
   649     std::string content( (std::istreambuf_iterator<char>(
file) ),
   650                         (std::istreambuf_iterator<char>()    ) );
   652     QTextEdit* text = 
new QTextEdit();
   653     text->setAcceptRichText (
true);
   654     text->setContentsMargins(5,5,5,5);
   655     text->setText(QString(
"<pre>")+content.c_str()+
"</pre>");
   656     text->setReadOnly(
true);
   657     fViewerTabWidget->addTab(text,title.c_str());
   668 bool G4UIQt::AddTabWidget(
   679   #if QT_VERSION < 0x050100   680    #if QT_VERSION >= 0x050000   681   QString message = QString(
   682                             "This Qt version [")+qVersion ()+
"] has some issues with the OpenGL viewer.\n"+
   683   "To prevent problems, you are not allowed to open a Stored nor Immediate viewer.\n" +
   685   "Please upgrade to Qt version >= 5.1\n";
   687   QMessageBox::warning(fMainWindow, tr(
"Warning"),
   688                        tr(message.toStdString().c_str()),
   695   if (fViewerTabWidget == NULL) {
   696     CreateViewerWidget();
   703   aWidget->setParent(fViewerTabWidget); 
   706   fViewerTabWidget->addTab(aWidget,name);
   708   fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
   711  #if QT_VERSION < 0x040200   712    fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
   714    fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
   725 void G4UIQt::SetStartPage(
   726 const std::string& text)
   729     fDefaultViewerFirstPageHTMLText = text;
   732     fStartPage = 
new QTextEdit();
   733     fStartPage->setAcceptRichText (
true);
   734     fStartPage->setContentsMargins(5,5,5,5);
   735     fStartPage->setReadOnly(
true);
   737   fStartPage->setText(fDefaultViewerFirstPageHTMLText.c_str());
   741 void G4UIQt::UpdateTabWidget(
int tabNumber) {
   742   if ( fViewerTabWidget == NULL) {
   743     fViewerTabWidget = 
new G4QTabWidget;
   746   fViewerTabWidget->setCurrentIndex(tabNumber);
   749   fViewerTabWidget->setTabSelected(
false);
   751  #if QT_VERSION < 0x040200   752   fViewerTabWidget->show();
   754   fViewerTabWidget->setVisible(
true);
   758   fViewerTabWidget->setTabSelected(
true);
   764 void G4UIQt::ResizeTabWidget( QResizeEvent* 
e) {
   765   if ( fViewerTabWidget) {
   766     for (
G4int a=0;
a<fViewerTabWidget->count() ;
a++) {
   767       fViewerTabWidget->widget(
a)->resize(e->size());
   778   G4Qt* interactorManager = G4Qt::getInstance ();
   782   QCoreApplication::sendPostedEvents () ;
   784   #if QT_VERSION < 0x040200   787       fMainWindow->setVisible(
true);
   791   fCommandArea->setFocus();
   793   interactorManager->DisableSecondaryLoop (); 
   794   if ((QApplication*)interactorManager->GetMainInteractor())
   795     ((QApplication*)interactorManager->GetMainInteractor())->exec();
   797   interactorManager->EnableSecondaryLoop ();
   807 void G4UIQt::Prompt (
   811   if (!aPrompt) 
return;
   813   fCommandLabel->setText((
char*)aPrompt.
data());
   818 void G4UIQt::SessionTerminate (
   821   G4Qt* interactorManager = G4Qt::getInstance ();
   822   fMainWindow->close();
   823   ((QApplication*)interactorManager->GetMainInteractor())->exit(); 
   836 void G4UIQt::PauseSessionStart (
   842   if(aState==
"G4_pause> ") {  
   843     SecondaryLoop (
"Pause, type continue to exit this state"); 
   846   if(aState==
"EndOfEvent") { 
   848     SecondaryLoop (
"End of event, type continue to exit this state"); 
   858 void G4UIQt::SecondaryLoop (
   862   if (!aPrompt) 
return;
   864   G4Qt* interactorManager = G4Qt::getInstance (); 
   868     ((QApplication*)interactorManager)->processEvents(QEventLoop::WaitForMoreEvents);
   869     if(exitPause==
true) 
break; 
   874 #ifdef G4MULTITHREADED   888 G4int G4UIQt::ReceiveG4cout (
   892   if (!aString) 
return 0;
   894 #ifdef G4MULTITHREADED   900   if (aString.
contains(
"*** This is just a warning message. ***")) {
   901     return ReceiveG4cerr(aString);
   907   G4UIOutputString txt = G4UIOutputString(QString((
char*)aString.
data()).trimmed(),GetThreadPrefix());
   908   fG4OutputString.push_back(txt);
   910 #ifdef G4MULTITHREADED   911   QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
   913   QString result = FilterOutput(txt,
"",fCoutFilter->text());
   916   if (result.isEmpty()) {
   919   QColor previousColor = fCoutTBTextArea->textColor();
   920   fCoutTBTextArea->setTextColor(Qt::black);
   921   fCoutTBTextArea->append(result);
   922   fCoutTBTextArea->setTextColor(previousColor);
   923   fCoutTBTextArea->ensureCursorVisible ();
   925 #ifdef G4MULTITHREADED   926   UpdateCoutThreadFilter();
   937 G4int G4UIQt::ReceiveG4cerr (
   941   if (!aString) 
return 0;
   943 #ifdef G4MULTITHREADED   950   G4UIOutputString txt = G4UIOutputString(QString((
char*)aString.
data()).trimmed(),
   953   fG4OutputString.push_back(txt);
   955 #ifdef G4MULTITHREADED   956   QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
   958   QString result = FilterOutput(txt,
"",fCoutFilter->text());
   960   if (result.isEmpty()) {
   965   if (QString(aString.
data()).trimmed() != 
"") {
   969       QMessageBox::critical(fMainWindow, 
"Error",QString(fLastErrMessage.data())+
"\n"+aString.
data());
   972   QColor previousColor = fCoutTBTextArea->textColor();
   973   fCoutTBTextArea->setTextColor(
Qt::red);
   974   fCoutTBTextArea->append(result);
   975   fCoutTBTextArea->setTextColor(previousColor);
   976   fCoutTBTextArea->ensureCursorVisible ();
   978   if (QString(aString.
data()).trimmed() != 
"") {
   979     fLastErrMessage = aString;
   981 #ifdef G4MULTITHREADED   982   UpdateCoutThreadFilter();
   988 G4String G4UIQt::GetThreadPrefix() {
   990 #ifdef G4MULTITHREADED   992   if(UI==NULL) 
return "";
  1000   return threadPrefix;
  1004 #ifdef G4MULTITHREADED  1005 void G4UIQt::UpdateCoutThreadFilter() {
  1007   if(UI==NULL) 
return;
  1010   if (fThreadsFilterComboBox->count() < 2) {
  1011     if ( fThreadsFilterComboBox->findText(
"All", Qt::MatchExactly) == -1) {
  1012       fThreadsFilterComboBox->addItem(
"All");
  1015   if (fThreadsFilterComboBox->count() < 2) {
  1016     if ( fThreadsFilterComboBox->findText(
"Master", Qt::MatchExactly) == -1) {
  1017       fThreadsFilterComboBox->addItem(
"Master");
  1023     if ( fThreadsFilterComboBox->findText(prefix.
data(), Qt::MatchExactly) == -1) {
  1024       fThreadsFilterComboBox->addItem(prefix.
data());
  1036 void G4UIQt::AddMenu (
  1041   if (aName == NULL) 
return;
  1042   if (aLabel == NULL) 
return;
  1044   QMenu *fileMenu = 
new QMenu(aLabel);
  1045   fMainWindow->menuBar()->addMenu(fileMenu); 
  1057 void G4UIQt::AddButton (
  1060 ,
const char* aCommand
  1063   if(aMenu==NULL) 
return; 
  1064   if(aLabel==NULL) 
return; 
  1065   if(aCommand==NULL) 
return; 
  1067   QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
  1069   if(parentTmp==NULL) {
  1074       G4cout << 
"Menu name " << aMenu<< 
" does not exist, please define it before using it."<< 
G4endl;
  1081   if(UI==NULL) 
return;
  1085   G4int cmdEndPos = cmd.find_first_of(
" \t");
  1086   if(cmdEndPos!=
G4int(std::string::npos)) {
  1087     cmd.erase(cmdEndPos);
  1090   if(treeTop->
FindPath(cmd) == NULL) {
  1095       G4cout << 
"Warning: command '"<< cmd <<
"' does not exist, please define it before using it."<< 
G4endl;
  1099   QSignalMapper *signalMapper = 
new QSignalMapper(
this);
  1100   QAction *action = parentTmp->addAction(aLabel, signalMapper, SLOT(map()));
  1102   connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
  1103   signalMapper->setMapping(action, QString(aCommand));
  1112 void G4UIQt::AddIcon(
const char* aLabel, 
const char* aIconFile, 
const char* aCommand, 
const char* aFileName){
  1113   if(aLabel==NULL) 
return; 
  1115   if (aCommand==NULL) {
  1116     if (std::string(aIconFile) == 
"user_icon") {
  1121   bool userToolBar = 
false;
  1123   if (std::string(aIconFile) == 
"user_icon") {
  1131         G4cout << 
"Warning: file '"<< aFileName <<
"' is incorrect or does not exist, this command will not be build"<< 
G4endl;
  1136   } 
else if (std::string(aIconFile) == 
"open") {
  1137     const char * 
const xpm[]={
  1180           " =)!)!!!!~                *#$'' ", 
  1181           " {]^/((_({-  %%%%%%%%%%%        ", 
  1182           " {(^_^^^^:<{{{{{{{{{{{{{[&      ", 
  1183           " {/_/(((((/]]]]]]]]]]]/]!#      ", 
  1184           " {/^(((((_^^^^^^^^^^^^^^:#      ", 
  1185           " {/^(((_^^____________^^}$      ", 
  1186           " {/^(((((/////////////((!#      ", 
  1187           " {/^/^_:<|||||||||||||||@@****1 ", 
  1188           " {/^/^(<[)||||||||||||||))!!}<; ", 
  1189           " {/^_(:|234444444444444444432)1 ", 
  1190           " {/_^/<)34444444444444444443},  ", 
  1191           " {/^(2{:41111111111111111142|5  ", 
  1192           " {3^3<:31111111111111111143}-   ", 
  1193           " {/^2<:31111111111111111441|'   ", 
  1194           " {_/<:41111111111111111143},    ", 
  1195           " {(4<:31111111111111111144!#    ", 
  1196           " )4))44111111111111111144},     ", 
  1197           " )2<:31111111111111111144{#     ", 
  1198           " @|:14444444444444444444}*      ", 
  1199           " ;@434444444444444444434<#      ", 
  1200           " ;[))))))))))))))))))))!~       ", 
  1201           " ++++++++++++++++++++++;%       ", 
  1207   } 
else if (std::string(aIconFile) == 
"save") {
  1208     const char * 
const xpm[]={
  1236       "   +++++++++++++++++++++++++    ",
  1237       "  +@##+$%%%%%%%%%%%%%%%&*$%&+   ",
  1238       "  +=-;@>,,''',,,,,,,',,)&!,)+   ",
  1239       "  +;-~@>,,,,,,,,,,,,,,,>$!,)+   ",
  1240       "  +=-~@>,,,,,{]]]]]^,,,>*&$&+   ",
  1241       "  +=-~@>,,,,,'{^{^^{,,,>*#=#+   ",
  1242       "  +=-~@>,,,,,,,,,,,,,,,>@~/=+   ",
  1243       "  +=-~@>,,,{{{''''{',,,>@~-=+   ",
  1244       "  +=-~@>,,'^]]]]]]({,,,>@~-=+   ",
  1245       "  +=-~@>,,,{{{{{{{{{,,,>@~-=+   ",
  1246       "  +=-~@>,,,,,'{^{{^{,,,>@~-=+   ",
  1247       "  +=-~@>,,,,,]]]]]]],,,>@~-=+   ",
  1248       "  +=-~*>,,,,,,,,,,,,,,,>@~-=+   ",
  1249       "  +=-~@>,,,,,,,,,,,,,,,>@~-=+   ",
  1250       "  +=-/=$%%%%%%%%%%%%%%%$=/-=+   ",
  1251       "  +=---;###############;---=+   ",
  1252       "  +=---////////////////----=+   ",
  1253       "  +=----------------///----=+   ",
  1254       "  +=---=@##############@#--=+   ",
  1255       "  +=---@+++++++++++*%))_+~-=+   ",
  1256       "  +=---#+++++++++++&:,,>@~-=+   ",
  1257       "  +=---#+++++++++++$',,>@~-=+   ",
  1258       "  +=---#+++++++++++&!,,>@~-=+   ",
  1259       "  +=/--#+++++++++++&',,>@~-=+   ",
  1260       "   @;--#+++++++++++$',,>@~-=+   ",
  1261       "    @;;@+++++++++++*)!>%@=;#+   ",
  1262       "     @++++++++++++++*&**++@++   ",
  1268   } 
else if (std::string(aIconFile) == 
"move") {
  1269     const char * 
const xpm[]={
  1302           "    ')&$$$$*@@    @@*$$$$&)'    ", 
  1303           "    ')&$$$$*@@    @@*$$$$&+'    ", 
  1322   } 
else if (std::string(aIconFile) == 
"rotate") {
  1323     const char * 
const xpm[]={
  1359           "             --------!*{{{*&,   ", 
  1360           "             -------=){*{{{>>{) ", 
  1361           "            ,!-----=  ){&  ,&{{@", 
  1362           "          ,*>!----=   &>&     )@", 
  1365           "        @{*   '!      ,-!=~^,@  ", 
  1366           "        @&    ==      {/(----!^ ", 
  1369           "          !-!!======!!(((---!   ", 
  1370           "           ='--------------!    ", 
  1387   } 
else if (std::string(aIconFile) == 
"pick") {
  1388     const char * 
const xpm[]={
  1426   } 
else if (std::string(aIconFile) == 
"zoom_in") {
  1427     const char * 
const xpm[]={
  1449           "      ++.%%%+&&&*%%.++          ", 
  1450           "     .+#%%%%+&&&*%%.#+          ", 
  1451           "     ++..%%%+&&&*%%%.++         ", 
  1452           "     +#.+++++&&&*++++.+         ", 
  1453           "     @.+&&&&&&&&&&&&&+@         ", 
  1454           "     @#+&&&&&&&&&&&&&+@         ", 
  1455           "     @.+&&&&&&&&&&&&&+.         ", 
  1456           "     +++@***+&&&****@+.         ", 
  1457           "     ....++++&&&*++++..         ", 
  1458           "      ++.===+&&&*%=.++          ", 
  1459           "       @..==+&&&*=..@#&         ", 
  1460           "       .@+#.+&&&@-+@@*@         ", 
  1461           "         +++.++++++ *+@*        ", 
  1474   } 
else if (std::string(aIconFile) == 
"zoom_out") {
  1475     const char * 
const xpm[]={
  1497           "      ++.$$$$$$$$$$.++          ", 
  1498           "     .+#$$$$$$$$$$$.#+          ", 
  1499           "     ++..$$$$$$$$$$$.++         ", 
  1500           "     +#.+++++++++++++.+         ", 
  1501           "     @.+&&&&&&&&&&&&&+@         ", 
  1502           "     @#+&&&&&&&&&&&&&+@         ", 
  1503           "     @.+&&&&&&&&&&&&&+.         ", 
  1504           "     +++@***********@+.         ", 
  1505           "     ....++++++++++++..         ", 
  1506           "      ++.===$$$$$$=.++          ", 
  1507           "       @..===$$$$=..@#&         ", 
  1508           "       .@+#.$$$..-+@@*@         ", 
  1509           "         +++#--.+++ *+@*        ", 
  1522   } 
else if (std::string(aIconFile) == 
"wireframe") {
  1523     const char * 
const xpm[]={
  1552           "        +&********&@-***;       ", 
  1553           "   +@@@&**&@@@@@@$  @*-&>&+     ", 
  1554           "  +*****&+          %*@ ,**'#   ", 
  1555           "  @***)!~           @*{&*****+  ", 
  1556           "  @*!]***&+        +-*^**'~!*@  ", 
  1557           "  @*~ +@&**&@@@@@@&****&+  ~*@  ", 
  1558           "  @*@    +&********&-*=    @*@  ", 
  1559           "  @*@      $%@-*-@$ @*@    @*@  ", 
  1560           "  @*@         @*@   %*%    @*@  ", 
  1561           "  @*@         %*%   %*%    @*@  ", 
  1562           "  @*@         %*%   %*%    @*@  ", 
  1563           "  @*@         %*%   %*%    @*@  ", 
  1564           "  @*@         %*%   %*%    @*@  ", 
  1565           "  @*@         %*%   %*%    @*@  ", 
  1566           "  @*@         @*@   %*%    @*@  ", 
  1567           "  @*@         =*-+  @*@    @*@  ", 
  1568           "  @*@    $%@@&****&@-*-+   @*@  ", 
  1569           "  @*@ $@&*****&@@&******&~~!*@  ", 
  1570           "  @*{/***&@@%$    $@-*-&*****+  ", 
  1571           "  @*)*)(-~          @*@ ~)**]   ", 
  1572           "  +*******&@@@@+    %*_+]**]    ", 
  1573           "   +@@@@@&******&@%+_*^**]#     ", 
  1574           "          $%@@@&****:**&+       ", 
  1583   } 
else if (std::string(aIconFile) == 
"solid") {
  1584     const char * 
const xpm[]={
  1622           "        +-;>>>>>>>>>,')!~       ", 
  1623           "   {]@@-;>>>>>>>>>>>>^/(_=      ", 
  1624           "  {:>>>>>>>>>>>>>>>>><//[)!=    ", 
  1625           "  ]>>>>>>>>>>>>>>>>>><////[)}   ", 
  1626           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1627           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1628           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1629           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1630           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1631           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1632           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1633           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1634           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1635           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1636           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1637           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1638           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1639           "  @>>>>>>>>>>>>>>>>>><//////|   ", 
  1640           "  @>>>>>>>>>>>>>>>>>></////[1   ", 
  1641           "  @>>>>>>>>>>>>>>>>>><////[*2   ", 
  1642           "  {:>>>>>>>>>>>>>>>>><//[)12    ", 
  1643           "   +@@@@@-;>>>>>>>>>><[)13      ", 
  1653   } 
else if (std::string(aIconFile) == 
"hidden_line_removal") {
  1654     const char * 
const xpm[]={
  1674           "        +#$$$$$$$$#@&$$$*       ", 
  1675           "   =-@@#$$#@@@@@-=  @$&#;>=     ", 
  1676           "  =$$$$$#+          -$@ *$$%+   ", 
  1677           "  -$&@-=            -$-  #$$$=  ", 
  1693           "  -$&@@@-=          -$-  =>;,   ", 
  1694           "  =$$$$$$$#@@@-=    -$'+#$$,    ", 
  1695           "   =-@@@@#$$$$$$#@-+'$)$$#+     ", 
  1696           "          =-@@@#$$$$)$$#+       ", 
  1705   } 
else if (std::string(aIconFile) == 
"hidden_line_and_surface_removal") {
  1706     const char * 
const xpm[]={
  1752           "        ++@%####&*=-#+;>,       ", 
  1753           "   +++++@'=)))))))!)~+{]^++     ", 
  1754           "   +$%&*=)!!!!!!!!!)~+/(]_+++   ", 
  1755           "   +#-))!!!!!!!!!!!)~+/(::<[+   ", 
  1756           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1757           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1758           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1759           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1760           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1761           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1762           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1763           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1764           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1765           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1766           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1767           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1768           "   +#)!!!!!!!!!!!!!!}+/::::{+   ", 
  1769           "   +#)!!!!!!!!!!!!!!}+/:::|1+   ", 
  1770           "   +$#}}~23!!!!!!!!)~+/(]45,    ", 
  1771           "   +++++++@#}}~23!!)~+678++     ", 
  1772           "          ++++++@#~90+a++       ", 
  1782   } 
else if (std::string(aIconFile) == 
"perspective") {
  1783     const char * 
const xpm[]={
  1793           "           ................     ", 
  1794           "       ....+++++++++++++++.     ", 
  1795           "    ...++++..+.........+++.     ", 
  1796           "   ..++..............++..+.     ", 
  1797           "   .+++++++++++++++++.. .+.     ", 
  1798           "   .+...............+.  .+.     ", 
  1799           "   .+.      .+.    .+.  .+.     ", 
  1800           "   .+.      .+.    .+.  .+.     ", 
  1801           "   .+.      .+.    .+.  .+.     ", 
  1802           "   .+.      .+.    .+.  .+.     ", 
  1803           "   .+.      .+.    .+.  .+.     ", 
  1804           "   .+.      .+.    .+.  .+.     ", 
  1805           "   .+.      .+.    .+.  .+.     ", 
  1806           "   .+.      .+.    .+.  .+.     ", 
  1807           "   .+.      .+......+....+.     ", 
  1808           "   .+.     ..++++++.+.++++.     ", 
  1809           "   .+.    .++.......+...+..     ", 
  1810           "   .+.   .++.      .+..++.      ", 
  1811           "   .+. ..+..       .+..+.       ", 
  1814           "   .+++.............++.         ", 
  1815           "   .+++++++++++++++++.          ", 
  1816           "   ...................          ", 
  1822   } 
else if (std::string(aIconFile) == 
"ortho") {
  1823     const char * 
const xpm[]={
  1831           "          ...................   ", 
  1832           "         ..@@@@@@@@@@@@@@@@@.   ", 
  1833           "       ..@@@.............@@@.   ", 
  1834           "      ..@@.@.         ..@..@.   ", 
  1835           "    ..@@ ..@.        .@@...@.   ", 
  1836           "   ..@@..............@@.. .@.   ", 
  1837           "   .@@@@@@@@@@@@@@@@@..   .@.   ", 
  1838           "   .@...............@.    .@.   ", 
  1839           "   .@.    .@.      .@.    .@.   ", 
  1840           "   .@.    .@.      .@.    .@.   ", 
  1841           "   .@.    .@.      .@.    .@.   ", 
  1842           "   .@.    .@.      .@.    .@.   ", 
  1843           "   .@.    .@.      .@.    .@.   ", 
  1844           "   .@.    .@.      .@.    .@.   ", 
  1845           "   .@.    .@.      .@.    .@.   ", 
  1846           "   .@.    .@.      .@.    .@.   ", 
  1847           "   .@.    .@.      .@.    .@.   ", 
  1848           "   .@.    .@.      .@.    .@.   ", 
  1849           "   .@.    .@........@......@.   ", 
  1850           "   .@.   .@@@@@@@@@.@.@@@@@@.   ", 
  1851           "   .@.  .@@+........@....@@..   ", 
  1852           "   .@...@.         .@...@...    ", 
  1854           "   .@@@.............@@@..       ", 
  1855           "   .@@@@@@@@@@@@@@@@@...        ", 
  1856           "   ...................          ", 
  1867       G4cout << 
"Parameter"<< aIconFile <<
" not defined"<< 
G4endl;
  1871   QToolBar *currentToolbar = NULL;
  1873     if (fToolbarUser == NULL) {
  1874       fToolbarUser = 
new QToolBar();
  1875       fToolbarUser->setIconSize (QSize(20,20));
  1876       fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
  1878     currentToolbar = fToolbarUser;
  1880     if (fToolbarApp == NULL) {
  1881       fToolbarApp = 
new QToolBar();
  1882       fToolbarApp->setIconSize (QSize(20,20));
  1883       fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
  1885     currentToolbar = fToolbarApp;
  1888   QSignalMapper *signalMapper = 
new QSignalMapper(
this);
  1889   QAction *action = currentToolbar->addAction(pix,aLabel, signalMapper, SLOT(map()));
  1893   if (std::string(aIconFile) == 
"open") {
  1894     connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(OpenIconCallback(
const QString &)));
  1895     QString txt = aCommand + fStringSeparator + aLabel;
  1896     signalMapper->setMapping(action, QString(txt));
  1899   } 
else if (std::string(aIconFile) == 
"save") {
  1900     connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(SaveIconCallback(
const QString&)));
  1901     QString txt = aCommand + fStringSeparator + aLabel;
  1902     signalMapper->setMapping(action, QString(txt));
  1905   } 
else if ((std::string(aIconFile) == 
"move") ||
  1906              (std::string(aIconFile) == 
"rotate") ||
  1907              (std::string(aIconFile) == 
"pick") ||
  1908              (std::string(aIconFile) == 
"zoom_out") ||
  1909              (std::string(aIconFile) == 
"zoom_in")) {
  1910     action->setCheckable(
TRUE);
  1911     action->setChecked(
TRUE);
  1912     action->setData(aIconFile);
  1914     connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeCursorStyle(
const QString&)));
  1915     signalMapper->setMapping(action, QString(aIconFile));
  1917     if (std::string(aIconFile) == 
"move") {
  1918       SetIconMoveSelected();
  1920     if (std::string(aIconFile) == 
"rotate") {
  1921       SetIconRotateSelected();
  1923     if (std::string(aIconFile) == 
"pick") {
  1924       SetIconPickSelected();
  1926     if (std::string(aIconFile) == 
"zoom_in") {
  1927       SetIconZoomInSelected();
  1929     if (std::string(aIconFile) == 
"zoom_out") {
  1930       SetIconZoomOutSelected();
  1934   } 
else if ((std::string(aIconFile) == 
"hidden_line_removal") ||
  1935              (std::string(aIconFile) == 
"hidden_line_and_surface_removal") ||
  1936              (std::string(aIconFile) == 
"solid") ||
  1937              (std::string(aIconFile) == 
"wireframe")) {
  1938     action->setCheckable(
TRUE);
  1939     action->setChecked(
TRUE);
  1940     action->setData(aIconFile);
  1941     connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangeSurfaceStyle(
const QString&)));
  1942     signalMapper->setMapping(action, QString(aIconFile));
  1944     if (std::string(aIconFile) == 
"hidden_line_removal") {
  1945       SetIconHLRSelected();
  1947     if (std::string(aIconFile) == 
"hidden_line_and_surface_removal") {
  1948       SetIconHLHSRSelected();
  1950     if (std::string(aIconFile) == 
"solid") {
  1951       SetIconSolidSelected();
  1953     if (std::string(aIconFile) == 
"wireframe") {
  1954       SetIconWireframeSelected();
  1958   } 
else if ((std::string(aIconFile) == 
"perspective") ||
  1959              (std::string(aIconFile) == 
"ortho")) {
  1960     action->setCheckable(
TRUE);
  1961     action->setChecked(
TRUE);
  1962     action->setData(aIconFile);
  1963     connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ChangePerspectiveOrtho(
const QString&)));
  1964     signalMapper->setMapping(action, QString(aIconFile));
  1966     if (std::string(aIconFile) == 
"perspective") {
  1967       SetIconPerspectiveSelected();
  1969     if (std::string(aIconFile) == 
"ortho") {
  1970       SetIconOrthoSelected();
  1977     if(UI==NULL) 
return;
  1979     if (aCommand != NULL) {
  1980       if(treeTop->
FindPath(aCommand) == NULL) {
  1985           G4cout << 
"Warning: command '"<< aCommand <<
"' does not exist, please define it before using it."<< 
G4endl;
  1990     connect(signalMapper, SIGNAL(mapped(
const QString &)),
this, SLOT(ButtonCallback(
const QString&)));
  1991     signalMapper->setMapping(action, QString(aCommand));
  1997 void G4UIQt::ActivateCommand(
  2001   if (!fHelpTreeWidget) {
  2005   size_t i = newCommand.
index(
" ");
  2007   if( i != std::string::npos )
  2009       G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
  2011       targetCom = ModifyToFullPathCommand( newValue );
  2013   if (targetCom != 
"") {
  2014     OpenHelpTreeOnCommand(targetCom.
data());
  2017   fUITabWidget->setCurrentWidget(fHelpTBWidget);
  2028 void G4UIQt::InitHelpTreeAndVisParametersWidget()
  2031   if (! fHelpTreeWidget ) {
  2032     fHelpTreeWidget = 
new QTreeWidget();
  2036   fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
  2038   labels << QString(
"Command");
  2039   fHelpTreeWidget->setHeaderLabels(labels);
  2042   connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),
this, SLOT(HelpTreeClicCallback()));  
  2043   connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,
int)),
this, SLOT(HelpTreeDoubleClicCallback()));  
  2052 void G4UIQt::FillHelpTree()
  2054   if (! fHelpTreeWidget ) {
  2055     InitHelpTreeAndVisParametersWidget();
  2058   QString searchText = fHelpLine->text();
  2060   if (searchText ==
"") {
  2067   if (fParameterHelpLabel) {
  2068     fParameterHelpLabel->setText(
"Choose a command in the command tree");
  2069     fParameterHelpTable->setVisible(
false);
  2073 #if QT_VERSION < 0x040200  2076     fHelpLine->setText(
"");
  2081   if(UI==NULL) 
return;
  2085   QTreeWidgetItem * newItem = NULL;
  2086   QString commandText = 
"";
  2087   for (
int a=0;
a<treeSize;
a++) {
  2094     for (
int b=0;
b<fHelpTreeWidget->topLevelItemCount();
b++) {
  2096         newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(
b),commandText);
  2099     if (newItem == NULL) {
  2101       newItem = 
new QTreeWidgetItem();
  2102       newItem->setText(0,GetShortCommandPath(commandText));
  2103       fHelpTreeWidget->addTopLevelItem(newItem);
  2107     CreateHelpTree(newItem,treeTop->
GetTree(
a+1));
  2118 void G4UIQt::CreateHelpTree(
  2119  QTreeWidgetItem *aParent
  2123   if (aParent == NULL) 
return;
  2124   if (aCommandTree == NULL) 
return;
  2128   QTreeWidgetItem * newItem;
  2130   QString commandText = 
"";
  2134     commandText = QString((
char*)(aCommandTree->
GetTree(
a+1)->
GetPathName()).data()).trimmed();
  2137     newItem = FindTreeItem(aParent,commandText);
  2138     if (newItem == NULL) {
  2139       newItem = 
new QTreeWidgetItem();
  2140       newItem->setText(0,GetShortCommandPath(commandText));
  2141       aParent->addChild(newItem);
  2143     CreateHelpTree(newItem,aCommandTree->
GetTree(
a+1));
  2150     QStringList stringList;
  2154     newItem = FindTreeItem(aParent,commandText);
  2155     if (newItem == NULL) {
  2156       newItem = 
new QTreeWidgetItem();
  2157       newItem->setText(0,GetShortCommandPath(commandText));
  2158       aParent->addChild(newItem);
  2160 #if QT_VERSION < 0x040202  2161       fHelpTreeWidget->setItemExpanded(newItem,
false); 
  2163       newItem->setExpanded(
false);
  2177 bool G4UIQt::CreateVisCommandGroupAndToolBox(
  2184   QString commandText = QString((
char*)(aCommand->
GetCommandPath().
data())).section(
"/",-aDepthLevel);
  2186   if (commandText == NULL) {
  2192   QWidget* newParentWidget = NULL;
  2194   QString commandSection = commandText.left(commandText.indexOf(
"/"));
  2196   if (aDepthLevel == 1) {
  2197     QToolBox* currentParent = 
dynamic_cast<QToolBox*
>(aParent);
  2198     if (currentParent != 0){
  2201       for (
int a=0; 
a<currentParent->count(); 
a++) {
  2202         if (currentParent->itemText(
a) == commandSection) {
  2204           newParentWidget = currentParent->widget(
a);
  2210       newParentWidget = 
new QGroupBox();
  2211       newParentWidget->setLayout(
new QVBoxLayout());
  2212       if (currentParent != 0){
  2213         currentParent->addItem(newParentWidget,commandSection);
  2215         if (!aParent->layout()) {
  2216           aParent->setLayout(
new QVBoxLayout());
  2218         aParent->layout()->addWidget(newParentWidget);
  2221       if (commandText.indexOf(
"/") == -1) {
  2226         for( 
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
  2227           guidance += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) + 
"\n";
  2229         newParentWidget->setToolTip(guidance);
  2232       QScrollArea* sc = 
dynamic_cast<QScrollArea*
>(newParentWidget->parent()->parent());
  2234         sc->ensureWidgetVisible(newParentWidget);
  2241     QGroupBox* currentParent = 
dynamic_cast<QGroupBox*
>(aParent);
  2242     if (currentParent != 0){
  2246       if (aDepthLevel == 2){
  2247         QToolBox* parentToolBox = 
dynamic_cast<QToolBox*
>(currentParent->parent()->parent()->parent());
  2248         if (parentToolBox != 0) {
  2252       for (
int a=0; 
a<aParent->layout()->count(); 
a++) {
  2253         QGroupBox* gb = 
dynamic_cast<QGroupBox*
>(aParent->layout()->itemAt(
a)->widget());
  2255           if (gb->title() == commandSection) {
  2257             newParentWidget = gb;
  2265       newParentWidget = 
new QGroupBox();
  2266       newParentWidget->setLayout(
new QVBoxLayout());
  2267       if (!aParent->layout()) {
  2268         aParent->setLayout(
new QVBoxLayout());
  2270       aParent->layout()->addWidget(newParentWidget);
  2276       for( 
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
  2277         guidance += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) + 
"\n";
  2279       newParentWidget->setToolTip(guidance);
  2284   if (commandText.indexOf(
"/") == -1) {
  2285     if (CreateCommandWidget(aCommand, newParentWidget,isDialog)) {
  2289     CreateVisCommandGroupAndToolBox(aCommand,newParentWidget, aDepthLevel-1,isDialog);
  2302 bool G4UIQt::CreateCommandWidget(
G4UIcommand* aCommand, QWidget* aParent, 
bool isDialog) {
  2304   if (aCommand == NULL) {
  2311   if( n_parameterEntry > 0 ) {
  2315     QWidget* paramWidget = 
new QWidget();
  2316     QGridLayout* gridLayout = 
new QGridLayout();
  2317     paramWidget->setLayout(gridLayout);
  2320     unsigned int nbColorParameter = 0;
  2321     bool isStillColorParameter = 
false;
  2322     bool isColorDialogAdded = 
false;
  2323     QLabel* redLabel = NULL;
  2324     QLabel* greenLabel = NULL;
  2325     QString redDefaultStr = 
"";
  2326     QString greenDefaultStr = 
"";
  2327     QString blueDefaultStr = 
"";
  2328     QWidget* redInput = NULL;
  2329     QWidget* greenInput = NULL;
  2331     for( 
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
  2334       QLabel* label = 
new QLabel(QString((
char*)(param->
GetParameterName()).data()));
  2336       if ((label->text() == 
"red") || (label->text() == 
"red_or_string")){
  2337         nbColorParameter ++;
  2338         isStillColorParameter = 
true;
  2339       } 
else if ((label->text() == 
"green") && isStillColorParameter) {
  2340         nbColorParameter ++;
  2341       } 
else if ((label->text() == 
"blue") && isStillColorParameter) {
  2342         nbColorParameter ++;
  2343       } 
else if (!isColorDialogAdded) {
  2346         if (nbColorParameter == 1) {
  2347           gridLayout->addWidget(redLabel,i_thParameter-1,0);
  2348           gridLayout->addWidget(redInput,i_thParameter-1,1);
  2349         } 
else if (nbColorParameter == 2) {
  2350           gridLayout->addWidget(redLabel,i_thParameter-2,0);
  2351           gridLayout->addWidget(redInput,i_thParameter-2,1);
  2352           gridLayout->addWidget(greenLabel,i_thParameter-1,0);
  2353           gridLayout->addWidget(greenInput,i_thParameter-1,1);
  2355         nbColorParameter = 0;
  2358       QWidget* input = NULL;
  2360         input = 
new QLineEdit();
  2362         dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
  2364         if (((label->text() == 
"red") || (label->text() == 
"red_or_string")) && isStillColorParameter) {
  2366         } 
else if ((label->text() == 
"green") && isStillColorParameter) {
  2368         } 
else if ((label->text() == 
"green") && isStillColorParameter) {
  2373         input = 
new QWidget();
  2374         QHBoxLayout* layout = 
new QHBoxLayout();
  2375         input->setLayout(layout);
  2377         QButtonGroup* buttons = 
new QButtonGroup();
  2378         QRadioButton* radioOff = 
new QRadioButton(
"0");
  2379         QRadioButton* radioOn = 
new QRadioButton(
"1");
  2380         buttons->addButton(radioOn);
  2381         buttons->addButton(radioOff);
  2382         layout->addWidget(radioOn);
  2383         layout->addWidget(radioOff);
  2387         if (defaultValue == 
"0") {
  2388           radioOff->setChecked(
true);
  2389         } 
else if (defaultValue == 
"1") {
  2390           radioOn->setChecked(
true);
  2393         input = 
new QComboBox();
  2395         QStringList list = candidates.split (
" ");
  2398         QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
  2399         for (
int a=0; 
a<list.size(); 
a++) {
  2400           dynamic_cast<QComboBox*
>(input)->addItem(list.at(
a));
  2402             dynamic_cast<QComboBox*
>(input)->setCurrentIndex(
a);
  2407         input = 
new QLineEdit();
  2409         dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
  2412         input = 
new QWidget();
  2413         QHBoxLayout* layout = 
new QHBoxLayout();
  2414         input->setLayout(layout);
  2416         QButtonGroup* buttons = 
new QButtonGroup();
  2417         QRadioButton* radioOff = 
new QRadioButton(
"off");
  2418         QRadioButton* radioOn = 
new QRadioButton(
"on");
  2419         buttons->addButton(radioOn);
  2420         buttons->addButton(radioOff);
  2421         layout->addWidget(radioOn);
  2422         layout->addWidget(radioOff);
  2425         QString defaultValue = QString((
char*)(param->
GetDefaultValue()).data());
  2426         if (defaultValue == 
"off") {
  2427           radioOff->setChecked(
true);
  2428         } 
else if (defaultValue == 
"on") {
  2429           radioOn->setChecked(
true);
  2433         input = 
new QLineEdit();
  2434         dynamic_cast<QLineEdit*
>(input)->setText(QString((
char*)(param->
GetDefaultValue()).data()));
  2437       txt += 
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) + 
"\n";
  2441       txt += 
" Parameter type  : " + QString(QChar(param->
GetParameterType())) + 
"\n";
  2443         txt += 
" Omittable       : True\n";
  2445         txt += 
" Omittable       : False\n";
  2448         txt += 
" Default value   : taken from the current value\n";
  2450         txt += 
" Default value   : " + QString((
char*)(param->
GetDefaultValue()).data())+ 
"\n";
  2453         txt += 
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data())+ 
"\n";
  2459       if (isStillColorParameter && (nbColorParameter != 0)) {
  2460         if ((label->text() == 
"red") || (label->text() == 
"red_or_string")) {
  2463         } 
else if (label->text() == 
"green") {
  2466         } 
else if (label->text() == 
"blue") {
  2472           if ((redDefaultStr != 
"") && (redDefaultStr != 
"") && (redDefaultStr != 
"")) {
  2473             qc.setRgbF(redDefaultStr.toDouble(),
  2474                        greenDefaultStr.toDouble(),
  2475                        blueDefaultStr.toDouble());
  2477           QPixmap pixmap = QPixmap(QSize(16, 16));
  2479           QPainter painter(&pixmap);
  2480           painter.setPen(Qt::black);
  2481           painter.drawRect(0,0,15,15); 
  2483           input = 
new QPushButton(
"Change color");
  2484           dynamic_cast<QPushButton*
>(input)->setIcon(pixmap);
  2485           dynamic_cast<QPushButton*
>(input)->setAccessibleName(redDefaultStr+
" "+greenDefaultStr+
" "+blueDefaultStr);
  2486           label = 
new QLabel(
"Choose color");
  2490           gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
  2491           input->setToolTip(
"Select the current color");
  2492           gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
  2495           QSignalMapper* signalMapper = 
new QSignalMapper(
this);
  2496           signalMapper->setMapping(input,input);
  2497           connect(input, SIGNAL(clicked()), signalMapper, SLOT(map()));
  2498           connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(ChangeColorCallback(QWidget*)));
  2500           isColorDialogAdded = 
true;
  2501           isStillColorParameter = 
false;
  2504         gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
  2505         input->setToolTip(txt);
  2506         gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
  2512     gridLayout->addWidget(name,n_parameterEntry-nbColorParameter,0);
  2514     QPushButton* applyButton = 
new QPushButton(
"Apply");
  2517       gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,1);
  2519       QSignalMapper* signalMapper = 
new QSignalMapper(
this);
  2520       signalMapper->setMapping(applyButton, paramWidget);
  2521       connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
  2522       connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
  2526       applyButton->setAutoDefault( 
TRUE );
  2527       applyButton->setDefault( 
TRUE );
  2529       QPushButton* cancelButton = 
new QPushButton( tr( 
"&Cancel" ));
  2530       cancelButton->setAutoDefault( 
TRUE );
  2531       gridLayout->addWidget(cancelButton,n_parameterEntry-nbColorParameter,1);
  2532       gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,0);
  2534       QSignalMapper* signalMapper = 
new QSignalMapper(
this);
  2535       signalMapper->setMapping(applyButton, paramWidget);
  2536       connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
  2537       connect(signalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(VisParameterCallback(QWidget*)));
  2539       QWidget * parentCheck = aParent;
  2540       QDialog* parentDialog = NULL;
  2542       while ((parentCheck->parentWidget()) != NULL) {
  2543         parentCheck = parentCheck->parentWidget();
  2544         parentDialog = 
dynamic_cast<QDialog*
>(parentCheck);
  2546           connect( applyButton, SIGNAL( clicked() ), parentDialog, SLOT( accept() ) );
  2547           connect( cancelButton, SIGNAL( clicked() ), parentDialog, SLOT( reject() ) );
  2556     if (!aParent->layout()) {
  2557       aParent->setLayout(
new QVBoxLayout());
  2559     aParent->layout()->addWidget(paramWidget);
  2570 QTreeWidgetItem* G4UIQt::FindTreeItem(
  2571  QTreeWidgetItem *aParent
  2572 ,
const QString& aCommand
  2575   if (aParent == NULL) 
return NULL;
  2578   QString myCommand = aCommand;
  2580   if (myCommand.lastIndexOf(
"/") == (myCommand.size()-1)) {
  2581     myCommand = myCommand.left(myCommand.size()-1);
  2584   if (GetLongCommandPath(aParent) == myCommand)
  2587   QTreeWidgetItem * 
tmp = NULL;
  2588   for (
int a=0;
a<aParent->childCount();
a++) {
  2590       tmp = FindTreeItem(aParent->child(
a),myCommand);
  2604 QString G4UIQt::GetCommandList (
  2610   if (aCommand == NULL)
  2618   if ((commandPath == 
"") &&
  2619       (rangeString == 
"") &&
  2620       (n_guidanceEntry == 0) &&
  2621       (n_parameterEntry == 0)) {
  2625   if((commandPath.length()-1)!=
'/') {
  2626     txt += 
"Command " + QString((
char*)(commandPath).data()) + 
"\n";
  2628   txt += 
"Guidance :\n";
  2630   for( 
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
  2631     txt += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) + 
"\n";
  2633   if( ! rangeString.
isNull() ) {
  2634     txt += 
" Range of parameters : " + QString((
char*)(rangeString).data()) + 
"\n";
  2636   if( n_parameterEntry > 0 ) {
  2641     for( 
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
  2643       txt += 
"\nParameter : " + QString((
char*)(param->
GetParameterName()).data()) + 
"\n";
  2646       txt += 
" Parameter type  : " + QString(QChar(param->
GetParameterType())) + 
"\n";
  2648         txt += 
" Omittable       : True\n";
  2650         txt += 
" Omittable       : False\n";
  2653         txt += 
" Default value   : taken from the current value\n";
  2655         txt += 
" Default value   : " + QString((
char*)(param->
GetDefaultValue()).data())+ 
"\n";
  2658         txt += 
" Parameter range : " + QString((
char*)(param->
GetParameterRange()).data())+ 
"\n";
  2676 void G4UIQt::updateHelpArea (
  2680   if (!fParameterHelpLabel)
  2682   if (!fParameterHelpTable)
  2685   fParameterHelpLabel->setTextInteractionFlags(Qt::NoTextInteraction);
  2687   if (aCommand == NULL)
  2695   if ((commandPath == 
"") && 
  2696       (rangeString == 
"") &&
  2697       (n_guidanceEntry == 0) &&
  2698       (n_parameterEntry == 0)) {
  2702   if((commandPath.length()-1)!=
'/') {
  2703     txt += 
"<b>Command </b> " + QString((
char*)(commandPath).data()) + 
"<br />";
  2705   txt += 
"<b>Guidance :</b> ";
  2707   for( 
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
  2708     txt += QString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) + 
"<br />";
  2710   if( ! rangeString.
isNull() ) {
  2711     txt += 
"<b>Range of parameters : </b> " + QString((
char*)(rangeString).data()) + 
"<br />";
  2715   fParameterHelpLabel->setHtml(txt);
  2717   if( n_parameterEntry > 0 ) {
  2722     fParameterHelpTable->clear();
  2723     fParameterHelpTable->setRowCount(n_parameterEntry);
  2724     fParameterHelpTable->setColumnCount(8);
  2725     fParameterHelpTable->setHorizontalHeaderLabels(QStringList() <<
  2734     fParameterHelpTable->setColumnWidth(2,60);
  2736     fParameterHelpTable->verticalHeader()->setVisible(
false);
  2737     fParameterHelpTable->setAlternatingRowColors (
true);
  2738 #if QT_VERSION < 0x050000  2739     fParameterHelpTable->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
  2740     fParameterHelpTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
  2742     fParameterHelpTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
  2743     fParameterHelpTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
  2745     fParameterHelpTable->setWordWrap(
true);
  2747     QTableWidgetItem* t = fParameterHelpTable->horizontalHeaderItem(1);
  2748     QFont fnt = t->font();
  2749     int size = fnt.pointSize();
  2750     fnt.setPointSize(size-2);
  2752     for( 
G4int a=0; 
a<n_parameterEntry; 
a++ ) {
  2754       fParameterHelpTable->setItem(
a, 0, 
new QTableWidgetItem(QString::number(
a+1)));
  2756       fParameterHelpTable->setItem(
a, 1, 
new QTableWidgetItem(QString((
char*)(param->
GetParameterName()).data())));
  2758         fParameterHelpTable->setItem(
a, 2, 
new QTableWidgetItem(QString((
char*)(param->
GetParameterGuidance()).data())));
  2760       fParameterHelpTable->setItem(
a, 3, 
new QTableWidgetItem(QString(QChar(param->
GetParameterType()))));
  2763         fParameterHelpTable->setItem(
a, 4, 
new QTableWidgetItem(QString(
"True")));
  2765         fParameterHelpTable->setItem(
a, 4, 
new QTableWidgetItem(QString(
"False")));
  2768         fParameterHelpTable->setItem(
a, 5, 
new QTableWidgetItem(QString(
"taken from the current value")));
  2770         fParameterHelpTable->setItem(
a, 5, 
new QTableWidgetItem(QString((
char*)(param->
GetDefaultValue()).data())));
  2773         fParameterHelpTable->setItem(
a, 6, 
new QTableWidgetItem(QString((
char*)(param->
GetParameterRange()).data())));
  2776         fParameterHelpTable->setItem(
a, 7, 
new QTableWidgetItem(QString((
char*)(param->
GetParameterCandidates()).data())));
  2779       for (
int b=0; 
b<8; 
b++) {
  2780         QTableWidgetItem* tmp = fParameterHelpTable->item(
a,
b);
  2782           tmp->setToolTip(tmp->text());
  2783           tmp->setFlags(Qt::NoItemFlags);
  2784           tmp->setForeground(QBrush());
  2788       fParameterHelpTable->resizeRowToContents(
a);
  2790     for (
int c=0; 
c<8; 
c++) {
  2792         fParameterHelpTable->resizeColumnToContents(
c);
  2795     fParameterHelpLabel->setVisible(
true);
  2796     fParameterHelpTable->setVisible(
true);
  2807 G4bool G4UIQt::IsGUICommand(
  2811   if (aCommand == NULL)
  2816   if( n_parameterEntry > 0 ) {
  2821     for( 
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
  2843 G4bool G4UIQt::GetHelpChoice(
  2858 bool G4UIQt::eventFilter( 
  2863   bool moveCommandCursor = 
false;
  2864   if (aObj == NULL) 
return false;
  2865   if (aEvent == NULL) 
return false;
  2867   if (aObj == fHistoryTBTableList) {
  2868     if (aEvent->type() == QEvent::KeyPress) {
  2869       fCommandArea->setFocus();
  2872   if (aObj == fCommandArea) {
  2873     if (aEvent->type() == QEvent::KeyPress) {
  2874       QKeyEvent *e = 
static_cast<QKeyEvent*
>(aEvent);
  2875       if ((e->key() == (Qt::Key_Down)) ||
  2876           (e->key() == (Qt::Key_PageDown)) ||
  2877           (e->key() == (Qt::Key_Up)) ||
  2878           (e->key() == (Qt::Key_PageUp))) {
  2879         int selection = fHistoryTBTableList->currentRow();
  2880         if (fHistoryTBTableList->count()) {
  2881           if (selection == -1) {
  2882             selection = fHistoryTBTableList->count()-1;
  2884             if (e->key() == (Qt::Key_Down)) {
  2885               if (selection <(fHistoryTBTableList->count()-1))
  2887             } 
else if (e->key() == (Qt::Key_PageDown)) {
  2888               selection = fHistoryTBTableList->count()-1;
  2889             } 
else if (e->key() == (Qt::Key_Up)) {
  2892             } 
else if (e->key() == (Qt::Key_PageUp)) {
  2896           fHistoryTBTableList->clearSelection();
  2897 #if QT_VERSION < 0x040202  2898           fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),
true);
  2900           fHistoryTBTableList->item(selection)->setSelected(
true);
  2902           fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
  2904         moveCommandCursor = 
true;
  2905       } 
else if (e->key() == (Qt::Key_Tab)) {
  2906         G4String ss = Complete(fCommandArea->text().toStdString().c_str());
  2907         fCommandArea->setText((
char*)(ss.
data()));
  2913       } 
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
  2914        fCommandArea->home(
false);
  2916       } 
else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
  2917        fCommandArea->end(
false);
  2924   if (moveCommandCursor == 
true) {
  2925     fCommandArea->setCursorPosition ( fCommandArea->text().length() );
  2926     fCommandArea->setCursorPosition (4);
  2929     res = QObject::eventFilter(aObj, aEvent);
  2945 void G4UIQt::ShowHelpCallback (
  2954 void G4UIQt::ClearButtonCallback (
  2957   fCoutTBTextArea->clear();
  2958   fG4OutputString.clear();
  2963 void G4UIQt::ExitSession (
  2969 void G4UIQt::ExitHelp(
  2977 void G4UIQt::CommandEnteredCallback (
  2981   QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
  2984   for (
int a=0; 
a< list.size(); 
a++) {
  2985     QString txt (list[
a].trimmed());
  2987       fHistoryTBTableList->addItem(txt);
  2988       fHistoryTBTableList->clearSelection();
  2989       fHistoryTBTableList->setCurrentItem(NULL);
  2990       fCommandArea->setText(
"");
  2991       G4Qt* interactorManager = G4Qt::getInstance ();
  2992       if (interactorManager) {
  2993         interactorManager->FlushAndWaitExecution();
  2996       G4String command = txt.toStdString().c_str();
  2997       if (command(0,4) != 
"help") {
  2998         ApplyShellCommand (command,exitSession,exitPause);
  3000         ActivateCommand(command);
  3005   fCommandArea->setFocus();
  3010   if(exitSession==
true)
  3019 void G4UIQt::CommandEditedCallback(
const QString &)
  3021   QStringList list = fCommandArea->text().split(QRegExp(
"[\r\n]"),QString::SkipEmptyParts);
  3023   if (list.size() > 1) { 
  3024     for (
int a=0; 
a<list.size()-1; 
a++) {
  3026       fCommandArea->setText(list[
a]);
  3028       CommandEnteredCallback();
  3031     fCommandArea->setText(list[list.size()-1]);
  3038 void G4UIQt::VisParameterCallback(QWidget* widget){
  3039   if (widget == NULL) {
  3044   QGridLayout* grid = 
dynamic_cast<QGridLayout*
>(widget->layout());
  3049 #if QT_VERSION < 0x040400  3050   QWidget* name = grid->itemAt(grid->columnCount()*(grid->rowCount()-2))->widget();
  3052   QWidget* name = grid->itemAtPosition(grid->rowCount()-1,0)->
widget();
  3054   if (dynamic_cast<QLabel*>(name) == 0) {
  3057   command += (
dynamic_cast<QLabel*
>(
name))->text()+
" ";
  3059   for (
int a=0;
a<grid->rowCount()-1; 
a++) {
  3060 #if QT_VERSION < 0x040400  3061     QWidget* widgetTmp = grid->itemAt(
a*grid->columnCount()+1)->
widget();
  3063     QWidget* widgetTmp = grid->itemAtPosition(
a,1)->widget();
  3067     if (widgetTmp != NULL) {
  3069       if (dynamic_cast<QLineEdit*>(widgetTmp) != 0) {
  3070         command += (
dynamic_cast<QLineEdit*
>(widgetTmp))->text()+
" ";
  3072       } 
else if (dynamic_cast<QComboBox*>(widgetTmp) != 0){
  3073         command += (
dynamic_cast<QComboBox*
>(widgetTmp))->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex())+
" ";
  3076       } 
else if (dynamic_cast<QPushButton*>(widgetTmp) != 0){
  3077         command += widgetTmp->accessibleName()+
" ";
  3080       } 
else if (dynamic_cast<QWidget*>(widgetTmp) != 0){
  3081         if (widgetTmp->layout()->count() > 0){
  3082           if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != 0) {
  3083             QAbstractButton * checked = (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton();
  3085               command += (
dynamic_cast<QRadioButton*
>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton()->text()+
" ";
  3093   if (command != 
"") {
  3107 void G4UIQt::ButtonCallback (
  3108  const QString& aCommand
  3115   if(UI==NULL) 
return;
  3122     if (IsGUICommand(command)) {
  3123       QDialog* menuParameterDialog = 
new QDialog();
  3125       if (CreateVisCommandGroupAndToolBox(command,menuParameterDialog,1,
true)) {
  3126         menuParameterDialog->setWindowTitle (aCommand);
  3127         menuParameterDialog->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
  3130         menuParameterDialog->exec();
  3136   ApplyShellCommand(ss,exitSession,exitPause);
  3141   if(exitSession==
true) 
  3149 void G4UIQt::HelpTreeClicCallback (
  3152   QTreeWidgetItem* item =  NULL;
  3153   if (!fHelpTreeWidget)
  3156   QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
  3159   item = list.first();
  3164   if(UI==NULL) 
return;
  3167   std::string itemText = GetLongCommandPath(item).toStdString();
  3170   if (item->childCount() > 0) {
  3176     updateHelpArea(command);
  3182       fParameterHelpLabel->setVisible(
true);
  3184       fParameterHelpTable->setVisible(
false);
  3191 void G4UIQt::HelpTreeDoubleClicCallback (
  3194   HelpTreeClicCallback();
  3196   QTreeWidgetItem* item =  NULL;
  3197   if (!fHelpTreeWidget)
  3200   QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
  3203   item = list.first();
  3207   fCommandArea->clear();
  3208   fCommandArea->setText(GetLongCommandPath(item));
  3215 void G4UIQt::CommandHistoryCallback(
  3218   QListWidgetItem* item =  NULL;
  3219   if (!fHistoryTBTableList)
  3223   QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
  3226   item = list.first();
  3229   fCommandArea->setText(item->text());
  3233 void G4UIQt::ThreadComboBoxCallback(
int) {
  3234   CoutFilterCallback(
"");
  3238 void G4UIQt::CoutFilterCallback(
  3241   FilterAllOutputTextArea();
  3243   fCoutTBTextArea->repaint();
  3244   fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
  3249 QString G4UIQt::FilterOutput(
  3250  const G4UIOutputString& output
  3251 ,
const QString& currentThread
  3252 ,
const QString& filter
  3255 #ifdef G4MULTITHREADED  3256   if ((currentThread == 
"All") ||
  3257       (currentThread == output.fThread)) {
  3259     if (currentThread == 
"") {
  3261     if (output.fText.contains(QRegExp(filter))) {
  3262       return output.fText;
  3269 void G4UIQt::FilterAllOutputTextArea() {
  3271   QString currentThread = 
"";
  3272 #ifdef G4MULTITHREADED  3273   currentThread = fThreadsFilterComboBox->currentText();
  3274   if (currentThread == 
"Master") {
  3278   QString filter = fCoutFilter->text();
  3279   G4String previousOutputStream = 
"";
  3281   fCoutTBTextArea->clear();
  3282   fCoutTBTextArea->setTextColor(QColor(Qt::black));
  3284   for (
unsigned int a=0; 
a<fG4OutputString.size(); 
a++) {
  3285     G4UIOutputString out = fG4OutputString[
a];
  3286     if (FilterOutput(out,currentThread,filter) != 
"") {
  3289       if (out.fOutputStream != previousOutputStream) {
  3290         previousOutputStream = out.fOutputStream;
  3291         if (out.fOutputStream == 
"info") {
  3292           fCoutTBTextArea->setTextColor(QColor(Qt::black));
  3294           fCoutTBTextArea->setTextColor(QColor(
Qt::red));
  3297       fCoutTBTextArea->
append(out.fText);
  3300   fCoutTBTextArea->setTextColor(QColor(Qt::black));
  3308 void G4UIQt::LookForHelpStringCallback(
  3311   QString searchText = fHelpLine->text();
  3313   fParameterHelpLabel->setText(
"");
  3314   fParameterHelpTable->setVisible(
false);
  3315   if (searchText ==
"") {
  3317     fHelpTreeWidget->clear();
  3323     OpenHelpTreeOnCommand(searchText);
  3328 void G4UIQt::OpenHelpTreeOnCommand(
  3329  const QString & searchText
  3334   if(UI==NULL) 
return;
  3340   fHelpTreeWidget->clear();
  3346   QMap<int,QString> commandResultMap;
  3347   QMap<int,QString> commandChildResultMap;
  3349   for (
int a=0;
a<treeSize;
a++) {
  3351     tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
  3353       commandResultMap.insertMulti(tmp,QString((
char*)(treeTop->
GetTree(
a+1)->
GetPathName()).data()));
  3356     commandChildResultMap = LookForHelpStringInChildTree(treeTop->
GetTree(
a+1),searchText);
  3358     if (!commandChildResultMap.empty()) {
  3359       QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
  3360       while (i != commandChildResultMap.constEnd()) {
  3361         commandResultMap.insertMulti(i.key(),i.value());
  3364       commandChildResultMap.clear();
  3369   fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
  3370   fHelpTreeWidget->setColumnCount(2);
  3372   labels << QString(
"Command") << QString(
"Match");
  3373   fHelpTreeWidget->setHeaderLabels(labels);
  3375   if (commandResultMap.empty()) {
  3376     fParameterHelpLabel->setText(
"No match found");
  3377     fParameterHelpTable->setVisible(
false);
  3381   QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
  3384   float multValue = 10.0/(float)(i.key());
  3385   QString progressChar = 
"|";
  3386   QString progressStr = 
"|";
  3388   QTreeWidgetItem * newItem;
  3391     if (i == commandResultMap.constBegin()) {
  3394     for(
int a=0;
a<int(i.key()*multValue);
a++) {
  3395       progressStr += progressChar;
  3397     newItem = 
new QTreeWidgetItem();
  3398     QString commandStr = i.value().trimmed();
  3400     if (commandStr.indexOf(
"/") == 0) {
  3401       commandStr = commandStr.right(commandStr.size()-1);
  3404     newItem->setText(0,commandStr);
  3405     newItem->setText(1,progressStr);
  3406     fHelpTreeWidget->addTopLevelItem(newItem);
  3407 #if QT_VERSION < 0x040200  3409     newItem->setForeground ( 1, QBrush(
Qt::blue) );
  3414   fHelpTreeWidget->resizeColumnToContents (0);
  3415   fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
  3422 QMap<int,QString> G4UIQt::LookForHelpStringInChildTree(
  3424 ,
const QString & text
  3427   QMap<int,QString> commandResultMap;
  3428   if (aCommandTree == NULL) 
return commandResultMap;
  3433   QMap<int,QString> commandChildResultMap;
  3437     tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
  3439       commandResultMap.insertMulti(tmp,QString((
char*)(aCommandTree->
GetTree(
a+1)->
GetPathName()).data()));
  3442     commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->
GetTree(
a+1),text);
  3444     if (!commandChildResultMap.empty()) {
  3446       QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
  3447       while (i != commandChildResultMap.constEnd()) {
  3448         commandResultMap.insertMulti(i.key(),i.value());
  3451       commandChildResultMap.clear();
  3458     tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
  3464   return commandResultMap;
  3468 QString G4UIQt::GetShortCommandPath(
  3472   if (commandPath.indexOf(
"/") == 0) {
  3473     commandPath = commandPath.right(commandPath.size()-1);
  3476   commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf(
"/",-2)-1);
  3478  if (commandPath.lastIndexOf(
"/") == (commandPath.size()-1)) {
  3479     commandPath = commandPath.left(commandPath.size()-1);
  3486 QString G4UIQt::GetLongCommandPath(
  3487  QTreeWidgetItem* item
  3490   if (item == NULL) 
return "";
  3493   QString itemText = 
"";
  3494   itemText = item->text(0);
  3496   while (item->parent() != NULL) {
  3497     itemText = item->parent()->text(0)+
"/"+itemText;
  3498     item = item->parent();
  3500   itemText = 
"/"+itemText;
  3506 void G4UIQt::ChangeColorCallback(QWidget* widget) {
  3507   if (widget == NULL) {
  3511   QPushButton* button = 
dynamic_cast<QPushButton*
>(
widget);
  3515   QString value = button->accessibleName();
  3518   old.setRgbF(value.section(
" ",0,1).toDouble(),
  3519               value.section(
" ",1,2).toDouble(),
  3520               value.section(
" ",2,3).toDouble());
  3521 #if QT_VERSION < 0x040500  3523   QColor color = QColor(QColorDialog::getRgba (old.rgba(),&
a,fUITabWidget));
  3525   QColor color = QColorDialog::getColor(old,
  3528                     QColorDialog::ShowAlphaChannel);
  3532   if (color.isValid()) {
  3534     QPixmap pixmap = QPixmap(QSize(16, 16));
  3535     pixmap.fill (color);
  3536     QPainter painter(&pixmap);
  3537     painter.setPen(Qt::black);
  3538     painter.drawRect(0,0,15,15); 
  3540     button->setAccessibleName(QString::number(color.redF())+
" "+
  3541                               QString::number(color.greenF())+
" "+
  3542                               QString::number(color.blueF())+
" "  3544     button->setIcon(pixmap);
  3551 void G4UIQt::ChangeCursorStyle(
const QString& action) {
  3555   fMoveSelected = 
true;
  3556   fPickSelected = 
true;
  3557   fRotateSelected = 
true;
  3558   fZoomInSelected = 
true;
  3559   fZoomOutSelected = 
true;
  3561   if (fToolbarApp == NULL) 
return; 
  3562   QList<QAction *> list = fToolbarApp->actions ();
  3563   for (
int i = 0; i < list.size(); ++i) {
  3564     if (list.at(i)->data().toString () == action) {
  3565       list.at(i)->setChecked(
TRUE);
  3566       if (list.at(i)->data().toString () == 
"pick") {
  3569     } 
else if (list.at(i)->data().toString () == 
"move") {
  3570       fMoveSelected = 
false;
  3571       list.at(i)->setChecked(
FALSE);
  3572     } 
else if (list.at(i)->data().toString () == 
"pick") {
  3573       fPickSelected = 
false;
  3574       list.at(i)->setChecked(
FALSE);
  3576     } 
else if (list.at(i)->data().toString () == 
"rotate") {
  3577       fRotateSelected = 
false;
  3578       list.at(i)->setChecked(
FALSE);
  3579     } 
else if (list.at(i)->data().toString () == 
"zoom_in") {
  3580       fZoomInSelected = 
false;
  3581       list.at(i)->setChecked(
FALSE);
  3582     } 
else if (list.at(i)->data().toString () == 
"zoom_out") {
  3583       fZoomOutSelected = 
false;
  3584       list.at(i)->setChecked(
FALSE);
  3597 void G4UIQt::ChangeSurfaceStyle(
const QString& action) {
  3601   if (fToolbarApp == NULL) 
return; 
  3602   QList<QAction *> list = fToolbarApp->actions ();
  3603   for (
int i = 0; i < list.size(); ++i) {
  3604     if (list.at(i)->data().toString () == action) {
  3605       list.at(i)->setChecked(
TRUE);
  3606     } 
else if (list.at(i)->data().toString () == 
"hidden_line_removal") {
  3607       list.at(i)->setChecked(
FALSE);
  3608     } 
else if (list.at(i)->data().toString () == 
"hidden_line_and_surface_removal") {
  3609       list.at(i)->setChecked(
FALSE);
  3610     } 
else if (list.at(i)->data().toString () == 
"solid") {
  3611       list.at(i)->setChecked(
FALSE);
  3612     } 
else if (list.at(i)->data().toString () == 
"wireframe") {
  3613       list.at(i)->setChecked(
FALSE);
  3618   if (action == 
"hidden_line_removal") {
  3622   } 
else if (action == 
"hidden_line_and_surface_removal") {
  3626   } 
else if (action == 
"solid") {
  3630   } 
else if (action == 
"wireframe") {
  3637 void G4UIQt::OpenIconCallback(
const QString& aParam) {
  3639   QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
  3640   QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
  3642   QString nomFich = QFileDialog::getOpenFileName(fMainWindow, aLabel, fLastOpenPath, 
"Macro files (*.mac)");
  3643   if (nomFich != 
"") {
  3646     fLastOpenPath = dir.absoluteFilePath(nomFich);
  3651 void G4UIQt::SaveIconCallback(
const QString& aParam) {
  3653   QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
  3654   QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
  3656   QString nomFich = QFileDialog::getSaveFileName(fMainWindow, aLabel, fLastOpenPath, 
"Macro files (*.mac)");
  3657   if (nomFich != 
"") {
  3660     fLastOpenPath = dir.absoluteFilePath(nomFich);
  3666 void G4UIQt::ChangePerspectiveOrtho(
const QString& action) {
  3670   if (fToolbarApp == NULL) 
return;
  3671   QList<QAction *> list = fToolbarApp->actions ();
  3672   QString checked = 
"";
  3673   for (
int i = 0; i < list.size(); ++i) {
  3674     if (list.at(i)->data().toString () == action) {
  3675       list.at(i)->setChecked(
TRUE);
  3676       checked = list.at(i)->data().toString ();
  3677     } 
else if (list.at(i)->data().toString () == 
"persepective") {
  3678       list.at(i)->setChecked(
FALSE);
  3679     } 
else if (list.at(i)->data().toString () == 
"ortho") {
  3680       list.at(i)->setChecked(
FALSE);
  3684   if ((action == 
"ortho") && (checked == 
"ortho")) {
  3686   } 
else if ((action == 
"perspective") && (checked == 
"perspective")) {
  3693 void G4UIQt::SetIconMoveSelected() {
  3695   fMoveSelected = 
true;
  3696   fRotateSelected = 
false;
  3697   fPickSelected = 
false;
  3698   fZoomInSelected = 
false;
  3699   fZoomOutSelected = 
false;
  3701   if (fToolbarApp == NULL) 
return; 
  3702   QList<QAction *> list = fToolbarApp->actions ();
  3703   for (
int i = 0; i < list.size(); ++i) {
  3704     if (list.at(i)->data().toString () == 
"move") {
  3705       list.at(i)->setChecked(
TRUE);
  3706     } 
else if (list.at(i)->data().toString () == 
"rotate") {
  3707       list.at(i)->setChecked(
FALSE);
  3708     } 
else if (list.at(i)->data().toString () == 
"pick") {
  3709       list.at(i)->setChecked(
FALSE);
  3710     } 
else if (list.at(i)->data().toString () == 
"zoom_in") {
  3711       list.at(i)->setChecked(
FALSE);
  3712     } 
else if (list.at(i)->data().toString () == 
"zoom_out") {
  3713       list.at(i)->setChecked(
FALSE);
  3719 void G4UIQt::SetIconRotateSelected() {
  3721   fRotateSelected = 
true;
  3722   fMoveSelected = 
false;
  3723   fPickSelected = 
false;
  3724   fZoomInSelected = 
false;
  3725   fZoomOutSelected = 
false;
  3727   if (fToolbarApp == NULL) 
return; 
  3728   QList<QAction *> list = fToolbarApp->actions ();
  3729   for (
int i = 0; i < list.size(); ++i) {
  3730     if (list.at(i)->data().toString () == 
"rotate") {
  3731       list.at(i)->setChecked(
TRUE);
  3732     } 
else if (list.at(i)->data().toString () == 
"move") {
  3733       list.at(i)->setChecked(
FALSE);
  3734     } 
else if (list.at(i)->data().toString () == 
"pick") {
  3735       list.at(i)->setChecked(
FALSE);
  3736     } 
else if (list.at(i)->data().toString () == 
"zoom_in") {
  3737       list.at(i)->setChecked(
FALSE);
  3738     } 
else if (list.at(i)->data().toString () == 
"zoom_out") {
  3739       list.at(i)->setChecked(
FALSE);
  3745 void G4UIQt::SetIconPickSelected() {
  3747   fPickSelected = 
true;
  3748   fMoveSelected = 
false;
  3749   fRotateSelected = 
false;
  3750   fZoomInSelected = 
false;
  3751   fZoomOutSelected = 
false;
  3753   if (fToolbarApp == NULL) 
return; 
  3754   QList<QAction *> list = fToolbarApp->actions ();
  3755   for (
int i = 0; i < list.size(); ++i) {
  3756     if (list.at(i)->data().toString () == 
"pick") {
  3757       list.at(i)->setChecked(
TRUE);
  3758     } 
else if (list.at(i)->data().toString () == 
"move") {
  3759       list.at(i)->setChecked(
FALSE);
  3760     } 
else if (list.at(i)->data().toString () == 
"rotate") {
  3761       list.at(i)->setChecked(
FALSE);
  3762     } 
else if (list.at(i)->data().toString () == 
"zoom_in") {
  3763       list.at(i)->setChecked(
FALSE);
  3764     } 
else if (list.at(i)->data().toString () == 
"zoom_out") {
  3765       list.at(i)->setChecked(
FALSE);
  3771 void G4UIQt::SetIconZoomInSelected() {
  3773   fZoomInSelected = 
true;
  3774   fMoveSelected = 
false;
  3775   fRotateSelected = 
false;
  3776   fPickSelected = 
false;
  3777   fZoomOutSelected = 
false;
  3779   if (fToolbarApp == NULL) 
return; 
  3780   QList<QAction *> list = fToolbarApp->actions ();
  3781   for (
int i = 0; i < list.size(); ++i) {
  3782     if (list.at(i)->data().toString () == 
"zoom_in") {
  3783       list.at(i)->setChecked(
TRUE);
  3784     } 
else if (list.at(i)->data().toString () == 
"move") {
  3785       list.at(i)->setChecked(
FALSE);
  3786     } 
else if (list.at(i)->data().toString () == 
"rotate") {
  3787       list.at(i)->setChecked(
FALSE);
  3788     } 
else if (list.at(i)->data().toString () == 
"pick") {
  3789       list.at(i)->setChecked(
FALSE);
  3790     } 
else if (list.at(i)->data().toString () == 
"zoom_out") {
  3791       list.at(i)->setChecked(
FALSE);
  3797 void G4UIQt::SetIconZoomOutSelected() {
  3799   fZoomOutSelected = 
true;
  3800   fMoveSelected = 
false;
  3801   fRotateSelected = 
false;
  3802   fPickSelected = 
false;
  3803   fZoomInSelected = 
false;
  3805   if (fToolbarApp == NULL) 
return; 
  3806   QList<QAction *> list = fToolbarApp->actions ();
  3807   for (
int i = 0; i < list.size(); ++i) {
  3808     if (list.at(i)->data().toString () == 
"zoom_out") {
  3809       list.at(i)->setChecked(
TRUE);
  3810     } 
else if (list.at(i)->data().toString () == 
"move") {
  3811       list.at(i)->setChecked(
FALSE);
  3812     } 
else if (list.at(i)->data().toString () == 
"rotate") {
  3813       list.at(i)->setChecked(
FALSE);
  3814     } 
else if (list.at(i)->data().toString () == 
"pick") {
  3815       list.at(i)->setChecked(
FALSE);
  3816     } 
else if (list.at(i)->data().toString () == 
"zoom_in") {
  3817       list.at(i)->setChecked(
FALSE);
  3823 void G4UIQt::SetIconSolidSelected() {
  3826   if (fToolbarApp == NULL) 
return; 
  3827   QList<QAction *> list = fToolbarApp->actions ();
  3828   for (
int i = 0; i < list.size(); ++i) {
  3829     if (list.at(i)->data().toString () == 
"solid") {
  3830       list.at(i)->setChecked(
TRUE);
  3831     } 
else if (list.at(i)->data().toString () == 
"hidden_line_removal") {
  3832       list.at(i)->setChecked(
FALSE);
  3833     } 
else if (list.at(i)->data().toString () == 
"hidden_line_and_surface_removal") {
  3834       list.at(i)->setChecked(
FALSE);
  3835     } 
else if (list.at(i)->data().toString () == 
"wireframe") {
  3836       list.at(i)->setChecked(
FALSE);
  3842 void G4UIQt::SetIconWireframeSelected() {
  3845   if (fToolbarApp == NULL) 
return; 
  3846   QList<QAction *> list = fToolbarApp->actions ();
  3847   for (
int i = 0; i < list.size(); ++i) {
  3848     if (list.at(i)->data().toString () == 
"wireframe") {
  3849       list.at(i)->setChecked(
TRUE);
  3850     } 
else if (list.at(i)->data().toString () == 
"hidden_line_removal") {
  3851       list.at(i)->setChecked(
FALSE);
  3852     } 
else if (list.at(i)->data().toString () == 
"hidden_line_and_surface_removal") {
  3853       list.at(i)->setChecked(
FALSE);
  3854     } 
else if (list.at(i)->data().toString () == 
"solid") {
  3855       list.at(i)->setChecked(
FALSE);
  3861 void G4UIQt::SetIconHLRSelected() {
  3864   if (fToolbarApp == NULL) 
return; 
  3865   QList<QAction *> list = fToolbarApp->actions ();
  3866   for (
int i = 0; i < list.size(); ++i) {
  3867     if (list.at(i)->data().toString () == 
"hidden_line_removal") {
  3868       list.at(i)->setChecked(
TRUE);
  3869     } 
else if (list.at(i)->data().toString () == 
"solid") {
  3870       list.at(i)->setChecked(
FALSE);
  3871     } 
else if (list.at(i)->data().toString () == 
"hidden_line_and_surface_removal") {
  3872       list.at(i)->setChecked(
FALSE);
  3873     } 
else if (list.at(i)->data().toString () == 
"wireframe") {
  3874       list.at(i)->setChecked(
FALSE);
  3880 void G4UIQt::SetIconHLHSRSelected() {
  3883   if (fToolbarApp == NULL) 
return; 
  3884   QList<QAction *> list = fToolbarApp->actions ();
  3885   for (
int i = 0; i < list.size(); ++i) {
  3886     if (list.at(i)->data().toString () == 
"hidden_line_and_surface_removal") {
  3887       list.at(i)->setChecked(
TRUE);
  3888     } 
else if (list.at(i)->data().toString () == 
"solid") {
  3889       list.at(i)->setChecked(
FALSE);
  3890     } 
else if (list.at(i)->data().toString () == 
"hidden_line_removal") {
  3891       list.at(i)->setChecked(
FALSE);
  3892     } 
else if (list.at(i)->data().toString () == 
"wireframe") {
  3893       list.at(i)->setChecked(
FALSE);
  3899 void G4UIQt::SetIconPerspectiveSelected() {
  3902   if (fToolbarApp == NULL) 
return; 
  3903   QList<QAction *> list = fToolbarApp->actions ();
  3904   for (
int i = 0; i < list.size(); ++i) {
  3905     if (list.at(i)->data().toString () == 
"perspective") {
  3906       list.at(i)->setChecked(
TRUE);
  3907     } 
else if (list.at(i)->data().toString () == 
"ortho") {
  3908       list.at(i)->setChecked(
FALSE);
  3915 void G4UIQt::SetIconOrthoSelected() {
  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 () == 
"ortho") {
  3922       list.at(i)->setChecked(
TRUE);
  3923     } 
else if (list.at(i)->data().toString () == 
"perspective") {
  3924       list.at(i)->setChecked(
FALSE);
  3931 G4QTabWidget::G4QTabWidget(
  3935 ):QTabWidget(aParent)
  3936  ,fTabSelected(false)
  3938 ,fPreferedSizeX(sizeX+6)  
  3939 ,fPreferedSizeY(sizeY+58)  
  3941   setMinimumSize(100,100);
  3942   QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
  3943   setSizePolicy(policy);
  3946 G4QTabWidget::G4QTabWidget(
  3948  ,fTabSelected(false)
  3956 G4UIOutputString::G4UIOutputString(
  3964   if (!GetOutputList().contains(QString(
" ")+outputStream+
" ")) {
  3965     fOutputStream = 
"info";
  3967     fOutputStream = outputStream;
  3972 #if QT_VERSION < 0x040500  3973 void G4UIQt::TabCloseCallback(
int){
  3975 void G4UIQt::TabCloseCallback(
int a){
  3977 #if QT_VERSION < 0x040500  3979   if (fViewerTabWidget == NULL) 
return;
  3982   QWidget* temp = fViewerTabWidget->widget(a);
  3984   fViewerTabWidget->removeTab (a);
  3992 void G4UIQt::ToolBoxActivated(
int a){
  3994   if (fUITabWidget->widget(a) == fHelpTBWidget) {
  3997   } 
else if (fUITabWidget->widget(a) == fSceneTreeComponentsTBWidget) {
  3998 #if QT_VERSION < 0x040200  3999     fSceneTreeComponentsTBWidget->show();
  4001     fSceneTreeComponentsTBWidget->setVisible(
true);
  4007 void G4QTabWidget::paintEvent(
  4012   if (currentWidget()) {
  4014     if ( isTabSelected()) {
  4018       QString text = tabText (currentIndex());
  4020       if (fLastCreated == -1) {
  4021         QTextEdit* edit = 
dynamic_cast<QTextEdit*
>(currentWidget());
  4023           QString paramSelect = QString(
"/vis/viewer/select ")+text;
  4032       setTabSelected(
false);
  4038 G4UIDockWidget::G4UIDockWidget(QString txt):
  4043 void G4UIDockWidget::closeEvent(QCloseEvent *aEvent) {
  4044   setFloating (
false);
 G4int GetGuidanceEntries() const
 
G4String GetDefaultValue() const
 
G4UIcommandTree * FindCommandTree(const char *commandPath)
 
G4MTcoutDestination * GetThreadCout()
 
const G4UIcommand * GetGuidance() const
 
G4String GetParameterRange() const
 
const char * data() const
 
G4int GetVerboseLevel() const
 
G4String strip(G4int strip_Type=trailing, char c=' ')
 
G4bool GetCurrentAsDefault() const
 
G4UIcommand * GetCommand(G4int i)
 
const G4String GetParameterGuidance() const
 
const G4String & GetGuidanceLine(G4int i) const
 
G4bool IsOmittable() const
 
char GetParameterType() const
 
G4UIparameter * GetParameter(G4int i) const
 
const G4String GetPathName() const
 
void SetSession(G4UIsession *const value)
 
G4bool contains(const std::string &) const
 
str_size index(const char *, G4int pos=0) const
 
#define G4MUTEX_INITIALIZER
 
void SetG4UIWindow(G4UIsession *const value)
 
G4int GetCommandEntry() const
 
static G4UImanager * GetUIpointer()
 
static G4StateManager * GetStateManager()
 
G4GLOB_DLL std::ostream G4cout
 
G4UIcommandTree * GetTree(G4int i)
 
const G4String & GetRange() const
 
G4String GetParameterName() const
 
G4UIcommandTree * GetTree() const
 
G4UIcommand * FindPath(const char *commandPath) const
 
G4String GetPrefixString() const
 
G4String GetParameterCandidates() const
 
G4String & append(const G4String &)
 
void SetCoutDestination(G4UIsession *const value)
 
const G4String & GetCommandPath() const
 
G4String FindMacroPath(const G4String &fname) const
 
G4int GetParameterEntries() const
 
G4ApplicationState GetCurrentState() const
 
G4int GetTreeEntry() const
 
const G4String GetTitle() const
 
G4int ApplyCommand(const char *aCommand)
 
G4String GetFullPrefixString() const