From 1ca477aeee58b2852ef36f515a53a89adacfcb56 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 11 Oct 2023 16:02:07 +0100 Subject: [PATCH] Unroll from PICKER_TOOL so we can handle amplitude/spacing events. Also fixes a bug where we didn't clear the router on an . --- pcbnew/generators/pcb_generator_meanders.cpp | 5 +++++ pcbnew/tools/drawing_tool.cpp | 12 +++++++++++- pcbnew/tools/drawing_tool.h | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pcbnew/generators/pcb_generator_meanders.cpp b/pcbnew/generators/pcb_generator_meanders.cpp index f2689dbbad..f660c58ef7 100644 --- a/pcbnew/generators/pcb_generator_meanders.cpp +++ b/pcbnew/generators/pcb_generator_meanders.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -1160,6 +1161,9 @@ const wxString PCB_GENERATOR_MEANDERS::DISPLAY_NAME = _HKI( "Meanders" ); const wxString PCB_GENERATOR_MEANDERS::GENERATOR_TYPE = wxS( "meanders" ); +using SCOPED_DRAW_MODE = SCOPED_SET_RESET; + + #define HITTEST_THRESHOLD_PIXELS 5 @@ -1181,6 +1185,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent ) GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide(); GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool(); PNS::ROUTER* router = generatorTool->Router(); + SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::MEANDER ); m_pickerItem = nullptr; m_meander = nullptr; diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 9cb2c726a1..ae84c4520e 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -231,6 +231,12 @@ bool DRAWING_TOOL::Init() return m_mode == MODE::VIA; }; + auto meanderToolActive = + [this]( const SELECTION& aSel ) + { + return m_mode == MODE::MEANDER; + }; + CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu(); // cancel current tool goes in main context menu at the top if present @@ -244,8 +250,12 @@ bool DRAWING_TOOL::Init() ctxMenu.AddItem( PCB_ACTIONS::closeOutline, canCloseOutline, 200 ); ctxMenu.AddItem( PCB_ACTIONS::deleteLastPoint, canUndoPoint, 200 ); ctxMenu.AddItem( PCB_ACTIONS::arcPosture, arcToolActive, 200 ); + ctxMenu.AddItem( PCB_ACTIONS::spacingIncrease, meanderToolActive, 200 ); + ctxMenu.AddItem( PCB_ACTIONS::spacingDecrease, meanderToolActive, 200 ); + ctxMenu.AddItem( PCB_ACTIONS::amplIncrease, meanderToolActive, 200 ); + ctxMenu.AddItem( PCB_ACTIONS::amplDecrease, meanderToolActive, 200 ); - ctxMenu.AddCheckItem( PCB_ACTIONS::toggleHV45Mode, SELECTION_CONDITIONS::ShowAlways, 250 ); + ctxMenu.AddCheckItem( PCB_ACTIONS::toggleHV45Mode, !meanderToolActive, 250 ); ctxMenu.AddSeparator( 500 ); std::shared_ptr viaSizeMenu = std::make_shared(); diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index 7e494365eb..e8de64926b 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -79,7 +79,8 @@ public: KEEPOUT, ZONE, GRAPHIC_POLYGON, - VIA + VIA, + MEANDER }; /**