Ignore:
Timestamp:
Sep 18, 2007, 6:39:37 PM (18 years ago)
Author:
garnier
Message:

r599@mac-90108: laurentgarnier | 2007-09-18 18:43:19 +0200
correction du ticket #72 et la suppresion de la fenetre OpenGL entraine desormais un message d erreur lors du prochain BeamOn

Location:
trunk/geant4/visualization/OpenGL/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r571 r579  
    6868  //   ::wglMakeCurrent(fHDC,fHGLRC);
    6969  //  fWindow->makeCurrent();
    70   G4OpenGLViewer::SetView (); 
     70  G4OpenGLViewer::SetView ();
    7171  printf("G4OpenGLQtViewer::SetView --------------------\n");
    7272}
     
    8585  printf("G4OpenGLQtViewer::ShowView  +++++++++++++++++++++\n");
    8686  glFlush ();
    87   GLWindow->activateWindow();
    88   printf("G4OpenGLQtViewer::ShowView -----------------------\n");
    89 
     87  if (!GLWindow) {
     88    G4cerr << "Visualization window not defined, please choose one before" << G4endl;
     89  } else {
     90    GLWindow->activateWindow();
     91    printf("G4OpenGLQtViewer::ShowView -----------------------\n");
     92  }
    9093  //   // Empty the Windows message queue :
    9194  //   MSG event;
     
    132135    foreach (QWidget *widget, QApplication::allWidgets()) {
    133136      if ((found== false) && (widget->inherits("QMainWindow"))) {
    134         GLWindow = new QDialog(widget);
     137        printf("G4OpenGLQtViewer::CreateMainWindow case Qapp exist\n");
     138        GLWindow = new QDialog(widget,Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
    135139        found = true;
    136140      }
    137141    }
    138142    if (found==false) {
     143      printf("G4OpenGLQtViewer::CreateMainWindow case Qapp exist, but not found\n");
    139144      GLWindow = new QDialog();
    140145    }
    141146  } else {
     147    printf("G4OpenGLQtViewer::CreateMainWindow case Qapp exist\n");
    142148    GLWindow = new QDialog();
    143149  }
     
    152158  GLWindow->show();
    153159 
     160  // delete the pointer if close this
     161  //  GLWindow->setAttribute(Qt::WA_DeleteOnClose);
     162
     163  QObject ::connect(GLWindow,
     164                    SIGNAL(rejected()),
     165                    this,
     166                    SLOT(dialogClosed()));
     167
    154168  WinSize_x = 400;
    155169  WinSize_y = 400;
     
    166180
    167181}
     182
     183/**  Close the dialog and set the pointer to NULL
     184 */
     185void G4OpenGLQtViewer::dialogClosed() {
     186  GLWindow = NULL;
     187}
     188
    168189
    169190//////////////////////////////////////////////////////////////////////////////
     
    187208{
    188209  printf("G4OpenGLQtViewer::~G4OpenGLQtViewer \n");
    189   delete fContextMenu;   
     210  delete fContextMenu;
    190211}
    191212
     
    357378void G4OpenGLQtViewer::manageContextMenuEvent(QContextMenuEvent *e)
    358379{
    359   if (!GLWindow) return;
     380  if (!GLWindow) {
     381    G4cerr << "Visualization window not defined, please choose one before" << G4endl;
     382  } else {
    360383 
    361   if (!fContextMenu)
    362     createPopupMenu();
    363 
    364   // launch menu
    365   if ( fContextMenu ) {
    366     fContextMenu->exec( e->globalPos() );
    367     //    delete fContextMenu;
     384    if (!fContextMenu)
     385      createPopupMenu();
     386   
     387    // launch menu
     388    if ( fContextMenu ) {
     389      fContextMenu->exec( e->globalPos() );
     390      //    delete fContextMenu;
     391    }
    368392  }
    369393  e->accept();
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc

    r565 r579  
    5555G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
    5656   printf("GLWidget::~GLWidget \n");
    57      makeCurrent();
     57   makeCurrent();
     58   // this is connect to the Dialog for deleting it properly
     59   // when close event.
     60   //   ((QDialog*)window())->reject();
    5861   printf("GLWidget::~GLWidget END\n");
    5962}
     
    104107
    105108  printf("G4OpenGLStoredQtViewer::DrawView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
    106 
     109  printf("G4OpenGLStoredQtViewer::DrawView Dialog adress : %d\n",GLWindow);
    107110   G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
    108111
     
    116119   // if necessary...
    117120   if (!fNeedKernelVisit)
    118      printf("***************************  CASE 0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
    119121
    120122   if (!fNeedKernelVisit) KernelVisitDecision ();
    121    printf("***************************  kernelVisit:%d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",fNeedKernelVisit);
    122123   
    123124   G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
     
    209210 {
    210211   if (!readyToPaint) {
    211      printf("\n\nG4OpenGLStoredQtViewer::paintGL ============  Not ready %d\n",readyToPaint);
     212     printf("G4OpenGLStoredQtViewer::paintGL ============  Not ready %d\n",readyToPaint);
    212213     readyToPaint= true;
    213214     return;
     
    218219   if ( !hasToRepaint) {
    219220     if (((WinSize_x == (G4int)width())) &&(WinSize_y == (G4int) height())) {
    220        printf("\n\nG4OpenGLStoredQtViewer::paintGL ============  Dont repaint\n");
     221       printf("G4OpenGLStoredQtViewer::paintGL ============  Dont repaint\n");
    221222       return;
    222223     }
    223224   }
    224225   nbPaint++;
    225    printf("\n\nG4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV %d ready %d\n",nbPaint,readyToPaint);
     226   printf("G4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV %d ready %d\n",nbPaint,readyToPaint);
    226227   WinSize_x = (G4int) width();
    227228   WinSize_y = (G4int) height();
     
    241242   hasToRepaint =false;
    242243
    243    printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n\n\n",nbPaint,readyToPaint);
     244   printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n",nbPaint,readyToPaint);
    244245 }
    245246
Note: See TracChangeset for help on using the changeset viewer.