X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSUIT%2FSUIT_ViewWindow.cxx;h=7886b415bfbb19adff3cec5d40e9d812be3d9d6f;hb=3b3dce973acb7299499dd3527ded627940516ab3;hp=4eb47e3ef6706bef2dfbbaba7600eff1bd926413;hpb=2e750f9ded92337bc3c44e9d7388180974cc4a43;p=modules%2Fgui.git diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index 4eb47e3ef..7886b415b 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -4,8 +4,18 @@ #include "SUIT_ViewWindow.h" #include "SUIT_Desktop.h" +#include "SUIT_Application.h" +#include "SUIT_Study.h" +#include "SUIT_ViewManager.h" +#include "SUIT_Tools.h" +#include "SUIT_MessageBox.h" #include "qhbox.h" #include "qpopupmenu.h" +#include "qapplication.h" + +// Dump view custom event +const int DUMP_EVENT = QEvent::User + 123; + ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// @@ -33,3 +43,44 @@ void SUIT_ViewWindow::contextMenuEvent ( QContextMenuEvent * e ) if ( e->reason() != QContextMenuEvent::Mouse ) emit contextMenuRequested( e ); } + +//**************************************************************** +void SUIT_ViewWindow::onDumpView() +{ + qApp->postEvent( this, new QPaintEvent( QRect( 0, 0, width(), height() ), TRUE ) ); + qApp->postEvent( this, new QCustomEvent( DUMP_EVENT ) ); +} + +//**************************************************************** +bool SUIT_ViewWindow::event( QEvent* e ) +{ + if ( e->type() == DUMP_EVENT ) { + bool bOk = false; + if ( myManager && myManager->study() && myManager->study()->application() ) { + // first create an image (this is small trick to avoid dialog box overlapping) + QImage img = dumpView(); + if ( !img.isNull() ) { + // get file name + QString fileName = myManager->study()->application()->getFileName( false, QString::null, tr( "TLT_IMAGE_FILES" ), tr( "TLT_DUMP_VIEW" ), 0 ); + 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 ); + bOk = img.save( fileName, fmt.latin1() ); + QApplication::restoreOverrideCursor(); + } + else { + bOk = true; // cancelled + } + } + } + if ( !bOk ) { + SUIT_MessageBox::error1( this, tr( "ERROR" ), tr( "ERR_CANT_DUMP_VIEW" ), tr( "BUT_OK" ) ); + } + return TRUE; + } + return QMainWindow::event( e ); +} + +//****************************************************************