From f22cf1cc3a8ab60b3c1e69bbd204ff92dc0cbdef Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 10 Jun 2022 14:09:22 +0100 Subject: [PATCH] Fill in missing bits of LAYER variable for printing/plotting. Fixes https://gitlab.com/kicad/code/kicad/issues/11788 --- common/board_printout.cpp | 2 ++ common/drawing_sheet/ds_proxy_view_item.cpp | 1 + common/plotters/common_plot_functions.cpp | 1 + include/render_settings.h | 6 +++++- pcbnew/pcbnew_printout.cpp | 2 +- pcbnew/plot_board_layers.cpp | 4 ++++ 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/common/board_printout.cpp b/common/board_printout.cpp index 2d126beb77..94c991bd64 100644 --- a/common/board_printout.cpp +++ b/common/board_printout.cpp @@ -133,6 +133,8 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa setupPainter( *painter ); setupViewLayers( *view, m_settings.m_LayerSet ); + dstSettings->SetLayerName( aLayerName ); + VECTOR2I sheetSizeMils = m_settings.m_pageInfo.GetSizeMils(); VECTOR2I sheetSizeIU( milsToIU( sheetSizeMils.x ), milsToIU( sheetSizeMils.y ) ); diff --git a/common/drawing_sheet/ds_proxy_view_item.cpp b/common/drawing_sheet/ds_proxy_view_item.cpp index d2ca57f94e..c96d298943 100644 --- a/common/drawing_sheet/ds_proxy_view_item.cpp +++ b/common/drawing_sheet/ds_proxy_view_item.cpp @@ -86,6 +86,7 @@ void DS_PROXY_VIEW_ITEM::buildDrawList( VIEW* aView, DS_DRAW_ITEM_LIST* aDrawLis aDrawList->SetFileName( fileName ); aDrawList->SetSheetName( sheetName ); aDrawList->SetSheetPath( sheetPath ); + aDrawList->SetSheetLayer( settings->GetLayerName() ); aDrawList->SetProject( m_project ); aDrawList->BuildDrawItemsList( *m_pageInfo, *m_titleBlock ); diff --git a/common/plotters/common_plot_functions.cpp b/common/plotters/common_plot_functions.cpp index 2b1641425b..407597b87c 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -86,6 +86,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL drawList.SetFileName( fn.GetFullName() ); // Print only the short filename drawList.SetSheetName( aSheetName ); drawList.SetSheetPath( aSheetPath ); + drawList.SetSheetLayer( plotter->RenderSettings()->GetLayerName() ); drawList.SetProject( aProject ); drawList.SetIsFirstPage( aIsFirstPage ); diff --git a/include/render_settings.h b/include/render_settings.h index 2e14fef18b..4fb2e6506e 100644 --- a/include/render_settings.h +++ b/include/render_settings.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.TXT for contributors. + * Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -112,6 +112,9 @@ public: PCB_LAYER_ID GetActiveLayer() const { return m_activeLayer; } void SetActiveLayer( PCB_LAYER_ID aLayer ) { m_activeLayer = aLayer; } + const wxString& GetLayerName() const { return m_layerName; } + void SetLayerName( const wxString& aLayerName ) { m_layerName = aLayerName; } + /** * Clear the list of active layers. */ @@ -293,6 +296,7 @@ protected: virtual void update(); PCB_LAYER_ID m_activeLayer; // The active layer (as shown by appearance mgr) + wxString m_layerName; std::set m_highContrastLayers; // High-contrast layers (both board layers and // synthetic GAL layers) COLOR4D m_layerColors[LAYER_ID_COUNT]; // Layer colors diff --git a/pcbnew/pcbnew_printout.cpp b/pcbnew/pcbnew_printout.cpp index f0d52d820f..ba58224cdf 100644 --- a/pcbnew/pcbnew_printout.cpp +++ b/pcbnew/pcbnew_printout.cpp @@ -109,7 +109,7 @@ bool PCBNEW_PRINTOUT::OnPrintPage( int aPage ) if( extractLayer == UNDEFINED_LAYER ) layerName = _( "Multiple Layers" ); else - layerName = LSET::Name( extractLayer ); + layerName = m_board->GetLayerName( extractLayer ); // In Pcbnew we can want the layer EDGE always printed if( m_pcbnewSettings.m_PrintEdgeCutsOnAllPages ) diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 12d43a76e3..4904be1d57 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -1141,6 +1141,10 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aL KIGFX::PCB_RENDER_SETTINGS* renderSettings = new KIGFX::PCB_RENDER_SETTINGS(); renderSettings->LoadColors( aPlotOpts->ColorSettings() ); renderSettings->SetDefaultPenWidth( Millimeter2iu( 0.0212 ) ); // Hairline at 1200dpi + + if( aLayer < GAL_LAYER_ID_END ) + renderSettings->SetLayerName( aBoard->GetLayerName( ToLAYER_ID( aLayer ) ) ); + plotter->SetRenderSettings( renderSettings ); // Compute the viewport and set the other options