Changeset 1236 for trunk/source


Ignore:
Timestamp:
Feb 8, 2010, 5:19:32 PM (14 years ago)
Author:
garnier
Message:

debug mode

Location:
trunk/source/interfaces/basic
Files:
2 edited

Legend:

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

    r1232 r1236  
    4141#include <qmap.h>
    4242#include <qstringlist.h>
     43#include <qtabwidget.h>
    4344
    4445class QMainWindow;
     
    5556class QTextEdit;
    5657class QLabel;
    57 class QTabWidget;
    5858class QResizeEvent;
    5959class QToolBox;
    6060class QStringList;
     61class QSplitter;
    6162
    6263// Class description :
     
    7980//
    8081// Class description - end :
     82
     83class G4QTabWidget : public QTabWidget {
     84public :
     85  G4QTabWidget();
     86  G4QTabWidget(QSplitter*&);
     87  void paintEvent  ( QPaintEvent * event );
     88  inline void setTabSelected() { tabSelected = true; };
     89  inline void unselectTab() { tabSelected = false; };
     90  inline bool isTabSelected() { return tabSelected; };
     91  bool tabSelected;
     92};
    8193
    8294class G4UIQt : public QObject, public G4VBasicShell, public G4VInteractiveSession {
     
    174186  QWidget* fViewComponentsTBWidget;
    175187  QLineEdit* helpLine;
    176   QTabWidget* fTabWidget;
     188  G4QTabWidget* fTabWidget;
    177189  QString fCoutText;
    178190
    179191signals :
    180   void myClicked(const QString &text);
     192  void refreshTab(const QString &text);
    181193
    182194private slots :
     
    193205  void ResizeTabWidget( QResizeEvent* );
    194206  void CoutFilterCallback(const QString&);
     207  void RefreshTabCallback (const QString&);
     208
    195209};
    196210
    197 #endif
    198 
    199 #endif
    200 
     211
     212#endif
     213
     214#endif
     215
  • trunk/source/interfaces/basic/src/G4UIQt.cc

    r1232 r1236  
    171171
    172172  // Add a empty tabwidget
    173   fTabWidget = new QTabWidget(myVSplitter);
     173  fTabWidget = new G4QTabWidget(myVSplitter);
     174#if QT_VERSION >= 0x040500
     175  fTabWidget->setTabsClosable (true);
     176#endif
     177
     178#if QT_VERSION >= 0x040200
     179  fTabWidget->setUsesScrollButtons (true);
     180#endif
    174181
    175182  QWidget* commandLineWidget = new QWidget(mainWidget);
     
    280287
    281288  connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
    282 
     289  connect(this, SIGNAL(refreshTab(const QString &)), SLOT(RefreshTabCallback(const QString&)));
    283290  if(UI!=NULL) UI->SetCoutDestination(this);  // TO KEEP
    284291
     
    521528  // then we have to force them on order to check the size
    522529
    523   fTabWidget->insertTab(fTabWidget->count()-1,aWidget,name);
    524  
     530  fTabWidget->insertTab(fTabWidget->count(),aWidget,name);
     531
     532  if (fTabWidget->count() == 1) {
     533    connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
     534    //  connect(fTabWidget, SIGNAL(resizeEvent (  QResizeEvent* ) ), SLOT(ResizeTabWidget( QResizeEvent*)));
     535  }
    525536  // Set visible
    526537#if QT_VERSION >= 0x040000
     
    574585#endif
    575586  if (  fTabWidget == NULL) {
    576     fTabWidget = new QTabWidget;
    577   }
    578  
    579   QString text = fTabWidget->tabText (tabNumber);
    580   if ( text != fCoutText) {
    581 
    582     // Then we have to do /vis/viewer/select on the selelected tab
    583     // And resize selected tab
    584     fTabWidget->currentWidget()->resize(fTabWidget->currentWidget()->width(),fTabWidget->currentWidget()->height());
    585 
    586     QString paramSelect = QString("/vis/viewer/select ")+text;
    587     QString paramFlush = QString("/vis/viewer/flush ")+text;
    588     G4UImanager* UI = G4UImanager::GetUIpointer();
    589     if(UI!=NULL)  {
    590       UI->ApplyCommand(paramSelect.toStdString().c_str());
    591       UI->ApplyCommand(paramFlush.toStdString().c_str());
    592     }
    593     fTabWidget->currentWidget()->repaint();
    594   }
    595   if (fTabWidget->count() == 1) {
    596     connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
    597     //  connect(fTabWidget, SIGNAL(resizeEvent (  QResizeEvent* ) ), SLOT(ResizeTabWidget( QResizeEvent*)));
    598   }
     587    fTabWidget = new G4QTabWidget;
     588  }
     589 
     590 
     591  //Must be BEFORE repaint of OGL
     592#ifdef G4DEBUG_INTERFACES_BASIC
     593  printf("G4UIQt::UpdateTabWidget CALL REPAINT tabGL\n");
     594#endif
     595//   QPaintEvent e(fTabWidget->currentWidget()->rect());
     596//   QApplication::sendEvent(fTabWidget->currentWidget(), &e);
     597
     598#ifdef G4DEBUG_INTERFACES_BASIC
     599  printf("G4UIQt::UpdateTabWidget CALL REPAINT tabWidget\n");
     600#endif
     601//   QPaintEvent e2(fTabWidget->rect());
     602//   QApplication::postEvent(fTabWidget, &e2);
     603
     604  // Emit signal in order to refresh glView after all paint tab
     605  // signals have been send
     606//  emit(refreshTab(fTabWidget->tabText (fTabWidget->currentIndex())));
     607  //  fTabWidget->repaint();
     608#ifdef G4DEBUG_INTERFACES_BASIC
     609  printf("G4UIQt::UpdateTabWidget CALL REPAINT END\n");
     610#endif
     611
     612//   QString text = fTabWidget->tabText (fTabWidget->currentIndex());
     613//   QString paramSelect = QString("/vis/viewer/select ")+text;
     614//   //  QString paramFlush = QString("/vis/viewer/flush ")+text;
     615//   G4UImanager* UI = G4UImanager::GetUIpointer();
     616//   if(UI!=NULL)  {
     617//     UI->ApplyCommand(paramSelect.toStdString().c_str());
     618//     //    UI->ApplyCommand(paramFlush.toStdString().c_str());
     619//   }
     620 
     621
     622
     623  fTabWidget->setTabSelected();
     624  // Then we have to do /vis/viewer/select on the selelected tab
     625  // And resize selected tab
     626  //  fTabWidget->currentWidget()->resize(fTabWidget->currentWidget()->width(),fTabWidget->currentWidget()->height());
     627
     628  //  ((QGLWIdget*)fTabWidget->currentWidget())->makeCurrent();
     629 
     630// #ifdef G4DEBUG_INTERFACES_BASIC
     631//   printf("G4UIQt::UpdateTabWidget REPAINT END\n");
     632// #endif
     633  //  QCoreApplication::flush ();
     634#ifdef G4DEBUG_INTERFACES_BASIC
     635  printf("G4UIQt::UpdateTabWidget END\n");
     636#endif
    599637}
    600638
     
    18331871}
    18341872
    1835 #endif
     1873 
     1874
     1875void G4UIQt::RefreshTabCallback (
     1876 const QString &text
     1877)
     1878{
     1879#ifdef G4DEBUG_INTERFACES_BASIC
     1880      printf("G4UIQt::RefreshTabCallback   BEGIN +++++++++++++++++++++\n");
     1881#endif
     1882  QString paramSelect = QString("/vis/viewer/select ")+text;
     1883  //  QString paramFlush = QString("/vis/viewer/flush ")+text;
     1884  G4UImanager* UI = G4UImanager::GetUIpointer();
     1885  if(UI!=NULL)  {
     1886    UI->ApplyCommand(paramSelect.toStdString().c_str());
     1887    //    UI->ApplyCommand(paramFlush.toStdString().c_str());
     1888  }
     1889#ifdef G4DEBUG_INTERFACES_BASIC
     1890      printf("G4UIQt::RefreshTabCallback   BEGIN -+-+-+-+-+-+-+-+-+-+-+\n");
     1891#endif
     1892}
     1893
     1894G4QTabWidget::G4QTabWidget(
     1895QSplitter*& split
     1896):QTabWidget(split)
     1897{
     1898}
     1899
     1900G4QTabWidget::G4QTabWidget(
     1901):QTabWidget()
     1902{
     1903}
     1904
     1905
     1906
     1907void G4QTabWidget::paintEvent(
     1908QPaintEvent * event
     1909)
     1910{
     1911  QCoreApplication::sendPostedEvents () ;
     1912
     1913  if (currentWidget()) {
     1914#ifdef G4DEBUG_INTERFACES_BASIC
     1915    printf("G4QTabWidget::paintEvent repaint type : %d -- rect %d %d  region:%d %d page : %d %d  ________________________ for = %d i= %d w: %d\n", event->type(),event->rect().height(),event->rect().width(),event->region().boundingRect().width(),event->region().boundingRect().height(),currentWidget()->width(),currentWidget()->height(),this,currentIndex(),currentWidget());
     1916#endif
     1917   
     1918    //    QTabWidget::paintEvent(event);
     1919
     1920    if ( isTabSelected()) {
     1921#ifdef G4DEBUG_INTERFACES_BASIC
     1922      printf("G4QTabWidget::paintEvent OK\n");
     1923#endif
     1924      QString text = tabText (currentIndex());
     1925      QString paramSelect = QString("/vis/viewer/select ")+text;
     1926      //  QString paramFlush = QString("/vis/viewer/flush ")+text;
     1927      G4UImanager* UI = G4UImanager::GetUIpointer();
     1928      if(UI!=NULL)  {
     1929        UI->ApplyCommand(paramSelect.toStdString().c_str());
     1930        //    UI->ApplyCommand(paramFlush.toStdString().c_str());
     1931      }
     1932
     1933      repaint();
     1934      unselectTab();
     1935    }
     1936  }
     1937}
     1938
     1939#endif
Note: See TracChangeset for help on using the changeset viewer.