diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index daa5d9f6be..c6c3411b49 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -518,6 +518,7 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std: entry["td_length_ratio"] = td_prm->m_LengthRatio; entry["td_height_ratio"] = td_prm->m_HeightRatio; entry["td_curve_segcount"] = td_prm->m_CurveSegCount; + entry["td_width_to_size_filter_ratio"] = td_prm->m_WidthtoSizeFilterRatio; js.push_back( entry ); } @@ -534,13 +535,7 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std: if( entry.empty() || !entry.is_object() ) continue; - if( !entry.contains( "td_target_name" ) - || !entry.contains( "td_maxlen" ) - || !entry.contains( "td_maxheight" ) - || !entry.contains( "td_length_ratio" ) - || !entry.contains( "td_height_ratio" ) - || !entry.contains( "td_curve_segcount" ) - ) + if( !entry.contains( "td_target_name" ) ) continue; int idx = GetTeardropTargetTypeFromCanonicalName( entry["td_target_name"].get() ); @@ -548,11 +543,24 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std: if( idx >= 0 && idx < 3 ) { TEARDROP_PARAMETERS* td_prm = m_TeardropParamsList.GetParameters( (TARGET_TD)idx ); - td_prm->m_TdMaxLen = Millimeter2iu( entry["td_maxlen"].get() ); - td_prm->m_TdMaxHeight = Millimeter2iu( entry["td_maxheight"].get() ); - td_prm->m_LengthRatio = entry["td_length_ratio"].get(); - td_prm->m_HeightRatio = entry["td_height_ratio"].get(); - td_prm->m_CurveSegCount = entry["td_curve_segcount"].get(); + + if( entry.contains( "td_maxlen" ) ) + td_prm->m_TdMaxLen = Millimeter2iu( entry["td_maxlen"].get() ); + + if( entry.contains( "td_maxheight" ) ) + td_prm->m_TdMaxHeight = Millimeter2iu( entry["td_maxheight"].get() ); + + if( entry.contains( "td_length_ratio" ) ) + td_prm->m_LengthRatio = entry["td_length_ratio"].get(); + + if( entry.contains( "td_height_ratio" ) ) + td_prm->m_HeightRatio = entry["td_height_ratio"].get(); + + if( entry.contains( "td_curve_segcount" ) ) + td_prm->m_CurveSegCount = entry["td_curve_segcount"].get(); + + if( entry.contains( "td_width_to_size_filter_ratio" ) ) + td_prm->m_WidthtoSizeFilterRatio = entry["td_width_to_size_filter_ratio"].get(); } } }, diff --git a/pcbnew/teardrop/dialog_teardrop.cpp b/pcbnew/teardrop/dialog_teardrop.cpp index bf0c204d26..1c066b2c20 100644 --- a/pcbnew/teardrop/dialog_teardrop.cpp +++ b/pcbnew/teardrop/dialog_teardrop.cpp @@ -75,13 +75,15 @@ public: m_spTeardropLenPercentRound->SetValue( prms->m_LengthRatio*100 ); m_spTeardropSizePercentRound->SetValue( prms->m_HeightRatio*100 ); m_rbShapeRound->SetSelection( prms->IsCurved() ); + m_spTeardropHDPercentRound->SetValue( prms->m_WidthtoSizeFilterRatio*100 ); prms = prmsList->GetParameters( TARGET_RECT ); m_teardropMaxLenSettingRect.SetValue( prms->m_TdMaxLen ); m_teardropMaxHeightSettingRect.SetValue( prms->m_TdMaxHeight ); m_spTeardropLenPercentRect->SetValue( prms->m_LengthRatio*100 ); - m_spTeardropSizePercentRect->SetValue(prms->m_HeightRatio*100 ); + m_spTeardropSizePercentRect->SetValue( prms->m_HeightRatio*100 ); m_rbShapeRect->SetSelection( prms->IsCurved() ); + m_spTeardropHDPercentRect->SetValue( prms->m_WidthtoSizeFilterRatio*100 ); prms = prmsList->GetParameters( TARGET_TRACK ); m_teardropMaxLenSettingTrack.SetValue(prms->m_TdMaxLen ); @@ -89,6 +91,7 @@ public: m_spTeardropLenPercentTrack->SetValue( prms->m_LengthRatio*100 ); m_spTeardropSizePercentTrack->SetValue( prms->m_HeightRatio*100 ); m_rbShapeTrack->SetSelection( prms->IsCurved() ); + m_spTeardropHDPercentTrack->SetValue( prms->m_WidthtoSizeFilterRatio*100 ); // recalculate sizers, now the bitmap is initialized finishDialogSettings(); @@ -122,6 +125,7 @@ public: prms->m_TdMaxLen = m_teardropMaxLenSettingRound.GetValue(); prms->m_TdMaxHeight = m_teardropMaxHeightSettingRound.GetValue(); prms->m_CurveSegCount = (CurvedShapeOption() & CURVED_OPTION_ROUND) ? shape_seg_count : 0; + prms->m_WidthtoSizeFilterRatio = m_spTeardropHDPercentRound->GetValue() / 100.0; prms = prmsList->GetParameters( TARGET_RECT ); prms->m_LengthRatio = GetTeardropLenPercentRect(); @@ -129,6 +133,7 @@ public: prms->m_TdMaxLen = m_teardropMaxLenSettingRect.GetValue(); prms->m_TdMaxHeight = m_teardropMaxHeightSettingRect.GetValue(); prms->m_CurveSegCount = (CurvedShapeOption() & CURVED_OPTION_RECT) ? shape_seg_count : 0; + prms->m_WidthtoSizeFilterRatio = m_spTeardropHDPercentRect->GetValue() / 100.0; prms = prmsList->GetParameters( TARGET_TRACK ); prms->m_LengthRatio = GetTeardropLenPercentTrack(); @@ -136,6 +141,7 @@ public: prms->m_TdMaxLen = m_teardropMaxLenSettingTrack.GetValue(); prms->m_TdMaxHeight = m_teardropMaxHeightSettingTrack.GetValue(); prms->m_CurveSegCount = (CurvedShapeOption() & CURVED_OPTION_TRACK) ? shape_seg_count : 0; + prms->m_WidthtoSizeFilterRatio = m_spTeardropHDPercentTrack->GetValue() / 100.0; } int CurvedShapeOption() diff --git a/pcbnew/teardrop/dialog_teardrop_base.cpp b/pcbnew/teardrop/dialog_teardrop_base.cpp index ad4c752404..0f5e4936f3 100644 --- a/pcbnew/teardrop/dialog_teardrop_base.cpp +++ b/pcbnew/teardrop/dialog_teardrop_base.cpp @@ -67,7 +67,7 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con m_stHsettingRound->Wrap( -1 ); fgSizerParmRound->Add( m_stHsettingRound, 0, wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - m_spTeardropLenPercentRound = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 20, 100, 50.000000, 10 ); + m_spTeardropLenPercentRound = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 20, 100, 40.000000, 10 ); m_spTeardropLenPercentRound->SetDigits( 0 ); fgSizerParmRound->Add( m_spTeardropLenPercentRound, 0, wxALL|wxEXPAND, 5 ); @@ -83,6 +83,20 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con m_stLenPercentRound->Wrap( -1 ); fgSizerParmRound->Add( m_stLenPercentRound, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + m_stHDRatioRound = new wxStaticText( this, wxID_ANY, _("Max height/d"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stHDRatioRound->Wrap( -1 ); + m_stHDRatioRound->SetToolTip( _("Max pad/via size to track width ratio to create a teardrop.\n100 always creates a teardrop.") ); + + fgSizerParmRound->Add( m_stHDRatioRound, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spTeardropHDPercentRound = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 90, 10 ); + m_spTeardropHDPercentRound->SetDigits( 0 ); + fgSizerParmRound->Add( m_spTeardropHDPercentRound, 0, wxALL|wxEXPAND, 5 ); + + m_stHDPercentRound = new wxStaticText( this, wxID_ANY, _("percent of H/d"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stHDPercentRound->Wrap( -1 ); + fgSizerParmRound->Add( m_stHDPercentRound, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + fgSizerBitmaps->Add( fgSizerParmRound, 1, wxEXPAND, 5 ); @@ -138,6 +152,20 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con m_stLenPercentRect->Wrap( -1 ); fgSizerParmRect->Add( m_stLenPercentRect, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + m_stHDRatioRect = new wxStaticText( this, wxID_ANY, _("Max height/d"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stHDRatioRect->Wrap( -1 ); + m_stHDRatioRect->SetToolTip( _("Max pad/via size to track width ratio to create a teardrop.\n100 always creates a teardrop.") ); + + fgSizerParmRect->Add( m_stHDRatioRect, 0, wxALL, 5 ); + + m_spTeardropHDPercentRect = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 90, 10 ); + m_spTeardropHDPercentRect->SetDigits( 0 ); + fgSizerParmRect->Add( m_spTeardropHDPercentRect, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_stHDPercentRect = new wxStaticText( this, wxID_ANY, _("percent of H/d"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stHDPercentRect->Wrap( -1 ); + fgSizerParmRect->Add( m_stHDPercentRect, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + fgSizerBitmaps->Add( fgSizerParmRect, 1, wxEXPAND, 5 ); @@ -193,11 +221,25 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con m_stLenPercentTrack->Wrap( -1 ); fgSizerParmTrack->Add( m_stLenPercentTrack, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + m_stHDRatioTrack = new wxStaticText( this, wxID_ANY, _("Max height/d"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stHDRatioTrack->Wrap( -1 ); + m_stHDRatioTrack->SetToolTip( _("Max pad/via size to track width ratio to create a teardrop.\n100 always creates a teardrop.") ); + + fgSizerParmTrack->Add( m_stHDRatioTrack, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spTeardropHDPercentTrack = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 90, 10 ); + m_spTeardropHDPercentTrack->SetDigits( 0 ); + fgSizerParmTrack->Add( m_spTeardropHDPercentTrack, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + + m_stHDPercentTrack = new wxStaticText( this, wxID_ANY, _("percent of H/d"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stHDPercentTrack->Wrap( -1 ); + fgSizerParmTrack->Add( m_stHDPercentTrack, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + fgSizerBitmaps->Add( fgSizerParmTrack, 1, wxEXPAND, 5 ); - bSizeScopeSize->Add( fgSizerBitmaps, 1, wxLEFT|wxEXPAND, 5 ); + bSizeScopeSize->Add( fgSizerBitmaps, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); bSizerTop->Add( bSizeScopeSize, 0, wxEXPAND, 5 ); diff --git a/pcbnew/teardrop/dialog_teardrop_base.fbp b/pcbnew/teardrop/dialog_teardrop_base.fbp index 91ab47d7f3..3b6f8f7dad 100644 --- a/pcbnew/teardrop/dialog_teardrop_base.fbp +++ b/pcbnew/teardrop/dialog_teardrop_base.fbp @@ -90,7 +90,7 @@ none 5 - wxLEFT|wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT 1 3 @@ -645,7 +645,7 @@ 0 wxID_ANY 10 - 50.000000 + 40.000000 100 0 @@ -861,6 +861,192 @@ -1 + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Max height/d + 0 + + 0 + + + 0 + + 1 + m_stHDRatioRound + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Max pad/via size to track width ratio to create a teardrop. 100 always creates a teardrop. + + + + -1 + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 10 + 90 + 100 + + 0 + + 0 + + 0 + + 1 + m_spTeardropHDPercentRound + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + ; ; forward_declare + 0 + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + percent of H/d + 0 + + 0 + + + 0 + + 1 + m_stHDPercentRound + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + @@ -1620,6 +1806,192 @@ -1 + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Max height/d + 0 + + 0 + + + 0 + + 1 + m_stHDRatioRect + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Max pad/via size to track width ratio to create a teardrop. 100 always creates a teardrop. + + + + -1 + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 10 + 90 + 100 + + 0 + + 0 + + 0 + + 1 + m_spTeardropHDPercentRect + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + ; ; forward_declare + 0 + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + percent of H/d + 0 + + 0 + + + 0 + + 1 + m_stHDPercentRect + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + @@ -2379,6 +2751,192 @@ -1 + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Max height/d + 0 + + 0 + + + 0 + + 1 + m_stHDRatioTrack + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Max pad/via size to track width ratio to create a teardrop. 100 always creates a teardrop. + + + + -1 + + + + 5 + wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 10 + 90 + 100 + + 0 + + 0 + + 0 + + 1 + m_spTeardropHDPercentTrack + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + ; ; forward_declare + 0 + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + percent of H/d + 0 + + 0 + + + 0 + + 1 + m_stHDPercentTrack + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + diff --git a/pcbnew/teardrop/dialog_teardrop_base.h b/pcbnew/teardrop/dialog_teardrop_base.h index 579dcd0883..d2cafebf64 100644 --- a/pcbnew/teardrop/dialog_teardrop_base.h +++ b/pcbnew/teardrop/dialog_teardrop_base.h @@ -54,6 +54,9 @@ class TEARDROP_DIALOG_BASE : public DIALOG_SHIM wxStaticText* m_stVsettingRound; wxSpinCtrlDouble* m_spTeardropSizePercentRound; wxStaticText* m_stLenPercentRound; + wxStaticText* m_stHDRatioRound; + wxSpinCtrlDouble* m_spTeardropHDPercentRound; + wxStaticText* m_stHDPercentRound; wxStaticText* m_staticTextRectS; wxStaticBitmap* m_bitmapTdRectangularInfo; wxStaticText* m_stMaxLenRect; @@ -66,6 +69,9 @@ class TEARDROP_DIALOG_BASE : public DIALOG_SHIM wxStaticText* m_stVsettingRect; wxSpinCtrlDouble* m_spTeardropSizePercentRect; wxStaticText* m_stLenPercentRect; + wxStaticText* m_stHDRatioRect; + wxSpinCtrlDouble* m_spTeardropHDPercentRect; + wxStaticText* m_stHDPercentRect; wxStaticText* m_staticTextTrck; wxStaticBitmap* m_bitmapTdTrackInfo; wxStaticText* m_stMaxLenTrack; @@ -78,6 +84,9 @@ class TEARDROP_DIALOG_BASE : public DIALOG_SHIM wxStaticText* m_stVsettingtrack; wxSpinCtrlDouble* m_spTeardropSizePercentTrack; wxStaticText* m_stLenPercentTrack; + wxStaticText* m_stHDRatioTrack; + wxSpinCtrlDouble* m_spTeardropHDPercentTrack; + wxStaticText* m_stHDPercentTrack; wxCheckBox* m_cbPadVia; wxCheckBox* m_cbRoundShapesOnly; wxCheckBox* m_cbSmdSimilarPads; diff --git a/pcbnew/teardrop/teardrop.cpp b/pcbnew/teardrop/teardrop.cpp index e30d155f61..17b3341fdd 100644 --- a/pcbnew/teardrop/teardrop.cpp +++ b/pcbnew/teardrop/teardrop.cpp @@ -158,6 +158,10 @@ int TEARDROP_MANAGER::SetTeardrops( BOARD_COMMIT* aCommitter, bool aFollowTracks || track->GetWidth() >= viapad.m_Width * currParams->m_HeightRatio ) continue; + // Ensure also it is not filtered by a too high track->GetWidth()/viapad.m_Width ratio + if( track->GetWidth() >= viapad.m_Width * currParams->m_WidthtoSizeFilterRatio ) + continue; + // Skip case where pad/via and the track is within a copper zone with the same net // (and the pad can be connected by the zone thermal relief ) if( !m_prmsList->m_TdOnPadsInZones && isViaAndTrackInSameZone( viapad, track ) ) @@ -297,7 +301,9 @@ int TEARDROP_MANAGER::addTeardropsOnTracks( BOARD_COMMIT* aCommitter ) // to avoid creating a teardrop between 2 tracks having similar widths // give a threshold - const double th = 1.2; + const double th = currParams->m_WidthtoSizeFilterRatio > 0.1 ? + 1.0 / currParams->m_WidthtoSizeFilterRatio + : 10.0; min_width = min_width * th; for( unsigned jj = ii+1; jj < sublist->size(); jj++ ) diff --git a/pcbnew/teardrop/teardrop_parameters.h b/pcbnew/teardrop/teardrop_parameters.h index ffb21b0e45..df4dc0fd89 100644 --- a/pcbnew/teardrop/teardrop_parameters.h +++ b/pcbnew/teardrop/teardrop_parameters.h @@ -53,7 +53,8 @@ public: m_TdMaxHeight( Millimeter2iu( 2.0 ) ), m_LengthRatio( 0.5), m_HeightRatio( 1.0 ), - m_CurveSegCount( 0 ) + m_CurveSegCount( 0 ), + m_WidthtoSizeFilterRatio( 0.9 ) { } @@ -102,6 +103,9 @@ public: /// number of segments to build the curved sides of a teardrop area /// must be > 2. for values <= 2 a straight line is used int m_CurveSegCount; + /// The ratio (H/D) between the via/pad size and the track width max value to create a teardrop + /// 1.0 (100 %) always creates a teardrop, 0.0 (0%) never create a teardrop + double m_WidthtoSizeFilterRatio; };