From c089afb408e3081f0a30f532cadc5da1e26b45cd Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 1 Oct 2022 22:57:32 +0100 Subject: [PATCH] Improve default net pattern to be all members of bus instead of first member. Fixes https://gitlab.com/kicad/code/kicad/issues/12546 --- eeschema/tools/sch_editor_control.cpp | 52 +++++++++++++-------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 136ea53498..a98cb8c943 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -1235,37 +1235,28 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent ) if( conn ) { - if( !conn->IsBus() - && ( !conn->Driver() - || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() ) - < CONNECTION_SUBGRAPH::PRIORITY::SHEET_PIN ) ) + wxString netName = conn->Name(); + + if( conn->IsBus() ) + { + wxString prefix; + + if( NET_SETTINGS::ParseBusVector( netName, &prefix, nullptr ) ) + { + netName = prefix + wxT( "*" ); + } + else if( NET_SETTINGS::ParseBusGroup( netName, &prefix, nullptr ) ) + { + netName = prefix + wxT( ".*" ); + } + } + else if( !conn->Driver() || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() ) + < CONNECTION_SUBGRAPH::PRIORITY::SHEET_PIN ) { m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) ); highlightNet( m_toolMgr, CLEAR ); return 0; } - else if( conn->IsBus() && conn->Members().size() == 0 ) - { - m_frame->ShowInfoBarError( _( "Bus has no members to assign netclass to." ) ); - highlightNet( m_toolMgr, CLEAR ); - return 0; - } - - wxString netName; - - if( conn->IsBus() && conn->Members().size() ) - { - const std::shared_ptr& member = conn->Members()[0]; - - if( member->IsBus() && member->Members().size() ) - netName = member->Members()[0]->Name(); - else - netName = member->Name(); - } - else - { - netName = conn->Name(); - } DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, schematic.GetNetClassAssignmentCandidates(), [&]( const std::vector& aNetNames ) @@ -1325,7 +1316,14 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent ) m_frame->GetCanvas()->ForceRefresh(); } ); - dlg.ShowModal(); + if( dlg.ShowModal() ) + { + getView()->UpdateAllItemsConditionally( KIGFX::REPAINT, + []( KIGFX::VIEW_ITEM* aItem ) -> bool + { + return dynamic_cast( aItem ); + } ); + } } highlightNet( m_toolMgr, CLEAR );