From d2c47a74f2c67a41c2e783d183c6456966c47cc7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Sep 2013 10:10:02 +0200 Subject: [PATCH] Parts of MODULEs are not selectable in multiple selection mode. --- pcbnew/tools/selection_tool.cpp | 40 +++++++++++++-------------------- pcbnew/tools/selection_tool.h | 9 +++----- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index c1a68a1914..63689482b5 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -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::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; - } - } -} diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index e198542b78..c76743d266 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -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 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