Eeschema, Cairo printing: adjust printing to page size and other refinements

This commit is contained in:
jean-pierre charras 2023-11-23 17:24:16 +01:00
parent 247a0e6501
commit 029df17b5a
2 changed files with 12 additions and 25 deletions

View File

@ -325,11 +325,6 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
VECTOR2I sheetSizeIU = aScreen->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS ); VECTOR2I sheetSizeIU = aScreen->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS );
BOX2I drawingAreaBBox = 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();
// Enable all layers and use KIGFX::TARGET_NONCACHED to force update drawings // Enable all layers and use KIGFX::TARGET_NONCACHED to force update drawings
// for printing with current GAL instance // for printing with current GAL instance
for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; ++i ) for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; ++i )
@ -340,27 +335,16 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
view->SetLayerVisible( LAYER_DRAWINGSHEET, printDrawingSheet ); view->SetLayerVisible( LAYER_DRAWINGSHEET, printDrawingSheet );
#if 0 // When is the actual paper size does not match the schematic page size,
// Fit to page (drawingAreaBBox) // we need to adjust the print scale to fit the selected paper size (pageSizeIU)
if( m_settings.m_scale <= 0.0 ) double scaleX = (double) pageSizeIU.x / drawingAreaBBox.GetWidth();
{ double scaleY = (double) pageSizeIU.y / drawingAreaBBox.GetHeight();
if( drawingAreaBBox.GetWidth() == 0 || drawingAreaBBox.GetHeight() == 0 )
{ double print_scale = std::min( scaleX, scaleY );
// Nothing to print (empty board and no worksheet)
m_settings.m_scale = 1.0;
}
else
{
double scaleX = (double) pageSizeIU.x / drawingAreaBBox.GetWidth();
double scaleY = (double) pageSizeIU.y / drawingAreaBBox.GetHeight();
m_settings.m_scale = std::min( scaleX, scaleY );
}
}
#endif
//setupGal( gal );
galPrint->SetNativePaperSize( pageSizeIn, printCtx->HasNativeLandscapeRotation() ); galPrint->SetNativePaperSize( pageSizeIn, printCtx->HasNativeLandscapeRotation() );
gal->SetLookAtPoint( drawingAreaBBox.Centre() ); gal->SetLookAtPoint( drawingAreaBBox.Centre() );
gal->SetZoomFactor( 1.0);//m_settings.m_scale ); gal->SetZoomFactor( print_scale );
gal->SetClearColor( dstSettings->GetBackgroundColor() ); gal->SetClearColor( dstSettings->GetBackgroundColor() );
gal->ClearScreen(); gal->ClearScreen();

View File

@ -144,7 +144,7 @@ COLOR4D SCH_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
bool SCH_RENDER_SETTINGS::GetShowPageLimits() const bool SCH_RENDER_SETTINGS::GetShowPageLimits() const
{ {
return eeconfig() && eeconfig()->m_Appearance.show_page_limits; return eeconfig() && eeconfig()->m_Appearance.show_page_limits && !IsPrinting();
} }
@ -1358,6 +1358,9 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
if( !aPin->IsVisible() ) if( !aPin->IsVisible() )
{ {
if( m_schSettings.IsPrinting() )
return;
if( !m_schematic || eeconfig()->m_Appearance.show_hidden_pins ) if( !m_schematic || eeconfig()->m_Appearance.show_hidden_pins )
{ {
color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed ); color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );