Skip to content
Permalink
Browse files
Hide custom snap lines before printing composition
  • Loading branch information
mhugent committed Mar 22, 2013
1 parent 9aa865e commit 66e98a1172944c1960c58b540335d4ccf0238d56
Showing with 20 additions and 0 deletions.
  1. +18 −0 src/core/composer/qgscomposition.cpp
  2. +2 −0 src/core/composer/qgscomposition.h
@@ -1076,6 +1076,22 @@ void QgsComposition::removeSnapLine( QGraphicsLineItem* line )
delete line;
}

void QgsComposition::setSnapLinesVisible( bool visible )
{
QList< QGraphicsLineItem* >::iterator it = mSnapLines.begin();
for ( ; it != mSnapLines.end(); ++it )
{
if ( visible )
{
( *it )->show();
}
else
{
( *it )->hide();
}
}
}

QGraphicsLineItem* QgsComposition::nearestSnapLine( bool horizontal, double x, double y, double tolerance,
QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode> >& snappedItems )
{
@@ -1802,7 +1818,9 @@ void QgsComposition::renderPage( QPainter* p, int page )
QgsComposition::PlotStyle savedPlotStyle = mPlotStyle;
mPlotStyle = QgsComposition::Print;

setSnapLinesVisible( false );
render( p, QRectF( 0, 0, paintDevice->width(), paintDevice->height() ), paperRect );
setSnapLinesVisible( true );

mPlotStyle = savedPlotStyle;
}
@@ -268,6 +268,8 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
void removeSnapLine( QGraphicsLineItem* line );
/**Get nearest snap line*/
QGraphicsLineItem* nearestSnapLine( bool horizontal, double x, double y, double tolerance, QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >& snappedItems );
/**Hides / shows custom snap lines*/
void setSnapLinesVisible( bool visible );

/**Allocates new item command and saves initial state in it
@param item target item

0 comments on commit 66e98a1

Please sign in to comment.