Implement expanding Select Connection.

Fixes https://gitlab.com/kicad/code/kicad/issues/8579
This commit is contained in:
Jeff Young 2022-05-29 22:51:07 +01:00
parent 155620cc9a
commit d5d8d36d86
3 changed files with 19 additions and 5 deletions

View File

@ -355,7 +355,7 @@ SCH_ITEM* SCH_SCREEN::GetItem( const VECTOR2I& aPosition, int aAccuracy, KICAD_T
}
std::set<SCH_ITEM*> SCH_SCREEN::MarkConnections( SCH_LINE* aSegment )
std::set<SCH_ITEM*> SCH_SCREEN::MarkConnections( SCH_LINE* aSegment, bool aIgnorePins )
{
std::set<SCH_ITEM*> retval;
std::stack<SCH_LINE*> to_search;
@ -384,9 +384,9 @@ std::set<SCH_ITEM*> SCH_SCREEN::MarkConnections( SCH_LINE* aSegment )
SCH_LINE* line = static_cast<SCH_LINE*>( item );
if( ( test_item->IsEndPoint( line->GetStartPoint() )
&& !GetPin( line->GetStartPoint(), nullptr, true ) )
&& ( aIgnorePins || !GetPin( line->GetStartPoint(), nullptr, true ) ) )
|| ( test_item->IsEndPoint( line->GetEndPoint() )
&& !GetPin( line->GetEndPoint(), nullptr, true ) ) )
&& ( aIgnorePins || !GetPin( line->GetEndPoint(), nullptr, true ) ) ) )
{
auto result = retval.insert( line );

View File

@ -301,7 +301,7 @@ public:
*
* @param aSegment The segment to test for connections.
*/
std::set<SCH_ITEM*> MarkConnections( SCH_LINE* aSegment );
std::set<SCH_ITEM*> MarkConnections( SCH_LINE* aSegment, bool aIgnorePins );
/**
* Clear the state flags of all the items in the screen.

View File

@ -1430,12 +1430,26 @@ int EE_SELECTION_TOOL::SelectConnection( const TOOL_EVENT& aEvent )
SCH_LINE* line = (SCH_LINE*) m_selection.Front();
EDA_ITEMS items;
unsigned done = false;
m_frame->GetScreen()->ClearDrawingState();
std::set<SCH_ITEM*> conns = m_frame->GetScreen()->MarkConnections( line );
std::set<SCH_ITEM*> conns = m_frame->GetScreen()->MarkConnections( line, false );
for( SCH_ITEM* item : conns )
{
if( item->IsType( wiresAndBuses ) && !item->IsSelected() )
done = true;
select( item );
}
if( !done )
{
conns = m_frame->GetScreen()->MarkConnections( line, true );
for( SCH_ITEM* item : conns )
select( item );
}
if( m_selection.GetSize() > 1 )
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );