diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 20c2c6f195..f66b095237 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1092,7 +1092,7 @@ void PNS_KICAD_IFACE::EraseView() } -void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClearance ) +void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClearance, bool aEdit ) { wxLogTrace( "PNS", "DisplayItem %p", aItem ); @@ -1107,10 +1107,28 @@ void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClea if( m_dispOptions ) { - auto clearanceDisp = m_dispOptions->m_ShowTrackClearanceMode; - pitem->ShowTrackClearance( clearanceDisp != PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE ); - pitem->ShowViaClearance( clearanceDisp != PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE - && clearanceDisp != PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS ); + switch( m_dispOptions->m_ShowTrackClearanceMode ) + { + case PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE: + pitem->ShowTrackClearance( false ); + pitem->ShowViaClearance( false ); + break; + case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_ALWAYS: + case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS: + pitem->ShowTrackClearance( true ); + pitem->ShowViaClearance( true ); + break; + + case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS: + pitem->ShowTrackClearance( !aEdit ); + pitem->ShowViaClearance( !aEdit ); + break; + + case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS: + pitem->ShowTrackClearance( !aEdit ); + pitem->ShowViaClearance( false ); + break; + } } } diff --git a/pcbnew/router/pns_kicad_iface.h b/pcbnew/router/pns_kicad_iface.h index 6281257558..3eaa0a1340 100644 --- a/pcbnew/router/pns_kicad_iface.h +++ b/pcbnew/router/pns_kicad_iface.h @@ -53,7 +53,7 @@ public: void SyncWorld( PNS::NODE* aWorld ) override; void EraseView() override; void HideItem( PNS::ITEM* aItem ) override; - void DisplayItem( const PNS::ITEM* aItem, int aColor = 0, int aClearance = 0 ) override; + void DisplayItem( const PNS::ITEM* aItem, int aColor = 0, int aClearance = 0, bool aEdit = false ) override; void AddItem( PNS::ITEM* aItem ) override; void RemoveItem( PNS::ITEM* aItem ) override; void Commit() override; diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index b7b0466013..ad444db1a5 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -255,7 +255,7 @@ void ROUTER::moveDragging( const VECTOR2I& aP, ITEM* aEndItem ) m_dragger->Drag( aP ); ITEM_SET dragged = m_dragger->Traces(); - updateView( m_dragger->CurrentNode(), dragged ); + updateView( m_dragger->CurrentNode(), dragged, true ); } @@ -290,7 +290,7 @@ void ROUTER::markViolations( NODE* aNode, ITEM_SET& aCurrent, NODE::ITEM_VECTOR& } -void ROUTER::updateView( NODE* aNode, ITEM_SET& aCurrent ) +void ROUTER::updateView( NODE* aNode, ITEM_SET& aCurrent, bool aDragging ) { NODE::ITEM_VECTOR removed, added; NODE::OBSTACLES obstacles; @@ -304,7 +304,11 @@ void ROUTER::updateView( NODE* aNode, ITEM_SET& aCurrent ) aNode->GetUpdatedItems( removed, added ); for( auto item : added ) - m_iface->DisplayItem( item ); + { + int clearance = GetRuleResolver()->Clearance( item->Net() ); + + m_iface->DisplayItem( item, -1, clearance, aDragging ); + } for( auto item : removed ) m_iface->HideItem( item ); diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index d4047dae27..f5e90f54ee 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -93,7 +93,7 @@ enum DRAG_MODE virtual void SyncWorld( NODE* aNode ) = 0; virtual void AddItem( ITEM* aItem ) = 0; virtual void RemoveItem( ITEM* aItem ) = 0; - virtual void DisplayItem( const ITEM* aItem, int aColor = -1, int aClearance = -1 ) = 0; + virtual void DisplayItem( const ITEM* aItem, int aColor = -1, int aClearance = -1, bool aEdit = false ) = 0; virtual void HideItem( ITEM* aItem ) = 0; virtual void Commit() = 0; // virtual void Abort () = 0; @@ -147,7 +147,7 @@ public: void FlipPosture(); - void DisplayItem( const ITEM* aItem, int aColor = -1, int aClearance = -1 ); + void DisplayItem( const ITEM* aItem, int aColor = -1, int aClearance = -1, bool aEdit = false ); void DisplayItems( const ITEM_SET& aItems ); void DeleteTraces( ITEM* aStartItem, bool aWholeTrack ); void SwitchLayer( int layer ); @@ -225,7 +225,7 @@ private: void moveDragging( const VECTOR2I& aP, ITEM* aItem ); void eraseView(); - void updateView( NODE* aNode, ITEM_SET& aCurrent ); + void updateView( NODE* aNode, ITEM_SET& aCurrent, bool aDragging = false ); void clearViewFlags();