Better feedback for netclass assignment patterns.
This commit is contained in:
parent
c30a557810
commit
efae2bbb4c
|
@ -29,10 +29,12 @@
|
||||||
|
|
||||||
|
|
||||||
DIALOG_ASSIGN_NETCLASS::DIALOG_ASSIGN_NETCLASS( EDA_BASE_FRAME* aParent, const wxString aNetName,
|
DIALOG_ASSIGN_NETCLASS::DIALOG_ASSIGN_NETCLASS( EDA_BASE_FRAME* aParent, const wxString aNetName,
|
||||||
const std::set<wxString> aCandidateNetNames ) :
|
const std::set<wxString> aCandidateNetNames,
|
||||||
|
const std::function<void( const std::vector<wxString>& )>& aPreviewer ) :
|
||||||
DIALOG_ASSIGN_NETCLASS_BASE( aParent ),
|
DIALOG_ASSIGN_NETCLASS_BASE( aParent ),
|
||||||
m_frame( aParent ),
|
m_frame( aParent ),
|
||||||
m_netCandidates( aCandidateNetNames )
|
m_netCandidates( aCandidateNetNames ),
|
||||||
|
m_previewer( aPreviewer )
|
||||||
{
|
{
|
||||||
std::shared_ptr<NET_SETTINGS>& netSettings = m_frame->Prj().GetProjectFile().m_NetSettings;
|
std::shared_ptr<NET_SETTINGS>& netSettings = m_frame->Prj().GetProjectFile().m_NetSettings;
|
||||||
|
|
||||||
|
@ -79,25 +81,37 @@ void DIALOG_ASSIGN_NETCLASS::OnUpdateUI( wxUpdateUIEvent& event )
|
||||||
|
|
||||||
if( pattern != m_lastPattern )
|
if( pattern != m_lastPattern )
|
||||||
{
|
{
|
||||||
m_matchingNets->Clear();
|
CallAfter(
|
||||||
|
[this, pattern]()
|
||||||
|
{
|
||||||
|
m_matchingNets->Clear();
|
||||||
|
|
||||||
if( !pattern.IsEmpty() )
|
std::vector<wxString> matchingNetNames;
|
||||||
{
|
|
||||||
EDA_COMBINED_MATCHER matcher( pattern, CTX_NETCLASS );
|
|
||||||
|
|
||||||
m_matchingNets->Report( _( "<b>Currently matching nets:</b>" ) );
|
if( !pattern.IsEmpty() )
|
||||||
|
{
|
||||||
|
EDA_COMBINED_MATCHER matcher( pattern, CTX_NETCLASS );
|
||||||
|
|
||||||
for( const wxString& net : m_netCandidates )
|
m_matchingNets->Report( _( "<b>Currently matching nets:</b>" ) );
|
||||||
{
|
|
||||||
int matches;
|
|
||||||
int offset;
|
|
||||||
|
|
||||||
if( matcher.Find( net, matches, offset ) && offset == 0 )
|
for( const wxString& net : m_netCandidates )
|
||||||
m_matchingNets->Report( net );
|
{
|
||||||
}
|
int matches;
|
||||||
}
|
int offset;
|
||||||
|
|
||||||
|
if( matcher.Find( net, matches, offset ) && offset == 0 )
|
||||||
|
{
|
||||||
|
m_matchingNets->Report( net );
|
||||||
|
matchingNetNames.push_back( net );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_matchingNets->Flush();
|
||||||
|
|
||||||
|
m_previewer( matchingNetNames );
|
||||||
|
} );
|
||||||
|
|
||||||
m_matchingNets->Flush();
|
|
||||||
m_lastPattern = pattern;
|
m_lastPattern = pattern;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -580,10 +580,12 @@ void ACTION_MENU::runOnSubmenus( std::function<void(ACTION_MENU*)> aFunction )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::for_each( m_submenus.begin(), m_submenus.end(), [&]( ACTION_MENU* m ) {
|
std::for_each( m_submenus.begin(), m_submenus.end(),
|
||||||
aFunction( m );
|
[&]( ACTION_MENU* m )
|
||||||
m->runOnSubmenus( aFunction );
|
{
|
||||||
} );
|
aFunction( m );
|
||||||
|
m->runOnSubmenus( aFunction );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
catch( std::exception& )
|
catch( std::exception& )
|
||||||
{
|
{
|
||||||
|
@ -595,15 +597,17 @@ OPT_TOOL_EVENT ACTION_MENU::findToolAction( int aId )
|
||||||
{
|
{
|
||||||
OPT_TOOL_EVENT evt;
|
OPT_TOOL_EVENT evt;
|
||||||
|
|
||||||
auto findFunc = [&]( ACTION_MENU* m ) {
|
auto findFunc =
|
||||||
if( evt )
|
[&]( ACTION_MENU* m )
|
||||||
return;
|
{
|
||||||
|
if( evt )
|
||||||
|
return;
|
||||||
|
|
||||||
const auto it = m->m_toolActions.find( aId );
|
const auto it = m->m_toolActions.find( aId );
|
||||||
|
|
||||||
if( it != m->m_toolActions.end() )
|
if( it != m->m_toolActions.end() )
|
||||||
evt = it->second->MakeEvent();
|
evt = it->second->MakeEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
findFunc( this );
|
findFunc( this );
|
||||||
|
|
||||||
|
|
|
@ -1110,6 +1110,8 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
|
||||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
||||||
|
SCHEMATIC& schematic = m_frame->Schematic();
|
||||||
|
SCH_SCREEN* screen = m_frame->GetCurrentSheet().LastScreen();
|
||||||
|
|
||||||
// TODO remove once real-time connectivity is a given
|
// TODO remove once real-time connectivity is a given
|
||||||
if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
||||||
|
@ -1142,30 +1144,79 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxArrayString netNames;
|
wxString netName;
|
||||||
|
|
||||||
if( conn->IsBus() )
|
if( conn->IsBus() && conn->Members().size() )
|
||||||
{
|
{
|
||||||
for( const std::shared_ptr<SCH_CONNECTION>& member : conn->Members() )
|
const std::shared_ptr<SCH_CONNECTION>& member = conn->Members()[0];
|
||||||
{
|
|
||||||
if( member->IsBus() )
|
if( member->IsBus() && member->Members().size() )
|
||||||
{
|
netName = member->Members()[0]->Name();
|
||||||
for( const std::shared_ptr<SCH_CONNECTION>& subMember : member->Members() )
|
else
|
||||||
netNames.Add( subMember->Name() );
|
netName = member->Name();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
netNames.Add( member->Name() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
netNames.Add( conn->Name() );
|
netName = conn->Name();
|
||||||
}
|
}
|
||||||
|
|
||||||
DIALOG_ASSIGN_NETCLASS dlg( m_frame, netNames.front(),
|
DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, schematic.GetNetClassAssignmentCandidates(),
|
||||||
m_frame->Schematic().GetNetClassAssignmentCandidates() );
|
[&]( const std::vector<wxString>& aNetNames )
|
||||||
|
{
|
||||||
|
for( SCH_ITEM* item : screen->Items() )
|
||||||
|
{
|
||||||
|
bool redraw = item->IsBrightened();
|
||||||
|
SCH_CONNECTION* itemConn = item->Connection();
|
||||||
|
|
||||||
|
if( itemConn && alg::contains( aNetNames, itemConn->Name() ) )
|
||||||
|
item->SetBrightened();
|
||||||
|
else
|
||||||
|
item->ClearBrightened();
|
||||||
|
|
||||||
|
redraw |= item->IsBrightened();
|
||||||
|
|
||||||
|
if( item->Type() == SCH_SYMBOL_T )
|
||||||
|
{
|
||||||
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
||||||
|
|
||||||
|
redraw |= symbol->HasBrightenedPins();
|
||||||
|
|
||||||
|
symbol->ClearBrightenedPins();
|
||||||
|
|
||||||
|
for( SCH_PIN* pin : symbol->GetPins() )
|
||||||
|
{
|
||||||
|
SCH_CONNECTION* pin_conn = pin->Connection();
|
||||||
|
|
||||||
|
if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
|
||||||
|
{
|
||||||
|
pin->SetBrightened();
|
||||||
|
redraw = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( item->Type() == SCH_SHEET_T )
|
||||||
|
{
|
||||||
|
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
|
||||||
|
{
|
||||||
|
SCH_CONNECTION* pin_conn = pin->Connection();
|
||||||
|
|
||||||
|
redraw |= pin->IsBrightened();
|
||||||
|
|
||||||
|
if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
|
||||||
|
pin->SetBrightened();
|
||||||
|
else
|
||||||
|
pin->ClearBrightened();
|
||||||
|
|
||||||
|
redraw |= pin->IsBrightened();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( redraw )
|
||||||
|
getView()->Update( item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame->GetCanvas()->ForceRefresh();
|
||||||
|
} );
|
||||||
|
|
||||||
dlg.ShowModal();
|
dlg.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ class DIALOG_ASSIGN_NETCLASS : public DIALOG_ASSIGN_NETCLASS_BASE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DIALOG_ASSIGN_NETCLASS( EDA_BASE_FRAME* aParent, const wxString aNetName,
|
DIALOG_ASSIGN_NETCLASS( EDA_BASE_FRAME* aParent, const wxString aNetName,
|
||||||
const std::set<wxString> aCandidateNetNames );
|
const std::set<wxString> aCandidateNetNames,
|
||||||
|
const std::function<void( const std::vector<wxString>& )>& aPreviewer );
|
||||||
~DIALOG_ASSIGN_NETCLASS() override {}
|
~DIALOG_ASSIGN_NETCLASS() override {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -46,6 +47,8 @@ private:
|
||||||
EDA_BASE_FRAME* m_frame;
|
EDA_BASE_FRAME* m_frame;
|
||||||
std::set<wxString> m_netCandidates;
|
std::set<wxString> m_netCandidates;
|
||||||
|
|
||||||
|
const std::function<void( const std::vector<wxString>& )>& m_previewer;
|
||||||
|
|
||||||
wxString m_lastPattern;
|
wxString m_lastPattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1485,16 +1485,28 @@ int BOARD_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove selection in favor of highlighting so the whole net is highlighted
|
|
||||||
selectionTool->ClearSelection();
|
selectionTool->ClearSelection();
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::highlightNet, true, (void*) netCode );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectNet, true, (void*) netCode );
|
||||||
wxSafeYield();
|
canvas()->ForceRefresh();
|
||||||
|
|
||||||
DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, board()->GetNetClassAssignmentCandidates() );
|
DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, board()->GetNetClassAssignmentCandidates(),
|
||||||
|
[&]( const std::vector<wxString>& aNetNames )
|
||||||
|
{
|
||||||
|
selectionTool->ClearSelection();
|
||||||
|
|
||||||
|
for( const wxString& netName : aNetNames )
|
||||||
|
{
|
||||||
|
int netCode = board()->GetNetInfo().GetNetItem( netName )->GetNetCode();
|
||||||
|
|
||||||
|
if( netCode > 0 )
|
||||||
|
selectionTool->SelectAllItemsOnNet( netCode );
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas()->ForceRefresh();
|
||||||
|
} );
|
||||||
|
|
||||||
dlg.ShowModal();
|
dlg.ShowModal();
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::clearHighlight, true );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1348,7 +1348,7 @@ void PCB_SELECTION_TOOL::selectAllConnectedTracks(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_SELECTION_TOOL::selectAllItemsOnNet( int aNetCode, bool aSelect )
|
void PCB_SELECTION_TOOL::SelectAllItemsOnNet( int aNetCode, bool aSelect )
|
||||||
{
|
{
|
||||||
std::shared_ptr<CONNECTIVITY_DATA> conn = board()->GetConnectivity();
|
std::shared_ptr<CONNECTIVITY_DATA> conn = board()->GetConnectivity();
|
||||||
|
|
||||||
|
@ -1369,7 +1369,7 @@ int PCB_SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( netcode > 0 )
|
if( netcode > 0 )
|
||||||
{
|
{
|
||||||
selectAllItemsOnNet( netcode, select );
|
SelectAllItemsOnNet( netcode, select );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1384,7 +1384,7 @@ int PCB_SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
|
||||||
BOARD_CONNECTED_ITEM* connItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( i );
|
BOARD_CONNECTED_ITEM* connItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( i );
|
||||||
|
|
||||||
if( connItem )
|
if( connItem )
|
||||||
selectAllItemsOnNet( connItem->GetNetCode(), select );
|
SelectAllItemsOnNet( connItem->GetNetCode(), select );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inform other potentially interested tools
|
// Inform other potentially interested tools
|
||||||
|
@ -1789,7 +1789,7 @@ void PCB_SELECTION_TOOL::FindItem( BOARD_ITEM* aItem )
|
||||||
|
|
||||||
if( netCode > 0 )
|
if( netCode > 0 )
|
||||||
{
|
{
|
||||||
selectAllItemsOnNet( netCode, true );
|
SelectAllItemsOnNet( netCode, true );
|
||||||
m_frame->FocusOnLocation( aItem->GetCenter() );
|
m_frame->FocusOnLocation( aItem->GetCenter() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -131,6 +131,14 @@ public:
|
||||||
*/
|
*/
|
||||||
bool Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly = false ) const;
|
bool Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly = false ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select all items with the given net code.
|
||||||
|
*
|
||||||
|
* @param aNetCode is the target net to select
|
||||||
|
* @param aSelect is true to add the items to the selection, false to remove them (deselect)
|
||||||
|
*/
|
||||||
|
void SelectAllItemsOnNet( int aNetCode, bool aSelect = true );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to guess best selection candidates in case multiple items are clicked, by doing
|
* Try to guess best selection candidates in case multiple items are clicked, by doing
|
||||||
* some brain-dead heuristics.
|
* some brain-dead heuristics.
|
||||||
|
@ -306,14 +314,6 @@ private:
|
||||||
void selectAllConnectedTracks( const std::vector<BOARD_CONNECTED_ITEM*>& aStartItems,
|
void selectAllConnectedTracks( const std::vector<BOARD_CONNECTED_ITEM*>& aStartItems,
|
||||||
STOP_CONDITION aStopCondition );
|
STOP_CONDITION aStopCondition );
|
||||||
|
|
||||||
/**
|
|
||||||
* Select all items with the given net code.
|
|
||||||
*
|
|
||||||
* @param aNetCode is the target net to select
|
|
||||||
* @param aSelect is true to add the items to the selection, false to remove them (deselect)
|
|
||||||
*/
|
|
||||||
void selectAllItemsOnNet( int aNetCode, bool aSelect = true );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Select tracks and vias connected to specified board items.
|
* Select tracks and vias connected to specified board items.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -301,7 +301,7 @@ void PCB_SELECTION_TOOL::selectAllConnectedTracks(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_SELECTION_TOOL::selectAllItemsOnNet( int aNetCode, bool aSelect )
|
void PCB_SELECTION_TOOL::SelectAllItemsOnNet( int aNetCode, bool aSelect )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue