mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 00:21:25 +00:00
When following board or plot settings, write results to current config.
Also adds migration from older layer numbers to strings. This may require users to dump their 9.0 settings files (which will have the wrong layer numbers in them), but those files are often useless anyway as they'll already have messed up colours if they were migrated from 8.0. Fixes https://gitlab.com/kicad/code/kicad/-/issues/18709
This commit is contained in:
parent
6729e313a5
commit
241962a84d
@ -879,26 +879,6 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetVisibleLayers() const
|
||||
{
|
||||
ret = preset->layers;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.set( LAYER_3D_BOARD, m_Cfg->m_Render.show_board_body );
|
||||
ret.set( LAYER_3D_COPPER_TOP, m_Cfg->m_Render.show_copper_top );
|
||||
ret.set( LAYER_3D_COPPER_BOTTOM, m_Cfg->m_Render.show_copper_bottom );
|
||||
ret.set( LAYER_3D_SILKSCREEN_TOP, m_Cfg->m_Render.show_silkscreen_top );
|
||||
ret.set( LAYER_3D_SILKSCREEN_BOTTOM, m_Cfg->m_Render.show_silkscreen_bottom );
|
||||
ret.set( LAYER_3D_SOLDERMASK_TOP, m_Cfg->m_Render.show_soldermask_top );
|
||||
ret.set( LAYER_3D_SOLDERMASK_BOTTOM, m_Cfg->m_Render.show_soldermask_bottom );
|
||||
ret.set( LAYER_3D_SOLDERPASTE, m_Cfg->m_Render.show_solderpaste );
|
||||
ret.set( LAYER_3D_ADHESIVE, m_Cfg->m_Render.show_adhesive );
|
||||
ret.set( LAYER_3D_USER_COMMENTS, m_Cfg->m_Render.show_comments );
|
||||
ret.set( LAYER_3D_USER_DRAWINGS, m_Cfg->m_Render.show_drawings );
|
||||
ret.set( LAYER_3D_USER_ECO1, m_Cfg->m_Render.show_eco1 );
|
||||
ret.set( LAYER_3D_USER_ECO2, m_Cfg->m_Render.show_eco2 );
|
||||
|
||||
ret.set( LAYER_FP_REFERENCES, m_Cfg->m_Render.show_fp_references );
|
||||
ret.set( LAYER_FP_VALUES, m_Cfg->m_Render.show_fp_values );
|
||||
ret.set( LAYER_FP_TEXT, m_Cfg->m_Render.show_fp_text );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -81,6 +81,35 @@ PARAM_LAYER_PRESET_3D::PARAM_LAYER_PRESET_3D( const std::string& aPath,
|
||||
m_presets( aPresetList )
|
||||
{
|
||||
wxASSERT( aPresetList );
|
||||
|
||||
#define LAYER( n, l ) m_layerToLayerNameMap[l] = n; m_layerNameToLayerMap[n] = l;
|
||||
|
||||
LAYER( "fp_values", LAYER_FP_VALUES );
|
||||
LAYER( "fp_references", LAYER_FP_REFERENCES );
|
||||
LAYER( "fp_text", LAYER_FP_TEXT );
|
||||
LAYER( "background_bottom", LAYER_3D_BACKGROUND_BOTTOM );
|
||||
LAYER( "background_top", LAYER_3D_BACKGROUND_TOP );
|
||||
LAYER( "board", LAYER_3D_BOARD );
|
||||
LAYER( "copper", LAYER_3D_COPPER_TOP );
|
||||
LAYER( "copper_bottom", LAYER_3D_COPPER_BOTTOM );
|
||||
LAYER( "silkscreen_bottom", LAYER_3D_SILKSCREEN_BOTTOM );
|
||||
LAYER( "silkscreen_top", LAYER_3D_SILKSCREEN_TOP );
|
||||
LAYER( "soldermask_bottom", LAYER_3D_SOLDERMASK_BOTTOM );
|
||||
LAYER( "soldermask_top", LAYER_3D_SOLDERMASK_TOP );
|
||||
LAYER( "solderpaste", LAYER_3D_SOLDERPASTE );
|
||||
LAYER( "adhesive", LAYER_3D_ADHESIVE );
|
||||
LAYER( "user_comments", LAYER_3D_USER_COMMENTS );
|
||||
LAYER( "user_drawings", LAYER_3D_USER_DRAWINGS );
|
||||
LAYER( "user_eco1", LAYER_3D_USER_ECO1 );
|
||||
LAYER( "user_eco2", LAYER_3D_USER_ECO2 );
|
||||
LAYER( "3d_axes", LAYER_3D_AXES );
|
||||
LAYER( "th_models", LAYER_3D_TH_MODELS );
|
||||
LAYER( "smd_models", LAYER_3D_SMD_MODELS );
|
||||
LAYER( "virtual_models", LAYER_3D_VIRTUAL_MODELS );
|
||||
LAYER( "non_pos_file_models", LAYER_3D_MODELS_NOT_IN_POS );
|
||||
LAYER( "dnp_models", LAYER_3D_MODELS_MARKED_DNP );
|
||||
LAYER( "bounding_boxes", LAYER_3D_BOUNDING_BOXES );
|
||||
LAYER( "off_board_silk", LAYER_3D_OFF_BOARD_SILK );
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +128,7 @@ nlohmann::json PARAM_LAYER_PRESET_3D::presetsToJson()
|
||||
for( int layer = 0; layer < LAYER_3D_END; ++layer )
|
||||
{
|
||||
if( preset.layers.test( layer ) )
|
||||
layers.push_back( layer );
|
||||
layers.push_back( m_layerToLayerNameMap[layer] );
|
||||
}
|
||||
|
||||
js["layers"] = layers;
|
||||
@ -109,7 +138,7 @@ nlohmann::json PARAM_LAYER_PRESET_3D::presetsToJson()
|
||||
for( const auto& [ layer, color ] : preset.colors )
|
||||
{
|
||||
nlohmann::json layerColor = {
|
||||
{ "layer", layer },
|
||||
{ "layer", m_layerToLayerNameMap[layer] },
|
||||
{ "color", color.ToCSSString() }
|
||||
};
|
||||
|
||||
@ -144,26 +173,20 @@ void PARAM_LAYER_PRESET_3D::jsonToPresets( const nlohmann::json& aJson )
|
||||
|
||||
for( const nlohmann::json& layer : preset.at( "layers" ) )
|
||||
{
|
||||
if( layer.is_number_integer() )
|
||||
{
|
||||
int layerNum = layer.get<int>();
|
||||
|
||||
if( layerNum >= 0 && layerNum < LAYER_3D_END )
|
||||
p.layers.set( layerNum );
|
||||
}
|
||||
if( layer.is_string() )
|
||||
p.layers.set( m_layerNameToLayerMap[layer.get<wxString>()] );
|
||||
}
|
||||
}
|
||||
|
||||
if( preset.contains( "colors" ) && preset.at( "colors" ).is_array() )
|
||||
{
|
||||
for( const nlohmann::json& layerColor : preset.at( "colors" ) )
|
||||
for( const nlohmann::json& entry : preset.at( "colors" ) )
|
||||
{
|
||||
if( layerColor.contains( "layer" ) && layerColor.contains( "color" )
|
||||
&& layerColor.at( "layer" ).is_number_integer() )
|
||||
if( entry.contains( "layer" ) && entry.contains( "color" )
|
||||
&& entry.at( "layer" ).is_string() )
|
||||
{
|
||||
int layerNum = layerColor.at( "layer" ).get<int>();
|
||||
COLOR4D color = layerColor.at( "color" ).get<COLOR4D>();
|
||||
p.colors[ layerNum ] = color;
|
||||
int layerNum = m_layerNameToLayerMap[entry.at( "layer" ).get<wxString>()];
|
||||
p.colors[ layerNum ] = entry.at( "color" ).get<COLOR4D>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,7 +198,7 @@ void PARAM_LAYER_PRESET_3D::jsonToPresets( const nlohmann::json& aJson )
|
||||
|
||||
|
||||
///! Update the schema version whenever a migration is required
|
||||
const int viewer3dSchemaVersion = 3;
|
||||
const int viewer3dSchemaVersion = 4;
|
||||
|
||||
|
||||
EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
|
||||
@ -425,6 +448,69 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
|
||||
Set( "render.show_eco2", *optval );
|
||||
}
|
||||
|
||||
return true;
|
||||
} );
|
||||
|
||||
registerMigration( 3, 4,
|
||||
[&]() -> bool
|
||||
{
|
||||
std::map<int, wxString> legacyColorMap;
|
||||
|
||||
legacyColorMap[142] = "fp_values";
|
||||
legacyColorMap[143] = "fp_references";
|
||||
legacyColorMap[130] = "fp_text";
|
||||
legacyColorMap[466] = "background_bottom";
|
||||
legacyColorMap[467] = "background_top";
|
||||
legacyColorMap[468] = "board";
|
||||
legacyColorMap[469] = "copper";
|
||||
legacyColorMap[470] = "copper_bottom";
|
||||
legacyColorMap[471] = "silkscreen_bottom";
|
||||
legacyColorMap[472] = "silkscreen_top";
|
||||
legacyColorMap[473] = "soldermask_bottom";
|
||||
legacyColorMap[474] = "soldermask_top";
|
||||
legacyColorMap[475] = "solderpaste";
|
||||
legacyColorMap[476] = "adhesive";
|
||||
legacyColorMap[477] = "user_comments";
|
||||
legacyColorMap[478] = "user_drawings";
|
||||
legacyColorMap[479] = "user_eco1";
|
||||
legacyColorMap[480] = "user_eco2";
|
||||
legacyColorMap[481] = "th_models";
|
||||
legacyColorMap[482] = "smd_models";
|
||||
legacyColorMap[483] = "virtual_models";
|
||||
legacyColorMap[484] = "non_pos_file_models";
|
||||
legacyColorMap[485] = "dnp_models";
|
||||
legacyColorMap[486] = "3d_axes";
|
||||
legacyColorMap[487] = "bounding_boxes";
|
||||
legacyColorMap[488] = "off_board_silk";
|
||||
|
||||
if( !Contains( "layer_presets" ) || !At( "layer_presets" ).is_array() )
|
||||
return true;
|
||||
|
||||
for( nlohmann::json& preset : At( "layer_presets" ) )
|
||||
{
|
||||
if( preset.contains( "colors" ) && preset.at( "colors" ).is_array() )
|
||||
{
|
||||
for( nlohmann::json& color : preset.at( "colors" ) )
|
||||
{
|
||||
if( color.contains( "layer" ) && color.at( "layer" ).is_number_integer() )
|
||||
color["layer"] = legacyColorMap[color["layer"].get<int>()];
|
||||
}
|
||||
}
|
||||
|
||||
if( preset.contains( "layers" ) && preset.at( "layers" ).is_array() )
|
||||
{
|
||||
nlohmann::json mappedLayers = nlohmann::json::array();
|
||||
|
||||
for( const nlohmann::json& layer : preset.at( "layers" ) )
|
||||
{
|
||||
if( layer.is_number_integer() )
|
||||
mappedLayers.push_back( legacyColorMap[layer.get<int>()] );
|
||||
}
|
||||
|
||||
preset["layers"] = mappedLayers;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} );
|
||||
}
|
||||
|
@ -64,7 +64,11 @@ private:
|
||||
|
||||
void jsonToPresets( const nlohmann::json& aJson );
|
||||
|
||||
private:
|
||||
std::vector<LAYER_PRESET_3D>* m_presets;
|
||||
|
||||
std::map<int, wxString> m_layerToLayerNameMap;
|
||||
std::map<wxString, int> m_layerNameToLayerMap;
|
||||
};
|
||||
|
||||
|
||||
|
@ -140,10 +140,10 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
|
||||
} );
|
||||
|
||||
m_cbUseBoardEditorCopperColors = new wxCheckBox( m_panelLayers, wxID_ANY,
|
||||
_( "Use board editor copper colors" ) );
|
||||
_( "Use PCB editor copper colors" ) );
|
||||
m_cbUseBoardEditorCopperColors->SetFont( infoFont );
|
||||
m_cbUseBoardEditorCopperColors->SetToolTip(
|
||||
_( "Use the board editor copper colors (openGL only)" ) );
|
||||
m_cbUseBoardEditorCopperColors->SetToolTip( _( "Use the board editor layer colors for copper "
|
||||
"layers (realtime renderer only)" ) );
|
||||
|
||||
m_cbUseBoardEditorCopperColors->Bind( wxEVT_CHECKBOX,
|
||||
[this]( wxCommandEvent& aEvent )
|
||||
@ -156,10 +156,9 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
|
||||
m_frame->NewDisplay( true );
|
||||
} );
|
||||
|
||||
|
||||
m_panelLayersSizer->Add( m_cbUseBoardStackupColors, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 7 );
|
||||
m_panelLayersSizer->Add( m_cbUseBoardStackupColors, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5 );
|
||||
m_panelLayersSizer->Add( m_cbUseBoardEditorCopperColors, 0,
|
||||
wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 7 );
|
||||
wxEXPAND | wxALL, 5 );
|
||||
|
||||
m_cbLayerPresets->SetToolTip( wxString::Format( _( "Save and restore color and visibility "
|
||||
"combinations.\n"
|
||||
@ -279,16 +278,7 @@ void APPEARANCE_CONTROLS_3D::CommonSettingsChanged()
|
||||
|
||||
void APPEARANCE_CONTROLS_3D::ApplyLayerPreset( const wxString& aPresetName )
|
||||
{
|
||||
if( aPresetName == FOLLOW_PCB || aPresetName == FOLLOW_PLOT_SETTINGS )
|
||||
{
|
||||
m_frame->GetAdapter().m_Cfg->m_CurrentPreset = aPresetName;
|
||||
UpdateLayerCtls();
|
||||
m_frame->NewDisplay( true );
|
||||
}
|
||||
else if( LAYER_PRESET_3D* preset = m_frame->GetAdapter().m_Cfg->FindPreset( aPresetName ) )
|
||||
{
|
||||
doApplyLayerPreset( *preset );
|
||||
}
|
||||
doApplyLayerPreset( aPresetName );
|
||||
|
||||
// Move to front of MRU list
|
||||
if( m_presetMRU.Index( aPresetName ) != wxNOT_FOUND )
|
||||
@ -731,17 +721,11 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
|
||||
|
||||
if( index == 0 )
|
||||
{
|
||||
name = FOLLOW_PCB;
|
||||
cfg->m_CurrentPreset = name;
|
||||
UpdateLayerCtls();
|
||||
m_frame->NewDisplay( true );
|
||||
doApplyLayerPreset( FOLLOW_PCB );
|
||||
}
|
||||
else if( index == 1 )
|
||||
{
|
||||
name = FOLLOW_PLOT_SETTINGS;
|
||||
cfg->m_CurrentPreset = name;
|
||||
UpdateLayerCtls();
|
||||
m_frame->NewDisplay( true );
|
||||
doApplyLayerPreset( FOLLOW_PLOT_SETTINGS );
|
||||
}
|
||||
else if( index == count - 3 )
|
||||
{
|
||||
@ -827,10 +811,9 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
|
||||
resetSelection();
|
||||
return;
|
||||
}
|
||||
else if( LAYER_PRESET_3D* preset = cfg->FindPreset( m_cbLayerPresets->GetStringSelection() ) )
|
||||
else
|
||||
{
|
||||
name = preset->name;
|
||||
doApplyLayerPreset( *preset );
|
||||
doApplyLayerPreset( m_cbLayerPresets->GetStringSelection() );
|
||||
}
|
||||
|
||||
// Move to front of MRU list
|
||||
@ -843,16 +826,28 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
|
||||
}
|
||||
|
||||
|
||||
void APPEARANCE_CONTROLS_3D::doApplyLayerPreset( const LAYER_PRESET_3D& aPreset )
|
||||
void APPEARANCE_CONTROLS_3D::doApplyLayerPreset( const wxString& aPresetName )
|
||||
{
|
||||
BOARD_ADAPTER& adapter = m_frame->GetAdapter();
|
||||
|
||||
adapter.m_Cfg->m_CurrentPreset = aPreset.name;
|
||||
adapter.SetVisibleLayers( aPreset.layers );
|
||||
adapter.SetLayerColors( aPreset.colors );
|
||||
if( aPresetName == FOLLOW_PCB || aPresetName == FOLLOW_PLOT_SETTINGS )
|
||||
{
|
||||
adapter.m_Cfg->m_CurrentPreset = aPresetName;
|
||||
adapter.SetVisibleLayers( adapter.GetVisibleLayers() );
|
||||
}
|
||||
else if( LAYER_PRESET_3D* preset = adapter.m_Cfg->FindPreset( aPresetName ) )
|
||||
{
|
||||
adapter.m_Cfg->m_CurrentPreset = aPresetName;
|
||||
adapter.SetVisibleLayers( preset->layers );
|
||||
adapter.SetLayerColors( preset->colors );
|
||||
|
||||
if( aPreset.name.Lower() == _( "legacy colors" ) )
|
||||
adapter.m_Cfg->m_UseStackupColors = false;
|
||||
if( preset->name.Lower() == _( "legacy colors" ) )
|
||||
adapter.m_Cfg->m_UseStackupColors = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateLayerCtls();
|
||||
m_frame->NewDisplay( true );
|
||||
|
@ -157,7 +157,7 @@ private:
|
||||
|
||||
void onLayerPresetChanged( wxCommandEvent& aEvent ) override;
|
||||
|
||||
void doApplyLayerPreset( const LAYER_PRESET_3D& aPreset );
|
||||
void doApplyLayerPreset( const wxString& aPresetName );
|
||||
|
||||
void onViewportChanged( wxCommandEvent& aEvent ) override;
|
||||
void onUpdateViewportsCb( wxUpdateUIEvent& aEvent ) override;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
APPEARANCE_CONTROLS_3D_BASE::APPEARANCE_CONTROLS_3D_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : WX_PANEL( parent, id, pos, size, style, name )
|
||||
{
|
||||
this->SetMinSize( wxSize( 200,360 ) );
|
||||
this->SetMinSize( wxSize( 210,360 ) );
|
||||
|
||||
m_sizerOuter = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="minimum_size">200,360</property>
|
||||
<property name="minimum_size">210,360</property>
|
||||
<property name="name">APPEARANCE_CONTROLS_3D_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">-1,-1</property>
|
||||
|
@ -85,7 +85,7 @@ wxString LayerName( int aLayer )
|
||||
case LAYER_RULE_AREAS: return _( "Rule areas" );
|
||||
case LAYER_DEVICE: return _( "Symbol body outlines" );
|
||||
case LAYER_DEVICE_BACKGROUND: return _( "Symbol body fills" );
|
||||
case LAYER_SHAPES_BACKGROUND: return _( "Shape fills" );
|
||||
case LAYER_SHAPES_BACKGROUND: return _( "Shape fills" );
|
||||
case LAYER_NOTES: return _( "Schematic text && graphics" );
|
||||
case LAYER_PRIVATE_NOTES: return _( "Symbol private text && graphics" );
|
||||
case LAYER_NOTES_BACKGROUND: return _( "Schematic text && graphics backgrounds" );
|
||||
|
Loading…
Reference in New Issue
Block a user