diff --git a/eeschema/eeschema_helpers.cpp b/eeschema/eeschema_helpers.cpp index 9dd1ff9d35..3f699f0618 100644 --- a/eeschema/eeschema_helpers.cpp +++ b/eeschema/eeschema_helpers.cpp @@ -196,25 +196,12 @@ SCHEMATIC* EESCHEMA_HELPERS::LoadSchematic( const wxString& aFileName, toolManager->SetEnvironment( schematic, nullptr, nullptr, Kiface().KifaceSettings(), nullptr ); SCH_COMMIT dummyCommit( toolManager ); - schematic->RecalculateConnections( &dummyCommit, GLOBAL_CLEANUP, toolManager, - [&]( SCH_GLOBALLABEL* label ) - { - for( SCH_FIELD& field : label->GetFields() ) - field.ClearBoundingBoxCache(); - - label->ClearBoundingBoxCache(); - } ); + schematic->RecalculateConnections( &dummyCommit, GLOBAL_CLEANUP, toolManager ); schematic->ResolveERCExclusionsPostUpdate(); schematic->SetSheetNumberAndCount(); - schematic->RecomputeIntersheetRefs( []( SCH_GLOBALLABEL* aGlobal ) - { - for( SCH_FIELD& field : aGlobal->GetFields() ) - field.ClearBoundingBoxCache(); - - aGlobal->ClearBoundingBoxCache(); - } ); + schematic->RecomputeIntersheetRefs(); for( SCH_SHEET_PATH& sheet : sheetList ) { diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index bfdb93a28d..2d3684005b 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1810,14 +1810,6 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL Schematic().RecalculateConnections( aCommit, aCleanupFlags, m_toolManager, - [&]( SCH_GLOBALLABEL* label ) - { - for( SCH_FIELD& field : label->GetFields() ) - field.ClearBoundingBoxCache(); - - label->ClearBoundingBoxCache(); - GetCanvas()->GetView()->Update( label ); - }, aProgressReporter, GetCanvas()->GetView(), &changeHandler, @@ -1880,14 +1872,13 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL void SCH_EDIT_FRAME::RecomputeIntersheetRefs() { - Schematic().RecomputeIntersheetRefs( [&]( SCH_GLOBALLABEL* label ) - { - for( SCH_FIELD& field : label->GetFields() ) - field.ClearBoundingBoxCache(); + Schematic().RecomputeIntersheetRefs(); +} - label->ClearBoundingBoxCache(); - GetCanvas()->GetView()->Update( label ); - } ); + +void SCH_EDIT_FRAME::IntersheetRefUpdate( SCH_GLOBALLABEL* aItem ) +{ + GetCanvas()->GetView()->Update( aItem ); } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 710fa06722..2065773a68 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -786,6 +786,11 @@ public: */ void RecomputeIntersheetRefs(); + /** + * Callback from schematic ref update + */ + void IntersheetRefUpdate( SCH_GLOBALLABEL* aItem ) override; + void ShowAllIntersheetRefs( bool aShow ); /** diff --git a/eeschema/schematic.cpp b/eeschema/schematic.cpp index 73f42165fa..643f22708d 100644 --- a/eeschema/schematic.cpp +++ b/eeschema/schematic.cpp @@ -693,8 +693,7 @@ void SCHEMATIC::SetSheetNumberAndCount() } -void SCHEMATIC::RecomputeIntersheetRefs( - const std::function& aItemCallback ) +void SCHEMATIC::RecomputeIntersheetRefs() { std::map>& pageRefsMap = GetPageRefsMap(); @@ -733,7 +732,14 @@ void SCHEMATIC::RecomputeIntersheetRefs( globalLabel->AutoplaceFields( CurrentSheet().LastScreen(), AUTOPLACE_AUTO ); CurrentSheet().LastScreen()->Update( globalLabel ); - aItemCallback( globalLabel ); + + for( SCH_FIELD& field : globalLabel->GetFields() ) + field.ClearBoundingBoxCache(); + + globalLabel->ClearBoundingBoxCache(); + + if( m_schematicHolder ) + m_schematicHolder->IntersheetRefUpdate( globalLabel ); } } } @@ -1250,7 +1256,6 @@ void SCHEMATIC::CleanUp( SCH_COMMIT* aCommit, SCH_SCREEN* aScreen ) void SCHEMATIC::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, TOOL_MANAGER* aToolManager, - const std::function& aIntersheetRefItemCallback, PROGRESS_REPORTER* aProgressReporter, KIGFX::SCH_VIEW* aSchView, std::function* aChangedItemHandler, @@ -1280,7 +1285,7 @@ void SCHEMATIC::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS a wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() ); if( settings.m_IntersheetRefsShow ) - RecomputeIntersheetRefs( aIntersheetRefItemCallback ); + RecomputeIntersheetRefs(); if( !ADVANCED_CFG::GetCfg().m_IncrementalConnectivity || aCleanupFlags == GLOBAL_CLEANUP diff --git a/eeschema/schematic.h b/eeschema/schematic.h index 96067a6bcb..3b57032c52 100644 --- a/eeschema/schematic.h +++ b/eeschema/schematic.h @@ -253,7 +253,7 @@ public: * Update the schematic's page reference map for all global labels, and refresh the labels * so that they are redrawn with up-to-date references. */ - void RecomputeIntersheetRefs( const std::function& aItemCallback ); + void RecomputeIntersheetRefs(); /** * Clear operating points from a .op simulation. @@ -416,7 +416,6 @@ public: */ void RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, TOOL_MANAGER* aToolManager, - const std::function& aIntersheetRefItemCallback, PROGRESS_REPORTER* aProgressReporter = nullptr, KIGFX::SCH_VIEW* aSchView = nullptr, std::function* aChangedItemHandler = nullptr, diff --git a/eeschema/schematic_holder.h b/eeschema/schematic_holder.h index 2f869024c7..918af25519 100644 --- a/eeschema/schematic_holder.h +++ b/eeschema/schematic_holder.h @@ -22,6 +22,7 @@ class EDA_ITEM; class SCH_SCREEN; class SCH_SELECTION_TOOL; +class SCH_GLOBALLABEL; /** * This is a bridge class to help the schematic be able to affect SCH_EDIT_FRAME @@ -42,4 +43,6 @@ public: virtual SCH_SELECTION_TOOL* GetSelectionTool() { return nullptr; } virtual void RemoveFromScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen ) = 0; + + virtual void IntersheetRefUpdate( SCH_GLOBALLABEL* aItem ) {} }; \ No newline at end of file