From db1d3ea710f060490432dd1bae41f8238d451dbc Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 27 Sep 2020 21:32:42 +0100 Subject: [PATCH] Update track, via and pad clearances for the current layer. Fixes https://gitlab.com/kicad/code/kicad/issues/5797 --- pcbnew/pcb_edit_frame.cpp | 23 ++++++++++++++++++++++- pcbnew/pcb_painter.cpp | 10 +++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 2a2d29df83..be5a5990eb 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1012,8 +1012,29 @@ void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer ) m_appearancePanel->OnLayerChanged(); m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools - GetCanvas()->SetFocus(); // allow capture of hotkeys + GetCanvas()->SetFocus(); // allow capture of hotkeys GetCanvas()->SetHighContrastLayer( aLayer ); + + // Clearances could be layer-dependent so redraw them when the active layer is changed + if( GetDisplayOptions().m_DisplayPadIsol ) + { + GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT, + []( KIGFX::VIEW_ITEM* aItem ) -> bool + { + return dynamic_cast( aItem ) != nullptr; + }); + } + + // Clearances could be layer-dependent so redraw them when the active layer is changed + if( GetDisplayOptions().m_ShowTrackClearanceMode == PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_ALWAYS ) + { + GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT, + []( KIGFX::VIEW_ITEM* aItem ) -> bool + { + return dynamic_cast( aItem ) != nullptr; + }); + } + GetCanvas()->Refresh(); } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index e02c73a45f..06be5b3f57 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -529,12 +529,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer ) if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags ) { - int clearance; - - if( m_pcbSettings.m_hiContrastEnabled ) - clearance = aTrack->GetClearance( m_pcbSettings.GetActiveLayer() ); - else - clearance = aTrack->GetClearance( ToLAYER_ID( aLayer ) ); + int clearance = aTrack->GetClearance( m_pcbSettings.GetActiveLayer() ); m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); m_gal->SetIsFill( false ); @@ -941,7 +936,8 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) m_gal->SetIsStroke( true ); m_gal->SetIsFill( false ); m_gal->SetStrokeColor( color ); - int clearance = aPad->GetClearance( aPad->GetLayer() ); + + int clearance = aPad->GetClearance( m_pcbSettings.GetActiveLayer() ); const std::shared_ptr shapes = std::dynamic_pointer_cast( aPad->GetEffectiveShape() );