Skip to content

Commit

Permalink
Hide custom snap lines before printing composition
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Mar 22, 2013
1 parent 9aa865e commit 66e98a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/composer/qgscomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 66e98a1

Please sign in to comment.