diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp index 69fdfdbeaf..fea8eacc12 100644 --- a/pcbnew/tools/common_actions.cpp +++ b/pcbnew/tools/common_actions.cpp @@ -54,6 +54,10 @@ TOOL_ACTION COMMON_ACTIONS::selectionClear( "pcbnew.InteractiveSelection.Clear", "", "" ); // No description, it is not supposed to be shown anywhere TOOL_ACTION COMMON_ACTIONS::selectConnection( "pcbnew.InteractiveSelection.SelectConnection", + AS_GLOBAL, 0, + _( "trivial connection" ), _( "Selects a connection between two junctions." ) ); + +TOOL_ACTION COMMON_ACTIONS::selectCopper( "pcbnew.InteractiveSelection.SelectCopper", AS_GLOBAL, 0, _( "copper connection" ), _( "Selects whole copper connection." ) ); diff --git a/pcbnew/tools/common_actions.h b/pcbnew/tools/common_actions.h index 92a0272e7d..08b3a049c2 100644 --- a/pcbnew/tools/common_actions.h +++ b/pcbnew/tools/common_actions.h @@ -56,9 +56,12 @@ public: /// Unselects an item (specified as the event parameter). static TOOL_ACTION unselectItem; - /// Selects whole copper connection. + /// Selects a connection between junctions. static TOOL_ACTION selectConnection; + /// Selects whole copper connection. + static TOOL_ACTION selectCopper; + /// Selects all connections belonging to a single net. static TOOL_ACTION selectNet; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 1480a18809..bea16d8906 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -62,6 +62,7 @@ public: SELECT_MENU() { Add( COMMON_ACTIONS::selectConnection ); + Add( COMMON_ACTIONS::selectCopper ); Add( COMMON_ACTIONS::selectNet ); } }; @@ -88,7 +89,7 @@ bool SELECTION_TOOL::Init() m_selection.group = new KIGFX::VIEW_GROUP; m_menu.AddMenu( new SELECT_MENU, _( "Select..." ), false, - (SELECTION_CONDITION) SELECTION_CONDITIONS::OnlyConnectedItems && + ( SELECTION_CONDITIONS::OnlyType( PCB_VIA_T ) || SELECTION_CONDITIONS::OnlyType( PCB_TRACE_T ) ) && SELECTION_CONDITIONS::Count( 1 ) ); m_menu.AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1000 ); @@ -259,6 +260,11 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) selectConnection( *evt ); } + else if( evt->IsAction( &COMMON_ACTIONS::selectCopper ) ) + { + selectCopper( *evt ); + } + else if( evt->IsAction( &COMMON_ACTIONS::selectNet ) ) { selectNet( *evt ); @@ -459,6 +465,7 @@ void SELECTION_TOOL::SetTransitions() Go( &SELECTION_TOOL::find, COMMON_ACTIONS::find.MakeEvent() ); Go( &SELECTION_TOOL::findMove, COMMON_ACTIONS::findMove.MakeEvent() ); Go( &SELECTION_TOOL::selectConnection, COMMON_ACTIONS::selectConnection.MakeEvent() ); + Go( &SELECTION_TOOL::selectCopper, COMMON_ACTIONS::selectCopper.MakeEvent() ); Go( &SELECTION_TOOL::selectNet, COMMON_ACTIONS::selectNet.MakeEvent() ); } @@ -561,6 +568,35 @@ int SELECTION_TOOL::UnselectItem( const TOOL_EVENT& aEvent ) int SELECTION_TOOL::selectConnection( const TOOL_EVENT& aEvent ) +{ + BOARD_CONNECTED_ITEM* item = m_selection.Item( 0 ); + int segmentCount; + + if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T ) + return 0; + + clearSelection(); + TRACK* trackList = getModel()->MarkTrace( static_cast( item ), &segmentCount, + NULL, NULL, true ); + + if( segmentCount == 0 ) + return 0; + + for( int i = 0; i < segmentCount; ++i ) + { + select( trackList ); + trackList = trackList->Next(); + } + + // Inform other potentially interested tools + TOOL_EVENT selectEvent( SelectedEvent ); + m_toolMgr->ProcessEvent( selectEvent ); + + return 0; +} + + +int SELECTION_TOOL::selectCopper( const TOOL_EVENT& aEvent ) { std::list itemsList; RN_DATA* ratsnest = getModel()->GetRatsnest(); diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 57cf0100af..84d72f48b7 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -199,9 +199,12 @@ private: */ bool selectMultiple(); - ///> Selects a continuous copper connection. + ///> Selects a trivial connection (between two junctions). int selectConnection( const TOOL_EVENT& aEvent ); + ///> Selects a continuous copper connection. + int selectCopper( const TOOL_EVENT& aEvent ); + ///> Selects all copper connections belonging to a single net. int selectNet( const TOOL_EVENT& aEvent );