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-06-03 15:59:00 +00:00
|
|
|
* Copyright (C) 2020-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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <footprint_editor_settings.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pgm_base.h>
|
2023-06-03 15:59:00 +00:00
|
|
|
#include <eda_text.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/common_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>
|
|
|
|
#include <settings/settings_manager.h>
|
|
|
|
#include <wx/config.h>
|
2020-06-14 15:08:47 +00:00
|
|
|
#include <base_units.h>
|
2021-06-01 05:17:57 +00:00
|
|
|
#include <wx/log.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-06 01:45:48 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
///! Update the schema version whenever a migration is required
|
2022-08-28 23:02:12 +00:00
|
|
|
const int fpEditSchemaVersion = 2;
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() :
|
2023-10-26 09:59:06 +00:00
|
|
|
PCB_VIEWERS_SETTINGS_BASE( "fpedit", fpEditSchemaVersion ),
|
2020-05-31 21:42:04 +00:00
|
|
|
m_DesignSettings( nullptr, "fpedit.settings" ),
|
2020-05-22 18:27:05 +00:00
|
|
|
m_MagneticItems(),
|
2020-05-08 18:10:47 +00:00
|
|
|
m_Display(),
|
|
|
|
m_UserGrid(),
|
|
|
|
m_PolarCoords( false ),
|
2023-10-25 12:59:12 +00:00
|
|
|
m_DisplayInvertXAxis( false ),
|
|
|
|
m_DisplayInvertYAxis( false ),
|
2022-01-19 13:24:02 +00:00
|
|
|
m_RotationAngle( ANGLE_90 ),
|
2021-09-02 22:32:15 +00:00
|
|
|
m_Use45Limit( true ),
|
2022-12-05 18:27:00 +00:00
|
|
|
m_ArcEditMode( ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS ),
|
2020-05-08 18:10:47 +00:00
|
|
|
m_LibWidth( 250 ),
|
2023-07-09 20:38:58 +00:00
|
|
|
m_LastExportPath(),
|
2020-05-08 18:10:47 +00:00
|
|
|
m_FootprintTextShownColumns()
|
2020-01-13 01:44:19 +00:00
|
|
|
{
|
2023-09-17 02:55:29 +00:00
|
|
|
m_MagneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
|
|
|
|
m_MagneticItems.tracks = MAGNETIC_OPTIONS::NO_EFFECT;
|
|
|
|
m_MagneticItems.graphics = true;
|
|
|
|
m_MagneticItems.allLayers = false;
|
2020-05-22 18:27:05 +00:00
|
|
|
|
2021-11-13 16:38:19 +00:00
|
|
|
m_AuiPanels.appearance_panel_tab = 0;
|
|
|
|
m_AuiPanels.right_panel_width = -1;
|
|
|
|
m_AuiPanels.show_layer_manager = true;
|
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( "window.lib_width",
|
|
|
|
&m_LibWidth, 250 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-10-30 22:21:15 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "aui.show_layer_manager",
|
|
|
|
&m_AuiPanels.show_layer_manager, true ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "aui.right_panel_width",
|
|
|
|
&m_AuiPanels.right_panel_width, -1 ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "aui.appearance_panel_tab",
|
|
|
|
&m_AuiPanels.appearance_panel_tab, 0, 0, 2 ) );
|
|
|
|
|
2023-02-16 03:16:49 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( "aui.properties_panel_width",
|
|
|
|
&m_AuiPanels.properties_panel_width, -1 ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
|
2023-09-25 11:35:31 +00:00
|
|
|
&m_AuiPanels.properties_splitter, 0.5f ) );
|
2023-02-16 03:16:49 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
|
|
|
|
&m_AuiPanels.show_properties, false ) );
|
|
|
|
|
2023-05-01 20:26:29 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( "library.sort_mode",
|
|
|
|
&m_LibrarySortMode, 0 ) );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_params.emplace_back( new PARAM<wxString>( "system.last_import_export_path",
|
2023-07-09 20:38:58 +00:00
|
|
|
&m_LastExportPath, "" ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2023-10-26 09:59:06 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "pcb_display.graphics_fill",
|
|
|
|
&m_ViewersDisplay.m_DisplayGraphicsFill, true ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "pcb_display.text_fill",
|
|
|
|
&m_ViewersDisplay.m_DisplayTextFill, true ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_fill",
|
|
|
|
&m_ViewersDisplay.m_DisplayPadFill, true ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_numbers",
|
|
|
|
&m_ViewersDisplay.m_DisplayPadNumbers, true ) );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_params.emplace_back( new PARAM<wxString>( "window.footprint_text_shown_columns",
|
|
|
|
&m_FootprintTextShownColumns, "0 1 2 3 4 5 6" ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "editing.magnetic_pads",
|
2020-05-22 18:27:05 +00:00
|
|
|
reinterpret_cast<int*>( &m_MagneticItems.pads ),
|
2020-12-19 00:19:47 +00:00
|
|
|
static_cast<int>( MAGNETIC_OPTIONS::CAPTURE_ALWAYS ) ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "editing.magnetic_graphics",
|
|
|
|
&m_MagneticItems.graphics, true ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2023-09-17 02:55:29 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "editing.magnetic_all_layers",
|
|
|
|
&m_MagneticItems.allLayers, false ) );
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "editing.polar_coords",
|
|
|
|
&m_PolarCoords, false ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2023-10-25 12:59:12 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "origin_invert_x_axis",
|
|
|
|
&m_DisplayInvertXAxis, false ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "origin_invert_y_axis",
|
|
|
|
&m_DisplayInvertYAxis, false ) );
|
|
|
|
|
2022-01-19 13:24:02 +00:00
|
|
|
m_params.emplace_back( new PARAM_LAMBDA<int>( "editing.rotation_angle",
|
|
|
|
[this] () -> int
|
|
|
|
{
|
|
|
|
return m_RotationAngle.AsTenthsOfADegree();
|
|
|
|
},
|
|
|
|
[this] ( int aVal )
|
|
|
|
{
|
2022-01-19 19:17:14 +00:00
|
|
|
if( aVal )
|
|
|
|
m_RotationAngle = EDA_ANGLE( aVal, TENTHS_OF_A_DEGREE_T );
|
2022-01-19 13:24:02 +00:00
|
|
|
},
|
|
|
|
900 ) );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "editing.fp_use_45_degree_limit",
|
2021-09-02 22:32:15 +00:00
|
|
|
&m_Use45Limit, false ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-09-30 03:29:58 +00:00
|
|
|
m_params.emplace_back( new PARAM_LAYER_PRESET( "pcb_display.layer_presets", &m_LayerPresets ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<wxString>( "pcb_display.active_layer_preset",
|
|
|
|
&m_ActiveLayerPreset, "" ) );
|
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>(
|
|
|
|
"design_settings.default_footprint_text_items",
|
|
|
|
[&] () -> nlohmann::json
|
|
|
|
{
|
|
|
|
nlohmann::json js = nlohmann::json::array();
|
|
|
|
|
|
|
|
for( const TEXT_ITEM_INFO& item : m_DesignSettings.m_DefaultFPTextItems )
|
|
|
|
{
|
|
|
|
js.push_back( nlohmann::json( { item.m_Text.ToUTF8(),
|
|
|
|
item.m_Visible,
|
|
|
|
item.m_Layer } ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return js;
|
|
|
|
},
|
|
|
|
[&] ( const nlohmann::json& aObj )
|
|
|
|
{
|
|
|
|
m_DesignSettings.m_DefaultFPTextItems.clear();
|
|
|
|
|
|
|
|
if( !aObj.is_array() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( const nlohmann::json& entry : aObj )
|
|
|
|
{
|
|
|
|
if( entry.empty() || !entry.is_array() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
TEXT_ITEM_INFO textInfo( wxT( "" ), true, F_SilkS );
|
|
|
|
|
|
|
|
textInfo.m_Text = entry.at(0).get<wxString>();
|
|
|
|
textInfo.m_Visible = entry.at(1).get<bool>();
|
|
|
|
textInfo.m_Layer = entry.at(2).get<int>();
|
|
|
|
|
|
|
|
m_DesignSettings.m_DefaultFPTextItems.push_back( std::move( textInfo ) );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
nlohmann::json::array( {
|
|
|
|
{ "REF**", true, F_SilkS },
|
|
|
|
{ "", true, F_Fab },
|
|
|
|
{ "${REFERENCE}", true, F_Fab }
|
|
|
|
} ) ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2023-06-03 15:59:00 +00:00
|
|
|
int minTextSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
|
|
|
|
int maxTextSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
|
|
|
|
int minStroke = 1;
|
|
|
|
int maxStroke = pcbIUScale.mmToIU( 100 );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.silk_line_width",
|
|
|
|
&m_DesignSettings.m_LineThickness[ LAYER_CLASS_SILK ],
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_SILK_LINE_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.silk_text_size_h",
|
|
|
|
&m_DesignSettings.m_TextSize[ LAYER_CLASS_SILK ].x,
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_SILK_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.silk_text_size_v",
|
|
|
|
&m_DesignSettings.m_TextSize[ LAYER_CLASS_SILK ].y,
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_SILK_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.silk_text_thickness",
|
|
|
|
&m_DesignSettings.m_TextThickness[ LAYER_CLASS_SILK ],
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_SILK_TEXT_WIDTH ), 1, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "design_settings.silk_text_italic",
|
|
|
|
&m_DesignSettings.m_TextItalic[ LAYER_CLASS_SILK ], false ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.copper_line_width",
|
|
|
|
&m_DesignSettings.m_LineThickness[ LAYER_CLASS_COPPER ],
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_COPPER_LINE_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.copper_text_size_h",
|
|
|
|
&m_DesignSettings.m_TextSize[ LAYER_CLASS_COPPER ].x,
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_COPPER_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.copper_text_size_v",
|
|
|
|
&m_DesignSettings.m_TextSize[ LAYER_CLASS_COPPER ].y,
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_COPPER_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.copper_text_thickness",
|
|
|
|
&m_DesignSettings.m_TextThickness[ LAYER_CLASS_COPPER ],
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_COPPER_TEXT_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "design_settings.copper_text_italic",
|
|
|
|
&m_DesignSettings.m_TextItalic[ LAYER_CLASS_COPPER ], false ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.edge_line_width",
|
|
|
|
&m_DesignSettings.m_LineThickness[ LAYER_CLASS_EDGES ],
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_EDGE_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.courtyard_line_width",
|
|
|
|
&m_DesignSettings.m_LineThickness[ LAYER_CLASS_COURTYARD ],
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_COURTYARD_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.fab_line_width",
|
|
|
|
&m_DesignSettings.m_LineThickness[ LAYER_CLASS_FAB ],
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
|
2020-05-01 16:24:01 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.fab_text_size_h",
|
|
|
|
&m_DesignSettings.m_TextSize[ LAYER_CLASS_FAB ].x,
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-05-01 16:24:01 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.fab_text_size_v",
|
|
|
|
&m_DesignSettings.m_TextSize[ LAYER_CLASS_FAB ].y,
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-05-01 16:24:01 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.fab_text_thickness",
|
|
|
|
&m_DesignSettings.m_TextThickness[ LAYER_CLASS_FAB ],
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_TEXT_WIDTH ), 1, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-05-01 16:24:01 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "design_settings.fab_text_italic",
|
2023-06-03 15:59:00 +00:00
|
|
|
&m_DesignSettings.m_TextItalic[ LAYER_CLASS_FAB ], false ) );
|
2020-05-01 16:24:01 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.others_line_width",
|
|
|
|
&m_DesignSettings.m_LineThickness[ LAYER_CLASS_OTHERS ],
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), minStroke, maxStroke, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.others_text_size_h",
|
|
|
|
&m_DesignSettings.m_TextSize[ LAYER_CLASS_OTHERS ].x,
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.others_text_size_v",
|
|
|
|
&m_DesignSettings.m_TextSize[ LAYER_CLASS_OTHERS ].y,
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_TEXT_SIZE ), minTextSize, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_SCALED<int>( "design_settings.others_text_thickness",
|
|
|
|
&m_DesignSettings.m_TextThickness[ LAYER_CLASS_OTHERS ],
|
2023-06-03 15:59:00 +00:00
|
|
|
pcbIUScale.mmToIU( DEFAULT_TEXT_WIDTH ), 1, maxTextSize, pcbIUScale.MM_PER_IU ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "design_settings.others_text_italic",
|
|
|
|
&m_DesignSettings.m_TextItalic[ LAYER_CLASS_OTHERS ], false ) );
|
2020-08-15 20:42:11 +00:00
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "editing.selection_filter",
|
|
|
|
[&]() -> nlohmann::json
|
|
|
|
{
|
|
|
|
nlohmann::json ret;
|
|
|
|
|
|
|
|
ret["lockedItems"] = m_SelectionFilter.lockedItems;
|
|
|
|
ret["footprints"] = m_SelectionFilter.footprints;
|
|
|
|
ret["text"] = m_SelectionFilter.text;
|
|
|
|
ret["tracks"] = m_SelectionFilter.tracks;
|
|
|
|
ret["vias"] = m_SelectionFilter.vias;
|
|
|
|
ret["pads"] = m_SelectionFilter.pads;
|
|
|
|
ret["graphics"] = m_SelectionFilter.graphics;
|
|
|
|
ret["zones"] = m_SelectionFilter.zones;
|
|
|
|
ret["keepouts"] = m_SelectionFilter.keepouts;
|
|
|
|
ret["dimensions"] = m_SelectionFilter.dimensions;
|
|
|
|
ret["otherItems"] = m_SelectionFilter.otherItems;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
[&]( const nlohmann::json& aVal )
|
|
|
|
{
|
|
|
|
if( aVal.empty() || !aVal.is_object() )
|
|
|
|
return;
|
|
|
|
|
2020-10-08 02:13:46 +00:00
|
|
|
SetIfPresent( aVal, "lockedItems", m_SelectionFilter.lockedItems );
|
|
|
|
SetIfPresent( aVal, "footprints", m_SelectionFilter.footprints );
|
|
|
|
SetIfPresent( aVal, "text", m_SelectionFilter.text );
|
|
|
|
SetIfPresent( aVal, "tracks", m_SelectionFilter.tracks );
|
|
|
|
SetIfPresent( aVal, "vias", m_SelectionFilter.vias );
|
|
|
|
SetIfPresent( aVal, "pads", m_SelectionFilter.pads );
|
|
|
|
SetIfPresent( aVal, "graphics", m_SelectionFilter.graphics );
|
|
|
|
SetIfPresent( aVal, "zones", m_SelectionFilter.zones );
|
|
|
|
SetIfPresent( aVal, "keepouts", m_SelectionFilter.keepouts );
|
|
|
|
SetIfPresent( aVal, "dimensions", m_SelectionFilter.dimensions );
|
|
|
|
SetIfPresent( aVal, "otherItems", m_SelectionFilter.otherItems );
|
2020-08-15 20:42:11 +00:00
|
|
|
},
|
|
|
|
{
|
2023-01-22 16:13:48 +00:00
|
|
|
{ "lockedItems", false },
|
2020-08-15 20:42:11 +00:00
|
|
|
{ "footprints", true },
|
|
|
|
{ "text", true },
|
|
|
|
{ "tracks", true },
|
|
|
|
{ "vias", true },
|
|
|
|
{ "pads", true },
|
|
|
|
{ "graphics", true },
|
|
|
|
{ "zones", true },
|
|
|
|
{ "keepouts", true },
|
|
|
|
{ "dimensions", true },
|
|
|
|
{ "otherItems", true }
|
|
|
|
} ) );
|
2020-10-06 03:21:57 +00:00
|
|
|
|
|
|
|
registerMigration( 0, 1, std::bind( &FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1, this ) );
|
2022-08-28 23:02:12 +00:00
|
|
|
|
|
|
|
registerMigration( 1, 2,
|
|
|
|
[&]() -> bool
|
|
|
|
{
|
|
|
|
// This is actually a migration for APP_SETTINGS_BASE::m_LibTree
|
|
|
|
return migrateLibTreeWidth();
|
|
|
|
} );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|
|
|
{
|
|
|
|
bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
|
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
//
|
|
|
|
// NOTE: there's no value in line-wrapping these; it just makes the table unreadable.
|
|
|
|
//
|
|
|
|
ret &= fromLegacy<int>( aCfg, "ModeditLibWidth", "window.lib_width" );
|
|
|
|
ret &= fromLegacyString( aCfg, "import_last_path", "system.last_import_export_path" );
|
|
|
|
ret &= fromLegacyString( aCfg, "LibFootprintTextShownColumns", "window.footprint_text_shown_columns" );
|
|
|
|
|
|
|
|
ret &= fromLegacy<int>( aCfg, "FpEditorMagneticPads", "editing.magnetic_pads" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "FpEditorDisplayPolarCoords", "editing.polar_coords" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, "FpEditorUse45DegreeGraphicSegments", "editing.use_45_degree_graphic_segments" );
|
|
|
|
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "FpEditorGraphicLinesDisplayMode", "pcb_display.graphic_items_fill" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "FpEditorPadDisplayMode", "pcb_display.pad_fill" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "FpEditorTextsDisplayMode", "pcb_display.footprint_text" );
|
|
|
|
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorSilkLineWidth", "design_settings.silk_line_width" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorSilkTextSizeH", "design_settings.silk_text_size_h" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorSilkTextSizeV", "design_settings.silk_text_size_v" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorSilkTextThickness", "design_settings.silk_text_thickness" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "FpEditorSilkTextItalic", "design_settings.silk_text_italic" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorCopperLineWidth", "design_settings.copper_line_width" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorCopperTextSizeH", "design_settings.copper_text_size_h" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorCopperTextSizeV", "design_settings.copper_text_size_v" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorCopperTextThickness", "design_settings.copper_text_thickness" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "FpEditorCopperTextItalic", "design_settings.copper_text_italic" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorEdgeCutLineWidth", "design_settings.edge_line_width" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorCourtyardLineWidth", "design_settings.courtyard_line_width" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorOthersLineWidth", "design_settings.others_line_width" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorOthersTextSizeH", "design_settings.others_text_size_h" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorOthersTextSizeV", "design_settings.others_text_size_v" );
|
|
|
|
ret &= fromLegacy<double>( aCfg, "FpEditorOthersTextThickness", "design_settings.others_text_thickness" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "FpEditorOthersTextItalic", "design_settings.others_text_italic" );
|
|
|
|
|
|
|
|
nlohmann::json textItems = nlohmann::json::array( {
|
|
|
|
{ "REF**", true, F_SilkS },
|
|
|
|
{ "", true, F_Fab }
|
|
|
|
} );
|
|
|
|
|
2021-06-04 03:52:50 +00:00
|
|
|
Set( "design_settings.default_footprint_text_items", textItems );
|
2020-05-08 18:10:47 +00:00
|
|
|
|
|
|
|
ret &= fromLegacyString( aCfg, "FpEditorRefDefaultText", "design_settings.default_footprint_text_items.0.0" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "FpEditorRefDefaultVisibility", "design_settings.default_footprint_text_items.0.1" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, "FpEditorRefDefaultLayer", "design_settings.default_footprint_text_items.0.2" );
|
|
|
|
ret &= fromLegacyString( aCfg, "FpEditorValueDefaultText", "design_settings.default_footprint_text_items.1.0" );
|
|
|
|
ret &= fromLegacy<bool>( aCfg, "FpEditorValueDefaultVisibility", "design_settings.default_footprint_text_items.1.1" );
|
|
|
|
ret &= fromLegacy<int>( aCfg, "FpEditorValueDefaultLayer", "design_settings.default_footprint_text_items.1.2" );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
std::string f = "ModEdit";
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
// Migrate color settings that were stored in the pcbnew config file
|
2020-05-06 01:45:48 +00:00
|
|
|
// We create a copy of the user scheme for the footprint editor context
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
SETTINGS_MANAGER& manager = Pgm().GetSettingsManager();
|
2020-05-06 01:45:48 +00:00
|
|
|
COLOR_SETTINGS* cs = manager.AddNewColorSettings( "user_footprints" );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-10-15 01:57:36 +00:00
|
|
|
cs->SetName( wxT( "User (Footprints)" ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
manager.Save( cs );
|
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId )
|
|
|
|
{
|
|
|
|
wxString str;
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
if( aCfg->Read( aKey, &str ) )
|
|
|
|
cs->SetColor( aLayerId, COLOR4D( str ) );
|
|
|
|
};
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
|
|
|
|
{
|
|
|
|
wxString layer = LSET::Name( PCB_LAYER_ID( i ) );
|
|
|
|
migrateLegacyColor( f + "Color4DPCBLayer_" + layer.ToStdString(), PCB_LAYER_ID( i ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
migrateLegacyColor( f + "Color4DAnchorEx", LAYER_ANCHOR );
|
|
|
|
migrateLegacyColor( f + "Color4DAuxItems", LAYER_AUX_ITEMS );
|
|
|
|
migrateLegacyColor( f + "Color4DGrid", LAYER_GRID );
|
|
|
|
migrateLegacyColor( f + "Color4DNonPlatedEx", LAYER_NON_PLATEDHOLES );
|
|
|
|
migrateLegacyColor( f + "Color4DPadThruHoleEx", LAYER_PADS_TH );
|
|
|
|
migrateLegacyColor( f + "Color4DPCBBackground", LAYER_PCB_BACKGROUND );
|
|
|
|
migrateLegacyColor( f + "Color4DPCBCursor", LAYER_CURSOR );
|
|
|
|
migrateLegacyColor( f + "Color4DRatsEx", LAYER_RATSNEST );
|
2023-08-04 10:13:20 +00:00
|
|
|
migrateLegacyColor( f + "Color4DTxtInvisEx", LAYER_HIDDEN_TEXT );
|
2020-01-13 01:44:19 +00:00
|
|
|
migrateLegacyColor( f + "Color4DViaBBlindEx", LAYER_VIA_BBLIND );
|
|
|
|
migrateLegacyColor( f + "Color4DViaMicroEx", LAYER_VIA_MICROVIA );
|
|
|
|
migrateLegacyColor( f + "Color4DViaThruEx", LAYER_VIA_THROUGH );
|
2021-02-22 16:37:43 +00:00
|
|
|
migrateLegacyColor( f + "Color4DWorksheet", LAYER_DRAWINGSHEET );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-06 01:45:48 +00:00
|
|
|
manager.SaveColorSettings( cs, "board" );
|
|
|
|
|
2021-06-04 03:52:50 +00:00
|
|
|
( *m_internals )[m_internals->PointerFromString( "appearance.color_theme" )] = "user_footprints";
|
2020-05-06 01:45:48 +00:00
|
|
|
|
2023-04-11 08:53:35 +00:00
|
|
|
double x = 0, y = 0;
|
2020-06-14 15:08:47 +00:00
|
|
|
f = "ModEditFrame";
|
|
|
|
|
|
|
|
if( aCfg->Read( f + "PcbUserGrid_X", &x ) && aCfg->Read( f + "PcbUserGrid_Y", &y ) )
|
|
|
|
{
|
|
|
|
EDA_UNITS u = static_cast<EDA_UNITS>( aCfg->ReadLong( f + "PcbUserGrid_Unit",
|
2022-09-19 09:25:20 +00:00
|
|
|
static_cast<long>( EDA_UNITS::INCHES ) ) );
|
2020-06-14 15:08:47 +00:00
|
|
|
|
|
|
|
// Convert to internal units
|
2022-09-16 04:38:10 +00:00
|
|
|
x = EDA_UNIT_UTILS::UI::FromUserUnit( pcbIUScale, u, x );
|
|
|
|
y = EDA_UNIT_UTILS::UI::FromUserUnit( pcbIUScale, u, y );
|
2020-06-14 15:08:47 +00:00
|
|
|
|
2022-09-16 04:38:10 +00:00
|
|
|
Set( "window.grid.user_grid_x", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, x ) );
|
|
|
|
Set( "window.grid.user_grid_y", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, y ) );
|
2020-06-14 15:08:47 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 01:45:48 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool FOOTPRINT_EDITOR_SETTINGS::migrateSchema0to1()
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Schema version 0 to 1:
|
|
|
|
*
|
|
|
|
* - Check to see if a footprints version of the currently selected theme exists.
|
|
|
|
* - If so, select it
|
|
|
|
*/
|
|
|
|
|
|
|
|
if( !m_manager )
|
|
|
|
{
|
2020-09-07 15:43:12 +00:00
|
|
|
wxLogTrace( traceSettings,
|
2022-02-03 20:57:26 +00:00
|
|
|
wxT( "Error: FOOTPRINT_EDITOR_SETTINGS migration cannot run unmanaged!" ) );
|
2020-05-06 01:45:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-04 03:52:50 +00:00
|
|
|
std::string theme_ptr( "appearance.color_theme" );
|
2020-05-06 01:45:48 +00:00
|
|
|
|
2022-11-04 02:22:35 +00:00
|
|
|
if( !Contains( theme_ptr ) )
|
2020-09-07 15:43:12 +00:00
|
|
|
return true;
|
|
|
|
|
2021-06-04 03:52:50 +00:00
|
|
|
wxString selected = At( theme_ptr ).get<wxString>();
|
2020-05-06 01:45:48 +00:00
|
|
|
wxString search = selected + wxT( "_footprints" );
|
|
|
|
|
|
|
|
for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
|
|
|
|
{
|
|
|
|
if( settings->GetFilename() == search )
|
|
|
|
{
|
2022-02-03 20:57:26 +00:00
|
|
|
wxLogTrace( traceSettings, wxT( "Updating footprint editor theme from %s to %s" ),
|
2020-09-07 15:43:12 +00:00
|
|
|
selected, search );
|
2021-06-04 03:52:50 +00:00
|
|
|
Set( theme_ptr, search );
|
2020-05-06 01:45:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|