Fix rendering of net colors on items
This commit is contained in:
parent
beab35472b
commit
0db00046d1
|
@ -943,6 +943,27 @@ inline bool IsDCodeLayer( int aLayer )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the given layer is "net copper", meaning it is eligible for net coloring
|
||||
* @param aLayer is the layer to test
|
||||
* @return true if the layer is one that participates in net coloring
|
||||
*/
|
||||
inline bool IsNetCopperLayer( LAYER_NUM aLayer )
|
||||
{
|
||||
static std::set<LAYER_NUM> netCopperLayers =
|
||||
{
|
||||
LAYER_PAD_FR,
|
||||
LAYER_PAD_BK,
|
||||
LAYER_PADS_TH,
|
||||
LAYER_VIA_THROUGH,
|
||||
LAYER_VIA_BBLIND,
|
||||
LAYER_VIA_MICROVIA
|
||||
};
|
||||
|
||||
return IsCopperLayer( aLayer ) || netCopperLayers.count( aLayer );
|
||||
}
|
||||
|
||||
|
||||
PCB_LAYER_ID ToLAYER_ID( int aLayer );
|
||||
|
||||
#endif // LAYERS_ID_AND_VISIBILITY_H_
|
||||
|
|
|
@ -267,22 +267,34 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
|
|||
netCode = conItem->GetNetCode();
|
||||
|
||||
// Apply net color overrides
|
||||
if( conItem && m_netColorMode == NET_COLOR_MODE::ALL )
|
||||
if( conItem && m_netColorMode == NET_COLOR_MODE::ALL && IsNetCopperLayer( aLayer ) )
|
||||
{
|
||||
if( m_netColors.count( conItem->GetNetCode() ) )
|
||||
color = m_netColors.at( conItem->GetNetCode() );
|
||||
if( m_netColors.count( netCode ) )
|
||||
color = m_netColors.at( netCode );
|
||||
else if( m_netclassColors.count( conItem->GetNetClassName() ) )
|
||||
color = m_netclassColors.at( conItem->GetNetClassName() );
|
||||
|
||||
if( item->IsSelected() )
|
||||
color.Brighten( m_selectFactor );
|
||||
else if( m_highlightEnabled && m_highlightNetcodes.count( netCode ) )
|
||||
color.Brighten( m_highlightFactor );
|
||||
else if( m_highlightEnabled )
|
||||
color.Darken( 1.0 - m_highlightFactor );
|
||||
else if( m_contrastModeDisplay == HIGH_CONTRAST_MODE::DIMMED
|
||||
&& m_activeLayers.count( aLayer ) == 0 )
|
||||
color.Mix( m_layerColors[LAYER_PCB_BACKGROUND], m_hiContrastFactor );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Single net highlight mode
|
||||
if( m_highlightEnabled )
|
||||
color = m_highlightNetcodes.count( netCode ) ? m_layerColorsHi[aLayer]
|
||||
: m_layerColorsDark[aLayer];
|
||||
|
||||
// Single net highlight mode
|
||||
if( m_highlightEnabled )
|
||||
color = m_highlightNetcodes.count( netCode ) ? m_layerColorsHi[aLayer]
|
||||
: m_layerColorsDark[aLayer];
|
||||
|
||||
// Return grayish color for non-highlighted layers in the dimmed high contrast mode
|
||||
if( m_contrastModeDisplay == HIGH_CONTRAST_MODE::DIMMED && m_activeLayers.count( aLayer ) == 0 )
|
||||
color = m_hiContrastColor[aLayer];
|
||||
// Return grayish color for non-highlighted layers in the dimmed high contrast mode
|
||||
if( m_contrastModeDisplay == HIGH_CONTRAST_MODE::DIMMED && m_activeLayers.count( aLayer ) == 0 )
|
||||
color = m_hiContrastColor[aLayer];
|
||||
}
|
||||
|
||||
// For vias, some layers depend on other layers in high contrast mode
|
||||
if( m_hiContrastEnabled && item->Type() == PCB_VIA_T &&
|
||||
|
|
|
@ -121,6 +121,9 @@ bool PCB_EDIT_FRAME::LoadProjectSettings()
|
|||
|
||||
for( const auto& pair : netSettings.m_PcbNetColors )
|
||||
{
|
||||
if( pair.second == COLOR4D::UNSPECIFIED )
|
||||
continue;
|
||||
|
||||
if( NETINFO_ITEM* net = nets.GetNetItem( pair.first ) )
|
||||
netColors[net->GetNet()] = pair.second;
|
||||
}
|
||||
|
@ -216,6 +219,9 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
|
|||
|
||||
for( const auto& pair : rs->GetNetColorMap() )
|
||||
{
|
||||
if( pair.second == COLOR4D::UNSPECIFIED )
|
||||
continue;
|
||||
|
||||
if( NETINFO_ITEM* net = nets.GetNetItem( pair.first ) )
|
||||
netSettings.m_PcbNetColors[net->GetNetname()] = pair.second;
|
||||
}
|
||||
|
@ -225,7 +231,8 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
|
|||
// NOTE: this assumes netclasses will have already been updated, which I think is the case
|
||||
for( const auto& pair : netSettings.m_NetClasses )
|
||||
{
|
||||
if( netclassColors.count( pair.first ) )
|
||||
if( netclassColors.count( pair.first )
|
||||
&& netclassColors.at( pair.first ) != COLOR4D::UNSPECIFIED )
|
||||
pair.second->SetPcbColor( netclassColors.at( pair.first ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -1201,6 +1201,8 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
|||
if( s->GetSwatchColor() == COLOR4D::UNSPECIFIED )
|
||||
s->Hide();
|
||||
|
||||
m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
|
||||
|
||||
m_frame->GetCanvas()->RedrawRatsnest();
|
||||
m_frame->GetCanvas()->Refresh();
|
||||
} );
|
||||
|
@ -1658,6 +1660,9 @@ void APPEARANCE_CONTROLS::onNetContextMenu( wxCommandEvent& aEvent )
|
|||
netColors[m_contextMenuNetCode] = color;
|
||||
else
|
||||
netColors.erase( m_contextMenuNetCode );
|
||||
|
||||
m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
|
||||
m_frame->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1761,6 +1766,7 @@ void APPEARANCE_CONTROLS::onNetclassColorChanged( wxCommandEvent& aEvent )
|
|||
if( swatch->GetSwatchColor() == COLOR4D::UNSPECIFIED )
|
||||
swatch->Hide();
|
||||
|
||||
m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
|
||||
m_frame->GetCanvas()->RedrawRatsnest();
|
||||
m_frame->GetCanvas()->Refresh();
|
||||
}
|
||||
|
@ -1788,6 +1794,7 @@ void APPEARANCE_CONTROLS::onNetColorModeChanged( wxCommandEvent& aEvent )
|
|||
options.m_NetColorMode = NET_COLOR_MODE::OFF;
|
||||
|
||||
m_frame->SetDisplayOptions( options );
|
||||
m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1823,6 +1830,8 @@ void APPEARANCE_CONTROLS::onNetclassContextMenu( wxCommandEvent& aEvent )
|
|||
netclassColors[m_contextMenuNetclass] = color;
|
||||
else
|
||||
netclassColors.erase( m_contextMenuNetclass );
|
||||
|
||||
view->UpdateAllLayersColor();
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue