Skip to content
Permalink
Browse files

Fix calculation of layout bounds considers page shadow

  • Loading branch information
nyalldawson committed Jul 25, 2017
1 parent cdb0ace commit e444f00cc5633c4e0616ff099960836565cb938e
Showing with 16 additions and 6 deletions.
  1. +12 −2 src/core/layout/qgslayout.cpp
  2. +4 −4 tests/src/core/testqgslayout.cpp
@@ -138,10 +138,20 @@ QRectF QgsLayout::layoutBounds( bool ignorePages, double margin ) const
if ( !isPage || !ignorePages )
{
//expand bounds with current item's bounds
QRectF itemBounds;
if ( isPage )
{
// for pages we only consider the item's rect - not the bounding rect
// as the bounding rect contains extra padding
itemBounds = layoutItem->mapToScene( layoutItem->rect() ).boundingRect();
}
else
itemBounds = item->sceneBoundingRect();

if ( bounds.isValid() )
bounds = bounds.united( item->sceneBoundingRect() );
bounds = bounds.united( itemBounds );
else
bounds = item->sceneBoundingRect();
bounds = itemBounds;
}
}

@@ -292,10 +292,10 @@ void TestQgsLayout::bounds()
QGSCOMPARENEAR( compositionBoundsNoPage.top(), 49.79, 0.01 );
#endif

QGSCOMPARENEAR( layoutBounds.height(), 211.000000, 0.01 );
QGSCOMPARENEAR( layoutBounds.width(), 298.000000, 0.01 );
QGSCOMPARENEAR( layoutBounds.left(), -0.500000, 0.01 );
QGSCOMPARENEAR( layoutBounds.top(), -0.500000, 0.01 );
QGSCOMPARENEAR( layoutBounds.height(), 210.000000, 0.01 );
QGSCOMPARENEAR( layoutBounds.width(), 297.000000, 0.01 );
QGSCOMPARENEAR( layoutBounds.left(), 0.00000, 0.01 );
QGSCOMPARENEAR( layoutBounds.top(), 0.00000, 0.01 );

QRectF compositionBoundsNoPage = l.layoutBounds( true );
QGSCOMPARENEAR( compositionBoundsNoPage.height(), 175.704581, 0.01 );

0 comments on commit e444f00

Please sign in to comment.
You can’t perform that action at this time.