From bd47692bf29d643982cd4c33606a517936167da1 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 7 Jan 2025 18:28:07 -0500 Subject: [PATCH] API: Include custom layer names in stackup --- api/proto/board/board.proto | 4 ++++ pcbnew/api/api_handler_pcb.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/api/proto/board/board.proto b/api/proto/board/board.proto index bb560cf8e8..9d89b0cfab 100644 --- a/api/proto/board/board.proto +++ b/api/proto/board/board.proto @@ -95,6 +95,10 @@ message BoardStackupLayer BoardStackupDielectricLayer dielectric = 5; kiapi.common.types.Color color = 6; string material_name = 7; + + // The name of the layer shown in the KiCad GUI, which may be a default value like "F.Cu" or may + // have been customized by the user. This field does not apply to dielectric layers. + string user_name = 8; } message BoardStackup diff --git a/pcbnew/api/api_handler_pcb.cpp b/pcbnew/api/api_handler_pcb.cpp index d657571585..67734701a1 100644 --- a/pcbnew/api/api_handler_pcb.cpp +++ b/pcbnew/api/api_handler_pcb.cpp @@ -675,6 +675,18 @@ HANDLER_RESULT API_HANDLER_PCB::handleGetStackup( any.UnpackTo( response.mutable_stackup() ); + // User-settable layer names are not stored in BOARD_STACKUP at the moment + for( board::BoardStackupLayer& layer : *response.mutable_stackup()->mutable_layers() ) + { + if( layer.type() == board::BoardStackupLayerType::BSLT_DIELECTRIC ) + continue; + + PCB_LAYER_ID id = FromProtoEnum( layer.layer() ); + wxCHECK2( id != UNDEFINED_LAYER, continue ); + + layer.set_user_name( frame()->GetBoard()->GetLayerName( id ) ); + } + return response; }