From f6f726acabec6e228d42eb329c068ebcd08d7fb2 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Tue, 19 Jun 2018 19:29:36 +0200 Subject: [PATCH] router: allow placing tracks/diff pairs without continuing routing by Shift+L-Click Fixes: lp:1777688 * https://bugs.launchpad.net/kicad/+bug/1777688 --- pcbnew/router/pns_diff_pair_placer.cpp | 8 ++++---- pcbnew/router/pns_diff_pair_placer.h | 2 +- pcbnew/router/pns_dp_meander_placer.cpp | 2 +- pcbnew/router/pns_dp_meander_placer.h | 2 +- pcbnew/router/pns_line_placer.cpp | 5 ++++- pcbnew/router/pns_line_placer.h | 2 +- pcbnew/router/pns_meander_placer.cpp | 2 +- pcbnew/router/pns_meander_placer.h | 2 +- pcbnew/router/pns_placement_algo.h | 2 +- pcbnew/router/pns_router.cpp | 4 ++-- pcbnew/router/pns_router.h | 2 +- pcbnew/router/router_tool.cpp | 6 ++++-- 12 files changed, 22 insertions(+), 17 deletions(-) diff --git a/pcbnew/router/pns_diff_pair_placer.cpp b/pcbnew/router/pns_diff_pair_placer.cpp index 7415c32516..0a344ef753 100644 --- a/pcbnew/router/pns_diff_pair_placer.cpp +++ b/pcbnew/router/pns_diff_pair_placer.cpp @@ -737,7 +737,7 @@ void DIFF_PAIR_PLACER::UpdateSizes( const SIZES_SETTINGS& aSizes ) } -bool DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) +bool DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish ) { if( !m_fitOk ) return false; @@ -751,7 +751,7 @@ bool DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) TOPOLOGY topo( m_lastNode ); - if( !m_snapOnTarget && !m_currentTrace.EndsWithVias() ) + if( !m_snapOnTarget && !m_currentTrace.EndsWithVias() && !aForceFinish ) { SHAPE_LINE_CHAIN newP( m_currentTrace.CP() ); SHAPE_LINE_CHAIN newN( m_currentTrace.CN() ); @@ -773,7 +773,7 @@ bool DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) } else { - m_chainedPlacement = !m_snapOnTarget; + m_chainedPlacement = !m_snapOnTarget && !aForceFinish; } LINE lineP( m_currentTrace.PLine() ); @@ -792,7 +792,7 @@ bool DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) m_lastNode = NULL; m_placingVia = false; - if( m_snapOnTarget ) + if( m_snapOnTarget || aForceFinish ) { m_idle = true; return true; diff --git a/pcbnew/router/pns_diff_pair_placer.h b/pcbnew/router/pns_diff_pair_placer.h index 543f77b12f..c2cb591944 100644 --- a/pcbnew/router/pns_diff_pair_placer.h +++ b/pcbnew/router/pns_diff_pair_placer.h @@ -84,7 +84,7 @@ public: * result is violating design rules - in such case, the track is only committed * if Settings.CanViolateDRC() is on. */ - bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) override; + bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish ) override; /** * Function ToggleVia() diff --git a/pcbnew/router/pns_dp_meander_placer.cpp b/pcbnew/router/pns_dp_meander_placer.cpp index 0b9dc8e16f..e340d7856a 100644 --- a/pcbnew/router/pns_dp_meander_placer.cpp +++ b/pcbnew/router/pns_dp_meander_placer.cpp @@ -300,7 +300,7 @@ bool DP_MEANDER_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem ) } -bool DP_MEANDER_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) +bool DP_MEANDER_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish ) { LINE lP( m_originPair.PLine(), m_finalShapeP ); LINE lN( m_originPair.NLine(), m_finalShapeN ); diff --git a/pcbnew/router/pns_dp_meander_placer.h b/pcbnew/router/pns_dp_meander_placer.h index 63a942df36..c798d2d359 100644 --- a/pcbnew/router/pns_dp_meander_placer.h +++ b/pcbnew/router/pns_dp_meander_placer.h @@ -78,7 +78,7 @@ public: * result is violating design rules - in such case, the track is only committed * if Settings.CanViolateDRC() is on. */ - bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) override; + bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish = false ) override; const LINE Trace() const; diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 30d96138ac..705a65899c 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -951,7 +951,7 @@ bool LINE_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem ) } -bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) +bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish ) { bool realEnd = false; int lastV; @@ -1009,6 +1009,9 @@ bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) if( aEndItem && m_currentNet >= 0 && m_currentNet == aEndItem->Net() ) realEnd = true; + if( aForceFinish ) + realEnd = true; + if( realEnd || m_placingVia ) lastV = l.SegmentCount(); else diff --git a/pcbnew/router/pns_line_placer.h b/pcbnew/router/pns_line_placer.h index 21a07c0b75..1e5a61d80c 100644 --- a/pcbnew/router/pns_line_placer.h +++ b/pcbnew/router/pns_line_placer.h @@ -81,7 +81,7 @@ public: * result is violating design rules - in such case, the track is only committed * if Settings.CanViolateDRC() is on. */ - bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) override; + bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish ) override; /** * Function ToggleVia() diff --git a/pcbnew/router/pns_meander_placer.cpp b/pcbnew/router/pns_meander_placer.cpp index e0f876d7b2..46c392f7ab 100644 --- a/pcbnew/router/pns_meander_placer.cpp +++ b/pcbnew/router/pns_meander_placer.cpp @@ -188,7 +188,7 @@ bool MEANDER_PLACER::doMove( const VECTOR2I& aP, ITEM* aEndItem, int aTargetLeng } -bool MEANDER_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) +bool MEANDER_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish ) { if( !m_currentNode ) return false; diff --git a/pcbnew/router/pns_meander_placer.h b/pcbnew/router/pns_meander_placer.h index 4b7a0b376f..b9a0bb90b8 100644 --- a/pcbnew/router/pns_meander_placer.h +++ b/pcbnew/router/pns_meander_placer.h @@ -59,7 +59,7 @@ public: virtual bool Move( const VECTOR2I& aP, ITEM* aEndItem ) override; /// @copydoc PLACEMENT_ALGO::FixRoute() - virtual bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) override; + virtual bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish = false ) override; /// @copydoc PLACEMENT_ALGO::CurrentNode() NODE* CurrentNode( bool aLoopsRemoved = false ) const override; diff --git a/pcbnew/router/pns_placement_algo.h b/pcbnew/router/pns_placement_algo.h index e7a9540cb0..98af6cbc72 100644 --- a/pcbnew/router/pns_placement_algo.h +++ b/pcbnew/router/pns_placement_algo.h @@ -76,7 +76,7 @@ public: * result is violating design rules - in such case, the track is only committed * if Settings.CanViolateDRC() is on. */ - virtual bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) = 0; + virtual bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish = false ) = 0; /** * Function ToggleVia() diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 579ae1dcc4..5c6e25b84f 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -361,14 +361,14 @@ void ROUTER::CommitRouting( NODE* aNode ) } -bool ROUTER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem ) +bool ROUTER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish ) { bool rv = false; switch( m_state ) { case ROUTE_TRACK: - rv = m_placer->FixRoute( aP, aEndItem ); + rv = m_placer->FixRoute( aP, aEndItem, aForceFinish ); break; case DRAG_SEGMENT: diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index 3ff593967d..d4047dae27 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -133,7 +133,7 @@ public: bool RoutingInProgress() const; bool StartRouting( const VECTOR2I& aP, ITEM* aItem, int aLayer ); void Move( const VECTOR2I& aP, ITEM* aItem ); - bool FixRoute( const VECTOR2I& aP, ITEM* aItem ); + bool FixRoute( const VECTOR2I& aP, ITEM* aItem, bool aForceFinish = false ); void BreakSegment( ITEM *aItem, const VECTOR2I& aP ); void StopRouting(); diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 93e22ecfe9..ca0db2b7aa 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -728,10 +728,12 @@ void ROUTER_TOOL::performRouting() { updateEndItem( *evt ); bool needLayerSwitch = m_router->IsPlacingVia(); + bool forceFinish = evt->Modifier( MD_SHIFT ); - if( m_router->FixRoute( m_endSnapPoint, m_endItem ) ) + + if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) ) break; - + if( needLayerSwitch ) switchLayerOnViaPlacement();