Printing code clean-up

This commit is contained in:
Maciej Suminski 2018-10-02 15:47:59 +02:00
parent 92c5cb288e
commit 562b8d7948
2 changed files with 10 additions and 22 deletions

View File

@ -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<KIGFX::VIEW> 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 );

View File

@ -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).