From 3c6118c009cfd611afbc7619edc481fdbca651d3 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 6 Nov 2007 12:19:20 +0000 Subject: [PATCH] Fix for Bug N7PAL15810 VISU formats of exit --- src/SVTK/SVTK_ViewWindow.cxx | 41 +++++++++++++++++++++++++++++++ src/SVTK/SVTK_ViewWindow.h | 6 ++++- src/SVTK/resources/SVTK_msg_en.po | 2 ++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index af9841baa..56317d592 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include "QtxAction.h" @@ -718,6 +719,46 @@ 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 ); + + QApplication::setOverrideCursor( Qt::waitCursor ); + + 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.latin1()); + anExporter->Write(); + anExporter->Delete(); + + QApplication::restoreOverrideCursor(); + 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 14b79945b..dca18f085 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -68,6 +68,8 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow virtual ~SVTK_ViewWindow(); + virtual QImage dumpView(); + //! To initialize #SVTK_ViewWindow instance virtual void @@ -354,7 +356,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; diff --git a/src/SVTK/resources/SVTK_msg_en.po b/src/SVTK/resources/SVTK_msg_en.po index 609f62c2b..6e5f620d3 100755 --- a/src/SVTK/resources/SVTK_msg_en.po +++ b/src/SVTK/resources/SVTK_msg_en.po @@ -314,3 +314,5 @@ msgstr "Current Update Rate, FPS" msgid "SVTK_UpdateRateDlg::NUMBER_CELLS" msgstr "Number of Cells, -" +msgid "SVTK_IMAGE_FILES" +msgstr "Images Files (*.bmp *.png *.jpg *.jpeg *.pdf *.ps *.eps)"" \ No newline at end of file -- 2.39.2