mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-15 02:33:15 +02:00
Add ability to quickly move through nets
After highlighting a net (`), press Tab to quikcly move to the next item on the net and Shift-Tab to move to the previous Fixes https://gitlab.com/kicad/code/kicad/-/issues/10911
This commit is contained in:
parent
7cfa826c9a
commit
1e9cf4e3d7
@ -379,6 +379,82 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const SCH_ITEM* SCH_EDIT_FRAME::SelectNextPrevNetNavigatorItem( bool aNext )
|
||||||
|
{
|
||||||
|
wxCHECK( m_netNavigator, nullptr );
|
||||||
|
|
||||||
|
wxTreeItemId id = m_netNavigator->GetSelection();
|
||||||
|
|
||||||
|
if( !id.IsOk() )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
wxTreeItemId nextId;
|
||||||
|
wxTreeItemId netNode = m_netNavigator->GetRootItem();
|
||||||
|
|
||||||
|
std::vector<wxTreeItemId> netItems;
|
||||||
|
std::list<wxTreeItemId> itemList;
|
||||||
|
itemList.push_back( netNode );
|
||||||
|
|
||||||
|
while( !itemList.empty() )
|
||||||
|
{
|
||||||
|
wxTreeItemId current = itemList.front();
|
||||||
|
itemList.pop_front();
|
||||||
|
|
||||||
|
wxTreeItemIdValue cookie;
|
||||||
|
wxTreeItemId child = m_netNavigator->GetFirstChild( current, cookie );
|
||||||
|
|
||||||
|
while( child.IsOk() )
|
||||||
|
{
|
||||||
|
if( m_netNavigator->ItemHasChildren( child ) )
|
||||||
|
itemList.push_back( child );
|
||||||
|
else
|
||||||
|
netItems.push_back( child );
|
||||||
|
|
||||||
|
child = m_netNavigator->GetNextSibling( child );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Locate current item and move forward or backward with wrap
|
||||||
|
auto it = std::find( netItems.begin(), netItems.end(), id );
|
||||||
|
|
||||||
|
if( it != netItems.end() )
|
||||||
|
{
|
||||||
|
if( aNext )
|
||||||
|
{
|
||||||
|
++it;
|
||||||
|
if( it == netItems.end() )
|
||||||
|
it = netItems.begin();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( it == netItems.begin() )
|
||||||
|
it = netItems.end();
|
||||||
|
--it;
|
||||||
|
}
|
||||||
|
nextId = *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( nextId.IsOk() )
|
||||||
|
{
|
||||||
|
if( !m_netNavigator->IsVisible( nextId ) )
|
||||||
|
{
|
||||||
|
m_netNavigator->CollapseAll();
|
||||||
|
m_netNavigator->EnsureVisible( nextId );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_netNavigator->SelectItem( nextId );
|
||||||
|
|
||||||
|
NET_NAVIGATOR_ITEM_DATA* data = static_cast<NET_NAVIGATOR_ITEM_DATA*>(
|
||||||
|
m_netNavigator->GetItemData( nextId ) );
|
||||||
|
|
||||||
|
if( data && data->GetItem() )
|
||||||
|
return data->GetItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::SelectNetNavigatorItem( const NET_NAVIGATOR_ITEM_DATA* aSelection )
|
void SCH_EDIT_FRAME::SelectNetNavigatorItem( const NET_NAVIGATOR_ITEM_DATA* aSelection )
|
||||||
{
|
{
|
||||||
wxCHECK( m_netNavigator, /* void */ );
|
wxCHECK( m_netNavigator, /* void */ );
|
||||||
|
@ -955,6 +955,8 @@ public:
|
|||||||
|
|
||||||
void SelectNetNavigatorItem( const NET_NAVIGATOR_ITEM_DATA* aSelection = nullptr );
|
void SelectNetNavigatorItem( const NET_NAVIGATOR_ITEM_DATA* aSelection = nullptr );
|
||||||
|
|
||||||
|
const SCH_ITEM* SelectNextPrevNetNavigatorItem( bool aNext );
|
||||||
|
|
||||||
void ToggleNetNavigator();
|
void ToggleNetNavigator();
|
||||||
|
|
||||||
PLUGIN_ACTION_SCOPE PluginActionScope() const override
|
PLUGIN_ACTION_SCOPE PluginActionScope() const override
|
||||||
|
@ -1108,6 +1108,20 @@ TOOL_ACTION EE_ACTIONS::remapSymbols( TOOL_ACTION_ARGS()
|
|||||||
.Tooltip( _( "Remap library symbol references in legacy schematics to the symbol library table" ) )
|
.Tooltip( _( "Remap library symbol references in legacy schematics to the symbol library table" ) )
|
||||||
.Icon( BITMAPS::rescue ) );
|
.Icon( BITMAPS::rescue ) );
|
||||||
|
|
||||||
|
TOOL_ACTION EE_ACTIONS::nextNetItem( TOOL_ACTION_ARGS()
|
||||||
|
.Name( "eeschema.EditorControl.nextNetItem" )
|
||||||
|
.Scope( AS_GLOBAL )
|
||||||
|
.DefaultHotkey( WXK_TAB )
|
||||||
|
.FriendlyName( _( "Next Net Item" ) )
|
||||||
|
.Tooltip( _( "Select next item on the current net" ) ) );
|
||||||
|
|
||||||
|
TOOL_ACTION EE_ACTIONS::previousNetItem( TOOL_ACTION_ARGS()
|
||||||
|
.Name( "eeschema.EditorControl.previousNetItem" )
|
||||||
|
.Scope( AS_GLOBAL )
|
||||||
|
.DefaultHotkey( MD_SHIFT + static_cast<int>( WXK_TAB ) )
|
||||||
|
.FriendlyName( _( "Previous Net Item" ) )
|
||||||
|
.Tooltip( _( "Select previous item on the current net" ) ) );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::drawSheetOnClipboard( TOOL_ACTION_ARGS()
|
TOOL_ACTION EE_ACTIONS::drawSheetOnClipboard( TOOL_ACTION_ARGS()
|
||||||
.Name( "eeschema.EditorControl.drawSheetOnClipboard" )
|
.Name( "eeschema.EditorControl.drawSheetOnClipboard" )
|
||||||
.Scope( AS_GLOBAL )
|
.Scope( AS_GLOBAL )
|
||||||
|
@ -176,6 +176,9 @@ public:
|
|||||||
static TOOL_ACTION rescueSymbols;
|
static TOOL_ACTION rescueSymbols;
|
||||||
static TOOL_ACTION remapSymbols;
|
static TOOL_ACTION remapSymbols;
|
||||||
|
|
||||||
|
static TOOL_ACTION nextNetItem;
|
||||||
|
static TOOL_ACTION previousNetItem;
|
||||||
|
|
||||||
// Suite operations
|
// Suite operations
|
||||||
static TOOL_ACTION editWithLibEdit;
|
static TOOL_ACTION editWithLibEdit;
|
||||||
static TOOL_ACTION editLibSymbolWithLibEdit;
|
static TOOL_ACTION editLibSymbolWithLibEdit;
|
||||||
|
@ -2855,6 +2855,50 @@ bool EE_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int EE_SELECTION_TOOL::SelectNext( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
||||||
|
|
||||||
|
if( !editFrame || !editFrame->GetNetNavigator() || m_selection.Size() == 0 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( !m_selection.Front()->IsBrightened() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
const SCH_ITEM* item = editFrame->SelectNextPrevNetNavigatorItem( true );
|
||||||
|
|
||||||
|
if( item )
|
||||||
|
{
|
||||||
|
select( const_cast<SCH_ITEM*>( item ) );
|
||||||
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int EE_SELECTION_TOOL::SelectPrevious( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
|
||||||
|
|
||||||
|
if( !editFrame || !editFrame->GetNetNavigator() || m_selection.Size() == 0 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( !m_selection.Front()->IsBrightened() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
const SCH_ITEM* item = editFrame->SelectNextPrevNetNavigatorItem( false );
|
||||||
|
|
||||||
|
if( item )
|
||||||
|
{
|
||||||
|
select( const_cast<SCH_ITEM*>( item ) );
|
||||||
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EE_SELECTION_TOOL::setTransitions()
|
void EE_SELECTION_TOOL::setTransitions()
|
||||||
{
|
{
|
||||||
Go( &EE_SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() );
|
Go( &EE_SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() );
|
||||||
@ -2877,6 +2921,9 @@ void EE_SELECTION_TOOL::setTransitions()
|
|||||||
Go( &EE_SELECTION_TOOL::SelectAll, EE_ACTIONS::selectAll.MakeEvent() );
|
Go( &EE_SELECTION_TOOL::SelectAll, EE_ACTIONS::selectAll.MakeEvent() );
|
||||||
Go( &EE_SELECTION_TOOL::UnselectAll, EE_ACTIONS::unselectAll.MakeEvent() );
|
Go( &EE_SELECTION_TOOL::UnselectAll, EE_ACTIONS::unselectAll.MakeEvent() );
|
||||||
|
|
||||||
|
Go( &EE_SELECTION_TOOL::SelectNext, EE_ACTIONS::nextNetItem.MakeEvent() );
|
||||||
|
Go( &EE_SELECTION_TOOL::SelectPrevious, EE_ACTIONS::previousNetItem.MakeEvent() );
|
||||||
|
|
||||||
Go( &EE_SELECTION_TOOL::disambiguateCursor, EVENTS::DisambiguatePoint );
|
Go( &EE_SELECTION_TOOL::disambiguateCursor, EVENTS::DisambiguatePoint );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +152,12 @@ public:
|
|||||||
///< Unselect all visible items in sheet
|
///< Unselect all visible items in sheet
|
||||||
int UnselectAll( const TOOL_EVENT& aEvent );
|
int UnselectAll( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///< Select next net item
|
||||||
|
int SelectNext( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///< Select previous net item
|
||||||
|
int SelectPrevious( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
void ClearSelection( bool aQuietMode = false );
|
void ClearSelection( bool aQuietMode = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user