Index: /trunk/geant4/visualization/G4History.macro
===================================================================
--- /trunk/geant4/visualization/G4History.macro	(revision 585)
+++ /trunk/geant4/visualization/G4History.macro	(revision 586)
@@ -59,2 +59,3 @@
 /gui/addButton viewer "Update scene" "/vis/scene/notifyHandlers"
 /N03/event/printModulo 100
+/run/beamOn 1
Index: /trunk/geant4/visualization/OpenGL/include/G4OpenGLQtExportDialog.hh
===================================================================
--- /trunk/geant4/visualization/OpenGL/include/G4OpenGLQtExportDialog.hh	(revision 585)
+++ /trunk/geant4/visualization/OpenGL/include/G4OpenGLQtExportDialog.hh	(revision 586)
@@ -58,4 +58,6 @@
   int getWidth();
   int getHeight();
+  int getTransparency();
+  int getNbColor();
 
 public slots:
@@ -74,6 +76,5 @@
   QPushButton* buttonOk;
   QPushButton* buttonCancel;
-  //  QButtonGroup* GroupBox1, *GroupBox2;
-  QCheckBox* boxEPS,*boxTransparency;
+  QCheckBox* transparencyEPS,*boxTransparency;
   QCheckBox* ratioCheckBox;
   QSlider * qualitySlider;
Index: /trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
===================================================================
--- /trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh	(revision 585)
+++ /trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh	(revision 586)
@@ -48,4 +48,5 @@
 #include <QMenu>
 #include <QPoint>
+#include <QImage>
 
 class G4OpenGLSceneHandler;
@@ -79,5 +80,6 @@
   void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
   void rescaleImage(int, int);
-  
+  int generateEPS(QString,int,QImage);  
+
   QMenu *fContextMenu;
   bool fMouseAction; // 1: rotate 0:move
Index: /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtExportDialog.cc
===================================================================
--- /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtExportDialog.cc	(revision 585)
+++ /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtExportDialog.cc	(revision 586)
@@ -92,7 +92,7 @@
     QVBoxLayout *EPSGroupBoxLayout = new QVBoxLayout;
 
-    boxEPS = new QCheckBox( "boxEPS" );
-    boxEPS->setText( "save background" );
-    boxEPS->setChecked( true );
+    transparencyEPS = new QCheckBox( "transparencyEPS" );
+    transparencyEPS->setText( "save background" );
+    transparencyEPS->setChecked( true );
 
     color = new QRadioButton("Color");
@@ -100,10 +100,7 @@
     color->setChecked( true );
     BW->setChecked( false );
-    
-    connect( color, SIGNAL( toggled(bool) ), BW, SLOT( setChecked(bool) ) );
-    connect( BW, SIGNAL( toggled(bool) ), color, SLOT( setChecked(bool) ) );
-
-
-    EPSGroupBoxLayout->addWidget(boxEPS);    
+
+
+    EPSGroupBoxLayout->addWidget(transparencyEPS);    
     EPSGroupBoxLayout->addWidget(color);    
     EPSGroupBoxLayout->addWidget(BW);    
@@ -157,7 +154,6 @@
   ratioCheckBox->setVisible(modify->isChecked());
 
-  connect( original, SIGNAL( toggled(bool) ), modify, SLOT( setChecked(bool) ) );
-  connect( modify, SIGNAL( toggled(bool) ), original, SLOT( setChecked(bool) ) );
-  connect( modify, SIGNAL( toggled(bool) ), this, SLOT( changeSizeBox(bool) ) );
+  connect( original, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(true)) );
+  connect( modify, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(false) ) );
 
   // height
@@ -235,10 +231,35 @@
 }
 
-
-void G4OpenGLQtExportDialog::changeSizeBox(bool aChange)
-{
-  heightWidget->setVisible(modify->isChecked());
-  widthWidget->setVisible(modify->isChecked());
-  ratioCheckBox->setVisible(modify->isChecked());
+int G4OpenGLQtExportDialog::getTransparency()
+{
+  return boxTransparency->isChecked();
+}
+
+int G4OpenGLQtExportDialog::getColorValue()
+{
+  if (!color->isChecked())
+    return 1;
+  if (color->isChecked() && transparencyEPS->isChecked())
+    return 4;
+  return 3;
+}
+
+
+void G4OpenGLQtExportDialog::changeSizeBox(bool aClick)
+{
+  if (aClick) {
+    modify->toggle();
+  } else {
+    original->toggle();
+  }
+  if ( original->isChecked()) {
+    heightWidget->setVisible(false);
+    widthWidget->setVisible(false);
+    ratioCheckBox->setVisible(false);
+  } else {
+    heightWidget->setVisible(true);
+    widthWidget->setVisible(true);
+    ratioCheckBox->setVisible(true);
+  }
 }
 
Index: /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
===================================================================
--- /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 585)
+++ /trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc	(revision 586)
@@ -659,9 +659,10 @@
   QList<QByteArray> formats =  QImageWriter::supportedImageFormats ();
   for (int i = 0; i < formats.size(); ++i) {
-    filters +=formats.at(i);
-    if ((i+1) <formats.size()) {
-      filters += ";;";
-    }
-  }
+    filters +=formats.at(i)+";;";
+    //    if ((i+1) <formats.size()) {
+    //      filters += ";;";
+    //    }
+  }
+  filters += "eps";
   QString* selectedFilter = new QString();
   QString nomFich =  QFileDialog::getSaveFileName ( GLWindow,
@@ -680,7 +681,9 @@
     
     printf("rescaling before\n");
-    QPixmap * pixmap = new QPixmap(fWindow->renderPixmap (exportDialog->getWidth(),exportDialog->getHeight() )) ;//fWindow->grabFrameBuffer();
+    //    QPixmap * pixmap = new QPixmap(fWindow->renderPixmap (exportDialog->getWidth(),exportDialog->getHeight() )) ;
+    QImage image = fWindow->grabFrameBuffer();
     printf("rescaling after\n");
       
+    
     if ((exportDialog->getWidth() !=fWindow->width()) ||
          (exportDialog->getWidth() !=fWindow->width())) {
@@ -694,8 +697,8 @@
         nomFich.endsWith(".jpeg")) {
       // grabFrameBuffer() :: Returns an image of the frame buffer. If withAlpha is true the alpha channel is included.
-      pixmap->save(nomFich,0,exportDialog->getSliderValue());
+      image.save(nomFich,0,exportDialog->getSliderValue());
       printf("saving jpeg quality : %d\n",exportDialog->getSliderValue());
     } else if (nomFich.endsWith(".eps")) {
-      printf("saving EPS\n");
+      generateEPS(nomFich,exportDialog->getNbColor(),image);
     } else if (nomFich.endsWith(".tif") ||
                nomFich.endsWith(".tiff") ||
@@ -704,5 +707,5 @@
                nomFich.endsWith(".bmp") ||
                nomFich.endsWith(".xpm")) {
-      pixmap->save(nomFich,0,exportDialog->getSliderValue());
+      image.save(nomFich,0,exportDialog->getSliderValue());
       printf("saving ELSE\n");
     } else {
@@ -940,5 +943,88 @@
 ,int aHeight
 ){
-  printf("");
+  printf("should rescale \n");
+}
+
+/**
+   Generate Postscript form image
+   @param aFilename : name of file
+   @param aInColor : numbers of colors : 1->BW 2->RGB 3->RGB+Alpha
+   @param aImage : Image to print
+*/
+int G4OpenGLQtViewer::generateEPS (
+ QString aFilename
+,int aInColor
+,QImage aImage
+)
+{
+  
+  printf("saving EPS\n");
+
+  FILE* fp;
+  
+  const uchar * pixels = aImage.bits ();
+    //  pixels = grabPixels (inColour, width, height);
+    
+  if (pixels == NULL)
+    return 1;
+  
+  fp = fopen (aFilename.toStdString().c_str(), "w");
+  if (fp == NULL) {
+    return 2;
+  }
+  
+  fprintf (fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
+  fprintf (fp, "%%%%Title: %s\n", aFilename.toStdString().c_str());
+  fprintf (fp, "%%%%Creator: OpenGL pixmap render output\n");
+  fprintf (fp, "%%%%BoundingBox: 0 0 %d %d\n", fWindow->width(), fWindow->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", fWindow->width() * aInColor);
+  fprintf (fp, "%d %d scale\n", fWindow->width(), fWindow->height());
+  fprintf (fp, "%d %d %d\n", fWindow->width(), fWindow->height(), 8);
+  fprintf (fp, "[%d 0 0 %d 0 0]\n", fWindow->width(), fWindow->height());
+  fprintf (fp, "{currentfile picstr readhexstring pop}\n");
+  fprintf (fp, "false %d\n", aInColor);
+  //  fprintf (fp, "%%BeginData:       %d ASCII Bytes\n",size);
+  fprintf (fp, "colorimage\n");
+  
+  printf("boucle jusque :%d/%d par ligne:%d \n",fWindow->width()*fWindow->height()*aInColor,aImage.numBytes(),aImage.bytesPerLine ());
+
+  int pos =0;
+  for (int i = 0;i<fWindow->width()*fWindow->height()*aInColor; i++) {
+    fprintf (fp, "%02hx ", pixels[i]);
+    if (++pos >= aImage.bytesPerLine ()) {
+      fprintf (fp, "\n");
+      pos = 0; 
+    }
+  }
+  
+  if (pos)
+    fprintf (fp, "\n");
+  
+  fprintf (fp, "grestore\n");
+  fprintf (fp, "showpage\n");
+  //  delete pixels;
+  fclose (fp);
+  return 0;
 }
 #endif
