From 867067aa9c22b23e30d16d9d70cf7225c7eae9e2 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 17 Sep 2013 11:32:47 +0200 Subject: [PATCH] Selection in high contrast mode selects only items that are shown as active. --- pcbnew/tools/selection_tool.cpp | 46 ++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index b64eebbe00..6324937d73 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -118,7 +119,8 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) // Check if dragging event started within the currently selected items bounding box std::set::iterator it, it_end; - for( it = m_selectedItems.begin(), it_end = m_selectedItems.end(); it != it_end; ++it ) + for( it = m_selectedItems.begin(), it_end = m_selectedItems.end(); + it != it_end; ++it ) { BOX2I itemBox = (*it)->ViewBBox(); itemBox.Inflate( 500000 ); // Give some margin for gripping an item @@ -207,8 +209,8 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere ) break; default: - // Remove footprints, they have to be selected by clicking on area that does not - // contain anything but footprint + // Remove modules, they have to be selected by clicking on area that does not + // contain anything but module footprint for( int i = 0; i < collector.GetCount(); ++i ) { BOARD_ITEM* boardItem = ( collector )[i]; @@ -343,20 +345,26 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) int limit = std::min( 10, aCollector->GetCount() ); + int addedItems = 0; for( int i = 0; i < limit; ++i ) { wxString text; BOARD_ITEM* item = ( *aCollector )[i]; - text = item->GetSelectMenuText(); - m_menu->Add( text, i ); + if( selectable( item ) ) + { + text = item->GetSelectMenuText(); + m_menu->Add( text, i ); + addedItems++; + } } + if( addedItems == 0 ) // none of items was selectable + return NULL; + SetContextMenu( m_menu.get(), CMENU_NOW ); while( OPT_TOOL_EVENT evt = Wait() ) { - wxLogDebug( wxT( "disambiguation menu event") ); - if( evt->Action() == TA_ContextMenuUpdate ) { // User has pointed an item, so show it in a different way @@ -404,6 +412,30 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) { BOARD* board = getModel( PCB_T ); + bool highContrast = getView()->GetPainter()->GetSettings()->GetHighContrast(); + + if( highContrast ) + { + bool onActive = false; + int layers[KiGfx::VIEW::VIEW_MAX_LAYERS], layers_count; + + // Filter out items that do not belong to active layers + std::set activeLayers = getView()->GetPainter()-> + GetSettings()->GetActiveLayers(); + aItem->ViewGetLayers( layers, layers_count ); + + for( int i = 0; i < layers_count; ++i ) + { + if( activeLayers.count( layers[i] ) > 0 ) // Item is on at least one active layer + { + onActive = true; + break; + } + } + + if( !onActive ) + return false; + } switch( aItem->Type() ) {