Skip to content
Permalink
Browse files

[composer] Make sure entire page symbol border is included when expor…

…ting compositions. Previously half the page border would be cropped out. Also fix nIRV's infamous 1px bad row at bottom of composer exports bug.
  • Loading branch information
nyalldawson committed Jan 4, 2014
1 parent b5502b6 commit 6d918a1acfba1f559c7ed79cc27d824199852886
Showing with 19 additions and 3 deletions.
  1. +16 −3 src/core/composer/qgspaperitem.cpp
  2. +3 −0 src/core/composer/qgspaperitem.h
@@ -128,13 +128,13 @@ QgsPaperItem::QgsPaperItem( QgsComposition* c ): QgsComposerItem( c, false ),
}

QgsPaperItem::QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition ): QgsComposerItem( x, y, width, height, composition, false ),
mPageGrid( 0 )
mPageGrid( 0 ), mPageMargin( 0 )
{
initialize();
}

QgsPaperItem::QgsPaperItem(): QgsComposerItem( 0, false ),
mPageGrid( 0 )
mPageGrid( 0 ), mPageMargin( 0 )
{
initialize();
}
@@ -167,15 +167,28 @@ void QgsPaperItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* ite

painter->save();
painter->setRenderHint( QPainter::Antialiasing );
QPolygonF pagePolygon = QPolygonF( QRectF( 0, 0, rect().width(), rect().height() ) );
mComposition->pageStyleSymbol()->startRender( context );

calculatePageMargin();
QPolygonF pagePolygon = QPolygonF( QRectF( mPageMargin, mPageMargin, rect().width() - 2 * mPageMargin, rect().height() - 2 * mPageMargin ) );
QList<QPolygonF> rings; //empty list
mComposition->pageStyleSymbol()->renderPolygon( pagePolygon, &rings, 0, context );
mComposition->pageStyleSymbol()->stopRender( context );
painter->restore();

}

void QgsPaperItem::calculatePageMargin()
{
//get max bleed from symbol
double maxBleed = QgsSymbolLayerV2Utils::estimateMaxSymbolBleed( mComposition->pageStyleSymbol() );

//Now subtract 1 pixel to prevent semi-transparent borders at edge of solid page caused by
//anti-aliased painting. This may cause a pixel to be cropped from certain edge lines/symbols,
//but that can be counteracted by adding a dummy transparent line symbol layer with a wider line width
mPageMargin = maxBleed - ( 25.4 / mComposition->printResolution() );
}

bool QgsPaperItem::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
Q_UNUSED( elem );
@@ -69,7 +69,10 @@ class CORE_EXPORT QgsPaperItem: public QgsComposerItem
/**Set flags and z-value*/
void initialize();

void calculatePageMargin();

QgsPaperGrid* mPageGrid;
double mPageMargin;
};

#endif

0 comments on commit 6d918a1

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