Index: /trunk/source/visualization/OpenGL/History
===================================================================
--- /trunk/source/visualization/OpenGL/History	(revision 1306)
+++ /trunk/source/visualization/OpenGL/History	(revision 1307)
@@ -1,3 +1,3 @@
-$Id: History,v 1.174 2010/05/30 09:53:05 allison Exp $
+$Id: History,v 1.178 2010/06/04 15:27:47 lgarnier Exp $
 -------------------------------------------------------------------
 
@@ -17,4 +17,38 @@
      * Reverse chronological order (last date on top), please *
      ----------------------------------------------------------
+
+4th June 2010  Laurent Garnier
+- G4OpenGLImmediate/StoredQtViewer : Add protection against multiple
+  repaint call. Add protection against resizeGl with bad values
+
+3rd June 2010  John Allison  (opengl-V09-03-06)
+- G4OpenGLImmediateSceneHandler: Re-instate
+  // Make sure screen corresponds to graphical database...
+  if (fpViewer) {
+    fpViewer -> SetView ();
+    fpViewer -> ClearView ();
+    fpViewer -> DrawView ();
+  }
+  I was wrong - it *is* necessary.  If not there, events are not refreshed.
+  So this and similar changes below are all back to geant4-09-03, including
+  glFlush, which is still a big performance penalty on Mac's Snow Leopard.
+
+3rd June 2010  John Allison  (opengl-V09-03-05)
+- Restored following files to geant4-09-03 in interests of stable behaviour:
+  o G4OpenGLStoredSceneHandler.cc
+    Restored code removed in opengl-V09-03-03:
+  // Make sure screen corresponds to graphical database...
+  if (fpViewer) {
+    fpViewer -> SetView ();
+    fpViewer -> ClearView ();
+    fpViewer -> DrawView ();
+  }
+  o G4OpenGLStoredXViewer.cc:
+    Restore to geant4-09-03.  Restored code removed in opengl-V09-03-03:
+      } else { // ADD TO AVOID KernelVisit=1 and nothing to display
+        DrawDisplayLists ();
+        FinishView ();
+- Note: G4OpenGLImmediateSceneHandler: Same code commented out.  I think
+  it's not necessary for immediate mode.
 
 30th May 2010  John Allison  (opengl-V09-03-04)
Index: /trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh
===================================================================
--- /trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh	(revision 1306)
+++ /trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh	(revision 1307)
@@ -25,5 +25,5 @@
 //
 //
-// $Id: G4OpenGLQtViewer.hh,v 1.22 2010/05/26 14:50:56 lgarnier Exp $
+// $Id: G4OpenGLQtViewer.hh,v 1.23 2010/06/04 15:27:47 lgarnier Exp $
 // GEANT4 tag $Name:  $
 //
@@ -129,4 +129,5 @@
   bool fHasToRepaint;
   bool fReadyToPaint;
+  bool fIsRepainting;
 
 private:
Index: /trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc
===================================================================
--- /trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc	(revision 1306)
+++ /trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc	(revision 1307)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4OpenGLImmediateQtViewer.cc,v 1.18 2010/03/10 11:03:46 lgarnier Exp $
-// GEANT4 tag $Name: vis-V09-03-06 $
+// $Id: G4OpenGLImmediateQtViewer.cc,v 1.19 2010/06/04 15:27:47 lgarnier Exp $
+// GEANT4 tag $Name:  $
 //
 //
@@ -53,5 +53,6 @@
   setFocusPolicy(Qt::StrongFocus); // enable keybord events
 #endif
-  fHasToRepaint =false;
+  fHasToRepaint = false;
+  fIsRepainting = false;
 
   if (fViewId < 0) return;  // In case error in base class instantiation.
@@ -148,6 +149,8 @@
 ,int aHeight)
 {  
-  ResizeWindow(aWidth,aHeight);
-  fHasToRepaint = sizeHasChanged();
+  if ((aWidth > 0) && (aHeight > 0)) {
+    ResizeWindow(aWidth,aHeight);
+    fHasToRepaint = sizeHasChanged();
+  }
 }
 
@@ -155,4 +158,7 @@
 void G4OpenGLImmediateQtViewer::paintGL()
 {
+  if (fIsRepainting) {
+    return ;
+  }
 #ifdef G4DEBUG_VIS_OGL
   printf("\n\nG4OpenGLImmediateQtViewer::paintGL ??\n");
@@ -208,4 +214,5 @@
   printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n\n\n",fReadyToPaint);
 #endif
+  fIsRepainting = false;
 }
 
Index: /trunk/source/visualization/OpenGL/src/G4OpenGLImmediateSceneHandler.cc
===================================================================
--- /trunk/source/visualization/OpenGL/src/G4OpenGLImmediateSceneHandler.cc	(revision 1306)
+++ /trunk/source/visualization/OpenGL/src/G4OpenGLImmediateSceneHandler.cc	(revision 1307)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4OpenGLImmediateSceneHandler.cc,v 1.32 2010/05/29 15:52:49 allison Exp $
-// GEANT4 tag $Name: vis-V09-03-06 $
+// $Id: G4OpenGLImmediateSceneHandler.cc,v 1.35 2010/06/03 20:35:19 allison Exp $
+// GEANT4 tag $Name:  $
 //
 // 
@@ -203,5 +203,13 @@
 
 void G4OpenGLImmediateSceneHandler::ClearTransientStore () {
+
   G4VSceneHandler::ClearTransientStore ();
+
+  // Make sure screen corresponds to graphical database...
+  if (fpViewer) {
+    fpViewer -> SetView ();
+    fpViewer -> ClearView ();
+    fpViewer -> DrawView ();
+  }
 }
 
Index: /trunk/source/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc
===================================================================
--- /trunk/source/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc	(revision 1306)
+++ /trunk/source/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc	(revision 1307)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4OpenGLStoredQtViewer.cc,v 1.29 2010/03/10 11:03:46 lgarnier Exp $
-// GEANT4 tag $Name: vis-V09-03-06 $
+// $Id: G4OpenGLStoredQtViewer.cc,v 1.30 2010/06/04 15:27:47 lgarnier Exp $
+// GEANT4 tag $Name:  $
 //
 //
@@ -53,5 +53,6 @@
   setFocusPolicy(Qt::StrongFocus); // enable keybord events
 #endif
-  fHasToRepaint =false;
+  fHasToRepaint = false;
+  fIsRepainting = false;
 
   if (fViewId < 0) return;  // In case error in base class instantiation.
@@ -181,5 +182,5 @@
   printf("G4OpenGLStoredQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
 #endif
-  fHasToRepaint =true;
+  fHasToRepaint = true;
 }
 
@@ -193,6 +194,8 @@
 {  
   // Set new size, it will be update when next Repaint()->SetView() called
-  ResizeWindow(aWidth,aHeight);
-  fHasToRepaint = sizeHasChanged();
+  if ((aWidth > 0) && (aHeight > 0)) {
+    ResizeWindow(aWidth,aHeight);
+    fHasToRepaint = sizeHasChanged();
+  }
 }
 
@@ -205,4 +208,8 @@
 void G4OpenGLStoredQtViewer::paintGL()
 {
+  if (fIsRepainting) {
+    return ;
+  }
+  fIsRepainting = true;
 #ifdef G4DEBUG_VIS_OGL
   printf("G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d??\n",fReadyToPaint,fHasToRepaint);
@@ -240,13 +247,14 @@
 
   SetView();
-          
+
   ClearView (); //ok, put the background correct
   ComputeView();
 
-  fHasToRepaint =false;
+  fHasToRepaint = false;
 
 #ifdef G4DEBUG_VIS_OGL
   printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n",fReadyToPaint);
 #endif
+  fIsRepainting = false;
 }
 
Index: /trunk/source/visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc
===================================================================
--- /trunk/source/visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc	(revision 1306)
+++ /trunk/source/visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc	(revision 1307)
@@ -25,5 +25,5 @@
 //
 //
-// $Id: G4OpenGLStoredSceneHandler.cc,v 1.41 2010/05/29 15:52:49 allison Exp $
+// $Id: G4OpenGLStoredSceneHandler.cc,v 1.42 2010/06/03 08:23:02 allison Exp $
 // GEANT4 tag $Name:  $
 //
@@ -361,4 +361,11 @@
     glDeleteLists(fTOList[i].fDisplayListId, 1);
   fTOList.clear ();
+
+  // Make sure screen corresponds to graphical database...
+  if (fpViewer) {
+    fpViewer -> SetView ();
+    fpViewer -> ClearView ();
+    fpViewer -> DrawView ();
+  }
 }
 
Index: /trunk/source/visualization/OpenGL/src/G4OpenGLStoredXViewer.cc
===================================================================
--- /trunk/source/visualization/OpenGL/src/G4OpenGLStoredXViewer.cc	(revision 1306)
+++ /trunk/source/visualization/OpenGL/src/G4OpenGLStoredXViewer.cc	(revision 1307)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4OpenGLStoredXViewer.cc,v 1.26 2010/05/29 15:56:50 allison Exp $
-// GEANT4 tag $Name: vis-V09-03-06 $
+// $Id: G4OpenGLStoredXViewer.cc,v 1.27 2010/06/03 08:26:55 allison Exp $
+// GEANT4 tag $Name:  $
 //
 // 
@@ -133,6 +133,6 @@
 	FinishView ();
       } else { // ADD TO AVOID KernelVisit=1 and nothing to display
-        //DrawDisplayLists ();  ????????? (JA)
-        //FinishView ();        ????????? (JA)
+        DrawDisplayLists ();
+        FinishView ();
       }
     }
Index: /trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc
===================================================================
--- /trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc	(revision 1306)
+++ /trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc	(revision 1307)
@@ -177,4 +177,7 @@
   glViewport(0, 0, fWinSize_x,fWinSize_y); 
 
+#ifdef G4DEBUG_VIS_OGL
+  printf("G4OpenGLViewer::ResizeGLView END %d %d &:%d\n",fWinSize_x,fWinSize_y,this);
+#endif
   
 }
@@ -186,4 +189,7 @@
     return;
   }
+#ifdef G4DEBUG_VIS_OGL
+  printf("G4OpenGLViewer::SetView\n");
+#endif
   // Calculates view representation based on extent of object being
   // viewed and (initial) viewpoint.  (Note: it can change later due
@@ -330,4 +336,7 @@
   background = fVP.GetBackgroundColour ();
 
+#ifdef G4DEBUG_VIS_OGL
+  printf("G4OpenGLViewer::SetView END\n");
+#endif
 }
 
