Index: trunk/source/visualization/OpenGL/GNUmakefile
===================================================================
--- trunk/source/visualization/OpenGL/GNUmakefile	(revision 1245)
+++ trunk/source/visualization/OpenGL/GNUmakefile	(revision 1253)
@@ -13,7 +13,5 @@
  CPPFLAGS += -DG4DEBUG_VIS_OGL
 
-CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_1
-CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_2
-CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_3
+#CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_2
 
 GLOBLIBS  = libG4vis_management.lib libG4modeling.lib libG4gl2ps.lib
@@ -26,4 +24,5 @@
 include $(G4INSTALL)/config/architecture.gmk
 include $(G4INSTALL)/config/G4VIS_BUILD.gmk
+include $(G4INSTALL)/config/G4UI_BUILD.gmk
 include $(G4INSTALL)/config/interactivity.gmk
 
Index: trunk/source/visualization/OpenGL/History
===================================================================
--- trunk/source/visualization/OpenGL/History	(revision 1245)
+++ trunk/source/visualization/OpenGL/History	(revision 1253)
@@ -1,3 +1,3 @@
-$Id: History,v 1.166 2010/04/27 15:59:10 lgarnier Exp $
+$Id: History,v 1.167 2010/04/30 13:18:32 lgarnier Exp $
 -------------------------------------------------------------------
 
@@ -17,4 +17,9 @@
      * Reverse chronological order (last date on top), please *
      ----------------------------------------------------------
+
+29th April 2010 Laurent Garnier
+ - G4OpenGLSceneHandler : Speed Improvment by drawing vector of
+   markers instead one by one
+
 27th April 2010 Laurent Garnier
  - G4OpenGLStoredXmViewer : remove viewer form list at destruction
Index: trunk/source/visualization/OpenGL/include/G4OpenGLSceneHandler.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLSceneHandler.hh	(revision 1245)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLSceneHandler.hh	(revision 1253)
@@ -25,5 +25,5 @@
 //
 //
-// $Id: G4OpenGLSceneHandler.hh,v 1.27 2009/10/21 15:18:14 allison Exp $
+// $Id: G4OpenGLSceneHandler.hh,v 1.28 2010/04/30 13:18:32 lgarnier Exp $
 // GEANT4 tag $Name:  $
 //
@@ -106,5 +106,5 @@
 
   void AddCircleSquare (const G4VMarker&, G4OpenGLBitMapStore::Shape);
-  void AddCircleSquares (std::vector <G4VMarker>, G4OpenGLBitMapStore::Shape);
+  void AddCircleSquareVector (std::vector <G4VMarker>, G4OpenGLBitMapStore::Shape);
 
   void DrawXYPolygon
Index: trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 1245)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 1253)
@@ -52,6 +52,8 @@
 #include "G4UnitsTable.hh"
 #include "G4Qt.hh"
+#include "G4UIQt.hh"
 #include "G4UImanager.hh"
 #include "G4UIcommandTree.hh"
+#include "G4VBasicShell.hh"
 #include <qlayout.h>
 #include <qdialog.h>
@@ -125,8 +127,40 @@
 
   // return false if G4UIQt was not launch
-  bool isTabbedView = interactorManager->AddTabWidget(fWindow,name,getWinWidth(),getWinHeight());
+
+  G4UImanager* UI = G4UImanager::GetUIpointer();
+#ifdef G4DEBUG_VIS_OGL
+  printf("G4OpenGLQtViewer::CreateMainWindow UI:%d\n",UI);
+#endif
+  if (UI == NULL) return;
+
+#ifdef G4DEBUG_VIS_OGL
+  G4UIQt * uiQt2 =  static_cast<G4UIQt*> (UI->GetG4UIWindow());
+  printf("G4UIQt:: recheck Session : %d UImanager:%d\n",uiQt2,UI);
+#endif
+
+
+  if (! static_cast<G4UIQt*> (UI->GetG4UIWindow())) {
+#ifdef G4DEBUG_VIS_OGL
+    printf("G4OpenGLQtViewer::CreateMainWindow return cast WRONG\n");
+#endif
+    return;
+  }
+  G4UIQt * uiQt = static_cast<G4UIQt*> (UI->GetG4UIWindow());
+#ifdef G4DEBUG_VIS_OGL
+  printf("G4OpenGLQtViewer::CreateMainWindow :: G4UIQt:%d UImanager:%d\n",uiQt,UI);
+#endif
+  
+//   if (! dynamic_cast<G4VBasicShell*> (session)) {
+//     G4VBasicShell * b = (G4VBasicShell*) session;
+//     if (! static_cast<G4UIQt*> (b)) {
+//       return;
+//     }
+//   }
+
+//   G4UIQt * uiQt = (dynamic_cast<G4UIQt*> (dynamic_cast<G4VBasicShell*> (UI)))->GetSession();
+  bool isTabbedView = uiQt->AddTabWidget(fWindow,name,getWinWidth(),getWinHeight());
 
   if (!isTabbedView) { // we have to do a dialog
-
+    
     QWidget *myParent = getParentWidget();
 #ifdef G4DEBUG_VIS_OGL
Index: trunk/source/visualization/OpenGL/src/G4OpenGLSceneHandler.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLSceneHandler.cc	(revision 1245)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLSceneHandler.cc	(revision 1253)
@@ -25,5 +25,5 @@
 //
 //
-// $Id: G4OpenGLSceneHandler.cc,v 1.56 2009/10/21 15:18:43 allison Exp $
+// $Id: G4OpenGLSceneHandler.cc,v 1.57 2010/04/30 13:18:32 lgarnier Exp $
 // GEANT4 tag $Name:  $
 //
@@ -198,7 +198,4 @@
 void G4OpenGLSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
 {
-#ifdef G4DEBUG_VIS_OGL
-// printf("G4OpenGLSceneHandler::AddPrimitive polymarker");
-#endif
   G4int nPoints = polymarker.size ();
   if (nPoints <= 0) return;
@@ -217,7 +214,4 @@
   case G4Polymarker::dots:
     {
-#ifdef G4DEBUG_VIS_OGL
-// printf(" dots ");
-#endif
       for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
         G4Circle dot (polymarker);
@@ -231,50 +225,29 @@
   case G4Polymarker::circles:
     {
-#ifdef G4DEBUG_VIS_OGL
-// printf(" circle ");
-#endif
-#ifdef G4VIS_BUILD_OPTIMISE_3
       std::vector <G4VMarker> circleV; 
-      // FIXME, must check attribute before doing a list
-#endif
       for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
         G4Circle circle (polymarker);
         // If not already drawn
         circle.SetPosition (polymarker[iPoint]);
-#ifdef G4VIS_BUILD_OPTIMISE_3
         circleV.push_back(circle);
-#endif
-      }
-#ifdef G4VIS_BUILD_OPTIMISE_3
+        //      G4OpenGLSceneHandler::AddPrimitive (circle);
+      }
       G4OpenGLSceneHandler::AddPrimitives (circleV);
-#endif
     }
     break;
   case G4Polymarker::squares:
     {
-#ifdef G4DEBUG_VIS_OGL
-// printf(" square ");
-#endif
-#ifdef G4VIS_BUILD_OPTIMISE_3
       std::vector <G4VMarker> squareV; 
-      // FIXME, must check attribute before doing a list
-#endif
       for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
         G4Square square (polymarker);
         square.SetPosition (polymarker[iPoint]);
-#ifdef G4VIS_BUILD_OPTIMISE_3
         squareV.push_back(square);
-#endif
-      }
-#ifdef G4VIS_BUILD_OPTIMISE_3
+        //      G4OpenGLSceneHandler::AddPrimitive (square);
+      }
       G4OpenGLSceneHandler::AddPrimitives (squareV);
-#endif
     }
     break;
   }
 
-#ifdef G4DEBUG_VIS_OGL
-// printf(" \n");
-#endif
   fProcessingPolymarker = false;
 }
@@ -340,5 +313,5 @@
 void G4OpenGLSceneHandler::AddPrimitives (std::vector <G4VMarker> square) {
   glDisable (GL_POINT_SMOOTH);
-  AddCircleSquares (square, G4OpenGLBitMapStore::square);
+  AddCircleSquareVector (square, G4OpenGLBitMapStore::square);
 }
 
@@ -347,100 +320,10 @@
  G4OpenGLBitMapStore::Shape shape) {
 
-  if (!fProcessingPolymarker) {  // Polymarker has already loaded atts.
-    // Loads G4Atts for picking...
-    if (fpViewer->GetViewParameters().IsPicking()) {
-      G4AttHolder* holder = new G4AttHolder;
-      LoadAtts(marker, holder);
-      fPickMap[fPickName] = holder;
-    }
-  }
-
-  // Note: colour treated in sub-class.
-
-  if (fpViewer -> GetViewParameters ().IsMarkerNotHidden ()) {
-#ifdef G4DEBUG_VIS_OGL
-    //    printf("+");
-#endif
-    glDisable (GL_DEPTH_TEST);
-  } else {
-#ifdef G4DEBUG_VIS_OGL
-    //    printf("-");
-#endif
-    glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS);}
-  
-  glDisable (GL_LIGHTING);
-  
-  // Get vis attributes - pick up defaults if none.
-  const G4VisAttributes* pVA =
-    fpViewer -> GetApplicableVisAttributes (marker.GetVisAttributes ());
-
-  G4double lineWidth = GetLineWidth(pVA);
-  glLineWidth(lineWidth);
-
-  G4VMarker::FillStyle style = marker.GetFillStyle();
-
-  G4bool filled = false;
-  static G4bool hashedWarned = false;
-  
-  switch (style) {
-  case G4VMarker::noFill: 
-    glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
-    filled = false;
-    break;
-    
-  case G4VMarker::hashed:
-    if (!hashedWarned) {
-      G4cout << "Hashed fill style in G4OpenGLSceneHandler."
-	     << "\n  Not implemented.  Using G4VMarker::filled."
-	     << G4endl;
-      hashedWarned = true;
-    }
-    // Maybe use
-    //glPolygonStipple (fStippleMaskHashed);
-    // Drop through to filled...
-    
-  case G4VMarker::filled:
-    glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
-    filled = true;
-    break;
-    
-  }
-
-  // A few useful quantities...
-  G4Point3D centre = marker.GetPosition();
-  MarkerSizeType sizeType;
-  G4double size = GetMarkerSize(marker, sizeType);
-
-
-  // Draw...
-   if (sizeType == world) {  // Size specified in world coordinates.
-
-     DrawXYPolygon (shape, size, centre, pVA);
-
-   } else { // Size specified in screen (window) coordinates.
-     glPointSize (size);       
-     glBegin (GL_POINTS);
-     glVertex3f(centre.x(),centre.y(),centre.z());
-     glEnd();
-     //Antialiasing
-     glEnable (GL_POINT_SMOOTH);
-     //Transparency
-     glEnable(GL_BLEND);
-     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
-     // L. GARNIER 1 March 2009
-     // Old method, we draw a bitmap instead of a GL_POINT. 
-     // I remove it because it cost in term of computing performances
-     // and gl2ps can't draw bitmaps
-
-     //      glRasterPos3d(centre.x(),centre.y(),centre.z());
-     //      const GLubyte* marker =
-     //        G4OpenGLBitMapStore::GetBitMap(shape, size, filled);
-     //      glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-     //      glBitmap(GLsizei(size), GLsizei(size), size/2., size/2., 0., 0., marker);
-   }
-}
-
-void G4OpenGLSceneHandler::AddCircleSquares
+  std::vector <G4VMarker> circleVector;
+  circleVector.push_back(marker);
+  AddCircleSquareVector(circleVector,shape);
+}
+ 
+void G4OpenGLSceneHandler::AddCircleSquareVector
 (std::vector <G4VMarker> marker,
  G4OpenGLBitMapStore::Shape shape) {
@@ -462,13 +345,8 @@
 
   if (fpViewer -> GetViewParameters ().IsMarkerNotHidden ()) {
-#ifdef G4DEBUG_VIS_OGL
-    //    printf("+");
-#endif
     glDisable (GL_DEPTH_TEST);
   } else {
-#ifdef G4DEBUG_VIS_OGL
-    //    printf("-");
-#endif
-    glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS);}
+    glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS);
+  }
   
   glDisable (GL_LIGHTING);
Index: trunk/source/visualization/OpenGL/src/G4OpenGLStoredXmViewer.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLStoredXmViewer.cc	(revision 1245)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLStoredXmViewer.cc	(revision 1253)
@@ -25,5 +25,5 @@
 //
 //
-// $Id: G4OpenGLStoredXmViewer.cc,v 1.25 2009/04/08 16:55:44 lgarnier Exp $
+// $Id: G4OpenGLStoredXmViewer.cc,v 1.26 2010/04/30 13:18:32 lgarnier Exp $
 // GEANT4 tag $Name:  $
 //
