Start of impl for persisting ERC exclusions.
This commit is contained in:
parent
293795fd46
commit
c61c7b62aa
|
@ -283,6 +283,7 @@ void DIALOG_ERC::OnRunERCClick( wxCommandEvent& event )
|
||||||
|
|
||||||
m_infoBar->Hide();
|
m_infoBar->Hide();
|
||||||
|
|
||||||
|
m_parent->RecordERCExclusions();
|
||||||
deleteAllMarkers( true );
|
deleteAllMarkers( true );
|
||||||
|
|
||||||
m_notebook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
|
m_notebook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
|
||||||
|
@ -418,6 +419,8 @@ void DIALOG_ERC::testErc()
|
||||||
tester.TestLibSymbolIssues();
|
tester.TestLibSymbolIssues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_parent->ResolveERCExclusions();
|
||||||
|
|
||||||
// Display diags:
|
// Display diags:
|
||||||
m_markerTreeModel->SetProvider( m_markerProvider );
|
m_markerTreeModel->SetProvider( m_markerProvider );
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,8 @@ void SCH_EDIT_FRAME::SaveProjectSettings()
|
||||||
if( !fn.HasName() || !IsWritable( fn ) )
|
if( !fn.HasName() || !IsWritable( fn ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
RecordERCExclusions();
|
||||||
|
|
||||||
GetSettingsManager()->SaveProject( fn.GetFullPath() );
|
GetSettingsManager()->SaveProject( fn.GetFullPath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,17 @@ public:
|
||||||
*/
|
*/
|
||||||
static std::shared_ptr<ERC_ITEM> Create( int aErrorCode );
|
static std::shared_ptr<ERC_ITEM> Create( int aErrorCode );
|
||||||
|
|
||||||
|
static std::shared_ptr<ERC_ITEM> Create( const wxString& aErrorKey )
|
||||||
|
{
|
||||||
|
for( const RC_ITEM& item : allItemTypes )
|
||||||
|
{
|
||||||
|
if( aErrorKey == item.GetSettingsKey() )
|
||||||
|
return std::make_shared<ERC_ITEM>( static_cast<const ERC_ITEM&>( item ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
|
static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
|
||||||
{
|
{
|
||||||
return allItemTypes;
|
return allItemTypes;
|
||||||
|
|
|
@ -138,6 +138,33 @@ ERC_SETTINGS::ERC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
|
||||||
},
|
},
|
||||||
{} ) );
|
{} ) );
|
||||||
|
|
||||||
|
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "erc_exclusions",
|
||||||
|
[&]() -> nlohmann::json
|
||||||
|
{
|
||||||
|
nlohmann::json js = nlohmann::json::array();
|
||||||
|
|
||||||
|
for( const auto& entry : m_ErcExclusions )
|
||||||
|
js.push_back( entry );
|
||||||
|
|
||||||
|
return js;
|
||||||
|
},
|
||||||
|
[&]( const nlohmann::json& aObj )
|
||||||
|
{
|
||||||
|
m_ErcExclusions.clear();
|
||||||
|
|
||||||
|
if( !aObj.is_array() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
for( const nlohmann::json& entry : aObj )
|
||||||
|
{
|
||||||
|
if( entry.empty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
m_ErcExclusions.insert( entry.get<wxString>() );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{} ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "pin_map",
|
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "pin_map",
|
||||||
[&]() -> nlohmann::json
|
[&]() -> nlohmann::json
|
||||||
{
|
{
|
||||||
|
|
|
@ -155,6 +155,7 @@ public:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
std::map<int, int> m_Severities;
|
std::map<int, int> m_Severities;
|
||||||
|
std::set<wxString> m_ErcExclusions;
|
||||||
|
|
||||||
PIN_ERROR m_PinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL];
|
PIN_ERROR m_PinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL];
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include <sch_edit_frame.h>
|
#include <sch_edit_frame.h>
|
||||||
#include <sch_painter.h>
|
#include <sch_painter.h>
|
||||||
#include <sch_sheet.h>
|
#include <sch_sheet.h>
|
||||||
|
#include <sch_marker.h>
|
||||||
#include <schematic.h>
|
#include <schematic.h>
|
||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
#include <advanced_config.h>
|
#include <advanced_config.h>
|
||||||
|
@ -696,6 +697,48 @@ void SCH_EDIT_FRAME::doCloseWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_EDIT_FRAME::RecordERCExclusions()
|
||||||
|
{
|
||||||
|
SCH_SHEET_LIST sheetList = Schematic().GetSheets();
|
||||||
|
ERC_SETTINGS& ercSettings = Schematic().ErcSettings();
|
||||||
|
|
||||||
|
ercSettings.m_ErcExclusions.clear();
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < sheetList.size(); i++ )
|
||||||
|
{
|
||||||
|
for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
|
||||||
|
{
|
||||||
|
SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
|
||||||
|
|
||||||
|
if( marker->IsExcluded() )
|
||||||
|
ercSettings.m_ErcExclusions.insert( marker->Serialize() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_EDIT_FRAME::ResolveERCExclusions()
|
||||||
|
{
|
||||||
|
for( SCH_MARKER* marker : Schematic().ResolveERCExclusions() )
|
||||||
|
{
|
||||||
|
// JEY TODO: need to get the right screen....
|
||||||
|
GetScreen()->Append( marker );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the view for the current screen
|
||||||
|
for( SCH_ITEM* item : GetScreen()->Items().OfType( SCH_MARKER_T ) )
|
||||||
|
{
|
||||||
|
SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
|
||||||
|
|
||||||
|
if( marker->IsExcluded() )
|
||||||
|
{
|
||||||
|
GetCanvas()->GetView()->Remove( marker );
|
||||||
|
GetCanvas()->GetView()->Add( marker );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
|
wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
|
||||||
{
|
{
|
||||||
// Filename is rootSheetName-sheetName-...-sheetName
|
// Filename is rootSheetName-sheetName-...-sheetName
|
||||||
|
|
|
@ -206,6 +206,16 @@ public:
|
||||||
*/
|
*/
|
||||||
void OnModify() override;
|
void OnModify() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scan existing markers and record data from any that are Excluded.
|
||||||
|
*/
|
||||||
|
void RecordERCExclusions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update markers to match recorded exclusions.
|
||||||
|
*/
|
||||||
|
void ResolveERCExclusions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a human-readable description of the current screen.
|
* Return a human-readable description of the current screen.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -63,6 +63,34 @@ void SCH_MARKER::SwapData( SCH_ITEM* aItem )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString SCH_MARKER::Serialize() const
|
||||||
|
{
|
||||||
|
return wxString::Format( wxT( "%s|%d|%d|%s|%s" ),
|
||||||
|
m_rcItem->GetSettingsKey(),
|
||||||
|
m_Pos.x,
|
||||||
|
m_Pos.y,
|
||||||
|
m_rcItem->GetMainItemID().AsString(),
|
||||||
|
m_rcItem->GetAuxItemID().AsString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SCH_MARKER* SCH_MARKER::Deserialize( const wxString& data )
|
||||||
|
{
|
||||||
|
wxArrayString props = wxSplit( data, '|' );
|
||||||
|
wxPoint markerPos( (int) strtol( props[1].c_str(), nullptr, 10 ),
|
||||||
|
(int) strtol( props[2].c_str(), nullptr, 10 ) );
|
||||||
|
|
||||||
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( props[0] );
|
||||||
|
|
||||||
|
if( !ercItem )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
ercItem->SetItems( KIID( props[3] ), KIID( props[4] ) );
|
||||||
|
|
||||||
|
return new SCH_MARKER( ercItem, markerPos );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
|
|
||||||
void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const
|
void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const
|
||||||
|
|
|
@ -51,6 +51,9 @@ public:
|
||||||
|
|
||||||
void SwapData( SCH_ITEM* aItem ) override;
|
void SwapData( SCH_ITEM* aItem ) override;
|
||||||
|
|
||||||
|
wxString Serialize() const;
|
||||||
|
static SCH_MARKER* Deserialize( const wxString& data );
|
||||||
|
|
||||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||||
|
|
||||||
SCH_LAYER_ID GetColorLayer() const;
|
SCH_LAYER_ID GetColorLayer() const;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <bus_alias.h>
|
#include <bus_alias.h>
|
||||||
#include <connection_graph.h>
|
#include <connection_graph.h>
|
||||||
#include <erc_settings.h>
|
#include <erc_settings.h>
|
||||||
|
#include <sch_marker.h>
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
#include <project/project_file.h>
|
#include <project/project_file.h>
|
||||||
#include <project/net_settings.h>
|
#include <project/net_settings.h>
|
||||||
|
@ -135,6 +136,45 @@ ERC_SETTINGS& SCHEMATIC::ErcSettings() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<SCH_MARKER*> SCHEMATIC::ResolveERCExclusions()
|
||||||
|
{
|
||||||
|
SCH_SHEET_LIST sheetList = GetSheets();
|
||||||
|
ERC_SETTINGS& settings = ErcSettings();
|
||||||
|
|
||||||
|
for( const SCH_SHEET_PATH& sheet : sheetList )
|
||||||
|
{
|
||||||
|
for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_MARKER_T ) )
|
||||||
|
{
|
||||||
|
SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
|
||||||
|
auto it = ErcSettings().m_ErcExclusions.find( marker->Serialize() );
|
||||||
|
|
||||||
|
if( it != ErcSettings().m_ErcExclusions.end() )
|
||||||
|
{
|
||||||
|
marker->SetExcluded( true );
|
||||||
|
settings.m_ErcExclusions.erase( it );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<SCH_MARKER*> newMarkers;
|
||||||
|
|
||||||
|
for( const wxString& exclusionData : settings.m_ErcExclusions )
|
||||||
|
{
|
||||||
|
SCH_MARKER* marker = SCH_MARKER::Deserialize( exclusionData );
|
||||||
|
|
||||||
|
if( marker )
|
||||||
|
{
|
||||||
|
marker->SetExcluded( true );
|
||||||
|
newMarkers.push_back( marker );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.m_ErcExclusions.clear();
|
||||||
|
|
||||||
|
return newMarkers;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<BUS_ALIAS> SCHEMATIC::GetBusAlias( const wxString& aLabel ) const
|
std::shared_ptr<BUS_ALIAS> SCHEMATIC::GetBusAlias( const wxString& aLabel ) const
|
||||||
{
|
{
|
||||||
for( const auto& sheet : GetSheets() )
|
for( const auto& sheet : GetSheets() )
|
||||||
|
|
|
@ -143,6 +143,8 @@ public:
|
||||||
|
|
||||||
ERC_SETTINGS& ErcSettings() const;
|
ERC_SETTINGS& ErcSettings() const;
|
||||||
|
|
||||||
|
std::vector<SCH_MARKER*> ResolveERCExclusions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to a bus alias object for the given label, or null if one
|
* Returns a pointer to a bus alias object for the given label, or null if one
|
||||||
* doesn't exist.
|
* doesn't exist.
|
||||||
|
|
Loading…
Reference in New Issue