3D viewer: fix color issues when using the colors stackup:

- Add missing Yellow (.gbrjob predefined color) in list
- silkscreen colors: add .gbrjob predefined colors in list
- Use a default body color (FR4) for dielectric material not in known list
This commit is contained in:
jean-pierre charras 2021-08-25 18:33:49 +02:00
parent a5560bb5f9
commit d98e93de7e
2 changed files with 20 additions and 6 deletions

View File

@ -162,8 +162,13 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
#define ADD_COLOR( list, r, g, b, a, name ) \ #define ADD_COLOR( list, r, g, b, a, name ) \
list.push_back( CUSTOM_COLOR_ITEM( r/255.0, g/255.0, b/255.0, a, name ) ) list.push_back( CUSTOM_COLOR_ITEM( r/255.0, g/255.0, b/255.0, a, name ) )
ADD_COLOR( g_SilkscreenColors, 241, 241, 241, 1.0, "White" ); ADD_COLOR( g_SilkscreenColors, 20, 51, 36, 1.0, "Green" );
ADD_COLOR( g_SilkscreenColors, 4, 18, 21, 1.0, "Dark" ); ADD_COLOR( g_SilkscreenColors, 181, 19, 21, 1.0, "Red" );
ADD_COLOR( g_SilkscreenColors, 2, 59, 162, 1.0, "Blue" );
ADD_COLOR( g_SilkscreenColors, 11, 11, 11, 1.0, "Black" );
ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, "White" );
ADD_COLOR( g_SilkscreenColors, 32, 2, 53, 1.0, "Purple" );
ADD_COLOR( g_SilkscreenColors, 194, 195, 0, 1.0, "Yellow" );
ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, "Green" ); ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, "Green" );
ADD_COLOR( g_MaskColors, 91, 168, 12, 0.83, "Light Green" ); ADD_COLOR( g_MaskColors, 91, 168, 12, 0.83, "Light Green" );
@ -179,6 +184,7 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
ADD_COLOR( g_MaskColors, 245, 245, 245, 0.83, "White" ); ADD_COLOR( g_MaskColors, 245, 245, 245, 0.83, "White" );
ADD_COLOR( g_MaskColors, 32, 2, 53, 0.83, "Purple" ); ADD_COLOR( g_MaskColors, 32, 2, 53, 0.83, "Purple" );
ADD_COLOR( g_MaskColors, 119, 31, 91, 0.83, "Light Purple" ); ADD_COLOR( g_MaskColors, 119, 31, 91, 0.83, "Light Purple" );
ADD_COLOR( g_MaskColors, 194, 195, 0, 0.83, "Yellow" );
ADD_COLOR( g_PasteColors, 128, 128, 128, 1.0, "Grey" ); ADD_COLOR( g_PasteColors, 128, 128, 128, 1.0, "Grey" );
ADD_COLOR( g_PasteColors, 90, 90, 90, 1.0, "Dark Grey" ); ADD_COLOR( g_PasteColors, 90, 90, 90, 1.0, "Dark Grey" );
@ -584,7 +590,6 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
m_SilkScreenColorTop = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) ); m_SilkScreenColorTop = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
else else
m_SilkScreenColorBot = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) ); m_SilkScreenColorBot = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
break; break;
case BS_ITEM_TYPE_SOLDERMASK: case BS_ITEM_TYPE_SOLDERMASK:
@ -597,7 +602,7 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
case BS_ITEM_TYPE_DIELECTRIC: case BS_ITEM_TYPE_DIELECTRIC:
{ {
KIGFX::COLOR4D layerColor = COLOR4D::CLEAR; KIGFX::COLOR4D layerColor = COLOR4D::UNSPECIFIED;
const wxString& materialName = stackupItem->GetMaterial(); const wxString& materialName = stackupItem->GetMaterial();
if( materialName.StartsWith( "FR4" ) ) if( materialName.StartsWith( "FR4" ) )
@ -618,6 +623,11 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
{ {
layerColor = findColor( "Aluminum", g_BoardColors ); layerColor = findColor( "Aluminum", g_BoardColors );
} }
else // A default color value for unknown dielectric material
// (i.e. an exotic name entered by hand)
{
layerColor = findColor( "FR4 natural", g_BoardColors );
}
if( bodyColor == COLOR4D( 0, 0, 0, 0 ) ) if( bodyColor == COLOR4D( 0, 0, 0, 0 ) )
bodyColor = layerColor; bodyColor = layerColor;

View File

@ -674,9 +674,13 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
if( ( layer_id == B_Mask ) || ( layer_id == F_Mask ) ) if( ( layer_id == B_Mask ) || ( layer_id == F_Mask ) )
continue; continue;
// Do not show inner layers when it is displaying the board and board body is full opaque // Do not show inner layers when it is displaying the board and board body is opaque
// enough: the time to create inner layers can be *really significant*.
// So avoid creating them is they are not very visible
const double opacity_min = 0.8;
if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) && if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) &&
( m_boardAdapter.m_BoardBodyColor.a > 0.99f ) ) ( m_boardAdapter.m_BoardBodyColor.a > opacity_min ) )
{ {
if( ( layer_id > F_Cu ) && ( layer_id < B_Cu ) ) if( ( layer_id > F_Cu ) && ( layer_id < B_Cu ) )
continue; continue;