// Function : dumpView
// Purpose :
//================================================================
-QImage GraphicsView_ViewPort::dumpView( bool theWholeScene )
+QImage GraphicsView_ViewPort::dumpView( bool theWholeScene,
+ QSizeF theSize )
{
if( !theWholeScene ) // just grab the view contents
{
if( aRect.isNull() )
return QImage();
+ QRectF aTargetRect( 0, 0, aRect.width(), aRect.height() );
+ if( theSize.isValid() )
+ {
+ double aRatioX = theSize.width() / aTargetRect.width();
+ double aRatioY = theSize.height() / aTargetRect.height();
+ double aRatio = qMin( aRatioX, aRatioY );
+ aTargetRect.setWidth( aTargetRect.width() * aRatio );
+ aTargetRect.setHeight( aTargetRect.height() * aRatio );
+ }
+
// render the scene to an image
- QImage anImage( aRect.toRect().size(), QImage::Format_RGB32 );
+ QImage anImage( aTargetRect.toRect().size(), QImage::Format_RGB32 );
QPainter aPainter( &anImage );
- QRectF aTargetRect( 0, 0, aRect.width(), aRect.height() );
+ aPainter.setRenderHints( renderHints() );
+
myScene->render( &aPainter, aTargetRect, aRect );
return anImage;
QRectF objectsBoundingRect( bool theOnlyVisible = false ) const;
- QImage dumpView( bool theWholeScene = false );
+ QImage dumpView( bool theWholeScene = false,
+ QSizeF theSize = QSizeF() );
public:
// scene