]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Dump to .pdf format(from BR_QT4_Dev)
authornds <nds@opencascade.com>
Thu, 3 Apr 2008 07:36:49 +0000 (07:36 +0000)
committernds <nds@opencascade.com>
Thu, 3 Apr 2008 07:36:49 +0000 (07:36 +0000)
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h

index 9dee3827dddcc2cf7971f1d2e5805f9fa92f4807..5e1895889fde7d0d7fc9bb5d3ae54e1c3a1ad867 100755 (executable)
 #include <vtkPointPicker.h>
 #include <vtkCellPicker.h>
 #include <vtkAxisActor2D.h>
+#include <vtkGL2PSExporter.h>
 
 #include "QtxAction.h"
 
 #include "SUIT_Session.h"
 #include "SUIT_MessageBox.h"
 #include "SUIT_Accel.h"
-
 #include "SUIT_Tools.h"
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_Accel.h"
+#include "SUIT_OverrideCursor.h"
 
 #include "VTKViewer_Utilities.h"
 
@@ -719,6 +720,45 @@ SVTK_ViewWindow
   return myDumpImage;
 }
 
+QString SVTK_ViewWindow::filter() const
+{
+  return tr( "SVTK_IMAGE_FILES" );
+}
+
+bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format )
+{
+  if ( format != "PS" && format != "EPS" && format != "PDF" )
+    return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
+
+  SUIT_OverrideCursor wc;
+
+  vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
+  anExporter->SetRenderWindow(getRenderWindow());
+
+  if ( format == "PS" ) {
+    anExporter->SetFileFormatToPS();
+    anExporter->CompressOff();
+  }
+
+  if ( format == "EPS" ) {
+    anExporter->SetFileFormatToEPS();
+    anExporter->CompressOff();
+  }
+
+  if ( format == "PDF" ) {
+    anExporter->SetFileFormatToPDF();
+  }
+
+  QString aFilePrefix(fileName);
+  QString anExtension(SUIT_Tools::extension(fileName));
+  aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
+  anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
+  anExporter->Write();
+  anExporter->Delete();
+
+  return true;
+}
+
 /*!
   \refresh QImage, containing all scene rendering in window
 */
index 86c46a116355e42be07425343e0b9610929fc971..f0c756ae5178d22c82dece1137c0e84dbccc352f 100755 (executable)
@@ -65,6 +65,8 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
   virtual
   ~SVTK_ViewWindow();
   
+  virtual QImage dumpView();
+
   //! To initialize #SVTK_ViewWindow instance
   virtual
   void
@@ -350,7 +352,9 @@ protected:
   void
   doSetVisualParameters( const QString& );
 
-  QImage dumpView();
+  virtual QString filter() const;
+  virtual bool dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format );
+  
   virtual bool action( const int );
   
   SVTK_View* myView;