Fix selection/highlighting of Default netclass

This commit is contained in:
Jon Evans 2020-08-18 22:19:25 -04:00
parent 744a8f011e
commit a36d30656f
1 changed files with 42 additions and 28 deletions

View File

@ -1890,6 +1890,24 @@ void APPEARANCE_CONTROLS::onNetclassContextMenu( wxCommandEvent& aEvent )
APPEARANCE_SETTING* setting = m_netclassSettingsMap.count( m_contextMenuNetclass ) ?
m_netclassSettingsMap.at( m_contextMenuNetclass ) : nullptr;
NETCLASSPTR defaultClass = classes.GetDefault();
auto runOnNetsOfClass =
[&]( NETCLASSPTR aClass, std::function<void( NETINFO_ITEM* )> aFunction )
{
if( aClass == defaultClass )
{
for( NETINFO_ITEM* net : nets )
if( net->GetNetClass() == defaultClass.get() )
aFunction( net );
}
else
{
for( const wxString& netName : *aClass )
aFunction( nets.GetNetItem( netName ) );
}
};
switch( aEvent.GetId() )
{
case ID_SET_NET_COLOR:
@ -1919,13 +1937,11 @@ void APPEARANCE_CONTROLS::onNetclassContextMenu( wxCommandEvent& aEvent )
{
if( netclass )
{
bool first = true;
for( const wxString& member : *netclass )
runOnNetsOfClass( netclass,
[&]( NETINFO_ITEM* aItem )
{
if( NETINFO_ITEM* net = nets.GetNetItem( member ) )
{
int code = net->GetNet();
static bool first = true;
int code = aItem->GetNet();
if( first )
{
@ -1938,8 +1954,7 @@ void APPEARANCE_CONTROLS::onNetclassContextMenu( wxCommandEvent& aEvent )
board->SetHighLightNet( code, true );
rs->SetHighlight( true, code, true );
}
}
}
} );
view->UpdateAllLayersColor();
board->HighLightON();
@ -1951,14 +1966,13 @@ void APPEARANCE_CONTROLS::onNetclassContextMenu( wxCommandEvent& aEvent )
{
if( netclass )
{
for( const wxString& member : *netclass )
runOnNetsOfClass( netclass,
[&]( NETINFO_ITEM* aItem )
{
if( NETINFO_ITEM* net = nets.GetNetItem( member ) )
{
int code = net->GetNet();
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectNet, true, code );
}
}
int code = aItem->GetNet();
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectNet, true,
code );
} );
}
break;
}