From 029df17b5a7b354d62bdd0fb5c18e598639655e6 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 23 Nov 2023 17:24:16 +0100 Subject: [PATCH] Eeschema, Cairo printing: adjust printing to page size and other refinements --- eeschema/printing/sch_printout.cpp | 32 ++++++++---------------------- eeschema/sch_painter.cpp | 5 ++++- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/eeschema/printing/sch_printout.cpp b/eeschema/printing/sch_printout.cpp index 50810e02e5..8ff57c9bfc 100644 --- a/eeschema/printing/sch_printout.cpp +++ b/eeschema/printing/sch_printout.cpp @@ -325,11 +325,6 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen ) VECTOR2I sheetSizeIU = aScreen->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS ); 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 // for printing with current GAL instance 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 ); - #if 0 - // Fit to page (drawingAreaBBox) - if( m_settings.m_scale <= 0.0 ) - { - if( drawingAreaBBox.GetWidth() == 0 || drawingAreaBBox.GetHeight() == 0 ) - { - // 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 ); + // When is the actual paper size does not match the schematic page size, + // we need to adjust the print scale to fit the selected paper size (pageSizeIU) + double scaleX = (double) pageSizeIU.x / drawingAreaBBox.GetWidth(); + double scaleY = (double) pageSizeIU.y / drawingAreaBBox.GetHeight(); + + double print_scale = std::min( scaleX, scaleY ); + galPrint->SetNativePaperSize( pageSizeIn, printCtx->HasNativeLandscapeRotation() ); gal->SetLookAtPoint( drawingAreaBBox.Centre() ); - gal->SetZoomFactor( 1.0);//m_settings.m_scale ); + gal->SetZoomFactor( print_scale ); gal->SetClearColor( dstSettings->GetBackgroundColor() ); gal->ClearScreen(); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index e558b030f7..53261ddd04 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -144,7 +144,7 @@ COLOR4D SCH_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons 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( m_schSettings.IsPrinting() ) + return; + if( !m_schematic || eeconfig()->m_Appearance.show_hidden_pins ) { color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );