From: nds Date: Thu, 3 Apr 2008 07:36:49 +0000 (+0000) Subject: Dump to .pdf format(from BR_QT4_Dev) X-Git-Tag: TG_ACHERON_2008-04-13~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e36ecd6b75fe1a77cf66bff244ee6657a997b62e;p=modules%2Fgui.git Dump to .pdf format(from BR_QT4_Dev) --- diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 9dee3827d..5e1895889 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -29,16 +29,17 @@ #include #include #include +#include #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 */ diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 86c46a116..f0c756ae5 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -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;