Ignore:
Timestamp:
Dec 17, 2009, 6:14:30 PM (15 years ago)
Author:
garnier
Message:

UIQt on avance

Location:
trunk/source/interfaces
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/interfaces/basic/include/G4UIQt.hh

    r1223 r1224  
    4040#include <qobject.h>
    4141#include <qmap.h>
     42#include <qstringlist.h>
    4243
    4344class QMainWindow;
     
    5758class QResizeEvent;
    5859class QToolBox;
     60class QStringList;
    5961
    6062// Class description :
     
    98100  // Ex : AddButton("my_menu","Run","/run/beamOn 1");
    99101
    100   void AddTabVisWidget(QWidget*,QString,int,int);
     102  void AddTabWidget(QWidget*,QString,int,int);
    101103  // To add a tab for vis openGL Qt driver
    102104
     
    118120  QTreeWidget * CreateHelpTree();
    119121#endif
     122  void ExitHelp();
    120123
    121124#if QT_VERSION < 0x040000
     
    134137  QMap<int,QString> LookForHelpStringInChildTree(G4UIcommandTree *,const QString&);
    135138
     139  void CreateVisParametersTBWidget();
     140  void CreateViewComponentsTBWidget();
     141  void CreateHelpTBWidget();
     142  void CreateCoutTBWidget();
     143  void CreateHistoryTBWidget();
    136144
    137145private:
     
    144152  QLabel *fCommandLabel;
    145153  QLineEdit * fCommandArea;
    146   QTextEdit *fTextArea;
     154  QTextEdit *fCoutTBTextArea;
    147155  QTextEdit *fHelpArea;
    148156  QToolBox* fToolBox;
     157  QStringList fG4cout;
     158  QLineEdit * fCoutFilter;
    149159
    150160#if QT_VERSION < 0x040000
    151   QListView *fCommandHistoryArea;
     161  QListView *fHistoryTBTableList;
    152162  QListView *fHelpTreeWidget;
    153163#else
    154   QListWidget *fCommandHistoryArea;
     164  QListWidget *fHistoryTBTableList;
    155165  QTreeWidget *fHelpTreeWidget;
    156166#endif
    157   QWidget *fHelpTBWidget;
    158   QLineEdit *helpLine;
    159   QWidget *visWidget;
     167  QWidget* fHelpTBWidget;
     168  QWidget* fHistoryTBWidget;
     169  QWidget* fCoutTBWidget;
     170  QWidget* fVisParametersTBWidget;
     171  QWidget* fViewComponentsTBWidget;
     172  QLineEdit* helpLine;
    160173  QTabWidget* fTabWidget;
    161174  QString fCoutText;
     
    176189  void UpdateTabWidget(int);
    177190  void ResizeTabWidget( QResizeEvent* );
     191  void CoutFilterCallback(const QString&);
    178192};
    179193
  • trunk/source/interfaces/basic/src/G4UIQt.cc

    r1223 r1224  
    6161#include <qtabbar.h>
    6262#include <qresizeevent>
     63#include <qstringlist.h>
    6364
    6465#include <qmainwindow.h>
     
    107108,char** argv
    108109)
    109 :fTabWidget(NULL)
     110:fG4cout("")
     111,fHelpTBWidget(NULL)
     112,fHistoryTBWidget(NULL)
     113,fCoutTBWidget(NULL)
     114,fVisParametersTBWidget(NULL)
     115,fViewComponentsTBWidget(NULL)
     116,fTabWidget(NULL)
    110117,fCoutText("Output")
    111118{
     119
    112120  G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");
    113121  if (!(QApplication*)interactorManager->GetMainInteractor()) {
     
    150158  printf("G4UIQt::Initialise after main window creation UImanager:%d G4UIQt(this) : %d+++++++++++\n",UI,this);
    151159#endif
    152 #if QT_VERSION < 0x040000
    153   fMainWindow->setCaption( tr( "G4UI Session" ));
    154   fMainWindow->resize(900,600);
    155   fMainWindow->move(50,100);
    156 #else
    157   fMainWindow->setWindowTitle( tr("G4UI Session") );
    158   fMainWindow->resize(900,600);
    159   fMainWindow->move(QPoint(50,100));
    160 #endif
    161160
    162161#ifdef G4DEBUG_INTERFACES_BASIC
     
    177176  // Set layouts
    178177
    179   fTabWidget = new QTabWidget;
    180 
    181   connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
    182   connect(fTabWidget, SIGNAL(resizeEvent (  QResizeEvent* ) ), SLOT(ResizeTabWidget( QResizeEvent*)));
    183 
    184   visWidget = new QWidget(myVSplitter);
    185   QWidget* coutTBWidget = new QWidget(fToolBox);
    186   fHelpTBWidget = new QWidget(fToolBox);
    187   QWidget* visParametersTBWidget = new QWidget(fToolBox);
    188   QWidget* viewComponentsTBWidget = new QWidget(fToolBox);
    189   QWidget* historyTBWidget = new QWidget(fToolBox);
     178  // Add a empty tabwidget
     179  fTabWidget = new QTabWidget(myVSplitter);
     180
    190181  QWidget* commandLineWidget = new QWidget(mainWidget);
    191 
    192   //  QVBoxLayout *layoutVis = new QVBoxLayout(visWidget);
    193   QVBoxLayout *layoutCout = new QVBoxLayout(coutTBWidget);
    194   QVBoxLayout *layoutHistory = new QVBoxLayout(historyTBWidget);
     182#if QT_VERSION < 0x040000
    195183  QVBoxLayout *layoutCommandLine = new QVBoxLayout(commandLineWidget);
    196 
     184#else
     185  QVBoxLayout *layoutCommandLine = new QVBoxLayout();
     186#endif
     187
     188#ifdef G4DEBUG_INTERFACES_BASIC
     189  printf("G4UIQt::G4UIQt :: 2b\n");
     190#endif
    197191  // fill them
    198 
    199   fTextArea = new QTextEdit(coutTBWidget);
    200   QPushButton *clearButton = new QPushButton("clear",coutTBWidget);
    201   connect(clearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
    202 
    203 #if QT_VERSION < 0x040000
    204 
    205   fCommandHistoryArea = new QListView(historyTBWidget);
    206   fCommandHistoryArea->setSorting (-1, FALSE);
    207   fCommandHistoryArea->setSelectionMode(QListView::Single);
    208   fCommandHistoryArea->addColumn("");
    209   fCommandHistoryArea->header()->hide();
    210   connect(fCommandHistoryArea, SIGNAL(selectionChanged()), SLOT(CommandHistoryCallback()));
    211 #else
    212   fCommandHistoryArea = new QListWidget();
    213   fCommandHistoryArea->setSelectionMode(QAbstractItemView::SingleSelection);
    214   connect(fCommandHistoryArea, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
    215 #endif
    216   fCommandHistoryArea->installEventFilter(this);
    217192
    218193  fCommandLabel = new QLabel("",commandLineWidget);
     
    228203  fCommandArea->activateWindow();
    229204#endif
    230   connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
     205
    231206#if QT_VERSION < 0x040000
    232207  fCommandArea->setFocusPolicy ( QWidget::StrongFocus );
     
    236211  fCommandArea->setFocus(Qt::TabFocusReason);
    237212#endif
    238   fTextArea->setReadOnly(true);
    239 
    240   //  layoutVis->addWidget(visWidget);
    241 
    242   layoutCout->addWidget(fTextArea);
    243   layoutCout->addWidget(clearButton);
    244 
    245 #ifdef G4DEBUG_INTERFACES_BASIC
    246   printf("G4UIQt::G4UIQt :: 4\n");
    247 #endif
    248 #if QT_VERSION >= 0x040000
    249   //  topWidget->setLayout(layoutTop);
    250 #endif
    251 
    252 
    253   layoutHistory->addWidget(fCommandHistoryArea);
     213
     214#ifdef G4DEBUG_INTERFACES_BASIC
     215  printf("G4UIQt::G4UIQt :: 4a\n");
     216#endif
     217
     218
    254219  layoutCommandLine->addWidget(fCommandLabel);
    255220  layoutCommandLine->addWidget(fCommandArea);
    256221#if QT_VERSION >= 0x040000
    257 
     222  QVBoxLayout *mainLayout = new QVBoxLayout();
     223#else
    258224  QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
    259 
    260   CreateHelpWidget();
     225#endif
     226
     227  fHelpTBWidget = new QWidget(fToolBox);
     228  fHistoryTBWidget = new QWidget(fToolBox);
     229  fCoutTBWidget = new QWidget(fToolBox);
     230  fVisParametersTBWidget = new QWidget(fToolBox);
     231  fViewComponentsTBWidget = new QWidget(fToolBox);
     232
     233#ifdef G4DEBUG_INTERFACES_BASIC
     234  printf("G4UIQt::G4UIQt :: 4b\n");
     235#endif
     236  CreateVisParametersTBWidget();
     237#ifdef G4DEBUG_INTERFACES_BASIC
     238  printf("G4UIQt::G4UIQt :: 4c\n");
     239#endif
     240  //  CreateViewComponentsTBWidget();
     241#ifdef G4DEBUG_INTERFACES_BASIC
     242  printf("G4UIQt::G4UIQt :: 4d\n");
     243#endif
     244  //  CreateHelpTBWidget();
     245#ifdef G4DEBUG_INTERFACES_BASIC
     246  printf("G4UIQt::G4UIQt :: 4e\n");
     247#endif
     248  CreateCoutTBWidget();
     249#ifdef G4DEBUG_INTERFACES_BASIC
     250  printf("G4UIQt::G4UIQt :: 4f\n");
     251#endif
     252  CreateHistoryTBWidget();
     253#ifdef G4DEBUG_INTERFACES_BASIC
     254  printf("G4UIQt::G4UIQt :: 4g\n");
     255#endif
     256
    261257  // the splitter
    262   fToolBox->addItem(visParametersTBWidget,"Vis parameters");
    263   fToolBox->addItem(viewComponentsTBWidget,"Viewer components");
     258  fToolBox->addItem(fVisParametersTBWidget,"Vis parameters");
     259#ifdef G4DEBUG_INTERFACES_BASIC
     260  printf("G4UIQt::G4UIQt :: 4h\n");
     261#endif
     262  fToolBox->addItem(fViewComponentsTBWidget,"Viewer components");
     263#ifdef G4DEBUG_INTERFACES_BASIC
     264  printf("G4UIQt::G4UIQt :: 4i\n");
     265#endif
    264266  fToolBox->addItem(fHelpTBWidget,"Help");
    265   fToolBox->addItem(coutTBWidget,"Cout");
    266   fToolBox->addItem(historyTBWidget,"History");
     267#ifdef G4DEBUG_INTERFACES_BASIC
     268  printf("G4UIQt::G4UIQt :: 4j\n");
     269#endif
     270  fToolBox->addItem(fCoutTBWidget,"Cout");
     271#ifdef G4DEBUG_INTERFACES_BASIC
     272  printf("G4UIQt::G4UIQt :: 4k\n");
     273#endif
     274  fToolBox->addItem(fHistoryTBWidget,"History");
     275#ifdef G4DEBUG_INTERFACES_BASIC
     276  printf("G4UIQt::G4UIQt :: 4l\n");
     277#endif
     278
    267279
    268280
    269281  fToolBox->setSizePolicy (QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
    270   visWidget->setSizePolicy (QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));
    271 
    272   QSizePolicy policy = visWidget->sizePolicy();
     282  fTabWidget->setSizePolicy (QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));
     283
     284  QSizePolicy policy = fTabWidget->sizePolicy();
    273285  policy.setHorizontalStretch(1);
    274286  policy.setVerticalStretch(1);
    275   visWidget->setSizePolicy(policy);
     287  fTabWidget->setSizePolicy(policy);
    276288
    277289  myVSplitter->addWidget(fToolBox);
    278   myVSplitter->addWidget(visWidget);
    279 
     290  myVSplitter->addWidget(fTabWidget);
     291
     292#if QT_VERSION >= 0x040000
     293  commandLineWidget->setLayout(layoutCommandLine);
     294#endif
    280295  commandLineWidget->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
    281296  mainLayout->addWidget(myVSplitter,1);
    282297  mainLayout->addWidget(commandLineWidget);
    283298
    284 #endif
    285299#ifdef G4DEBUG_INTERFACES_BASIC
    286300  printf("G4UIQt::G4UIQt :: 5\n");
     
    288302
    289303#if QT_VERSION >= 0x040000
     304  mainWidget->setLayout(mainLayout);
     305#endif
     306
    290307  fMainWindow->setCentralWidget(mainWidget);
    291 #else
    292   fMainWindow->setCentralWidget(myVSplitter);
    293 #endif
    294308
    295309#if QT_VERSION < 0x040000
     
    313327#endif
    314328
    315   // Set the splitter size. The fTextArea sould be 2/3 on the fMainWindow
    316 #if QT_VERSION < 0x040000
    317   //  QValueList<int> vals = splitter->sizes();
    318 #else
    319   //  QList<int> vals = splitter->sizes();
    320 #endif
    321 //    if(vals.size()==2) {
    322 //      vals[0] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*3/4;
    323 //      vals[1] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*1/4;
    324 //      splitter->setSizes(vals);
    325 //    }
     329  connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
    326330
    327331  if(UI!=NULL) UI->SetCoutDestination(this);  // TO KEEP
    328332
    329333  interactorManager->SetG4UI(this);
     334
     335#if QT_VERSION < 0x040000
     336  fMainWindow->setCaption( tr( "G4UI Session" ));
     337  fMainWindow->resize(900,600);
     338  fMainWindow->move(50,100);
     339#else
     340  fMainWindow->setWindowTitle( tr("G4UI Session") );
     341  fMainWindow->resize(900,600);
     342  fMainWindow->move(QPoint(50,100));
     343#endif
    330344
    331345#ifdef G4DEBUG_INTERFACES_BASIC
     
    356370}
    357371
     372/** Create the History ToolBox Widget
     373 */
     374void G4UIQt::CreateHistoryTBWidget(
     375)
     376{
     377
     378#if QT_VERSION < 0x040000
     379  QVBoxLayout *layoutHistoryTB = new QVBoxLayout(fHistoryTBWidget);
     380
     381  fHistoryTBTableList = new QListView(fHistoryTBWidget);
     382  fHistoryTBTableList->setSorting (-1, FALSE);
     383  fHistoryTBTableList->setSelectionMode(QListView::Single);
     384  fHistoryTBTableList->addColumn("");
     385  fHistoryTBTableList->header()->hide();
     386  connect(fHistoryTBTableList, SIGNAL(selectionChanged()), SLOT(CommandHistoryCallback()));
     387#else
     388  QVBoxLayout *layoutHistoryTB = new QVBoxLayout();
     389  fHistoryTBTableList = new QListWidget();
     390  fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
     391  connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
     392#endif
     393  fHistoryTBTableList->installEventFilter(this);
     394
     395  layoutHistoryTB->addWidget(fHistoryTBTableList);
     396
     397#if QT_VERSION >= 0x040000
     398  fHistoryTBWidget->setLayout(layoutHistoryTB);
     399#endif
     400}
     401
     402/** Create the Help ToolBox Widget
     403 */
     404void G4UIQt::CreateHelpTBWidget(
     405)
     406{
     407
     408  QWidget *helpWidget = new QWidget(fHelpTBWidget);
     409 
     410  QSplitter *splitter = new QSplitter(Qt::Horizontal,fHelpTBWidget);
     411#if QT_VERSION < 0x040000
     412  QHBoxLayout *helpLayout = new QHBoxLayout(helpWidget);
     413  QVBoxLayout *vLayout = new QVBoxLayout(fHelpTBWidget);
     414  helpLayout->add(new QLabel("Search :",helpWidget));
     415#else
     416  QHBoxLayout *helpLayout = new QHBoxLayout();
     417  QVBoxLayout *vLayout = new QVBoxLayout();
     418  helpLayout->addWidget(new QLabel("Search :",helpWidget));
     419#endif
     420  helpLine = new QLineEdit(fHelpTBWidget);
     421#if QT_VERSION < 0x040000
     422  helpLayout->add(helpLine);
     423  connect( helpLine, SIGNAL( returnPressed () ), this, SLOT( lookForHelpStringCallback() ) );
     424#else
     425  helpLayout->addWidget(helpLine);
     426  connect( helpLine, SIGNAL( editingFinished () ), this, SLOT( lookForHelpStringCallback() ) );
     427#endif
     428 
     429  // the help tree
     430#if QT_VERSION < 0x040000
     431  fHelpTreeWidget = new QListView(splitter);
     432#else
     433  fHelpTreeWidget = new QTreeWidget();
     434#endif
     435  fHelpTreeWidget = CreateHelpTree();
     436 
     437  fHelpArea = new QTextEdit(splitter);
     438  fHelpArea->setReadOnly(true);
     439 
     440  // Set layouts
     441 
     442#if QT_VERSION >= 0x040000
     443  if (fHelpTreeWidget)
     444    splitter->addWidget(fHelpTreeWidget);
     445  splitter->addWidget(fHelpArea);
     446#endif
     447 
     448 
     449#if QT_VERSION >= 0x040000
     450  vLayout->addWidget(helpWidget);
     451  vLayout->addWidget(splitter,1);
     452#else
     453  vLayout->addWidget(helpWidget);
     454  vLayout->addWidget(splitter,1);
     455#endif
     456 
     457  // set the splitter size
     458#if QT_VERSION >= 0x040000
     459  QList<int> list;
     460#else
     461  QValueList<int> list;
     462#endif
     463  list.append( 400 );
     464  list.append( 400 );
     465  splitter->setSizes(list);
     466
     467#if QT_VERSION >= 0x040000
     468  helpWidget->setLayout(helpLayout);
     469  fHelpTBWidget->setLayout(vLayout);
     470#endif 
     471}
     472
     473
     474/** Create the Cout ToolBox Widget
     475 */
     476void G4UIQt::CreateCoutTBWidget(
     477)
     478{
     479#if QT_VERSION >= 0x040000
     480  QVBoxLayout *layoutCoutTB = new QVBoxLayout();
     481#else
     482  QVBoxLayout *layoutCoutTB = new QVBoxLayout(fCoutTBWidget);
     483#endif
     484
     485  fCoutTBTextArea = new QTextEdit(fCoutTBWidget);
     486  fCoutFilter = new QLineEdit(fCoutTBWidget);
     487  QLabel* coutFilterLabel = new QLabel("Filter : ",fCoutTBWidget);
     488
     489  QPushButton *coutTBClearButton = new QPushButton("clear",fCoutTBWidget);
     490  connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
     491  connect(fCoutFilter, SIGNAL(textEdited ( const QString &)), SLOT(CoutFilterCallback( const QString &)));
     492
     493  fCoutTBTextArea->setReadOnly(true);
     494
     495  QWidget* coutButtonWidget = new QWidget(fCoutTBWidget);
     496  QHBoxLayout* layoutCoutTBButtons = new QHBoxLayout(coutButtonWidget);
     497  layoutCoutTBButtons->addWidget(coutTBClearButton);
     498  layoutCoutTBButtons->addWidget(coutFilterLabel);
     499  layoutCoutTBButtons->addWidget(fCoutFilter);
     500
     501  layoutCoutTB->addWidget(fCoutTBTextArea);
     502  layoutCoutTB->addWidget(coutButtonWidget);
     503
     504#if QT_VERSION >= 0x040000
     505  fCoutTBWidget->setLayout(layoutCoutTB);
     506#endif
     507}
     508
     509
     510/** Create the VisParameters ToolBox Widget
     511 */
     512void G4UIQt::CreateVisParametersTBWidget(
     513)
     514{
     515}
     516
     517
     518/** Create the ViewComponents ToolBox Widget
     519 */
     520void G4UIQt::CreateViewComponentsTBWidget(
     521)
     522{
     523}
     524
    358525
    359526/**   Add a new tab widget.
    360527  Create the tab if it was not done
    361528*/
    362 void G4UIQt::AddTabVisWidget(
     529void G4UIQt::AddTabWidget(
    363530 QWidget* aWidget
    364531,QString name
     
    368535{
    369536#ifdef G4DEBUG_INTERFACES_BASIC
    370   printf("G4UIQt::AddTabVisWidget %d %d\n",sizeX, sizeY);
    371 #endif
    372   if (fTabWidget != NULL) {
    373     if (!aWidget) return;
     537  printf("G4UIQt::AddTabWidget %d %d\n",sizeX, sizeY);
     538#endif
     539  if (!aWidget) return;
     540 
     541#ifdef G4DEBUG_INTERFACES_BASIC
     542  printf("G4UIQt::AddTabWidget ADD %d %d + %d %d---------------------------------------------------\n",sizeX, sizeY,sizeX-fTabWidget->width(),sizeY-fTabWidget->height());
     543#endif
     544 
     545#if QT_VERSION < 0x040000
     546  aWidget->reparent(fTabWidget,0,QPoint(0,0)); 
     547#else
     548  aWidget->setParent(fTabWidget);
     549#endif
    374550   
    375 #ifdef G4DEBUG_INTERFACES_BASIC
    376     printf("G4UIQt::AddTabVisWidget ADD %d %d + %d %d---------------------------------------------------\n",sizeX, sizeY,sizeX-visWidget->width(),sizeY-visWidget->height());
    377 #endif
    378 
    379 #if QT_VERSION < 0x040000
    380     aWidget->reparent(visWidget,0,QPoint(0,0)); 
    381 #else
    382     aWidget->setParent(visWidget);
    383 #endif
    384    
    385     fTabWidget->insertTab(fTabWidget->count()-1,aWidget,name);
    386     QHBoxLayout *mainLayout = new QHBoxLayout(visWidget);
    387     mainLayout->setMargin(0);
    388     mainLayout->setSpacing(0);   
    389     mainLayout->addWidget(fTabWidget);
    390 
    391     // Set the size
    392     //    fMainWindow->setSizeIncrement();
    393 
    394     fMainWindow->resize(fMainWindow->width()+sizeX-visWidget->width(),
    395                         fMainWindow->height()+sizeY-visWidget->height());
    396   }
     551  fTabWidget->insertTab(fTabWidget->count()-1,aWidget,name);
     552 
     553  fMainWindow->resize(fMainWindow->width()+sizeX-fTabWidget->width(),
     554                      fMainWindow->height()+sizeY-fTabWidget->height());
    397555}
    398556
     
    400558void G4UIQt::UpdateTabWidget(int tabNumber) {
    401559#ifdef G4DEBUG_INTERFACES_BASIC
    402     printf("G4UIQt::UpdateTabWidget\n");
    403 #endif
     560  printf("G4UIQt::UpdateTabWidget\n");
     561#endif
     562  if (  fTabWidget == NULL) {
     563    fTabWidget = new QTabWidget;
     564  }
     565 
    404566  QString text = fTabWidget->tabText (tabNumber);
    405567  if ( text != fCoutText) {
     
    417579    }
    418580    fTabWidget->currentWidget()->repaint();
     581  }
     582  if (fTabWidget->count() == 1) {
     583    connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
     584    //  connect(fTabWidget, SIGNAL(resizeEvent (  QResizeEvent* ) ), SLOT(ResizeTabWidget( QResizeEvent*)));
    419585  }
    420586}
     
    554720G4int G4UIQt::ReceiveG4cout (
    555721 G4String aString
    556 )
     722 )
    557723{
    558724  if (!aString) return 0;
    559   G4Qt* interactorManager = G4Qt::getInstance ();
    560   if (!interactorManager) return 0;
    561  
    562 #if QT_VERSION < 0x040000
    563   fTextArea->append(QString((char*)aString.data()).simplifyWhiteSpace());
    564   fTextArea->verticalScrollBar()->setValue(fTextArea->verticalScrollBar()->maxValue());
    565 #else
    566   fTextArea->append(QString((char*)aString.data()).trimmed());
    567   fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum());
    568 #endif
    569   fTextArea->repaint();
    570   //  interactorManager->FlushAndWaitExecution();
     725 
     726  QStringList newStr;
     727 
     728  // Add to stringList
     729#if QT_VERSION < 0x040000
     730  newStr = QStringList(QString((char*)aString.data()).simplifyWhiteSpace());
     731#else
     732  newStr = QStringList(QString((char*)aString.data()).trimmed());
     733#endif
     734  fG4cout += newStr;
     735 
     736  QStringList result = newStr.filter(fCoutFilter->text());
     737
     738  if (result.join("\n").isEmpty()) {
     739    return 0;
     740  }
     741  fCoutTBTextArea->append(result.join("\n"));
     742  fCoutTBTextArea->repaint();
     743
     744#if QT_VERSION < 0x040000
     745  fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue());
     746#else
     747  fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
     748#endif
     749
    571750  return 0;
    572751}
     
    583762{
    584763  if (!aString) return 0;
    585   G4Qt* interactorManager = G4Qt::getInstance ();
    586   if (!interactorManager) return 0;
    587 
    588 #if QT_VERSION < 0x040000
    589   QColor previousColor = fTextArea->color();
    590   fTextArea->setColor(Qt::red);
    591   fTextArea->append(QString((char*)aString.data()).simplifyWhiteSpace());
    592   fTextArea->setColor(previousColor);
    593   fTextArea->verticalScrollBar()->setValue(fTextArea->verticalScrollBar()->maxValue());
    594 #else
    595   QColor previousColor = fTextArea->textColor();
    596   fTextArea->setTextColor(Qt::red);
    597   fTextArea->append(QString((char*)aString.data()).trimmed());
    598   fTextArea->setTextColor(previousColor);
    599   fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum());
    600 #endif
    601   fTextArea->repaint();
    602   //  interactorManager->FlushAndWaitExecution();
     764
     765  QStringList newStr;
     766
     767  // Add to stringList
     768#if QT_VERSION < 0x040000
     769  newStr = QStringList(QString((char*)aString.data()).simplifyWhiteSpace());
     770#else
     771  newStr = QStringList(QString((char*)aString.data()).trimmed());
     772#endif
     773  fG4cout += newStr;
     774 
     775 QStringList result = newStr.filter(fCoutFilter->text());
     776
     777#if QT_VERSION < 0x040000
     778  QColor previousColor = fCoutTBTextArea->color();
     779  fCoutTBTextArea->setColor(Qt::red);
     780  fCoutTBTextArea->append(result.join("\n"));
     781  fCoutTBTextArea->setColor(previousColor);
     782  fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue());
     783#else
     784  QColor previousColor = fCoutTBTextArea->textColor();
     785  fCoutTBTextArea->setTextColor(Qt::red);
     786  fCoutTBTextArea->append(result.join("\n"));
     787  fCoutTBTextArea->setTextColor(previousColor);
     788  fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
     789#endif
     790  fCoutTBTextArea->repaint();
    603791  return 0;
    604792}
     
    675863
    676864
    677 
    678 
    679 /**
    680    Create the fHelpTBWidget
    681    Implementation of <b>void G4VBasicShell::TerminalHelp(G4String newCommand)</b>
    682 */
    683 void G4UIQt::CreateHelpWidget(
    684 )
    685 {
    686  
    687   QVBoxLayout *vLayout = new QVBoxLayout(fHelpTBWidget);
    688   QWidget *helpWidget = new QWidget(fHelpTBWidget);
    689   QSplitter *splitter = new QSplitter(Qt::Horizontal,fHelpTBWidget);
    690  
    691   QHBoxLayout *helpLayout = new QHBoxLayout(helpWidget);
    692 #if QT_VERSION < 0x040000
    693   helpLayout->add(new QLabel("Search :",helpWidget));
    694 #else
    695   helpLayout->addWidget(new QLabel("Search :",helpWidget));
    696 #endif
    697   helpLine = new QLineEdit(fHelpTBWidget);
    698 #if QT_VERSION < 0x040000
    699   helpLayout->add(helpLine);
    700   connect( helpLine, SIGNAL( returnPressed () ), this, SLOT( lookForHelpStringCallback() ) );
    701 #else
    702   helpLayout->addWidget(helpLine);
    703   connect( helpLine, SIGNAL( editingFinished () ), this, SLOT( lookForHelpStringCallback() ) );
    704 #endif
    705  
    706   // the help tree
    707 #if QT_VERSION < 0x040000
    708   fHelpTreeWidget = new QListView(splitter);
    709 #else
    710   fHelpTreeWidget = new QTreeWidget();
    711 #endif
    712   fHelpTreeWidget = CreateHelpTree();
    713  
    714   fHelpArea = new QTextEdit(splitter);
    715   fHelpArea->setReadOnly(true);
    716  
    717   // Set layouts
    718  
    719 #if QT_VERSION >= 0x040000
    720   if (fHelpTreeWidget)
    721     splitter->addWidget(fHelpTreeWidget);
    722   splitter->addWidget(fHelpArea);
    723 #endif
    724  
    725  
    726 #if QT_VERSION >= 0x040000
    727   vLayout->addWidget(helpWidget);
    728   vLayout->addWidget(splitter,1);
    729 #else
    730   vLayout->addWidget(helpWidget);
    731   vLayout->addWidget(splitter,1);
    732 #endif
    733  
    734   // set the splitter size
    735 #if QT_VERSION >= 0x040000
    736   QList<int> list;
    737 #else
    738   QValueList<int> list;
    739 #endif
    740   list.append( 400 );
    741   list.append( 400 );
    742   splitter->setSizes(list);
    743  
    744 #if QT_VERSION >= 0x040000
    745   fHelpTBWidget->setLayout(vLayout);
    746 #endif
    747  
    748 }
    749865
    750866
     
    11341250  if (aEvent == NULL) return false;
    11351251
    1136   if (aObj == fCommandHistoryArea) {
     1252  if (aObj == fHistoryTBTableList) {
    11371253    if (aEvent->type() == QEvent::KeyPress) {
    11381254      fCommandArea->setFocus();
     
    11481264#if QT_VERSION < 0x040000
    11491265        // count rows...
    1150         QListViewItem* tmpItem = fCommandHistoryArea->firstChild();
     1266        QListViewItem* tmpItem = fHistoryTBTableList->firstChild();
    11511267        int selection = -1;
    11521268        int index = 0;
    11531269        while (tmpItem != 0) {
    1154           if (tmpItem == fCommandHistoryArea->selectedItem()) {
     1270          if (tmpItem == fHistoryTBTableList->selectedItem()) {
    11551271            selection = index;
    11561272          }
     
    11581274          tmpItem = tmpItem->nextSibling();
    11591275        }
    1160         if (fCommandHistoryArea->childCount()) {
     1276        if (fHistoryTBTableList->childCount()) {
    11611277          if (selection == -1) {
    1162             selection = fCommandHistoryArea->childCount()-1;
     1278            selection = fHistoryTBTableList->childCount()-1;
    11631279          } else {
    11641280            if (e->key() == (Qt::Key_Down)) {
    1165               if (selection <(fCommandHistoryArea->childCount()-1))
     1281              if (selection <(fHistoryTBTableList->childCount()-1))
    11661282                selection++;
    11671283            } else if (e->key() == (Qt::Key_PageDown)) {
    1168               selection = fCommandHistoryArea->childCount()-1;
    1169 #else
    1170         int selection = fCommandHistoryArea->currentRow();
    1171         if (fCommandHistoryArea->count()) {
     1284              selection = fHistoryTBTableList->childCount()-1;
     1285#else
     1286        int selection = fHistoryTBTableList->currentRow();
     1287        if (fHistoryTBTableList->count()) {
    11721288          if (selection == -1) {
    1173             selection = fCommandHistoryArea->count()-1;
     1289            selection = fHistoryTBTableList->count()-1;
    11741290          } else {
    11751291            if (e->key() == (Qt::Key_Down)) {
    1176               if (selection <(fCommandHistoryArea->count()-1))
     1292              if (selection <(fHistoryTBTableList->count()-1))
    11771293                selection++;
    11781294            } else if (e->key() == (Qt::Key_PageDown)) {
    1179               selection = fCommandHistoryArea->count()-1;
     1295              selection = fHistoryTBTableList->count()-1;
    11801296#endif
    11811297            } else if (e->key() == (Qt::Key_Up)) {
     
    11861302            }
    11871303          }
    1188           fCommandHistoryArea->clearSelection();
    1189 #if QT_VERSION < 0x040000
    1190           QListViewItem* tmpItem = fCommandHistoryArea->firstChild();
     1304          fHistoryTBTableList->clearSelection();
     1305#if QT_VERSION < 0x040000
     1306          QListViewItem* tmpItem = fHistoryTBTableList->firstChild();
    11911307          int index = 0;
    11921308          while (tmpItem != 0) {
    11931309            if (index == selection) {
    11941310              tmpItem->setSelected(true);
    1195               fCommandHistoryArea->setCurrentItem(tmpItem);
     1311              fHistoryTBTableList->setCurrentItem(tmpItem);
    11961312          }
    11971313          index ++;
     
    12001316#else
    12011317#if QT_VERSION < 0x040202
    1202           fCommandHistoryArea->setItemSelected(fCommandHistoryArea->item(selection),true);
    1203 #else
    1204           fCommandHistoryArea->item(selection)->setSelected(true);
     1318          fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),true);
     1319#else
     1320          fHistoryTBTableList->item(selection)->setSelected(true);
    12051321#endif     
    1206           fCommandHistoryArea->setCurrentItem(fCommandHistoryArea->item(selection));
     1322          fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
    12071323#endif
    12081324        }
     
    12691385)
    12701386{
    1271   fTextArea->clear();
     1387  fCoutTBTextArea->clear();
     1388  fG4cout.clear();
    12721389}
    12731390
     
    12801397}
    12811398
     1399void G4UIQt::ExitHelp(
     1400)
     1401{
     1402}
    12821403
    12831404/**   Callback call when "click on a menu entry.<br>
     
    12911412  if (fCommandArea->text().simplifyWhiteSpace() != "") {
    12921413
    1293     QListViewItem *newItem = new QListViewItem(fCommandHistoryArea);
     1414    QListViewItem *newItem = new QListViewItem(fHistoryTBTableList);
    12941415    newItem->setText(0,fCommandArea->text());
    1295     fCommandHistoryArea->insertItem(newItem);
     1416    fHistoryTBTableList->insertItem(newItem);
    12961417    // now we have to arrange
    1297     QListViewItem *temp= fCommandHistoryArea->lastItem();
    1298     for (int i=0; i<fCommandHistoryArea->childCount()-1;i++) {
    1299       fCommandHistoryArea->takeItem(temp);
    1300       fCommandHistoryArea->insertItem(temp);
    1301       temp= fCommandHistoryArea->lastItem();
     1418    QListViewItem *temp= fHistoryTBTableList->lastItem();
     1419    for (int i=0; i<fHistoryTBTableList->childCount()-1;i++) {
     1420      fHistoryTBTableList->takeItem(temp);
     1421      fHistoryTBTableList->insertItem(temp);
     1422      temp= fHistoryTBTableList->lastItem();
    13021423    }
    13031424#else
    13041425  G4String command (fCommandArea->text().toStdString().c_str());
    13051426  if (fCommandArea->text().trimmed() != "") {
    1306     fCommandHistoryArea->addItem(fCommandArea->text());
    1307 #endif
    1308     fCommandHistoryArea->clearSelection();
    1309     fCommandHistoryArea->setCurrentItem(NULL);
     1427    fHistoryTBTableList->addItem(fCommandArea->text());
     1428#endif
     1429    fHistoryTBTableList->clearSelection();
     1430    fHistoryTBTableList->setCurrentItem(NULL);
    13101431    fCommandArea->setText("");
    13111432
     
    14621583  QListWidgetItem* item =  NULL;
    14631584#endif
    1464   if (!fCommandHistoryArea)
     1585  if (!fHistoryTBTableList)
    14651586    return ;
    14661587
    14671588 
    14681589#if QT_VERSION < 0x040000
    1469   item =fCommandHistoryArea->selectedItem();
    1470 #else
    1471   QList<QListWidgetItem *> list =fCommandHistoryArea->selectedItems();
     1590  item =fHistoryTBTableList->selectedItem();
     1591#else
     1592  QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
    14721593  if (list.isEmpty())
    14731594    return;
     
    14861607}
    14871608
     1609
     1610void G4UIQt::CoutFilterCallback(
     1611const QString & text) {
     1612
     1613#ifdef G4DEBUG_INTERFACES_BASIC
     1614  printf("G4UIQt::CoutFilterCallback : %s\n",text.toStdString().c_str());
     1615#endif
     1616 
     1617  QStringList result = fG4cout.filter(text);
     1618
     1619  fCoutTBTextArea->setText(result.join("\n"));
     1620  fCoutTBTextArea->repaint();
     1621#if QT_VERSION < 0x040000
     1622  fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue());
     1623#else
     1624  fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
     1625#endif
     1626#ifdef G4DEBUG_INTERFACES_BASIC
     1627  printf("G4UIQt::CoutFilterCallback textSize:%d resSize:%d \n",fG4cout.join("").size(),result.join("").size());
     1628#endif
     1629
     1630 }
    14881631
    14891632/**   Callback called when user give a new string to look for<br>
  • trunk/source/interfaces/common/include/G4Qt.hh

    r1180 r1224  
    6060  void FlushAndWaitExecution();
    6161  virtual ~G4Qt();                     
    62   bool AddTabVisWidget(QWidget*,QString,int,int);
     62  bool AddTabWidget(QWidget*,QString,int,int);
    6363  void SetG4UI(G4UIQt*);
    6464
  • trunk/source/interfaces/common/src/G4Qt.cc

    r1179 r1224  
    130130      qApp = new QApplication (*p_argn, args);
    131131#else
     132#ifdef G4DEBUG_INTERFACES_COMMON
     133    printf("G4Qt::G4Qt QAppl \n");
     134#endif
    132135      new QApplication (*p_argn, args);
    133136#endif
     
    138141        QtInited  = TRUE;
    139142        if (a_argn != 0) {
     143#ifdef G4DEBUG_INTERFACES_COMMON
     144        printf("G4Qt::G4Qt SetMainInteractor\n");
     145#endif
    140146          SetMainInteractor (qApp);
    141147        }
     
    218224
    219225/***************************************************************************/
    220 bool G4Qt::AddTabVisWidget (
     226bool G4Qt::AddTabWidget (
    221227 QWidget * vis
    222228,QString name
     
    228234{
    229235  if (fG4UI != NULL) {
    230     fG4UI->AddTabVisWidget(vis,name,sizeX,sizeY);
     236    fG4UI->AddTabWidget(vis,name,sizeX,sizeY);
    231237    return true;
    232238  }
Note: See TracChangeset for help on using the changeset viewer.