Don't draw the selection if it's not from the current screen.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17132
This commit is contained in:
Jeff Young 2024-03-02 18:56:14 +00:00
parent a4929f9c27
commit 9c371e2ef5
1 changed files with 15 additions and 0 deletions

View File

@ -19,6 +19,8 @@
*/
#include "sch_printout.h"
#include <tool/tool_manager.h>
#include <tools/ee_selection_tool.h>
#include <sch_edit_frame.h>
#include <math/vector2wx.h>
#include <pgm_base.h>
@ -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<EE_SELECTION_TOOL>();
// 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<SCH_ITEM*>( 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();