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
This commit is contained in:
Roberto Fernandez Bautista 2021-06-19 21:04:58 +01:00
parent e402563087
commit 04b71f5167
5 changed files with 34 additions and 6 deletions

View File

@ -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 );

View File

@ -1171,7 +1171,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Spacing (s):</property>
<property name="label">Min spacing (s):</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -1253,7 +1253,7 @@
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">Minimum spacing between adjacent meander segments. The resulting spacing may be greater based on design rules.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>

View File

@ -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 );
}
}

View File

@ -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;

View File

@ -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.
*