Browse Source
Migrate PcbNew project settings to new framework
Migrate PcbNew project settings to new framework
Various architecture upgrades to support this. Creating a BOARD now requires a valid PROJECT, which caused some (mostly transparent) changes to the Python API internals. ADDED: Project local settings file CHANGED: Board design settings are no longer stored in PCB file CHANGED: Net classes are no longer stored in PCB file CHANGED: Importing board settings now reads boards, not just projects Fixes https://gitlab.com/kicad/code/kicad/-/issues/2578 Fixes https://gitlab.com/kicad/code/kicad/-/issues/4070pull/16/head
87 changed files with 2442 additions and 1960 deletions
-
53d-viewer/3d_canvas/board_adapter.cpp
-
9common/CMakeLists.txt
-
45common/lib_tree_model_adapter.cpp
-
10common/lib_tree_model_adapter.h
-
122common/netclass.cpp
-
18common/project.cpp
-
142common/project/net_settings.cpp
-
478common/project/project_file.cpp
-
105common/project/project_local_settings.cpp
-
60common/settings/json_settings.cpp
-
26common/settings/nested_settings.cpp
-
247common/settings/project_file.cpp
-
107common/settings/settings_manager.cpp
-
0common/swig/netclass.i
-
1common/wildcards_and_files_ext.cpp
-
2cvpcb/auto_associate.cpp
-
2cvpcb/dialogs/dialog_config_equfiles.cpp
-
6eeschema/files-io.cpp
-
2eeschema/symbol_tree_model_adapter.cpp
-
2eeschema/symbol_tree_synchronizing_adapter.cpp
-
153include/board_design_settings.h
-
2include/footprint_editor_settings.h
-
3include/layers_id_colors_and_visibility.h
-
10include/netclass.h
-
4include/pcb_base_frame.h
-
19include/project.h
-
46include/project/net_settings.h
-
60include/project/project_file.h
-
83include/project/project_local_settings.h
-
10include/settings/color_settings.h
-
22include/settings/json_settings.h
-
9include/settings/nested_settings.h
-
124include/settings/parameters.h
-
30include/settings/settings_manager.h
-
1include/wildcards_and_files_ext.h
-
8kicad/kicad_manager_frame.cpp
-
2pcbnew/CMakeLists.txt
-
2pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp
-
1203pcbnew/board_design_settings.cpp
-
40pcbnew/board_item_container.h
-
201pcbnew/class_board.cpp
-
82pcbnew/class_board.h
-
31pcbnew/class_pad.cpp
-
8pcbnew/class_pad.h
-
77pcbnew/dialogs/dialog_board_setup.cpp
-
1pcbnew/dialogs/dialog_export_idf.cpp
-
1pcbnew/dialogs/dialog_export_step.cpp
-
1pcbnew/dialogs/dialog_export_vrml.cpp
-
4pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp
-
2pcbnew/dialogs/dialog_import_settings.cpp
-
1pcbnew/dialogs/dialog_netlist.cpp
-
4pcbnew/dialogs/panel_modedit_defaults.cpp
-
8pcbnew/dialogs/panel_setup_netclasses.cpp
-
2pcbnew/drc/drc_netclass_tester.cpp
-
2pcbnew/drc/drc_rule_parser.cpp
-
1pcbnew/exporters/export_gencad.cpp
-
2pcbnew/exporters/gerber_jobfile_writer.cpp
-
85pcbnew/files.cpp
-
6pcbnew/footprint_edit_frame.cpp
-
1pcbnew/footprint_edit_frame.h
-
2pcbnew/footprint_editor_settings.cpp
-
2pcbnew/fp_tree_model_adapter.cpp
-
14pcbnew/initpcb.cpp
-
181pcbnew/kicad_plugin.cpp
-
6pcbnew/kicad_plugin.h
-
25pcbnew/legacy_plugin.cpp
-
4pcbnew/netinfo_item.cpp
-
1pcbnew/netlist_reader/netlist.cpp
-
14pcbnew/pcb_base_frame.cpp
-
33pcbnew/pcb_edit_frame.cpp
-
33pcbnew/pcb_edit_frame.h
-
24pcbnew/pcb_layer_widget.cpp
-
79pcbnew/pcb_parser.cpp
-
50pcbnew/pcbnew_config.cpp
-
4pcbnew/router/pns_kicad_iface.cpp
-
4pcbnew/router/pns_sizes_settings.cpp
-
4pcbnew/specctra_import_export/specctra_export.cpp
-
2pcbnew/specctra_import_export/specctra_import.cpp
-
19pcbnew/swig/board.i
-
72pcbnew/swig/pcbnew_scripting_helpers.cpp
-
6pcbnew/swig/pcbnew_scripting_helpers.h
-
3pcbnew/tools/pcb_editor_control.cpp
-
2pcbnew/tools/pcbnew_control.cpp
-
3pcbnew/zone_settings.h
-
28qa/pcbnew/drc/test_drc_courtyard_invalid.cpp
-
22qa/pcbnew/drc/test_drc_courtyard_overlap.cpp
-
25qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp
@ -0,0 +1,142 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 CERN |
|||
* @author Jon Evans <jon@craftyjon.com> |
|||
* |
|||
* 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 <project/net_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
|
|||
// Netclasses were originally only stored in board files. The IU context is PCBNEW.
|
|||
#ifndef PCBNEW
|
|||
#define PCBNEW
|
|||
#endif
|
|||
#include <base_units.h>
|
|||
|
|||
|
|||
const int netSettingsSchemaVersion = 0; |
|||
|
|||
|
|||
NET_SETTINGS::NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) : |
|||
NESTED_SETTINGS( "net_settings", netSettingsSchemaVersion, aParent, aPath ), |
|||
m_NetClasses() |
|||
{ |
|||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "classes", |
|||
[&]() -> nlohmann::json |
|||
{ |
|||
nlohmann::json ret = nlohmann::json::array(); |
|||
|
|||
NETCLASSPTR netclass = m_NetClasses.GetDefault(); |
|||
NETCLASSES::const_iterator nc = m_NetClasses.begin(); |
|||
|
|||
for( unsigned int idx = 0; idx <= m_NetClasses.GetCount(); idx++ ) |
|||
{ |
|||
if( idx > 0 ) |
|||
{ |
|||
netclass = nc->second; |
|||
++nc; |
|||
} |
|||
|
|||
nlohmann::json netJson = { |
|||
{ "name", netclass->GetName().ToUTF8() }, |
|||
{ "clearance", Iu2Millimeter( netclass->GetClearance() ) }, |
|||
{ "track_width", Iu2Millimeter( netclass->GetTrackWidth() ) }, |
|||
{ "via_diameter", Iu2Millimeter( netclass->GetViaDiameter() ) }, |
|||
{ "via_drill", Iu2Millimeter( netclass->GetViaDrill() ) }, |
|||
{ "microvia_diameter", Iu2Millimeter( netclass->GetuViaDiameter() ) }, |
|||
{ "microvia_drill", Iu2Millimeter( netclass->GetuViaDrill() ) }, |
|||
{ "diff_pair_width", Iu2Millimeter( netclass->GetDiffPairWidth() ) }, |
|||
{ "diff_pair_gap", Iu2Millimeter( netclass->GetDiffPairGap() ) }, |
|||
{ "diff_pair_via_gap", Iu2Millimeter( netclass->GetDiffPairViaGap() ) } |
|||
}; |
|||
|
|||
nlohmann::json nets = nlohmann::json::array(); |
|||
|
|||
for( NETCLASS::const_iterator i = netclass->begin(); i != netclass->end(); ++i ) |
|||
if( !i->empty() ) |
|||
nets.push_back( std::string( i->ToUTF8() ) ); |
|||
|
|||
netJson["nets"] = nets; |
|||
|
|||
ret.push_back( netJson ); |
|||
} |
|||
|
|||
return ret; |
|||
}, |
|||
[&]( const nlohmann::json& aJson ) |
|||
{ |
|||
if( !aJson.is_array() ) |
|||
return; |
|||
|
|||
m_NetClasses.Clear(); |
|||
NETCLASSPTR netclass; |
|||
NETCLASSPTR defaultClass = m_NetClasses.GetDefault(); |
|||
|
|||
auto get = |
|||
[]( const nlohmann::json& aObj, const std::string& aKey, int aDefault ) |
|||
{ |
|||
if( aObj.contains( aKey ) ) |
|||
return Millimeter2iu( aObj[aKey].get<double>() ); |
|||
else |
|||
return aDefault; |
|||
}; |
|||
|
|||
for( const nlohmann::json& entry : aJson ) |
|||
{ |
|||
if( !entry.is_object() || !entry.contains( "name" ) ) |
|||
continue; |
|||
|
|||
wxString name = entry["name"]; |
|||
|
|||
if( name == defaultClass->GetName() ) |
|||
netclass = defaultClass; |
|||
else |
|||
netclass = std::make_shared<NETCLASS>( name ); |
|||
|
|||
netclass->SetClearance( get( aJson, "clearance", netclass->GetClearance() ) ); |
|||
netclass->SetTrackWidth( |
|||
get( aJson, "track_width", netclass->GetTrackWidth() ) ); |
|||
netclass->SetViaDiameter( |
|||
get( aJson, "via_diameter", netclass->GetViaDiameter() ) ); |
|||
netclass->SetViaDrill( get( aJson, "via_drill", netclass->GetViaDrill() ) ); |
|||
netclass->SetuViaDiameter( |
|||
get( aJson, "microvia_diameter", netclass->GetuViaDiameter() ) ); |
|||
netclass->SetuViaDrill( |
|||
get( aJson, "microvia_drill", netclass->GetuViaDrill() ) ); |
|||
netclass->SetDiffPairWidth( |
|||
get( aJson, "diff_pair_width", netclass->GetDiffPairWidth() ) ); |
|||
netclass->SetDiffPairGap( |
|||
get( aJson, "diff_pair_gap", netclass->GetDiffPairGap() ) ); |
|||
netclass->SetDiffPairViaGap( |
|||
get( aJson, "diff_pair_via_gap", netclass->GetDiffPairViaGap() ) ); |
|||
|
|||
if( netclass != defaultClass ) |
|||
m_NetClasses.Add( netclass ); |
|||
} |
|||
}, {} ) ); |
|||
} |
|||
|
|||
|
|||
NET_SETTINGS::~NET_SETTINGS() |
|||
{ |
|||
// Release early before destroying members
|
|||
if( m_parent ) |
|||
{ |
|||
m_parent->ReleaseNestedSettings( this ); |
|||
m_parent = nullptr; |
|||
} |
|||
} |
|||
@ -0,0 +1,478 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 CERN |
|||
* @author Jon Evans <jon@craftyjon.com> |
|||
* |
|||
* 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 <config_params.h>
|
|||
#include <project.h>
|
|||
#include <project/net_settings.h>
|
|||
#include <project/project_file.h>
|
|||
#include <settings/common_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
#include <wildcards_and_files_ext.h>
|
|||
#include <wx/config.h>
|
|||
#include <wx/log.h>
|
|||
|
|||
extern const char* traceSettings; |
|||
|
|||
///! Update the schema version whenever a migration is required
|
|||
const int projectFileSchemaVersion = 1; |
|||
|
|||
|
|||
PROJECT_FILE::PROJECT_FILE( const std::string& aFullPath ) : |
|||
JSON_SETTINGS( aFullPath, SETTINGS_LOC::PROJECT, projectFileSchemaVersion ), |
|||
m_sheets(), m_boards(), m_BoardSettings() |
|||
{ |
|||
// Keep old files around
|
|||
m_deleteLegacyAfterMigration = false; |
|||
|
|||
m_params.emplace_back( new PARAM_LIST<FILE_INFO_PAIR>( "sheets", &m_sheets, {} ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_LIST<FILE_INFO_PAIR>( "boards", &m_boards, {} ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM_LIST<wxString>( "libraries.pinned_symbol_libs", &m_PinnedSymbolLibs, {} ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_LIST<wxString>( |
|||
"libraries.pinned_footprint_libs", &m_PinnedFootprintLibs, {} ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM_PATH_LIST( "cvpcb.equivalence_files", &m_EquivalenceFiles, {} ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM_PATH( "pcbnew.page_layout_descr_file", &m_PageLayoutDescrFile, "" ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM_PATH( "pcbnew.last_paths.netlist", &m_PcbLastPath[LAST_PATH_NETLIST], "" ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM_PATH( "pcbnew.last_paths.step", &m_PcbLastPath[LAST_PATH_STEP], "" ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM_PATH( "pcbnew.last_paths.idf", &m_PcbLastPath[LAST_PATH_IDF], "" ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM_PATH( "pcbnew.last_paths.vmrl", &m_PcbLastPath[LAST_PATH_VRML], "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_PATH( |
|||
"pcbnew.last_paths.specctra_dsn", &m_PcbLastPath[LAST_PATH_SPECCTRADSN], "" ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM_PATH( "pcbnew.last_paths.gencad", &m_PcbLastPath[LAST_PATH_GENCAD], "" ) ); |
|||
|
|||
m_NetSettings = std::make_shared<NET_SETTINGS>( this, "net_settings" ); |
|||
} |
|||
|
|||
|
|||
bool PROJECT_FILE::MigrateFromLegacy( wxConfigBase* aCfg ) |
|||
{ |
|||
bool ret = true; |
|||
wxString str; |
|||
long index = 0; |
|||
|
|||
std::set<wxString> group_blacklist; |
|||
|
|||
// Legacy files don't store board info; they assume board matches project name
|
|||
// We will leave m_boards empty here so it can be populated with other code
|
|||
|
|||
// First handle migration of data that will be stored locally in this object
|
|||
|
|||
auto loadPinnedLibs = |
|||
[&]( const std::string& aDest ) |
|||
{ |
|||
int libIndex = 1; |
|||
wxString libKey = wxT( "PinnedItems" ); |
|||
libKey << libIndex; |
|||
|
|||
nlohmann::json libs = nlohmann::json::array(); |
|||
|
|||
while( aCfg->Read( libKey, &str ) ) |
|||
{ |
|||
libs.push_back( str ); |
|||
|
|||
aCfg->DeleteEntry( libKey, true ); |
|||
|
|||
libKey = wxT( "PinnedItems" ); |
|||
libKey << ++libIndex; |
|||
} |
|||
|
|||
( *this )[PointerFromString( aDest )] = libs; |
|||
}; |
|||
|
|||
aCfg->SetPath( wxT( "/LibeditFrame" ) ); |
|||
loadPinnedLibs( "libraries.pinned_symbol_libs" ); |
|||
|
|||
aCfg->SetPath( wxT( "/ModEditFrame" ) ); |
|||
loadPinnedLibs( "libraries.pinned_footprint_libs" ); |
|||
|
|||
aCfg->SetPath( wxT( "/cvpcb/equfiles" ) ); |
|||
|
|||
{ |
|||
int eqIdx = 1; |
|||
wxString eqKey = wxT( "EquName" ); |
|||
eqKey << eqIdx; |
|||
|
|||
nlohmann::json eqs = nlohmann::json::array(); |
|||
|
|||
while( aCfg->Read( eqKey, &str ) ) |
|||
{ |
|||
eqs.push_back( str ); |
|||
|
|||
eqKey = wxT( "EquName" ); |
|||
eqKey << ++eqIdx; |
|||
} |
|||
|
|||
( *this )[PointerFromString( "cvpcb.equivalence_files" )] = eqs; |
|||
} |
|||
|
|||
// All CvPcb params that we want to keep have been migrated above
|
|||
group_blacklist.insert( wxT( "/cvpcb" ) ); |
|||
|
|||
aCfg->SetPath( wxT( "/pcbnew" ) ); |
|||
|
|||
fromLegacyString( aCfg, "PageLayoutDescrFile", "pcbnew.page_layout_descr_file" ); |
|||
fromLegacyString( aCfg, "LastNetListRead", "pcbnew.last_paths.netlist" ); |
|||
fromLegacyString( aCfg, "LastSTEPExportPath", "pcbnew.last_paths.step" ); |
|||
fromLegacyString( aCfg, "LastIDFExportPath", "pcbnew.last_paths.idf" ); |
|||
fromLegacyString( aCfg, "LastVRMLExportPath", "pcbnew.last_paths.vmrl" ); |
|||
fromLegacyString( aCfg, "LastSpecctraDSNExportPath", "pcbnew.last_paths.specctra_dsn" ); |
|||
fromLegacyString( aCfg, "LastGenCADExportPath", "pcbnew.last_paths.gencad" ); |
|||
|
|||
std::string bp = "board.design_settings."; |
|||
|
|||
{ |
|||
int idx = 1; |
|||
wxString key = wxT( "DRCExclusion" ); |
|||
key << idx; |
|||
|
|||
nlohmann::json exclusions = nlohmann::json::array(); |
|||
|
|||
while( aCfg->Read( key, &str ) ) |
|||
{ |
|||
exclusions.push_back( str ); |
|||
|
|||
key = wxT( "DRCExclusion" ); |
|||
key << ++idx; |
|||
} |
|||
|
|||
( *this )[PointerFromString( bp + "drc_exclusions" )] = exclusions; |
|||
} |
|||
|
|||
fromLegacy<bool>( aCfg, "AllowMicroVias", bp + "rules.allow_microvias" ); |
|||
fromLegacy<bool>( aCfg, "AllowBlindVias", bp + "rules.allow_blind_buried_vias" ); |
|||
fromLegacy<double>( aCfg, "MinClearance", bp + "rules.min_clearance" ); |
|||
fromLegacy<double>( aCfg, "MinTrackWidth", bp + "rules.min_track_width" ); |
|||
fromLegacy<double>( aCfg, "MinViaAnnulus", bp + "rules.min_via_annulus" ); |
|||
fromLegacy<double>( aCfg, "MinViaDiameter", bp + "rules.min_via_diameter" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "MinThroughDrill", bp + "rules.min_through_hole_diameter" ) ) |
|||
fromLegacy<double>( aCfg, "MinViaDrill", bp + "rules.min_through_hole_diameter" ); |
|||
|
|||
fromLegacy<double>( aCfg, "MinMicroViaDiameter", bp + "rules.min_microvia_diameter" ); |
|||
fromLegacy<double>( aCfg, "MinMicroViaDrill", bp + "rules.min_microvia_drill" ); |
|||
fromLegacy<double>( aCfg, "MinHoleToHole", bp + "rules.min_hole_to_hole" ); |
|||
fromLegacy<double>( aCfg, "CopperEdgeClearance", bp + "rules.min_copper_edge_clearance" ); |
|||
fromLegacy<double>( aCfg, "SolderMaskClearance", bp + "rules.solder_mask_clearance" ); |
|||
fromLegacy<double>( aCfg, "SolderMaskMinWidth", bp + "rules.solder_mask_min_width" ); |
|||
fromLegacy<double>( aCfg, "SolderPasteClearance", bp + "rules.solder_paste_clearance" ); |
|||
fromLegacy<double>( aCfg, "SolderPasteRatio", bp + "rules.solder_paste_margin_ratio" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "SilkLineWidth", bp + "defaults.silk_line_width" ) ) |
|||
fromLegacy<double>( aCfg, "ModuleOutlineThickness", bp + "defaults.silk_line_width" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "SilkTextSizeV", bp + "defaults.silk_text_size_v" ) ) |
|||
fromLegacy<double>( aCfg, "ModuleTextSizeV", bp + "defaults.silk_text_size_v" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "SilkTextSizeH", bp + "defaults.silk_text_size_h" ) ) |
|||
fromLegacy<double>( aCfg, "ModuleTextSizeH", bp + "defaults.silk_text_size_h" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "SilkTextSizeThickness", bp + "defaults.silk_text_thickness" ) ) |
|||
fromLegacy<double>( aCfg, "ModuleTextSizeThickness", bp + "defaults.silk_text_thickness" ); |
|||
|
|||
fromLegacy<bool>( aCfg, "SilkTextItalic", bp + "defaults.silk_text_italic" ); |
|||
fromLegacy<bool>( aCfg, "SilkTextUpright", bp + "defaults.silk_text_upright" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "CopperLineWidth", bp + "defaults.copper_line_width" ) ) |
|||
fromLegacy<double>( aCfg, "DrawSegmentWidth", bp + "defaults.copper_line_width" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "CopperTextSizeV", bp + "defaults.copper_text_size_v" ) ) |
|||
fromLegacy<double>( aCfg, "PcbTextSizeV", bp + "defaults.copper_text_size_v" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "CopperTextSizeH", bp + "defaults.copper_text_size_h" ) ) |
|||
fromLegacy<double>( aCfg, "PcbTextSizeH", bp + "defaults.copper_text_size_h" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "CopperTextThickness", bp + "defaults.copper_text_thickness" ) ) |
|||
fromLegacy<double>( aCfg, "PcbTextThickness", bp + "defaults.copper_text_thickness" ); |
|||
|
|||
fromLegacy<bool>( aCfg, "CopperTextItalic", bp + "defaults.copper_text_italic" ); |
|||
fromLegacy<bool>( aCfg, "CopperTextUpright", bp + "defaults.copper_text_upright" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "EdgeCutLineWidth", bp + "defaults.board_outline_line_width" ) ) |
|||
fromLegacy<double>( |
|||
aCfg, "BoardOutlineThickness", bp + "defaults.board_outline_line_width" ); |
|||
|
|||
fromLegacy<double>( aCfg, "CourtyardLineWidth", bp + "defaults.courtyard_line_width" ); |
|||
|
|||
fromLegacy<double>( aCfg, "FabLineWidth", bp + "defaults.fab_line_width" ); |
|||
fromLegacy<double>( aCfg, "FabTextSizeV", bp + "defaults.fab_text_size_v" ); |
|||
fromLegacy<double>( aCfg, "FabTextSizeH", bp + "defaults.fab_text_size_h" ); |
|||
fromLegacy<double>( aCfg, "FabTextSizeThickness", bp + "defaults.fab_text_thickness" ); |
|||
fromLegacy<bool>( aCfg, "FabTextItalic", bp + "defaults.fab_text_italic" ); |
|||
fromLegacy<bool>( aCfg, "FabTextUpright", bp + "defaults.fab_text_upright" ); |
|||
|
|||
if( !fromLegacy<double>( aCfg, "OthersLineWidth", bp + "defaults.other_line_width" ) ) |
|||
fromLegacy<double>( aCfg, "ModuleOutlineThickness", bp + "defaults.other_line_width" ); |
|||
|
|||
fromLegacy<double>( aCfg, "OthersTextSizeV", bp + "defaults.other_text_size_v" ); |
|||
fromLegacy<double>( aCfg, "OthersTextSizeH", bp + "defaults.other_text_size_h" ); |
|||
fromLegacy<double>( aCfg, "OthersTextSizeThickness", bp + "defaults.other_text_thickness" ); |
|||
fromLegacy<bool>( aCfg, "OthersTextItalic", bp + "defaults.other_text_italic" ); |
|||
fromLegacy<bool>( aCfg, "OthersTextUpright", bp + "defaults.other_text_upright" ); |
|||
|
|||
fromLegacy<int>( aCfg, "DimensionUnits", bp + "defaults.dimension_units" ); |
|||
fromLegacy<int>( aCfg, "DimensionPrecision", bp + "defaults.dimension_precision" ); |
|||
|
|||
std::string sev = bp + "rule_severities"; |
|||
|
|||
fromLegacy<bool>( |
|||
aCfg, "RequireCourtyardDefinitions", sev + "legacy_no_courtyard_defined" ); |
|||
|
|||
fromLegacy<bool>( aCfg, "ProhibitOverlappingCourtyards", sev + "legacy_ourtyards_overlap" ); |
|||
|
|||
{ |
|||
int idx = 1; |
|||
wxString keyBase = "TrackWidth"; |
|||
wxString key = keyBase; |
|||
double val; |
|||
|
|||
nlohmann::json widths = nlohmann::json::array(); |
|||
|
|||
key << idx; |
|||
|
|||
while( aCfg->Read( key, &val ) ) |
|||
{ |
|||
widths.push_back( val ); |
|||
key = keyBase; |
|||
key << ++idx; |
|||
} |
|||
|
|||
( *this )[PointerFromString( bp + "track_widths" )] = widths; |
|||
} |
|||
|
|||
{ |
|||
int idx = 1; |
|||
wxString keyBase = "ViaDiameter"; |
|||
wxString key = keyBase; |
|||
double diameter; |
|||
double drill = 1.0; |
|||
|
|||
nlohmann::json vias = nlohmann::json::array(); |
|||
|
|||
key << idx; |
|||
|
|||
while( aCfg->Read( key, &diameter ) ) |
|||
{ |
|||
key = "ViaDrill"; |
|||
aCfg->Read( key << idx, &drill ); |
|||
|
|||
nlohmann::json via = { { "diameter", diameter }, { "drill", drill } }; |
|||
vias.push_back( via ); |
|||
|
|||
key = keyBase; |
|||
key << ++idx; |
|||
} |
|||
|
|||
( *this )[PointerFromString( bp + "via_dimensions" )] = vias; |
|||
} |
|||
|
|||
{ |
|||
int idx = 1; |
|||
wxString keyBase = "dPairWidth"; |
|||
wxString key = keyBase; |
|||
double width; |
|||
double gap = 1.0; |
|||
double via_gap = 1.0; |
|||
|
|||
nlohmann::json pairs = nlohmann::json::array(); |
|||
|
|||
key << idx; |
|||
|
|||
while( aCfg->Read( key, &width ) ) |
|||
{ |
|||
key = "dPairGap"; |
|||
aCfg->Read( key << idx, &gap ); |
|||
|
|||
key = "dPairViaGap"; |
|||
aCfg->Read( key << idx, &via_gap ); |
|||
|
|||
nlohmann::json pair = { { "width", width }, { "gap", gap }, { "via_gap", via_gap } }; |
|||
pairs.push_back( pair ); |
|||
|
|||
key = keyBase; |
|||
key << ++idx; |
|||
} |
|||
|
|||
( *this )[PointerFromString( bp + "diff_pair_dimensions" )] = pairs; |
|||
} |
|||
|
|||
// NOTE: severities are just left alone to be migrated by BOARD_DESIGN_SETTINGS when it
|
|||
// initializes, so that common doesn't need knowledge of the DRC error list (this is the
|
|||
// downside of storing them as string keys... Do not blacklist the /pcbnew group so that
|
|||
// this works!
|
|||
|
|||
// General group is unused these days, we can throw it away
|
|||
group_blacklist.insert( wxT( "/general" ) ); |
|||
|
|||
// Next load sheet names and put all other legacy data in the legacy dict
|
|||
aCfg->SetPath( wxT( "/" ) ); |
|||
|
|||
auto loadSheetNames = |
|||
[&]() -> bool |
|||
{ |
|||
int sheet = 1; |
|||
wxString entry; |
|||
nlohmann::json arr = nlohmann::json::array(); |
|||
|
|||
wxLogTrace( traceSettings, "Migrating sheet names" ); |
|||
|
|||
aCfg->SetPath( wxT( "/sheetnames" ) ); |
|||
|
|||
while( aCfg->Read( wxString::Format( "%d", sheet++ ), &entry ) ) |
|||
{ |
|||
wxArrayString tokens = wxSplit( entry, ':' ); |
|||
|
|||
if( tokens.size() == 2 ) |
|||
{ |
|||
wxLogTrace( traceSettings, "%d: %s = %s", sheet, tokens[0], tokens[1] ); |
|||
arr.push_back( nlohmann::json::array( { tokens[0], tokens[1] } ) ); |
|||
} |
|||
} |
|||
|
|||
( *this )[PointerFromString( "sheets" )] = arr; |
|||
|
|||
aCfg->SetPath( "/" ); |
|||
|
|||
// TODO: any reason we want to fail on this?
|
|||
return true; |
|||
}; |
|||
|
|||
std::vector<wxString> groups; |
|||
|
|||
groups.emplace_back( "" ); |
|||
|
|||
auto loadLegacyPairs = |
|||
[&]( const std::string& aGroup ) -> bool |
|||
{ |
|||
wxLogTrace( traceSettings, "Migrating group %s", aGroup ); |
|||
bool success = true; |
|||
wxString keyStr; |
|||
wxString val; |
|||
|
|||
index = 0; |
|||
|
|||
while( aCfg->GetNextEntry( keyStr, index ) ) |
|||
{ |
|||
if( !aCfg->Read( keyStr, &val ) ) |
|||
continue; |
|||
|
|||
std::string key( keyStr.ToUTF8() ); |
|||
|
|||
wxLogTrace( traceSettings, " %s = %s", key, val ); |
|||
|
|||
try |
|||
{ |
|||
nlohmann::json::json_pointer ptr( "/legacy" + aGroup + "/" + key ); |
|||
( *this )[ptr] = val; |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
success = false; |
|||
} |
|||
} |
|||
|
|||
return success; |
|||
}; |
|||
|
|||
for( size_t i = 0; i < groups.size(); i++ ) |
|||
{ |
|||
aCfg->SetPath( groups[i] ); |
|||
|
|||
if( groups[i] == wxT( "/sheetnames" ) ) |
|||
{ |
|||
ret |= loadSheetNames(); |
|||
continue; |
|||
} |
|||
|
|||
aCfg->DeleteEntry( wxT( "last_client" ), true ); |
|||
aCfg->DeleteEntry( wxT( "update" ), true ); |
|||
aCfg->DeleteEntry( wxT( "version" ), true ); |
|||
|
|||
ret &= loadLegacyPairs( groups[i].ToStdString() ); |
|||
|
|||
index = 0; |
|||
|
|||
while( aCfg->GetNextGroup( str, index ) ) |
|||
{ |
|||
wxString group = groups[i] + "/" + str; |
|||
|
|||
if( !group_blacklist.count( group ) ) |
|||
groups.emplace_back( group ); |
|||
} |
|||
|
|||
aCfg->SetPath( "/" ); |
|||
} |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
|
|||
bool PROJECT_FILE::SaveToFile( const std::string& aDirectory, bool aForce ) |
|||
{ |
|||
wxASSERT( m_project ); |
|||
|
|||
( *this )[PointerFromString( "meta.filename" )] = |
|||
m_project->GetProjectName() + "." + ProjectFileExtension; |
|||
|
|||
return JSON_SETTINGS::SaveToFile( aDirectory, aForce ); |
|||
} |
|||
|
|||
|
|||
wxString PROJECT_FILE::getFileExt() const |
|||
{ |
|||
return ProjectFileExtension; |
|||
} |
|||
|
|||
|
|||
wxString PROJECT_FILE::getLegacyFileExt() const |
|||
{ |
|||
return LegacyProjectFileExtension; |
|||
} |
|||
|
|||
|
|||
void to_json( nlohmann::json& aJson, const FILE_INFO_PAIR& aPair ) |
|||
{ |
|||
aJson = nlohmann::json::array( { aPair.first.AsString().ToUTF8(), aPair.second.ToUTF8() } ); |
|||
} |
|||
|
|||
|
|||
void from_json( const nlohmann::json& aJson, FILE_INFO_PAIR& aPair ) |
|||
{ |
|||
wxASSERT( aJson.is_array() && aJson.size() == 2 ); |
|||
aPair.first = KIID( wxString( aJson[0].get<std::string>().c_str(), wxConvUTF8 ) ); |
|||
aPair.second = wxString( aJson[1].get<std::string>().c_str(), wxConvUTF8 ); |
|||
} |
|||
@ -0,0 +1,105 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 CERN |
|||
* @author Jon Evans <jon@craftyjon.com> |
|||
* |
|||
* 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 <project.h>
|
|||
#include <project/project_local_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
|
|||
const int projectLocalSettingsVersion = 1; |
|||
|
|||
|
|||
PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( const std::string& aFilename ) : |
|||
JSON_SETTINGS( aFilename, SETTINGS_LOC::PROJECT, projectLocalSettingsVersion, |
|||
/* aCreateIfMissing = */ true, /* aCreateIfDefault = */ false, |
|||
/* aWriteFile = */ true ), |
|||
m_project( nullptr ) |
|||
{ |
|||
m_params.emplace_back( new PARAM_LAMBDA<std::string>( "board.visible_layers", |
|||
[&]() -> std::string |
|||
{ |
|||
return m_VisibleLayers.FmtHex(); |
|||
}, |
|||
[&]( const std::string& aString ) |
|||
{ |
|||
m_VisibleLayers.ParseHex( aString.c_str(), aString.size() ); |
|||
}, |
|||
LSET::AllLayersMask().FmtHex() ) ); |
|||
|
|||
static GAL_SET defaultVisible; |
|||
defaultVisible.set().reset( GAL_LAYER_INDEX( LAYER_MOD_TEXT_INVISIBLE ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "board.visible_items", |
|||
[&]() -> nlohmann::json |
|||
{ |
|||
nlohmann::json ret = nlohmann::json::array(); |
|||
|
|||
for( size_t i = 0; i < m_VisibleItems.size(); i++ ) |
|||
if( m_VisibleItems.test( i ) ) |
|||
ret.push_back( i ); |
|||
|
|||
return ret; |
|||
}, |
|||
[&]( const nlohmann::json& aVal ) |
|||
{ |
|||
if( !aVal.is_array() || aVal.empty() ) |
|||
{ |
|||
m_VisibleItems = defaultVisible; |
|||
return; |
|||
} |
|||
|
|||
m_VisibleItems.reset(); |
|||
|
|||
for( const nlohmann::json& entry : aVal ) |
|||
{ |
|||
try |
|||
{ |
|||
int i = entry.get<int>(); |
|||
m_VisibleItems.set( i ); |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
// Non-integer or out of range entry in the array; ignore
|
|||
} |
|||
} |
|||
}, |
|||
{} ) ); |
|||
} |
|||
|
|||
|
|||
bool PROJECT_LOCAL_SETTINGS::MigrateFromLegacy( wxConfigBase* aLegacyConfig ) |
|||
{ |
|||
/**
|
|||
* The normal legacy migration code won't be used for this because the only legacy |
|||
* information stored here was stored in board files, so we do that migration when loading |
|||
* the board. |
|||
*/ |
|||
return true; |
|||
} |
|||
|
|||
|
|||
bool PROJECT_LOCAL_SETTINGS::SaveToFile( const std::string& aDirectory, bool aForce ) |
|||
{ |
|||
wxASSERT( m_project ); |
|||
|
|||
( *this )[PointerFromString( "meta.filename" )] = |
|||
m_project->GetProjectName() + "." + ProjectLocalSettingsFileExtension; |
|||
|
|||
return JSON_SETTINGS::SaveToFile( aDirectory, aForce ); |
|||
} |
|||
@ -1,247 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 CERN |
|||
* @author Jon Evans <jon@craftyjon.com> |
|||
* |
|||
* 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 <config_params.h>
|
|||
#include <settings/common_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
#include <settings/project_file.h>
|
|||
#include <wildcards_and_files_ext.h>
|
|||
#include <wx/config.h>
|
|||
#include <wx/log.h>
|
|||
|
|||
extern const char* traceSettings; |
|||
|
|||
///! Update the schema version whenever a migration is required
|
|||
const int projectFileSchemaVersion = 1; |
|||
|
|||
|
|||
PROJECT_FILE::PROJECT_FILE( const std::string& aFullPath ) : |
|||
JSON_SETTINGS( aFullPath, SETTINGS_LOC::NONE, projectFileSchemaVersion ), |
|||
m_sheets(), m_boards() |
|||
{ |
|||
// Keep old files around
|
|||
m_deleteLegacyAfterMigration = false; |
|||
|
|||
m_params.emplace_back( new PARAM_LIST<FILE_INFO_PAIR>( "sheets", &m_sheets, {} ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_LIST<FILE_INFO_PAIR>( "boards", &m_boards, {} ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM_LIST<wxString>( "libraries.pinned_symbol_libs", &m_PinnedSymbolLibs, {} ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_LIST<wxString>( |
|||
"libraries.pinned_footprint_libs", &m_PinnedFootprintLibs, {} ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM_PATH_LIST( "cvpcb.equivalence_files", &m_EquivalenceFiles, {} ) ); |
|||
} |
|||
|
|||
|
|||
bool PROJECT_FILE::MigrateFromLegacy( wxConfigBase* aLegacyFile ) |
|||
{ |
|||
bool ret = true; |
|||
wxString str; |
|||
long index = 0; |
|||
|
|||
std::set<wxString> group_blacklist; |
|||
|
|||
// Legacy files don't store board info; they assume board matches project name
|
|||
// We will leave m_boards empty here so it can be populated with other code
|
|||
|
|||
// First handle migration of data that will be stored locally in this object
|
|||
|
|||
auto loadPinnedLibs = |
|||
[&]( const std::string& aDest ) |
|||
{ |
|||
int libIndex = 1; |
|||
wxString libKey = wxT( "PinnedItems" ); |
|||
libKey << libIndex; |
|||
|
|||
nlohmann::json libs = nlohmann::json::array(); |
|||
|
|||
while( aLegacyFile->Read( libKey, &str ) ) |
|||
{ |
|||
libs.push_back( str ); |
|||
|
|||
aLegacyFile->DeleteEntry( libKey, true ); |
|||
|
|||
libKey = wxT( "PinnedItems" ); |
|||
libKey << ++libIndex; |
|||
} |
|||
|
|||
( *this )[PointerFromString( aDest )] = libs; |
|||
}; |
|||
|
|||
aLegacyFile->SetPath( wxT( "/LibeditFrame" ) ); |
|||
loadPinnedLibs( "libraries.pinned_symbol_libs" ); |
|||
|
|||
aLegacyFile->SetPath( wxT( "/ModEditFrame" ) ); |
|||
loadPinnedLibs( "libraries.pinned_footprint_libs" ); |
|||
|
|||
aLegacyFile->SetPath( wxT( "/cvpcb/equfiles" ) ); |
|||
|
|||
{ |
|||
int eqIdx = 1; |
|||
wxString eqKey = wxT( "EquName" ); |
|||
eqKey << eqIdx; |
|||
|
|||
nlohmann::json eqs = nlohmann::json::array(); |
|||
|
|||
while( aLegacyFile->Read( eqKey, &str ) ) |
|||
{ |
|||
eqs.push_back( str ); |
|||
|
|||
eqKey = wxT( "EquName" ); |
|||
eqKey << ++eqIdx; |
|||
} |
|||
|
|||
( *this )[PointerFromString( "cvpcb.equivalence_files" )] = eqs; |
|||
} |
|||
|
|||
// No other cvpcb params are currently used
|
|||
group_blacklist.insert( "/cvpcb" ); |
|||
|
|||
// Next load sheet names and put all other legacy data in the legacy dict
|
|||
aLegacyFile->SetPath( "/" ); |
|||
|
|||
auto loadSheetNames = |
|||
[&]() -> bool |
|||
{ |
|||
int sheet = 1; |
|||
wxString entry; |
|||
nlohmann::json arr = nlohmann::json::array(); |
|||
|
|||
wxLogTrace( traceSettings, "Migrating sheet names" ); |
|||
|
|||
aLegacyFile->SetPath( wxT( "/sheetnames" ) ); |
|||
|
|||
while( aLegacyFile->Read( wxString::Format( "%d", sheet++ ), &entry ) ) |
|||
{ |
|||
wxArrayString tokens = wxSplit( entry, ':' ); |
|||
|
|||
if( tokens.size() == 2 ) |
|||
{ |
|||
wxLogTrace( traceSettings, "%d: %s = %s", sheet, tokens[0], tokens[1] ); |
|||
arr.push_back( nlohmann::json::array( { tokens[0], tokens[1] } ) ); |
|||
} |
|||
} |
|||
|
|||
( *this )[PointerFromString( "sheets" )] = arr; |
|||
|
|||
aLegacyFile->SetPath( "/" ); |
|||
|
|||
// TODO: any reason we want to fail on this?
|
|||
return true; |
|||
}; |
|||
|
|||
std::vector<wxString> groups; |
|||
|
|||
groups.emplace_back( "" ); |
|||
|
|||
auto loadLegacyPairs = |
|||
[&]( const std::string& aGroup ) -> bool |
|||
{ |
|||
wxLogTrace( traceSettings, "Migrating group %s", aGroup ); |
|||
bool success = true; |
|||
wxString keyStr; |
|||
wxString val; |
|||
|
|||
index = 0; |
|||
|
|||
while( aLegacyFile->GetNextEntry( keyStr, index ) ) |
|||
{ |
|||
if( !aLegacyFile->Read( keyStr, &val ) ) |
|||
continue; |
|||
|
|||
std::string key( keyStr.ToUTF8() ); |
|||
|
|||
wxLogTrace( traceSettings, " %s = %s", key, val ); |
|||
|
|||
try |
|||
{ |
|||
nlohmann::json::json_pointer ptr( "/legacy" + aGroup + "/" + key ); |
|||
( *this )[ptr] = val; |
|||
} |
|||
catch( ... ) |
|||
{ |
|||
success = false; |
|||
} |
|||
} |
|||
|
|||
return success; |
|||
}; |
|||
|
|||
for( size_t i = 0; i < groups.size(); i++ ) |
|||
{ |
|||
aLegacyFile->SetPath( groups[i] ); |
|||
|
|||
if( groups[i] == wxT( "/sheetnames" ) ) |
|||
{ |
|||
ret |= loadSheetNames(); |
|||
continue; |
|||
} |
|||
|
|||
aLegacyFile->DeleteEntry( wxT( "last_client" ), true ); |
|||
aLegacyFile->DeleteEntry( wxT( "update" ), true ); |
|||
aLegacyFile->DeleteEntry( wxT( "version" ), true ); |
|||
|
|||
ret &= loadLegacyPairs( groups[i].ToStdString() ); |
|||
|
|||
index = 0; |
|||
|
|||
while( aLegacyFile->GetNextGroup( str, index ) ) |
|||
{ |
|||
wxString group = groups[i] + "/" + str; |
|||
|
|||
if( !group_blacklist.count( group ) ) |
|||
groups.emplace_back( group ); |
|||
} |
|||
|
|||
aLegacyFile->SetPath( "/" ); |
|||
} |
|||
|
|||
return ret; |
|||
} |
|||
|
|||
|
|||
wxString PROJECT_FILE::getFileExt() const |
|||
{ |
|||
return ProjectFileExtension; |
|||
} |
|||
|
|||
|
|||
wxString PROJECT_FILE::getLegacyFileExt() const |
|||
{ |
|||
return LegacyProjectFileExtension; |
|||
} |
|||
|
|||
|
|||
void to_json( nlohmann::json& aJson, const FILE_INFO_PAIR& aPair ) |
|||
{ |
|||
aJson = nlohmann::json::array( { aPair.first.AsString().ToUTF8(), aPair.second.ToUTF8() } ); |
|||
} |
|||
|
|||
|
|||
void from_json( const nlohmann::json& aJson, FILE_INFO_PAIR& aPair ) |
|||
{ |
|||
wxASSERT( aJson.is_array() && aJson.size() == 2 ); |
|||
aPair.first = KIID( wxString( aJson[0].get<std::string>().c_str(), wxConvUTF8 ) ); |
|||
aPair.second = wxString( aJson[1].get<std::string>().c_str(), wxConvUTF8 ); |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 CERN |
|||
* @author Jon Evans <jon@craftyjon.com> |
|||
* |
|||
* 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/>. |
|||
*/ |
|||
|
|||
#ifndef KICAD_NET_SETTINGS_H |
|||
#define KICAD_NET_SETTINGS_H |
|||
|
|||
#include <netclass.h> |
|||
#include <settings/nested_settings.h> |
|||
|
|||
/** |
|||
* NET_SETTINGS stores various net-related settings in a project context. These settings are |
|||
* accessible and editable from both the schematic and PCB editors. |
|||
*/ |
|||
class NET_SETTINGS : public NESTED_SETTINGS |
|||
{ |
|||
public: |
|||
NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ); |
|||
|
|||
virtual ~NET_SETTINGS(); |
|||
|
|||
NETCLASSES m_NetClasses; |
|||
|
|||
private: |
|||
NETCLASSPTR m_defaultClass; |
|||
|
|||
// TODO: Add diff pairs, bus information, etc here. |
|||
}; |
|||
|
|||
#endif // KICAD_NET_SETTINGS_H |
|||
@ -0,0 +1,83 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 CERN |
|||
* @author Jon Evans <jon@craftyjon.com> |
|||
* |
|||
* 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/>. |
|||
*/ |
|||
|
|||
#ifndef KICAD_PROJECT_LOCAL_SETTINGS_H |
|||
#define KICAD_PROJECT_LOCAL_SETTINGS_H |
|||
|
|||
#include <layers_id_colors_and_visibility.h> |
|||
#include <settings/json_settings.h> |
|||
#include <wildcards_and_files_ext.h> |
|||
|
|||
class PROJECT; |
|||
|
|||
/** |
|||
* The project local settings are things that are attached to a particular project, but also might |
|||
* be particular to a certain user editing that project, or change quickly, and therefore may not |
|||
* want to be checked in to version control or otherwise distributed with the main project. |
|||
* |
|||
* Examples include layer visibility, recently-used design entry settings, and so on. |
|||
* |
|||
* The backing store is a JSON file named <project>.kicad_prl |
|||
* |
|||
* This file doesn't need to exist for a project to be loaded. It will be created on-demand if |
|||
* any of the things stored here are modified by the user. |
|||
*/ |
|||
class PROJECT_LOCAL_SETTINGS : public JSON_SETTINGS |
|||
{ |
|||
public: |
|||
PROJECT_LOCAL_SETTINGS( const std::string& aFilename ); |
|||
|
|||
virtual ~PROJECT_LOCAL_SETTINGS() {} |
|||
|
|||
bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override; |
|||
|
|||
bool SaveToFile( const std::string& aDirectory = "", bool aForce = false ) override; |
|||
|
|||
void SetProject( PROJECT* aProject ) |
|||
{ |
|||
m_project = aProject; |
|||
} |
|||
|
|||
protected: |
|||
|
|||
wxString getFileExt() const override |
|||
{ |
|||
return ProjectLocalSettingsFileExtension; |
|||
} |
|||
|
|||
private: |
|||
|
|||
/// A link to the owning project |
|||
PROJECT* m_project; |
|||
|
|||
public: |
|||
|
|||
/** |
|||
* Board settings |
|||
*/ |
|||
|
|||
/// The board layers that are turned on for viewing (@see PCB_LAYER_ID) |
|||
LSET m_VisibleLayers; |
|||
|
|||
/// The GAL layers (aka items) that are turned on for viewing (@see GAL_LAYER_ID) |
|||
GAL_SET m_VisibleItems; |
|||
}; |
|||
|
|||
#endif |
|||
1203
pcbnew/board_design_settings.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue