mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -05:00
Snapshot work in progress
This commit is contained in:
1 parent
361b4bc3db
commit
52df6fd283
20 files changed
+103
-89
No files matched your search
@@ -651,7 +651,7 @@ QImage RimMultiPlot::captureSnapshot( int width, int height )
|
||||
|
||||
QSize orgViewSize = m_viewer->size();
|
||||
|
||||
image = captureImage( m_viewer->bookWidget(), width, height );
|
||||
image = RimViewWindow::captureSnapshot( m_viewer->bookWidget(), width, height );
|
||||
|
||||
m_viewer->resize( orgViewSize );
|
||||
doUpdateLayout();
|
||||
|
||||
@@ -228,19 +228,28 @@ QImage RimViewWindow::snapshotWindowContent()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QImage RimViewWindow::captureSnapshot( int width, int height )
|
||||
{
|
||||
return captureImage( viewWidget(), width, height );
|
||||
return captureSnapshot( viewWidget(), width, height );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QImage RimViewWindow::captureImage( QWidget* widget, int width, int height )
|
||||
QImage RimViewWindow::captureSnapshot( QWidget* widget, int width, int height )
|
||||
{
|
||||
if ( !widget ) return QImage();
|
||||
|
||||
QSize orgSize = widget->size();
|
||||
bool shouldResize = width > 0 && height > 0 && ( widget->width() != width || widget->height() != height );
|
||||
|
||||
widget->setFixedSize( width, height );
|
||||
QSize orgSize = widget->size();
|
||||
if ( shouldResize )
|
||||
{
|
||||
widget->setFixedSize( width, height );
|
||||
}
|
||||
else
|
||||
{
|
||||
width = widget->width();
|
||||
height = widget->height();
|
||||
}
|
||||
|
||||
QPixmap pix( width, height );
|
||||
pix.fill( Qt::transparent );
|
||||
@@ -248,10 +257,12 @@ QImage RimViewWindow::captureImage( QWidget* widget, int width, int height )
|
||||
QPainter painter( &pix );
|
||||
widget->render( &painter );
|
||||
|
||||
// reset fixed size and restore original size
|
||||
widget->setMinimumSize( 0, 0 );
|
||||
widget->setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
|
||||
widget->resize( orgSize );
|
||||
if ( shouldResize )
|
||||
{
|
||||
widget->setMinimumSize( 0, 0 );
|
||||
widget->setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
|
||||
widget->resize( orgSize );
|
||||
}
|
||||
|
||||
return pix.toImage();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <QImage>
|
||||
|
||||
class RimDockWindowController;
|
||||
|
||||
namespace ads
|
||||
@@ -101,7 +103,7 @@ protected:
|
||||
|
||||
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
QImage captureImage( QWidget* widget, int width, int height );
|
||||
QImage captureSnapshot( QWidget* widget, int width, int height );
|
||||
|
||||
private:
|
||||
friend class RimProject;
|
||||
|
||||
Reference in new issue
Block a user