From a02ea1609bf244433a1da073bbbdb860dfa1fa96 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 24 Aug 2021 11:17:28 +0100 Subject: [PATCH] A more robust solution to the 3D color opacity issue. (This also fixes a typo in the previous fix that assigned the opacities backwards.) --- pcbnew/plugins/kicad/kicad_plugin.h | 3 ++- pcbnew/plugins/kicad/pcb_parser.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pcbnew/plugins/kicad/kicad_plugin.h b/pcbnew/plugins/kicad/kicad_plugin.h index 3516868284..79ff19b0dd 100644 --- a/pcbnew/plugins/kicad/kicad_plugin.h +++ b/pcbnew/plugins/kicad/kicad_plugin.h @@ -99,7 +99,8 @@ class PCB_TEXT; //#define SEXPR_BOARD_FILE_VERSION 20210424 // Correct locked flag syntax (remove parens). //#define SEXPR_BOARD_FILE_VERSION 20210606 // Change overbar syntax from `~...~` to `~{...}`. //#define SEXPR_BOARD_FILE_VERSION 20210623 // Add support for reading/writing arcs in polygons -#define SEXPR_BOARD_FILE_VERSION 20210722 // Reading/writing group locked flags +//#define SEXPR_BOARD_FILE_VERSION 20210722 // Reading/writing group locked flags +#define SEXPR_BOARD_FILE_VERSION 20210824 // Opacity in 3D colors #define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 793dc5bb78..188fedbea6 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -58,6 +58,7 @@ #include #include #include +#include using namespace PCB_KEYS_T; @@ -1476,13 +1477,17 @@ void PCB_PARSER::parseBoardStackup() NeedSYMBOL(); name = FromUTF8(); - // Older versions didn't always store opacity with colors - if( name.StartsWith( "#" ) && name.Length() < 9 ) + // Older versions didn't store opacity with custom colors + if( name.StartsWith( "#" ) && m_requiredVersion < 20210824 ) { + KIGFX::COLOR4D color( name ); + if( item->GetType() == BS_ITEM_TYPE_SOLDERMASK ) - name += "FF"; + color = color.WithAlpha( DEFAULT_SOLDERMASK_OPACITY ); else - name += "D3"; + color = color.WithAlpha( 1.0 ); + + name = color.ToColour().GetAsString( wxC2S_HTML_SYNTAX ); } item->SetColor( name );