Parts of MODULEs are not selectable in multiple selection mode.

This commit is contained in:
Maciej Suminski 2013-09-09 10:10:02 +02:00
parent 31f7ecc16a
commit d2c47a74f2
2 changed files with 18 additions and 31 deletions

View File

@ -44,7 +44,7 @@ using namespace KiGfx;
using boost::optional;
SELECTION_TOOL::SELECTION_TOOL() :
TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" )
TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), m_multiple( false )
{
m_selArea = new SELECTION_AREA;
}
@ -233,6 +233,7 @@ bool SELECTION_TOOL::selectMultiple()
OPT_TOOL_EVENT evt;
VIEW* v = getView();
bool cancelled = false;
m_multiple = true;
// Those 2 lines remove the blink-in-the-random-place effect
m_selArea->SetOrigin( VECTOR2I( 0, 0 ) );
@ -281,13 +282,12 @@ bool SELECTION_TOOL::selectMultiple()
m_selectedItems.insert( item );
}
}
handleModules();
break;
}
}
v->Remove( m_selArea );
m_multiple = false;
return cancelled;
}
@ -370,6 +370,11 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem )
break;
case PCB_PAD_T:
{
// Pads are not selectable in multiple selection mode
if( m_multiple )
return false;
// Pads are supposed to be on top, bottom or both at the same time (THT)
if( aItem->IsOnLayer( LAYER_N_FRONT ) && board->IsLayerVisible( LAYER_N_FRONT ) )
return true;
@ -378,6 +383,13 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem )
return true;
return false;
}
break;
case PCB_MODULE_TEXT_T:
// Module texts are not selectable in multiple selection mode
if( m_multiple )
return false;
break;
case PCB_MODULE_EDGE_T:
@ -389,25 +401,3 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem )
// All other items are selected only if the layer on which they exist is visible
return board->IsLayerVisible( aItem->GetLayer() );
}
void SELECTION_TOOL::handleModules()
{
std::set<BOARD_ITEM*>::iterator it, it_end;
for( it = m_selectedItems.begin(), it_end = m_selectedItems.end(); it != it_end; )
{
BOARD_ITEM* parent = (*it)->GetParent();
// Do not allow to select MODULE and it's parts at the same time
if( parent != NULL && parent->IsSelected() )
{
(*it)->ClearSelected();
m_selectedItems.erase( it++ );
}
else
{
++it;
}
}
}

View File

@ -131,12 +131,6 @@ private:
*/
bool selectable( const BOARD_ITEM* aItem );
/**
* Prevents from selecting both MODULEs and it's parts at the same time. The right way is
* to select a MODULE *or* some of it's parts.
*/
void handleModules();
/// Container storing currently selected items
std::set<BOARD_ITEM*> m_selectedItems;
@ -148,6 +142,9 @@ private:
/// Flag saying if items should be added to the current selection or rather replace it
bool m_additive;
/// Flag saying if multiple selection mode is active
bool m_multiple;
};
#endif