Commit d2c47a74 authored by Maciej Suminski's avatar Maciej Suminski

Parts of MODULEs are not selectable in multiple selection mode.

parent 31f7ecc1
...@@ -44,7 +44,7 @@ using namespace KiGfx; ...@@ -44,7 +44,7 @@ using namespace KiGfx;
using boost::optional; using boost::optional;
SELECTION_TOOL::SELECTION_TOOL() : SELECTION_TOOL::SELECTION_TOOL() :
TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ) TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), m_multiple( false )
{ {
m_selArea = new SELECTION_AREA; m_selArea = new SELECTION_AREA;
} }
...@@ -233,6 +233,7 @@ bool SELECTION_TOOL::selectMultiple() ...@@ -233,6 +233,7 @@ bool SELECTION_TOOL::selectMultiple()
OPT_TOOL_EVENT evt; OPT_TOOL_EVENT evt;
VIEW* v = getView(); VIEW* v = getView();
bool cancelled = false; bool cancelled = false;
m_multiple = true;
// Those 2 lines remove the blink-in-the-random-place effect // Those 2 lines remove the blink-in-the-random-place effect
m_selArea->SetOrigin( VECTOR2I( 0, 0 ) ); m_selArea->SetOrigin( VECTOR2I( 0, 0 ) );
...@@ -281,13 +282,12 @@ bool SELECTION_TOOL::selectMultiple() ...@@ -281,13 +282,12 @@ bool SELECTION_TOOL::selectMultiple()
m_selectedItems.insert( item ); m_selectedItems.insert( item );
} }
} }
handleModules();
break; break;
} }
} }
v->Remove( m_selArea ); v->Remove( m_selArea );
m_multiple = false;
return cancelled; return cancelled;
} }
...@@ -370,6 +370,11 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) ...@@ -370,6 +370,11 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem )
break; break;
case PCB_PAD_T: 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) // 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 ) ) if( aItem->IsOnLayer( LAYER_N_FRONT ) && board->IsLayerVisible( LAYER_N_FRONT ) )
return true; return true;
...@@ -377,6 +382,13 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) ...@@ -377,6 +382,13 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem )
if( aItem->IsOnLayer( LAYER_N_BACK ) && board->IsLayerVisible( LAYER_N_BACK ) ) if( aItem->IsOnLayer( LAYER_N_BACK ) && board->IsLayerVisible( LAYER_N_BACK ) )
return true; return true;
return false;
}
break;
case PCB_MODULE_TEXT_T:
// Module texts are not selectable in multiple selection mode
if( m_multiple )
return false; return false;
break; break;
...@@ -389,25 +401,3 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) ...@@ -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 // All other items are selected only if the layer on which they exist is visible
return board->IsLayerVisible( aItem->GetLayer() ); 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;
}
}
}
...@@ -131,12 +131,6 @@ private: ...@@ -131,12 +131,6 @@ private:
*/ */
bool selectable( const BOARD_ITEM* aItem ); 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 /// Container storing currently selected items
std::set<BOARD_ITEM*> m_selectedItems; std::set<BOARD_ITEM*> m_selectedItems;
...@@ -148,6 +142,9 @@ private: ...@@ -148,6 +142,9 @@ private:
/// Flag saying if items should be added to the current selection or rather replace it /// Flag saying if items should be added to the current selection or rather replace it
bool m_additive; bool m_additive;
/// Flag saying if multiple selection mode is active
bool m_multiple;
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment