Changeset 1135


Ignore:
Timestamp:
Oct 21, 2009, 10:14:58 AM (15 years ago)
Author:
garnier
Message:

preparation to integrate Vis in UI for Qt

Location:
trunk/source/visualization/OpenGL
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/OpenGL/History

    r1133 r1135  
    1 $Id: History,v 1.154 2009/10/15 15:33:30 lgarnier Exp $
     1$Id: History,v 1.155 2009/10/21 08:14:44 lgarnier Exp $
    22-------------------------------------------------------------------
    33
     
    1717     * Reverse chronological order (last date on top), please *
    1818     ----------------------------------------------------------
     19
     2021 October 2009 Laurent Garnier
     21 -  G4OpenGLQtViewer : Prepare to attach viewer In UI
     22
    192315 October 2009 Laurent Garnier
    2024 - G4OpenGLViewer.cc : Fix a problem with printing. On mac OSX version
  • trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh

    r1132 r1135  
    2525//
    2626//
    27 // $Id: G4OpenGLQtViewer.hh,v 1.19 2009/10/14 15:04:09 lgarnier Exp $
     27// $Id: G4OpenGLQtViewer.hh,v 1.20 2009/10/21 08:14:44 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    150150  void setRecordingInfos(QString);
    151151  QString getProcessErrorMsg();
    152 
     152  QWidget* getParentWidget();
    153153
    154154#if QT_VERSION < 0x040000
  • trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r1131 r1135  
    2525//
    2626//
    27 // $Id: G4OpenGLQtViewer.cc,v 1.44 2009/10/14 14:35:07 lgarnier Exp $
     27// $Id: G4OpenGLQtViewer.cc,v 1.45 2009/10/21 08:14:44 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    107107  if(fWindow) return; //Done.
    108108
    109   // launch Qt if not
    110   G4Qt* interactorManager = G4Qt::getInstance ();
    111   //  G4UImanager* UI = G4UImanager::GetUIpointer();
    112 
    113109  fWindow = glWidget ;
    114110  //  fWindow->makeCurrent();
    115111
    116   // create window
    117   if (((QApplication*)interactorManager->GetMainInteractor())) {
    118     // look for the main window
    119     bool found = false;
    120 #if QT_VERSION < 0x040000
    121     // theses lines does nothing exept this one "GLWindow = new QDialog(0..."
    122     // but if I comment them, it doesn't work...
    123     QWidgetList  *list = QApplication::allWidgets();
    124     QWidgetListIt it( *list );         // iterate over the widgets
    125     QWidget * widget;
    126     while ( (widget=it.current()) != 0 ) {  // for each widget...
    127       ++it;
    128       if ((found== false) && (widget->inherits("QMainWindow"))) {
    129         fGLWindow = new QDialog(0,0,FALSE,Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WStyle_MinMax );
    130         found = true;
    131       }
    132     }
    133     delete list;                      // delete the list, not the widgets
    134 #else
    135     foreach (QWidget *widget, QApplication::allWidgets()) {
    136       if ((found== false) && (widget->inherits("QMainWindow"))) {
    137         fGLWindow = new QDialog(0,Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
    138         found = true;
    139       }
    140     }
    141 #endif
    142 
    143 #if QT_VERSION < 0x040000
    144     glWidget->reparent(fGLWindow,0,QPoint(0,0)); 
    145 #else
    146     glWidget->setParent(fGLWindow); 
    147 #endif
    148 
    149     if (found==false) {
    150 #ifdef G4DEBUG_VIS_OGL
    151       printf("G4OpenGLQtViewer::CreateMainWindow case Qapp exist, but not found\n");
    152 #endif
    153       fGLWindow = new QDialog();
    154     }
    155   } else {
    156 #ifdef G4DEBUG_VIS_OGL
    157     printf("G4OpenGLQtViewer::CreateMainWindow case Qapp exist\n");
    158 #endif
    159     fGLWindow = new QDialog();
     112  QWidget *myParent = getParentWidget();
     113  if (myParent != NULL) {
     114#if QT_VERSION < 0x040000
     115    glWidget->reparent(myParent,0,QPoint(0,0)); 
     116#else
     117    glWidget->setParent(myParent); 
     118#endif
    160119  }
    161120
     
    25472506
    25482507
    2549 void G4OpenGLQtViewer::drawText(
    2550  const char * str
    2551 ,int x
    2552 ,int y
    2553 ,int z
    2554 ,int size ) {
    2555 
    2556 #ifdef G4DEBUG_VIS_OGL
    2557   printf ("G4OpenGLStoredQtViewer::drawText-position %d,%d,%d-----------------------------------------\n",x,y,z);
    2558 #endif 
    2559 
    2560   QFont f1 = QFont("Courrier", size, QFont::Bold);
    2561   f1.setPointSizeF(20);
    2562 
    2563   // FIXME : Interesting border effect : resizing world resize detector
    2564   // but not traces !
    2565   glColor3d (0.123456,0.1234560,0.123456);
    2566   fWindow->renderText (x,y,z,str,f1);
    2567   glColor3d (0.321,0.321,0.321);
    2568 }
    2569 
    2570 
    25712508// FIXME : does not work on Qt3
    25722509void G4OpenGLQtViewer::processEncodeStdout()
     
    26632600}
    26642601
     2602
     2603
     2604
     2605QWidget *G4OpenGLQtViewer::getParentWidget()
     2606{
     2607  // launch Qt if not
     2608  G4Qt* interactorManager = G4Qt::getInstance ();
     2609  //  G4UImanager* UI = G4UImanager::GetUIpointer();
     2610 
     2611  bool found = false;
     2612 
     2613  // create window
     2614  if (((QApplication*)interactorManager->GetMainInteractor())) {
     2615    // look for the main window
     2616#if QT_VERSION < 0x040000
     2617    // theses lines does nothing exept this one "GLWindow = new QDialog(0..."
     2618    // but if I comment them, it doesn't work...
     2619    QWidgetList  *list = QApplication::allWidgets();
     2620    QWidgetListIt it( *list );         // iterate over the widgets
     2621    QWidget * widget;
     2622    while ( (widget=it.current()) != 0 ) {  // for each widget...
     2623      ++it;
     2624      if ((found== false) && (widget->inherits("QMainWindow"))) {
     2625        fGLWindow = new QDialog(0,0,FALSE,Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WStyle_MinMax );
     2626        found = true;
     2627      }
     2628    }
     2629    delete list;                      // delete the list, not the widgets
     2630#else
     2631    foreach (QWidget *widget, QApplication::allWidgets()) {
     2632      if ((found== false) && (widget->inherits("QMainWindow"))) {
     2633        fGLWindow = new QDialog(widget,Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
     2634        found = true;
     2635      }
     2636    }
     2637#endif
     2638   
     2639    if (found==false) {
     2640#ifdef G4DEBUG_VIS_OGL
     2641      printf("G4OpenGLQtViewer::CreateMainWindow case Qapp exist, but not found\n");
     2642#endif
     2643      fGLWindow = new QDialog();
     2644    }
     2645  } else {
     2646#ifdef G4DEBUG_VIS_OGL
     2647    printf("G4OpenGLQtViewer::CreateMainWindow case Qapp exist\n");
     2648#endif
     2649    fGLWindow = new QDialog();
     2650  }
     2651  if (found) {
     2652    return fGLWindow;
     2653  } else {
     2654    return NULL;
     2655  }
     2656}
     2657
    26652658/*
    26662659 
Note: See TracChangeset for help on using the changeset viewer.