From f341fde938997419a982e8438b24cc400829c2ba Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sun, 13 Aug 2023 19:50:05 -0400 Subject: [PATCH] Move RecordERCExclusions and ResolveERCExclusions out of the schematic frame --- eeschema/dialogs/dialog_erc.cpp | 2 +- eeschema/eeschema_config.cpp | 2 +- eeschema/erc.cpp | 3 +-- eeschema/files-io.cpp | 2 +- eeschema/sch_edit_frame.cpp | 37 -------------------------------- eeschema/sch_edit_frame.h | 10 --------- eeschema/schematic.cpp | 38 +++++++++++++++++++++++++++++++++ eeschema/schematic.h | 10 +++++++++ 8 files changed, 52 insertions(+), 52 deletions(-) diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 70e90e7756..f70969ebc3 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -380,7 +380,7 @@ void DIALOG_ERC::OnRunERCClick( wxCommandEvent& event ) UpdateAnnotationWarning(); - m_parent->RecordERCExclusions(); + sch->RecordERCExclusions(); deleteAllMarkers( true ); std::vector> violations = ERC_ITEM::GetItemsWithSeverities(); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 6e64548c1a..4e73b4a084 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -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(); diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index d4f0d4c659..96570d0232 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -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(); } \ No newline at end of file diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 6969077c80..aed020ebbd 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -495,7 +495,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in } // Load any exclusions from the project file - ResolveERCExclusions(); + Schematic().ResolveERCExclusionsPostUpdate(); initScreenZoom(); SetSheetNumberAndCount(); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 3f97d073ba..96b35f29c0 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -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( 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 ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index bbb94570d5..467f2048a2 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -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; /** diff --git a/eeschema/schematic.cpp b/eeschema/schematic.cpp index 66be397105..66f9b1028e 100644 --- a/eeschema/schematic.cpp +++ b/eeschema/schematic.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -715,4 +716,41 @@ void SCHEMATIC::RemoveAllListeners() void SCHEMATIC::OnItemsChanged( std::vector& 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( 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 ); + } } \ No newline at end of file diff --git a/eeschema/schematic.h b/eeschema/schematic.h index 0483ab7b7d..e5f756e539 100644 --- a/eeschema/schematic.h +++ b/eeschema/schematic.h @@ -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.