From 10c5297f2efc8b9176997370ff8a522a7ff8770f Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 17 Jul 2017 10:21:36 +0200 Subject: [PATCH] Code clean-up and formatting --- pcbnew/connectivity.cpp | 5 ++++- pcbnew/tools/selection_tool.cpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pcbnew/connectivity.cpp b/pcbnew/connectivity.cpp index d8d08304ae..42285b09b6 100644 --- a/pcbnew/connectivity.cpp +++ b/pcbnew/connectivity.cpp @@ -578,15 +578,18 @@ const std::vector CONNECTIVITY_DATA::GetConnectedItems( return rv; } + RN_NET* CONNECTIVITY_DATA::GetRatsnestForNet( int aNet ) { - if ( aNet < 0 || aNet >= (int)m_nets.size() ) + if ( aNet < 0 || aNet >= (int) m_nets.size() ) { return nullptr; } + return m_nets[ aNet ]; } + void CONNECTIVITY_DATA::MarkItemNetAsDirty( BOARD_ITEM *aItem ) { if (aItem->Type() == PCB_MODULE_T) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index e589156044..1d73d25fe5 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -916,19 +916,17 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) // then we need to determine if these modules are in the list of modules // belonging to this sheet ( modList ) std::list removeCodeList; + constexpr KICAD_T padType[] = { PCB_PAD_T, EOT }; - - KICAD_T padType[] = { PCB_PAD_T }; for( int netCode : netcodeList ) { - for( BOARD_CONNECTED_ITEM* mitem : board()->GetConnectivity()->GetNetItems( netCode, padType ) ) { if( mitem->Type() == PCB_PAD_T) { + bool found = ( std::find( modList.begin(), modList.end(), + mitem->GetParent() ) != modList.end() ); - /* 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 @@ -951,13 +949,13 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) } std::list localConnectionList; + constexpr KICAD_T trackViaType[] = { PCB_TRACE_T, PCB_VIA_T, EOT }; + for( int netCode : netcodeList ) { - KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT }; - for( BOARD_CONNECTED_ITEM* item : board()->GetConnectivity()->GetNetItems( netCode, types ) ) + for( BOARD_CONNECTED_ITEM* item : board()->GetConnectivity()->GetNetItems( netCode, trackViaType ) ) { localConnectionList.push_back( item ); - std::cout << netCode << std::endl; } } @@ -966,6 +964,7 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) if( i != NULL ) select( i ); } + for( BOARD_CONNECTED_ITEM* i : localConnectionList ) { if( i != NULL ) @@ -973,6 +972,7 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) } } + void SELECTION_TOOL::zoomFitSelection( void ) { //Should recalculate the view to zoom in on the selection