Add feedback showing current router state to the message panel

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8265
This commit is contained in:
Jon Evans 2021-07-03 13:21:51 -04:00
parent bc65b7173f
commit 277bf2b719
4 changed files with 87 additions and 1 deletions

View File

@ -445,6 +445,9 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
if( bds.m_UseConnectedTrackWidth && aStartItem != nullptr )
{
found = inheritTrackWidth( aStartItem, &trackWidth );
if( found )
aSizes.SetWidthSource( _( "existing track" ) );
}
if( !found && bds.UseNetClassTrack() && aStartItem )
@ -454,12 +457,24 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
{
trackWidth = std::max( trackWidth, constraint.m_Value.Opt() );
found = true;
if( trackWidth == constraint.m_Value.Opt() )
aSizes.SetWidthSource( constraint.m_RuleName );
else
aSizes.SetWidthSource( _( "board minimum width" ) );
}
}
if( !found )
{
trackWidth = std::max( trackWidth, bds.GetCurrentTrackWidth() );
if( bds.UseNetClassTrack() )
aSizes.SetWidthSource( _( "netclass 'Default'" ) );
else if( trackWidth == bds.GetCurrentTrackWidth() )
aSizes.SetWidthSource( _( "user choice" ) );
else
aSizes.SetWidthSource( _( "board minimum width" ) );
}
aSizes.SetTrackWidth( trackWidth );

View File

@ -48,7 +48,8 @@ public:
m_diffPairGap( 180000 ),
m_diffPairViaGap( 180000 ),
m_diffPairViaGapSameAsTraceGap( true ),
m_holeToHole( 0 )
m_holeToHole( 0 ),
m_widthSource()
{};
~SIZES_SETTINGS() {};
@ -103,6 +104,9 @@ public:
void SetViaType( VIATYPE aViaType ) { m_viaType = aViaType; }
VIATYPE ViaType() const { return m_viaType; }
wxString GetWidthSource() const { return m_widthSource; }
void SetWidthSource( const wxString& aSource ) { m_widthSource = aSource; }
private:
int m_minClearance;
int m_trackWidth;
@ -120,6 +124,8 @@ private:
int m_holeToHole;
std::map<int, int> m_layerPairs;
wxString m_widthSource;
};
}

View File

@ -1033,6 +1033,7 @@ bool ROUTER_TOOL::prepareInteractive()
m_endItem = nullptr;
m_endSnapPoint = m_startSnapPoint;
updateMessagePanel();
frame()->UndoRedoBlock( true );
return true;
@ -1046,6 +1047,7 @@ bool ROUTER_TOOL::finishInteractive()
m_startItem = nullptr;
m_endItem = nullptr;
updateMessagePanel();
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
controls()->SetAutoPan( false );
controls()->ForceCursorPosition( false );
@ -1869,6 +1871,67 @@ int ROUTER_TOOL::onTrackViaSizeChanged( const TOOL_EVENT& aEvent )
}
void ROUTER_TOOL::updateMessagePanel()
{
if( !m_router->RoutingInProgress() )
{
frame()->SetMsgPanel( board() );
return;
}
MSG_PANEL_ITEMS items;
PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
PNS::RULE_RESOLVER* resolver = m_iface->GetRuleResolver();
bool isDiffPair = m_router->Mode() == PNS::ROUTER_MODE::PNS_MODE_ROUTE_DIFF_PAIR;
if( m_startItem && m_startItem->Net() > 0 )
{
wxString description = isDiffPair ? _( "Routing Diff Pair: %s" ) : _( "Routing Track: %s" );
NETINFO_ITEM* netInfo = board()->FindNet( m_startItem->Net() );
wxASSERT( netInfo );
items.emplace_back( wxString::Format( description, netInfo->GetNetname() ),
wxString::Format( _( "Net Class: %s" ), netInfo->GetNetClassName() ) );
}
else
{
items.emplace_back( _( "Routing Track" ), _( "(no net)" ) );
}
EDA_UNITS units = frame()->GetUserUnits();
int width = isDiffPair ? sizes.DiffPairWidth() : sizes.TrackWidth();
items.emplace_back( wxString::Format( _( "Track Width: %s" ),
MessageTextFromValue( units, width ) ),
wxString::Format( _( "(from %s)" ), sizes.GetWidthSource() ) );
if( m_startItem )
{
PNS::SEGMENT dummy;
dummy.SetNet( m_startItem->Net() );
PNS::CONSTRAINT constraint;
if( resolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_CLEARANCE, &dummy, nullptr,
m_router->GetCurrentLayer(), &constraint ) )
{
items.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
MessageTextFromValue( units, constraint.m_Value.Min() ) ),
wxString::Format( _( "(from %s)" ), constraint.m_RuleName ) );
}
}
if( isDiffPair )
{
items.emplace_back( _( "Diff Pair Gap" ),
MessageTextFromValue( units, sizes.DiffPairGap() ) );
}
frame()->SetMsgPanel( items );
}
void ROUTER_TOOL::setTransitions()
{
Go( &ROUTER_TOOL::SelectCopperLayerPair, PCB_ACTIONS::selectLayerPair.MakeEvent() );

View File

@ -73,6 +73,8 @@ private:
bool finishInteractive();
void saveRouterDebugLog();
void updateMessagePanel();
private:
std::shared_ptr<ACTION_MENU> m_diffPairMenu;
std::shared_ptr<ACTION_MENU> m_trackViaMenu;