From 0321d96b1ec416e1461ac4b3390d87ac308ae8f5 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 (cherry picked from commit f22cf1cc3a8ab60b3c1e69bbd204ff92dc0cbdef) --- common/board_printout.cpp | 2 ++ common/drawing_sheet/ds_proxy_view_item.cpp | 1 + common/plotters/common_plot_functions.cpp | 1 + include/drawing_sheet/ds_proxy_view_item.h | 6 ++++++ include/render_settings.h | 6 +++++- pcbnew/pcbnew_printout.cpp | 2 +- pcbnew/plot_board_layers.cpp | 4 ++++ 7 files changed, 20 insertions(+), 2 deletions(-) diff --git a/common/board_printout.cpp b/common/board_printout.cpp index c3d21bc9b5..92ceec3ac3 100644 --- a/common/board_printout.cpp +++ b/common/board_printout.cpp @@ -137,6 +137,8 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa setupPainter( *painter ); setupViewLayers( *view, m_settings.m_LayerSet ); + dstSettings->SetLayerName( aLayerName ); + wxSize sheetSizeMils = m_settings.m_pageInfo.GetSizeMils(); VECTOR2I sheetSizeIU( milsToIU( sheetSizeMils.GetWidth() ), milsToIU( sheetSizeMils.GetHeight() ) ); diff --git a/common/drawing_sheet/ds_proxy_view_item.cpp b/common/drawing_sheet/ds_proxy_view_item.cpp index dd825752c0..3a191cbf92 100644 --- a/common/drawing_sheet/ds_proxy_view_item.cpp +++ b/common/drawing_sheet/ds_proxy_view_item.cpp @@ -83,6 +83,7 @@ void DS_PROXY_VIEW_ITEM::buildDrawList( VIEW* aView, DS_DRAW_ITEM_LIST* aDrawLis aDrawList->SetSheetCount( m_sheetCount ); aDrawList->SetFileName( fileName ); aDrawList->SetSheetName( sheetName ); + 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 8f56d844e9..cb33690a27 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -84,6 +84,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL drawList.SetSheetCount( aSheetCount ); drawList.SetFileName( fn.GetFullName() ); // Print only the short filename drawList.SetSheetName( aSheetDesc ); + drawList.SetSheetLayer( plotter->RenderSettings()->GetLayerName() ); drawList.SetProject( aProject ); drawList.SetIsFirstPage( aIsFirstPage ); diff --git a/include/drawing_sheet/ds_proxy_view_item.h b/include/drawing_sheet/ds_proxy_view_item.h index b9e4723570..44d449dafc 100644 --- a/include/drawing_sheet/ds_proxy_view_item.h +++ b/include/drawing_sheet/ds_proxy_view_item.h @@ -60,6 +60,11 @@ public: */ void SetSheetName( const std::string& aSheetName ) { m_sheetName = aSheetName; } + /** + * Set the sheet path displayed in the title block. + */ + void SetSheetPath( const std::string& aSheetPath ) { m_sheetPath = aSheetPath; } + /** * Changes the page number displayed in the title block. */ @@ -132,6 +137,7 @@ protected: std::string m_fileName; std::string m_sheetName; + std::string m_sheetPath; const TITLE_BLOCK* m_titleBlock; const PAGE_INFO* m_pageInfo; std::string m_pageNumber; diff --git a/include/render_settings.h b/include/render_settings.h index ea0f821faa..7c04b42d50 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. */ @@ -283,6 +286,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 eec788af75..21cc8c9f3c 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 533a38ad72..3c73d0e830 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -1187,6 +1187,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