Pcb printing: fix incorrect pos. of the board when printed without worksheet.
Fixes #13258 https://gitlab.com/kicad/code/kicad/issues/13258
This commit is contained in:
parent
ddd4178c62
commit
ae2da76615
|
@ -143,34 +143,35 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
|
|||
VECTOR2I sheetSizeMils = m_settings.m_pageInfo.GetSizeMils();
|
||||
VECTOR2I sheetSizeIU( milsToIU( sheetSizeMils.x ),
|
||||
milsToIU( sheetSizeMils.y ) );
|
||||
BOX2I bBox = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sheetSizeIU ) );
|
||||
BOX2I drawingAreaBBox = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sheetSizeIU ) );
|
||||
|
||||
// When printing the board without worksheet items, move board center to the
|
||||
// drawing area center.
|
||||
if( !m_settings.PrintBorderAndTitleBlock() )
|
||||
drawingAreaBBox = getBoundingBox();
|
||||
|
||||
view->SetLayerVisible( LAYER_DRAWINGSHEET, m_settings.PrintBorderAndTitleBlock() );
|
||||
|
||||
// Fit to page
|
||||
// Fit to page (drawingAreaBBox)
|
||||
if( m_settings.m_scale <= 0.0 )
|
||||
{
|
||||
if( !m_settings.PrintBorderAndTitleBlock() )
|
||||
bBox = getBoundingBox(); // Fit to "objects", new centre
|
||||
|
||||
if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
|
||||
if( drawingAreaBBox.GetWidth() == 0 || drawingAreaBBox.GetHeight() == 0 )
|
||||
{
|
||||
// Nothing to print
|
||||
// Nothing to print (empty board and no worksheet)
|
||||
m_settings.m_scale = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double scaleX = (double) pageSizeIU.x / bBox.GetWidth();
|
||||
double scaleY = (double) pageSizeIU.y / bBox.GetHeight();
|
||||
double scaleX = (double) pageSizeIU.x / drawingAreaBBox.GetWidth();
|
||||
double scaleY = (double) pageSizeIU.y / drawingAreaBBox.GetHeight();
|
||||
m_settings.m_scale = std::min( scaleX, scaleY );
|
||||
}
|
||||
}
|
||||
|
||||
setupGal( gal );
|
||||
galPrint->SetNativePaperSize( pageSizeIn, printCtx->HasNativeLandscapeRotation() );
|
||||
gal->SetLookAtPoint( bBox.Centre() );
|
||||
gal->SetLookAtPoint( drawingAreaBBox.Centre() );
|
||||
gal->SetZoomFactor( m_settings.m_scale );
|
||||
|
||||
gal->SetClearColor( dstSettings->GetBackgroundColor() );
|
||||
gal->ClearScreen();
|
||||
|
||||
|
|
Loading…
Reference in New Issue