SELECTION: Prevent double select/deselect.

When processing the selection filter, items were deselected before being
reselected after passing through the filter.  This adjusts the logic to
only deselect those items that are filtered out.
This commit is contained in:
Seth Hillbrand 2018-10-23 21:20:44 -07:00
parent 1dd22f5035
commit 90233e5ec6
2 changed files with 16 additions and 10 deletions

View File

@ -86,6 +86,14 @@ public:
virtual SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) = 0;
using ITER = std::vector<EDA_ITEM*>::iterator;
using CITER = std::vector<EDA_ITEM*>::const_iterator;
ITER begin() { return m_List.begin(); }
ITER end() { return m_List.end(); }
CITER begin() const { return m_List.cbegin(); }
CITER end() const { return m_List.cend(); }
/**
* Function IsValidIndex
* tests if \a aIndex is with the limits of the list of collected items.

View File

@ -422,19 +422,17 @@ SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aClientFilt
{
GENERAL_COLLECTOR collector;
while( m_selection.GetSize() )
{
collector.Append( m_selection.Front() );
unselect( static_cast<BOARD_ITEM*>( m_selection.Front() ) );
}
for( auto item : m_selection )
collector.Append( item );
aClientFilter( VECTOR2I(), collector );
for( int i = 0; i < collector.GetCount(); ++i )
{
m_additive = true;
select( collector[ i ] );
}
std::vector<EDA_ITEM*> diff;
std::set_difference( m_selection.begin(), m_selection.end(), collector.begin(), collector.end(),
std::back_inserter( diff ) );
for( auto item : diff )
unhighlight( static_cast<BOARD_ITEM*>( item ), SELECTED, m_selection );
m_frame->GetGalCanvas()->ForceRefresh();
}