Index: /trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
===================================================================
--- /trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh	(revision 677)
+++ /trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh	(revision 678)
@@ -103,7 +103,11 @@
   QMenu *fContextMenu;
 #endif
-  bool fMouseAction; // 1: rotate 0:move
+  enum mouseActions {ROTATE, MOVE, ZOOM}; 
+  mouseActions fMouseAction; // 1: rotate 0:move
   QPoint lastPos;
 #if QT_VERSION < 0x040000
+  QPopupMenu *fMouseRotate;
+  QPopupMenu *fMouseMove;
+  QPopupMenu *fMouseZoom;
   QPopupMenu *fDrawingWireframe;
   QPopupMenu *fDrawingLineRemoval;
@@ -111,4 +115,7 @@
   QPopupMenu *fDrawingLineSurfaceRemoval;
 #else
+  QAction *fMouseRotate;
+  QAction *fMouseMove;
+  QAction *fMouseZoom;
   QAction *fDrawingWireframe;
   QAction *fDrawingLineRemoval;
@@ -118,4 +125,7 @@
 
 private slots :
+  void actionMouseRotate();
+  void actionMouseMove();
+  void actionMouseZoom();
   void actionDrawingWireframe();
   void actionDrawingLineRemoval();
@@ -127,5 +137,5 @@
 
   void toggleDrawingAction(int);
-  void toggleMouseAction(bool);
+  void toggleMouseAction(mouseActions);
   void toggleRepresentation(bool);
   void toggleBackground(bool);
Index: /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
===================================================================
--- /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 677)
+++ /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 678)
@@ -124,5 +124,4 @@
   printf("G4OpenGLQtViewer::ShowView  +++++++++++++++++++++\n");
 #endif
-  glFlush ();
   if (!GLWindow) {
     G4cerr << "Visualization window not defined, please choose one before\n" << G4endl;
@@ -137,4 +136,5 @@
 #endif
   }
+  glFlush ();
   //   // Empty the Windows message queue :
   //   MSG event;
@@ -285,5 +285,5 @@
   ,fWindow(0)
   ,fContextMenu(0)
-  ,fMouseAction(true)
+  ,fMouseAction(ROTATE)
 {
 #ifdef GEANT4_QT_DEBUG
@@ -314,33 +314,79 @@
   fContextMenu = new QMenu("All");
 #endif
-  Q_CHECK_PTR( fContextMenu );
+
+#if QT_VERSION < 0x040000
+  QPopupMenu *mMouseAction = new QPopupMenu( fContextMenu );
+  fContextMenu->insertItem("&Mouse actions");
+#else
+  QMenu *mMouseAction = fContextMenu->addMenu("&Mouse actions");
+#endif
 
 #if QT_VERSION < 0x040000
   // === Mouse menu ===
-  QPopupMenu *mMouseAction = new QPopupMenu( fContextMenu );
-  Q_CHECK_PTR( mMouseAction );
-
-#if QT_VERSION < 0x030200
-  QAction *rotate = new QAction("&Rotate scene","&Rotate scene",CTRL+Key_N,mMouseAction);
-  QAction *move =  new QAction("&Move scene","&Move scene",CTRL+Key_M,mMouseAction);
-#else
-  QAction *rotate = new QAction("&Rotate scene",CTRL+Key_N,mMouseAction);
-  QAction *move =  new QAction("&Move scene",CTRL+Key_M,mMouseAction);
-#endif
-  rotate->addTo(mMouseAction);
-  move->addTo(mMouseAction);
-
-  fContextMenu->insertItem( "&Mouse action", mMouseAction);
+
+  fMouseRotate = new QPopupMenu(mMouseAction);
+  mMouseAction->insertItem("&Rotate",fMouseRotate);
+
+  mMouseAction->setCheckable(true);
+  fMouseRotate->setCheckable(true);
+
+  fMouseMove = new QPopupMenu(mMouseAction);
+  mMouseAction->insertItem("&Move",fMouseMove);
+  fMouseMove->setCheckable(true);
+
+  fMouseZoom = new QPopupMenu(mMouseAction);
+  mMouseAction->insertItem("&Zoom",fMouseZoom);
+  fMouseZoom->setCheckable(true);
 
 #else
   // === Mouse menu ===
-  QMenu *mMouseAction = fContextMenu->addMenu("&Mouse action");
-
-  QAction *rotate = mMouseAction->addAction("&Rotate scene");
-  QAction *move = mMouseAction->addAction("&Move scene");
+
+  fMouseRotate = mMouseAction->addAction("Rotate");
+  fMouseRotate->setCheckable(true);
+
+  fMouseMove = mMouseAction->addAction("Move");
+  fMouseMove->setCheckable(true);
+
+  fMouseZoom = mMouseAction->addAction("Zoom");
+  fMouseZoom->setCheckable(true);
 #endif
 
   // INIT mMouse
-  createRadioAction(rotate,move,SLOT(toggleMouseAction(bool)),1);
+#if QT_VERSION < 0x040000
+  fMouseRotate->setItemCheckeded(0,true);
+
+  QObject ::connect(fMouseRotate, 
+                    SIGNAL(activated(int)),
+                    this, 
+                    SLOT(actionMouseRotate()));
+
+  QObject ::connect(fMouseMove, 
+                    SIGNAL(activated(int)),
+                    this, 
+                    SLOT(actionMouseMove()));
+
+  QObject ::connect(fMouseZoom, 
+                    SIGNAL(activated(int)),
+                    this, 
+                    SLOT(actionMouseZoom()));
+
+#else
+  fMouseRotate->setChecked(true);
+
+  QObject ::connect(fMouseRotate, 
+                    SIGNAL(triggered(bool)),
+                    this, 
+                    SLOT(actionMouseRotate()));
+
+  QObject ::connect(fMouseMove, 
+                    SIGNAL(triggered(bool)),
+                    this, 
+                    SLOT(actionMouseMove()));
+
+  QObject ::connect(fMouseZoom, 
+                    SIGNAL(triggered(bool)),
+                    this, 
+                    SLOT(actionMouseZoom()));
+#endif
 
 #if QT_VERSION < 0x040000
@@ -775,4 +821,28 @@
 
 /**
+   Slot activate when mouseAction->rotate menu is set 
+ */
+void G4OpenGLQtViewer::actionMouseRotate() {
+  emit toggleMouseAction(ROTATE);
+}
+
+/**
+   Slot activate when mouseAction->move menu is set 
+ */
+void G4OpenGLQtViewer::actionMouseMove() {
+  emit toggleMouseAction(MOVE);
+}
+
+/**
+   Slot activate when mouseAction->zoom menu is set 
+ */
+void G4OpenGLQtViewer::actionMouseZoom() {
+#ifdef GEANT4_QT_DEBUG
+  printf("G4OpenGLQtViewer::actionMouseZoom \n");
+#endif
+  emit toggleMouseAction(ZOOM);
+}
+
+/**
    Slot activate when drawing->wireframe menu is set 
  */
@@ -803,4 +873,62 @@
 
 
+/**
+   Slot activated when mouse action is toggle
+   @param aAction : ROTATE, MOVE, ZOOM
+ */
+void G4OpenGLQtViewer::toggleMouseAction(mouseActions aAction) {
+  
+
+#ifdef GEANT4_QT_DEBUG
+  printf("G4OpenGLQtViewer::toggleMouseAction **** \n");
+#endif
+  if (aAction == ROTATE) {
+#ifdef GEANT4_QT_DEBUG
+  printf("G4OpenGLQtViewer::toggleMouseAction ROTATE \n");
+#endif
+#if QT_VERSION < 0x040000
+    fMouseRotate->setItemChecked (0,true);
+    fMouseMove->setItemChecked (0,false);
+    fMouseZoom->setItemChecked (0,false);
+#else
+    fMouseRotate->setChecked (true);
+    fMouseMove->setChecked (false);
+    fMouseZoom->setChecked (false);
+#endif
+    fMouseAction = ROTATE;
+  } else  if (aAction == MOVE) {
+#ifdef GEANT4_QT_DEBUG
+  printf("G4OpenGLQtViewer::toggleMouseAction MOVE \n");
+#endif
+#if QT_VERSION < 0x040000
+    fMouseRotate->setItemChecked (0,false);
+    fMouseMove->setItemChecked (0,true);
+    fMouseZoom->setItemChecked (0,false);
+#else
+    fMouseRotate->setChecked (false);
+    fMouseMove->setChecked (true);
+    fMouseZoom->setChecked (false);
+#endif
+    fMouseAction = MOVE;
+  } else  if (aAction == ZOOM) {
+#ifdef GEANT4_QT_DEBUG
+  printf("G4OpenGLQtViewer::toggleMouseAction ZOOM \n");
+#endif
+#if QT_VERSION < 0x040000
+    fMouseRotate->setItemChecked (0,false);
+    fMouseMove->setItemChecked (0,false);
+    fMouseZoom->setItemChecked (0,true);
+#else
+    fMouseRotate->setChecked (false);
+    fMouseMove->setChecked (false);
+    fMouseZoom->setChecked (true);
+#endif
+    fMouseAction = ZOOM;
+  }
+
+#ifdef GEANT4_QT_DEBUG
+  printf("G4OpenGLQtViewer::toggleMouseAction\n");
+#endif
+}
 /**
    Slot activated when drawing menu is toggle
@@ -1022,20 +1150,4 @@
   G4cerr << "This version of G4UI Could not generate the selected format\n" << G4endl;
 #endif
-#ifdef GEANT4_QT_DEBUG
-  printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check);
-#endif
-}
-
-/**
-   SLOT Activate by a click on the mouse action menu
-   @param check : 1 , 0
-*/
-void G4OpenGLQtViewer::toggleMouseAction(bool check) {
-  if (check) { // rotate scene
-    fMouseAction = true;
-  } else { // move scene
-    fMouseAction = false;
-  }
-
 #ifdef GEANT4_QT_DEBUG
   printf("G4OpenGLQtViewer::toggleRepresentation %d\n",check);
@@ -1222,5 +1334,5 @@
   int dx = pos_x - lastPos.x();
   int dy = pos_y - lastPos.y();
-  if (fMouseAction) {  // rotate
+  if (fMouseAction == ROTATE) {  // rotate
     if (mButtons & Qt::LeftButton) {
       //phi spin stuff here
@@ -1281,6 +1393,6 @@
       //       updateQWidget();
     }
-  } else {  // move
-
+  } else   if (fMouseAction == MOVE){  // move
+      
     float dx = pos_x - lastPos.x();
     float dy = pos_y - lastPos.y();
@@ -1301,4 +1413,13 @@
     
     updateQWidget();
+  } else   if (fMouseAction == ZOOM){  // zoom
+    if (mButtons & Qt::LeftButton) {
+      Pick(pos_x,pos_y);
+      G4cerr << "Zoom not implemented for the moment\n" << G4endl;
+    }
+  } else   if (fMouseAction == MOVE){  // pick
+    if (mButtons & Qt::LeftButton) {
+      Pick(pos_x,pos_y);
+    }
   }
   lastPos = QPoint(pos_x, pos_y);
Index: /trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc
===================================================================
--- /trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc	(revision 677)
+++ /trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc	(revision 678)
@@ -54,5 +54,4 @@
  QGLWidget(QGLFormat(QGL::SampleBuffers))             // FIXME : gerer le pb du parent !
  {
-   zoomAction = false;
    nbPaint =0;
    hasToRepaint =false;
@@ -257,80 +256,4 @@
 void G4OpenGLStoredQtViewer::paintGL()
  {
-   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);
-     //         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,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);
-         //          }
-       }
-       //       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);
-     
-#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 {
      
      if (!readyToPaint) {
@@ -376,5 +299,4 @@
      hasToRepaint =false;
      
-   }
 #ifdef GEANT4_QT_DEBUG
      printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n",nbPaint,readyToPaint);
@@ -391,4 +313,8 @@
 }
 
+/**
+ * This function was build in order to make a zoom on double clic event.
+ * It was think to build a rubberband on the zoom area, but never work fine
+ */
 void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *event)
 {
@@ -396,30 +322,6 @@
   printf("G4OpenGLStoredQtViewer::mouseDoubleClickEvent\n");
 #endif
-  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().convertToFormat(QImage::Format_ARGB32);//_Premultiplied);
-  QImage acha( glBufferImage.size(), QImage::Format_RGB32 );
-  acha.fill( Qt::black );
-  glBufferImage.setAlphaChannel( acha );
-  
-#ifdef GEANT4_QT_DEBUG
-//   for (int ay=0;ay<glBufferImage.height();ay++) {
-//     for (int ax=0;ax<glBufferImage.width();ax++) {
-//       if (glBufferImage.pixel(ax,ay) == 255) {
-//         printf(".");
-//       } else if (!glBufferImage.pixel(ax,ay)) {
-//         printf("X");
-//       } else {
-//         printf("%d",glBufferImage.pixel(ax,ay));
-//       }
-//     }
-//     printf("\n");
-//   }
-#endif
-  beginZoom.setX(event->x());
-  beginZoom.setY(event->y());
+//   setMouseTracking(true);
+//   glBufferImage = grabFrameBuffer().convertToFormat(QImage::Format_ARGB32);//_Premultiplied);  
 }
 
@@ -429,14 +331,10 @@
   printf("G4OpenGLStoredQtViewer::mouseReleaseEvent\n");
 #endif
-  setMouseTracking(false);
-  zoomAction =false;
+//   setMouseTracking(false);
 }
 
 void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
 {
-  // special case of mouse zoom action, it should draw a rect on
-  // the openGL buffer, so it could only be done in this class
-  // and sould be reimplemented in G4OpenGLImmediateQtViewer
-  if (!zoomAction) {
+
 #if QT_VERSION < 0x040000
     G4MouseMoveEvent(event->x(),event->y(),event->state());
@@ -444,13 +342,4 @@
     G4MouseMoveEvent(event->x(),event->y(),event->buttons());
 #endif
-  } else {
-#ifdef GEANT4_QT_DEBUG
-    printf("G4OpenGLStoredQtViewer::mouseMoveEvent zoom\n");
-#endif
-    endZoom.setX(event->x());
-    endZoom.setY(event->y());
-    updateGL();
-  }
-  //  DrawView();
 }
 
Index: /trunk/geant4/visualization/OpenGL/src/G4OpenGLViewer.cc
===================================================================
--- /trunk/geant4/visualization/OpenGL/src/G4OpenGLViewer.cc	(revision 677)
+++ /trunk/geant4/visualization/OpenGL/src/G4OpenGLViewer.cc	(revision 678)
@@ -313,4 +313,5 @@
 void G4OpenGLViewer::Pick(GLdouble x, GLdouble y)
 {
+  printf("G4OpenGLViewer::Pick\n");
   //G4cout << "X: " << x << ", Y: " << y << G4endl;
   const G4int BUFSIZE = 512;
