From 0441c9c12c10108cec812fcfd7bbc878cc39f7a0 Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 13 Apr 2006 11:09:06 +0000 Subject: [PATCH] Snapshot under Linux must don`t contain image of dialog --- src/Plot2d/Plot2d_ViewWindow.cxx | 4 ++-- src/Plot2d/Plot2d_ViewWindow.h | 2 +- src/SUIT/SUIT_ViewWindow.cxx | 15 ++++++++++----- src/SUIT/SUIT_ViewWindow.h | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 017e8fada..b91c1e345 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -452,11 +452,11 @@ QImage Plot2d_ViewWindow::dumpView() return px.convertToImage(); } -bool Plot2d_ViewWindow::dumpViewToFormat( const QString& fileName, const QString& format ) +bool Plot2d_ViewWindow::dumpViewToFormat( const QImage& im, const QString& fileName, const QString& format ) { bool res = myViewFrame ? myViewFrame->print( fileName, format ) : false; if( !res ) - res = SUIT_ViewWindow::dumpViewToFormat( fileName, format ); + res = SUIT_ViewWindow::dumpViewToFormat( im, fileName, format ); return res; } diff --git a/src/Plot2d/Plot2d_ViewWindow.h b/src/Plot2d/Plot2d_ViewWindow.h index ec0e5bf64..010359ee1 100755 --- a/src/Plot2d/Plot2d_ViewWindow.h +++ b/src/Plot2d/Plot2d_ViewWindow.h @@ -52,7 +52,7 @@ public: protected: virtual QImage dumpView(); virtual QString filter() const; - virtual bool dumpViewToFormat( const QString& fileName, const QString& format ); + virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format ); private: bool eventFilter(QObject* watched, QEvent* e); diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index 3b013f679..0579c4341 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -69,9 +69,8 @@ QImage SUIT_ViewWindow::dumpView() return QImage(); } -bool SUIT_ViewWindow::dumpViewToFormat( const QString& fileName, const QString& format ) +bool SUIT_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format ) { - QImage img = dumpView(); if( img.isNull() ) return false; @@ -107,8 +106,12 @@ void SUIT_ViewWindow::contextMenuEvent ( QContextMenuEvent * e ) */ void SUIT_ViewWindow::onDumpView() { - qApp->postEvent( this, new QPaintEvent( QRect( 0, 0, width(), height() ), TRUE ) ); - qApp->postEvent( this, new QCustomEvent( DUMP_EVENT ) ); + qApp->processEvents(); + qApp->sendEvent( this, new QPaintEvent( QRect( 0, 0, width(), height() ), TRUE ) ); + QImage im = dumpView(); + QCustomEvent* e = new QCustomEvent( DUMP_EVENT ); + e->setData( &im ); + qApp->sendEvent( this, e ); } QString SUIT_ViewWindow::filter() const @@ -131,7 +134,9 @@ bool SUIT_ViewWindow::event( QEvent* e ) if( !fileName.isEmpty() ) { QString fmt = SUIT_Tools::extension( fileName ).upper(); - bOk = dumpViewToFormat( fileName, fmt ); + QCustomEvent* ce = ( QCustomEvent* )e; + QImage* im = ( QImage* )ce->data(); + bOk = dumpViewToFormat( *im, fileName, fmt ); } else { diff --git a/src/SUIT/SUIT_ViewWindow.h b/src/SUIT/SUIT_ViewWindow.h index 200deb1c4..a04250ea6 100755 --- a/src/SUIT/SUIT_ViewWindow.h +++ b/src/SUIT/SUIT_ViewWindow.h @@ -48,7 +48,7 @@ public: bool event(QEvent*); virtual QImage dumpView(); - virtual bool dumpViewToFormat( const QString& fileName, const QString& format ); + virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format ); void onAccelAction( int ); -- 2.39.2