Selection fixes for multi-part lib items.

1) Don't select pins from other units/conversions
2) Don't delete pins from other units/conversions

Fixes: lp:1838511
* https://bugs.launchpad.net/kicad/+bug/1838511
This commit is contained in:
Jeff Young 2019-07-31 22:31:19 -06:00
parent bea74c27e5
commit 03a33b6b56
3 changed files with 28 additions and 28 deletions

View File

@ -436,7 +436,7 @@ EDA_ITEM* EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T*
// Post-process collected items
for( int i = collector.GetCount() - 1; i >= 0; --i )
{
if( !selectable( collector[ i ] ) )
if( !Selectable( collector[ i ] ) )
{
collector.Remove( i );
continue;
@ -719,7 +719,7 @@ bool EE_SELECTION_TOOL::selectMultiple()
{
EDA_ITEM* item = static_cast<EDA_ITEM*>( it->first );
if( !item || !selectable( item ) )
if( !item || !Selectable( item ) )
continue;
if( item->HitTest( selectionRect, windowSelection ) )
@ -1064,7 +1064,7 @@ bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector )
}
bool EE_SELECTION_TOOL::selectable( const EDA_ITEM* aItem, bool checkVisibilityOnly ) const
bool EE_SELECTION_TOOL::Selectable( const EDA_ITEM* aItem, bool checkVisibilityOnly ) const
{
// NOTE: in the future this is where eeschema layer/itemtype visibility will be handled
@ -1083,20 +1083,12 @@ bool EE_SELECTION_TOOL::selectable( const EDA_ITEM* aItem, bool checkVisibilityO
LIB_EDIT_FRAME* editFrame = (LIB_EDIT_FRAME*) m_frame;
LIB_PIN* pin = (LIB_PIN*) aItem;
if( ( pin->GetUnit() && pin->GetUnit() != editFrame->GetUnit() )
|| ( pin->GetConvert() && pin->GetConvert() != editFrame->GetConvert() ) )
{
// Specific rules for pins:
// - do not select pins in other units when synchronized pin edit mode is disabled
// - do not select pins in other units when units are not interchangeable
// - in other cases verify if the pin belongs to the requested DeMorgan variant
if( !editFrame->SynchronizePins()
|| editFrame->GetCurPart()->UnitsLocked()
|| ( pin->GetConvert() && pin->GetConvert() != editFrame->GetConvert() ) )
{
if( pin->GetUnit() && pin->GetUnit() != editFrame->GetUnit() )
return false;
}
}
if( pin->GetConvert() && pin->GetConvert() != editFrame->GetConvert() )
return false;
break;
}
case SCH_MARKER_T: // Always selectable

View File

@ -131,6 +131,13 @@ public:
void ClearSelection();
/**
* Function Selectable()
* Checks conditions for an item to be selected.
* @return True if the item fulfills conditions to be selected.
*/
bool Selectable( const EDA_ITEM* aItem, bool checkVisibilityOnly = false ) const;
/**
* Apply heuristics to try and determine a single object when multiple are found under the
* cursor.
@ -170,14 +177,6 @@ private:
*/
bool doSelectionMenu( EE_COLLECTOR* aItems );
/**
* Function selectable()
* Checks conditions for an item to be selected.
*
* @return True if the item fulfills conditions to be selected.
*/
bool selectable( const EDA_ITEM* aItem, bool checkVisibilityOnly = false ) const;
/**
* Function select()
* Takes necessary action mark an item as selected.

View File

@ -309,11 +309,20 @@ int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
picker->SetMotionHandler(
[this] ( const VECTOR2D& aPos )
{
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
EE_COLLECTOR collector;
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
collector.Collect( m_frame->GetCurPart(), nonFields, (wxPoint) aPos );
collector.Collect( m_frame->GetCurPart(), nonFields, (wxPoint) aPos,
m_frame->GetUnit(), m_frame->GetConvert() );
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
// Remove unselectable items
for( int i = collector.GetCount() - 1; i >= 0; --i )
{
if( !selectionTool->Selectable( collector[ i ] ) )
collector.Remove( i );
}
if( collector.GetCount() > 1 )
selectionTool->GuessSelectionCandidates( collector, aPos );
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;