Fix visibility control for Default netclass

This commit is contained in:
Jon Evans 2020-08-16 15:41:35 -04:00
parent afc94fdec3
commit 126565cbed
1 changed files with 37 additions and 15 deletions

View File

@ -1749,27 +1749,49 @@ void APPEARANCE_CONTROLS::onNetclassVisibilityChanged( wxCommandEvent& aEvent )
void APPEARANCE_CONTROLS::showNetclass( const wxString& aClassName, bool aShow )
{
BOARD* board = m_frame->GetBoard();
NETINFO_LIST& nets = board->GetNetInfo();
NETCLASSES& classes = board->GetDesignSettings().GetNetClasses();
NETCLASSPTR netclass = classes.Find( aClassName );
TOOL_MANAGER* manager = m_frame->GetToolManager();
if( !netclass )
return;
NETINFO_LIST& nets = board->GetNetInfo();
TOOL_MANAGER* manager = m_frame->GetToolManager();
NETCLASS* defaultClass = classes.GetDefaultPtr();
auto updateWidget =
[&]( int aCode )
{
if( m_netSettingsMap.count( aCode ) )
{
APPEARANCE_SETTING* setting = m_netSettingsMap.at( aCode );
setting->ctl_visibility->SetValue( aShow );
}
};
if( netclass == classes.GetDefault() )
{
const TOOL_ACTION& action = aShow ? PCB_ACTIONS::showNet : PCB_ACTIONS::hideNet;
for( NETINFO_ITEM* net : nets )
{
if( net->GetNetClass() == defaultClass )
{
manager->RunAction( action, true, net->GetNet() );
updateWidget( net->GetNet() );
}
}
}
else
{
const TOOL_ACTION& action = aShow ? PCB_ACTIONS::showNet : PCB_ACTIONS::hideNet;
for( const wxString& member : *netclass )
{
int code = nets.GetNetItem( member )->GetNet();
if( m_netSettingsMap.count( code ) )
{
APPEARANCE_SETTING* setting = m_netSettingsMap.at( code );
setting->ctl_visibility->SetValue( aShow );
}
const TOOL_ACTION& action = aShow ? PCB_ACTIONS::showNet : PCB_ACTIONS::hideNet;
manager->RunAction( action, true, code );
updateWidget( code );
}
}
}