From b9e0543850edc5039d5cd610e10e975df42b6511 Mon Sep 17 00:00:00 2001 From: mzn Date: Wed, 16 Aug 2006 15:33:02 +0000 Subject: [PATCH] Fix for bug PAL12468(When dumping a VTK view, the dialog box appears in the saved image). --- src/Plot2d/Plot2d_ViewModel.cxx | 1 + src/Plot2d/Plot2d_ViewWindow.cxx | 21 ++++++++++++++++++--- src/Plot2d/Plot2d_ViewWindow.h | 6 ++++++ src/SVTK/SVTK_ViewModel.cxx | 1 + src/SVTK/SVTK_ViewWindow.cxx | 16 ++++++++++++++-- src/SVTK/SVTK_ViewWindow.h | 10 +++++++++- 6 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/Plot2d/Plot2d_ViewModel.cxx b/src/Plot2d/Plot2d_ViewModel.cxx index 3d268e1c4..e689f6ef5 100755 --- a/src/Plot2d/Plot2d_ViewModel.cxx +++ b/src/Plot2d/Plot2d_ViewModel.cxx @@ -76,6 +76,7 @@ void Plot2d_Viewer::contextMenuPopup(QPopupMenu* thePopup) if (thePopup->count() > 0) thePopup->insertSeparator(); thePopup->insertItem("Show toolbar", this, SLOT(onShowToolbar())); } + aView->RefreshDumpImage(); } } diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index e562e30dc..1fdf78431 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -33,7 +33,6 @@ #include #include #include -#include /*! Constructor @@ -43,6 +42,8 @@ Plot2d_ViewWindow::Plot2d_ViewWindow(SUIT_Desktop* theDesktop, Plot2d_Viewer* th { myModel = theModel; + myDumpImage = QImage(); + myViewFrame = new Plot2d_ViewFrame(this, "plotView"); setCentralWidget(myViewFrame); @@ -491,8 +492,13 @@ void Plot2d_ViewWindow::onDumpView() */ QImage Plot2d_ViewWindow::dumpView() { - QPixmap px = QPixmap::grabWindow( myViewFrame->winId() ); - return px.convertToImage(); + if ( getToolBar()->hasMouse() || myDumpImage.isNull() ) + { + QPixmap px = QPixmap::grabWindow( myViewFrame->winId() ); + return px.convertToImage(); + } + + return myDumpImage; } /*! @@ -532,3 +538,12 @@ void Plot2d_ViewWindow::setVisualParameters( const QString& parameters ) { myViewFrame->setVisualParameters( parameters ); } + +/*! + \refresh QImage, containing all scene rendering in window +*/ +void Plot2d_ViewWindow::RefreshDumpImage() +{ + QPixmap px = QPixmap::grabWindow( myViewFrame->winId() ); + myDumpImage = px.convertToImage(); +} diff --git a/src/Plot2d/Plot2d_ViewWindow.h b/src/Plot2d/Plot2d_ViewWindow.h index b8c3718d3..aa1d4dd62 100755 --- a/src/Plot2d/Plot2d_ViewWindow.h +++ b/src/Plot2d/Plot2d_ViewWindow.h @@ -22,6 +22,8 @@ #include "Plot2d.h" #include +#include + #ifdef WIN32 #pragma warning( disable:4251 ) #endif @@ -48,6 +50,8 @@ public: virtual QString getVisualParameters(); virtual void setVisualParameters( const QString& parameters ); + + virtual void RefreshDumpImage(); protected: virtual QImage dumpView(); @@ -94,6 +98,8 @@ private: QToolBar* myToolBar; SUIT_ToolButton* myCurveBtn; + + QImage myDumpImage; }; #ifdef WIN32 diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 61cde9d5b..4a1722242 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -197,6 +197,7 @@ SVTK_Viewer if ( !aView->getMainWindow()->getToolBar()->isVisible() ){ thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); } + aView->RefreshDumpImage(); } } diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 3fee43d8e..529db8ce1 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -68,7 +68,8 @@ SVTK_ViewWindow ::SVTK_ViewWindow(SUIT_Desktop* theDesktop): SUIT_ViewWindow(theDesktop), myMainWindow(NULL), - myView(NULL) + myView(NULL), + myDumpImage(QImage()) {} /*! @@ -684,8 +685,19 @@ SVTK_ViewWindow QImage SVTK_ViewWindow ::dumpView() +{ + if ( myMainWindow->getToolBar()->hasMouse() || myDumpImage.isNull() ) + return myMainWindow->dumpView(); + + return myDumpImage; +} + +/*! + \refresh QImage, containing all scene rendering in window +*/ +void SVTK_ViewWindow::RefreshDumpImage() { - return myMainWindow->dumpView(); + myDumpImage = myMainWindow->dumpView(); } /*! diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 7a592578b..cc56484de 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -28,6 +28,8 @@ #include "SUIT_ViewWindow.h" #include "SALOME_InteractiveObject.hxx" +#include + class SUIT_Desktop; class VTKViewer_Actor; @@ -255,6 +257,9 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow virtual bool eventFilter( QObject*, QEvent* ); + + virtual + void RefreshDumpImage(); public slots: virtual @@ -344,12 +349,15 @@ protected: QImage dumpView(); virtual bool action( const int ); - + SVTK_View* myView; SVTK_MainWindow* myMainWindow; SVTK_ViewModelBase* myModel; QString myVisualParams; // used for delayed setting of view parameters + +private: + QImage myDumpImage; }; #ifdef WIN32 -- 2.39.2