Move RecordERCExclusions and ResolveERCExclusions out of the schematic frame

This commit is contained in:
Marek Roszko 2023-08-13 19:50:05 -04:00
parent 50a4a8639e
commit f341fde938
8 changed files with 52 additions and 52 deletions

View File

@ -380,7 +380,7 @@ void DIALOG_ERC::OnRunERCClick( wxCommandEvent& event )
UpdateAnnotationWarning();
m_parent->RecordERCExclusions();
sch->RecordERCExclusions();
deleteAllMarkers( true );
std::vector<std::reference_wrapper<RC_ITEM>> violations = ERC_ITEM::GetItemsWithSeverities();

View File

@ -132,7 +132,7 @@ void SCH_EDIT_FRAME::saveProjectSettings()
if( !fn.HasName() || !IsWritable( fn, false ) )
return;
RecordERCExclusions();
Schematic().RecordERCExclusions();
if( Kiway().Player( FRAME_SIMULATOR, false ) )
Prj().GetProjectFile().m_SchematicSettings->m_NgspiceSettings->SaveToFile();

View File

@ -1175,6 +1175,5 @@ void ERC_TESTER::RunTests( SCHEMATIC* aSch, DS_PROXY_VIEW_ITEM* aDrawingSheet,
TestOffGridEndpoints( aEditFrame->GetCanvas()->GetView()->GetGAL()->GetGridSize().x );
}
if( aEditFrame )
aEditFrame->ResolveERCExclusions();
aSch->ResolveERCExclusionsPostUpdate();
}

View File

@ -495,7 +495,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
}
// Load any exclusions from the project file
ResolveERCExclusions();
Schematic().ResolveERCExclusionsPostUpdate();
initScreenZoom();
SetSheetNumberAndCount();

View File

@ -1046,43 +1046,6 @@ 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()
{
SCH_SHEET_LIST sheetList = Schematic().GetSheets();
for( SCH_MARKER* marker : Schematic().ResolveERCExclusions() )
{
SCH_SHEET_PATH errorPath;
ignore_unused( sheetList.GetItem( marker->GetRCItem()->GetMainItemID(), &errorPath ) );
if( errorPath.LastScreen() )
errorPath.LastScreen()->Append( marker );
else
Schematic().RootScreen()->Append( marker );
}
}
SEVERITY SCH_EDIT_FRAME::GetSeverity( int aErrorCode ) const
{
return Schematic().ErcSettings().GetSeverity( aErrorCode );

View File

@ -197,16 +197,6 @@ public:
*/
void OnModify() override;
/**
* Scan existing markers and record data from any that are Excluded.
*/
void RecordERCExclusions();
/**
* Update markers to match recorded exclusions.
*/
void ResolveERCExclusions();
SEVERITY GetSeverity( int aErrorCode ) const override;
/**

View File

@ -19,6 +19,7 @@
#include <bus_alias.h>
#include <connection_graph.h>
#include <core/ignore.h>
#include <core/kicad_algo.h>
#include <erc_settings.h>
#include <sch_marker.h>
@ -715,4 +716,41 @@ void SCHEMATIC::RemoveAllListeners()
void SCHEMATIC::OnItemsChanged( std::vector<SCH_ITEM*>& aItems )
{
InvokeListeners( &SCHEMATIC_LISTENER::OnSchItemsChanged, *this, aItems );
}
void SCHEMATIC::RecordERCExclusions()
{
SCH_SHEET_LIST sheetList = GetSheets();
ERC_SETTINGS& ercSettings = 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 SCHEMATIC::ResolveERCExclusionsPostUpdate()
{
SCH_SHEET_LIST sheetList = GetSheets();
for( SCH_MARKER* marker : ResolveERCExclusions() )
{
SCH_SHEET_PATH errorPath;
ignore_unused( sheetList.GetItem( marker->GetRCItem()->GetMainItemID(), &errorPath ) );
if( errorPath.LastScreen() )
errorPath.LastScreen()->Append( marker );
else
RootScreen()->Append( marker );
}
}

View File

@ -239,6 +239,16 @@ public:
*/
void FixupJunctions();
/**
* Scan existing markers and record data from any that are Excluded.
*/
void RecordERCExclusions();
/**
* Update markers to match recorded exclusions.
*/
void ResolveERCExclusionsPostUpdate();
/**
* Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for
* listeners.