Skip to content

Commit 6d918a1

Browse files
committedJan 4, 2014
[composer] Make sure entire page symbol border is included when exporting compositions. Previously half the page border would be cropped out. Also fix nIRV's infamous 1px bad row at bottom of composer exports bug.
1 parent b5502b6 commit 6d918a1

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed
 

‎src/core/composer/qgspaperitem.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ QgsPaperItem::QgsPaperItem( QgsComposition* c ): QgsComposerItem( c, false ),
128128
}
129129

130130
QgsPaperItem::QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition ): QgsComposerItem( x, y, width, height, composition, false ),
131-
mPageGrid( 0 )
131+
mPageGrid( 0 ), mPageMargin( 0 )
132132
{
133133
initialize();
134134
}
135135

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

168168
painter->save();
169169
painter->setRenderHint( QPainter::Antialiasing );
170-
QPolygonF pagePolygon = QPolygonF( QRectF( 0, 0, rect().width(), rect().height() ) );
171170
mComposition->pageStyleSymbol()->startRender( context );
171+
172+
calculatePageMargin();
173+
QPolygonF pagePolygon = QPolygonF( QRectF( mPageMargin, mPageMargin, rect().width() - 2 * mPageMargin, rect().height() - 2 * mPageMargin ) );
172174
QList<QPolygonF> rings; //empty list
173175
mComposition->pageStyleSymbol()->renderPolygon( pagePolygon, &rings, 0, context );
174176
mComposition->pageStyleSymbol()->stopRender( context );
175177
painter->restore();
176178

177179
}
178180

181+
void QgsPaperItem::calculatePageMargin()
182+
{
183+
//get max bleed from symbol
184+
double maxBleed = QgsSymbolLayerV2Utils::estimateMaxSymbolBleed( mComposition->pageStyleSymbol() );
185+
186+
//Now subtract 1 pixel to prevent semi-transparent borders at edge of solid page caused by
187+
//anti-aliased painting. This may cause a pixel to be cropped from certain edge lines/symbols,
188+
//but that can be counteracted by adding a dummy transparent line symbol layer with a wider line width
189+
mPageMargin = maxBleed - ( 25.4 / mComposition->printResolution() );
190+
}
191+
179192
bool QgsPaperItem::writeXML( QDomElement& elem, QDomDocument & doc ) const
180193
{
181194
Q_UNUSED( elem );

‎src/core/composer/qgspaperitem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ class CORE_EXPORT QgsPaperItem: public QgsComposerItem
6969
/**Set flags and z-value*/
7070
void initialize();
7171

72+
void calculatePageMargin();
73+
7274
QgsPaperGrid* mPageGrid;
75+
double mPageMargin;
7376
};
7477

7578
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.