From c5120b9090987551ce6e442da4e3f88f50b6d187 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista <roberto.fer.bau@gmail.com> Date: Fri, 31 Jan 2025 15:47:27 +0100 Subject: [PATCH] Add fake-autoroute to context menus (router and edit) --- pcbnew/router/router_tool.cpp | 2 ++ pcbnew/tools/edit_tool.cpp | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 596d48f3f5..e9c41c61c8 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -527,6 +527,8 @@ bool ROUTER_TOOL::Init() menu.AddItem( PCB_ACTIONS::routerUndoLastSegment, SELECTION_CONDITIONS::ShowAlways ); menu.AddItem( PCB_ACTIONS::routerContinueFromEnd, hasOtherEnd ); menu.AddItem( PCB_ACTIONS::routerAttemptFinish, hasOtherEnd ); + menu.AddItem( PCB_ACTIONS::routerAutorouteSelected, notRoutingCond + && SELECTION_CONDITIONS::NotEmpty ); menu.AddItem( PCB_ACTIONS::breakTrack, notRoutingCond ); menu.AddItem( PCB_ACTIONS::drag45Degree, notRoutingCond ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index d3fd3fdbac..f720b6a60f 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -97,11 +97,11 @@ static const std::vector<KICAD_T> connectedTypes = { PCB_TRACE_T, PCB_PAD_T, PCB_ZONE_T }; -static const std::vector<KICAD_T> unroutableTypes = { PCB_TRACE_T, - PCB_ARC_T, - PCB_VIA_T, - PCB_PAD_T, - PCB_FOOTPRINT_T }; +static const std::vector<KICAD_T> routableTypes = { PCB_TRACE_T, + PCB_ARC_T, + PCB_VIA_T, + PCB_PAD_T, + PCB_FOOTPRINT_T }; EDIT_TOOL::EDIT_TOOL() : @@ -329,6 +329,13 @@ bool EDIT_TOOL::Init() return frame()->IsCurrentTool( PCB_ACTIONS::moveIndividually ); }; + SELECTION_CONDITION isRoutable = + SELECTION_CONDITIONS::NotEmpty + && SELECTION_CONDITIONS::OnlyTypes( routableTypes ) + && notMovingCondition + && !inFootprintEditor; + + const auto canCopyAsText = SELECTION_CONDITIONS::NotEmpty && SELECTION_CONDITIONS::OnlyTypes( { PCB_FIELD_T, @@ -349,10 +356,8 @@ bool EDIT_TOOL::Init() // clang-format off menu.AddItem( PCB_ACTIONS::move, SELECTION_CONDITIONS::NotEmpty && notMovingCondition ); - menu.AddItem( PCB_ACTIONS::unrouteSelected, SELECTION_CONDITIONS::NotEmpty - && SELECTION_CONDITIONS::OnlyTypes( unroutableTypes ) - && notMovingCondition - && !inFootprintEditor ); + menu.AddItem( PCB_ACTIONS::unrouteSelected, isRoutable ); + menu.AddItem( PCB_ACTIONS::routerAutorouteSelected, isRoutable ); menu.AddItem( PCB_ACTIONS::moveIndividually, SELECTION_CONDITIONS::MoreThan( 1 ) && notMovingCondition ); menu.AddItem( PCB_ACTIONS::skip, isSkippable );