From fbef1a51306eef19e614f6bfa295213f81e3006c Mon Sep 17 00:00:00 2001 From: jfa Date: Fri, 24 Jun 2005 11:56:48 +0000 Subject: [PATCH] Provide SavePicture functionality --- src/VISU_I/VISU_View_i.cc | 86 ++++++++++++++++++++------------------- src/VISU_I/VISU_View_i.hh | 4 -- 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index 73b1d60b..6615e8e4 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -45,8 +45,9 @@ #include "SVTK_ViewWindow.h" #include "SVTK_ViewModel.h" -#include "SPlot2d_ViewModel.h" +#include "SVTK_RenderWindow.h" +#include "SPlot2d_ViewModel.h" #include "Plot2d_ViewFrame.h" #include "Plot2d_ViewModel.h" @@ -537,10 +538,43 @@ namespace VISU{ Update() {} + class TSavePictureEvent: public SALOME_Event + { + SUIT_ViewWindow * myViewWindow; + const char * myFileName; + public: + typedef CORBA::Boolean TResult; + TResult myResult; + TSavePictureEvent (SUIT_ViewWindow * theViewWindow, const char * theFileName) + : myViewWindow(theViewWindow), + myFileName(theFileName), + myResult(false) + { + } + + virtual void Execute() + { + if (myViewWindow) { + QImage img = myViewWindow->dumpView(); + if (!img.isNull()) { + QString fileName (myFileName); + if (!fileName.isEmpty()) { + QString fmt = SUIT_Tools::extension(fileName).upper(); + if (fmt.isEmpty()) fmt = QString("BMP"); // default format + if (fmt == "JPG" ) fmt = "JPEG"; + //QApplication::setOverrideCursor(Qt::waitCursor); + img.save(fileName, fmt.latin1()); + //QApplication::restoreOverrideCursor(); + } + } + } + } + }; + CORBA::Boolean View_i::SavePicture(const char* theFileName) { - return false; + return ProcessEvent(new TSavePictureEvent (myViewWindow,theFileName)); } const char* @@ -575,37 +609,6 @@ namespace VISU{ // return aStudy; //} - class TSavePictureEvent: public SALOME_Event - { - QWidget* myWidget; - const char* myFileName; - public: - typedef CORBA::Boolean TResult; - TResult myResult; - TSavePictureEvent (QWidget* theWidget, const char* theFileName) - : myWidget(theWidget), - myFileName(theFileName), - myResult(false) - { - } - - virtual void Execute() - { - if (myWidget) { - QPixmap px = QPixmap::grabWindow(myWidget->winId()); - if (!QString(myFileName).isNull()) { - QString fmt = SUIT_Tools::extension(myFileName).upper(); - if (fmt.isEmpty()) - fmt = QString("BMP"); // default format - if (fmt == "JPG") - fmt = "JPEG"; - myResult = px.save(myFileName, fmt.latin1()); - } - } - } - }; - - //=========================================================================== XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication) : View_i(theApplication, NULL) @@ -909,10 +912,10 @@ namespace VISU{ ProcessVoidEvent(new TVoidMemFunEvent (myView,&Plot2d_ViewFrame::fitAll)); } - CORBA::Boolean XYPlot_i::SavePicture (const char* theFileName) - { - return ProcessEvent(new TSavePictureEvent (myView->getViewWidget(),theFileName)); - } + //CORBA::Boolean XYPlot_i::SavePicture (const char* theFileName) + //{ + // return ProcessEvent(new TSavePictureEvent (myView->getViewWidget(),theFileName)); + //} //=========================================================================== @@ -1033,11 +1036,10 @@ namespace VISU{ ProcessVoidEvent(new TEvent(myViewWindow)); } - CORBA::Boolean View3D_i::SavePicture (const char* theFileName) - { - //jfa tmp:return ProcessEvent(new TSavePictureEvent(myView->getViewWidget(), theFileName)); - return false; - } + //CORBA::Boolean View3D_i::SavePicture (const char* theFileName) + //{ + // return ProcessEvent(new TSavePictureEvent(myViewWindow, theFileName)); + //} bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName) { diff --git a/src/VISU_I/VISU_View_i.hh b/src/VISU_I/VISU_View_i.hh index 4dd18f32..af96f2f4 100644 --- a/src/VISU_I/VISU_View_i.hh +++ b/src/VISU_I/VISU_View_i.hh @@ -141,8 +141,6 @@ namespace VISU virtual void DisplayOnly (PrsObject_ptr thePrsObj); virtual void Update(); - virtual CORBA::Boolean SavePicture (const char* theFileName); - virtual void FitAll(); virtual void Close(); @@ -204,8 +202,6 @@ namespace VISU virtual void DisplayOnly (PrsObject_ptr thePrsObj); virtual void Update(); - virtual CORBA::Boolean SavePicture (const char* theFileName); - //View3D interface virtual void FitAll(); virtual void SetView (VISU::View3D::ViewType theType); -- 2.39.2