From b6f61ff6763e2439e6173acd63f8f4eaeaf6c533 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Tue, 4 Aug 2015 12:15:47 +0200 Subject: [PATCH] PNS: correctly snap to offset pads --- pcbnew/ratsnest_data.cpp | 2 +- pcbnew/router/pns_optimizer.cpp | 8 ++++++++ pcbnew/router/pns_router.cpp | 6 +++++- pcbnew/router/pns_solid.h | 11 +++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/pcbnew/ratsnest_data.cpp b/pcbnew/ratsnest_data.cpp index fd8b83f86c..4200e2407b 100644 --- a/pcbnew/ratsnest_data.cpp +++ b/pcbnew/ratsnest_data.cpp @@ -385,7 +385,7 @@ void RN_NET::Update() void RN_NET::AddItem( const D_PAD* aPad ) { - RN_NODE_PTR node = m_links.AddNode( aPad->ShapePos().x, aPad->ShapePos().y ); + RN_NODE_PTR node = m_links.AddNode( aPad->GetPosition().x, aPad->GetPosition().y ); node->AddParent( aPad ); m_pads[aPad] = node; diff --git a/pcbnew/router/pns_optimizer.cpp b/pcbnew/router/pns_optimizer.cpp index 02bbb730ba..d18933f491 100644 --- a/pcbnew/router/pns_optimizer.cpp +++ b/pcbnew/router/pns_optimizer.cpp @@ -27,6 +27,7 @@ #include "pns_line.h" #include "pns_diff_pair.h" #include "pns_node.h" +#include "pns_solid.h" #include "pns_optimizer.h" #include "pns_utils.h" #include "pns_router.h" @@ -831,6 +832,13 @@ int PNS_OPTIMIZER::smartPadsSingle( PNS_LINE* aLine, PNS_ITEM* aPad, bool aEnd, typedef std::pair RtVariant; std::vector variants; + PNS_SOLID* solid = dyn_cast( aPad ); + + // don't do auto-neckdown for offset pads + if( solid && solid->Offset() != VECTOR2I( 0, 0 ) ) + return -1; + + BREAKOUT_LIST breakouts = computeBreakouts( aLine->Width(), aPad, true ); SHAPE_LINE_CHAIN line = ( aEnd ? aLine->CLine().Reverse() : aLine->CLine() ); diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 08ea234cf6..3b3fa6ff1a 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -199,11 +199,15 @@ PNS_ITEM* PNS_ROUTER::syncPad( D_PAD* aPad ) wxPoint wx_c = aPad->ShapePos(); wxSize wx_sz = aPad->GetSize(); + wxPoint offset = aPad->GetOffset(); VECTOR2I c( wx_c.x, wx_c.y ); VECTOR2I sz( wx_sz.x, wx_sz.y ); - solid->SetPos( c ); + RotatePoint( &offset, aPad->GetOrientation() ); + + solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) ); + solid->SetOffset ( VECTOR2I ( offset.x, offset.y ) ); double orient = aPad->GetOrientation() / 10.0; diff --git a/pcbnew/router/pns_solid.h b/pcbnew/router/pns_solid.h index e598409849..593b3b09db 100644 --- a/pcbnew/router/pns_solid.h +++ b/pcbnew/router/pns_solid.h @@ -88,9 +88,20 @@ public: return 1; } + VECTOR2I Offset() const + { + return m_offset; + } + + void SetOffset( const VECTOR2I& aOffset ) + { + m_offset = aOffset; + } + private: VECTOR2I m_pos; SHAPE* m_shape; + VECTOR2I m_offset; }; #endif