Skip to content
Permalink
Browse files

[composer] Tweak appearance of compositions so that it's still possib…

…le to see page edges when using a transparent paper style
  • Loading branch information
nyalldawson committed Jan 6, 2014
1 parent d1a3508 commit 0ae2b1ab6dba50f3f3175a98caf1df1649ed6c0f
Showing with 25 additions and 2 deletions.
  1. +2 −2 src/core/composer/qgscomposition.cpp
  2. +23 −0 src/core/composer/qgspaperitem.cpp
@@ -78,7 +78,7 @@ QgsComposition::QgsComposition( QgsMapRenderer* mapRenderer )
, mAtlasPreviewEnabled( false )
, mPreventCursorChange( false )
{
setBackgroundBrush( Qt::gray );
setBackgroundBrush( QColor( 215, 215, 215 ) );
createDefaultPageStyleSymbol();
addPaperItem();

@@ -2248,7 +2248,7 @@ void QgsComposition::renderPage( QPainter* p, int page )
setBackgroundBrush( Qt::NoBrush );
render( p, QRectF( 0, 0, paintDevice->width(), paintDevice->height() ), paperRect );
//show background after rendering
setBackgroundBrush( Qt::gray );
setBackgroundBrush( QColor( 215, 215, 215 ) );
setSnapLinesVisible( true );

mPlotStyle = savedPlotStyle;
@@ -166,6 +166,24 @@ void QgsPaperItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* ite
}

painter->save();

if ( mComposition->plotStyle() == QgsComposition::Preview )
{
//if in preview mode, draw page border and shadow so that it's
//still possible to tell where pages with a transparent style begin and end
painter->setRenderHint( QPainter::Antialiasing, false );

//shadow
painter->setBrush( QBrush( QColor( 150, 150, 150 ) ) );
painter->setPen( Qt::NoPen );
painter->drawRect( QRectF( 1, 1, rect().width() + 1, rect().height() + 1 ) );

//page area
painter->setBrush( QColor( 215, 215, 215 ) );
painter->setPen( QPen( QColor( 100, 100, 100 ) ) );
painter->drawRect( QRectF( 0, 0, rect().width(), rect().height() ) );
}

painter->setRenderHint( QPainter::Antialiasing );
mComposition->pageStyleSymbol()->startRender( context );

@@ -217,6 +235,11 @@ void QgsPaperItem::initialize()
setFlag( QGraphicsItem::ItemIsMovable, false );
setZValue( 0 );

//even though we aren't going to use it to draw the page, set the pen width as 4
//so that the page border and shadow is fully rendered within its scene rect
//(QGraphicsRectItem considers the pen width when calculating an item's scene rect)
setPen( QPen( QBrush( Qt::NoBrush ), 4 ) );

//create a new QgsPaperGrid for this page, and add it to the composition
mPageGrid = new QgsPaperGrid( pos().x(), pos().y(), rect().width(), rect().height(), mComposition );
mComposition->addItem( mPageGrid );

0 comments on commit 0ae2b1a

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