From 4c94d02c421034a4a73fe7dbb56cd61a6e9d0093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20=C3=96dmark?= Date: Sun, 16 Jul 2017 13:39:30 +0200 Subject: [PATCH] Fixed sheet-selection code Fixes: lp:1704644 * https://bugs.launchpad.net/kicad/+bug/1704644 --- pcbnew/tools/selection_tool.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 8fa5c83ab9..e589156044 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -915,23 +915,28 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) // now we need to find all modules that are connected to each of these nets // then we need to determine if these modules are in the list of modules // belonging to this sheet ( modList ) - //RN_DATA* ratsnest = getModel()->GetRatsnest(); std::list removeCodeList; + + + KICAD_T padType[] = { PCB_PAD_T }; for( int netCode : netcodeList ) { - std::list netPads; -// fixme - // ratsnest->GetNetItems( netCode, netPads, (RN_ITEM_TYPE)( RN_PADS ) ); - for( BOARD_CONNECTED_ITEM* mitem : netPads ) + + for( BOARD_CONNECTED_ITEM* mitem : board()->GetConnectivity()->GetNetItems( netCode, padType ) ) { - bool found = ( std::find( modList.begin(), modList.end(), mitem->GetParent() ) != modList.end() ); - if( !found ) + if( mitem->Type() == PCB_PAD_T) { - // if we cannot find the module of the pad in the modList - // then we can assume that that module is not located in the same - // schematic, therefore invalidate this netcode. - removeCodeList.push_back( netCode ); - break; + + /* std::cout << "Checking net " << netCode << "of type " << mitem->Type() << ": "; */ + bool found = ( std::find( modList.begin(), modList.end(), mitem->GetParent() ) != modList.end() ); + if( !found ) + { + // if we cannot find the module of the pad in the modList + // then we can assume that that module is not located in the same + // schematic, therefore invalidate this netcode. + removeCodeList.push_back( netCode ); + break; + } } } } @@ -949,9 +954,10 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) for( int netCode : netcodeList ) { KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT }; - for( auto item : board()->GetConnectivity()->GetNetItems( netCode, types ) ) + for( BOARD_CONNECTED_ITEM* item : board()->GetConnectivity()->GetNetItems( netCode, types ) ) { localConnectionList.push_back( item ); + std::cout << netCode << std::endl; } }