A more robust solution to the 3D color opacity issue.

(This also fixes a typo in the previous fix that assigned the opacities
backwards.)
This commit is contained in:
Jeff Young 2021-08-24 11:17:28 +01:00
parent a9f092b370
commit a02ea1609b
2 changed files with 11 additions and 5 deletions

View File

@ -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

View File

@ -58,6 +58,7 @@
#include <string_utils.h>
#include <wx/log.h>
#include <progress_reporter.h>
#include <board_stackup_manager/stackup_predefined_prms.h>
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 );