Index: /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
===================================================================
--- /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 674)
+++ /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 675)
@@ -1355,5 +1355,6 @@
   glRenderMode (GL_FEEDBACK);
   
-  glViewport (0, 0, aWidth,aHeight);
+  int side = qMin(aWidth, aHeight);
+  glViewport((aWidth - side) / 2, (aHeight - side) / 2, side, side);
   DrawView();
 
Index: /trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc
===================================================================
--- /trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc	(revision 674)
+++ /trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc	(revision 675)
@@ -52,5 +52,5 @@
  G4OpenGLQtViewer (sceneHandler),
  G4OpenGLStoredViewer (sceneHandler),
- QGLWidget()                      // FIXME : gerer le pb du parent !
+ QGLWidget(QGLFormat(QGL::SampleBuffers))             // FIXME : gerer le pb du parent !
  {
    zoomAction = false;
@@ -86,5 +86,5 @@
   printf("G4OpenGLStoredQtViewer::Initialise () 3\n");
 #endif
-  CreateFontLists ();  // FIXME Does nothing!
+  //  CreateFontLists ();  // FIXME Does nothing!
   
 #ifdef GEANT4_QT_DEBUG
@@ -101,4 +101,7 @@
   ShowView();
   FinishView();
+#ifdef GEANT4_QT_DEBUG
+  printf("G4OpenGLStoredQtViewer::Initialise () 4\n");
+#endif
 }
 
@@ -128,5 +131,4 @@
 
 void G4OpenGLStoredQtViewer::DrawView () {
-
 #ifdef GEANT4_QT_DEBUG
   printf("G4OpenGLStoredQtViewer::DrawView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
@@ -257,48 +259,77 @@
  {
    if (zoomAction) {
+     //     glEnable (GL_DEPTH_TEST);
+     //     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+     setupViewport(width(),height());     
+     SetView();
+     ClearView (); //ok, put the background correct
+
      QPainter painter;
      painter.begin(this);
+     //      painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);
+     //      painter.setCompositionMode(QPainter::CompositionMode_SourceOver); // diagonale en pointillé
+     //     painter.setCompositionMode(QPainter::CompositionMode_DestinationOver); // blanc
+     //     painter.setCompositionMode(QPainter::CompositionMode_Clear);// diagonale noire
+     //     painter.setCompositionMode(QPainter::CompositionMode_Source); // diagonale en pointillé
+     //     painter.setCompositionMode(QPainter::CompositionMode_Destination); // blanc
+     //     painter.setCompositionMode(QPainter::CompositionMode_SourceIn); // blanc ?
+     //     painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); // blanc
+     //     painter.setCompositionMode(QPainter::CompositionMode_SourceOut); // digonale noire
+     //     painter.setCompositionMode(QPainter::CompositionMode_DestinationOut); // diagonale noire
+     //     painter.setCompositionMode(QPainter::CompositionMode_SourceAtop); // diagonale noire
+     //     painter.setCompositionMode(QPainter::CompositionMode_DestinationAtop); // blanc
+     //     painter.setCompositionMode(QPainter::CompositionMode_Xor); // diagonale noire
      //     painter.setRenderHint(QPainter::Antialiasing);
-     QColor bg = QColor(glBufferImage.pixel(0,0));
-     printf("%d+%d+%d+%d %d+%d+%d+%d",bg.red(),bg.green(),bg.blue(),bg.alpha(),qAlpha(glBufferImage.pixel(0,0)),qRed(glBufferImage.pixel(0,0)),qGreen(glBufferImage.pixel(0,0)),qBlue(glBufferImage.pixel(0,0)));
-     painter.setBackground(QBrush(bg));
-     //     painter.drawRect(10,10,50,80);
-//      QImage test = grabFrameBuffer().copy();
-//      painter.drawImage(0, 0,test);
+     //         painter.setBackgroundMode(Qt::OpaqueMode);
+          painter.drawImage(0, 0, glBufferImage);
+     
+     //     painter.setRenderHint(QPainter::Antialiasing);
+     //      QColor bg = QColor(glBufferImage.pixel(0,0));
+     //      printf("%d+%d+%d+%d %d+%d+%d+%d",bg.red(),bg.green(),bg.blue(),bg.alpha(),qAlpha(glBufferImage.pixel(0,0)),qRed(glBufferImage.pixel(0,0)),qGreen(glBufferImage.pixel(0,0)),qBlue(glBufferImage.pixel(0,0)));
+     //      painter.setBackground(QBrush(bg));
+     //      //     painter.drawRect(10,10,50,80);
+     // //      QImage test = grabFrameBuffer().copy();
+     // //      painter.drawImage(0, 0,test);
      for (int ay=0;ay<glBufferImage.height();ay++) {
        for (int ax=0;ax<glBufferImage.width();ax++) {
-         if(QColor(glBufferImage.pixel(ax,ay)) != bg) {
-//            painter.setPen(QColor(glBufferImage.pixel(ax,ay)));
-//            painter.drawPoint(ax,glBufferImage.height()-ay);
-         } else {
-           printf("o");
-         }
+         //         if(QColor(glBufferImage.pixel(ax,ay)) != bg) {
+         //.           painter.setPen(QColor(glBufferImage.pixel(ax,ay)));
+         //.           painter.drawPoint(ax,ay);
+           //          } else {
+           //            printf("o");
+           //          }
          //          printf("%d+%d+%d+%d ",QColor(glBufferImage.pixel(ax,ay)).red(),QColor(glBufferImage.pixel(ax,ay)).green(),QColor(glBufferImage.pixel(ax,ay)).blue(),QColor(glBufferImage.pixel(ax,ay)).alpha());
-//          if (glBufferImage.pixel(ax,ay) == 255) {
-//            test.setPixel(ax,ay,1);
-//          } else {
-//            test.setPixel(ax,ay,0);
-//          }
+         //          if (glBufferImage.pixel(ax,ay) == 255) {
+         //            test.setPixel(ax,ay,1);
+         //          } else {
+         //            test.setPixel(ax,ay,0);
+         //          }
        }
        //       printf("\n");
      }
-//      for (int ay=0;ay<test.height();ay++) {
-//        for (int ax=0;ax<test.width();ax++) {
-//          if (test.pixel(ax,ay) == 1) {
-//            printf(".");
-//          } else if (!test.pixel(ax,ay)) {
-//            printf("X");
-//          } else {
-//            printf("%d",test.pixel(ax,ay));
-//          }
-//        }
-//        printf("\n");
-//      }
+     // //      for (int ay=0;ay<test.height();ay++) {
+     // //        for (int ax=0;ax<test.width();ax++) {
+     // //          if (test.pixel(ax,ay) == 1) {
+     // //            printf(".");
+     // //          } else if (!test.pixel(ax,ay)) {
+     // //            printf("X");
+     // //          } else {
+     // //            printf("%d",test.pixel(ax,ay));
+     // //          }
+     // //        }
+     // //        printf("\n");
+     // //      }
      
      //     painter.drawImage(0, 0, glBufferImage);
      //     painter.drawImage(0, 0, test,0,0,-1,-1,Qt::ColorOnly);
      
-     printf("paint event zoom \n");
-     //     painter.drawRect(beginZoom.x(),beginZoom.y(),endZoom.x()-beginZoom.x(),endZoom.y()-beginZoom.y());
+#ifdef GEANT4_QT_DEBUG
+       printf("G4OpenGLStoredQtViewer::paintGL ============  zoom event\n");
+#endif
+       painter.setBrush(Qt::NoBrush);
+       painter.setPen(Qt::red);
+       painter.setPen(Qt::DashLine);
+       painter.drawRect(beginZoom.x(),beginZoom.y(),endZoom.x()-beginZoom.x(),endZoom.y()-beginZoom.y());
      painter.end();
    } else {
@@ -346,8 +377,8 @@
      hasToRepaint =false;
      
+   }
 #ifdef GEANT4_QT_DEBUG
      printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n",nbPaint,readyToPaint);
 #endif
-   }
  }
 
@@ -368,8 +399,8 @@
   setMouseTracking(true);
   zoomAction=true;
-  makeCurrent();
-  glBufferImage = QImage( width(), height(), QImage::Format_ARGB32_Premultiplied );
-  glReadPixels( 0, 0, width(), height(), GL_RGBA, GL_UNSIGNED_BYTE, glBufferImage.bits() );
-  //  glBufferImage = grabFrameBuffer(false).convertToFormat(QImage::Format_RGB16); //QImage::Format_ARGB32_Premultiplied
+  //  makeCurrent();
+//   glBufferImage = QImage( width(), height(), QImage::Format_ARGB32_Premultiplied );
+//   glReadPixels( 0, 0, width(), height(), GL_RGBA, GL_UNSIGNED_BYTE, glBufferImage.bits() );
+  glBufferImage = grabFrameBuffer().convertToFormat(QImage::Format_ARGB32_Premultiplied);
   
 #ifdef GEANT4_QT_DEBUG
