2020-01-13 01:44:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
2023-02-09 17:18:56 +00:00
|
|
|
* Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-01-13 01:44:19 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
2021-06-04 03:52:50 +00:00
|
|
|
#include <settings/json_settings_internals.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/parameters.h>
|
2020-05-06 01:45:48 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2021-06-01 05:17:57 +00:00
|
|
|
#include <wx/log.h>
|
2023-09-16 23:41:50 +00:00
|
|
|
#include <wx/translation.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-10-15 01:57:36 +00:00
|
|
|
#include "builtin_color_themes.h"
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
///! Update the schema version whenever a migration is required
|
2022-05-14 15:49:53 +00:00
|
|
|
const int colorsSchemaVersion = 5;
|
2023-02-18 22:42:36 +00:00
|
|
|
const wxString COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT = "_builtin_default";
|
|
|
|
const wxString COLOR_SETTINGS::COLOR_BUILTIN_CLASSIC = "_builtin_classic";
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
|
2021-11-10 03:11:59 +00:00
|
|
|
COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath ) :
|
2024-04-27 12:29:44 +00:00
|
|
|
JSON_SETTINGS( aFilename, SETTINGS_LOC::COLORS, colorsSchemaVersion ),
|
2024-02-23 16:06:23 +00:00
|
|
|
m_overrideSchItemColors( false )
|
2020-01-13 01:44:19 +00:00
|
|
|
{
|
2021-11-10 03:11:59 +00:00
|
|
|
if( aAbsolutePath )
|
|
|
|
SetLocation( SETTINGS_LOC::NONE );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2023-12-19 19:29:17 +00:00
|
|
|
m_params.emplace_back( new PARAM<wxString>( "meta.name", &m_displayName,
|
|
|
|
wxS( "KiCad Default" ) ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-04-09 16:15:57 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "schematic.override_item_colors",
|
|
|
|
&m_overrideSchItemColors, false ) );
|
|
|
|
|
2020-10-15 01:57:36 +00:00
|
|
|
#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 ) );
|
|
|
|
|
2021-09-29 00:26:47 +00:00
|
|
|
CLR( "schematic.anchor", LAYER_SCHEMATIC_ANCHOR );
|
2021-02-22 16:37:43 +00:00
|
|
|
CLR( "schematic.aux_items", LAYER_SCHEMATIC_AUX_ITEMS );
|
|
|
|
CLR( "schematic.background", LAYER_SCHEMATIC_BACKGROUND );
|
2022-05-14 15:49:53 +00:00
|
|
|
CLR( "schematic.hovered", LAYER_HOVERED );
|
2021-02-22 16:37:43 +00:00
|
|
|
CLR( "schematic.brightened", LAYER_BRIGHTENED );
|
|
|
|
CLR( "schematic.bus", LAYER_BUS );
|
|
|
|
CLR( "schematic.bus_junction", LAYER_BUS_JUNCTION );
|
|
|
|
CLR( "schematic.component_body", LAYER_DEVICE_BACKGROUND );
|
|
|
|
CLR( "schematic.component_outline", LAYER_DEVICE );
|
|
|
|
CLR( "schematic.cursor", LAYER_SCHEMATIC_CURSOR );
|
2023-07-16 17:04:21 +00:00
|
|
|
CLR( "schematic.dnp_marker", LAYER_DNP_MARKER );
|
2024-06-03 12:59:40 +00:00
|
|
|
CLR( "schematic.excluded_from_sim", LAYER_EXCLUDED_FROM_SIM );
|
2021-02-22 16:37:43 +00:00
|
|
|
CLR( "schematic.erc_error", LAYER_ERC_ERR );
|
|
|
|
CLR( "schematic.erc_warning", LAYER_ERC_WARN );
|
2022-03-31 20:37:53 +00:00
|
|
|
CLR( "schematic.erc_exclusion", LAYER_ERC_EXCLUSION );
|
2021-02-22 16:37:43 +00:00
|
|
|
CLR( "schematic.fields", LAYER_FIELDS );
|
|
|
|
CLR( "schematic.grid", LAYER_SCHEMATIC_GRID );
|
|
|
|
CLR( "schematic.grid_axes", LAYER_SCHEMATIC_GRID_AXES );
|
|
|
|
CLR( "schematic.hidden", LAYER_HIDDEN );
|
|
|
|
CLR( "schematic.junction", LAYER_JUNCTION );
|
|
|
|
CLR( "schematic.label_global", LAYER_GLOBLABEL );
|
|
|
|
CLR( "schematic.label_hier", LAYER_HIERLABEL );
|
|
|
|
CLR( "schematic.label_local", LAYER_LOCLABEL );
|
2022-01-24 13:40:39 +00:00
|
|
|
CLR( "schematic.netclass_flag", LAYER_NETCLASS_REFS );
|
2024-04-25 14:24:46 +00:00
|
|
|
CLR( "schematic.rule_area", LAYER_RULE_AREAS );
|
2021-02-22 16:37:43 +00:00
|
|
|
CLR( "schematic.no_connect", LAYER_NOCONNECT );
|
|
|
|
CLR( "schematic.note", LAYER_NOTES );
|
2022-07-07 04:51:23 +00:00
|
|
|
CLR( "schematic.private_note", LAYER_PRIVATE_NOTES );
|
2021-07-17 19:56:18 +00:00
|
|
|
CLR( "schematic.note_background", LAYER_NOTES_BACKGROUND );
|
2021-02-22 16:37:43 +00:00
|
|
|
CLR( "schematic.pin", LAYER_PIN );
|
|
|
|
CLR( "schematic.pin_name", LAYER_PINNAM );
|
|
|
|
CLR( "schematic.pin_number", LAYER_PINNUM );
|
|
|
|
CLR( "schematic.reference", LAYER_REFERENCEPART );
|
|
|
|
CLR( "schematic.shadow", LAYER_SELECTION_SHADOWS );
|
|
|
|
CLR( "schematic.sheet", LAYER_SHEET );
|
|
|
|
CLR( "schematic.sheet_background", LAYER_SHEET_BACKGROUND );
|
|
|
|
CLR( "schematic.sheet_filename", LAYER_SHEETFILENAME );
|
|
|
|
CLR( "schematic.sheet_fields", LAYER_SHEETFIELDS );
|
|
|
|
CLR( "schematic.sheet_label", LAYER_SHEETLABEL );
|
|
|
|
CLR( "schematic.sheet_name", LAYER_SHEETNAME );
|
|
|
|
CLR( "schematic.value", LAYER_VALUEPART );
|
|
|
|
CLR( "schematic.wire", LAYER_WIRE );
|
|
|
|
CLR( "schematic.worksheet", LAYER_SCHEMATIC_DRAWINGSHEET );
|
2022-03-24 14:10:47 +00:00
|
|
|
CLR( "schematic.page_limits", LAYER_SCHEMATIC_PAGE_LIMITS );
|
2023-02-09 17:18:56 +00:00
|
|
|
CLR( "schematic.op_voltages", LAYER_OP_VOLTAGES );
|
|
|
|
CLR( "schematic.op_currents", LAYER_OP_CURRENTS );
|
2021-02-22 16:37:43 +00:00
|
|
|
|
|
|
|
CLR( "gerbview.axes", LAYER_GERBVIEW_AXES );
|
|
|
|
CLR( "gerbview.background", LAYER_GERBVIEW_BACKGROUND );
|
|
|
|
CLR( "gerbview.dcodes", LAYER_DCODES );
|
|
|
|
CLR( "gerbview.grid", LAYER_GERBVIEW_GRID );
|
|
|
|
CLR( "gerbview.negative_objects", LAYER_NEGATIVE_OBJECTS );
|
|
|
|
CLR( "gerbview.worksheet", LAYER_GERBVIEW_DRAWINGSHEET );
|
2022-03-24 14:10:47 +00:00
|
|
|
CLR( "gerbview.page_limits", LAYER_GERBVIEW_PAGE_LIMITS );
|
2020-10-15 01:57:36 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
for( int i = 0, id = GERBVIEW_LAYER_ID_START;
|
|
|
|
id < GERBER_DRAWLAYERS_COUNT + GERBVIEW_LAYER_ID_START; ++i, ++id )
|
|
|
|
{
|
2020-10-15 01:57:36 +00:00
|
|
|
m_params.emplace_back( new COLOR_MAP_PARAM( "gerbview.layers." + std::to_string( i ), id,
|
2022-09-10 15:11:24 +00:00
|
|
|
s_defaultTheme.at( id ), &m_colors ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
2020-10-15 01:57:36 +00:00
|
|
|
CLR( "board.anchor", LAYER_ANCHOR );
|
2022-03-06 19:11:03 +00:00
|
|
|
CLR( "board.locked_shadow", LAYER_LOCKED_ITEM_SHADOW );
|
2022-05-20 09:08:33 +00:00
|
|
|
CLR( "board.conflicts_shadow", LAYER_CONFLICTS_SHADOW );
|
2020-10-15 01:57:36 +00:00
|
|
|
CLR( "board.aux_items", LAYER_AUX_ITEMS );
|
|
|
|
CLR( "board.background", LAYER_PCB_BACKGROUND );
|
|
|
|
CLR( "board.cursor", LAYER_CURSOR );
|
|
|
|
CLR( "board.drc_error", LAYER_DRC_ERROR );
|
|
|
|
CLR( "board.drc_warning", LAYER_DRC_WARNING );
|
|
|
|
CLR( "board.drc_exclusion", LAYER_DRC_EXCLUSION );
|
2023-08-04 10:13:20 +00:00
|
|
|
CLR( "board.footprint_text_invisible", LAYER_HIDDEN_TEXT );
|
2020-10-15 01:57:36 +00:00
|
|
|
CLR( "board.grid", LAYER_GRID );
|
|
|
|
CLR( "board.grid_axes", LAYER_GRID_AXES );
|
2021-01-30 14:41:31 +00:00
|
|
|
CLR( "board.pad_plated_hole", LAYER_PAD_PLATEDHOLES );
|
2020-10-15 01:57:36 +00:00
|
|
|
CLR( "board.pad_through_hole", LAYER_PADS_TH );
|
|
|
|
CLR( "board.plated_hole", LAYER_NON_PLATEDHOLES );
|
|
|
|
CLR( "board.ratsnest", LAYER_RATSNEST );
|
|
|
|
CLR( "board.via_blind_buried", LAYER_VIA_BBLIND );
|
2021-01-30 14:41:31 +00:00
|
|
|
CLR( "board.via_hole", LAYER_VIA_HOLES );
|
2020-10-15 01:57:36 +00:00
|
|
|
CLR( "board.via_micro", LAYER_VIA_MICROVIA );
|
|
|
|
CLR( "board.via_through", LAYER_VIA_THROUGH );
|
2022-03-24 14:10:47 +00:00
|
|
|
CLR( "board.worksheet", LAYER_DRAWINGSHEET );
|
|
|
|
CLR( "board.page_limits", LAYER_PAGE_LIMITS );
|
2020-10-15 01:57:36 +00:00
|
|
|
|
|
|
|
CLR( "board.copper.f", F_Cu );
|
|
|
|
CLR( "board.copper.in1", In1_Cu );
|
|
|
|
CLR( "board.copper.in2", In2_Cu );
|
|
|
|
CLR( "board.copper.in3", In3_Cu );
|
|
|
|
CLR( "board.copper.in4", In4_Cu );
|
|
|
|
CLR( "board.copper.in5", In5_Cu );
|
|
|
|
CLR( "board.copper.in6", In6_Cu );
|
|
|
|
CLR( "board.copper.in7", In7_Cu );
|
|
|
|
CLR( "board.copper.in8", In8_Cu );
|
|
|
|
CLR( "board.copper.in9", In9_Cu );
|
|
|
|
CLR( "board.copper.in10", In10_Cu );
|
|
|
|
CLR( "board.copper.in11", In11_Cu );
|
|
|
|
CLR( "board.copper.in12", In12_Cu );
|
|
|
|
CLR( "board.copper.in13", In13_Cu );
|
|
|
|
CLR( "board.copper.in14", In14_Cu );
|
|
|
|
CLR( "board.copper.in15", In15_Cu );
|
|
|
|
CLR( "board.copper.in16", In16_Cu );
|
|
|
|
CLR( "board.copper.in17", In17_Cu );
|
|
|
|
CLR( "board.copper.in18", In18_Cu );
|
|
|
|
CLR( "board.copper.in19", In19_Cu );
|
|
|
|
CLR( "board.copper.in20", In20_Cu );
|
|
|
|
CLR( "board.copper.in21", In21_Cu );
|
|
|
|
CLR( "board.copper.in22", In22_Cu );
|
|
|
|
CLR( "board.copper.in23", In23_Cu );
|
|
|
|
CLR( "board.copper.in24", In24_Cu );
|
|
|
|
CLR( "board.copper.in25", In25_Cu );
|
|
|
|
CLR( "board.copper.in26", In26_Cu );
|
|
|
|
CLR( "board.copper.in27", In27_Cu );
|
|
|
|
CLR( "board.copper.in28", In28_Cu );
|
|
|
|
CLR( "board.copper.in29", In29_Cu );
|
|
|
|
CLR( "board.copper.in30", In30_Cu );
|
|
|
|
CLR( "board.copper.b", B_Cu );
|
|
|
|
|
|
|
|
CLR( "board.b_adhes", B_Adhes );
|
|
|
|
CLR( "board.f_adhes", F_Adhes );
|
|
|
|
CLR( "board.b_paste", B_Paste );
|
|
|
|
CLR( "board.f_paste", F_Paste );
|
|
|
|
CLR( "board.b_silks", B_SilkS );
|
|
|
|
CLR( "board.f_silks", F_SilkS );
|
|
|
|
CLR( "board.b_mask", B_Mask );
|
|
|
|
CLR( "board.f_mask", F_Mask );
|
|
|
|
CLR( "board.dwgs_user", Dwgs_User );
|
|
|
|
CLR( "board.cmts_user", Cmts_User );
|
|
|
|
CLR( "board.eco1_user", Eco1_User );
|
|
|
|
CLR( "board.eco2_user", Eco2_User );
|
|
|
|
CLR( "board.edge_cuts", Edge_Cuts );
|
|
|
|
CLR( "board.margin", Margin );
|
|
|
|
CLR( "board.b_crtyd", B_CrtYd );
|
|
|
|
CLR( "board.f_crtyd", F_CrtYd );
|
|
|
|
CLR( "board.b_fab", B_Fab );
|
|
|
|
CLR( "board.f_fab", F_Fab );
|
|
|
|
CLR( "board.user_1", User_1 );
|
|
|
|
CLR( "board.user_2", User_2 );
|
|
|
|
CLR( "board.user_3", User_3 );
|
|
|
|
CLR( "board.user_4", User_4 );
|
|
|
|
CLR( "board.user_5", User_5 );
|
|
|
|
CLR( "board.user_6", User_6 );
|
|
|
|
CLR( "board.user_7", User_7 );
|
|
|
|
CLR( "board.user_8", User_8 );
|
|
|
|
CLR( "board.user_9", User_9 );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
// Colors for 3D viewer, which are used as defaults unless overridden by the board
|
2020-10-15 01:57:36 +00:00
|
|
|
CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM );
|
|
|
|
CLR( "3d_viewer.background_top", LAYER_3D_BACKGROUND_TOP );
|
|
|
|
CLR( "3d_viewer.board", LAYER_3D_BOARD );
|
2023-08-11 17:40:13 +00:00
|
|
|
CLR( "3d_viewer.copper", LAYER_3D_COPPER_TOP );
|
2020-10-15 01:57:36 +00:00
|
|
|
CLR( "3d_viewer.silkscreen_bottom", LAYER_3D_SILKSCREEN_BOTTOM );
|
|
|
|
CLR( "3d_viewer.silkscreen_top", LAYER_3D_SILKSCREEN_TOP );
|
2021-07-27 21:24:18 +00:00
|
|
|
CLR( "3d_viewer.soldermask_bottom", LAYER_3D_SOLDERMASK_BOTTOM );
|
|
|
|
CLR( "3d_viewer.soldermask_top", LAYER_3D_SOLDERMASK_TOP );
|
2020-10-15 01:57:36 +00:00
|
|
|
CLR( "3d_viewer.solderpaste", LAYER_3D_SOLDERPASTE );
|
2020-10-06 03:21:57 +00:00
|
|
|
|
|
|
|
registerMigration( 0, 1, std::bind( &COLOR_SETTINGS::migrateSchema0to1, this ) );
|
|
|
|
|
|
|
|
registerMigration( 1, 2,
|
|
|
|
[&]()
|
|
|
|
{
|
2021-01-30 14:41:31 +00:00
|
|
|
// Fix LAYER_VIA_HOLES color - before version 2, this setting had no effect
|
2022-08-15 22:43:30 +00:00
|
|
|
nlohmann::json::json_pointer ptr( "/board/via_hole" );
|
2020-10-06 03:21:57 +00:00
|
|
|
|
2022-09-30 19:18:37 +00:00
|
|
|
( *m_internals )[ptr] = COLOR4D( 0.5, 0.4, 0, 0.8 ).ToCSSString();
|
2020-10-06 03:21:57 +00:00
|
|
|
|
2021-08-14 12:16:29 +00:00
|
|
|
return true;
|
|
|
|
} );
|
|
|
|
|
|
|
|
registerMigration( 2, 3,
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
// We don't support opacity in some 3D colors but some versions of 5.99 let
|
|
|
|
// you set it.
|
|
|
|
|
2021-08-14 13:57:01 +00:00
|
|
|
for( std::string path : { "3d_viewer.background_top",
|
|
|
|
"3d_viewer.background_bottom",
|
|
|
|
"3d_viewer.copper",
|
|
|
|
"3d_viewer.silkscreen_top",
|
|
|
|
"3d_viewer.silkscreen_bottom",
|
|
|
|
"3d_viewer.solderpaste" } )
|
2021-08-14 12:16:29 +00:00
|
|
|
{
|
2022-08-25 22:50:47 +00:00
|
|
|
if( std::optional<COLOR4D> optval = Get<COLOR4D>( path ) )
|
2021-08-14 12:16:29 +00:00
|
|
|
Set( path, optval->WithAlpha( 1.0 ) );
|
|
|
|
}
|
|
|
|
|
2022-03-24 14:10:47 +00:00
|
|
|
return true;
|
|
|
|
} );
|
|
|
|
|
|
|
|
registerMigration( 3, 4,
|
|
|
|
[&]()
|
|
|
|
{
|
2022-08-25 22:50:47 +00:00
|
|
|
if( std::optional<COLOR4D> optval = Get<COLOR4D>( "board.grid" ) )
|
2022-08-30 20:58:43 +00:00
|
|
|
Set( "board.page_limits", *optval );
|
2022-03-24 14:10:47 +00:00
|
|
|
|
2022-08-25 22:50:47 +00:00
|
|
|
if( std::optional<COLOR4D> optval = Get<COLOR4D>( "schematic.grid" ) )
|
2022-08-30 20:58:43 +00:00
|
|
|
Set( "schematic.page_limits", *optval );
|
2022-03-24 14:10:47 +00:00
|
|
|
|
2020-10-06 03:21:57 +00:00
|
|
|
return true;
|
|
|
|
} );
|
2023-11-01 03:38:44 +00:00
|
|
|
|
|
|
|
// this bump shouldn't have happened; add a no-op migration to avoid future issues
|
|
|
|
registerMigration( 4, 5, []() { return true; } );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-04 02:34:16 +00:00
|
|
|
COLOR_SETTINGS::COLOR_SETTINGS( const COLOR_SETTINGS& aOther ) :
|
|
|
|
JSON_SETTINGS( aOther.m_filename, SETTINGS_LOC::COLORS, colorsSchemaVersion )
|
|
|
|
{
|
2020-07-08 16:19:10 +00:00
|
|
|
initFromOther( aOther );
|
2020-07-04 02:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
COLOR_SETTINGS& COLOR_SETTINGS::operator=( const COLOR_SETTINGS &aOther )
|
|
|
|
{
|
2020-07-08 16:19:10 +00:00
|
|
|
m_filename = aOther.m_filename;
|
|
|
|
|
|
|
|
initFromOther( aOther );
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void COLOR_SETTINGS::initFromOther( const COLOR_SETTINGS& aOther )
|
|
|
|
{
|
2020-07-04 02:34:16 +00:00
|
|
|
m_displayName = aOther.m_displayName;
|
|
|
|
m_overrideSchItemColors = aOther.m_overrideSchItemColors;
|
|
|
|
m_colors = aOther.m_colors;
|
|
|
|
m_defaultColors = aOther.m_defaultColors;
|
2020-10-15 01:57:36 +00:00
|
|
|
m_writeFile = aOther.m_writeFile;
|
2020-07-04 02:34:16 +00:00
|
|
|
|
2020-07-08 16:19:10 +00:00
|
|
|
// Ensure default colors are present
|
|
|
|
for( PARAM_BASE* param : aOther.m_params )
|
|
|
|
{
|
|
|
|
if( COLOR_MAP_PARAM* cmp = dynamic_cast<COLOR_MAP_PARAM*>( param ) )
|
|
|
|
m_defaultColors[cmp->GetKey()] = cmp->GetDefault();
|
|
|
|
}
|
2020-07-04 02:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
bool COLOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-05 16:33:08 +00:00
|
|
|
|
2020-05-06 01:45:48 +00:00
|
|
|
bool COLOR_SETTINGS::migrateSchema0to1()
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Schema version 0 to 1:
|
|
|
|
*
|
|
|
|
* - Footprint editor settings are split out into a new file called "ThemeName (Footprints)"
|
|
|
|
* - fpedit namespace is removed from the schema
|
|
|
|
*/
|
|
|
|
|
|
|
|
if( !m_manager )
|
|
|
|
{
|
2022-02-03 20:57:26 +00:00
|
|
|
wxLogTrace( traceSettings, wxT( "Error: COLOR_SETTINGS migration cannot run unmanaged!" ) );
|
2020-05-06 01:45:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-04 03:52:50 +00:00
|
|
|
if( !Contains( "fpedit" ) )
|
2020-05-06 01:45:48 +00:00
|
|
|
{
|
2023-12-19 19:29:17 +00:00
|
|
|
wxLogTrace( traceSettings,
|
|
|
|
wxT( "migrateSchema0to1: %s doesn't have fpedit settings; skipping." ),
|
2020-10-06 03:21:57 +00:00
|
|
|
m_filename );
|
2020-05-06 01:45:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-11-01 03:38:44 +00:00
|
|
|
wxString filename = GetFilename().BeforeLast( '.' ) + wxT( "_footprints" );
|
2020-05-06 01:45:48 +00:00
|
|
|
|
|
|
|
COLOR_SETTINGS* fpsettings = m_manager->AddNewColorSettings( filename );
|
2023-11-01 03:38:44 +00:00
|
|
|
fpsettings->SetLocation( GetLocation() );
|
2020-05-06 01:45:48 +00:00
|
|
|
|
|
|
|
// Start out with a clone
|
2021-07-05 16:26:14 +00:00
|
|
|
fpsettings->m_internals->CloneFrom( *m_internals );
|
2020-05-06 01:45:48 +00:00
|
|
|
|
|
|
|
// Footprint editor now just looks at the "board" namespace
|
2021-06-04 03:52:50 +00:00
|
|
|
fpsettings->Set( "board", fpsettings->At( "fpedit" ) );
|
2020-05-06 01:45:48 +00:00
|
|
|
|
2021-06-04 03:52:50 +00:00
|
|
|
fpsettings->Internals()->erase( "fpedit" );
|
2020-05-06 01:45:48 +00:00
|
|
|
fpsettings->Load();
|
2020-10-20 19:05:04 +00:00
|
|
|
fpsettings->SetName( fpsettings->GetName() + wxS( " " ) + _( "(Footprints)" ) );
|
2020-05-06 01:45:48 +00:00
|
|
|
m_manager->Save( fpsettings );
|
|
|
|
|
|
|
|
// Now we can get rid of our own copy
|
2021-06-04 03:52:50 +00:00
|
|
|
m_internals->erase( "fpedit" );
|
2020-05-06 01:45:48 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
COLOR4D COLOR_SETTINGS::GetColor( int aLayer ) const
|
|
|
|
{
|
2020-03-07 21:06:33 +00:00
|
|
|
if( m_colors.count( aLayer ) )
|
2020-01-13 01:44:19 +00:00
|
|
|
return m_colors.at( aLayer );
|
2020-03-07 21:06:33 +00:00
|
|
|
|
|
|
|
return COLOR4D::UNSPECIFIED;
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
COLOR4D COLOR_SETTINGS::GetDefaultColor( int aLayer )
|
|
|
|
{
|
|
|
|
if( !m_defaultColors.count( aLayer ) )
|
|
|
|
{
|
|
|
|
COLOR_MAP_PARAM* p = nullptr;
|
|
|
|
|
2020-05-06 17:55:07 +00:00
|
|
|
for( PARAM_BASE* param : m_params )
|
|
|
|
{
|
|
|
|
COLOR_MAP_PARAM* cmp = dynamic_cast<COLOR_MAP_PARAM*>( param );
|
|
|
|
|
|
|
|
if( cmp && cmp->GetKey() == aLayer )
|
|
|
|
p = cmp;
|
|
|
|
}
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-06 17:55:07 +00:00
|
|
|
if( p )
|
|
|
|
m_defaultColors[aLayer] = p->GetDefault();
|
|
|
|
else
|
|
|
|
m_defaultColors[aLayer] = COLOR4D::UNSPECIFIED;
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 16:19:10 +00:00
|
|
|
return m_defaultColors.at( aLayer );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-26 17:28:37 +00:00
|
|
|
void COLOR_SETTINGS::SetColor( int aLayer, const COLOR4D& aColor )
|
2020-01-13 01:44:19 +00:00
|
|
|
{
|
|
|
|
m_colors[ aLayer ] = aColor;
|
|
|
|
}
|
2020-10-15 01:57:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
std::vector<COLOR_SETTINGS*> COLOR_SETTINGS::CreateBuiltinColorSettings()
|
|
|
|
{
|
2023-02-18 22:42:36 +00:00
|
|
|
COLOR_SETTINGS* defaultTheme = new COLOR_SETTINGS( COLOR_BUILTIN_DEFAULT );
|
2020-10-15 01:57:36 +00:00
|
|
|
defaultTheme->SetName( _( "KiCad Default" ) );
|
|
|
|
defaultTheme->m_writeFile = false;
|
|
|
|
defaultTheme->Load(); // We can just get the colors out of the param defaults for this one
|
|
|
|
|
2023-02-18 22:42:36 +00:00
|
|
|
COLOR_SETTINGS* classicTheme = new COLOR_SETTINGS( COLOR_BUILTIN_CLASSIC );
|
2020-10-15 01:57:36 +00:00
|
|
|
classicTheme->SetName( _( "KiCad Classic" ) );
|
|
|
|
classicTheme->m_writeFile = false;
|
2020-12-24 00:24:44 +00:00
|
|
|
|
|
|
|
for( PARAM_BASE* param : classicTheme->m_params )
|
|
|
|
delete param;
|
|
|
|
|
2020-12-20 19:41:00 +00:00
|
|
|
classicTheme->m_params.clear(); // Disable load/store
|
2020-10-15 01:57:36 +00:00
|
|
|
|
|
|
|
for( const std::pair<int, COLOR4D> entry : s_classicTheme )
|
|
|
|
classicTheme->m_colors[entry.first] = entry.second;
|
|
|
|
|
|
|
|
std::vector<COLOR_SETTINGS*> ret;
|
|
|
|
|
|
|
|
ret.push_back( defaultTheme );
|
|
|
|
ret.push_back( classicTheme );
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|