From 71215bcab3087d6698ad1588e0392b18359bb2d9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 3 Jan 2021 21:14:44 +0000 Subject: [PATCH] Make sure TH pads get collision layer highlighted. Also cleans it up to centralise all the decision-making. Fixes https://gitlab.com/kicad/code/kicad/issues/6925 --- pcbnew/router/pns_kicad_iface.cpp | 5 +---- pcbnew/router/pns_kicad_iface.h | 6 ++---- pcbnew/router/pns_router.cpp | 28 +++++++++++++++++++++------ pcbnew/router/pns_router.h | 3 +-- pcbnew/router/router_preview_item.cpp | 8 ++------ pcbnew/router/router_preview_item.h | 2 -- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index a5af4a3ffa..674d2d81ac 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1337,15 +1337,12 @@ void PNS_KICAD_IFACE_BASE::SetDebugDecorator( PNS::DEBUG_DECORATOR *aDec ) m_debugDecorator = aDec; } -void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClearance, bool aEdit ) +void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit ) { wxLogTrace( "PNS", "DisplayItem %p", aItem ); ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view ); - if( aColor >= 0 ) - pitem->SetColor( KIGFX::COLOR4D( aColor ) ); - if( aClearance >= 0 ) { pitem->SetClearance( aClearance ); diff --git a/pcbnew/router/pns_kicad_iface.h b/pcbnew/router/pns_kicad_iface.h index 88433abdd7..cae30f2203 100644 --- a/pcbnew/router/pns_kicad_iface.h +++ b/pcbnew/router/pns_kicad_iface.h @@ -59,8 +59,7 @@ public: bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override { return true; }; bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; } void HideItem( PNS::ITEM* aItem ) override {} - void DisplayItem( const PNS::ITEM* aItem, int aColor = 0, int aClearance = 0, - bool aEdit = false ) override {} + void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false ) override {} void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor = -1 ) override {} void AddItem( PNS::ITEM* aItem ) override; void RemoveItem( PNS::ITEM* aItem ) override; @@ -117,8 +116,7 @@ public: bool IsItemVisible( const PNS::ITEM* aItem ) const override; bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override; void HideItem( PNS::ITEM* aItem ) override; - void DisplayItem( const PNS::ITEM* aItem, int aColor = 0, int aClearance = 0, - bool aEdit = false ) override; + void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false ) override; void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor = -1 ) override; void Commit() override; void AddItem( PNS::ITEM* aItem ) override; diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 1724d1606c..aae90d1570 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -294,16 +294,32 @@ void ROUTER::markViolations( NODE* aNode, ITEM_SET& aCurrent, NODE::ITEM_VECTOR& { std::unique_ptr tmp( itemToMark->Clone() ); int clearance; + bool removeOriginal = true; if( itemToMark->Marker() & MK_HOLE ) clearance = aNode->GetHoleClearance( currentItem, itemToMark ); else clearance = aNode->GetClearance( currentItem, itemToMark ); - m_iface->DisplayItem( tmp.get(), -1, clearance ); + if( itemToMark->Layers().IsMultilayer() && !currentItem->Layers().IsMultilayer() ) + itemToMark->SetLayer( currentItem->Layer() ); - // Remove the obstacle itself from the view unless we're just marking its hole - if( !(itemToMark->Marker() & MK_HOLE ) ) + if( itemToMark->Kind() == ITEM::SOLID_T ) + { + if( ( itemToMark->Marker() & PNS::MK_HOLE ) + || !m_iface->IsFlashedOnLayer( itemToMark, itemToMark->Layer() ) ) + { + SOLID* solid = static_cast( tmp.get() ); + solid->SetShape( solid->Hole()->Clone() ); + + // Leave the pad flashing around the highlighted hole + removeOriginal = false; + } + } + + m_iface->DisplayItem( tmp.get(), clearance ); + + if( removeOriginal ) aRemoved.push_back( itemToMark ); }; @@ -358,7 +374,7 @@ void ROUTER::updateView( NODE* aNode, ITEM_SET& aCurrent, bool aDragging ) for( ITEM* item : added ) { int clearance = GetRuleResolver()->Clearance( item, nullptr ); - m_iface->DisplayItem( item, -1, clearance, aDragging ); + m_iface->DisplayItem( item, clearance, aDragging ); } for( ITEM* item : removed ) @@ -391,7 +407,7 @@ void ROUTER::movePlacing( const VECTOR2I& aP, ITEM* aEndItem ) const LINE* l = static_cast( item ); int clearance = GetRuleResolver()->Clearance( item, nullptr ); - m_iface->DisplayItem( l, -1, clearance ); + m_iface->DisplayItem( l, clearance ); if( l->EndsWithVia() ) { @@ -402,7 +418,7 @@ void ROUTER::movePlacing( const VECTOR2I& aP, ITEM* aEndItem ) if( holeClearance + via.Drill() / 2 > viaClearance + via.Diameter() / 2 ) viaClearance = holeClearance + via.Drill() / 2 - via.Diameter() / 2; - m_iface->DisplayItem( &l->Via(), -1, viaClearance ); + m_iface->DisplayItem( &l->Via(), viaClearance ); } } diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index 5331333818..f89116e7fd 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -101,8 +101,7 @@ enum DRAG_MODE virtual bool IsAnyLayerVisible( const LAYER_RANGE& aLayer ) const = 0; virtual bool IsItemVisible( const PNS::ITEM* aItem ) const = 0; virtual bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const = 0; - virtual void DisplayItem( const ITEM* aItem, int aColor = -1, int aClearance = -1, - bool aEdit = false ) = 0; + virtual void DisplayItem( const ITEM* aItem, int aClearance, bool aEdit = false ) = 0; virtual void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor = -1 ) = 0; virtual void HideItem( ITEM* aItem ) = 0; virtual void Commit() = 0; diff --git a/pcbnew/router/router_preview_item.cpp b/pcbnew/router/router_preview_item.cpp index 4dbfb23c3f..750a9c6d3e 100644 --- a/pcbnew/router/router_preview_item.cpp +++ b/pcbnew/router/router_preview_item.cpp @@ -42,7 +42,8 @@ ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem, KIGFX::VIEW* a { m_view = aView; - m_shape = NULL; + m_shape = aItem ? aItem->Shape()->Clone() : nullptr; + m_clearance = -1; m_originLayer = m_layer = LAYER_SELECT_OVERLAY ; @@ -86,11 +87,6 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS::ITEM* aItem ) m_color.a = 0.8; m_depth = BaseOverlayDepth - aItem->Layers().Start(); - if( ( aItem->Marker() & PNS::MK_HOLE ) && aItem->Kind() == PNS::ITEM::SOLID_T && aItem->Hole() ) - m_shape = aItem->Hole()->Clone(); - else - m_shape = aItem->Shape()->Clone(); - switch( aItem->Kind() ) { case PNS::ITEM::LINE_T: diff --git a/pcbnew/router/router_preview_item.h b/pcbnew/router/router_preview_item.h index 9960a6d815..e639c84c27 100644 --- a/pcbnew/router/router_preview_item.h +++ b/pcbnew/router/router_preview_item.h @@ -61,8 +61,6 @@ public: void Update( const PNS::ITEM* aItem ); - void StuckMarker( VECTOR2I& aPosition ); - void Line( const SHAPE_LINE_CHAIN& aLine, int aWidth = 0, int aStyle = 0 ); void Box( const BOX2I& aBox, int aStyle = 0 ); void Point ( const VECTOR2I& aPos, int aStyle = 0);