mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 11:21:41 +00:00
Port Eeschema to new project settings
DRC/ERC error serialization changed to use explicit tokens Old stored severities and ignored errors are discarded
This commit is contained in:
parent
c0aa6965de
commit
12b4a55ae8
common
eeschema
CMakeLists.txtclass_library.cppconnection_graph.cpp
dialogs
dialog_erc.cppdialog_sch_import_settings.cppdialog_schematic_setup.cppdialog_schematic_setup.hdialog_symbol_remap.cpppanel_setup_formatting.cpppanel_setup_formatting.h
eeschema_config.cpperc.cpperc_item.cpperc_item.herc_settings.cpperc_settings.hfiles-io.cppsch_base_frame.cppsch_eagle_plugin.cppsch_edit_frame.cppsch_edit_frame.hsch_marker.cppschematic.cppschematic.hschematic_settings.cppschematic_settings.hinclude
kicad
pcbnew
board_design_settings.cppclass_marker_pcb.cppcleanup_item.h
dialogs
drc
drc.cppdrc.hdrc_clearance_test_functions.cppdrc_courtyard_tester.cppdrc_drilled_hole_tester.cppdrc_item.cppdrc_item.hdrc_keepout_tester.cppdrc_netclass_tester.cppdrc_textvar_tester.cppfootprint_tester.cpp
pcbnew_config.cppqa/eeschema
@ -27,14 +27,13 @@
|
||||
#include "panel_setup_severities.h"
|
||||
|
||||
|
||||
PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, RC_ITEM& aDummyItem,
|
||||
PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent,
|
||||
std::vector<std::reference_wrapper<RC_ITEM>> aItems,
|
||||
std::map<int, int>& aSeverities,
|
||||
int aFirstErrorCode, int aLastErrorCode,
|
||||
int aPinMapSpecialCase ) :
|
||||
RC_ITEM* aPinMapSpecialCase ) :
|
||||
wxPanel( aParent->GetTreebook() ),
|
||||
m_severities( aSeverities ),
|
||||
m_firstErrorCode( aFirstErrorCode ),
|
||||
m_lastErrorCode( aLastErrorCode ),
|
||||
m_items( aItems ),
|
||||
m_pinMapSpecialCase( aPinMapSpecialCase )
|
||||
{
|
||||
wxString severities[] = { _( "Error" ), _( "Warning" ), _( "Ignore" ) };
|
||||
@ -50,9 +49,10 @@ PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, RC_ITEM&
|
||||
wxFlexGridSizer* gridSizer = new wxFlexGridSizer( 0, 2, 0, 5 );
|
||||
gridSizer->SetFlexibleDirection( wxBOTH );
|
||||
|
||||
for( int errorCode = m_firstErrorCode; errorCode <= m_lastErrorCode; ++errorCode )
|
||||
for( const RC_ITEM& item : m_items )
|
||||
{
|
||||
wxString msg = aDummyItem.GetErrorText( errorCode );
|
||||
int errorCode = item.GetErrorCode();
|
||||
wxString msg = item.GetErrorText();
|
||||
|
||||
// When msg is empty, for some reason, the current errorCode is not supported
|
||||
// by the RC_ITEM aDummyItem.
|
||||
@ -84,11 +84,11 @@ PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, RC_ITEM&
|
||||
}
|
||||
}
|
||||
|
||||
if( m_pinMapSpecialCase >= 0 )
|
||||
if( m_pinMapSpecialCase )
|
||||
{
|
||||
wxString pinMapSeverities[] = { _( "From Pin Conflicts Map" ), wxT( "" ), _( "Ignore" ) };
|
||||
int errorCode = m_pinMapSpecialCase;
|
||||
wxString msg = aDummyItem.GetErrorText( errorCode );
|
||||
int errorCode = m_pinMapSpecialCase->GetErrorCode();
|
||||
wxString msg = m_pinMapSpecialCase->GetErrorText();
|
||||
|
||||
wxStaticText* errorLabel = new wxStaticText( scrollWin, wxID_ANY, msg + wxT( ":" ) );
|
||||
gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 4 );
|
||||
@ -133,8 +133,10 @@ PANEL_SETUP_SEVERITIES::PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, RC_ITEM&
|
||||
|
||||
void PANEL_SETUP_SEVERITIES::ImportSettingsFrom( std::map<int, int>& aSettings )
|
||||
{
|
||||
for( int errorCode = m_firstErrorCode; errorCode <= m_lastErrorCode; ++errorCode )
|
||||
for( const RC_ITEM& item : m_items )
|
||||
{
|
||||
int errorCode = item.GetErrorCode();
|
||||
|
||||
if(! m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
|
||||
continue;
|
||||
|
||||
@ -147,20 +149,23 @@ void PANEL_SETUP_SEVERITIES::ImportSettingsFrom( std::map<int, int>& aSettings )
|
||||
}
|
||||
}
|
||||
|
||||
if( m_pinMapSpecialCase >= 0 )
|
||||
if( m_pinMapSpecialCase )
|
||||
{
|
||||
int newSeverity = aSettings[ m_pinMapSpecialCase ];
|
||||
int pinMapCode = m_pinMapSpecialCase->GetErrorCode();
|
||||
int newSeverity = aSettings[ pinMapCode ];
|
||||
|
||||
m_buttonMap[ m_pinMapSpecialCase ][0]->SetValue( newSeverity != RPT_SEVERITY_IGNORE );
|
||||
m_buttonMap[ m_pinMapSpecialCase ][1]->SetValue( newSeverity == RPT_SEVERITY_IGNORE );
|
||||
m_buttonMap[ pinMapCode ][0]->SetValue( newSeverity != RPT_SEVERITY_IGNORE );
|
||||
m_buttonMap[ pinMapCode ][1]->SetValue( newSeverity == RPT_SEVERITY_IGNORE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool PANEL_SETUP_SEVERITIES::TransferDataToWindow()
|
||||
{
|
||||
for( int errorCode = m_firstErrorCode; errorCode <= m_lastErrorCode; ++errorCode )
|
||||
for( const RC_ITEM& item : m_items )
|
||||
{
|
||||
int errorCode = item.GetErrorCode();
|
||||
|
||||
if( !m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
|
||||
continue;
|
||||
|
||||
@ -173,12 +178,13 @@ bool PANEL_SETUP_SEVERITIES::TransferDataToWindow()
|
||||
}
|
||||
}
|
||||
|
||||
if( m_pinMapSpecialCase >= 0 )
|
||||
if( m_pinMapSpecialCase )
|
||||
{
|
||||
int severity = m_severities[ m_pinMapSpecialCase ];
|
||||
int pinMapCode = m_pinMapSpecialCase->GetErrorCode();
|
||||
int severity = m_severities[pinMapCode];
|
||||
|
||||
m_buttonMap[ m_pinMapSpecialCase ][0]->SetValue( severity != RPT_SEVERITY_IGNORE );
|
||||
m_buttonMap[ m_pinMapSpecialCase ][2]->SetValue( severity == RPT_SEVERITY_IGNORE );
|
||||
m_buttonMap[ pinMapCode ][0]->SetValue( severity != RPT_SEVERITY_IGNORE );
|
||||
m_buttonMap[ pinMapCode ][2]->SetValue( severity == RPT_SEVERITY_IGNORE );
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -187,8 +193,10 @@ bool PANEL_SETUP_SEVERITIES::TransferDataToWindow()
|
||||
|
||||
bool PANEL_SETUP_SEVERITIES::TransferDataFromWindow()
|
||||
{
|
||||
for( int errorCode = m_firstErrorCode; errorCode <= m_lastErrorCode; ++errorCode )
|
||||
for( const RC_ITEM& item : m_items )
|
||||
{
|
||||
int errorCode = item.GetErrorCode();
|
||||
|
||||
if( !m_buttonMap[ errorCode ][0] ) // this entry does not actually exist
|
||||
continue;
|
||||
|
||||
@ -204,16 +212,17 @@ bool PANEL_SETUP_SEVERITIES::TransferDataFromWindow()
|
||||
m_severities[ errorCode ] = severity;
|
||||
}
|
||||
|
||||
if( m_pinMapSpecialCase >= 0 )
|
||||
if( m_pinMapSpecialCase )
|
||||
{
|
||||
int severity = RPT_SEVERITY_UNDEFINED;
|
||||
int pinMapCode = m_pinMapSpecialCase->GetErrorCode();
|
||||
int severity = RPT_SEVERITY_UNDEFINED;
|
||||
|
||||
if( m_buttonMap[ m_pinMapSpecialCase ][0]->GetValue() )
|
||||
if( m_buttonMap[ pinMapCode ][0]->GetValue() )
|
||||
severity = RPT_SEVERITY_ERROR;
|
||||
else if( m_buttonMap[ m_pinMapSpecialCase ][2]->GetValue() )
|
||||
else if( m_buttonMap[ pinMapCode ][2]->GetValue() )
|
||||
severity = RPT_SEVERITY_IGNORE;
|
||||
|
||||
m_severities[ m_pinMapSpecialCase ] = severity;
|
||||
m_severities[ pinMapCode ] = severity;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -38,16 +38,27 @@ class PANEL_SETUP_SEVERITIES : public wxPanel
|
||||
{
|
||||
private:
|
||||
std::map<int, int>& m_severities;
|
||||
int m_firstErrorCode;
|
||||
int m_lastErrorCode;
|
||||
int m_pinMapSpecialCase;
|
||||
|
||||
/// A list of item templates (to get descriptive text and error codes from)
|
||||
std::vector<std::reference_wrapper<RC_ITEM>> m_items;
|
||||
|
||||
/// For ERC settings; a pointer to ERC_ITEM::pinTableConflict
|
||||
RC_ITEM* m_pinMapSpecialCase;
|
||||
|
||||
std::map<int, wxRadioButton*[4]> m_buttonMap; // map from DRC error code to button group
|
||||
|
||||
public:
|
||||
PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent, RC_ITEM& aDummyItem,
|
||||
std::map<int, int>& aSeverities, int aFirstError, int aLastError,
|
||||
int aPinMapSpecialCase = -1 );
|
||||
/**
|
||||
* Creates the severities setup panel
|
||||
* @param aParent is the dialog parent
|
||||
* @param aItems is a list of error types that can have a severity. Must have one or more!
|
||||
* @param aSeverities is a map of error code to severity
|
||||
* @param aPinMapSpecialCase is used to special-case the ERCE_PIN_TO_PIN_WARNING
|
||||
*/
|
||||
PANEL_SETUP_SEVERITIES( PAGED_DIALOG* aParent,
|
||||
std::vector<std::reference_wrapper<RC_ITEM>> aItems,
|
||||
std::map<int, int>& aSeverities,
|
||||
RC_ITEM* aPinMapSpecialCase = nullptr );
|
||||
|
||||
void ImportSettingsFrom( std::map<int, int>& aSettings );
|
||||
|
||||
|
@ -65,9 +65,9 @@ PROJECT::~PROJECT()
|
||||
|
||||
bool PROJECT::TextVarResolver( wxString* aToken ) const
|
||||
{
|
||||
if( m_textVars.count( *aToken ) > 0 )
|
||||
if( GetTextVars().count( *aToken ) > 0 )
|
||||
{
|
||||
*aToken = m_textVars.at( *aToken );
|
||||
*aToken = GetTextVars().at( *aToken );
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -75,6 +75,12 @@ bool PROJECT::TextVarResolver( wxString* aToken ) const
|
||||
}
|
||||
|
||||
|
||||
std::map<wxString, wxString>& PROJECT::GetTextVars() const
|
||||
{
|
||||
return GetProjectFile().m_TextVars;
|
||||
}
|
||||
|
||||
|
||||
void PROJECT::setProjectFullName( const wxString& aFullPathAndName )
|
||||
{
|
||||
// Compare paths, rather than inodes, to be less surprising to the user.
|
||||
@ -357,91 +363,6 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList,
|
||||
}
|
||||
|
||||
|
||||
void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aGroupName,
|
||||
const std::vector<PARAM_CFG*>& aParams, const wxString& aFileName )
|
||||
{
|
||||
std::unique_ptr<wxConfigBase> cfg( configCreate( aSList, aGroupName, aFileName ) );
|
||||
|
||||
if( !cfg.get() )
|
||||
{
|
||||
// could not find template
|
||||
return;
|
||||
}
|
||||
|
||||
cfg->SetPath( wxT( "/" ) );
|
||||
|
||||
cfg->Write( wxT( "update" ), DateAndTime() );
|
||||
|
||||
// @todo: pass in aLastClient wxString:
|
||||
cfg->Write( wxT( "last_client" ), Pgm().App().GetAppName() );
|
||||
|
||||
// Save parameters
|
||||
cfg->DeleteGroup( aGroupName ); // Erase all data
|
||||
cfg->Flush();
|
||||
|
||||
cfg->SetPath( aGroupName );
|
||||
cfg->Write( wxT( "version" ), CONFIG_VERSION );
|
||||
|
||||
cfg->SetPath( wxT( "/" ) );
|
||||
|
||||
wxConfigSaveParams( cfg.get(), aParams, aGroupName );
|
||||
|
||||
cfg->DeleteGroup( GROUP_TEXT_VARS );
|
||||
cfg->SetPath( GROUP_TEXT_VARS );
|
||||
int index = 1;
|
||||
|
||||
for( const auto& textvar : m_textVars )
|
||||
{
|
||||
cfg->Write( wxString::Format( "%d", index++ ),
|
||||
wxString::Format( "%s:%s", textvar.first, textvar.second ) );
|
||||
}
|
||||
|
||||
cfg->SetPath( wxT( "/" ) );
|
||||
|
||||
cfg->Flush();
|
||||
}
|
||||
|
||||
|
||||
bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aGroupName,
|
||||
const std::vector<PARAM_CFG*>& aParams,
|
||||
const wxString& aForeignProjectFileName )
|
||||
{
|
||||
std::unique_ptr<wxConfigBase> cfg( configCreate( aSList, aGroupName,
|
||||
aForeignProjectFileName ) );
|
||||
|
||||
if( !cfg.get() )
|
||||
{
|
||||
// could not find template
|
||||
return false;
|
||||
}
|
||||
|
||||
// We do not want expansion of env var values when reading our project config file
|
||||
cfg->SetExpandEnvVars( false );
|
||||
|
||||
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
|
||||
|
||||
wxString timestamp = cfg->Read( wxT( "update" ) );
|
||||
|
||||
m_pro_date_and_time = timestamp;
|
||||
|
||||
wxConfigLoadParams( cfg.get(), aParams, aGroupName );
|
||||
|
||||
cfg->SetPath( GROUP_TEXT_VARS );
|
||||
|
||||
int index = 1;
|
||||
wxString entry;
|
||||
|
||||
while( cfg->Read( wxString::Format( "%d", index++ ), &entry ) )
|
||||
{
|
||||
wxArrayString tokens = wxSplit( entry, ':' );
|
||||
|
||||
if( tokens.size() == 2 )
|
||||
m_textVars[ tokens[0] ] = tokens[1];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const wxString PROJECT::AbsolutePath( const wxString& aFileName ) const
|
||||
{
|
||||
wxFileName fn = aFileName;
|
||||
|
@ -36,7 +36,13 @@ 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()
|
||||
m_sheets(),
|
||||
m_boards(),
|
||||
m_project( nullptr ),
|
||||
m_ErcSettings( nullptr ),
|
||||
m_SchematicSettings( nullptr ),
|
||||
m_TemplateFieldNames( nullptr ),
|
||||
m_BoardSettings()
|
||||
{
|
||||
// Keep old files around
|
||||
m_deleteLegacyAfterMigration = false;
|
||||
@ -45,6 +51,8 @@ PROJECT_FILE::PROJECT_FILE( const std::string& aFullPath ) :
|
||||
|
||||
m_params.emplace_back( new PARAM_LIST<FILE_INFO_PAIR>( "boards", &m_boards, {} ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_WXSTRING_MAP( "text_variables", &m_TextVars, {} ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_LIST<wxString>( "libraries.pinned_symbol_libs", &m_PinnedSymbolLibs, {} ) );
|
||||
|
||||
@ -55,7 +63,7 @@ PROJECT_FILE::PROJECT_FILE( const std::string& aFullPath ) :
|
||||
new PARAM_PATH_LIST( "cvpcb.equivalence_files", &m_EquivalenceFiles, {} ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_PATH( "pcbnew.page_layout_descr_file", &m_PageLayoutDescrFile, "" ) );
|
||||
new PARAM_PATH( "pcbnew.page_layout_descr_file", &m_BoardPageLayoutDescrFile, "" ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_PATH( "pcbnew.last_paths.netlist", &m_PcbLastPath[LAST_PATH_NETLIST], "" ) );
|
||||
@ -75,6 +83,29 @@ PROJECT_FILE::PROJECT_FILE( const std::string& aFullPath ) :
|
||||
m_params.emplace_back(
|
||||
new PARAM_PATH( "pcbnew.last_paths.gencad", &m_PcbLastPath[LAST_PATH_GENCAD], "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<wxString>( "schematic.legacy_lib_dir", &m_LegacyLibDir, "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "schematic.legacy_lib_list",
|
||||
[&]() -> nlohmann::json
|
||||
{
|
||||
nlohmann::json ret = nlohmann::json::array();
|
||||
|
||||
for( const wxString& libName : m_LegacyLibNames )
|
||||
ret.push_back( libName );
|
||||
|
||||
return ret;
|
||||
},
|
||||
[&]( const nlohmann::json& aJson )
|
||||
{
|
||||
if( aJson.empty() || !aJson.is_array() )
|
||||
return;
|
||||
|
||||
m_LegacyLibNames.clear();
|
||||
|
||||
for( const nlohmann::json& entry : aJson )
|
||||
m_LegacyLibNames.push_back( entry.get<wxString>() );
|
||||
}, {} ) );
|
||||
|
||||
m_NetSettings = std::make_shared<NET_SETTINGS>( this, "net_settings" );
|
||||
}
|
||||
|
||||
@ -143,6 +174,78 @@ bool PROJECT_FILE::MigrateFromLegacy( wxConfigBase* aCfg )
|
||||
// All CvPcb params that we want to keep have been migrated above
|
||||
group_blacklist.insert( wxT( "/cvpcb" ) );
|
||||
|
||||
aCfg->SetPath( wxT( "/eeschema" ) );
|
||||
fromLegacyString( aCfg, "LibDir", "schematic.legacy_lib_dir" );
|
||||
|
||||
aCfg->SetPath( wxT( "/eeschema/libraries" ) );
|
||||
|
||||
{
|
||||
int libIdx = 1;
|
||||
wxString libKey = wxT( "LibName" );
|
||||
libKey << libIdx;
|
||||
|
||||
nlohmann::json libs = nlohmann::json::array();
|
||||
|
||||
while( aCfg->Read( libKey, &str ) )
|
||||
{
|
||||
libs.push_back( str );
|
||||
|
||||
libKey = wxT( "LibName" );
|
||||
libKey << ++libIdx;
|
||||
}
|
||||
|
||||
( *this )[PointerFromString( "schematic.legacy_lib_list" )] = libs;
|
||||
}
|
||||
|
||||
group_blacklist.insert( wxT( "/eeschema" ) );
|
||||
|
||||
aCfg->SetPath( wxT( "/text_variables" ) );
|
||||
|
||||
{
|
||||
int txtIdx = 1;
|
||||
wxString txtKey;
|
||||
txtKey << txtIdx;
|
||||
|
||||
nlohmann::json vars = nlohmann::json();
|
||||
|
||||
while( aCfg->Read( txtKey, &str ) )
|
||||
{
|
||||
wxArrayString tokens = wxSplit( str, ':' );
|
||||
|
||||
if( tokens.size() == 2 )
|
||||
vars[ tokens[0].ToStdString() ] = tokens[1];
|
||||
|
||||
txtKey.clear();
|
||||
txtKey << ++txtIdx;
|
||||
}
|
||||
|
||||
( *this )[PointerFromString( "text_variables" )] = vars;
|
||||
}
|
||||
|
||||
group_blacklist.insert( wxT( "/text_variables" ) );
|
||||
|
||||
aCfg->SetPath( wxT( "/schematic_editor" ) );
|
||||
|
||||
fromLegacyString( aCfg, "PageLayoutDescrFile", "schematic.page_layout_descr_file" );
|
||||
fromLegacyString( aCfg, "PlotDirectoryName", "schematic.plot_directory" );
|
||||
fromLegacyString( aCfg, "NetFmtName", "schematic.net_format_name" );
|
||||
fromLegacy<bool>( aCfg, "SpiceAjustPassiveValues", "schematic.spice_adjust_passive_values" );
|
||||
fromLegacy<int>( aCfg, "SubpartIdSeparator", "schematic.subpart_id_separator" );
|
||||
fromLegacy<int>( aCfg, "SubpartFirstId", "schematic.subpart_first_id" );
|
||||
|
||||
fromLegacy<int>( aCfg, "LineThickness", "schematic.drawing.default_line_thickness" );
|
||||
fromLegacy<int>( aCfg, "WireThickness", "schematic.drawing.default_wire_thickness" );
|
||||
fromLegacy<int>( aCfg, "BusThickness", "schematic.drawing.default_bus_thickness" );
|
||||
fromLegacy<int>( aCfg, "LabSize", "schematic.drawing.default_text_size" );
|
||||
fromLegacy<int>( aCfg, "PinSymbolSize", "schematic.drawing.pin_symbol_size" );
|
||||
fromLegacy<int>( aCfg, "JunctionSize", "schematic.drawing.default_junction_size" );
|
||||
|
||||
fromLegacyString( aCfg, "FieldNameTemplates", "schematic.drawing.field_names" );
|
||||
fromLegacy<double>( aCfg, "TextOffsetRatio", "schematic.drawing.text_offset_ratio" );
|
||||
|
||||
// All schematic_editor keys we keep are migrated above
|
||||
group_blacklist.insert( wxT( "/schematic_editor" ) );
|
||||
|
||||
aCfg->SetPath( wxT( "/pcbnew" ) );
|
||||
|
||||
fromLegacyString( aCfg, "PageLayoutDescrFile", "pcbnew.page_layout_descr_file" );
|
||||
@ -252,7 +355,7 @@ bool PROJECT_FILE::MigrateFromLegacy( wxConfigBase* aCfg )
|
||||
fromLegacy<bool>(
|
||||
aCfg, "RequireCourtyardDefinitions", sev + "legacy_no_courtyard_defined" );
|
||||
|
||||
fromLegacy<bool>( aCfg, "ProhibitOverlappingCourtyards", sev + "legacy_ourtyards_overlap" );
|
||||
fromLegacy<bool>( aCfg, "ProhibitOverlappingCourtyards", sev + "legacy_courtyards_overlap" );
|
||||
|
||||
{
|
||||
int idx = 1;
|
||||
@ -330,10 +433,7 @@ bool PROJECT_FILE::MigrateFromLegacy( wxConfigBase* aCfg )
|
||||
( *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!
|
||||
group_blacklist.insert( wxT( "/pcbnew" ) );
|
||||
|
||||
// General group is unused these days, we can throw it away
|
||||
group_blacklist.insert( wxT( "/general" ) );
|
||||
|
@ -36,7 +36,7 @@
|
||||
wxString RC_ITEM::GetErrorMessage() const
|
||||
{
|
||||
if( m_errorMessage.IsEmpty() )
|
||||
return GetErrorText( m_errorCode );
|
||||
return GetErrorText();
|
||||
else
|
||||
return m_errorMessage;
|
||||
}
|
||||
|
@ -78,7 +78,9 @@ class RC_ITEM
|
||||
{
|
||||
protected:
|
||||
int m_errorCode; // the error code's numeric value
|
||||
wxString m_errorMessage;
|
||||
wxString m_errorMessage; ///< A message describing the details of this specific error
|
||||
wxString m_errorTitle; ///< The string describing the type of error
|
||||
wxString m_settingsKey; ///< The key used to describe this type of error in settings
|
||||
MARKER_BASE* m_parent; // The marker this item belongs to, if any
|
||||
KIID m_mainItemUuid;
|
||||
KIID m_auxItemUuid;
|
||||
@ -99,11 +101,13 @@ public:
|
||||
|
||||
RC_ITEM( RC_ITEM* aItem )
|
||||
{
|
||||
m_errorCode = aItem->m_errorCode;
|
||||
m_errorCode = aItem->m_errorCode;
|
||||
m_errorMessage = aItem->m_errorMessage;
|
||||
m_parent = aItem->m_parent;
|
||||
m_errorTitle = aItem->m_errorTitle;
|
||||
m_settingsKey = aItem->m_settingsKey;
|
||||
m_parent = aItem->m_parent;
|
||||
m_mainItemUuid = aItem->m_mainItemUuid;
|
||||
m_auxItemUuid = aItem->m_auxItemUuid;
|
||||
m_auxItemUuid = aItem->m_auxItemUuid;
|
||||
m_auxItem2Uuid = aItem->m_auxItem2Uuid;
|
||||
m_auxItem3Uuid = aItem->m_auxItem3Uuid;
|
||||
}
|
||||
@ -156,18 +160,22 @@ public:
|
||||
int GetErrorCode() const { return m_errorCode; }
|
||||
void SetErrorCode( int aCode ) { m_errorCode = aCode; }
|
||||
|
||||
/**
|
||||
* Function GetErrorText
|
||||
* returns the string form of a RC error code
|
||||
*/
|
||||
virtual wxString GetErrorText( int aCode = -1, bool aTranslate = true ) const = 0;
|
||||
|
||||
/**
|
||||
* Function GetErrorMessage
|
||||
* returns the error message of a RC_ITEM
|
||||
*/
|
||||
virtual wxString GetErrorMessage() const;
|
||||
|
||||
wxString GetErrorText() const
|
||||
{
|
||||
return wxGetTranslation( m_errorTitle );
|
||||
}
|
||||
|
||||
wxString GetSettingsKey() const
|
||||
{
|
||||
return m_settingsKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ShowCoord
|
||||
* formats a coordinate or position to text.
|
||||
|
@ -113,8 +113,10 @@ void NESTED_SETTINGS::SetParent( JSON_SETTINGS* aParent )
|
||||
m_parent = aParent;
|
||||
|
||||
if( m_parent )
|
||||
{
|
||||
m_parent->AddNestedSettings( this );
|
||||
|
||||
// In case we were created after the parent's ctor
|
||||
LoadFromFile();
|
||||
// In case we were created after the parent's ctor
|
||||
LoadFromFile();
|
||||
}
|
||||
}
|
||||
|
@ -105,3 +105,23 @@ wxBitmap MakeBadge( SEVERITY aStyle, int aCount, wxWindow* aWindow, int aDepth )
|
||||
}
|
||||
|
||||
|
||||
SEVERITY SeverityFromString( const wxString& aSeverity )
|
||||
{
|
||||
if( aSeverity == wxT( "warning" ) )
|
||||
return RPT_SEVERITY_WARNING;
|
||||
else if( aSeverity == wxT( "ignore" ) )
|
||||
return RPT_SEVERITY_IGNORE;
|
||||
else
|
||||
return RPT_SEVERITY_ERROR;
|
||||
}
|
||||
|
||||
|
||||
wxString SeverityToString( const SEVERITY& aSeverity )
|
||||
{
|
||||
if( aSeverity == RPT_SEVERITY_IGNORE )
|
||||
return wxT( "ignore" );
|
||||
else if( aSeverity == RPT_SEVERITY_WARNING )
|
||||
return wxT( "warning" );
|
||||
else
|
||||
return wxT( "error" );
|
||||
}
|
||||
|
@ -159,6 +159,7 @@ set( EESCHEMA_SRCS
|
||||
eeschema_settings.cpp
|
||||
erc.cpp
|
||||
erc_item.cpp
|
||||
erc_settings.cpp
|
||||
fields_grid_table.cpp
|
||||
files-io.cpp
|
||||
generate_alias_info.cpp
|
||||
@ -216,6 +217,7 @@ set( EESCHEMA_SRCS
|
||||
sch_text.cpp
|
||||
sch_validators.cpp
|
||||
schematic.cpp
|
||||
schematic_settings.cpp
|
||||
schematic_undo_redo.cpp
|
||||
sch_edit_frame.cpp
|
||||
sheet.cpp
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <richio.h>
|
||||
#include <config_params.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <project/project_file.h>
|
||||
#include <project_rescue.h>
|
||||
#include <properties.h>
|
||||
|
||||
@ -439,47 +440,25 @@ int PART_LIBS::GetModifyHash()
|
||||
void PART_LIBS::LibNamesAndPaths( PROJECT* aProject, bool doSave,
|
||||
wxString* aPaths, wxArrayString* aNames )
|
||||
{
|
||||
wxString pro = aProject->GetProjectFullName();
|
||||
wxCHECK_RET( aProject, "Null PROJECT in LibNamesAndPaths" );
|
||||
|
||||
std::vector<PARAM_CFG*> ca;
|
||||
|
||||
try
|
||||
{
|
||||
if( aPaths )
|
||||
ca.push_back( new PARAM_CFG_FILENAME( "LibDir", aPaths ) );
|
||||
|
||||
if( aNames )
|
||||
ca.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), aNames, GROUP_SCH_LIBS ) );
|
||||
}
|
||||
catch( boost::bad_pointer& )
|
||||
{
|
||||
// Out of memory? Ship's going down anyway....
|
||||
}
|
||||
PROJECT_FILE& project = aProject->GetProjectFile();
|
||||
|
||||
if( doSave )
|
||||
{
|
||||
aProject->ConfigSave( Kiface().KifaceSearch(), GROUP_SCH, ca );
|
||||
if( aPaths )
|
||||
project.m_LegacyLibDir = *aPaths;
|
||||
|
||||
/*
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Unable save project's \"%s\" file" ),
|
||||
GetChars( pro )
|
||||
);
|
||||
THROW_IO_ERROR( msg );
|
||||
}
|
||||
*/
|
||||
if( aNames )
|
||||
project.m_LegacyLibNames = *aNames;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !aProject->ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH, ca ) )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Unable to load project's \"%s\" file" ),
|
||||
GetChars( pro )
|
||||
);
|
||||
THROW_IO_ERROR( msg );
|
||||
}
|
||||
if( aPaths )
|
||||
*aPaths = project.m_LegacyLibDir;
|
||||
|
||||
if( aNames )
|
||||
*aNames = project.m_LegacyLibNames;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCreateMarkers )
|
||||
static_cast<SCH_PIN*>( candidates[0] )->GetTransformedPosition() :
|
||||
candidates[0]->GetPosition();
|
||||
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_DRIVER_CONFLICT );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_DRIVER_CONFLICT );
|
||||
ercItem->SetItems( candidates[0], second_item );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, pos );
|
||||
@ -2023,7 +2023,7 @@ int CONNECTION_GRAPH::RunERC()
|
||||
|
||||
wxCHECK_MSG( m_schematic, true, "Null m_schematic in CONNECTION_GRAPH::ercCheckLabels" );
|
||||
|
||||
ERC_SETTINGS* settings = m_schematic->ErcSettings();
|
||||
ERC_SETTINGS& settings = m_schematic->ErcSettings();
|
||||
|
||||
for( auto&& subgraph : m_subgraphs )
|
||||
{
|
||||
@ -2041,18 +2041,18 @@ int CONNECTION_GRAPH::RunERC()
|
||||
* format due to their TestDanglingEnds() implementation.
|
||||
*/
|
||||
|
||||
if( settings->IsTestEnabled( ERCE_DRIVER_CONFLICT ) && !subgraph->ResolveDrivers() )
|
||||
if( settings.IsTestEnabled( ERCE_DRIVER_CONFLICT ) && !subgraph->ResolveDrivers() )
|
||||
error_count++;
|
||||
|
||||
if( settings->IsTestEnabled( ERCE_BUS_TO_NET_CONFLICT )
|
||||
if( settings.IsTestEnabled( ERCE_BUS_TO_NET_CONFLICT )
|
||||
&& !ercCheckBusToNetConflicts( subgraph ) )
|
||||
error_count++;
|
||||
|
||||
if( settings->IsTestEnabled( ERCE_BUS_ENTRY_CONFLICT )
|
||||
if( settings.IsTestEnabled( ERCE_BUS_ENTRY_CONFLICT )
|
||||
&& !ercCheckBusToBusEntryConflicts( subgraph ) )
|
||||
error_count++;
|
||||
|
||||
if( settings->IsTestEnabled( ERCE_BUS_TO_BUS_CONFLICT )
|
||||
if( settings.IsTestEnabled( ERCE_BUS_TO_BUS_CONFLICT )
|
||||
&& !ercCheckBusToBusConflicts( subgraph ) )
|
||||
error_count++;
|
||||
|
||||
@ -2062,8 +2062,8 @@ int CONNECTION_GRAPH::RunERC()
|
||||
if( !ercCheckNoConnects( subgraph ) )
|
||||
error_count++;
|
||||
|
||||
if( ( settings->IsTestEnabled( ERCE_LABEL_NOT_CONNECTED )
|
||||
|| settings->IsTestEnabled( ERCE_GLOBLABEL ) ) && !ercCheckLabels( subgraph ) )
|
||||
if( ( settings.IsTestEnabled( ERCE_LABEL_NOT_CONNECTED )
|
||||
|| settings.IsTestEnabled( ERCE_GLOBLABEL ) ) && !ercCheckLabels( subgraph ) )
|
||||
error_count++;
|
||||
}
|
||||
|
||||
@ -2114,7 +2114,7 @@ bool CONNECTION_GRAPH::ercCheckBusToNetConflicts( const CONNECTION_SUBGRAPH* aSu
|
||||
|
||||
if( net_item && bus_item )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_BUS_TO_NET_CONFLICT );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_BUS_TO_NET_CONFLICT );
|
||||
ercItem->SetItems( net_item, bus_item );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, net_item->GetPosition() );
|
||||
@ -2182,7 +2182,7 @@ bool CONNECTION_GRAPH::ercCheckBusToBusConflicts( const CONNECTION_SUBGRAPH* aSu
|
||||
|
||||
if( !match )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_BUS_TO_BUS_CONFLICT );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_BUS_TO_BUS_CONFLICT );
|
||||
ercItem->SetItems( label, port );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, label->GetPosition() );
|
||||
@ -2262,7 +2262,7 @@ bool CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts( const CONNECTION_SUBGRAPH
|
||||
|
||||
if( conflict )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_BUS_ENTRY_CONFLICT );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_CONFLICT );
|
||||
ercItem->SetItems( bus_entry, bus_wire );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, bus_entry->GetPosition() );
|
||||
@ -2315,7 +2315,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
|
||||
|
||||
if( pin && has_invalid_items )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_NOCONNECT_CONNECTED );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_CONNECTED );
|
||||
ercItem->SetItems( pin );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetTransformedPosition() );
|
||||
@ -2326,7 +2326,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
|
||||
|
||||
if( !has_other_items )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_NOCONNECT_NOT_CONNECTED );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_NOCONNECT_NOT_CONNECTED );
|
||||
ercItem->SetItems( aSubgraph->m_no_connect );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, aSubgraph->m_no_connect->GetPosition() );
|
||||
@ -2381,7 +2381,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
|
||||
|
||||
if( pin && !has_other_connections && pin->GetType() != ELECTRICAL_PINTYPE::PT_NC )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_PIN_NOT_CONNECTED );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_PIN_NOT_CONNECTED );
|
||||
ercItem->SetItems( pin );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetTransformedPosition() );
|
||||
@ -2437,7 +2437,7 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
|
||||
wxCHECK_MSG( m_schematic, true, "Null m_schematic in CONNECTION_GRAPH::ercCheckLabels" );
|
||||
|
||||
// Global label check can be disabled independently
|
||||
if( !m_schematic->ErcSettings()->IsTestEnabled( ERCE_GLOBLABEL ) && is_global )
|
||||
if( !m_schematic->ErcSettings().IsTestEnabled( ERCE_GLOBLABEL ) && is_global )
|
||||
return true;
|
||||
|
||||
wxString name = text->GetShownText();
|
||||
@ -2475,7 +2475,7 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
|
||||
|
||||
if( !has_other_connections )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( is_global ? ERCE_GLOBLABEL : ERCE_LABEL_NOT_CONNECTED );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( is_global ? ERCE_GLOBLABEL : ERCE_LABEL_NOT_CONNECTED );
|
||||
ercItem->SetItems( text );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
|
||||
|
@ -195,17 +195,17 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter )
|
||||
}
|
||||
|
||||
SCH_SCREENS screens( sch->Root() );
|
||||
ERC_SETTINGS* settings = sch->ErcSettings();
|
||||
ERC_SETTINGS& settings = sch->ErcSettings();
|
||||
|
||||
// Test duplicate sheet names inside a given sheet. While one can have multiple references
|
||||
// to the same file, each must have a unique name.
|
||||
if( settings->IsTestEnabled( ERCE_DUPLICATE_SHEET_NAME ) )
|
||||
if( settings.IsTestEnabled( ERCE_DUPLICATE_SHEET_NAME ) )
|
||||
{
|
||||
aReporter.ReportTail( _( "Checking sheet names...\n" ), RPT_SEVERITY_INFO );
|
||||
TestDuplicateSheetNames( sch, true );
|
||||
}
|
||||
|
||||
if( settings->IsTestEnabled( ERCE_BUS_ALIAS_CONFLICT ) )
|
||||
if( settings.IsTestEnabled( ERCE_BUS_ALIAS_CONFLICT ) )
|
||||
{
|
||||
aReporter.ReportTail( _( "Checking bus conflicts...\n" ), RPT_SEVERITY_INFO );
|
||||
TestConflictingBusAliases( sch );
|
||||
@ -217,7 +217,7 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter )
|
||||
sch->ConnectionGraph()->RunERC();
|
||||
|
||||
// Test is all units of each multiunit component have the same footprint assigned.
|
||||
if( settings->IsTestEnabled( ERCE_DIFFERENT_UNIT_FP ) )
|
||||
if( settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_FP ) )
|
||||
{
|
||||
aReporter.ReportTail( _( "Checking footprints...\n" ), RPT_SEVERITY_INFO );
|
||||
SCH_SHEET_LIST sheets = sch->GetSheets();
|
||||
@ -277,7 +277,7 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter )
|
||||
case NETLIST_ITEM::PIN:
|
||||
{
|
||||
// Check if this pin has appeared before on a different net
|
||||
if( item->m_Link && settings->IsTestEnabled( ERCE_DIFFERENT_UNIT_NET ) )
|
||||
if( item->m_Link && settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_NET ) )
|
||||
{
|
||||
wxString ref = item->GetComponentParent()->GetRef( &item->m_SheetPath );
|
||||
wxString pin_name = ref + "_" + item->m_PinNum;
|
||||
@ -294,7 +294,7 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter )
|
||||
pin_to_net_map[pin_name],
|
||||
item->GetNetName() );
|
||||
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_DIFFERENT_UNIT_NET );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_NET );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
ercItem->SetItems( item->m_Comp );
|
||||
|
||||
@ -316,13 +316,13 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter )
|
||||
|
||||
// Test similar labels (i;e. labels which are identical when
|
||||
// using case insensitive comparisons)
|
||||
if( settings->IsTestEnabled( ERCE_SIMILAR_LABELS ) )
|
||||
if( settings.IsTestEnabled( ERCE_SIMILAR_LABELS ) )
|
||||
{
|
||||
aReporter.ReportTail( _( "Checking labels...\n" ), RPT_SEVERITY_INFO );
|
||||
objectsConnectedList->TestforSimilarLabels();
|
||||
}
|
||||
|
||||
if( settings->IsTestEnabled( ERCE_UNRESOLVED_VARIABLE ) )
|
||||
if( settings.IsTestEnabled( ERCE_UNRESOLVED_VARIABLE ) )
|
||||
TestTextVars( sch, m_parent->GetCanvas()->GetView()->GetWorksheet() );
|
||||
|
||||
// Display diags:
|
||||
@ -393,14 +393,14 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
|
||||
if( !node )
|
||||
return;
|
||||
|
||||
SCHEMATIC& sch = m_parent->Schematic();
|
||||
ERC_SETTINGS& settings = m_parent->Schematic().ErcSettings();
|
||||
|
||||
RC_ITEM* rcItem = node->m_RcItem;
|
||||
wxString listName;
|
||||
wxMenu menu;
|
||||
wxString msg;
|
||||
|
||||
switch( sch.GetErcSeverity( rcItem->GetErrorCode() ) )
|
||||
switch( settings.GetSeverity( rcItem->GetErrorCode() ) )
|
||||
{
|
||||
case RPT_SEVERITY_ERROR: listName = _( "errors" ); break;
|
||||
case RPT_SEVERITY_WARNING: listName = _( "warnings" ); break;
|
||||
@ -425,21 +425,20 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
|
||||
{
|
||||
// Pin to pin severities edited through pin conflict map
|
||||
}
|
||||
else if( sch.GetErcSeverity( rcItem->GetErrorCode() ) == RPT_SEVERITY_WARNING )
|
||||
else if( settings.GetSeverity( rcItem->GetErrorCode() ) == RPT_SEVERITY_WARNING )
|
||||
{
|
||||
menu.Append( 4, wxString::Format( _( "Change severity to Error for all '%s' violations" ),
|
||||
rcItem->GetErrorText( rcItem->GetErrorCode() ) ),
|
||||
rcItem->GetErrorText() ),
|
||||
_( "Violation severities can also be edited in the Board Setup... dialog" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
menu.Append( 5, wxString::Format( _( "Change severity to Warning for all '%s' violations" ),
|
||||
rcItem->GetErrorText( rcItem->GetErrorCode() ) ),
|
||||
rcItem->GetErrorText() ),
|
||||
_( "Violation severities can also be edited in the Board Setup... dialog" ) );
|
||||
}
|
||||
|
||||
menu.Append( 6, wxString::Format( _( "Ignore all '%s' violations" ),
|
||||
rcItem->GetErrorText( rcItem->GetErrorCode() ) ),
|
||||
menu.Append( 6, wxString::Format( _( "Ignore all '%s' violations" ), rcItem->GetErrorText() ),
|
||||
_( "Violations will not be checked or reported" ) );
|
||||
|
||||
menu.AppendSeparator();
|
||||
@ -478,7 +477,7 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
|
||||
break;
|
||||
|
||||
case 4:
|
||||
sch.SetErcSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_ERROR );
|
||||
settings.SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_ERROR );
|
||||
|
||||
// Rebuild model and view
|
||||
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markerProvider );
|
||||
@ -486,7 +485,7 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
|
||||
break;
|
||||
|
||||
case 5:
|
||||
sch.SetErcSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_WARNING );
|
||||
settings.SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_WARNING );
|
||||
|
||||
// Rebuild model and view
|
||||
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markerProvider );
|
||||
@ -495,12 +494,12 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
|
||||
|
||||
case 6:
|
||||
{
|
||||
sch.SetErcSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_IGNORE );
|
||||
settings.SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_IGNORE );
|
||||
|
||||
if( rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_ERROR )
|
||||
sch.SetErcSeverity( ERCE_PIN_TO_PIN_WARNING, RPT_SEVERITY_IGNORE );
|
||||
settings.SetSeverity( ERCE_PIN_TO_PIN_WARNING, RPT_SEVERITY_IGNORE );
|
||||
|
||||
SCH_SCREENS ScreenList( sch.Root() );
|
||||
SCH_SCREENS ScreenList( m_parent->Schematic().Root() );
|
||||
ScreenList.DeleteMarkers( MARKER_BASE::MARKER_ERC, rcItem->GetErrorCode() );
|
||||
|
||||
// Rebuild model and view
|
||||
@ -615,6 +614,8 @@ bool DIALOG_ERC::writeReport( const wxString& aFullFileName )
|
||||
|
||||
sheetList.FillItemMap( itemMap );
|
||||
|
||||
ERC_SETTINGS& settings = m_parent->Schematic().ErcSettings();
|
||||
|
||||
for( unsigned i = 0; i < sheetList.size(); i++ )
|
||||
{
|
||||
msg << wxString::Format( _( "\n***** Sheet %s\n" ), sheetList[i].PathHumanReadable() );
|
||||
@ -628,7 +629,7 @@ bool DIALOG_ERC::writeReport( const wxString& aFullFileName )
|
||||
|
||||
total_count++;
|
||||
|
||||
switch( m_parent->Schematic().GetErcSeverity( marker->GetRCItem()->GetErrorCode() ) )
|
||||
switch( settings.GetSeverity( marker->GetRCItem()->GetErrorCode() ) )
|
||||
{
|
||||
case RPT_SEVERITY_ERROR: err_count++; break;
|
||||
case RPT_SEVERITY_WARNING: warn_count++; break;
|
||||
|
@ -56,7 +56,7 @@ bool DIALOG_SCH_IMPORT_SETTINGS::TransferDataToWindow()
|
||||
void DIALOG_SCH_IMPORT_SETTINGS::OnBrowseClicked( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn = m_frame->Schematic().Root().GetFileName();
|
||||
fn.SetExt( LegacyProjectFileExtension );
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
wxFileDialog dlg( this, _( "Import Settings From" ), fn.GetPath(), fn.GetFullName(),
|
||||
ProjectFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
|
||||
|
@ -17,6 +17,7 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <schematic.h>
|
||||
#include <kiface_i.h>
|
||||
@ -27,6 +28,8 @@
|
||||
#include <eeschema_config.h>
|
||||
#include <erc_item.h>
|
||||
#include <panel_text_variables.h>
|
||||
#include <project/project_file.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include "dialog_schematic_setup.h"
|
||||
#include "panel_eeschema_template_fieldnames.h"
|
||||
|
||||
@ -41,10 +44,9 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
|
||||
m_fieldNameTemplates = new PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( aFrame, m_treebook, false );
|
||||
m_pinMap = new PANEL_SETUP_PINMAP( m_treebook, aFrame );
|
||||
|
||||
ERC_ITEM dummyItem( 0 );
|
||||
m_severities = new PANEL_SETUP_SEVERITIES( this, dummyItem,
|
||||
m_frame->Schematic().ErcSettings()->m_Severities, ERCE_FIRST, ERCE_LAST,
|
||||
ERCE_PIN_TO_PIN_WARNING );
|
||||
m_pinToPinError = ERC_ITEM::Create( ERCE_PIN_TO_PIN_WARNING );
|
||||
m_severities = new PANEL_SETUP_SEVERITIES( this, ERC_ITEM::GetItemsWithSeverities(),
|
||||
m_frame->Schematic().ErcSettings().m_Severities, m_pinToPinError );
|
||||
|
||||
m_textVars = new PANEL_TEXT_VARIABLES( m_treebook, &Prj() );
|
||||
|
||||
@ -76,6 +78,8 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
|
||||
|
||||
DIALOG_SCHEMATIC_SETUP::~DIALOG_SCHEMATIC_SETUP()
|
||||
{
|
||||
delete m_pinToPinError;
|
||||
|
||||
m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
||||
wxBookCtrlEventHandler( DIALOG_SCHEMATIC_SETUP::OnPageChange ), NULL, this );
|
||||
}
|
||||
@ -108,29 +112,35 @@ void DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction( wxCommandEvent& event )
|
||||
if( importDlg.ShowModal() == wxID_CANCEL )
|
||||
return;
|
||||
|
||||
wxConfigBase* cfg = new wxFileConfig( wxEmptyString, wxEmptyString, importDlg.GetFilePath() );
|
||||
wxFileName projectFn( importDlg.GetFilePath() );
|
||||
|
||||
// We do not want expansion of env var values when reading our project config file
|
||||
cfg->SetExpandEnvVars( false );
|
||||
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
|
||||
if( !m_frame->GetSettingsManager()->LoadProject( projectFn.GetFullPath(), false ) )
|
||||
{
|
||||
wxString msg = wxString::Format( _( "Error importing settings from project:\n"
|
||||
"Project file %s could not be loaded" ),
|
||||
projectFn.GetFullPath() );
|
||||
DisplayErrorMessage( this, msg );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PROJECT* otherPrj = m_frame->GetSettingsManager()->GetProject( projectFn.GetFullPath() );
|
||||
|
||||
SCHEMATIC otherSch( otherPrj );
|
||||
|
||||
TEMPLATES templateMgr;
|
||||
PROJECT_FILE& file = otherPrj->GetProjectFile();
|
||||
|
||||
wxASSERT( file.m_SchematicSettings );
|
||||
|
||||
file.m_SchematicSettings->m_TemplateFieldNames = &templateMgr;
|
||||
file.m_SchematicSettings->LoadFromFile();
|
||||
|
||||
if( importDlg.m_formattingOpt->GetValue() )
|
||||
{
|
||||
std::vector<PARAM_CFG*> params;
|
||||
m_frame->AddFormattingParameters( params );
|
||||
|
||||
wxConfigLoadParams( cfg, params, GROUP_SCH_EDIT );
|
||||
m_formatting->TransferDataToWindow();
|
||||
}
|
||||
m_formatting->ImportSettingsFrom( *file.m_SchematicSettings );
|
||||
|
||||
if( importDlg.m_fieldNameTemplatesOpt->GetValue() )
|
||||
{
|
||||
TEMPLATES templateMgr;
|
||||
PARAM_CFG_FIELDNAMES param( &templateMgr );
|
||||
param.ReadParam( cfg );
|
||||
|
||||
m_fieldNameTemplates->ImportSettingsFrom( &templateMgr );
|
||||
}
|
||||
m_fieldNameTemplates->ImportSettingsFrom( file.m_SchematicSettings->m_TemplateFieldNames );
|
||||
|
||||
if( importDlg.m_pinMapOpt->GetValue() )
|
||||
{
|
||||
@ -138,13 +148,7 @@ void DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction( wxCommandEvent& event )
|
||||
}
|
||||
|
||||
if( importDlg.m_SeveritiesOpt->GetValue() )
|
||||
{
|
||||
ERC_SETTINGS settings;
|
||||
settings.LoadDefaults();
|
||||
wxConfigLoadParams( cfg, settings.GetProjectFileParameters(), GROUP_SCH_EDIT );
|
||||
m_severities->ImportSettingsFrom( file.m_ErcSettings->m_Severities );
|
||||
|
||||
m_severities->ImportSettingsFrom( settings.m_Severities );
|
||||
}
|
||||
|
||||
delete cfg;
|
||||
m_frame->GetSettingsManager()->UnloadProject( otherPrj, false );
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ protected:
|
||||
PANEL_SETUP_PINMAP* m_pinMap;
|
||||
PANEL_SETUP_SEVERITIES* m_severities;
|
||||
PANEL_TEXT_VARIABLES* m_textVars;
|
||||
ERC_ITEM* m_pinToPinError;
|
||||
|
||||
std::vector<bool> m_macHack;
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <sch_screen.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <schematic.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <env_paths.h>
|
||||
|
||||
|
@ -138,3 +138,17 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow()
|
||||
}
|
||||
|
||||
|
||||
void PANEL_SETUP_FORMATTING::ImportSettingsFrom( SCHEMATIC_SETTINGS& aSettings )
|
||||
{
|
||||
m_textSize.SetValue( aSettings.m_DefaultTextSize );
|
||||
m_lineWidth.SetValue( aSettings.m_DefaultLineWidth );
|
||||
m_busWidth.SetValue( aSettings.m_DefaultBusThickness );
|
||||
m_wireWidth.SetValue( aSettings.m_DefaultWireThickness );
|
||||
m_pinSymbolSize.SetValue( aSettings.m_PinSymbolSize );
|
||||
m_junctionSize.SetValue( aSettings.m_JunctionSize );
|
||||
|
||||
wxString offsetRatio = wxString::Format( "%f", aSettings.m_TextOffsetRatio * 100.0 );
|
||||
m_textOffsetRatioCtrl->SetValue( offsetRatio );
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "panel_setup_formatting_base.h"
|
||||
|
||||
class SCH_EDIT_FRAME;
|
||||
class SCHEMATIC_SETTINGS;
|
||||
class GAL_OPTIONS_PANEL;
|
||||
|
||||
|
||||
@ -44,6 +45,8 @@ public:
|
||||
|
||||
bool TransferDataToWindow() override;
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
void ImportSettingsFrom( SCHEMATIC_SETTINGS& aSettings );
|
||||
};
|
||||
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <dialogs/panel_libedit_color_settings.h>
|
||||
#include <dialogs/panel_libedit_settings.h>
|
||||
#include <eeschema_config.h>
|
||||
#include <eeschema_settings.h>
|
||||
#include <fctsys.h>
|
||||
#include <gestfich.h>
|
||||
#include <gr_text.h>
|
||||
@ -39,6 +38,7 @@
|
||||
#include <panel_gal_display_options.h>
|
||||
#include <panel_hotkeys_editor.h>
|
||||
#include <pgm_base.h>
|
||||
#include <project/project_file.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_junction.h>
|
||||
#include <sch_painter.h>
|
||||
@ -238,90 +238,8 @@ void SCH_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::AddFormattingParameters( std::vector<PARAM_CFG*>& params )
|
||||
bool SCH_EDIT_FRAME::LoadProjectSettings()
|
||||
{
|
||||
EESCHEMA_SETTINGS* appSettings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
||||
|
||||
wxCHECK( appSettings, /*void*/ );
|
||||
|
||||
SCHEMATIC_SETTINGS& settings = Schematic().Settings();
|
||||
|
||||
params.push_back( new PARAM_CFG_INT( wxT( "SubpartIdSeparator" ),
|
||||
LIB_PART::SubpartIdSeparatorPtr(), 0, 0, 126 ) );
|
||||
params.push_back( new PARAM_CFG_INT( wxT( "SubpartFirstId" ),
|
||||
LIB_PART::SubpartFirstIdPtr(), 'A', '1', 'z' ) );
|
||||
|
||||
params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "LabSize" ),
|
||||
&settings.m_DefaultTextSize,
|
||||
Mils2iu( DEFAULT_SIZE_TEXT ),
|
||||
Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) );
|
||||
params.push_back( new PARAM_CFG_DOUBLE( wxT( "TextOffsetRatio" ),
|
||||
&settings.m_TextOffsetRatio,
|
||||
(double) TXT_MARGIN / DEFAULT_SIZE_TEXT,
|
||||
-200.0, 200.0 ) );
|
||||
params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "LineThickness" ),
|
||||
&settings.m_DefaultLineWidth,
|
||||
Mils2iu( appSettings->m_Drawing.default_line_thickness ),
|
||||
Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) );
|
||||
|
||||
params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "BusThickness" ),
|
||||
&settings.m_DefaultBusThickness,
|
||||
Mils2iu( appSettings->m_Drawing.default_bus_thickness ),
|
||||
Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) );
|
||||
params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "WireThickness" ),
|
||||
&settings.m_DefaultWireThickness,
|
||||
Mils2iu( appSettings->m_Drawing.default_wire_thickness ),
|
||||
Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) );
|
||||
params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PinSymbolSize" ),
|
||||
&settings.m_PinSymbolSize,
|
||||
Mils2iu( appSettings->m_Drawing.pin_symbol_size ),
|
||||
Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) );
|
||||
params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "JunctionSize" ),
|
||||
&settings.m_JunctionSize,
|
||||
Mils2iu( appSettings->m_Drawing.default_junction_size ),
|
||||
Mils2iu( 5 ), Mils2iu( 1000 ), nullptr, 1 / IU_PER_MILS ) );
|
||||
}
|
||||
|
||||
|
||||
std::vector<PARAM_CFG*>& SCH_EDIT_FRAME::GetProjectFileParameters()
|
||||
{
|
||||
if( !m_projectFileParams.empty() )
|
||||
return m_projectFileParams;
|
||||
|
||||
std::vector<PARAM_CFG*>& params = m_projectFileParams;
|
||||
|
||||
params.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
|
||||
&BASE_SCREEN::m_PageLayoutDescrFileName ) );
|
||||
params.push_back( new PARAM_CFG_FILENAME( wxT( "PlotDirectoryName" ), &m_plotDirectoryName ) );
|
||||
params.push_back( new PARAM_CFG_WXSTRING( wxT( "NetFmtName" ), &m_netListFormat) );
|
||||
params.push_back( new PARAM_CFG_BOOL( wxT( "SpiceAjustPassiveValues" ),
|
||||
&m_spiceAjustPassiveValues, false ) );
|
||||
|
||||
AddFormattingParameters( params );
|
||||
|
||||
params.push_back( new PARAM_CFG_FIELDNAMES( &m_templateFieldNames ) );
|
||||
|
||||
params.push_back( new PARAM_CFG_SEVERITIES( Schematic().ErcSettings() ) );
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
std::vector<PARAM_CFG*> ERC_SETTINGS::GetProjectFileParameters()
|
||||
{
|
||||
std::vector<PARAM_CFG*> params;
|
||||
|
||||
params.push_back( new PARAM_CFG_SEVERITIES( this ) );
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::LoadProjectFile()
|
||||
{
|
||||
bool ret = Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH_EDIT,
|
||||
GetProjectFileParameters() );
|
||||
|
||||
GetRenderSettings()->SetDefaultPenWidth( m_defaults->m_DefaultLineWidth );
|
||||
GetRenderSettings()->m_DefaultWireThickness = m_defaults->m_DefaultWireThickness;
|
||||
GetRenderSettings()->m_DefaultBusThickness = m_defaults->m_DefaultBusThickness;
|
||||
@ -343,7 +261,9 @@ bool SCH_EDIT_FRAME::LoadProjectFile()
|
||||
|
||||
pglayout.SetPageLayout( filename );
|
||||
|
||||
return ret;
|
||||
Prj().GetProjectFile().m_TemplateFieldNames = &m_templateFieldNames;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -366,17 +286,14 @@ void SCH_EDIT_FRAME::ShowSchematicSetupDialog( const wxString& aInitialPage )
|
||||
|
||||
void SCH_EDIT_FRAME::SaveProjectSettings()
|
||||
{
|
||||
PROJECT& prj = Prj();
|
||||
wxFileName fn = Schematic().RootScreen()->GetFileName(); //ConfigFileName
|
||||
wxFileName fn = Schematic().RootScreen()->GetFileName(); //ConfigFileName
|
||||
|
||||
fn.SetExt( LegacyProjectFileExtension );
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
if( !fn.HasName() || !IsWritable( fn ) )
|
||||
return;
|
||||
|
||||
wxString path = fn.GetFullPath();
|
||||
|
||||
prj.ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters(), path );
|
||||
GetSettingsManager()->SaveProject( fn.GetFullPath() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -185,7 +185,7 @@ int TestDuplicateSheetNames( SCHEMATIC* aSchematic, bool aCreateMarker )
|
||||
{
|
||||
if( aCreateMarker )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_DUPLICATE_SHEET_NAME );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_DUPLICATE_SHEET_NAME );
|
||||
ercItem->SetItems( sheet, test_item );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, sheet->GetPosition() );
|
||||
@ -230,7 +230,7 @@ void TestTextVars( SCHEMATIC* aSchematic, KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet
|
||||
pos = component->GetTransform().TransformCoordinate( pos );
|
||||
pos += component->GetPosition();
|
||||
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_UNRESOLVED_VARIABLE );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( &field );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, pos );
|
||||
@ -246,7 +246,7 @@ void TestTextVars( SCHEMATIC* aSchematic, KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet
|
||||
{
|
||||
if( field.GetShownText().Matches( wxT( "*${*}*" ) ) )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_UNRESOLVED_VARIABLE );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( &field );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, field.GetPosition() );
|
||||
@ -258,7 +258,7 @@ void TestTextVars( SCHEMATIC* aSchematic, KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet
|
||||
{
|
||||
if( pin->GetShownText().Matches( wxT( "*${*}*" ) ) )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_UNRESOLVED_VARIABLE );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( pin );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetPosition() );
|
||||
@ -270,7 +270,7 @@ void TestTextVars( SCHEMATIC* aSchematic, KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet
|
||||
{
|
||||
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_UNRESOLVED_VARIABLE );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( text );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
|
||||
@ -285,7 +285,7 @@ void TestTextVars( SCHEMATIC* aSchematic, KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet
|
||||
{
|
||||
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_UNRESOLVED_VARIABLE );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetErrorMessage( _( "Unresolved text variable in worksheet." ) );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
|
||||
@ -320,7 +320,7 @@ int TestConflictingBusAliases( SCHEMATIC* aSchematic )
|
||||
alias->GetParent()->GetFileName(),
|
||||
test->GetParent()->GetFileName() );
|
||||
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_BUS_ALIAS_CONFLICT );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_BUS_ALIAS_CONFLICT );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, wxPoint() );
|
||||
@ -386,7 +386,7 @@ int TestMultiunitFootprints( const SCH_SHEET_LIST& aSheetList )
|
||||
msg.Printf( _( "Different footprints assigned to %s and %s" ),
|
||||
unitName, secondName );
|
||||
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_DIFFERENT_UNIT_FP );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_FP );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
ercItem->SetItems( unit, secondUnit );
|
||||
|
||||
@ -413,7 +413,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, int aMi
|
||||
{
|
||||
if( aMinConn == NOD ) /* Nothing driving the net. */
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_PIN_NOT_DRIVEN );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_PIN_NOT_DRIVEN );
|
||||
ercItem->SetItems( pin );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, aNetItemRef->m_Start );
|
||||
@ -424,7 +424,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, int aMi
|
||||
|
||||
if( aNetItemTst && aNetItemTst->m_Type == NETLIST_ITEM::PIN ) /* Error between 2 pins */
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( aDiag == ERR ? ERCE_PIN_TO_PIN_ERROR
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( aDiag == ERR ? ERCE_PIN_TO_PIN_ERROR
|
||||
: ERCE_PIN_TO_PIN_WARNING );
|
||||
ercItem->SetItems( pin, static_cast<SCH_PIN*>( aNetItemTst->m_Comp ) );
|
||||
|
||||
@ -764,7 +764,7 @@ static int countIndenticalLabels( std::vector<NETLIST_OBJECT*>& aList, NETLIST_O
|
||||
// Helper function: creates a marker for similar labels ERC warning
|
||||
static void SimilarLabelsDiagnose( NETLIST_OBJECT* aItemA, NETLIST_OBJECT* aItemB )
|
||||
{
|
||||
ERC_ITEM* ercItem = new ERC_ITEM( ERCE_SIMILAR_LABELS );
|
||||
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS );
|
||||
ercItem->SetItems( aItemA->m_Comp, aItemB->m_Comp );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, aItemA->m_Start );
|
||||
|
@ -29,84 +29,179 @@
|
||||
#include <erc_item.h>
|
||||
#include <i18n_utility.h>
|
||||
|
||||
wxString ERC_ITEM::GetErrorText( int aErrorCode, bool aTranslate ) const
|
||||
|
||||
// These, being statically-defined, require specialized I18N handling. We continue to
|
||||
// use the _() macro so that string harvesting by the I18N framework doesn't have to be
|
||||
// specialized, but we don't translate on initialization and instead do it in the getters.
|
||||
|
||||
#undef _
|
||||
#define _(s) s
|
||||
|
||||
ERC_ITEM ERC_ITEM::duplicateSheetName( ERCE_DUPLICATE_SHEET_NAME,
|
||||
_( "Duplicate sheet names within a given sheet" ),
|
||||
wxT( "duplicate_sheet_names" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::pinNotConnected( ERCE_PIN_NOT_CONNECTED,
|
||||
_( "Pin not connected" ),
|
||||
wxT( "pin_not_connected" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::pinNotDriven( ERCE_PIN_NOT_DRIVEN,
|
||||
_( "Pin connected to other pins, but not driven by any pin" ),
|
||||
wxT( "pin_not_driven" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::pinTableConflict( ERCE_PIN_TO_PIN_ERROR,
|
||||
_( "Conflict problem between pins" ),
|
||||
wxT( "pin_to_pin" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::hierLabelMismatch( ERCE_HIERACHICAL_LABEL,
|
||||
_( "Mismatch between hierarchical labels and pins sheets" ),
|
||||
wxT( "hier_label_mismatch" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::noConnectConnected( ERCE_NOCONNECT_CONNECTED,
|
||||
_( "A pin with a \"no connection\" flag is connected" ),
|
||||
wxT( "no_connect_connected" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::noConnectDangling( ERCE_NOCONNECT_NOT_CONNECTED,
|
||||
_( "Unconnected \"no connection\" flag" ),
|
||||
wxT( "no_connect_dangling" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::labelDangling( ERCE_LABEL_NOT_CONNECTED,
|
||||
_( "Label not connected anywhere else in the schematic" ),
|
||||
wxT( "label_dangling" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::globalLabelDangling( ERCE_GLOBLABEL,
|
||||
_( "Global label not connected anywhere else in the schematic" ),
|
||||
wxT( "global_label_dangling" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::similarLabels( ERCE_SIMILAR_LABELS,
|
||||
_( "Labels are similar (lower/upper case difference only) "),
|
||||
wxT( "similar_labels" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::differentUnitFootprint( ERCE_DIFFERENT_UNIT_FP,
|
||||
_( "Different footprint assigned in another unit of the same component" ),
|
||||
wxT( "different_unit_footprint" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::differentUnitNet( ERCE_DIFFERENT_UNIT_NET,
|
||||
_( "Different net assigned to a shared pin in another unit of the same component" ),
|
||||
wxT( "different_unit_net" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::busDefinitionConflict( ERCE_BUS_ALIAS_CONFLICT,
|
||||
_( "Conflict between bus alias definitions across schematic sheets" ),
|
||||
wxT( "bus_definition_conflict" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::multipleNetNames( ERCE_DRIVER_CONFLICT,
|
||||
_( "More than one name given to this bus or net" ),
|
||||
wxT( "multiple_net_names" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::netNotBusMember( ERCE_BUS_ENTRY_CONFLICT,
|
||||
_( "Net is graphically connected to a bus but not a bus member" ),
|
||||
wxT( "net_not_bus_member" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::busLabelSyntax( ERCE_BUS_LABEL_ERROR,
|
||||
_( "Label attached to bus item does not describe a bus" ),
|
||||
wxT( "bus_label_syntax" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::busToBusConflict( ERCE_BUS_TO_BUS_CONFLICT,
|
||||
_( "Buses are graphically connected but share no bus members" ),
|
||||
wxT( "bus_to_bus_conflict" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::busToNetConflict( ERCE_BUS_TO_NET_CONFLICT,
|
||||
_( "Invalid connection between bus and net items" ),
|
||||
wxT( "bus_to_net_conflict" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::unresolvedVariable( ERCE_UNRESOLVED_VARIABLE,
|
||||
_( "Unresolved text variable" ),
|
||||
wxT( "unresolved_variable" ) );
|
||||
|
||||
std::vector<std::reference_wrapper<RC_ITEM>> ERC_ITEM::allItemTypes( {
|
||||
ERC_ITEM::duplicateSheetName,
|
||||
ERC_ITEM::pinNotConnected,
|
||||
ERC_ITEM::pinNotDriven,
|
||||
ERC_ITEM::pinTableConflict,
|
||||
ERC_ITEM::hierLabelMismatch,
|
||||
ERC_ITEM::noConnectConnected,
|
||||
ERC_ITEM::noConnectDangling,
|
||||
ERC_ITEM::labelDangling,
|
||||
ERC_ITEM::globalLabelDangling,
|
||||
ERC_ITEM::similarLabels,
|
||||
ERC_ITEM::differentUnitFootprint,
|
||||
ERC_ITEM::differentUnitNet,
|
||||
ERC_ITEM::busDefinitionConflict,
|
||||
ERC_ITEM::multipleNetNames,
|
||||
ERC_ITEM::netNotBusMember,
|
||||
ERC_ITEM::busLabelSyntax,
|
||||
ERC_ITEM::busToBusConflict,
|
||||
ERC_ITEM::busToNetConflict,
|
||||
ERC_ITEM::unresolvedVariable
|
||||
} );
|
||||
|
||||
|
||||
|
||||
ERC_ITEM* ERC_ITEM::Create( int aErrorCode )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
if( aErrorCode < 0 )
|
||||
aErrorCode = m_errorCode;
|
||||
|
||||
switch( aErrorCode )
|
||||
{
|
||||
case ERCE_UNSPECIFIED:
|
||||
msg = _HKI("ERC err unspecified" );
|
||||
break;
|
||||
case ERCE_DUPLICATE_SHEET_NAME:
|
||||
msg = _HKI("Duplicate sheet names within a given sheet" );
|
||||
break;
|
||||
return new ERC_ITEM( duplicateSheetName );
|
||||
|
||||
case ERCE_PIN_NOT_CONNECTED:
|
||||
msg = _HKI("Pin not connected" );
|
||||
break;
|
||||
return new ERC_ITEM( pinNotConnected );
|
||||
|
||||
case ERCE_PIN_NOT_DRIVEN:
|
||||
msg = _HKI( "Pin connected to other pins, but not driven by any pin" );
|
||||
break;
|
||||
return new ERC_ITEM( pinNotDriven );
|
||||
|
||||
case ERCE_PIN_TO_PIN_WARNING:
|
||||
case ERCE_PIN_TO_PIN_ERROR:
|
||||
msg = _HKI("Conflict problem between pins" );
|
||||
break;
|
||||
case ERCE_HIERACHICAL_LABEL:
|
||||
msg = _HKI("Mismatch between hierarchical labels and pins sheets" );
|
||||
break;
|
||||
case ERCE_NOCONNECT_CONNECTED:
|
||||
msg = _HKI("A pin with a \"no connection\" flag is connected" );
|
||||
break;
|
||||
case ERCE_NOCONNECT_NOT_CONNECTED:
|
||||
msg = _HKI("Unconnected \"no connection\" flag" );
|
||||
break;
|
||||
case ERCE_LABEL_NOT_CONNECTED:
|
||||
msg = _HKI("Label not connected anywhere else in the schematic" );
|
||||
break;
|
||||
case ERCE_SIMILAR_LABELS:
|
||||
msg = _HKI("Labels are similar (lower/upper case difference only)" );
|
||||
break;
|
||||
case ERCE_DIFFERENT_UNIT_FP:
|
||||
msg = _HKI("Different footprint assigned in another unit of the same component" );
|
||||
break;
|
||||
case ERCE_DIFFERENT_UNIT_NET:
|
||||
msg = _HKI("Different net assigned to a shared pin in another unit of the same component" );
|
||||
break;
|
||||
case ERCE_BUS_ALIAS_CONFLICT:
|
||||
msg = _HKI("Conflict between bus alias definitions across schematic sheets" );
|
||||
break;
|
||||
case ERCE_DRIVER_CONFLICT:
|
||||
msg = _HKI( "More than one name given to this bus or net" );
|
||||
break;
|
||||
case ERCE_BUS_ENTRY_CONFLICT:
|
||||
msg = _HKI( "Net is graphically connected to a bus but not a bus member" );
|
||||
break;
|
||||
case ERCE_BUS_LABEL_ERROR:
|
||||
msg = _HKI( "Label attached to bus item does not describe a bus" );
|
||||
break;
|
||||
case ERCE_BUS_TO_BUS_CONFLICT:
|
||||
msg = _HKI( "Buses are graphically connected but share no bus members" );
|
||||
break;
|
||||
case ERCE_BUS_TO_NET_CONFLICT:
|
||||
msg = _HKI( "Invalid connection between bus and net items" );
|
||||
break;
|
||||
case ERCE_GLOBLABEL:
|
||||
msg = _HKI( "Global label not connected anywhere else in the schematic" );
|
||||
break;
|
||||
case ERCE_UNRESOLVED_VARIABLE:
|
||||
msg = _HKI( "Unresolved text variable" );
|
||||
break;
|
||||
default:
|
||||
wxFAIL_MSG( "Missing ERC error description" );
|
||||
msg = _HKI( "Unknown ERC violation" );
|
||||
break;
|
||||
}
|
||||
return new ERC_ITEM( pinTableConflict );
|
||||
|
||||
if( aTranslate )
|
||||
return wxGetTranslation( msg );
|
||||
else
|
||||
return msg;
|
||||
case ERCE_HIERACHICAL_LABEL:
|
||||
return new ERC_ITEM( hierLabelMismatch );
|
||||
|
||||
case ERCE_NOCONNECT_CONNECTED:
|
||||
return new ERC_ITEM( noConnectConnected );
|
||||
|
||||
case ERCE_NOCONNECT_NOT_CONNECTED:
|
||||
return new ERC_ITEM( noConnectDangling );
|
||||
|
||||
case ERCE_LABEL_NOT_CONNECTED:
|
||||
return new ERC_ITEM( labelDangling );
|
||||
|
||||
case ERCE_SIMILAR_LABELS:
|
||||
return new ERC_ITEM( similarLabels );
|
||||
|
||||
case ERCE_DIFFERENT_UNIT_FP:
|
||||
return new ERC_ITEM( differentUnitFootprint );
|
||||
|
||||
case ERCE_DIFFERENT_UNIT_NET:
|
||||
return new ERC_ITEM( differentUnitNet );
|
||||
|
||||
case ERCE_BUS_ALIAS_CONFLICT:
|
||||
return new ERC_ITEM( busDefinitionConflict );
|
||||
|
||||
case ERCE_DRIVER_CONFLICT:
|
||||
return new ERC_ITEM( multipleNetNames );
|
||||
|
||||
case ERCE_BUS_ENTRY_CONFLICT:
|
||||
return new ERC_ITEM( netNotBusMember );
|
||||
|
||||
case ERCE_BUS_LABEL_ERROR:
|
||||
return new ERC_ITEM( busLabelSyntax );
|
||||
|
||||
case ERCE_BUS_TO_BUS_CONFLICT:
|
||||
return new ERC_ITEM( busToBusConflict );
|
||||
|
||||
case ERCE_BUS_TO_NET_CONFLICT:
|
||||
return new ERC_ITEM( busToNetConflict );
|
||||
|
||||
case ERCE_GLOBLABEL:
|
||||
return new ERC_ITEM( globalLabelDangling );
|
||||
|
||||
case ERCE_UNRESOLVED_VARIABLE:
|
||||
return new ERC_ITEM( unresolvedVariable );
|
||||
|
||||
case ERCE_UNSPECIFIED:
|
||||
default:
|
||||
wxFAIL_MSG( "Unknown ERC error code" );
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -30,16 +30,47 @@
|
||||
class ERC_ITEM : public RC_ITEM
|
||||
{
|
||||
public:
|
||||
ERC_ITEM( int aErrorCode )
|
||||
/**
|
||||
* Constructs an ERC_ITEM for the given error code
|
||||
* @see ERCE_T
|
||||
*/
|
||||
static ERC_ITEM* Create( int aErrorCode );
|
||||
|
||||
static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
|
||||
{
|
||||
m_errorCode = aErrorCode;
|
||||
return allItemTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetErrorText
|
||||
* returns the string form of an erc error code.
|
||||
*/
|
||||
wxString GetErrorText( int aErrorCode = -1, bool aTranslate = true ) const override;
|
||||
private:
|
||||
ERC_ITEM( int aErrorCode = 0, const wxString& aTitle = "", const wxString& aSettingsKey = "" )
|
||||
{
|
||||
m_errorCode = aErrorCode;
|
||||
m_errorTitle = aTitle;
|
||||
m_settingsKey = aSettingsKey;
|
||||
}
|
||||
|
||||
/// A list of all ERC_ITEM types which are valid error codes
|
||||
static std::vector<std::reference_wrapper<RC_ITEM>> allItemTypes;
|
||||
|
||||
static ERC_ITEM duplicateSheetName;
|
||||
static ERC_ITEM pinNotConnected;
|
||||
static ERC_ITEM pinNotDriven;
|
||||
static ERC_ITEM pinTableConflict;
|
||||
static ERC_ITEM hierLabelMismatch;
|
||||
static ERC_ITEM noConnectConnected;
|
||||
static ERC_ITEM noConnectDangling;
|
||||
static ERC_ITEM labelDangling;
|
||||
static ERC_ITEM globalLabelDangling;
|
||||
static ERC_ITEM similarLabels;
|
||||
static ERC_ITEM differentUnitFootprint;
|
||||
static ERC_ITEM differentUnitNet;
|
||||
static ERC_ITEM busDefinitionConflict;
|
||||
static ERC_ITEM multipleNetNames;
|
||||
static ERC_ITEM netNotBusMember;
|
||||
static ERC_ITEM busLabelSyntax;
|
||||
static ERC_ITEM busToBusConflict;
|
||||
static ERC_ITEM busToNetConflict;
|
||||
static ERC_ITEM unresolvedVariable;
|
||||
};
|
||||
|
||||
|
||||
|
218
eeschema/erc_settings.cpp
Normal file
218
eeschema/erc_settings.cpp
Normal file
@ -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();
|
||||
}
|
@ -22,11 +22,12 @@
|
||||
#define _ERC_SETTINGS_H
|
||||
|
||||
#include <erc.h>
|
||||
#include <erc_item.h>
|
||||
#include <settings/nested_settings.h>
|
||||
#include <widgets/ui_common.h>
|
||||
|
||||
|
||||
class PARAM_CFG;
|
||||
|
||||
class SCH_MARKER;
|
||||
|
||||
/**
|
||||
* Container for ERC settings
|
||||
@ -34,25 +35,21 @@ class PARAM_CFG;
|
||||
* Currently only stores flags about checks to run, but could later be expanded
|
||||
* to contain the matrix of electrical pin types.
|
||||
*/
|
||||
class ERC_SETTINGS
|
||||
class ERC_SETTINGS : public NESTED_SETTINGS
|
||||
{
|
||||
public:
|
||||
ERC_SETTINGS()
|
||||
{
|
||||
for( int i = ERCE_FIRST; i <= ERCE_LAST; ++i )
|
||||
m_Severities[ i ] = RPT_SEVERITY_ERROR;
|
||||
ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
|
||||
|
||||
m_Severities[ ERCE_UNSPECIFIED ] = RPT_SEVERITY_UNDEFINED;
|
||||
}
|
||||
virtual ~ERC_SETTINGS();
|
||||
|
||||
void LoadDefaults()
|
||||
{
|
||||
m_Severities[ ERCE_SIMILAR_LABELS ] = RPT_SEVERITY_WARNING;
|
||||
m_Severities[ ERCE_GLOBLABEL ] = RPT_SEVERITY_WARNING;
|
||||
m_Severities[ ERCE_DRIVER_CONFLICT ] = RPT_SEVERITY_WARNING;
|
||||
m_Severities[ ERCE_BUS_ENTRY_CONFLICT ] = RPT_SEVERITY_WARNING;
|
||||
m_Severities[ ERCE_BUS_TO_BUS_CONFLICT ] = RPT_SEVERITY_ERROR;
|
||||
m_Severities[ ERCE_BUS_TO_NET_CONFLICT ] = RPT_SEVERITY_ERROR;
|
||||
m_Severities[ERCE_SIMILAR_LABELS] = RPT_SEVERITY_WARNING;
|
||||
m_Severities[ERCE_GLOBLABEL] = RPT_SEVERITY_WARNING;
|
||||
m_Severities[ERCE_DRIVER_CONFLICT] = RPT_SEVERITY_WARNING;
|
||||
m_Severities[ERCE_BUS_ENTRY_CONFLICT] = RPT_SEVERITY_WARNING;
|
||||
m_Severities[ERCE_BUS_TO_BUS_CONFLICT] = RPT_SEVERITY_ERROR;
|
||||
m_Severities[ERCE_BUS_TO_NET_CONFLICT] = RPT_SEVERITY_ERROR;
|
||||
}
|
||||
|
||||
bool operator==( const ERC_SETTINGS& other ) const
|
||||
@ -70,9 +67,41 @@ public:
|
||||
return m_Severities.at( aErrorCode ) != RPT_SEVERITY_IGNORE;
|
||||
}
|
||||
|
||||
std::vector<PARAM_CFG*> GetProjectFileParameters();
|
||||
int GetSeverity( int aErrorCode ) const;
|
||||
|
||||
void SetSeverity( int aErrorCode, int aSeverity );
|
||||
|
||||
std::map<int, int> m_Severities;
|
||||
};
|
||||
|
||||
/**
|
||||
* SHEETLIST_ERC_ITEMS_PROVIDER
|
||||
* is an implementation of the RC_ITEM_LISTinterface which uses the global SHEETLIST
|
||||
* to fulfill the contract.
|
||||
*/
|
||||
class SHEETLIST_ERC_ITEMS_PROVIDER : public RC_ITEMS_PROVIDER
|
||||
{
|
||||
private:
|
||||
SCHEMATIC* m_schematic;
|
||||
int m_severities;
|
||||
std::vector<SCH_MARKER*> m_filteredMarkers;
|
||||
|
||||
public:
|
||||
SHEETLIST_ERC_ITEMS_PROVIDER( SCHEMATIC* aSchematic ) :
|
||||
m_schematic( aSchematic ),
|
||||
m_severities( 0 )
|
||||
{ }
|
||||
|
||||
void SetSeverities( int aSeverities ) override;
|
||||
|
||||
int GetCount( int aSeverity = -1 ) override;
|
||||
|
||||
ERC_ITEM* GetItem( int aIndex ) override;
|
||||
|
||||
void DeleteItem( int aIndex, bool aDeep ) override;
|
||||
|
||||
void DeleteAllItems() override;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -283,9 +283,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||
CreateScreens();
|
||||
}
|
||||
|
||||
GetScreen()->SetFileName( fullFileName );
|
||||
Schematic().Root().SetFileName( fullFileName );
|
||||
|
||||
SetStatusText( wxEmptyString );
|
||||
ClearMsgPanel();
|
||||
|
||||
@ -326,13 +323,15 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||
if( pro.GetFullPath() != Prj().GetProjectFullName() )
|
||||
GetSettingsManager()->LoadProject( pro.GetFullPath() );
|
||||
|
||||
LoadProjectFile();
|
||||
|
||||
// Load the symbol library table, this will be used forever more.
|
||||
Prj().SetElem( PROJECT::ELEM_SYMBOL_LIB_TABLE, NULL );
|
||||
Prj().SchSymbolLibTable();
|
||||
|
||||
Schematic().SetProject( Prj() );
|
||||
Schematic().SetProject( &Prj() );
|
||||
|
||||
// Load project settings after schematic has been set up with the project link, since this will
|
||||
// update some of the needed schematic settings such as drawing defaults
|
||||
LoadProjectSettings();
|
||||
|
||||
SetShutdownBlockReason( _( "Schematic file changes are unsaved" ) );
|
||||
|
||||
@ -344,7 +343,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||
else
|
||||
{
|
||||
SetScreen( nullptr );
|
||||
Schematic().Reset();
|
||||
|
||||
SCH_PLUGIN* plugin = SCH_IO_MGR::FindPlugin( schFileType );
|
||||
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( plugin );
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user