Commit 327f307a authored by Maciej Suminski's avatar Maciej Suminski

FIx layer switching after via placement in PNS router.

parent 0953d573
......@@ -758,9 +758,12 @@ void PNS_LINE_PLACER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, co
}
void PNS_LINE_PLACER::SetLayer(int aLayer)
void PNS_LINE_PLACER::SetLayer( int aLayer )
{
m_currentLayer = aLayer;
m_head.SetLayer( aLayer );
m_tail.SetLayer( aLayer );
}
......@@ -901,9 +904,18 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
VECTOR2I p_start = m_placingVia ? p_last : p_pre_last;
if( m_placingVia )
m_currentLayer = Router()->NextCopperLayer( true );
{
int layerTop = Router()->Settings().GetLayerTop();
int layerBottom = Router()->Settings().GetLayerBottom();
// Change the current layer to the other side of the board
if( m_currentLayer == layerTop )
m_currentLayer = layerBottom;
else
m_currentLayer = layerTop;
}
setWorld ( Router()->GetWorld()->Branch() );
setWorld( Router()->GetWorld()->Branch() );
startPlacement( p_start, m_head.Net(), m_head.Width(), m_currentLayer );
m_startsOnVia = m_placingVia;
......
......@@ -212,7 +212,7 @@ private:
*
* Sets the board to route.
*/
void setWorld ( PNS_NODE* aWorld );
void setWorld( PNS_NODE* aWorld );
/**
* Function startPlacement()
......
......@@ -323,6 +323,7 @@ PNS_ROUTER::PNS_ROUTER()
m_currentLayer = 1;
m_placingVia = false;
m_startsOnVia = false;
m_currentNet = -1;
m_state = IDLE;
m_world = NULL;
......@@ -758,6 +759,7 @@ void PNS_ROUTER::CommitRouting( PNS_NODE* aNode )
via_board->SetWidth( via->Diameter() );
via_board->SetDrill( via->Drill() );
via_board->SetNetCode( via->Net() );
via_board->SetLayerPair( m_settings.GetLayerTop(), m_settings.GetLayerBottom() );
newBI = via_board;
break;
}
......@@ -809,6 +811,7 @@ bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
case ROUTE_TRACK:
rv = m_placer->FixRoute( aP, aEndItem );
m_startsOnVia = m_placingVia;
m_placingVia = false;
break;
......@@ -874,8 +877,7 @@ void PNS_ROUTER::SwitchLayer( int aLayer )
if( m_startsOnVia )
{
m_currentLayer = aLayer;
//m_placer->StartPlacement( m_currentStart, m_currentNet, m_currentWidth,
// m_currentLayer );
m_placer->SetLayer( aLayer );
}
break;
......
......@@ -107,7 +107,7 @@ public:
void DisplayItems( const PNS_ITEMSET& aItems );
void DisplayDebugLine( const SHAPE_LINE_CHAIN& aLine, int aType = 0, int aWidth = 0 );
void DisplayDebugPoint( const VECTOR2I aPos, int aType = 0);
void DisplayDebugPoint( const VECTOR2I aPos, int aType = 0 );
void DisplayDebugBox( const BOX2I& aBox, int aType = 0, int aWidth = 0 );
void SwitchLayer( int layer );
......@@ -223,7 +223,7 @@ private:
void highlightCurrent( bool enabled );
void markViolations( PNS_NODE *aNode, PNS_ITEMSET& aCurrent, PNS_NODE::ITEM_VECTOR& aRemoved );
void markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent, PNS_NODE::ITEM_VECTOR& aRemoved );
int m_currentLayer;
int m_currentNet;
......
......@@ -127,6 +127,23 @@ public:
int WalkaroundIterationLimit() const { return m_walkaroundIterationLimit; };
TIME_LIMIT WalkaroundTimeLimit() const;
void SetLayerPair( int aLayer1, int aLayer2 )
{
if( aLayer1 > aLayer2 )
{
m_layerTop = aLayer1;
m_layerBottom = aLayer2;
}
else
{
m_layerBottom = aLayer1;
m_layerTop = aLayer2;
}
}
int GetLayerTop() const { return m_layerTop; }
int GetLayerBottom() const { return m_layerBottom; }
private:
bool m_shoveVias;
bool m_startDiagonal;
......@@ -150,6 +167,10 @@ private:
int m_shoveIterationLimit;
TIME_LIMIT m_shoveTimeLimit;
TIME_LIMIT m_walkaroundTimeLimit;
// Routing layers pair
int m_layerTop;
int m_layerBottom;
};
#endif
......@@ -478,7 +478,7 @@ void ROUTER_TOOL::updateEndItem( TOOL_EVENT& aEvent )
int layer;
bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
m_router->EnableSnapping ( snapEnabled );
m_router->EnableSnapping( snapEnabled );
if( !snapEnabled || m_router->GetCurrentNet() < 0 || !m_startItem )
{
......@@ -566,39 +566,36 @@ void ROUTER_TOOL::performRouting()
if( m_router->FixRoute( m_endSnapPoint, m_endItem ) )
break;
// Synchronize the indicated layer
frame->SetActiveLayer( m_router->GetCurrentLayer() );
m_router->Move( m_endSnapPoint, m_endItem );
}
else if( evt->IsAction( &ACT_PlaceThroughVia ) )
{
m_router->Settings().SetLayerPair( frame->GetScreen()->m_Route_Layer_TOP,
frame->GetScreen()->m_Route_Layer_BOTTOM );
m_router->ToggleViaPlacement();
frame->GetGalCanvas()->SetTopLayer( ToLAYER_ID( m_router->GetCurrentLayer() ) );
m_router->Move( m_endSnapPoint, m_endItem );
m_router->Move( m_endSnapPoint, m_endItem ); // refresh
}
else if( evt->IsAction( &ACT_SwitchPosture ) )
{
m_router->FlipPosture();
m_router->Move( m_endSnapPoint, m_endItem );
m_router->Move( m_endSnapPoint, m_endItem ); // refresh
}
else if( evt->IsAction( &COMMON_ACTIONS::layerNext ) )
else if( evt->IsAction( &COMMON_ACTIONS::layerChanged ) )
{
m_router->SwitchLayer( m_router->NextCopperLayer( true ) );
updateEndItem( *evt );
frame->SetActiveLayer( ToLAYER_ID( m_router->GetCurrentLayer() ) );
m_router->Move( m_endSnapPoint, m_endItem );
}
else if( evt->IsAction( &COMMON_ACTIONS::layerPrev ) )
{
m_router->SwitchLayer( m_router->NextCopperLayer( false ) );
frame->SetActiveLayer( ToLAYER_ID( m_router->GetCurrentLayer() ) );
m_router->Move( m_endSnapPoint, m_endItem );
m_router->SwitchLayer( frame->GetActiveLayer() );
m_router->Move( m_endSnapPoint, m_endItem ); // refresh
}
else if( evt->IsAction( &ACT_EndTrack ) )
{
if( m_router->FixRoute( m_endSnapPoint, m_endItem ) )
break;
}
handleCommonEvents(*evt);
handleCommonEvents( *evt );
}
m_router->StopRouting();
......@@ -642,7 +639,7 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
m_router->Settings().SetViaDiameter( bds.GetCurrentViaSize() );
m_router->Settings().SetViaDrill( bds.GetCurrentViaDrill() );
ROUTER_TOOL_MENU *ctxMenu = new ROUTER_TOOL_MENU( board );
ROUTER_TOOL_MENU* ctxMenu = new ROUTER_TOOL_MENU( board );
SetContextMenu ( ctxMenu );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment