From 2b0b7a5153273630263a9d77b98c792b497a1703 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 13 Aug 2020 22:30:30 +0100 Subject: [PATCH] Clear pin net-name-driving cache when changing annotation. Also update connectivity after clear annotation, annotate or back annotate. Also update status bar for highlighted nets. Fixes https://gitlab.com/kicad/code/kicad/issues/5170 --- common/advanced_config.cpp | 2 +- eeschema/annotate.cpp | 6 ++++++ .../dialogs/dialog_edit_component_in_schematic.cpp | 5 +++++ eeschema/sch_component.cpp | 6 ++++++ eeschema/sch_edit_frame.cpp | 14 ++++++++++++++ eeschema/sch_edit_frame.h | 2 ++ eeschema/sch_pin.cpp | 11 +++++++++++ eeschema/sch_pin.h | 1 + eeschema/tools/backannotate.cpp | 6 ++++++ eeschema/tools/ee_inspection_tool.cpp | 3 +++ eeschema/tools/sch_edit_tool.cpp | 4 +++- eeschema/tools/sch_editor_control.cpp | 4 ++-- 12 files changed, 60 insertions(+), 4 deletions(-) diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index cde700ae2d..4631763989 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -230,7 +230,7 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) std::vector configParams; configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::RealtimeConnectivity, - &m_realTimeConnectivity, false ) ); + &m_realTimeConnectivity, true ) ); configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::ExtraFillMargin, &m_extraClearance, 0.002, 0.0, 1.0 ) ); diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 5493e6d012..3f4ca46232 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -94,6 +94,9 @@ void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly, bool* aAppendUndo SyncView(); GetCanvas()->Refresh(); OnModify(); + + // Must go after OnModify() so the connectivity graph has been updated + UpdateNetHighlightStatus(); } @@ -255,6 +258,9 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, SyncView(); GetCanvas()->Refresh(); OnModify(); + + // Must go after OnModify() so the connectivity graph has been updated + UpdateNetHighlightStatus(); } diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index ce8dc1e59c..ba5b7c8feb 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include #ifdef KICAD_SPICE #include @@ -535,6 +537,9 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() GetParent()->UpdateItem( m_cmp ); GetParent()->OnModify(); + // This must go after OnModify() so that the connectivity graph will have been updated. + GetParent()->GetToolManager()->PostEvent( EVENTS::SelectedItemsModified ); + return true; } diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 88aff98da0..637ddcbd19 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -483,6 +483,9 @@ void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref ) if( notInArray ) AddHierarchicalReference( path, ref, m_unit ); + for( std::unique_ptr& pin : m_pins ) + pin->ClearDefaultNetName( sheet ); + SCH_FIELD* rf = GetField( REFERENCE ); // @todo Should we really be checking for what is a "reasonable" position? @@ -871,6 +874,9 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath ) instance.m_Reference = defRef; } + for( std::unique_ptr& pin : m_pins ) + pin->ClearDefaultNetName( aSheetPath ); + // These 2 changes do not work in complex hierarchy. // When a clear annotation is made, the calling function must call a // UpdateAllScreenReferences for the active sheet. diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 0184e48075..22117755fc 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1085,6 +1085,20 @@ void SCH_EDIT_FRAME::ShowChangedLanguage() } +void SCH_EDIT_FRAME::UpdateNetHighlightStatus() +{ + if( const SCH_CONNECTION* conn = GetHighlightedConnection() ) + { + SetStatusText( wxString::Format( _( "Highlighted net: %s" ), + UnescapeString( conn->Name() ) ) ); + } + else + { + SetStatusText( wxT( "" ) ); + } +} + + void SCH_EDIT_FRAME::SetScreen( BASE_SCREEN* aScreen ) { SCH_BASE_FRAME::SetScreen( aScreen ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 176021742f..e6fc9b3c33 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -939,6 +939,8 @@ public: */ void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override; + void UpdateNetHighlightStatus(); + void ShowChangedLanguage() override; void SyncToolbars() override; diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 151a2f3454..9802372493 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -98,6 +98,17 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) } +void SCH_PIN::ClearDefaultNetName( const SCH_SHEET_PATH* aPath ) +{ + std::lock_guard lock( m_netmap_mutex ); + + if( aPath ) + m_net_name_map.erase( *aPath ); + else + m_net_name_map.clear(); +} + + wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH aPath ) { if( m_libPin->IsPowerConnection() ) diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index ca6a1129ea..90c0cb71e9 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -64,6 +64,7 @@ public: LIB_PIN* GetLibPin() const { return m_libPin; } + void ClearDefaultNetName( const SCH_SHEET_PATH* aPath ); wxString GetDefaultNetName( const SCH_SHEET_PATH aPath ); wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/eeschema/tools/backannotate.cpp b/eeschema/tools/backannotate.cpp index fd45d647c7..8847ff8f0c 100644 --- a/eeschema/tools/backannotate.cpp +++ b/eeschema/tools/backannotate.cpp @@ -468,6 +468,12 @@ void BACK_ANNOTATE::applyChangelist() } } + if( !m_dryRun ) + { + m_frame->RecalculateConnections( NO_CLEANUP ); + m_frame->UpdateNetHighlightStatus(); + } + m_reporter.ReportHead( msg, RPT_SEVERITY_INFO ); } diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index 8e185fb887..26d037555b 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -310,6 +310,9 @@ int EE_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) m_frame->ClearMsgPanel(); } + if( SCH_EDIT_FRAME* editFrame = dynamic_cast( m_frame ) ) + editFrame->UpdateNetHighlightStatus(); + return 0; } diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 1ee052afae..77a75fcb0b 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -1141,9 +1141,11 @@ void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField ) if( m_frame->eeconfig()->m_AutoplaceFields.enable || aField->GetParent()->Type() == SCH_SHEET_T ) static_cast( aField->GetParent() )->AutoAutoplaceFields( m_frame->GetScreen() ); - m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); m_frame->UpdateItem( aField ); m_frame->OnModify(); + + // This must go after OnModify() so that the connectivity graph will have been updated. + m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); } diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 6b12c03cf1..f741971f39 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -870,11 +870,11 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition ) else { editFrame->SetCrossProbeConnection( conn ); - editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ), - UnescapeString( conn->Name() ) ) ); } editFrame->SetHighlightedConnection( conn ); + editFrame->UpdateNetHighlightStatus(); + TOOL_EVENT dummy; editorControl->UpdateNetHighlighting( dummy );