Index: trunk/source/visualization/OpenGL/include/G4OpenGLBitMapStore.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLBitMapStore.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLBitMapStore.hh	(revision 914)
@@ -46,6 +46,8 @@
 
 #include "globals.hh"
-#include "G4OpenGL.hh"
 #include <map>
+
+#include <GL/gl.h>
+#include <GL/glu.h>
 
 namespace G4OpenGLBitMapStore {
Index: trunk/source/visualization/OpenGL/include/G4OpenGLImmediateSceneHandler.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLImmediateSceneHandler.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLImmediateSceneHandler.hh	(revision 914)
@@ -37,10 +37,6 @@
 #define G4OPENGLIMMEDIATESCENEHANDLER_HH
 
-#include "G4VSceneHandler.hh"
-#include "G4OpenGLViewer.hh"
-#include "G4OpenGLImmediateViewer.hh"
+#include "G4OpenGLSceneHandler.hh"
 #include "globals.hh"
-#include "G4RotationMatrix.hh"
-#include "G4OpenGLSceneHandler.hh"
 
 class G4OpenGLImmediate;
Index: trunk/source/visualization/OpenGL/include/G4OpenGLImmediateViewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLImmediateViewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLImmediateViewer.hh	(revision 914)
@@ -39,9 +39,5 @@
 #define G4OPENGLIMMEDIATEVIEWER_HH
 
-#include "G4VViewer.hh"
 #include "G4OpenGLViewer.hh"
-#include "G4OpenGLSceneHandler.hh"
-#include "G4OpenGLImmediateSceneHandler.hh"
-#include "G4OpenGLTransform3D.hh"
 #include "globals.hh"
 
Index: trunk/source/visualization/OpenGL/include/G4OpenGLImmediateWin32Viewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLImmediateWin32Viewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLImmediateWin32Viewer.hh	(revision 914)
@@ -37,5 +37,4 @@
 #define G4OpenGLIMMEDIATEWIN32VIEWER_HH
 
-#include "G4VViewer.hh"
 #include "G4OpenGLImmediateViewer.hh"
 #include "G4OpenGLWin32Viewer.hh"
Index: trunk/source/visualization/OpenGL/include/G4OpenGLImmediateXViewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLImmediateXViewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLImmediateXViewer.hh	(revision 914)
@@ -38,5 +38,4 @@
 #define G4OpenGLIMMEDIATEXVIEWER_HH
 
-#include "G4VViewer.hh"
 #include "G4OpenGLImmediateViewer.hh"
 #include "G4OpenGLXViewer.hh"
Index: trunk/source/visualization/OpenGL/include/G4OpenGLImmediateXmViewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLImmediateXmViewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLImmediateXmViewer.hh	(revision 914)
@@ -38,5 +38,4 @@
 #define G4OPENGLIMMEDIATEXMVIEWER_HH
 
-#include "G4VViewer.hh"
 #include "G4OpenGLImmediateViewer.hh"
 #include "G4OpenGLXmViewer.hh"
Index: trunk/source/visualization/OpenGL/include/G4OpenGLQtExportDialog.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLQtExportDialog.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLQtExportDialog.hh	(revision 914)
@@ -36,5 +36,4 @@
 
 #include <qdialog.h>
-#include <qobject.h>
 
 class QButtonGroup;
Index: trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh	(revision 914)
@@ -39,9 +39,10 @@
 #include "globals.hh"
 
-#include "G4VViewer.hh"
-#include "G4OpenGLSceneHandler.hh"
+#include "G4OpenGLViewer.hh"
 
 #include <qobject.h>
 #include <qpoint.h>
+
+class G4OpenGLSceneHandler;
 
 class QGLWidget;
@@ -143,5 +144,5 @@
   void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
   void rescaleImage(int, int);
-  bool generateEPS(QString,int,QImage);  
+  bool generateEPS2(QString,int,QImage);  
   bool generateVectorEPS (QString,int,int,QImage);
   bool generatePS_PDF(QString,int,QImage);  
Index: trunk/source/visualization/OpenGL/include/G4OpenGLSceneHandler.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLSceneHandler.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLSceneHandler.hh	(revision 914)
@@ -39,11 +39,10 @@
 
 #include "globals.hh"
-#include "G4RotationMatrix.hh"
-
-#include "G4OpenGL.hh"
 
 #include "G4VSceneHandler.hh"
-#include "G4OpenGLViewer.hh"
-#include "G4OpenGLBitMapStore.hh"
+#include "G4OpenGLBitMapStore.hh";
+#include <GL/gl.h>
+#include <GL/glu.h>
+
 #include <map>
 
Index: trunk/source/visualization/OpenGL/include/G4OpenGLStoredQtViewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLStoredQtViewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLStoredQtViewer.hh	(revision 914)
@@ -37,5 +37,4 @@
 #define G4OpenGLSTOREDQTVIEWER_HH
 
-#include "G4VViewer.hh"
 #include "G4OpenGLStoredViewer.hh"
 #include "G4OpenGLQtViewer.hh"
Index: trunk/source/visualization/OpenGL/include/G4OpenGLStoredSceneHandler.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLStoredSceneHandler.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLStoredSceneHandler.hh	(revision 914)
@@ -37,9 +37,5 @@
 #define G4OPENGLSTOREDSCENEHANDLER_HH
 
-#include "G4VSceneHandler.hh"
-#include "G4OpenGLViewer.hh"
-#include "G4OpenGLStoredViewer.hh"
 #include "globals.hh"
-#include "G4RotationMatrix.hh"
 #include "G4OpenGLSceneHandler.hh"
 #include <map>
Index: trunk/source/visualization/OpenGL/include/G4OpenGLStoredXViewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLStoredXViewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLStoredXViewer.hh	(revision 914)
@@ -38,5 +38,4 @@
 #define G4OPENGLSTOREDXVIEWER_HH
 
-#include "G4VViewer.hh"
 #include "G4OpenGLStoredViewer.hh"
 #include "G4OpenGLXViewer.hh"
Index: trunk/source/visualization/OpenGL/include/G4OpenGLStoredXmViewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLStoredXmViewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLStoredXmViewer.hh	(revision 914)
@@ -38,5 +38,4 @@
 #define G4OpenGLSTOREDXMVIEWER_HH
 
-#include "G4VViewer.hh"
 #include "G4OpenGLStoredViewer.hh"
 #include "G4OpenGLXmViewer.hh"
Index: trunk/source/visualization/OpenGL/include/G4OpenGLViewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLViewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLViewer.hh	(revision 914)
@@ -38,5 +38,5 @@
 
 #include "G4VViewer.hh"
-#include "G4OpenGL.hh"
+#include <GL/gl.h>
 
 class G4OpenGLSceneHandler;
@@ -70,4 +70,11 @@
   void rotateScene (G4double dx, G4double dy,G4double delta);
 //////////////////////////////Vectored PostScript production functions///
+  GLubyte* grabPixels (int inColor,
+		       unsigned int width,
+		       unsigned int height);
+  int generateEPS (const char* filnam,
+		   int inColour,
+		   unsigned int width,
+		   unsigned int height);
   void printBuffer(GLint, GLfloat*);
   GLfloat* spewPrimitiveEPS (FILE*, GLfloat*);
Index: trunk/source/visualization/OpenGL/include/G4OpenGLWin32Viewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLWin32Viewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLWin32Viewer.hh	(revision 914)
@@ -39,6 +39,5 @@
 #include "globals.hh"
 
-#include "G4VViewer.hh"
-#include "G4OpenGLSceneHandler.hh"
+#include "G4OpenGLViewer.hh"
 
 class G4OpenGLSceneHandler;
Index: trunk/source/visualization/OpenGL/include/G4OpenGLXViewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLXViewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLXViewer.hh	(revision 914)
@@ -38,6 +38,5 @@
 #define G4OPENGLXVIEWER_HH
 
-#include "G4VViewer.hh"
-#include "G4OpenGLSceneHandler.hh"
+#include "G4OpenGLViewer.hh"
 #include "globals.hh"
 
@@ -72,11 +71,4 @@
 
 //////////////////////////////Pixmap (screen dump) production functions/////
-  GLubyte* grabPixels (int inColor,
-		       unsigned int width,
-		       unsigned int height);
-  int generateEPS (char* filnam,
-		   int inColour,
-		   unsigned int width,
-		   unsigned int height);
   GLXContext create_GL_print_context (XVisualInfo*& pvi);
 
Index: trunk/source/visualization/OpenGL/include/G4OpenGLXmBox.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLXmBox.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLXmBox.hh	(revision 914)
@@ -38,6 +38,4 @@
 #include "G4OpenGLXmVWidgetContainer.hh"
 #include "globals.hh"
-#include <Xm/Frame.h>
-#include <Xm/RowColumn.h>
 
 class G4OpenGLXmVWidgetComponent;
Index: trunk/source/visualization/OpenGL/include/G4OpenGLXmFramedBox.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLXmFramedBox.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLXmFramedBox.hh	(revision 914)
@@ -37,9 +37,6 @@
 #define G4OPENGLXMFRAMEDBOX_HH
 
-#include "G4OpenGLXmVWidgetContainer.hh"
 #include "G4OpenGLXmBox.hh"
 #include "globals.hh"
-#include <Xm/Frame.h>
-#include <Xm/RowColumn.h>
 
 class G4OpenGLXmVWidgetComponent;
Index: trunk/source/visualization/OpenGL/include/G4OpenGLXmVWidgetObject.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLXmVWidgetObject.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLXmVWidgetObject.hh	(revision 914)
@@ -40,6 +40,6 @@
 #include "X11/Intrinsic.h"
 #include <X11/Xlib.h>
-#include "G4OpenGLXmViewer.hh"
 
+class G4OpenGLXmViewer;
 class G4OpenGLXmVWidgetObject {
 
Index: trunk/source/visualization/OpenGL/include/G4OpenGLXmViewer.hh
===================================================================
--- trunk/source/visualization/OpenGL/include/G4OpenGLXmViewer.hh	(revision 912)
+++ trunk/source/visualization/OpenGL/include/G4OpenGLXmViewer.hh	(revision 914)
@@ -39,5 +39,4 @@
 
 #include "G4OpenGLXViewer.hh"
-#include "G4OpenGLSceneHandler.hh"
 #include "globals.hh"
 
Index: trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQt.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQt.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQt.cc	(revision 914)
@@ -40,4 +40,5 @@
 #include "G4OpenGLImmediateQtViewer.hh"
 #include "G4OpenGLViewerMessenger.hh"
+#include "G4OpenGLImmediateSceneHandler.hh"
 
 G4OpenGLImmediateQt::G4OpenGLImmediateQt ():
Index: trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc	(revision 914)
@@ -35,4 +35,5 @@
 
 #include "G4OpenGLImmediateQtViewer.hh"
+#include "G4OpenGLImmediateSceneHandler.hh"
 
 #include "G4ios.hh"
Index: trunk/source/visualization/OpenGL/src/G4OpenGLImmediateSceneHandler.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLImmediateSceneHandler.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLImmediateSceneHandler.cc	(revision 914)
@@ -45,4 +45,5 @@
 #include "G4OpenGLImmediateSceneHandler.hh"
 
+#include "G4OpenGLViewer.hh"
 #include "G4OpenGLTransform3D.hh"
 #include "G4Polyline.hh"
Index: trunk/source/visualization/OpenGL/src/G4OpenGLImmediateViewer.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLImmediateViewer.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLImmediateViewer.cc	(revision 914)
@@ -37,4 +37,5 @@
 
 #include "G4OpenGLImmediateViewer.hh"
+#include "G4OpenGLImmediateSceneHandler.hh"
 
 G4OpenGLImmediateViewer::G4OpenGLImmediateViewer (G4OpenGLImmediateSceneHandler& scene):
Index: trunk/source/visualization/OpenGL/src/G4OpenGLImmediateX.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLImmediateX.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLImmediateX.cc	(revision 914)
@@ -41,5 +41,5 @@
 #include "G4OpenGLImmediateXViewer.hh"
 #include "G4OpenGLViewerMessenger.hh"
-
+#include "G4OpenGLImmediateSceneHandler.hh"
 G4OpenGLImmediateX::G4OpenGLImmediateX ():
   G4VGraphicsSystem ("OpenGLImmediateX",
Index: trunk/source/visualization/OpenGL/src/G4OpenGLImmediateXViewer.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLImmediateXViewer.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLImmediateXViewer.cc	(revision 914)
@@ -36,4 +36,5 @@
 
 #include "G4OpenGLImmediateXViewer.hh"
+#include "G4OpenGLImmediateSceneHandler.hh"
 
 #include "G4ios.hh"
Index: trunk/source/visualization/OpenGL/src/G4OpenGLImmediateXm.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLImmediateXm.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLImmediateXm.cc	(revision 914)
@@ -42,4 +42,5 @@
 #include "G4OpenGLViewerMessenger.hh"
 #include "G4OpenGLXmViewerMessenger.hh"
+#include "G4OpenGLImmediateSceneHandler.hh"
 
 G4OpenGLImmediateXm::G4OpenGLImmediateXm ():
Index: trunk/source/visualization/OpenGL/src/G4OpenGLImmediateXmViewer.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLImmediateXmViewer.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLImmediateXmViewer.cc	(revision 914)
@@ -36,4 +36,5 @@
 
 #include "G4OpenGLImmediateXmViewer.hh"
+#include "G4OpenGLImmediateSceneHandler.hh"
 
 #include "G4ios.hh"
Index: trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 914)
@@ -37,4 +37,7 @@
 
 #include "G4OpenGLQtViewer.hh"
+#include "G4VViewer.hh"
+#include "G4VSceneHandler.hh"
+#include "G4OpenGLSceneHandler.hh"
 
 #include "G4ios.hh"
@@ -1347,5 +1350,5 @@
         res = generateVectorEPS(nomFich,exportDialog->getWidth(),exportDialog->getHeight(),image);
       } else {
-        res = generateEPS(nomFich,exportDialog->getNbColor(),image);
+        res = generateEPS2(nomFich,exportDialog->getNbColor(),image);
       }
     } else if ((format == "ps") || (format == "pdf")) {
@@ -1707,5 +1710,5 @@
    @param aImage : Image to print
 */
-bool G4OpenGLQtViewer::generateEPS (
+bool G4OpenGLQtViewer::generateEPS2 (
  QString aFilename
 ,int aInColor
@@ -1713,4 +1716,11 @@
 )
 {
+#ifdef G4DEBUG_VIS_OGL
+  printf("G4OpenGLQtViewer::generateEPS call parent\n");
+#endif
+  generateEPS((aFilename+"GL").toStdString().c_str(),3,(unsigned int)aImage.width(),(unsigned int)aImage.height());
+#ifdef G4DEBUG_VIS_OGL
+  printf("G4OpenGLQtViewer::generateEPS\n");
+#endif
   // FIXME
 
Index: trunk/source/visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc	(revision 914)
@@ -54,4 +54,6 @@
 #include "G4Polyhedron.hh"
 #include "G4AttHolder.hh"
+#include "G4OpenGLTransform3D.hh"
+#include "G4OpenGLViewer.hh"
 
 G4OpenGLStoredSceneHandler::PO::PO
Index: trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc	(revision 914)
@@ -25,5 +25,5 @@
 //
 //
-// $Id: G4OpenGLViewer.cc,v 1.46 2009/01/19 16:53:42 lgarnier Exp $
+// $Id: G4OpenGLViewer.cc,v 1.45 2009/01/15 18:14:58 lgarnier Exp $
 // GEANT4 tag $Name:  $
 //
@@ -745,4 +745,130 @@
 }
 
+GLubyte* G4OpenGLViewer::grabPixels (int inColor, unsigned int width, unsigned int height) {
+  
+  GLubyte* buffer;
+  GLint swapbytes, lsbfirst, rowlength;
+  GLint skiprows, skippixels, alignment;
+  GLenum format;
+  int size;
+
+  if (inColor) {
+    format = GL_RGB;
+    size = width*height*3;
+  } else {
+    format = GL_LUMINANCE;
+    size = width*height*1;
+  }
+
+  buffer = new GLubyte[size];
+  if (buffer == NULL)
+    return NULL;
+
+  glGetIntegerv (GL_UNPACK_SWAP_BYTES, &swapbytes);
+  glGetIntegerv (GL_UNPACK_LSB_FIRST, &lsbfirst);
+  glGetIntegerv (GL_UNPACK_ROW_LENGTH, &rowlength);
+
+  glGetIntegerv (GL_UNPACK_SKIP_ROWS, &skiprows);
+  glGetIntegerv (GL_UNPACK_SKIP_PIXELS, &skippixels);
+  glGetIntegerv (GL_UNPACK_ALIGNMENT, &alignment);
+
+  glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
+  glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
+  glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
+
+  glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
+  glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
+  glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+
+  glReadPixels (0, 0, (GLsizei)width, (GLsizei)height, format, GL_UNSIGNED_BYTE, (GLvoid*) buffer);
+
+  glPixelStorei (GL_UNPACK_SWAP_BYTES, swapbytes);
+  glPixelStorei (GL_UNPACK_LSB_FIRST, lsbfirst);
+  glPixelStorei (GL_UNPACK_ROW_LENGTH, rowlength);
+  
+  glPixelStorei (GL_UNPACK_SKIP_ROWS, skiprows);
+  glPixelStorei (GL_UNPACK_SKIP_PIXELS, skippixels);
+  glPixelStorei (GL_UNPACK_ALIGNMENT, alignment);
+  
+  return buffer;
+}
+
+int G4OpenGLViewer::generateEPS (const char* filnam,
+				int inColour,
+				unsigned int width,
+				unsigned int height) {
+
+  FILE* fp;
+  GLubyte* pixels;
+  GLubyte* curpix;
+  int components, pos, i;
+
+  pixels = grabPixels (inColour, width, height);
+
+  if (pixels == NULL)
+    return 1;
+  if (inColour) {
+    components = 3;
+  } else {
+    components = 1;
+  }
+  
+  fp = fopen (filnam, "w");
+  if (fp == NULL) {
+    return 2;
+  }
+  
+  fprintf (fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
+  fprintf (fp, "%%%%Title: %s\n", filnam);
+  fprintf (fp, "%%%%Creator: OpenGL pixmap render output\n");
+  fprintf (fp, "%%%%BoundingBox: 0 0 %d %d\n", width, height);
+  fprintf (fp, "%%%%EndComments\n");
+  fprintf (fp, "gsave\n");
+  fprintf (fp, "/bwproc {\n");
+  fprintf (fp, "    rgbproc\n");
+  fprintf (fp, "    dup length 3 idiv string 0 3 0 \n");
+  fprintf (fp, "    5 -1 roll {\n");
+  fprintf (fp, "    add 2 1 roll 1 sub dup 0 eq\n");
+  fprintf (fp, "    { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n");
+  fprintf (fp, "       3 1 roll 5 -1 roll } put 1 add 3 0 \n");
+  fprintf (fp, "    { 2 1 roll } ifelse\n");
+  fprintf (fp, "    }forall\n");
+  fprintf (fp, "    pop pop pop\n");
+  fprintf (fp, "} def\n");
+  fprintf (fp, "systemdict /colorimage known not {\n");
+  fprintf (fp, "   /colorimage {\n");
+  fprintf (fp, "       pop\n");
+  fprintf (fp, "       pop\n");
+  fprintf (fp, "       /rgbproc exch def\n");
+  fprintf (fp, "       { bwproc } image\n");
+  fprintf (fp, "   }  def\n");
+  fprintf (fp, "} if\n");
+  fprintf (fp, "/picstr %d string def\n", width * components);
+  fprintf (fp, "%d %d scale\n", width, height);
+  fprintf (fp, "%d %d %d\n", width, height, 8);
+  fprintf (fp, "[%d 0 0 %d 0 0]\n", width, height);
+  fprintf (fp, "{currentfile picstr readhexstring pop}\n");
+  fprintf (fp, "false %d\n", components);
+  fprintf (fp, "colorimage\n");
+  
+  curpix = (GLubyte*) pixels;
+  pos = 0;
+  for (i = width*height*components; i>0; i--) {
+    fprintf (fp, "%02hx ", *(curpix++));
+    if (++pos >= 32) {
+      fprintf (fp, "\n");
+      pos = 0; 
+    }
+  }
+  if (pos)
+    fprintf (fp, "\n");
+
+  fprintf (fp, "grestore\n");
+  fprintf (fp, "showpage\n");
+  delete pixels;
+  fclose (fp);
+  return 0;
+}
+
 GLdouble G4OpenGLViewer::getSceneNearWidth()
 {
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXViewer.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXViewer.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXViewer.cc	(revision 914)
@@ -36,4 +36,7 @@
 
 #include "G4OpenGLXViewer.hh"
+#include "G4VViewer.hh"
+#include "G4OpenGLSceneHandler.hh"
+#include <GL/glu.h>
 
 #include "G4OpenGLFontBaseStore.hh"
@@ -465,129 +468,4 @@
 }
 
-GLubyte* G4OpenGLXViewer::grabPixels (int inColor, unsigned int width, unsigned int height) {
-  
-  GLubyte* buffer;
-  GLint swapbytes, lsbfirst, rowlength;
-  GLint skiprows, skippixels, alignment;
-  GLenum format;
-  int size;
-
-  if (inColor) {
-    format = GL_RGB;
-    size = width*height*3;
-  } else {
-    format = GL_LUMINANCE;
-    size = width*height*1;
-  }
-
-  buffer = new GLubyte[size];
-  if (buffer == NULL)
-    return NULL;
-
-  glGetIntegerv (GL_UNPACK_SWAP_BYTES, &swapbytes);
-  glGetIntegerv (GL_UNPACK_LSB_FIRST, &lsbfirst);
-  glGetIntegerv (GL_UNPACK_ROW_LENGTH, &rowlength);
-
-  glGetIntegerv (GL_UNPACK_SKIP_ROWS, &skiprows);
-  glGetIntegerv (GL_UNPACK_SKIP_PIXELS, &skippixels);
-  glGetIntegerv (GL_UNPACK_ALIGNMENT, &alignment);
-
-  glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
-  glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
-  glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
-
-  glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
-  glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
-  glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
-
-  glReadPixels (0, 0, (GLsizei)width, (GLsizei)height, format, GL_UNSIGNED_BYTE, (GLvoid*) buffer);
-
-  glPixelStorei (GL_UNPACK_SWAP_BYTES, swapbytes);
-  glPixelStorei (GL_UNPACK_LSB_FIRST, lsbfirst);
-  glPixelStorei (GL_UNPACK_ROW_LENGTH, rowlength);
-  
-  glPixelStorei (GL_UNPACK_SKIP_ROWS, skiprows);
-  glPixelStorei (GL_UNPACK_SKIP_PIXELS, skippixels);
-  glPixelStorei (GL_UNPACK_ALIGNMENT, alignment);
-  
-  return buffer;
-}
-
-int G4OpenGLXViewer::generateEPS (char* filnam,
-				int inColour,
-				unsigned int width,
-				unsigned int height) {
-
-  FILE* fp;
-  GLubyte* pixels;
-  GLubyte* curpix;
-  int components, pos, i;
-
-  pixels = grabPixels (inColour, width, height);
-
-  if (pixels == NULL)
-    return 1;
-  if (inColour) {
-    components = 3;
-  } else {
-    components = 1;
-  }
-  
-  fp = fopen (filnam, "w");
-  if (fp == NULL) {
-    return 2;
-  }
-  
-  fprintf (fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
-  fprintf (fp, "%%%%Title: %s\n", filnam);
-  fprintf (fp, "%%%%Creator: OpenGL pixmap render output\n");
-  fprintf (fp, "%%%%BoundingBox: 0 0 %d %d\n", width, height);
-  fprintf (fp, "%%%%EndComments\n");
-  fprintf (fp, "gsave\n");
-  fprintf (fp, "/bwproc {\n");
-  fprintf (fp, "    rgbproc\n");
-  fprintf (fp, "    dup length 3 idiv string 0 3 0 \n");
-  fprintf (fp, "    5 -1 roll {\n");
-  fprintf (fp, "    add 2 1 roll 1 sub dup 0 eq\n");
-  fprintf (fp, "    { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n");
-  fprintf (fp, "       3 1 roll 5 -1 roll } put 1 add 3 0 \n");
-  fprintf (fp, "    { 2 1 roll } ifelse\n");
-  fprintf (fp, "    }forall\n");
-  fprintf (fp, "    pop pop pop\n");
-  fprintf (fp, "} def\n");
-  fprintf (fp, "systemdict /colorimage known not {\n");
-  fprintf (fp, "   /colorimage {\n");
-  fprintf (fp, "       pop\n");
-  fprintf (fp, "       pop\n");
-  fprintf (fp, "       /rgbproc exch def\n");
-  fprintf (fp, "       { bwproc } image\n");
-  fprintf (fp, "   }  def\n");
-  fprintf (fp, "} if\n");
-  fprintf (fp, "/picstr %d string def\n", width * components);
-  fprintf (fp, "%d %d scale\n", width, height);
-  fprintf (fp, "%d %d %d\n", width, height, 8);
-  fprintf (fp, "[%d 0 0 %d 0 0]\n", width, height);
-  fprintf (fp, "{currentfile picstr readhexstring pop}\n");
-  fprintf (fp, "false %d\n", components);
-  fprintf (fp, "colorimage\n");
-  
-  curpix = (GLubyte*) pixels;
-  pos = 0;
-  for (i = width*height*components; i>0; i--) {
-    fprintf (fp, "%02hx ", *(curpix++));
-    if (++pos >= 32) {
-      fprintf (fp, "\n");
-      pos = 0; 
-    }
-  }
-  if (pos)
-    fprintf (fp, "\n");
-
-  fprintf (fp, "grestore\n");
-  fprintf (fp, "showpage\n");
-  delete pixels;
-  fclose (fp);
-  return 0;
-}
 
 GLXContext G4OpenGLXViewer::create_GL_print_context(XVisualInfo*& pvi) {
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmBox.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmBox.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmBox.cc	(revision 914)
@@ -36,4 +36,6 @@
 #include "G4OpenGLXmVWidgetComponent.hh"
 #include "G4OpenGLXmVWidgetShell.hh"
+#include <Xm/RowColumn.h>
+#include <Xm/Xm.h>
 
 G4OpenGLXmBox::G4OpenGLXmBox (const char* n, 
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmFourArrowButtons.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmFourArrowButtons.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmFourArrowButtons.cc	(revision 914)
@@ -36,4 +36,7 @@
 #include "G4OpenGLXmFourArrowButtons.hh"
 #include <X11/Intrinsic.h>
+#include <Xm/Form.h>
+#include <Xm/ArrowBG.h>
+
 #include "globals.hh"
 
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmFramedBox.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmFramedBox.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmFramedBox.cc	(revision 914)
@@ -36,4 +36,6 @@
 #include "G4OpenGLXmVWidgetComponent.hh"
 #include "G4OpenGLXmVWidgetShell.hh"
+#include <Xm/RowColumn.h>
+#include <Xm/Frame.h>
 
 G4OpenGLXmFramedBox::G4OpenGLXmFramedBox (const char* n, 
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmMainMenubarCallbacks.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmMainMenubarCallbacks.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmMainMenubarCallbacks.cc	(revision 914)
@@ -43,4 +43,5 @@
 
 #include "G4OpenGLXmViewer.hh"
+#include "G4VSceneHandler.hh"
 
 #include "G4Scene.hh"
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmPanningCallbacks.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmPanningCallbacks.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmPanningCallbacks.cc	(revision 914)
@@ -40,4 +40,7 @@
 
 #include "G4OpenGLXmViewer.hh"
+#include "G4VSceneHandler.hh"
+#include <Xm/ToggleB.h>
+
 #include "G4Scene.hh"
 
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmPushButton.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmPushButton.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmPushButton.cc	(revision 914)
@@ -36,4 +36,6 @@
 #include "G4OpenGLXmPushButton.hh"
 #include <X11/Intrinsic.h>
+#include <Xm/PushB.h>
+
 #include "globals.hh"
 
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmRadioButton.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmRadioButton.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmRadioButton.cc	(revision 914)
@@ -36,4 +36,6 @@
 #include "G4OpenGLXmRadioButton.hh"
 #include <X11/Intrinsic.h>
+#include <Xm/ToggleB.h>
+
 #include "globals.hh"
 
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmSeparator.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmSeparator.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmSeparator.cc	(revision 914)
@@ -36,4 +36,6 @@
 #include "G4OpenGLXmSeparator.hh"
 #include <X11/Intrinsic.h>
+#include <Xm/Separator.h>
+
 #include "globals.hh"
 
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmTextField.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmTextField.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmTextField.cc	(revision 914)
@@ -34,6 +34,11 @@
 #include "G4OpenGLXmVWidgetComponent.hh"
 #include "G4OpenGLXmVWidgetContainer.hh"
+#include "G4OpenGLXmViewer.hh"
 #include "G4OpenGLXmTextField.hh"
+
 #include <X11/Intrinsic.h>
+#include <Xm/Label.h>
+#include <Xm/TextF.h>
+
 #include "globals.hh"
 
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmTopLevelShell.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmTopLevelShell.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmTopLevelShell.cc	(revision 914)
@@ -34,4 +34,8 @@
 #include "G4OpenGLXmTopLevelShell.hh"
 #include "G4OpenGLXmVWidgetContainer.hh"
+#include "G4OpenGLXmViewer.hh"
+
+#include <Xm/Frame.h>
+#include <Xm/RowColumn.h>
 
 G4OpenGLXmTopLevelShell::G4OpenGLXmTopLevelShell (G4OpenGLXmViewer* v,
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmVWidgetObject.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmVWidgetObject.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmVWidgetObject.cc	(revision 914)
@@ -33,4 +33,5 @@
 
 #include "G4OpenGLXmVWidgetObject.hh"
+#include "G4OpenGLXmViewer.hh"
 
 G4OpenGLXmVWidgetObject::G4OpenGLXmVWidgetObject ()
Index: trunk/source/visualization/OpenGL/src/G4OpenGLXmViewer.cc
===================================================================
--- trunk/source/visualization/OpenGL/src/G4OpenGLXmViewer.cc	(revision 912)
+++ trunk/source/visualization/OpenGL/src/G4OpenGLXmViewer.cc	(revision 914)
@@ -38,4 +38,5 @@
 
 #include "G4OpenGLXmViewer.hh"
+#include "G4OpenGLSceneHandler.hh"
 
 #include "G4VisExtent.hh"
