When running selectable() recursively, we're really only checking visibility.

Fixes: lp:1802949
* https://bugs.launchpad.net/kicad/+bug/1802949
This commit is contained in:
Jeff Young 2018-11-12 21:59:02 +00:00
parent 0a71212929
commit 6d76097291
2 changed files with 17 additions and 12 deletions

View File

@ -1527,7 +1527,7 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
}
bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem, bool ignoreMultipleFlag ) const
bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly ) const
{
// Is high contrast mode enabled?
bool highContrast = getView()->GetPainter()->GetSettings()->GetHighContrast();
@ -1653,8 +1653,11 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem, bool ignoreMultipleFla
// Multiple selection is only allowed in modedit mode. In pcbnew, you have to select
// module subparts one by one, rather than with a drag selection. This is so you can
// pick up items under an (unlocked) module without also moving the module's sub-parts.
if( m_multiple && !ignoreMultipleFlag && !m_editModules )
if( !m_editModules && !checkVisibilityOnly )
{
if( m_multiple )
return false;
}
if( !m_editModules && !view()->IsVisible( aItem ) )
return false;
@ -1667,15 +1670,9 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem, bool ignoreMultipleFla
// Multiple selection is only allowed in modedit mode. In pcbnew, you have to select
// module subparts one by one, rather than with a drag selection. This is so you can
// pick up items under an (unlocked) module without also moving the module's sub-parts.
if( m_multiple && !ignoreMultipleFlag && !m_editModules )
return false;
// In pcbnew, locked modules prevent individual pad selection.
// In modedit, we don't enforce this as the module is assumed to be edited by design.
if( !m_editModules )
if( !m_editModules && !checkVisibilityOnly )
{
MODULE* mod = static_cast<const D_PAD*>( aItem )->GetParent();
if( mod && mod->IsLocked() )
if( m_multiple )
return false;
}
@ -1683,6 +1680,14 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem, bool ignoreMultipleFla
{
auto pad = static_cast<const D_PAD*>( aItem );
// In pcbnew, locked modules prevent individual pad selection.
// In modedit, we don't enforce this as the module is assumed to be edited by design.
if( !m_editModules && !checkVisibilityOnly )
{
if( pad->GetParent() && pad->GetParent()->IsLocked() )
return false;
}
// Check render mode (from the Items tab) first
switch( pad->GetAttribute() )
{

View File

@ -273,7 +273,7 @@ private:
*
* @return True if the item fulfills conditions to be selected.
*/
bool selectable( const BOARD_ITEM* aItem, bool ignoreMultipleFlag = false ) const;
bool selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly = false ) const;
/**
* Function select()