From faae009dba0939e77c9558a71c46f6b0037e4a07 Mon Sep 17 00:00:00 2001 From: John Beard Date: Tue, 26 Nov 2024 19:01:57 +0800 Subject: [PATCH] Fabmaster: use User layers for unknown layers This is a bit of a hack as it will still only allow 9 more layers and drop the rest, but it's a start and allows testing using the Beaglebone Black board and the board in issue 19174. --- pcbnew/pcb_io/fabmaster/import_fabmaster.cpp | 33 +++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/pcbnew/pcb_io/fabmaster/import_fabmaster.cpp b/pcbnew/pcb_io/fabmaster/import_fabmaster.cpp index f200fc5e56..817b8a7583 100644 --- a/pcbnew/pcb_io/fabmaster/import_fabmaster.cpp +++ b/pcbnew/pcb_io/fabmaster/import_fabmaster.cpp @@ -742,6 +742,8 @@ bool FABMASTER::assignLayers() std::vector layer_order; + int next_user_layer = User_1; + for( auto& el : layers ) { FABMASTER_LAYER& layer = el.second; @@ -775,9 +777,32 @@ bool FABMASTER::assignLayers() layer.layerid = F_Paste; } else if( layer.name.find( "NCLEGEND" ) != std::string::npos ) + { layer.layerid = Dwgs_User; + } else - layer.disable = true; + { + // Try to gather as many other layers into user layers as possible + + // Skip ones that seem like a waste of good layers + if( layer.name.find( "AUTOSILK" ) == std::string::npos ) + { + if( next_user_layer <= User_9 ) + { + // Assign the mapping + layer.layerid = next_user_layer; + next_user_layer += 2; + } + else + { + // Out of additional layers + // For now, drop it, but maybr we could gather onto some other layer. + // Or implement a proper layer remapper. + layer.disable = true; + wxLogWarning( _( "No user layer to put layer %s" ), layer.name ); + } + } + } } std::sort( layer_order.begin(), layer_order.end(), FABMASTER_LAYER::BY_ID() ); @@ -810,6 +835,12 @@ bool FABMASTER::assignLayers() } } + for( const auto& [layer_name, fabmaster_layer] : layers ) + { + wxLogTrace( traceFabmaster, wxT( "Layer %s -> KiCad layer %d" ), layer_name, + fabmaster_layer.layerid ); + } + return true; }