From 1664e02fa6a79b41521c92e6f911b8ecfffe62aa Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 2 Mar 2024 18:56:14 +0000 Subject: [PATCH] Don't draw the selection if it's not from the current screen. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17132 --- eeschema/printing/sch_printout.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/eeschema/printing/sch_printout.cpp b/eeschema/printing/sch_printout.cpp index e64b408577..86988d2960 100644 --- a/eeschema/printing/sch_printout.cpp +++ b/eeschema/printing/sch_printout.cpp @@ -19,6 +19,8 @@ */ #include "sch_printout.h" +#include +#include #include #include #include @@ -257,6 +259,7 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen ) SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); EESCHEMA_SETTINGS* cfg = m_parent->eeconfig(); COLOR_SETTINGS* theme = mgr.GetColorSettings( cfg->m_Printing.color_theme ); + EE_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool(); // Target paper size wxRect pageSizePx = GetLogicalPageRect(); @@ -345,6 +348,18 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen ) view->SetLayerVisible( LAYER_DRAWINGSHEET, printDrawingSheet ); + // Don't draw the selection if it's not from the current screen + for( EDA_ITEM* item : selTool->GetSelection() ) + { + if( SCH_ITEM* schItem = dynamic_cast( item ) ) + { + if( !m_parent->GetScreen()->CheckIfOnDrawList( schItem ) ) + view->SetLayerVisible( LAYER_SELECT_OVERLAY, false ); + + break; + } + } + // 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();