eeschema: Handle Rebuild for subcomponents

The parents are the only items that live in the RTree, so the rebuild
check needs to recurse into the sub structure to check for selection

Fixes https://gitlab.com/kicad/code/kicad/issues/3858
This commit is contained in:
Seth Hillbrand 2020-02-04 22:48:33 -06:00
parent 2507f985ad
commit 7d64527eeb
3 changed files with 37 additions and 5 deletions

View File

@ -852,6 +852,18 @@ void SCH_COMPONENT::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOn
}
std::vector<SCH_FIELD*> SCH_COMPONENT::GetFields()
{
std::vector<SCH_FIELD*> retvec;
retvec.reserve( m_Fields.size() );
for( SCH_FIELD& field : m_Fields )
retvec.push_back( &field );
return retvec;
}
SCH_FIELD* SCH_COMPONENT::AddField( const SCH_FIELD& aField )
{
int newNdx = m_Fields.size();

View File

@ -4,7 +4,7 @@
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -374,6 +374,11 @@ public:
*/
void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly );
/**
* Returns a vector of fields from the component
*/
std::vector<SCH_FIELD*> GetFields();
/**
* Add a field to the symbol.
*

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 CERN
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -984,12 +984,27 @@ void EE_SELECTION_TOOL::RebuildSelection()
for( auto item : m_frame->GetScreen()->Items() )
{
// If the field and component are selected, only use the component
if( item->IsSelected()
&& !( item->Type() == SCH_FIELD_T && item->GetParent()
&& item->GetParent()->IsSelected() ) )
if( item->IsSelected() )
{
select( item );
}
else
{
if( item->Type() == SCH_COMPONENT_T )
{
for( auto field : static_cast<SCH_COMPONENT*>( item )->GetFields() )
if( field->IsSelected() )
select( field );
}
if( item->Type() == SCH_SHEET_T )
{
for( auto pin : static_cast<SCH_SHEET*>( item )->GetPins() )
if( pin->IsSelected() )
select( pin );
}
}
}
}