Browse Source
Port Eeschema to new project settings
Port Eeschema to new project settings
DRC/ERC error serialization changed to use explicit tokens Old stored severities and ignored errors are discardedpull/16/head
59 changed files with 1555 additions and 1118 deletions
-
61common/dialogs/panel_setup_severities.cpp
-
23common/dialogs/panel_setup_severities.h
-
95common/project.cpp
-
114common/project/project_file.cpp
-
2common/rc_item.cpp
-
28common/rc_item.h
-
6common/settings/nested_settings.cpp
-
20common/widgets/ui_common.cpp
-
2eeschema/CMakeLists.txt
-
43eeschema/class_library.cpp
-
32eeschema/connection_graph.cpp
-
43eeschema/dialogs/dialog_erc.cpp
-
2eeschema/dialogs/dialog_sch_import_settings.cpp
-
62eeschema/dialogs/dialog_schematic_setup.cpp
-
1eeschema/dialogs/dialog_schematic_setup.h
-
1eeschema/dialogs/dialog_symbol_remap.cpp
-
14eeschema/dialogs/panel_setup_formatting.cpp
-
3eeschema/dialogs/panel_setup_formatting.h
-
99eeschema/eeschema_config.cpp
-
22eeschema/erc.cpp
-
203eeschema/erc_item.cpp
-
45eeschema/erc_item.h
-
218eeschema/erc_settings.cpp
-
61eeschema/erc_settings.h
-
12eeschema/files-io.cpp
-
1eeschema/sch_base_frame.cpp
-
16eeschema/sch_eagle_plugin.cpp
-
3eeschema/sch_edit_frame.cpp
-
12eeschema/sch_edit_frame.h
-
5eeschema/sch_marker.cpp
-
167eeschema/schematic.cpp
-
63eeschema/schematic.h
-
152eeschema/schematic_settings.cpp
-
29eeschema/schematic_settings.h
-
13include/config_params.h
-
43include/project.h
-
36include/project/project_file.h
-
103include/settings/parameters.h
-
6include/widgets/ui_common.h
-
2kicad/kicad_manager_frame.cpp
-
71pcbnew/board_design_settings.cpp
-
7pcbnew/class_marker_pcb.cpp
-
2pcbnew/cleanup_item.h
-
7pcbnew/dialogs/dialog_board_setup.cpp
-
6pcbnew/dialogs/dialog_drc.cpp
-
57pcbnew/drc/drc.cpp
-
50pcbnew/drc/drc.h
-
59pcbnew/drc/drc_clearance_test_functions.cpp
-
8pcbnew/drc/drc_courtyard_tester.cpp
-
12pcbnew/drc/drc_drilled_hole_tester.cpp
-
301pcbnew/drc/drc_item.cpp
-
66pcbnew/drc/drc_item.h
-
30pcbnew/drc/drc_keepout_tester.cpp
-
95pcbnew/drc/drc_netclass_tester.cpp
-
6pcbnew/drc/drc_textvar_tester.cpp
-
6pcbnew/drc/footprint_tester.cpp
-
4pcbnew/pcbnew_config.cpp
-
8qa/eeschema/sim/test_netlist_exporter_pspice_sim.cpp
-
15qa/eeschema/test_netlists.cpp
@ -0,0 +1,218 @@ |
|||
/*
|
|||
* 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 <erc_item.h>
|
|||
#include <erc_settings.h>
|
|||
#include <schematic.h>
|
|||
#include <sch_marker.h>
|
|||
#include <sch_screen.h>
|
|||
#include <settings/parameters.h>
|
|||
|
|||
|
|||
const int ercSettingsSchemaVersion = 0; |
|||
|
|||
|
|||
ERC_SETTINGS::ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) : |
|||
NESTED_SETTINGS( "erc", ercSettingsSchemaVersion, aParent, aPath ) |
|||
{ |
|||
for( int i = ERCE_FIRST; i <= ERCE_LAST; ++i ) |
|||
m_Severities[ i ] = RPT_SEVERITY_ERROR; |
|||
|
|||
m_Severities[ ERCE_UNSPECIFIED ] = RPT_SEVERITY_UNDEFINED; |
|||
|
|||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "rule_severities", |
|||
[&]() -> nlohmann::json |
|||
{ |
|||
nlohmann::json ret = {}; |
|||
|
|||
for( const RC_ITEM& item : ERC_ITEM::GetItemsWithSeverities() ) |
|||
{ |
|||
int code = item.GetErrorCode(); |
|||
|
|||
if( !m_Severities.count( code ) ) |
|||
continue; |
|||
|
|||
wxString name = item.GetSettingsKey(); |
|||
|
|||
ret[std::string( name.ToUTF8() )] = |
|||
SeverityToString( static_cast<SEVERITY>( m_Severities[code] ) ); |
|||
} |
|||
|
|||
return ret; |
|||
}, |
|||
[&]( const nlohmann::json& aJson ) |
|||
{ |
|||
if( !aJson.is_object() ) |
|||
return; |
|||
|
|||
for( const RC_ITEM& item : ERC_ITEM::GetItemsWithSeverities() ) |
|||
{ |
|||
int code = item.GetErrorCode(); |
|||
wxString name = item.GetSettingsKey(); |
|||
|
|||
std::string key( name.ToUTF8() ); |
|||
|
|||
if( aJson.contains( key ) ) |
|||
m_Severities[code] = SeverityFromString( aJson[key] ); |
|||
} |
|||
}, |
|||
{} ) ); |
|||
} |
|||
|
|||
|
|||
ERC_SETTINGS::~ERC_SETTINGS() |
|||
{ |
|||
if( m_parent ) |
|||
{ |
|||
m_parent->ReleaseNestedSettings( this ); |
|||
m_parent = nullptr; |
|||
} |
|||
} |
|||
|
|||
|
|||
int ERC_SETTINGS::GetSeverity( int aErrorCode ) const |
|||
{ |
|||
wxCHECK_MSG( m_Severities.count( aErrorCode ), RPT_SEVERITY_IGNORE, |
|||
"Missing severity from map in ERC_SETTINGS!" ); |
|||
|
|||
// Special-case pin-to-pin errors:
|
|||
// Ignore-or-not is controlled by ERCE_PIN_TO_PIN_WARNING (for both)
|
|||
// Warning-or-error is controlled by which errorCode it is
|
|||
if( aErrorCode == ERCE_PIN_TO_PIN_ERROR ) |
|||
{ |
|||
wxASSERT( m_Severities.count( ERCE_PIN_TO_PIN_WARNING ) ); |
|||
|
|||
if( m_Severities.at( ERCE_PIN_TO_PIN_WARNING ) == RPT_SEVERITY_IGNORE ) |
|||
return RPT_SEVERITY_IGNORE; |
|||
else |
|||
return RPT_SEVERITY_ERROR; |
|||
} |
|||
else if( aErrorCode == ERCE_PIN_TO_PIN_WARNING ) |
|||
{ |
|||
wxASSERT( m_Severities.count( ERCE_PIN_TO_PIN_WARNING ) ); |
|||
|
|||
if( m_Severities.at( ERCE_PIN_TO_PIN_WARNING ) == RPT_SEVERITY_IGNORE ) |
|||
return RPT_SEVERITY_IGNORE; |
|||
else |
|||
return RPT_SEVERITY_WARNING; |
|||
} |
|||
|
|||
return m_Severities.at( aErrorCode ); |
|||
} |
|||
|
|||
|
|||
void ERC_SETTINGS::SetSeverity( int aErrorCode, int aSeverity ) |
|||
{ |
|||
m_Severities[ aErrorCode ] = aSeverity; |
|||
} |
|||
|
|||
|
|||
void SHEETLIST_ERC_ITEMS_PROVIDER::SetSeverities( int aSeverities ) |
|||
{ |
|||
m_severities = aSeverities; |
|||
|
|||
m_filteredMarkers.clear(); |
|||
|
|||
SCH_SHEET_LIST sheetList = m_schematic->GetSheets(); |
|||
ERC_SETTINGS& settings = m_schematic->ErcSettings(); |
|||
|
|||
for( unsigned i = 0; i < sheetList.size(); i++ ) |
|||
{ |
|||
for( SCH_ITEM* aItem : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) ) |
|||
{ |
|||
SCH_MARKER* marker = static_cast<SCH_MARKER*>( aItem ); |
|||
int markerSeverity; |
|||
|
|||
if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC ) |
|||
continue; |
|||
|
|||
if( marker->IsExcluded() ) |
|||
markerSeverity = RPT_SEVERITY_EXCLUSION; |
|||
else |
|||
markerSeverity = settings.GetSeverity( marker->GetRCItem()->GetErrorCode() ); |
|||
|
|||
if( markerSeverity & m_severities ) |
|||
m_filteredMarkers.push_back( marker ); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
int SHEETLIST_ERC_ITEMS_PROVIDER::GetCount( int aSeverity ) |
|||
{ |
|||
if( aSeverity < 0 ) |
|||
return m_filteredMarkers.size(); |
|||
|
|||
int count = 0; |
|||
|
|||
SCH_SHEET_LIST sheetList = m_schematic->GetSheets(); |
|||
ERC_SETTINGS& settings = m_schematic->ErcSettings(); |
|||
|
|||
for( unsigned i = 0; i < sheetList.size(); i++ ) |
|||
{ |
|||
for( SCH_ITEM* aItem : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) ) |
|||
{ |
|||
SCH_MARKER* marker = static_cast<SCH_MARKER*>( aItem ); |
|||
int markerSeverity; |
|||
|
|||
if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC ) |
|||
continue; |
|||
|
|||
if( marker->IsExcluded() ) |
|||
markerSeverity = RPT_SEVERITY_EXCLUSION; |
|||
else |
|||
markerSeverity = settings.GetSeverity( marker->GetRCItem()->GetErrorCode() ); |
|||
|
|||
if( markerSeverity == aSeverity ) |
|||
count++; |
|||
} |
|||
} |
|||
|
|||
return count; |
|||
} |
|||
|
|||
|
|||
ERC_ITEM* SHEETLIST_ERC_ITEMS_PROVIDER::GetItem( int aIndex ) |
|||
{ |
|||
SCH_MARKER* marker = m_filteredMarkers[ aIndex ]; |
|||
|
|||
return marker ? static_cast<ERC_ITEM*>( marker->GetRCItem() ) : nullptr; |
|||
} |
|||
|
|||
|
|||
void SHEETLIST_ERC_ITEMS_PROVIDER::DeleteItem( int aIndex, bool aDeep ) |
|||
{ |
|||
SCH_MARKER* marker = m_filteredMarkers[ aIndex ]; |
|||
m_filteredMarkers.erase( m_filteredMarkers.begin() + aIndex ); |
|||
|
|||
if( aDeep ) |
|||
{ |
|||
SCH_SCREENS screens( m_schematic->Root() ); |
|||
screens.DeleteMarker( marker ); |
|||
} |
|||
} |
|||
|
|||
|
|||
void SHEETLIST_ERC_ITEMS_PROVIDER::DeleteAllItems() |
|||
{ |
|||
SCH_SCREENS screens( m_schematic->Root() ); |
|||
screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC ); |
|||
m_filteredMarkers.clear(); |
|||
} |
|||
@ -0,0 +1,152 @@ |
|||
/*
|
|||
* 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 <base_screen.h>
|
|||
#include <class_libentry.h>
|
|||
#include <convert_to_biu.h>
|
|||
#include <default_values.h>
|
|||
#include <eda_text.h>
|
|||
#include <eeschema_settings.h>
|
|||
#include <kiface_i.h>
|
|||
#include <schematic_settings.h>
|
|||
#include <settings/parameters.h>
|
|||
|
|||
|
|||
const int schSettingsSchemaVersion = 0; |
|||
|
|||
|
|||
SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) : |
|||
NESTED_SETTINGS( "schematic", schSettingsSchemaVersion, aParent, aPath ), |
|||
m_DefaultLineWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ), |
|||
m_DefaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ), |
|||
m_DefaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ), |
|||
m_DefaultTextSize( DEFAULT_TEXT_SIZE * IU_PER_MILS ), |
|||
m_TextOffsetRatio( 0.08 ), |
|||
m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ), |
|||
m_JunctionSize( DEFAULT_JUNCTION_DIAM * IU_PER_MILS ), |
|||
m_TemplateFieldNames( nullptr ) |
|||
{ |
|||
EESCHEMA_SETTINGS* appSettings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); |
|||
|
|||
int defaultLineThickness = |
|||
appSettings ? appSettings->m_Drawing.default_line_thickness : DEFAULT_LINE_THICKNESS; |
|||
int defaultWireThickness = |
|||
appSettings ? appSettings->m_Drawing.default_wire_thickness : DEFAULT_WIRE_THICKNESS; |
|||
int defaultBusThickness = |
|||
appSettings ? appSettings->m_Drawing.default_bus_thickness : DEFAULT_BUS_THICKNESS; |
|||
int defaultTextSize = |
|||
appSettings ? appSettings->m_Drawing.default_text_size : DEFAULT_TEXT_SIZE; |
|||
int defaultPinSymbolSize = |
|||
appSettings ? appSettings->m_Drawing.pin_symbol_size : DEFAULT_TEXT_SIZE / 2; |
|||
|
|||
m_params.emplace_back( new PARAM_SCALED<int>( "drawing.default_line_thickness", |
|||
&m_DefaultLineWidth, Mils2iu( defaultLineThickness ), |
|||
Mils2iu( 5 ), Mils2iu( 1000 ), 1 / IU_PER_MILS ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_SCALED<int>( "drawing.default_wire_thickness", |
|||
&m_DefaultWireThickness, Mils2iu( defaultWireThickness ), |
|||
Mils2iu( 5 ), Mils2iu( 1000 ), 1 / IU_PER_MILS ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_SCALED<int>( "drawing.default_bus_thickness", |
|||
&m_DefaultBusThickness, Mils2iu( defaultBusThickness ), |
|||
Mils2iu( 5 ), Mils2iu( 1000 ), 1 / IU_PER_MILS ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_SCALED<int>( "drawing.default_text_size", &m_DefaultTextSize, |
|||
Mils2iu( defaultTextSize ), Mils2iu( 5 ), Mils2iu( 1000 ), |
|||
1 / IU_PER_MILS ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<double>( "drawing.text_offset_ratio", &m_TextOffsetRatio, |
|||
(double) TXT_MARGIN / DEFAULT_SIZE_TEXT, -200.0, 200.0 ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_SCALED<int>( "drawing.pin_symbol_size", &m_PinSymbolSize, |
|||
Mils2iu( defaultPinSymbolSize ), Mils2iu( 5 ), Mils2iu( 1000 ), |
|||
1 / IU_PER_MILS ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_SCALED<int>( "drawing.default_junction_size", &m_JunctionSize, |
|||
Mils2iu( DEFAULT_BUS_THICKNESS ), Mils2iu( 5 ), Mils2iu( 1000 ), 1 / IU_PER_MILS ) ); |
|||
|
|||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "drawing.field_names", |
|||
[&]() -> nlohmann::json |
|||
{ |
|||
nlohmann::json ret = nlohmann::json::array(); |
|||
|
|||
if( !m_TemplateFieldNames ) |
|||
return ret; |
|||
|
|||
for( const TEMPLATE_FIELDNAME& field : |
|||
m_TemplateFieldNames->GetTemplateFieldNames( false ) ) |
|||
{ |
|||
ret.push_back( nlohmann::json( { |
|||
{ "name", field.m_Name }, |
|||
{ "visible", field.m_Visible }, |
|||
{ "url", field.m_URL } |
|||
} ) ); |
|||
} |
|||
|
|||
return ret; |
|||
}, |
|||
[&]( const nlohmann::json& aJson ) |
|||
{ |
|||
if( !m_TemplateFieldNames || aJson.empty() || !aJson.is_array() ) |
|||
return; |
|||
|
|||
m_TemplateFieldNames->DeleteAllFieldNameTemplates( false ); |
|||
|
|||
for( const nlohmann::json& entry : aJson ) |
|||
{ |
|||
if( !entry.contains( "name" ) || !entry.contains( "url" ) |
|||
|| !entry.contains( "visible" ) ) |
|||
continue; |
|||
|
|||
TEMPLATE_FIELDNAME field( entry["name"].get<wxString>() ); |
|||
field.m_URL = entry["url"].get<bool>(); |
|||
field.m_Visible = entry["visible"].get<bool>(); |
|||
m_TemplateFieldNames->AddTemplateFieldName( field, false ); |
|||
} |
|||
}, {} ) ); |
|||
|
|||
// TOOD(JE) get rid of this static
|
|||
m_params.emplace_back( new PARAM<wxString>( |
|||
"page_layout_descr_file", &BASE_SCREEN::m_PageLayoutDescrFileName, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "plot_directory", &m_PlotDirectoryName, "" ) ); |
|||
|
|||
m_params.emplace_back( new PARAM<wxString>( "net_format_name", &m_NetFormatName, "" ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<bool>( "spice_adjust_passive_values", &m_SpiceAdjustPassiveValues, false ) ); |
|||
|
|||
// TODO(JE) should we keep these LIB_PART:: things around?
|
|||
m_params.emplace_back( new PARAM<int>( |
|||
"subpart_id_separator", LIB_PART::SubpartIdSeparatorPtr(), 0, 0, 126 ) ); |
|||
|
|||
m_params.emplace_back( |
|||
new PARAM<int>( "subpart_first_id", LIB_PART::SubpartFirstIdPtr(), 'A', '1', 'z' ) ); |
|||
} |
|||
|
|||
|
|||
SCHEMATIC_SETTINGS::~SCHEMATIC_SETTINGS() |
|||
{ |
|||
if( m_parent ) |
|||
{ |
|||
m_parent->ReleaseNestedSettings( this ); |
|||
m_parent = nullptr; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue