Hook up 3D viewer colors to board stackup.

Fixes https://gitlab.com/kicad/code/kicad/issues/5173
This commit is contained in:
Jeff Young 2021-08-05 21:47:23 +01:00
parent ef9f041279
commit bff247b08a
12 changed files with 1782 additions and 1670 deletions

View File

@ -22,16 +22,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file cinfo3d_visu.cpp
* @brief Handles data related with the board to be visualized
*/
#include "../3d_rendering/camera.h"
#include "board_adapter.h"
#include <board_design_settings.h>
#include <board_stackup_manager/board_stackup.h>
#include <3d_rendering/3d_render_raytracing/shapes2D/polygon_2d.h>
#include <board.h>
#include <dialogs/dialog_color_picker.h>
#include <3d_math.h>
#include "3d_fastmath.h"
#include <geometry/geometry_utils.h>
@ -40,6 +37,23 @@
#include <settings/settings_manager.h>
#include <wx/log.h>
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_SilkscreenColors;
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_MaskColors;
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_PasteColors;
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_FinishColors;
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_BoardColors;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBackgroundTop;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBackgroundBot;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSilkscreen;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSolderMask;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSolderPaste;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSurfaceFinish;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBoardBody;
static bool g_ColorsLoaded = false;
/**
* Trace mask used to enable or disable the trace output of this class.
* The debug output can be turned on by setting the WXTRACE environment variable to
@ -60,7 +74,7 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
{
wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) );
m_gridType = GRID3D_TYPE::NONE;
m_gridType = GRID3D_TYPE::NONE;
m_antiAliasingMode = ANTIALIASING_MODE::AA_8X;
m_drawFlags.resize( FL_LAST, false );
@ -142,6 +156,61 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_RtRecursiveReflectionCount = 0;
m_RtRecursiveRefractionCount = 0;
if( !g_ColorsLoaded )
{
#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 ) )
ADD_COLOR( g_SilkscreenColors, 241, 241, 241, 1.0, "White" );
ADD_COLOR( g_SilkscreenColors, 4, 18, 21, 1.0, "Dark" );
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, 13, 104, 11, 0.83, "Saturated Green" );
ADD_COLOR( g_MaskColors, 181, 19, 21, 0.83, "Red" );
ADD_COLOR( g_MaskColors, 210, 40, 14, 0.83, "Light Red" );
ADD_COLOR( g_MaskColors, 239, 53, 41, 0.83, "Red/Orange" );
ADD_COLOR( g_MaskColors, 2, 59, 162, 0.83, "Blue" );
ADD_COLOR( g_MaskColors, 54, 79, 116, 0.83, "Light Blue 1" );
ADD_COLOR( g_MaskColors, 61, 85, 130, 0.83, "Light Blue 2" );
ADD_COLOR( g_MaskColors, 21, 70, 80, 0.83, "Green/Blue" );
ADD_COLOR( g_MaskColors, 11, 11, 11, 0.83, "Black" );
ADD_COLOR( g_MaskColors, 245, 245, 245, 0.83, "White" );
ADD_COLOR( g_MaskColors, 32, 2, 53, 0.83, "Purple" );
ADD_COLOR( g_MaskColors, 119, 31, 91, 0.83, "Light Purple" );
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, 213, 213, 213, 1.0, "Silver" );
ADD_COLOR( g_FinishColors, 184, 115, 50, 1.0, "Copper" );
ADD_COLOR( g_FinishColors, 178, 156, 0, 1.0, "Gold" );
ADD_COLOR( g_FinishColors, 213, 213, 213, 1.0, "Silver" );
ADD_COLOR( g_FinishColors, 160, 160, 160, 1.0, "Tin" );
ADD_COLOR( g_BoardColors, 51, 43, 22, 0.83, "FR4 natural, dark" );
ADD_COLOR( g_BoardColors, 109, 116, 75, 0.83, "FR4 natural" );
ADD_COLOR( g_BoardColors, 252, 252, 250, 0.90, "PTFE natural" );
ADD_COLOR( g_BoardColors, 205, 130, 0, 0.68, "Polyimide" );
ADD_COLOR( g_BoardColors, 92, 17, 6, 0.90, "Phenolic natural" );
ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, "Brown 1" );
ADD_COLOR( g_BoardColors, 160, 123, 54, 0.83, "Brown 2" );
ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, "Brown 3" );
ADD_COLOR( g_BoardColors, 213, 213, 213, 1.0, "Aluminum" );
g_DefaultBackgroundTop = COLOR4D( 0.80, 0.80, 0.90, 1.0 );
g_DefaultBackgroundBot = COLOR4D( 0.40, 0.40, 0.50, 1.0 );
g_DefaultSilkscreen = COLOR4D( 0.94, 0.94, 0.94, 1.0 );
g_DefaultSolderMask = COLOR4D( 0.08, 0.20, 0.14, 0.83 );
g_DefaultSolderPaste = COLOR4D( 0.50, 0.50, 0.50, 1.0 );
g_DefaultSurfaceFinish = COLOR4D( 0.75, 0.61, 0.23, 1.0 );
g_DefaultBoardBody = COLOR4D( 0.43, 0.45, 0.30, 0.90 );
g_ColorsLoaded = true;
}
#undef ADD_COLOR
}
@ -299,9 +368,12 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
if( ( m_board && m_board->IsFootprintHolder() ) || !GetFlag( FL_USE_REALISTIC_MODE )
|| !succeedToGetBoardPolygon )
{
boardEdgesOnly = false;
}
EDA_RECT bbbox;
if( m_board )
bbbox = m_board->ComputeBoundingBox( boardEdgesOnly );
@ -457,6 +529,144 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
aStatusReporter->Report( _( "Create layers" ) );
createLayers( aStatusReporter );
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
auto to_SFVEC4F =
[]( const COLOR4D& src )
{
return SFVEC4F( src.r, src.g, src.b, src.a );
};
m_BgColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_TOP ) );
m_BgColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ) );
m_SolderPasteColor = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERPASTE ) );
if( m_board && colors->GetUseBoardStackupColors() )
{
const BOARD_STACKUP& stackup = m_board->GetDesignSettings().GetStackupDescriptor();
auto findColor =
[]( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet )
{
for( const CUSTOM_COLOR_ITEM& color : aColorSet )
{
if( color.m_ColorName == aColorName )
return color.m_Color;
}
return KIGFX::COLOR4D();
};
m_SilkScreenColorTop = to_SFVEC4F( g_DefaultSilkscreen );
m_SilkScreenColorBot = to_SFVEC4F( g_DefaultSilkscreen );
m_SolderMaskColorTop = to_SFVEC4F( g_DefaultSolderMask );
m_SolderMaskColorBot = to_SFVEC4F( g_DefaultSolderMask );
KIGFX::COLOR4D bodyColor( 0, 0, 0, 0 );
for( const BOARD_STACKUP_ITEM* stackupItem : stackup.GetList() )
{
wxString colorName = stackupItem->GetColor();
switch( stackupItem->GetType() )
{
case BS_ITEM_TYPE_SILKSCREEN:
if( stackupItem->GetBrdLayerId() == F_SilkS )
m_SilkScreenColorTop = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
else
m_SilkScreenColorBot = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
break;
case BS_ITEM_TYPE_SOLDERMASK:
if( stackupItem->GetBrdLayerId() == F_Mask )
m_SolderMaskColorTop = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
else
m_SolderMaskColorBot = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
break;
case BS_ITEM_TYPE_DIELECTRIC:
{
KIGFX::COLOR4D layerColor = COLOR4D::CLEAR;
const wxString& materialName = stackupItem->GetMaterial();
if( materialName.StartsWith( "FR4" ) )
{
layerColor = findColor( "FR4 natural", g_BoardColors );
}
else if( materialName.IsSameAs( "PTFE" )
|| materialName.IsSameAs( "Teflon" ) )
{
layerColor = findColor( "PTFE natural", g_BoardColors );
}
else if( materialName.IsSameAs( "Polyimide" )
|| materialName.IsSameAs( "Kapton" ) )
{
layerColor = findColor( "Polyimide", g_BoardColors );
}
else if( materialName.IsSameAs( "Al" ) )
{
layerColor = findColor( "Aluminum", g_BoardColors );
}
if( bodyColor == COLOR4D( 0, 0, 0, 0 ) )
bodyColor = layerColor;
else
bodyColor = bodyColor.Mix( layerColor, 1.0 - layerColor.a );
bodyColor.a += ( 1.0 - bodyColor.a ) * layerColor.a / 2;
break;
}
default:
break;
}
}
if( bodyColor != COLOR4D( 0, 0, 0, 0 ) )
m_BoardBodyColor = to_SFVEC4F( bodyColor );
else
m_BoardBodyColor = to_SFVEC4F( g_DefaultBoardBody );
const wxString& finishName = stackup.m_FinishType;
if( finishName.EndsWith( "OSP" ) )
{
m_CopperColor = to_SFVEC4F( findColor( "Copper", g_FinishColors ) );
}
else if( finishName.EndsWith( "IG" )
|| finishName.EndsWith( "gold" ) )
{
m_CopperColor = to_SFVEC4F( findColor( "Gold", g_FinishColors ) );
}
else if( finishName.StartsWith( "HAL" )
|| finishName.StartsWith( "HASL" )
|| finishName.EndsWith( "tin" )
|| finishName.EndsWith( "nickel" ) )
{
m_CopperColor = to_SFVEC4F( findColor( "Tin", g_FinishColors ) );
}
else if( finishName.EndsWith( "silver" ) )
{
m_CopperColor = to_SFVEC4F( findColor( "Silver", g_FinishColors ) );
}
else
{
m_CopperColor = to_SFVEC4F( g_DefaultSurfaceFinish );
}
}
else
{
m_SilkScreenColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ) );
m_SilkScreenColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ) );
m_SolderMaskColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_BOTTOM ) );
m_SolderMaskColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_TOP ) );
m_CopperColor = to_SFVEC4F( colors->GetColor( LAYER_3D_COPPER ) );
m_BoardBodyColor = to_SFVEC4F( colors->GetColor( LAYER_3D_BOARD ) );
}
}

View File

@ -46,6 +46,7 @@
#include <zone.h>
#include <footprint.h>
#include <reporter.h>
#include <dialogs/dialog_color_picker.h>
class COLOR_SETTINGS;
@ -607,6 +608,21 @@ private:
void transformFPShapesToPolygon( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer ) const;
public:
static CUSTOM_COLORS_LIST g_SilkscreenColors;
static CUSTOM_COLORS_LIST g_MaskColors;
static CUSTOM_COLORS_LIST g_PasteColors;
static CUSTOM_COLORS_LIST g_FinishColors;
static CUSTOM_COLORS_LIST g_BoardColors;
static KIGFX::COLOR4D g_DefaultBackgroundTop;
static KIGFX::COLOR4D g_DefaultBackgroundBot;
static KIGFX::COLOR4D g_DefaultSilkscreen;
static KIGFX::COLOR4D g_DefaultSolderMask;
static KIGFX::COLOR4D g_DefaultSolderPaste;
static KIGFX::COLOR4D g_DefaultSurfaceFinish;
static KIGFX::COLOR4D g_DefaultBoardBody;
public:
SFVEC4F m_BgColorBot; ///< background bottom color
SFVEC4F m_BgColorTop; ///< background top color

View File

@ -23,96 +23,41 @@
#include "panel_3D_colors.h"
#include <widgets/color_swatch.h>
#include <3d_canvas/board_adapter.h>
#include <3d_viewer/eda_3d_viewer_frame.h>
#include <eda_3d_viewer_settings.h>
#include <settings/settings_manager.h>
#include <board_stackup_manager/stackup_predefined_prms.h>
#include <board_stackup_manager/board_stackup.h>
#include <board_design_settings.h>
#include <pgm_base.h>
PANEL_3D_COLORS::PANEL_3D_COLORS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ) :
PANEL_3D_COLORS_BASE( aParent ),
m_frame( aFrame ),
m_boardAdapter( aFrame->GetAdapter() )
{
#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 ) )
m_backgroundTop->SetDefaultColor( m_boardAdapter.g_DefaultBackgroundTop );
m_backgroundBottom->SetDefaultColor( m_boardAdapter.g_DefaultBackgroundBot );
m_backgroundTop->SetDefaultColor( COLOR4D( 0.8, 0.8, 0.9, 1.0 ) );
m_backgroundBottom->SetDefaultColor( COLOR4D( 0.4, 0.4, 0.5, 1.0 ) );
m_silkscreenTop->SetUserColors( &m_boardAdapter.g_SilkscreenColors );
m_silkscreenTop->SetDefaultColor( m_boardAdapter.g_DefaultSilkscreen );
m_silkscreenBottom->SetUserColors( &m_boardAdapter.g_SilkscreenColors );
m_silkscreenBottom->SetDefaultColor( m_boardAdapter.g_DefaultSilkscreen );
m_silkscreenTop->SetDefaultColor( COLOR4D( 0.9, 0.9, 0.9, 1.0 ) );
m_silkscreenBottom->SetDefaultColor( COLOR4D( 0.9, 0.9, 0.9, 1.0 ) );
m_solderMaskTop->SetUserColors( &m_boardAdapter.g_MaskColors );
m_solderMaskTop->SetDefaultColor( m_boardAdapter.g_DefaultSolderMask );
m_solderMaskBottom->SetUserColors( &m_boardAdapter.g_MaskColors );
m_solderMaskBottom->SetDefaultColor( m_boardAdapter.g_DefaultSolderMask );
ADD_COLOR( m_silkscreenColors, 241, 241, 241, 1.0, "White" );
ADD_COLOR( m_silkscreenColors, 4, 18, 21, 1.0, "Dark" );
m_silkscreenTop->SetUserColors( &m_silkscreenColors );
m_silkscreenBottom->SetUserColors( &m_silkscreenColors );
m_solderPaste->SetUserColors( &m_boardAdapter.g_PasteColors );
m_solderPaste->SetDefaultColor( m_boardAdapter.g_DefaultSolderPaste );
m_solderMaskTop->SetDefaultColor( COLOR4D( 0.1, 0.2, 0.1, 0.83 ) );
m_solderMaskBottom->SetDefaultColor( COLOR4D( 0.1, 0.2, 0.1, 0.83 ) );
m_surfaceFinish->SetUserColors( &m_boardAdapter.g_FinishColors );
m_surfaceFinish->SetDefaultColor( m_boardAdapter.g_DefaultSurfaceFinish );
ADD_COLOR( m_maskColors, 20, 51, 36, 0.83, "Green" );
ADD_COLOR( m_maskColors, 91, 168, 12, 0.83, "Light Green" );
ADD_COLOR( m_maskColors, 13, 104, 11, 0.83, "Saturated Green" );
ADD_COLOR( m_maskColors, 181, 19, 21, 0.83, "Red" );
ADD_COLOR( m_maskColors, 239, 53, 41, 0.83, "Red Light Orange" );
ADD_COLOR( m_maskColors, 210, 40, 14, 0.83, "Red 2" );
ADD_COLOR( m_maskColors, 2, 59, 162, 0.83, "Blue" );
ADD_COLOR( m_maskColors, 54, 79, 116, 0.83, "Light blue 1" );
ADD_COLOR( m_maskColors, 61, 85, 130, 0.83, "Light blue 2" );
ADD_COLOR( m_maskColors, 21, 70, 80, 0.83, "Green blue (dark)" );
ADD_COLOR( m_maskColors, 11, 11, 11, 0.83, "Black" );
ADD_COLOR( m_maskColors, 245, 245, 245, 0.83, "White" );
ADD_COLOR( m_maskColors, 119, 31, 91, 0.83, "Purple" );
ADD_COLOR( m_maskColors, 32, 2, 53, 0.83, "Purple Dark" );
m_solderMaskTop->SetUserColors( &m_maskColors );
m_solderMaskBottom->SetUserColors( &m_maskColors );
m_solderPaste->SetDefaultColor( COLOR4D( 0.4, 0.4, 0.4, 1.0 ) );
ADD_COLOR( m_pasteColors, 128, 128, 128, 1.0, "grey" );
ADD_COLOR( m_pasteColors, 213, 213, 213, 1.0, "Silver" );
ADD_COLOR( m_pasteColors, 90, 90, 90, 1.0, "grey 2" );
m_solderPaste->SetUserColors( &m_pasteColors );
m_surfaceFinish->SetDefaultColor( COLOR4D( 0.75, 0.61, 0.23, 1.0 ) );
ADD_COLOR( m_finishColors, 184, 115, 50, 1.0, "Copper" );
ADD_COLOR( m_finishColors, 178, 156, 0, 1.0, "Gold" );
ADD_COLOR( m_finishColors, 213, 213, 213, 1.0, "Silver" );
ADD_COLOR( m_finishColors, 160, 160, 160, 1.0, "Tin" );
m_surfaceFinish->SetUserColors( &m_finishColors );
m_boardBody->SetDefaultColor( COLOR4D( 0.4, 0.4, 0.5, 0.9 ) );
ADD_COLOR( m_boardColors, 51, 43, 22, 0.9, "FR4 natural, dark" );
ADD_COLOR( m_boardColors, 109, 116, 75, 0.9, "FR4 natural" );
ADD_COLOR( m_boardColors, 78, 14, 5, 0.9, "brown/red" );
ADD_COLOR( m_boardColors, 146, 99, 47, 0.9, "brown 1" );
ADD_COLOR( m_boardColors, 160, 123, 54, 0.9, "brown 2" );
ADD_COLOR( m_boardColors, 146, 99, 47, 0.9, "brown 3" );
ADD_COLOR( m_boardColors, 63, 126, 71, 0.9, "green 1" );
ADD_COLOR( m_boardColors, 117, 122, 90, 0.9, "green 2" );
m_boardBody->SetUserColors( &m_boardColors );
// Only allow the stackup to be used in the PCB editor, since it isn't editable in the other
// frames
m_loadStackup->Show( aFrame->Parent()->IsType( FRAME_PCB_EDITOR ) );
#undef ADD_COLOR
m_boardBody->SetUserColors( &m_boardAdapter.g_BoardColors );
m_boardBody->SetDefaultColor( m_boardAdapter.g_DefaultBoardBody );
}
bool PANEL_3D_COLORS::TransferDataToWindow()
{
auto to_COLOR4D = []( const SFVEC4F& src )
{
return COLOR4D( src.r, src.g, src.b, src.a );
};
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
m_backgroundTop->SetSupportsOpacity( false );
m_backgroundBottom->SetSupportsOpacity( false );
@ -124,15 +69,20 @@ bool PANEL_3D_COLORS::TransferDataToWindow()
m_surfaceFinish->SetSupportsOpacity( false );
m_boardBody->SetBackgroundColour( *wxWHITE );
m_backgroundTop->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_BgColorTop ), false );
m_backgroundBottom->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_BgColorBot ), false );
m_silkscreenTop->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_SilkScreenColorTop ), false );
m_silkscreenBottom->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_SilkScreenColorBot ), false );
m_solderMaskTop->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_SolderMaskColorTop ), false );
m_solderMaskBottom->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_SolderMaskColorBot ), false );
m_solderPaste->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_SolderPasteColor ), false );
m_surfaceFinish->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_CopperColor ), false );
m_boardBody->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_BoardBodyColor ), false );
m_backgroundTop->SetSwatchColor( colors->GetColor( LAYER_3D_BACKGROUND_TOP ), false );
m_backgroundBottom->SetSwatchColor( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ), false );
m_silkscreenTop->SetSwatchColor( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ), false );
m_silkscreenBottom->SetSwatchColor( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ), false );
m_solderMaskTop->SetSwatchColor( colors->GetColor( LAYER_3D_SOLDERMASK_TOP ), false );
m_solderMaskBottom->SetSwatchColor( colors->GetColor( LAYER_3D_SOLDERMASK_BOTTOM ), false );
m_solderPaste->SetSwatchColor( colors->GetColor( LAYER_3D_SOLDERPASTE ), false );
m_surfaceFinish->SetSwatchColor( colors->GetColor( LAYER_3D_COPPER ), false );
m_boardBody->SetSwatchColor( colors->GetColor( LAYER_3D_BOARD ), false );
if( colors->GetUseBoardStackupColors() )
m_boardStackupRB->SetValue( true );
else
m_specificColorsRB->SetValue( true );
return true;
}
@ -140,94 +90,21 @@ bool PANEL_3D_COLORS::TransferDataToWindow()
bool PANEL_3D_COLORS::TransferDataFromWindow()
{
auto to_SFVEC4F = []( const COLOR4D& src )
{
return SFVEC4F( src.r, src.g, src.b, src.a );
};
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
m_boardAdapter.m_BgColorTop = to_SFVEC4F( m_backgroundTop->GetSwatchColor() );
m_boardAdapter.m_BgColorBot = to_SFVEC4F( m_backgroundBottom->GetSwatchColor() );
m_boardAdapter.m_SilkScreenColorTop = to_SFVEC4F( m_silkscreenTop->GetSwatchColor() );
m_boardAdapter.m_SilkScreenColorBot = to_SFVEC4F( m_silkscreenBottom->GetSwatchColor() );
m_boardAdapter.m_SolderMaskColorTop = to_SFVEC4F( m_solderMaskTop->GetSwatchColor() );
m_boardAdapter.m_SolderMaskColorBot = to_SFVEC4F( m_solderMaskBottom->GetSwatchColor() );
m_boardAdapter.m_SolderPasteColor = to_SFVEC4F( m_solderPaste->GetSwatchColor() );
m_boardAdapter.m_CopperColor = to_SFVEC4F( m_surfaceFinish->GetSwatchColor() );
m_boardAdapter.m_BoardBodyColor = to_SFVEC4F( m_boardBody->GetSwatchColor() );
colors->SetColor( LAYER_3D_BACKGROUND_TOP, m_backgroundTop->GetSwatchColor() );
colors->SetColor( LAYER_3D_BACKGROUND_BOTTOM, m_backgroundBottom->GetSwatchColor() );
colors->SetColor( LAYER_3D_SILKSCREEN_TOP, m_silkscreenTop->GetSwatchColor() );
colors->SetColor( LAYER_3D_SILKSCREEN_BOTTOM, m_silkscreenBottom->GetSwatchColor() );
colors->SetColor( LAYER_3D_SOLDERMASK_TOP, m_solderMaskTop->GetSwatchColor() );
colors->SetColor( LAYER_3D_SOLDERMASK_BOTTOM, m_solderMaskBottom->GetSwatchColor() );
colors->SetColor( LAYER_3D_SOLDERPASTE, m_solderPaste->GetSwatchColor() );
colors->SetColor( LAYER_3D_COPPER, m_surfaceFinish->GetSwatchColor() );
colors->SetColor( LAYER_3D_BOARD, m_boardBody->GetSwatchColor() );
auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
colors->SetUseBoardStackupColors( m_boardStackupRB->GetValue() );
if( cfg )
m_frame->SaveSettings( cfg );
Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
return true;
}
void PANEL_3D_COLORS::OnLoadColorsFromBoardStackup( wxCommandEvent& event )
{
const BOARD* brd = m_boardAdapter.GetBoard();
const FAB_LAYER_COLOR* stdColors = GetColorStandardList();
wxColour color;
if( brd )
{
const BOARD_STACKUP& stckp = brd->GetDesignSettings().GetStackupDescriptor();
for( const BOARD_STACKUP_ITEM* stckpItem : stckp.GetList() )
{
wxString colorName = stckpItem->GetColor();
if( colorName.StartsWith( "#" ) ) // This is a user defined color.
{
color.Set( colorName );
}
else
{
for( int i = 0; i < GetColorStandardListCount(); i++ )
{
if( stdColors[i].m_ColorName == colorName )
{
color = stdColors[i].m_Color;
break;
}
}
}
if( color.IsOk() )
{
switch( stckpItem->GetBrdLayerId() )
{
case F_SilkS:
m_boardAdapter.m_SilkScreenColorTop.r = color.Red() / 255.0;
m_boardAdapter.m_SilkScreenColorTop.g = color.Green() / 255.0;
m_boardAdapter.m_SilkScreenColorTop.b = color.Blue() / 255.0;
break;
case B_SilkS:
m_boardAdapter.m_SilkScreenColorBot.r = color.Red() / 255.0;
m_boardAdapter.m_SilkScreenColorBot.g = color.Green() / 255.0;
m_boardAdapter.m_SilkScreenColorBot.b = color.Blue() / 255.0;
break;
case F_Mask:
m_boardAdapter.m_SolderMaskColorTop.r = color.Red() / 255.0;
m_boardAdapter.m_SolderMaskColorTop.g = color.Green() / 255.0;
m_boardAdapter.m_SolderMaskColorTop.b = color.Blue() / 255.0;
// Keep the previous alpha value
//m_boardAdapter.m_SolderMaskColorTop.a = color.Alpha() / 255.0;
break;
case B_Mask:
m_boardAdapter.m_SolderMaskColorBot.r = color.Red() / 255.0;
m_boardAdapter.m_SolderMaskColorBot.g = color.Green() / 255.0;
m_boardAdapter.m_SolderMaskColorBot.b = color.Blue() / 255.0;
// Keep the previous alpha value
//m_boardAdapter.m_SolderMaskColorBot.a = color.Alpha() / 255.0;
break;
default:
break;
}
}
}
TransferDataToWindow();
}
}

View File

@ -38,17 +38,8 @@ public:
/// Automatically called after creating the dialog
bool TransferDataToWindow() override;
void OnLoadColorsFromBoardStackup( wxCommandEvent& event ) override;
private:
EDA_3D_VIEWER_FRAME* m_frame;
BOARD_ADAPTER& m_boardAdapter;
CUSTOM_COLORS_LIST m_silkscreenColors;
CUSTOM_COLORS_LIST m_maskColors;
CUSTOM_COLORS_LIST m_pasteColors;
CUSTOM_COLORS_LIST m_finishColors;
CUSTOM_COLORS_LIST m_boardColors;
BOARD_ADAPTER& m_boardAdapter;
};

View File

@ -17,114 +17,128 @@ PANEL_3D_COLORS_BASE::PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id, con
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerMargins;
bSizerMargins = new wxBoxSizer( wxHORIZONTAL );
bSizerMargins = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbEnvironmentColors;
sbEnvironmentColors = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Environment Colors") ), wxVERTICAL );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 2, 5, 0 );
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
backgroundTopLabel = new wxStaticText( this, wxID_ANY, _("Background top:"), wxDefaultPosition, wxDefaultSize, 0 );
backgroundTopLabel = new wxStaticText( sbEnvironmentColors->GetStaticBox(), wxID_ANY, _("Background gradient start:"), wxDefaultPosition, wxDefaultSize, 0 );
backgroundTopLabel->Wrap( -1 );
fgSizer1->Add( backgroundTopLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer1->Add( backgroundTopLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_backgroundTop = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_backgroundTop = new COLOR_SWATCH( sbEnvironmentColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_backgroundTop, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
backgroundBotLabel = new wxStaticText( this, wxID_ANY, _("Background bottom:"), wxDefaultPosition, wxDefaultSize, 0 );
backgroundBotLabel = new wxStaticText( sbEnvironmentColors->GetStaticBox(), wxID_ANY, _("Background gradient end:"), wxDefaultPosition, wxDefaultSize, 0 );
backgroundBotLabel->Wrap( -1 );
fgSizer1->Add( backgroundBotLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer1->Add( backgroundBotLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_backgroundBottom = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_backgroundBottom = new COLOR_SWATCH( sbEnvironmentColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_backgroundBottom, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( 0, 10, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 6, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
silkscreenTopLabel = new wxStaticText( this, wxID_ANY, _("Silkscreen top:"), wxDefaultPosition, wxDefaultSize, 0 );
silkscreenTopLabel->Wrap( -1 );
fgSizer1->Add( silkscreenTopLabel, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_silkscreenTop = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_silkscreenTop, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
silkscreenBottomLabel = new wxStaticText( this, wxID_ANY, _("Silkscreen bottom:"), wxDefaultPosition, wxDefaultSize, 0 );
silkscreenBottomLabel->Wrap( -1 );
fgSizer1->Add( silkscreenBottomLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_silkscreenBottom = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_silkscreenBottom, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( 0, 10, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
solderMaskTopLabel = new wxStaticText( this, wxID_ANY, _("Solder mask top:"), wxDefaultPosition, wxDefaultSize, 0 );
solderMaskTopLabel->Wrap( -1 );
fgSizer1->Add( solderMaskTopLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_solderMaskTop = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_solderMaskTop, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
solderMaskBottomLabel = new wxStaticText( this, wxID_ANY, _("Solder mask bottom:"), wxDefaultPosition, wxDefaultSize, 0 );
solderMaskBottomLabel->Wrap( -1 );
fgSizer1->Add( solderMaskBottomLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_solderMaskBottom = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_solderMaskBottom, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( 0, 10, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
solderPasteLabel = new wxStaticText( this, wxID_ANY, _("Solder paste:"), wxDefaultPosition, wxDefaultSize, 0 );
solderPasteLabel = new wxStaticText( sbEnvironmentColors->GetStaticBox(), wxID_ANY, _("Solder paste:"), wxDefaultPosition, wxDefaultSize, 0 );
solderPasteLabel->Wrap( -1 );
fgSizer1->Add( solderPasteLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer1->Add( solderPasteLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_solderPaste = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_solderPaste = new COLOR_SWATCH( sbEnvironmentColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_solderPaste, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer1->Add( 0, 10, 1, wxEXPAND, 5 );
sbEnvironmentColors->Add( fgSizer1, 0, wxBOTTOM, 10 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
bSizerMargins->Add( sbEnvironmentColors, 0, wxEXPAND|wxBOTTOM, 5 );
surfaceFinishLabel = new wxStaticText( this, wxID_ANY, _("Copper/surface finish:"), wxDefaultPosition, wxDefaultSize, 0 );
wxStaticBoxSizer* sbBoardColors;
sbBoardColors = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Board Colors") ), wxVERTICAL );
m_boardStackupRB = new wxRadioButton( sbBoardColors->GetStaticBox(), wxID_ANY, _("Use board stackup colors"), wxDefaultPosition, wxDefaultSize, 0 );
sbBoardColors->Add( m_boardStackupRB, 0, wxBOTTOM, 5 );
m_specificColorsRB = new wxRadioButton( sbBoardColors->GetStaticBox(), wxID_ANY, _("Use colors:"), wxDefaultPosition, wxDefaultSize, 0 );
sbBoardColors->Add( m_specificColorsRB, 0, wxTOP|wxBOTTOM, 5 );
wxFlexGridSizer* fgSizer2;
fgSizer2 = new wxFlexGridSizer( 0, 2, 5, 0 );
fgSizer2->SetFlexibleDirection( wxBOTH );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
silkscreenTopLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Silkscreen top:"), wxDefaultPosition, wxDefaultSize, 0 );
silkscreenTopLabel->Wrap( -1 );
fgSizer2->Add( silkscreenTopLabel, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 );
m_silkscreenTop = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_silkscreenTop, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
silkscreenBottomLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Silkscreen bottom:"), wxDefaultPosition, wxDefaultSize, 0 );
silkscreenBottomLabel->Wrap( -1 );
fgSizer2->Add( silkscreenBottomLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 20 );
m_silkscreenBottom = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_silkscreenBottom, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer2->Add( 0, 6, 1, wxEXPAND, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
solderMaskTopLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Solder mask top:"), wxDefaultPosition, wxDefaultSize, 0 );
solderMaskTopLabel->Wrap( -1 );
fgSizer2->Add( solderMaskTopLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 20 );
m_solderMaskTop = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_solderMaskTop, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
solderMaskBottomLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Solder mask bottom:"), wxDefaultPosition, wxDefaultSize, 0 );
solderMaskBottomLabel->Wrap( -1 );
fgSizer2->Add( solderMaskBottomLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 20 );
m_solderMaskBottom = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_solderMaskBottom, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer2->Add( 0, 6, 1, wxEXPAND, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
surfaceFinishLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Copper/surface finish:"), wxDefaultPosition, wxDefaultSize, 0 );
surfaceFinishLabel->Wrap( -1 );
fgSizer1->Add( surfaceFinishLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer2->Add( surfaceFinishLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 20 );
m_surfaceFinish = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_surfaceFinish, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_surfaceFinish = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_surfaceFinish, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( 0, 10, 1, wxEXPAND, 5 );
fgSizer2->Add( 0, 6, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
boardBodyLabel = new wxStaticText( this, wxID_ANY, _("Board body:"), wxDefaultPosition, wxDefaultSize, 0 );
boardBodyLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Board body:"), wxDefaultPosition, wxDefaultSize, 0 );
boardBodyLabel->Wrap( -1 );
fgSizer1->Add( boardBodyLabel, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer2->Add( boardBodyLabel, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 );
m_boardBody = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_boardBody, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_boardBody = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_boardBody, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bSizerMargins->Add( fgSizer1, 0, wxTOP, 5 );
sbBoardColors->Add( fgSizer2, 1, wxEXPAND, 5 );
bSizerMargins->Add( 0, 0, 1, wxEXPAND, 5 );
m_loadStackup = new wxButton( this, wxID_ANY, _("Load Colors from Board Stackup"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerMargins->Add( m_loadStackup, 0, wxALL, 5 );
bSizerMargins->Add( sbBoardColors, 0, wxEXPAND|wxTOP, 5 );
bSizerMain->Add( bSizerMargins, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );
@ -133,14 +147,8 @@ PANEL_3D_COLORS_BASE::PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id, con
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
// Connect Events
m_loadStackup->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_3D_COLORS_BASE::OnLoadColorsFromBoardStackup ), NULL, this );
}
PANEL_3D_COLORS_BASE::~PANEL_3D_COLORS_BASE()
{
// Disconnect Events
m_loadStackup->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_3D_COLORS_BASE::OnLoadColorsFromBoardStackup ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -19,10 +19,8 @@ class COLOR_SWATCH;
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/statbox.h>
#include <wx/radiobut.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
@ -40,6 +38,10 @@ class PANEL_3D_COLORS_BASE : public wxPanel
COLOR_SWATCH* m_backgroundTop;
wxStaticText* backgroundBotLabel;
COLOR_SWATCH* m_backgroundBottom;
wxStaticText* solderPasteLabel;
COLOR_SWATCH* m_solderPaste;
wxRadioButton* m_boardStackupRB;
wxRadioButton* m_specificColorsRB;
wxStaticText* silkscreenTopLabel;
COLOR_SWATCH* m_silkscreenTop;
wxStaticText* silkscreenBottomLabel;
@ -48,17 +50,10 @@ class PANEL_3D_COLORS_BASE : public wxPanel
COLOR_SWATCH* m_solderMaskTop;
wxStaticText* solderMaskBottomLabel;
COLOR_SWATCH* m_solderMaskBottom;
wxStaticText* solderPasteLabel;
COLOR_SWATCH* m_solderPaste;
wxStaticText* surfaceFinishLabel;
COLOR_SWATCH* m_surfaceFinish;
wxStaticText* boardBodyLabel;
COLOR_SWATCH* m_boardBody;
wxButton* m_loadStackup;
// Virtual event handlers, overide them in your derived class
virtual void OnLoadColorsFromBoardStackup( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -37,9 +37,7 @@
#include <3d_viewer/tools/eda_3d_conditions.h>
#include <bitmaps.h>
#include <board_design_settings.h>
#include <board_stackup_manager/board_stackup.h>
#include <core/arraydim.h>
#include <layer_ids.h>
#include <gal/dpi_scaling.h>
#include <pgm_base.h>
#include <project.h>
@ -414,27 +412,6 @@ void EDA_3D_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE *aCfg )
wxLogTrace( m_logTrace, "EDA_3D_VIEWER_FRAME::LoadSettings" );
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
auto set_color =
[] ( const COLOR4D& aColor, SFVEC4F& aTarget )
{
aTarget.r = aColor.r;
aTarget.g = aColor.g;
aTarget.b = aColor.b;
aTarget.a = aColor.a;
};
set_color( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ), m_boardAdapter.m_BgColorBot );
set_color( colors->GetColor( LAYER_3D_BACKGROUND_TOP ), m_boardAdapter.m_BgColorTop );
set_color( colors->GetColor( LAYER_3D_BOARD ), m_boardAdapter.m_BoardBodyColor );
set_color( colors->GetColor( LAYER_3D_COPPER ), m_boardAdapter.m_CopperColor );
set_color( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ), m_boardAdapter.m_SilkScreenColorBot );
set_color( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ), m_boardAdapter.m_SilkScreenColorTop );
set_color( colors->GetColor( LAYER_3D_SOLDERMASK_BOTTOM ), m_boardAdapter.m_SolderMaskColorBot );
set_color( colors->GetColor( LAYER_3D_SOLDERMASK_TOP ), m_boardAdapter.m_SolderMaskColorTop );
set_color( colors->GetColor( LAYER_3D_SOLDERPASTE ), m_boardAdapter.m_SolderPasteColor );
if( cfg )
{
m_boardAdapter.m_RtCameraLightColor =
@ -551,43 +528,6 @@ void EDA_3D_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE *aCfg )
wxLogTrace( m_logTrace, "EDA_3D_VIEWER_FRAME::SaveSettings" );
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
auto save_color =
[colors] ( SFVEC4F& aSource, LAYER_3D_ID aTarget )
{
// You could think just copy the new color in config is enough.
// unfortunately, SFVEC4F uses floats, and COLOR4D uses doubles,
// and the conversion SFVEC4F from/to COLOR4D creates small diffs.
//
// This has no matter to draw colors, but creates slight differences
// in config file, that appears always modified.
// So we must compare the SFVEC4F old and new values and update only
// actual changes.
SFVEC4F newSFVEC4Fcolor( float( colors->GetColor( aTarget ).r ),
float( colors->GetColor( aTarget ).g ),
float( colors->GetColor( aTarget ).b ),
float( colors->GetColor( aTarget ).a ) );
if( aSource != newSFVEC4Fcolor )
{
colors->SetColor( aTarget, COLOR4D( aSource.r, aSource.g, aSource.b,
aSource.a ) );
}
};
save_color( m_boardAdapter.m_BgColorBot, LAYER_3D_BACKGROUND_BOTTOM );
save_color( m_boardAdapter.m_BgColorTop, LAYER_3D_BACKGROUND_TOP );
save_color( m_boardAdapter.m_BoardBodyColor, LAYER_3D_BOARD );
save_color( m_boardAdapter.m_CopperColor, LAYER_3D_COPPER );
save_color( m_boardAdapter.m_SilkScreenColorBot, LAYER_3D_SILKSCREEN_BOTTOM );
save_color( m_boardAdapter.m_SilkScreenColorTop, LAYER_3D_SILKSCREEN_TOP );
save_color( m_boardAdapter.m_SolderMaskColorBot, LAYER_3D_SOLDERMASK_BOTTOM );
save_color( m_boardAdapter.m_SolderMaskColorTop, LAYER_3D_SOLDERMASK_TOP );
save_color( m_boardAdapter.m_SolderPasteColor, LAYER_3D_SOLDERPASTE );
Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
wxLogTrace( m_logTrace, m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::RAYTRACING ?
"EDA_3D_VIEWER_FRAME::SaveSettings render setting Ray Trace" :
"EDA_3D_VIEWER_FRAME::SaveSettings render setting OpenGL" );

View File

@ -35,7 +35,8 @@ const int colorsSchemaVersion = 3;
COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename ) :
JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::COLORS, colorsSchemaVersion ),
m_overrideSchItemColors( false )
m_overrideSchItemColors( false ),
m_useBoardStackupColors( true )
{
m_params.emplace_back( new PARAM<wxString>( "meta.name", &m_displayName, "KiCad Default" ) );
@ -63,6 +64,9 @@ COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename ) :
m_params.emplace_back( new PARAM<bool>( "schematic.override_item_colors",
&m_overrideSchItemColors, false ) );
m_params.emplace_back( new PARAM<bool>( "3d_viewer.use_board_stackup_colors",
&m_overrideSchItemColors, true ) );
#define CLR( x, y ) \
wxASSERT( s_defaultTheme.count( y ) ); \
m_params.emplace_back( new COLOR_MAP_PARAM( x, y, s_defaultTheme.at( y ), &m_colors ) );
@ -271,6 +275,7 @@ void COLOR_SETTINGS::initFromOther( const COLOR_SETTINGS& aOther )
{
m_displayName = aOther.m_displayName;
m_overrideSchItemColors = aOther.m_overrideSchItemColors;
m_useBoardStackupColors = aOther.m_useBoardStackupColors;
m_colors = aOther.m_colors;
m_defaultColors = aOther.m_defaultColors;
m_writeFile = aOther.m_writeFile;

View File

@ -84,6 +84,9 @@ public:
bool GetOverrideSchItemColors() const { return m_overrideSchItemColors; }
void SetOverrideSchItemColors( bool aFlag ) { m_overrideSchItemColors = aFlag; }
bool GetUseBoardStackupColors() const { return m_useBoardStackupColors; }
void SetUseBoardStackupColors( bool aFlag ) { m_useBoardStackupColors = aFlag; }
/**
* Constructs and returns a list of color settings objects based on the built-in color themes.
* These color settings are not backed by a file and cannot be modified by the user.
@ -101,6 +104,7 @@ private:
wxString m_displayName;
bool m_overrideSchItemColors;
bool m_useBoardStackupColors;
/**
* Map of all layer colors.

View File

@ -23,10 +23,6 @@
*/
/**
* @file dielectric_material.cpp
*/
#include "stackup_predefined_prms.h"
#include "dielectric_material.h"
#include <core/arraydim.h>
@ -41,31 +37,32 @@
// DO NOT translate them, as they are proper noun
static DIELECTRIC_SUBSTRATE substrateMaterial[] =
{
{ NotSpecifiedPrm(), 0.0, 0.0 }, // Not specified, not in .gbrjob
{ "FR4", 4.5, 0.02 }, // used in .gbrjob file
{ "FR408-HR", 3.69, 0.0091 }, // used in .gbrjob file
{ "Polyimide", 1.0, 0.0 }, // used in .gbrjob file
{ "Polyolefin", 1.0, 0.0 }, // used in .gbrjob file
{ "Al", 8.7, 0.001 }, // used in .gbrjob file
{ "PTFE", 2.1, 0.0002 }, // used in .gbrjob file
{ "Teflon", 2.1, 0.0002 }, // used in .gbrjob file
{ "Ceramic", 1.0, 0.0 } // used in .gbrjob file
// Other names are free
{ NotSpecifiedPrm(), 0.0, 0.0 }, // Not specified, not in .gbrjob
{ "FR4", 4.5, 0.02 }, // used in .gbrjob file
{ "FR408-HR", 3.69, 0.0091 }, // used in .gbrjob file
{ "Polyimide", 3.2, 0.004 }, // used in .gbrjob file
{ "Kapton", 3.2, 0.004 }, // used in .gbrjob file
{ "Polyolefin", 1.0, 0.0 }, // used in .gbrjob file
{ "Al", 8.7, 0.001 }, // used in .gbrjob file
{ "PTFE", 2.1, 0.0002 }, // used in .gbrjob file
{ "Teflon", 2.1, 0.0002 }, // used in .gbrjob file
{ "Ceramic", 1.0, 0.0 } // used in .gbrjob file
// Other names are free
};
static DIELECTRIC_SUBSTRATE solderMaskMaterial[] =
{
{ NotSpecifiedPrm(), DEFAULT_EPSILON_R_SOLDERMASK, 0.0 }, // Not specified, not in .gbrjob
{ "Epoxy", DEFAULT_EPSILON_R_SOLDERMASK, 0.0 }, // Epoxy Liquid material (usual)
{ "Liquid Ink", DEFAULT_EPSILON_R_SOLDERMASK, 0.0 }, // Liquid Ink Photoimageable
{ "Dry Film", DEFAULT_EPSILON_R_SOLDERMASK, 0.0 } // Dry Film Photoimageable
{ "Epoxy", DEFAULT_EPSILON_R_SOLDERMASK, 0.0 }, // Epoxy Liquid material (usual)
{ "Liquid Ink", DEFAULT_EPSILON_R_SOLDERMASK, 0.0 }, // Liquid Ink Photoimageable
{ "Dry Film", DEFAULT_EPSILON_R_SOLDERMASK, 0.0 } // Dry Film Photoimageable
};
static DIELECTRIC_SUBSTRATE silkscreenMaterial[] =
{
{ NotSpecifiedPrm(), DEFAULT_EPSILON_R_SILKSCREEN, 0.0 }, // Not specified, not in .gbrjob
{ "Liquid Photo", DEFAULT_EPSILON_R_SILKSCREEN, 0.0 }, // Liquid Ink Photoimageable
{ "Direct Printing", DEFAULT_EPSILON_R_SILKSCREEN, 0.0 } // Direct Legend Printing
{ NotSpecifiedPrm(), DEFAULT_EPSILON_R_SILKSCREEN, 0.0 }, // Not specified, not in .gbrjob
{ "Liquid Photo", DEFAULT_EPSILON_R_SILKSCREEN, 0.0 }, // Liquid Ink Photoimageable
{ "Direct Printing", DEFAULT_EPSILON_R_SILKSCREEN, 0.0 } // Direct Legend Printing
};
@ -135,14 +132,16 @@ int DIELECTRIC_SUBSTRATE_LIST::FindSubstrate( DIELECTRIC_SUBSTRATE* aItem )
{
// Find a item matching aItem. The comparison is for the name case insensitive
int idx = 0;
for( DIELECTRIC_SUBSTRATE& item : m_substrateList )
{
if( item.m_EpsilonR == aItem->m_EpsilonR &&
item.m_LossTangent == aItem->m_LossTangent &&
item.m_Name.CmpNoCase( aItem->m_Name ) == 0
)
item.m_Name.CmpNoCase( aItem->m_Name ) == 0 )
{
return idx;
}
++idx;
}
@ -155,14 +154,16 @@ int DIELECTRIC_SUBSTRATE_LIST::FindSubstrate( const wxString& aName, double aEps
{
// Find a item matching parameters
int idx = 0;
for( DIELECTRIC_SUBSTRATE& item : m_substrateList )
{
if( item.m_EpsilonR == aEpsilonR &&
item.m_LossTangent == aLossTg &&
item.m_Name.CmpNoCase( aName ) == 0
)
item.m_Name.CmpNoCase( aName ) == 0 )
{
return idx;
}
++idx;
}

View File

@ -23,17 +23,10 @@
*/
/**
* @file stackup_predefined_prms.cpp
*/
#include "board_stackup.h"
#include <convert_to_biu.h>
#include <wx/string.h>
#include <core/arraydim.h>
#include <layer_ids.h>
#include <board_design_settings.h>
#include <i18n_utility.h> // _HKI definition
#include <macros.h>
#include "stackup_predefined_prms.h"
// A list of copper finish standard type names
@ -67,14 +60,15 @@ static wxString CopperFinishType[] =
// and R<integer>G<integer>B<integer> In gbrjob file.
static FAB_LAYER_COLOR solderMaskColors[] =
{
{ NotSpecifiedPrm(), wxColor( 80, 80, 80 ) }, // Not specified, not in .gbrjob file
{ _HKI( "Green" ), wxColor( 60, 150, 80 ) }, // used in .gbrjob file
{ _HKI( "Red" ), wxColor( 128, 0, 0 ) }, // used in .gbrjob file
{ _HKI( "Blue" ), wxColor( 0, 0, 128 ) }, // used in .gbrjob file
{ _HKI( "Black" ), wxColor( 20, 20, 20 ) }, // used in .gbrjob file
{ _HKI( "White" ), wxColor( 200, 200, 200 ) }, // used in .gbrjob file
{ _HKI( "Yellow" ), wxColor( 128, 128, 0 ) }, // used in .gbrjob file
{ _HKI( "User defined" ), wxColor( 128, 128, 128 ) }//free. the name is a dummy name here
{ NotSpecifiedPrm(), wxColor( 80, 80, 80 ) }, // Not specified, not in .gbrjob file
{ _HKI( "Green" ), wxColor( 60, 150, 80 ) }, // used in .gbrjob file
{ _HKI( "Red" ), wxColor( 128, 0, 0 ) }, // used in .gbrjob file
{ _HKI( "Blue" ), wxColor( 0, 0, 128 ) }, // used in .gbrjob file
{ _HKI( "Purple" ), wxColor( 80, 0, 80 ) }, // used in .gbrjob file
{ _HKI( "Black" ), wxColor( 20, 20, 20 ) }, // used in .gbrjob file
{ _HKI( "White" ), wxColor( 200, 200, 200 ) }, // used in .gbrjob file
{ _HKI( "Yellow" ), wxColor( 128, 128, 0 ) }, // used in .gbrjob file
{ _HKI( "User defined" ), wxColor( 128, 128, 128 ) } // free. the name is a dummy name here
};