From b4135e0a33fdd2951b36cfdd4c6b87f2633ef506 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 21 Aug 2015 16:35:34 +0200 Subject: [PATCH] router: fixed snapping to target while placing diff pair --- pcbnew/router/pns_diff_pair_placer.cpp | 11 ++++++++++- pcbnew/router/pns_diff_pair_placer.h | 7 ++----- pcbnew/router/pns_dp_meander_placer.cpp | 14 ++++++++------ pcbnew/router/pns_dp_meander_placer.h | 4 +++- pcbnew/router/pns_line_placer.h | 4 ++-- pcbnew/router/pns_meander_placer.cpp | 7 ------- pcbnew/router/pns_meander_placer.h | 7 +++++-- pcbnew/router/pns_placement_algo.h | 8 ++++---- pcbnew/router/pns_router.cpp | 7 ++++--- pcbnew/router/pns_router.h | 2 +- pcbnew/router/pns_tool_base.cpp | 14 ++++++++++++-- 11 files changed, 51 insertions(+), 34 deletions(-) diff --git a/pcbnew/router/pns_diff_pair_placer.cpp b/pcbnew/router/pns_diff_pair_placer.cpp index a4f536ec5d..f37c2c38a8 100644 --- a/pcbnew/router/pns_diff_pair_placer.cpp +++ b/pcbnew/router/pns_diff_pair_placer.cpp @@ -505,7 +505,7 @@ bool PNS_DIFF_PAIR_PLACER::findDpPrimitivePair( const VECTOR2I& aP, PNS_ITEM* aI NETINFO_ITEM* netInfoP = brd->FindNet( netNameP ); NETINFO_ITEM* netInfoN = brd->FindNet( netNameN ); - + if( !netInfoP || !netInfoN ) return false; @@ -819,3 +819,12 @@ void PNS_DIFF_PAIR_PLACER::updateLeadingRatLine() Router()->DisplayDebugLine( ratLineN, 3, 10000 ); } } + + +const std::vector PNS_DIFF_PAIR_PLACER::CurrentNets() const +{ + std::vector rv; + rv.push_back( m_netP ); + rv.push_back( m_netN ); + return rv; +} diff --git a/pcbnew/router/pns_diff_pair_placer.h b/pcbnew/router/pns_diff_pair_placer.h index 19a43ccb6a..9bbed4cbcd 100644 --- a/pcbnew/router/pns_diff_pair_placer.h +++ b/pcbnew/router/pns_diff_pair_placer.h @@ -117,14 +117,11 @@ public: } /** - * Function CurrentNet() + * Function CurrentNets() * * Returns the net code of currently routed track. */ - int CurrentNet() const - { - return m_currentNet; - } + const std::vector CurrentNets() const; /** * Function CurrentLayer() diff --git a/pcbnew/router/pns_dp_meander_placer.cpp b/pcbnew/router/pns_dp_meander_placer.cpp index dcce295826..4ff870e2d9 100644 --- a/pcbnew/router/pns_dp_meander_placer.cpp +++ b/pcbnew/router/pns_dp_meander_placer.cpp @@ -356,12 +356,6 @@ const VECTOR2I& PNS_DP_MEANDER_PLACER::CurrentEnd() const } -int PNS_DP_MEANDER_PLACER::CurrentNet() const -{ - return m_initialSegment->Net(); -} - - int PNS_DP_MEANDER_PLACER::CurrentLayer() const { return m_initialSegment->Layers().Start(); @@ -402,3 +396,11 @@ PNS_DP_MEANDER_PLACER::TUNING_STATUS PNS_DP_MEANDER_PLACER::TuningStatus() const { return m_lastStatus; } + +const std::vector PNS_DP_MEANDER_PLACER::CurrentNets() const +{ + std::vector rv; + rv.push_back( m_originPair.NetP() ); + rv.push_back( m_originPair.NetN() ); + return rv; +} diff --git a/pcbnew/router/pns_dp_meander_placer.h b/pcbnew/router/pns_dp_meander_placer.h index 029c93ae8e..eb89e106c6 100644 --- a/pcbnew/router/pns_dp_meander_placer.h +++ b/pcbnew/router/pns_dp_meander_placer.h @@ -92,7 +92,9 @@ public: const VECTOR2I& CurrentEnd() const; - int CurrentNet() const; + /// @copydoc PNS_PLACEMENT_ALGO::CurrentNets() + const std::vector CurrentNets() const; + int CurrentLayer() const; int totalLength(); diff --git a/pcbnew/router/pns_line_placer.h b/pcbnew/router/pns_line_placer.h index 38f29e3982..8a1f263910 100644 --- a/pcbnew/router/pns_line_placer.h +++ b/pcbnew/router/pns_line_placer.h @@ -141,9 +141,9 @@ public: * * Returns the net code of currently routed track. */ - int CurrentNet() const + const std::vector CurrentNets() const { - return m_currentNet; + return std::vector( 1, m_currentNet ); } /** diff --git a/pcbnew/router/pns_meander_placer.cpp b/pcbnew/router/pns_meander_placer.cpp index aba538de26..3e235a4685 100644 --- a/pcbnew/router/pns_meander_placer.cpp +++ b/pcbnew/router/pns_meander_placer.cpp @@ -229,13 +229,6 @@ const VECTOR2I& PNS_MEANDER_PLACER::CurrentEnd() const return m_currentEnd; } - -int PNS_MEANDER_PLACER::CurrentNet() const -{ - return m_initialSegment->Net(); -} - - int PNS_MEANDER_PLACER::CurrentLayer() const { return m_initialSegment->Layers().Start(); diff --git a/pcbnew/router/pns_meander_placer.h b/pcbnew/router/pns_meander_placer.h index cbf667e57e..b38457e666 100644 --- a/pcbnew/router/pns_meander_placer.h +++ b/pcbnew/router/pns_meander_placer.h @@ -68,8 +68,11 @@ public: /// @copydoc PNS_PLACEMENT_ALGO::CurrentEnd() const VECTOR2I& CurrentEnd() const; - /// @copydoc PNS_PLACEMENT_ALGO::CurrentNet() - int CurrentNet() const; + /// @copydoc PNS_PLACEMENT_ALGO::CurrentNets() + const std::vector CurrentNets() const + { + return std::vector (1, m_originLine.Net() ); + } /// @copydoc PNS_PLACEMENT_ALGO::CurrentLayer() int CurrentLayer() const; diff --git a/pcbnew/router/pns_placement_algo.h b/pcbnew/router/pns_placement_algo.h index 315ddc3813..6598d821ac 100644 --- a/pcbnew/router/pns_placement_algo.h +++ b/pcbnew/router/pns_placement_algo.h @@ -115,17 +115,17 @@ public: /** * Function CurrentEnd() * - * Returns the current end of the line being placed/tuned. It may not be equal + * Returns the current end of the line(s) being placed/tuned. It may not be equal * to the cursor position due to collisions. */ virtual const VECTOR2I& CurrentEnd() const = 0; /** - * Function CurrentNet() + * Function CurrentNets() * - * Returns the net code of currently routed track. + * Returns the net code(s) of currently routed track(s). */ - virtual int CurrentNet() const = 0; + virtual const std::vector CurrentNets() const = 0; /** * Function CurrentLayer() diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index fc871fa549..5fcc7c65a8 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -1018,11 +1018,12 @@ void PNS_ROUTER::ToggleViaPlacement() } -int PNS_ROUTER::GetCurrentNet() const +const std::vector PNS_ROUTER::GetCurrentNets() const { if( m_placer ) - return m_placer->CurrentNet(); - return -1; + return m_placer->CurrentNets(); + + return std::vector(); } diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index f2404b9bba..7936c4d544 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -129,7 +129,7 @@ public: void SetOrthoMode ( bool aEnable ); int GetCurrentLayer() const; - int GetCurrentNet() const; + const std::vector GetCurrentNets() const; void DumpLog(); diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index f2d94891bb..2be624614d 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -251,7 +251,7 @@ void PNS_TOOL_BASE::updateEndItem( TOOL_EVENT& aEvent ) m_router->EnableSnapping( snapEnabled ); - if( m_router->GetCurrentNet() < 0 ) + if( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) { m_endItem = NULL; m_endSnapPoint = cp; @@ -265,7 +265,17 @@ void PNS_TOOL_BASE::updateEndItem( TOOL_EVENT& aEvent ) else layer = m_router->GetCurrentLayer(); - PNS_ITEM* endItem = pickSingleItem( p, m_router->GetCurrentNet(), layer ); + PNS_ITEM* endItem = NULL; + + std::vector nets = m_router->GetCurrentNets(); + + BOOST_FOREACH( int net, nets ) + { + endItem = pickSingleItem( p, net, layer ); + + if( endItem ) + break; + } if( endItem ) {