From 5aac36dba9851b0b8f97c8413dd9e3b01cfe080f Mon Sep 17 00:00:00 2001 From: Simon Richter Date: Fri, 27 Mar 2020 22:56:39 +0100 Subject: [PATCH] New enum for trace selection mode This avoids giving KICAD_T another meaning, which is especially messy here as "select up to the next via" is encoded as SCH_JUNCTION_T, which belongs to eeschema. Also, document what is happening. --- pcbnew/tools/selection_tool.cpp | 10 +++++----- pcbnew/tools/selection_tool.h | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 9138b658b4..d55ccb0d96 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -797,7 +797,7 @@ int SELECTION_TOOL::expandConnection( const TOOL_EVENT& aEvent ) if( initialCount == 0 ) selectCursor( true, connectedItemFilter ); - for( KICAD_T stopCondition : { PCB_VIA_T, PCB_PAD_T, EOT } ) + for( STOP_CONDITION stopCondition : { STOP_AT_JUNCTION, STOP_AT_PAD, STOP_NEVER } ) { // copy the selection, since we're going to iterate and modify std::deque selectedItems = m_selection.GetItems(); @@ -828,7 +828,7 @@ int SELECTION_TOOL::expandConnection( const TOOL_EVENT& aEvent ) void SELECTION_TOOL::selectConnectedTracks( BOARD_CONNECTED_ITEM& aStartItem, - KICAD_T aStopCondition ) + STOP_CONDITION aStopCondition ) { constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_PAD_T, EOT }; @@ -900,13 +900,13 @@ void SELECTION_TOOL::selectConnectedTracks( BOARD_CONNECTED_ITEM& aStartItem, { wxPoint pt = activePts[i]; - if( trackMap[ pt ].size() > 2 && aStopCondition == SCH_JUNCTION_T ) + if( trackMap[ pt ].size() > 2 && aStopCondition == STOP_AT_JUNCTION ) { activePts.erase( activePts.begin() + i ); continue; } - if( padMap.count( pt ) && aStopCondition != EOT ) + if( padMap.count( pt ) && aStopCondition != STOP_NEVER ) { activePts.erase( activePts.begin() + i ); continue; @@ -1012,7 +1012,7 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetPath ) std::list launchTracks; for( D_PAD* pad : padList ) - selectConnectedTracks( *pad, EOT ); + selectConnectedTracks( *pad, STOP_NEVER ); // 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 diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 03ef9c9a89..5901c23449 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -219,12 +219,26 @@ private: */ int selectNet( const TOOL_EVENT& aEvent ); + enum STOP_CONDITION + { + /** Stop at any place where more than two traces meet + * + * Because vias are also traces, this makes selection stop at a + * via if there is a trace on another layer as well, but a via + * with only one connection will be selected. */ + STOP_AT_JUNCTION, + /** Stop when reaching a pad */ + STOP_AT_PAD, + /** Select the entire net */ + STOP_NEVER + }; + /** * Selects connecteed tracks and vias. * - * @param aStopCondition must be one of JUNCTION_T, PAD_T, or EOT. + * @param aStopCondition where to stop selecting more items */ - void selectConnectedTracks( BOARD_CONNECTED_ITEM& aSourceItem, KICAD_T aStopCondition ); + void selectConnectedTracks( BOARD_CONNECTED_ITEM& aSourceItem, STOP_CONDITION aStopCondition ); /** * Selects all items with the given net code