From 04b71f5167509c3684155159405b096442b492e1 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Sat, 19 Jun 2021 21:04:58 +0100 Subject: [PATCH] Meander minimum spacing can be equal to track width + minimum clearance 2x track width was too constraining in some scenarios Also better wording "Min Spacing" to indicate to the user that the actual spacing could be larger if there are any constraints. Fixes https://gitlab.com/kicad/code/kicad/-/issues/8172 --- ...dialog_pns_length_tuning_settings_base.cpp | 4 +++- ...dialog_pns_length_tuning_settings_base.fbp | 4 ++-- pcbnew/router/pns_meander.cpp | 6 ++++-- pcbnew/router/pns_meander_placer_base.cpp | 19 ++++++++++++++++++- pcbnew/router/pns_meander_placer_base.h | 7 +++++++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp index 17431c906a..36f895c2ef 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp @@ -128,11 +128,13 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE::DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE( m_maxAmplUnit->Wrap( -1 ); fgSizer3->Add( m_maxAmplUnit, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 ); - m_spacingLabel = new wxStaticText( sbSizerLower->GetStaticBox(), wxID_ANY, _("Spacing (s):"), wxDefaultPosition, wxDefaultSize, 0 ); + m_spacingLabel = new wxStaticText( sbSizerLower->GetStaticBox(), wxID_ANY, _("Min spacing (s):"), wxDefaultPosition, wxDefaultSize, 0 ); m_spacingLabel->Wrap( -1 ); fgSizer3->Add( m_spacingLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); m_spacingText = new wxTextCtrl( sbSizerLower->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_spacingText->SetToolTip( _("Minimum spacing between adjacent meander segments. The resulting spacing may be greater based on design rules.") ); + fgSizer3->Add( m_spacingText, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); m_spacingUnit = new wxStaticText( sbSizerLower->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp index 3d5d62aadb..2054bb05a6 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp @@ -1171,7 +1171,7 @@ 0 0 wxID_ANY - Spacing (s): + Min spacing (s): 0 0 @@ -1253,7 +1253,7 @@ ; ; forward_declare 0 - + Minimum spacing between adjacent meander segments. The resulting spacing may be greater based on design rules. wxFILTER_NONE wxDefaultValidator diff --git a/pcbnew/router/pns_meander.cpp b/pcbnew/router/pns_meander.cpp index 4d8e6f54d6..14d9507b48 100644 --- a/pcbnew/router/pns_meander.cpp +++ b/pcbnew/router/pns_meander.cpp @@ -176,10 +176,12 @@ int MEANDER_SHAPE::cornerRadius() const int MEANDER_SHAPE::spacing( ) const { if( !m_dual ) - return std::max( 2 * m_width, Settings().m_spacing ); + { + return std::max( m_width + m_placer->Clearance(), Settings().m_spacing ); + } else { - int sp = 2 * ( m_width + std::abs( m_baselineOffset ) ); + int sp = m_width + m_placer->Clearance() + ( 2 * std::abs( m_baselineOffset ) ); return std::max( sp, Settings().m_spacing ); } } diff --git a/pcbnew/router/pns_meander_placer_base.cpp b/pcbnew/router/pns_meander_placer_base.cpp index a134c4b2b8..6a2ca26a2e 100644 --- a/pcbnew/router/pns_meander_placer_base.cpp +++ b/pcbnew/router/pns_meander_placer_base.cpp @@ -53,12 +53,29 @@ void MEANDER_PLACER_BASE::AmplitudeStep( int aSign ) void MEANDER_PLACER_BASE::SpacingStep( int aSign ) { int s = m_settings.m_spacing + aSign * m_settings.m_step; - s = std::max( s, 2 * m_currentWidth ); + s = std::max( s, m_currentWidth + Clearance() ); m_settings.m_spacing = s; } +int MEANDER_PLACER_BASE::Clearance() +{ + // Asumption: All tracks are part of the same net class. + // It shouldn't matter which track we pick. They should all have the same clearance if + // they are part of the same net class. Therefore, pick the first one on the list. + ITEM* itemToCheck = Traces().CItems().front().item; + PNS::CONSTRAINT constraint; + + Router()->GetRuleResolver()->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_CLEARANCE, itemToCheck, + nullptr, CurrentLayer(), &constraint ); + + wxCHECK_MSG( constraint.m_Value.HasMin(), m_currentWidth, "No minimum clearance?" ); + + return constraint.m_Value.Min(); +} + + void MEANDER_PLACER_BASE::UpdateSettings( const MEANDER_SETTINGS& aSettings ) { m_settings = aSettings; diff --git a/pcbnew/router/pns_meander_placer_base.h b/pcbnew/router/pns_meander_placer_base.h index 51fa7ea9a7..9c0a999390 100644 --- a/pcbnew/router/pns_meander_placer_base.h +++ b/pcbnew/router/pns_meander_placer_base.h @@ -79,6 +79,13 @@ public: */ virtual void SpacingStep( int aSign ); + /** + * Return the clearance of the track(s) being length tuned + * + * @return clearance value in internal units + */ + virtual int Clearance(); + /** * Return the current meandering configuration. *