From 562b8d794840103a0af9658095a74caeda5ce61d Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 2 Oct 2018 15:47:59 +0200 Subject: [PATCH] Printing code clean-up --- common/board_printout.cpp | 27 ++++++--------------------- include/board_printout.h | 5 ++++- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/common/board_printout.cpp b/common/board_printout.cpp index 297ba7481c..5dd969ef99 100644 --- a/common/board_printout.cpp +++ b/common/board_printout.cpp @@ -77,15 +77,6 @@ void BOARD_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, } -bool BOARD_PRINTOUT::HasPage( int aPage ) -{ - if( aPage <= m_PrintParams.m_PageCount ) - return true; - else - return false; -} - - void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPageCount ) { auto dc = GetDC(); @@ -96,8 +87,10 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa auto painter = getPainter( gal ); std::unique_ptr view( m_view->DataReference() ); - wxRect page = GetLogicalPageRect(); - galPrint->SetSheetSize( VECTOR2D( page.width / dc->GetPPI().x, page.height / dc->GetPPI().y ) ); + wxRect pageSizePx = GetLogicalPageRect(); + VECTOR2D pageSizeIn( (double) pageSizePx.width / dc->GetPPI().x, + (double) pageSizePx.height / dc->GetPPI().y ); + galPrint->SetSheetSize( pageSizeIn ); view->SetGAL( gal ); view->SetPainter( painter.get() ); @@ -156,17 +149,9 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa scale = m_PrintParams.m_XScaleAdjust; } - - if( m_PrintParams.m_PrintMirror ) - gal->SetFlip( true, false ); - - - // TODO fix 'Preview' button - VECTOR2D nps( GetLogicalPageRect().width, GetLogicalPageRect().height ); - setupGal( gal ); - galPrint->SetNativePaperSize( VECTOR2D( nps.x / dc->GetPPI().x, nps.y / dc->GetPPI().y ), - printCtx->HasNativeLandscapeRotation() ); + galPrint->SetNativePaperSize( pageSizeIn, printCtx->HasNativeLandscapeRotation() ); + gal->SetFlip( m_PrintParams.m_PrintMirror, false ); gal->SetLookAtPoint( bBox.Centre() ); gal->SetZoomFactor( scale ); diff --git a/include/board_printout.h b/include/board_printout.h index e27e7dabe2..89a70eada6 100644 --- a/include/board_printout.h +++ b/include/board_printout.h @@ -111,7 +111,10 @@ public: void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo ) override; - bool HasPage( int aPage ) override; + bool HasPage( int aPage ) override + { + return aPage <= m_PrintParams.m_PageCount; + } /** * Print a page (or a set of pages).