Fix various rendering issues with non-through vias
Correctly hide netnames in high contrast mode Correct highlighting for blind/buried/micro via drills Repaint vias when needed to support stacked microvias Fixes https://gitlab.com/kicad/code/kicad/-/issues/2593
This commit is contained in:
parent
2abce40553
commit
cb4ef5a619
|
@ -755,6 +755,7 @@ void PCB_BASE_FRAME::ActivateGalCanvas()
|
||||||
|
|
||||||
void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions )
|
void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions )
|
||||||
{
|
{
|
||||||
|
bool hcChanged = m_displayOptions.m_ContrastModeDisplay != aOptions.m_ContrastModeDisplay;
|
||||||
m_displayOptions = aOptions;
|
m_displayOptions = aOptions;
|
||||||
|
|
||||||
EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
|
EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
|
||||||
|
@ -764,5 +765,19 @@ void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions )
|
||||||
canvas->SetHighContrastLayer( GetActiveLayer() );
|
canvas->SetHighContrastLayer( GetActiveLayer() );
|
||||||
OnDisplayOptionsChanged();
|
OnDisplayOptionsChanged();
|
||||||
|
|
||||||
|
// Vias on a restricted layer set must be redrawn when high contrast mode is changed
|
||||||
|
if( hcChanged )
|
||||||
|
{
|
||||||
|
GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||||
|
[]( KIGFX::VIEW_ITEM* aItem ) -> bool
|
||||||
|
{
|
||||||
|
if( VIA* via = dynamic_cast<VIA*>( aItem ) )
|
||||||
|
return ( via->GetViaType() == VIATYPE::BLIND_BURIED ||
|
||||||
|
via->GetViaType() == VIATYPE::MICROVIA );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
canvas->Refresh();
|
canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -982,6 +982,17 @@ void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
|
||||||
GetCanvas()->SetFocus(); // allow capture of hotkeys
|
GetCanvas()->SetFocus(); // allow capture of hotkeys
|
||||||
GetCanvas()->SetHighContrastLayer( aLayer );
|
GetCanvas()->SetHighContrastLayer( aLayer );
|
||||||
|
|
||||||
|
// Vias on a restricted layer set must be redrawn when the active layer is changed
|
||||||
|
GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||||
|
[]( KIGFX::VIEW_ITEM* aItem ) -> bool
|
||||||
|
{
|
||||||
|
if( VIA* via = dynamic_cast<VIA*>( aItem ) )
|
||||||
|
return ( via->GetViaType() == VIATYPE::BLIND_BURIED ||
|
||||||
|
via->GetViaType() == VIATYPE::MICROVIA );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} );
|
||||||
|
|
||||||
// Clearances could be layer-dependent so redraw them when the active layer is changed
|
// Clearances could be layer-dependent so redraw them when the active layer is changed
|
||||||
if( GetDisplayOptions().m_DisplayPadIsol )
|
if( GetDisplayOptions().m_DisplayPadIsol )
|
||||||
{
|
{
|
||||||
|
|
|
@ -320,7 +320,8 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
|
||||||
( aLayer == LAYER_VIAS_HOLES ||
|
( aLayer == LAYER_VIAS_HOLES ||
|
||||||
aLayer == LAYER_VIA_THROUGH ||
|
aLayer == LAYER_VIA_THROUGH ||
|
||||||
aLayer == LAYER_VIA_MICROVIA ||
|
aLayer == LAYER_VIA_MICROVIA ||
|
||||||
aLayer == LAYER_VIA_BBLIND ) )
|
aLayer == LAYER_VIA_BBLIND ||
|
||||||
|
aLayer == LAYER_VIAS_NETNAMES ) )
|
||||||
{
|
{
|
||||||
const VIA* via = static_cast<const VIA*>( item );
|
const VIA* via = static_cast<const VIA*>( item );
|
||||||
const BOARD* pcb = static_cast<const BOARD*>( item->GetParent() );
|
const BOARD* pcb = static_cast<const BOARD*>( item->GetParent() );
|
||||||
|
@ -332,6 +333,9 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
|
||||||
viaActiveLayer |= via->IsOnLayer( lay_id ) && pcb->IsLayerVisible( lay_id );
|
viaActiveLayer |= via->IsOnLayer( lay_id ) && pcb->IsLayerVisible( lay_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !viaActiveLayer && m_contrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN )
|
||||||
|
return COLOR4D::CLEAR;
|
||||||
|
|
||||||
if( !viaActiveLayer )
|
if( !viaActiveLayer )
|
||||||
color.Darken( 1.0 - m_highlightFactor );
|
color.Darken( 1.0 - m_highlightFactor );
|
||||||
}
|
}
|
||||||
|
@ -592,9 +596,29 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
|
||||||
VECTOR2D position( center );
|
VECTOR2D position( center );
|
||||||
|
|
||||||
// Is anything that we can display enabled?
|
// Is anything that we can display enabled?
|
||||||
if( m_pcbSettings.m_netNamesOnVias )
|
if( !m_pcbSettings.m_netNamesOnVias || aVia->GetNetname().empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// We won't get CLEAR from GetColor below for a non-through via on an inactive layer in
|
||||||
|
// high contrast mode because LAYER_VIAS_NETNAMES will always be part of the high-contrast
|
||||||
|
// set. So we do another check here to prevent drawing netnames for these vias.
|
||||||
|
if( m_pcbSettings.GetHighContrast() )
|
||||||
{
|
{
|
||||||
bool displayNetname = ( !aVia->GetNetname().empty() );
|
bool draw = false;
|
||||||
|
|
||||||
|
for( unsigned int layer : m_pcbSettings.GetHighContrastLayers() )
|
||||||
|
{
|
||||||
|
if( aVia->IsOnLayer( static_cast<PCB_LAYER_ID>( layer ) ) )
|
||||||
|
{
|
||||||
|
draw = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !draw )
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
|
double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
|
||||||
double size = aVia->GetWidth();
|
double size = aVia->GetWidth();
|
||||||
|
|
||||||
|
@ -612,8 +636,6 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
|
||||||
// Set the text position to the pad shape position (the pad position is not the best place)
|
// Set the text position to the pad shape position (the pad position is not the best place)
|
||||||
VECTOR2D textpos( 0.0, 0.0 );
|
VECTOR2D textpos( 0.0, 0.0 );
|
||||||
|
|
||||||
if( displayNetname )
|
|
||||||
{
|
|
||||||
wxString netname = UnescapeString( aVia->GetShortNetname() );
|
wxString netname = UnescapeString( aVia->GetShortNetname() );
|
||||||
// calculate the size of net name text:
|
// calculate the size of net name text:
|
||||||
double tsize = 1.5 * size / netname.Length();
|
double tsize = 1.5 * size / netname.Length();
|
||||||
|
@ -625,13 +647,9 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
|
||||||
m_gal->SetGlyphSize( namesize );
|
m_gal->SetGlyphSize( namesize );
|
||||||
m_gal->SetLineWidth( namesize.x / 12.0 );
|
m_gal->SetLineWidth( namesize.x / 12.0 );
|
||||||
m_gal->BitmapText( netname, textpos, 0.0 );
|
m_gal->BitmapText( netname, textpos, 0.0 );
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
m_gal->Restore();
|
m_gal->Restore();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Choose drawing settings depending on if we are drawing via's pad or hole
|
// Choose drawing settings depending on if we are drawing via's pad or hole
|
||||||
if( aLayer == LAYER_VIAS_HOLES )
|
if( aLayer == LAYER_VIAS_HOLES )
|
||||||
|
@ -647,6 +665,9 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
|
||||||
bool sketchMode = false;
|
bool sketchMode = false;
|
||||||
COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer );
|
COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer );
|
||||||
|
|
||||||
|
if( color == COLOR4D::CLEAR )
|
||||||
|
return;
|
||||||
|
|
||||||
switch( aVia->GetViaType() )
|
switch( aVia->GetViaType() )
|
||||||
{
|
{
|
||||||
case VIATYPE::THROUGH:
|
case VIATYPE::THROUGH:
|
||||||
|
|
|
@ -447,8 +447,6 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
|
||||||
opts.m_ContrastModeDisplay = aMode;
|
opts.m_ContrastModeDisplay = aMode;
|
||||||
|
|
||||||
m_frame->SetDisplayOptions( opts );
|
m_frame->SetDisplayOptions( opts );
|
||||||
m_frame->GetCanvas()->SetHighContrastLayer( m_frame->GetActiveLayer() );
|
|
||||||
m_frame->GetCanvas()->Refresh();
|
|
||||||
passOnFocus();
|
passOnFocus();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue