diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 646b8342ba..4bd30aa363 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -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( 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() ) ) - { - return false; - } - } + 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 diff --git a/eeschema/tools/ee_selection_tool.h b/eeschema/tools/ee_selection_tool.h index b40fff0de8..701fe3fd17 100644 --- a/eeschema/tools/ee_selection_tool.h +++ b/eeschema/tools/ee_selection_tool.h @@ -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. diff --git a/eeschema/tools/lib_edit_tool.cpp b/eeschema/tools/lib_edit_tool.cpp index a8c685f586..2147d7c254 100644 --- a/eeschema/tools/lib_edit_tool.cpp +++ b/eeschema/tools/lib_edit_tool.cpp @@ -309,12 +309,21 @@ int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) picker->SetMotionHandler( [this] ( const VECTOR2D& aPos ) { + EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool(); 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(); - selectionTool->GuessSelectionCandidates( collector, aPos ); + // 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;