Allow changing router mode while routing

Keeps shove active even when not using to allow switching modes during
routing.

Fixes https://gitlab.com/kicad/code/kicad/issues/9342
This commit is contained in:
Seth Hillbrand 2021-10-12 09:53:52 -07:00
parent 7f1247a23c
commit 35e90d0cf4
5 changed files with 21 additions and 43 deletions

View File

@ -54,16 +54,12 @@ DIFF_PAIR_PLACER::DIFF_PAIR_PLACER( ROUTER* aRouter ) :
m_orthoMode = false; m_orthoMode = false;
m_snapOnTarget = false; m_snapOnTarget = false;
m_currentEndItem = nullptr; m_currentEndItem = nullptr;
m_currentMode = RM_MarkObstacles;
m_currentTraceOk = false; m_currentTraceOk = false;
m_idle = true; m_idle = true;
} }
DIFF_PAIR_PLACER::~DIFF_PAIR_PLACER() DIFF_PAIR_PLACER::~DIFF_PAIR_PLACER()
{ {}
if( m_shove )
delete m_shove;
}
void DIFF_PAIR_PLACER::setWorld( NODE* aWorld ) void DIFF_PAIR_PLACER::setWorld( NODE* aWorld )
@ -133,12 +129,12 @@ bool DIFF_PAIR_PLACER::propagateDpHeadForces ( const VECTOR2I& aP, VECTOR2I& aNe
bool solidsOnly = true; bool solidsOnly = true;
if( m_currentMode == RM_MarkObstacles ) if( Settings().Mode() == RM_MarkObstacles )
{ {
aNewP = aP; aNewP = aP;
return true; return true;
} }
else if( m_currentMode == RM_Walkaround ) else if( Settings().Mode() == RM_Walkaround )
{ {
solidsOnly = false; solidsOnly = false;
} }
@ -324,7 +320,7 @@ bool DIFF_PAIR_PLACER::rhWalkOnly( const VECTOR2I& aP )
bool DIFF_PAIR_PLACER::route( const VECTOR2I& aP ) bool DIFF_PAIR_PLACER::route( const VECTOR2I& aP )
{ {
switch( m_currentMode ) switch( Settings().Mode() )
{ {
case RM_MarkObstacles: case RM_MarkObstacles:
return rhMarkObstacles( aP ); return rhMarkObstacles( aP );
@ -621,17 +617,8 @@ void DIFF_PAIR_PLACER::initPlacement()
m_lastNode = nullptr; m_lastNode = nullptr;
m_currentNode = rootNode; m_currentNode = rootNode;
m_currentMode = Settings().Mode();
if( m_shove ) m_shove = std::make_unique<SHOVE>( m_currentNode, Router() );
delete m_shove;
m_shove = nullptr;
if( m_currentMode == RM_Shove || m_currentMode == RM_Smart )
{
m_shove = new SHOVE( m_currentNode, Router() );
}
} }

View File

@ -234,7 +234,7 @@ private:
VECTOR2I m_p_start; VECTOR2I m_p_start;
///< The shove engine ///< The shove engine
SHOVE* m_shove; std::unique_ptr<SHOVE> m_shove;
///< Current world state ///< Current world state
NODE* m_currentNode; NODE* m_currentNode;
@ -268,7 +268,6 @@ private:
bool m_currentTraceOk; bool m_currentTraceOk;
ITEM* m_currentEndItem; ITEM* m_currentEndItem;
PNS_MODE m_currentMode;
bool m_idle; bool m_idle;
}; };

View File

@ -51,7 +51,6 @@ LINE_PLACER::LINE_PLACER( ROUTER* aRouter ) :
m_placingVia = false; m_placingVia = false;
m_currentNet = 0; m_currentNet = 0;
m_currentLayer = 0; m_currentLayer = 0;
m_currentMode = RM_MarkObstacles;
m_startItem = nullptr; m_startItem = nullptr;
m_chainedPlacement = false; m_chainedPlacement = false;
m_orthoMode = false; m_orthoMode = false;
@ -806,7 +805,7 @@ bool LINE_PLACER::rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead )
bool LINE_PLACER::routeHead( const VECTOR2I& aP, LINE& aNewHead ) bool LINE_PLACER::routeHead( const VECTOR2I& aP, LINE& aNewHead )
{ {
switch( m_currentMode ) switch( Settings().Mode() )
{ {
case RM_MarkObstacles: case RM_MarkObstacles:
return rhMarkObstacles( aP, aNewHead ); return rhMarkObstacles( aP, aNewHead );
@ -1144,7 +1143,7 @@ bool LINE_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem )
NODE *n; NODE *n;
if ( m_shove ) if ( Settings().Mode() == PNS::RM_Shove || Settings().Mode() == PNS::RM_Smart )
n = m_shove->CurrentNode(); n = m_shove->CurrentNode();
else else
n = m_currentNode; n = m_currentNode;
@ -1189,12 +1188,8 @@ void LINE_PLACER::initPlacement()
m_lastNode = nullptr; m_lastNode = nullptr;
m_currentNode = m_world; m_currentNode = m_world;
m_currentMode = Settings().Mode();
m_shove.reset(); m_shove = std::make_unique<SHOVE>( m_world->Branch(), Router() );
if( m_currentMode == RM_Shove || m_currentMode == RM_Smart )
m_shove = std::make_unique<SHOVE>( m_world->Branch(), Router() );
} }
@ -1249,7 +1244,7 @@ bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinis
LINE pl = Trace(); LINE pl = Trace();
if( m_currentMode == RM_MarkObstacles ) if( Settings().Mode() == RM_MarkObstacles )
{ {
// Mark Obstacles is sort of a half-manual, half-automated mode in which the // Mark Obstacles is sort of a half-manual, half-automated mode in which the
// user has more responsibility and authority. // user has more responsibility and authority.
@ -1405,8 +1400,7 @@ bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinis
m_currentNode = m_lastNode; m_currentNode = m_lastNode;
m_lastNode = m_lastNode->Branch(); m_lastNode = m_lastNode->Branch();
if( m_shove ) m_shove->AddLockedSpringbackNode( m_currentNode );
m_shove->AddLockedSpringbackNode( m_currentNode );
DIRECTION_45 lastSegDir = pl.EndsWithVia() ? DIRECTION_45::UNDEFINED : d_last; DIRECTION_45 lastSegDir = pl.EndsWithVia() ? DIRECTION_45::UNDEFINED : d_last;
@ -1451,10 +1445,11 @@ bool LINE_PLACER::UnfixRoute()
m_mouseTrailTracer.SetDefaultDirections( m_initial_direction, m_direction ); m_mouseTrailTracer.SetDefaultDirections( m_initial_direction, m_direction );
m_mouseTrailTracer.AddTrailPoint( m_p_start ); m_mouseTrailTracer.AddTrailPoint( m_p_start );
if( m_shove ) m_shove->RewindSpringbackTo( m_currentNode );
m_shove->UnlockSpringbackNode( m_currentNode );
if( Settings().Mode() == PNS::RM_Shove || Settings().Mode() == PNS::RM_Smart )
{ {
m_shove->RewindSpringbackTo( m_currentNode );
m_shove->UnlockSpringbackNode( m_currentNode );
m_currentNode = m_shove->CurrentNode(); m_currentNode = m_shove->CurrentNode();
m_currentNode->KillChildren(); m_currentNode->KillChildren();
} }
@ -1696,7 +1691,7 @@ bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aForce
VIA v( makeVia( aP ) ); VIA v( makeVia( aP ) );
v.SetNet( aHead.Net() ); v.SetNet( aHead.Net() );
if( m_currentMode == RM_MarkObstacles ) if( Settings().Mode() == RM_MarkObstacles )
{ {
aHead.AppendVia( v ); aHead.AppendVia( v );
return true; return true;
@ -1705,7 +1700,7 @@ bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aForce
VECTOR2I force; VECTOR2I force;
VECTOR2I lead = aP - m_p_start; VECTOR2I lead = aP - m_p_start;
bool solidsOnly = ( m_currentMode != RM_Walkaround ); bool solidsOnly = ( Settings().Mode() != RM_Walkaround );
if( v.PushoutForce( m_currentNode, lead, force, solidsOnly, 40 ) ) if( v.PushoutForce( m_currentNode, lead, force, solidsOnly, 40 ) )
{ {

View File

@ -28,12 +28,12 @@
#include <geometry/shape.h> #include <geometry/shape.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include "pns_sizes_settings.h"
#include "pns_node.h"
#include "pns_via.h"
#include "pns_line.h" #include "pns_line.h"
#include "pns_placement_algo.h"
#include "pns_mouse_trail_tracer.h" #include "pns_mouse_trail_tracer.h"
#include "pns_node.h"
#include "pns_placement_algo.h"
#include "pns_sizes_settings.h"
#include "pns_via.h"
namespace PNS { namespace PNS {
@ -203,7 +203,6 @@ public:
*/ */
bool SplitAdjacentSegments( NODE* aNode, ITEM* aSeg, const VECTOR2I& aP ); bool SplitAdjacentSegments( NODE* aNode, ITEM* aSeg, const VECTOR2I& aP );
private: private:
/** /**
* Re-route the current track to point aP. Returns true, when routing has completed * Re-route the current track to point aP. Returns true, when routing has completed
@ -353,7 +352,6 @@ private:
VECTOR2I m_currentStart; VECTOR2I m_currentStart;
LINE m_currentTrace; LINE m_currentTrace;
PNS_MODE m_currentMode;
ITEM* m_startItem; ITEM* m_startItem;
bool m_idle; bool m_idle;

View File

@ -1190,7 +1190,6 @@ void ROUTER_TOOL::performRouting()
} }
m_router->CommitRouting(); m_router->CommitRouting();
m_router->StopRouting();
finishInteractive(); finishInteractive();
} }