Eeschema: fix assigning netclass to buses

Buses with at least one member can use assign netclass functionality to
set all members to that netclass.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8743
This commit is contained in:
Mike Williams 2021-07-26 11:20:45 -04:00 committed by Roberto Fernandez Bautista
parent 43cb710297
commit 2c766bdb2b
1 changed files with 44 additions and 19 deletions

View File

@ -922,17 +922,39 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
if( conn )
{
if( !conn->Driver() || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() )
< CONNECTION_SUBGRAPH::PRIORITY::SHEET_PIN )
if( !conn->IsBus()
&& ( !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 must have at least one member to assign a netclass to members." ) );
highlightNet( m_toolMgr, CLEAR );
return 0;
}
wxArrayString netNames;
if( conn->IsBus() )
{
for( auto& m : conn->Members() )
{
netNames.Add( m->Name() );
}
}
else
{
netNames.Add( conn->Name() );
}
wxString netName = conn->Name();
NET_SETTINGS& netSettings = m_frame->Schematic().Prj().GetProjectFile().NetSettings();
wxString netclassName = netSettings.GetNetclassName( netName );
wxString netclassName = netSettings.GetNetclassName( netNames.front() );
wxArrayString headers;
std::vector<wxArrayString> items;
@ -957,6 +979,8 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
{
netclassName = dlg.GetTextSelection();
for( auto& netName : netNames )
{
// Remove from old netclass membership list
if( netSettings.m_NetClassAssignments.count( netName ) )
{
@ -977,6 +1001,7 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
netSettings.ResolveNetClassAssignments();
}
}
}
highlightNet( m_toolMgr, CLEAR );
return 0;