router: Allow highlighting both DP nets when routing.

This commit is contained in:
Alex 2022-12-06 05:24:09 +03:00
parent b673202a4e
commit 008704fc6f
4 changed files with 52 additions and 31 deletions

View File

@ -142,7 +142,7 @@ void LENGTH_TUNER_TOOL::performTuning()
frame()->SetActiveLayer( ToLAYER_ID ( m_startItem->Layers().Start() ) );
if( m_startItem->Net() >= 0 )
highlightNet( true, m_startItem->Net() );
highlightNets( true, { m_startItem->Net() } );
}
controls()->ForceCursorPosition( false );
@ -153,7 +153,7 @@ void LENGTH_TUNER_TOOL::performTuning()
if( !m_router->StartRouting( m_startSnapPoint, m_startItem, layer ) )
{
frame()->ShowInfoBarMsg( m_router->FailureReason() );
highlightNet( false );
highlightNets( false );
return;
}
@ -259,7 +259,7 @@ void LENGTH_TUNER_TOOL::performTuning()
controls()->SetAutoPan( false );
controls()->ForceCursorPosition( false );
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
highlightNet( false );
highlightNets( false );
}

View File

@ -49,7 +49,6 @@ TOOL_BASE::TOOL_BASE( const std::string& aToolName ) :
m_cancelled = false;
m_startItem = nullptr;
m_startHighlight = false;
m_endItem = nullptr;
m_gridHelper = nullptr;
@ -221,25 +220,37 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b
}
void TOOL_BASE::highlightNet( bool aEnabled, int aNetcode )
void TOOL_BASE::highlightNets( bool aEnabled, std::set<int> aNetcodes )
{
RENDER_SETTINGS* rs = getView()->GetPainter()->GetSettings();
if( aNetcode >= 0 && aEnabled )
if( aNetcodes.size() > 0 && aEnabled )
{
// If the user has previously set the current net to be highlighted,
// we assume they want to keep it highlighted after routing
m_startHighlight = ( rs->IsHighlightEnabled()
&& rs->GetHighlightNetCodes().count( aNetcode ) );
// If the user has previously set some of the routed nets to be highlighted,
// we assume they want to keep them highlighted after routing
rs->SetHighlight( true, aNetcode );
const std::set<int>& currentNetCodes = rs->GetHighlightNetCodes();
bool keep = false;
for( const int& netcode : aNetcodes )
{
if( currentNetCodes.find( netcode ) != currentNetCodes.end() )
{
keep = true;
break;
}
}
if( rs->IsHighlightEnabled() && keep )
m_startHighlightNetcodes = currentNetCodes;
else
m_startHighlightNetcodes.clear();
rs->SetHighlight( aNetcodes, true );
}
else
{
if( !m_startHighlight )
rs->SetHighlight( false );
m_startHighlight = false;
rs->SetHighlight( m_startHighlightNetcodes, m_startHighlightNetcodes.size() > 0 );
}
// Do not remove this call. This is required to update the layers when we highlight a net.
@ -317,9 +328,9 @@ void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent )
m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
controls()->ForceCursorPosition( false );
VECTOR2I mousePos = controls()->GetMousePosition();
if( m_router->GetState() == ROUTER::ROUTE_TRACK && aEvent.IsDrag() )
{
// If the user is moving the mouse quickly while routing then clicks will come in as

View File

@ -61,7 +61,7 @@ protected:
bool aIgnorePads = false,
const std::vector<ITEM*> aAvoidItems = {} );
virtual void highlightNet( bool aEnabled, int aNetcode = -1 );
virtual void highlightNets( bool aEnabled, std::set<int> aNetcodes = {} );
virtual void updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads = false );
virtual void updateEndItem( const TOOL_EVENT& aEvent );
@ -69,7 +69,7 @@ protected:
SIZES_SETTINGS m_savedSizes; // Stores sizes settings between router invocations
ITEM* m_startItem;
VECTOR2I m_startSnapPoint;
bool m_startHighlight; // Was net highlighted before routing?
std::set<int> m_startHighlightNetcodes; // The set of nets highlighted before routing
ITEM* m_endItem;
VECTOR2I m_endSnapPoint;

View File

@ -1184,11 +1184,6 @@ bool ROUTER_TOOL::prepareInteractive()
editFrame->GetCanvas()->Refresh();
}
if( m_startItem && m_startItem->Net() > 0 )
highlightNet( true, m_startItem->Net() );
controls()->SetAutoPan( true );
PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
m_iface->SetStartLayer( routingLayer );
@ -1200,13 +1195,28 @@ bool ROUTER_TOOL::prepareInteractive()
m_router->UpdateSizes( sizes );
if( m_startItem && m_startItem->Net() > 0 )
{
if( m_router->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
{
if( int coupledNet = m_router->GetRuleResolver()->DpCoupledNet( m_startItem->Net() ) )
highlightNets( true, { m_startItem->Net(), coupledNet } );
}
else
{
highlightNets( true, { m_startItem->Net() } );
}
}
controls()->SetAutoPan( true );
if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
{
// It would make more sense to leave the net highlighted as the higher-contrast mode
// makes the router clearances more visible. However, since we just started routing
// the conversion of the screen from low contrast to high contrast is a bit jarring and
// makes the infobar coming up less noticeable.
highlightNet( false );
highlightNets( false );
frame()->ShowInfoBarError( m_router->FailureReason(), true,
[&]()
@ -1241,7 +1251,7 @@ bool ROUTER_TOOL::finishInteractive()
controls()->SetAutoPan( false );
controls()->ForceCursorPosition( false );
frame()->UndoRedoBlock( false );
highlightNet( false );
highlightNets( false );
return true;
}
@ -1819,7 +1829,7 @@ void ROUTER_TOOL::performDragging( int aMode )
m_gridHelper->SetAuxAxes( false );
ctls->ForceCursorPosition( false );
highlightNet( false );
highlightNets( false );
m_cancelled = true;
@ -1834,7 +1844,7 @@ void ROUTER_TOOL::performDragging( int aMode )
return;
if( m_startItem && m_startItem->Net() > 0 )
highlightNet( true, m_startItem->Net() );
highlightNets( true, { m_startItem->Net() } );
ctls->SetAutoPan( true );
m_gridHelper->SetAuxAxes( true, m_startSnapPoint );
@ -1916,7 +1926,7 @@ void ROUTER_TOOL::performDragging( int aMode )
frame()->UndoRedoBlock( false );
ctls->SetAutoPan( false );
ctls->ForceCursorPosition( false );
highlightNet( false );
highlightNets( false );
}
@ -2100,7 +2110,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
m_startItem = startItem;
if( m_startItem && m_startItem->Net() > 0 )
highlightNet( true, m_startItem->Net() );
highlightNets( true, { m_startItem->Net() } );
}
else if( footprint )
{
@ -2333,7 +2343,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
controls()->SetAutoPan( false );
controls()->ForceCursorPosition( false );
frame()->UndoRedoBlock( false );
highlightNet( false );
highlightNets( false );
return 0;
}