From a39b9b88905e0da6cfc13c399818a1fe5882385d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 24 Apr 2024 10:51:03 +0100 Subject: [PATCH] Support legacy Length Tuning Settings workflow. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17748 (cherry picked from commit 978ef352d0338cd298fd03620eaf7846ad34392e) --- pcbnew/generators/pcb_tuning_pattern.cpp | 21 +++++++++++++++++---- pcbnew/tools/drawing_tool.cpp | 1 + pcbnew/tools/pcb_actions.cpp | 10 ++++++++++ pcbnew/tools/pcb_actions.h | 1 + 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/pcbnew/generators/pcb_tuning_pattern.cpp b/pcbnew/generators/pcb_tuning_pattern.cpp index b4c9fda9b3..8a004274af 100644 --- a/pcbnew/generators/pcb_tuning_pattern.cpp +++ b/pcbnew/generators/pcb_tuning_pattern.cpp @@ -2280,7 +2280,7 @@ int DRAWING_TOOL::PlaceTuningPattern( const TOOL_EVENT& aEvent ) if( collector.GetCount() > 0 ) { - double min_dist_sq = std::numeric_limits().max(); + double min_dist_sq = std::numeric_limits::max(); for( EDA_ITEM* candidate : collector ) { @@ -2323,8 +2323,8 @@ int DRAWING_TOOL::PlaceTuningPattern( const TOOL_EVENT& aEvent ) if( dynamic_cast( m_pickerItem->GetParentGroup() ) ) { - m_frame->ShowInfoBarWarning( - _( "Unable to tune segments inside other tuning patterns." ) ); + m_frame->ShowInfoBarWarning( _( "Unable to tune segments inside other " + "tuning patterns." ) ); } else { @@ -2381,6 +2381,10 @@ int DRAWING_TOOL::PlaceTuningPattern( const TOOL_EVENT& aEvent ) m_tuningPattern->SetSpacing( placer->MeanderSettings().m_spacing ); updateTuningPattern(); } + else + { + m_frame->ShowInfoBarWarning( _( "Select a track to tune first." ) ); + } } else if( evt->IsAction( &PCB_ACTIONS::amplIncrease ) || evt->IsAction( &PCB_ACTIONS::amplDecrease ) ) @@ -2393,8 +2397,13 @@ int DRAWING_TOOL::PlaceTuningPattern( const TOOL_EVENT& aEvent ) m_tuningPattern->SetMaxAmplitude( placer->MeanderSettings().m_maxAmplitude ); updateTuningPattern(); } + else + { + m_frame->ShowInfoBarWarning( _( "Select a track to tune first." ) ); + } } - else if( evt->IsAction( &PCB_ACTIONS::properties ) ) + else if( evt->IsAction( &PCB_ACTIONS::properties ) + || evt->IsAction( &PCB_ACTIONS::lengthTunerSettings ) ) { if( m_tuningPattern ) { @@ -2414,6 +2423,10 @@ int DRAWING_TOOL::PlaceTuningPattern( const TOOL_EVENT& aEvent ) if( dlg.ShowModal() == wxID_OK ) updateTuningPattern(); } + else + { + m_frame->ShowInfoBarWarning( _( "Select a track to tune first." ) ); + } } // TODO: It'd be nice to be able to say "don't allow any non-trivial editing actions", // but we don't at present have that, so we just knock out some of the egregious ones. diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 843b639bd3..cd462f8ba9 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -255,6 +255,7 @@ bool DRAWING_TOOL::Init() ctxMenu.AddItem( PCB_ACTIONS::spacingDecrease, tuningToolActive, 200 ); ctxMenu.AddItem( PCB_ACTIONS::amplIncrease, tuningToolActive, 200 ); ctxMenu.AddItem( PCB_ACTIONS::amplDecrease, tuningToolActive, 200 ); + ctxMenu.AddItem( PCB_ACTIONS::lengthTunerSettings, tuningToolActive, 200 ); ctxMenu.AddCheckItem( PCB_ACTIONS::toggleHV45Mode, !tuningToolActive, 250 ); ctxMenu.AddSeparator( 500 ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 87b1a5469b..1c05ffacca 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -2425,6 +2425,16 @@ TOOL_ACTION PCB_ACTIONS::generatorsShowManager( TOOL_ACTION_ARGS() // LENGTH_TUNER_TOOL // +TOOL_ACTION PCB_ACTIONS::lengthTunerSettings( TOOL_ACTION_ARGS() + .Name( "pcbnew.LengthTuner.Settings" ) + .Scope( AS_CONTEXT ) + .DefaultHotkey( MD_CTRL + 'L' ) + // Don't be tempted to remove "Modern Toolset only". It's in the legacy property name. + .LegacyHotkeyName( "Length Tuning Settings (Modern Toolset only)" ) + .MenuText( _( "Length Tuning Settings..." ) ) + .Tooltip( _( "Displays tuning pattern properties dialog" ) ) + .Icon( BITMAPS::router_len_tuner_setup ) ); + TOOL_ACTION PCB_ACTIONS::ddAppendBoard( TOOL_ACTION_ARGS() .Name( "pcbnew.Control.DdAppendBoard" ) .Scope( AS_GLOBAL ) ); diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 86686d3913..626ad71841 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -204,6 +204,7 @@ public: static TOOL_ACTION spacingDecrease; static TOOL_ACTION amplIncrease; static TOOL_ACTION amplDecrease; + static TOOL_ACTION lengthTunerSettings; static TOOL_ACTION drawAlignedDimension; static TOOL_ACTION drawCenterDimension; static TOOL_ACTION drawRadialDimension;