From 59c31fe149a5ec513b40010c8c811155c4bc7326 Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 21 Nov 2017 11:18:26 +0300 Subject: [PATCH] refs #1417: debug of dump view --- src/GraphicsView/GraphicsView_ViewPort.cxx | 17 +++++++++++++++-- src/SUIT/SUIT_ViewManager.cxx | 7 +++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/GraphicsView/GraphicsView_ViewPort.cxx b/src/GraphicsView/GraphicsView_ViewPort.cxx index de9a19d9e..9cafbd737 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.cxx +++ b/src/GraphicsView/GraphicsView_ViewPort.cxx @@ -462,13 +462,26 @@ QImage GraphicsView_ViewPort::dumpView( bool theWholeScene, bool GraphicsView_ViewPort::dumpViewToPSFormat(const QString& fileName) { QPrinter printer(QPrinter::HighResolution); + printer.setOutputFormat(QPrinter::PostScriptFormat); printer.setOutputFileName(fileName); QPainter painter; if (!painter.begin(&printer)) return false; - myScene->render(&painter); + + QRect view( 0, 0, printer.pageRect().width(), printer.paperRect().height() ); + QRectF bounds = myScene->itemsBoundingRect(); + + if( !view.isEmpty() && !bounds.isEmpty() ) + { + float SCALE = 0.5;//qMin( view.width()/bounds.width(), view.height()/bounds.height() ); + painter.setViewport( view ); + painter.scale( SCALE, SCALE ); + } + myScene->render( &painter, QRectF( view ), bounds ); + if (!painter.end()) - return false;; + return false; + return true; } //================================================================ diff --git a/src/SUIT/SUIT_ViewManager.cxx b/src/SUIT/SUIT_ViewManager.cxx index 85d50eb4f..89c950173 100755 --- a/src/SUIT/SUIT_ViewManager.cxx +++ b/src/SUIT/SUIT_ViewManager.cxx @@ -57,8 +57,11 @@ SUIT_ViewManager::SUIT_ViewManager( SUIT_Study* theStudy, myId = useNewId( getType() ); - connect( theDesktop, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), - this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); + if( theDesktop ) + { + connect( theDesktop, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), + this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); + } myStudy = theStudy; if ( myStudy ) -- 2.39.2