From ac78d51b1489ce1c62952bdab6c6c4a5742d40be Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 19 Dec 2021 10:30:31 +0100 Subject: [PATCH] Teardrops: better dialog, and better code --- pcbnew/plugins/kicad/pcb_parser.cpp | 8 +- pcbnew/teardrop/dialog_teardrop.cpp | 31 +- pcbnew/teardrop/dialog_teardrop_base.cpp | 77 ++- pcbnew/teardrop/dialog_teardrop_base.fbp | 716 ++++++++++++++++++----- pcbnew/teardrop/dialog_teardrop_base.h | 27 +- pcbnew/teardrop/teardrop.cpp | 17 +- pcbnew/teardrop/teardrop.h | 72 +-- pcbnew/teardrop/teardrop_utils.cpp | 125 ++-- pcbnew/zone_filler.cpp | 17 +- 9 files changed, 804 insertions(+), 286 deletions(-) diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 435453044a..673d2bf6c9 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -5572,9 +5572,11 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) zone->SetZoneName( FromUTF8() ); // TODO: remove this hack and replace it when a suitable token is added - // If a zone name is $teardrop$, set its teardrop property flag - if( zone->GetZoneName() == "$teardrop$" ) - zone->SetIsTeardropArea( true ); + // If a zone name starts by "$teardrop_", set its teardrop property flag + if( zone->GetZoneName().StartsWith( "$teardrop_p" ) ) + zone->SetTeardropAreaType( TEARDROP_TYPE::TD_VIAPAD ); + else if( zone->GetZoneName().StartsWith( "$teardrop_t" ) ) + zone->SetTeardropAreaType( TEARDROP_TYPE::TD_TRACKEND ); NeedRIGHT(); break; diff --git a/pcbnew/teardrop/dialog_teardrop.cpp b/pcbnew/teardrop/dialog_teardrop.cpp index 4b2986326d..3afc5f2c61 100644 --- a/pcbnew/teardrop/dialog_teardrop.cpp +++ b/pcbnew/teardrop/dialog_teardrop.cpp @@ -50,7 +50,8 @@ public: m_spTeardropSizePercent->SetValue( m_teardropSizePrm ); m_cbSmdSimilarPads->SetValue( m_includeNotPTH ); m_cbRoundShapesOnly->SetValue( m_roundShapesOnly ); - m_rbShape->SetSelection( m_curveOption ); + m_rbShapeRound->SetSelection( m_curveOptionRoundShapes ); + m_rbShapeRect->SetSelection( m_curveOptionRectShapes ); m_cbOptUseNextTrack->SetValue( m_canUseTwoTracks ); m_spPointCount->SetValue( m_curveSegCount ); m_cbTrack2Track->SetValue( m_track2Track ); @@ -71,16 +72,25 @@ public: m_teardropMaxSizePrm = m_teardropMaxHeightSetting.GetValue(); m_roundShapesOnly = m_cbRoundShapesOnly->GetValue(); m_includeNotPTH = m_cbSmdSimilarPads->GetValue(); - m_curveOption = m_rbShape->GetSelection(); + m_curveOptionRoundShapes = m_rbShapeRound->GetSelection(); + m_curveOptionRectShapes = m_rbShapeRect->GetSelection(); m_canUseTwoTracks = m_cbOptUseNextTrack->GetValue(); m_curveSegCount = m_spPointCount->GetValue(); m_track2Track = m_cbTrack2Track->GetValue(); m_includeViasAndPTH = m_cbPadVia->GetValue(); } - CURVED_OPTION CurvedShapeOption() + int CurvedShapeOption() { - return (CURVED_OPTION) m_rbShape->GetSelection(); + int opt = 0; + + if( m_rbShapeRound->GetSelection() ) + opt |= CURVED_OPTION_ROUND; + + if( m_rbShapeRect->GetSelection() ) + opt |= CURVED_OPTION_RECT; + + return opt; } // Options for curved shapes @@ -111,7 +121,8 @@ private: static int m_teardropMaxSizePrm; static bool m_includeNotPTH; static bool m_roundShapesOnly; - static int m_curveOption; + static int m_curveOptionRoundShapes; + static int m_curveOptionRectShapes; static bool m_canUseTwoTracks; static int m_curveSegCount; static bool m_track2Track; @@ -126,7 +137,8 @@ int TEARDROP_DIALOG::m_teardropMaxLenPrm = Millimeter2iu( 1.0 ); int TEARDROP_DIALOG::m_teardropMaxSizePrm = Millimeter2iu( 2.0 ); bool TEARDROP_DIALOG::m_includeNotPTH = true; bool TEARDROP_DIALOG::m_roundShapesOnly = false; -int TEARDROP_DIALOG::m_curveOption = 0; +int TEARDROP_DIALOG::m_curveOptionRoundShapes = 0; +int TEARDROP_DIALOG::m_curveOptionRectShapes = 0; bool TEARDROP_DIALOG::m_canUseTwoTracks = true; int TEARDROP_DIALOG::m_curveSegCount = 5; bool TEARDROP_DIALOG::m_track2Track = true; @@ -146,12 +158,7 @@ void PCB_EDIT_FRAME::OnRunTeardropTool( wxCommandEvent& event ) TEARDROP_MANAGER trdm( GetBoard(), this ); - int shape_seg_count; - - if( dlg.CurvedShapeOption() != CURVED_OPTION::OPTION_NONE ) - shape_seg_count = dlg.GetCurvePointCount(); - else - shape_seg_count = 1; + int shape_seg_count = dlg.GetCurvePointCount(); trdm.SetTeardropMaxSize( dlg.GetTeardropMaxLen(), dlg.GetTeardropMaxHeight() ); trdm.SetTeardropSizeRatio( dlg.GetTeardropLenPercent(), dlg.GetTeardropSizePercent() ); diff --git a/pcbnew/teardrop/dialog_teardrop_base.cpp b/pcbnew/teardrop/dialog_teardrop_base.cpp index 2740bee9b1..d919572e81 100644 --- a/pcbnew/teardrop/dialog_teardrop_base.cpp +++ b/pcbnew/teardrop/dialog_teardrop_base.cpp @@ -25,23 +25,37 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con wxBoxSizer* bSizeScopeSize; bSizeScopeSize = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* bSizerBitmaps; - bSizerBitmaps = new wxBoxSizer( wxVERTICAL ); + wxFlexGridSizer* fgSizerBitmaps; + fgSizerBitmaps = new wxFlexGridSizer( 0, 2, 0, 0 ); + fgSizerBitmaps->SetFlexibleDirection( wxBOTH ); + fgSizerBitmaps->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticText10 = new wxStaticText( this, wxID_ANY, wxT("Round shapes"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText10->Wrap( -1 ); + fgSizerBitmaps->Add( m_staticText10, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_bitmapTdCircularInfo = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); - bSizerBitmaps->Add( m_bitmapTdCircularInfo, 0, wxALL, 5 ); + fgSizerBitmaps->Add( m_bitmapTdCircularInfo, 0, wxALL, 5 ); + + m_staticText11 = new wxStaticText( this, wxID_ANY, wxT("Rect shapes"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText11->Wrap( -1 ); + fgSizerBitmaps->Add( m_staticText11, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_bitmapTdRectangularInfo = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); - bSizerBitmaps->Add( m_bitmapTdRectangularInfo, 0, wxALL, 5 ); + fgSizerBitmaps->Add( m_bitmapTdRectangularInfo, 0, wxALL, 5 ); + + m_staticText12 = new wxStaticText( this, wxID_ANY, wxT("Tracks"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText12->Wrap( -1 ); + fgSizerBitmaps->Add( m_staticText12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_bitmapTdTrackInfo = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); - bSizerBitmaps->Add( m_bitmapTdTrackInfo, 0, wxALL, 5 ); + fgSizerBitmaps->Add( m_bitmapTdTrackInfo, 0, wxALL, 5 ); - bSizeScopeSize->Add( bSizerBitmaps, 0, wxEXPAND, 5 ); + bSizeScopeSize->Add( fgSizerBitmaps, 1, wxLEFT|wxEXPAND, 5 ); - bSizeScopeSize->Add( 0, 0, 1, wxEXPAND, 5 ); + bSizeScopeSize->Add( 30, 0, 0, wxEXPAND, 5 ); wxFlexGridSizer* fgSizerSizes; fgSizerSizes = new wxFlexGridSizer( 0, 3, 0, 0 ); @@ -103,6 +117,25 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con m_stTdSizePercent->Wrap( -1 ); fgSizerSizes->Add( m_stTdSizePercent, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + m_staticline51 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + fgSizerSizes->Add( m_staticline51, 0, wxEXPAND | wxALL, 5 ); + + m_staticline61 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + fgSizerSizes->Add( m_staticline61, 0, wxEXPAND | wxALL, 5 ); + + m_staticline71 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + fgSizerSizes->Add( m_staticline71, 0, wxEXPAND | wxALL, 5 ); + + m_stPoinCount = new wxStaticText( this, wxID_ANY, wxT("Curve points"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stPoinCount->Wrap( -1 ); + fgSizerSizes->Add( m_stPoinCount, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spPointCount = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 3, 10, 5 ); + fgSizerSizes->Add( m_spPointCount, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + + fgSizerSizes->Add( 0, 0, 1, wxEXPAND, 5 ); + bSizeScopeSize->Add( fgSizerSizes, 0, wxEXPAND|wxALL, 5 ); @@ -130,30 +163,30 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con sbSizerScope->Add( m_cbSmdSimilarPads, 0, wxALL, 5 ); m_cbTrack2Track = new wxCheckBox( sbSizerScope->GetStaticBox(), wxID_ANY, wxT("Track to track"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbTrack2Track->SetValue(true); sbSizerScope->Add( m_cbTrack2Track, 0, wxALL, 5 ); - bSizerShape->Add( sbSizerScope, 0, 0, 5 ); + bSizerShape->Add( sbSizerScope, 0, wxTOP|wxBOTTOM, 5 ); - bSizerShape->Add( 30, 10, 1, wxEXPAND, 5 ); + bSizerShape->Add( 30, 10, 0, wxEXPAND, 5 ); - wxString m_rbShapeChoices[] = { wxT("Straight lines"), wxT("Curved for round pads"), wxT("Curved for all pad shapes") }; - int m_rbShapeNChoices = sizeof( m_rbShapeChoices ) / sizeof( wxString ); - m_rbShape = new wxRadioBox( this, wxID_ANY, wxT("Teardrop style"), wxDefaultPosition, wxDefaultSize, m_rbShapeNChoices, m_rbShapeChoices, 1, wxRA_SPECIFY_COLS ); - m_rbShape->SetSelection( 0 ); - bSizerShape->Add( m_rbShape, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + wxString m_rbShapeRoundChoices[] = { wxT("Straight lines"), wxT("Curved") }; + int m_rbShapeRoundNChoices = sizeof( m_rbShapeRoundChoices ) / sizeof( wxString ); + m_rbShapeRound = new wxRadioBox( this, wxID_ANY, wxT("Round shapes teardrop style"), wxDefaultPosition, wxDefaultSize, m_rbShapeRoundNChoices, m_rbShapeRoundChoices, 1, wxRA_SPECIFY_COLS ); + m_rbShapeRound->SetSelection( 0 ); + bSizerShape->Add( m_rbShapeRound, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + wxString m_rbShapeRectChoices[] = { wxT("Straight lines"), wxT("Curved") }; + int m_rbShapeRectNChoices = sizeof( m_rbShapeRectChoices ) / sizeof( wxString ); + m_rbShapeRect = new wxRadioBox( this, wxID_ANY, wxT("Rect shapes teardrop style"), wxDefaultPosition, wxDefaultSize, m_rbShapeRectNChoices, m_rbShapeRectChoices, 1, wxRA_SPECIFY_COLS ); + m_rbShapeRect->SetSelection( 0 ); + bSizerShape->Add( m_rbShapeRect, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); bSizerShape->Add( 30, 0, 0, 0, 5 ); - m_stPoinCount = new wxStaticText( this, wxID_ANY, wxT("Curve points"), wxDefaultPosition, wxDefaultSize, 0 ); - m_stPoinCount->Wrap( -1 ); - bSizerShape->Add( m_stPoinCount, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_spPointCount = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 3, 10, 5 ); - bSizerShape->Add( m_spPointCount, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizerUpper->Add( bSizerShape, 0, wxEXPAND, 5 ); @@ -167,7 +200,7 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con sbSizerOptions->Add( m_cbOptUseNextTrack, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - bSizerUpper->Add( sbSizerOptions, 1, wxEXPAND, 5 ); + bSizerUpper->Add( sbSizerOptions, 1, wxEXPAND|wxTOP, 5 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bSizerUpper->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); diff --git a/pcbnew/teardrop/dialog_teardrop_base.fbp b/pcbnew/teardrop/dialog_teardrop_base.fbp index 0f1dbea674..ba3a3c9284 100644 --- a/pcbnew/teardrop/dialog_teardrop_base.fbp +++ b/pcbnew/teardrop/dialog_teardrop_base.fbp @@ -47,7 +47,7 @@ TEARDROP_DIALOG_BASE - 477,427 + 532,470 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h; forward_declare Teardrop Settings @@ -90,13 +90,81 @@ none 5 - wxEXPAND - 0 - + wxLEFT|wxEXPAND + 1 + + 2 + wxBOTH + + + 0 - bSizerBitmaps - wxVERTICAL + fgSizerBitmaps + wxFLEX_GROWMODE_SPECIFIED none + 0 + 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 + Round shapes + 0 + + 0 + + + 0 + + 1 + m_staticText10 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + 5 wxALL @@ -155,6 +223,67 @@ + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Rect shapes + 0 + + 0 + + + 0 + + 1 + m_staticText11 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + 5 wxALL @@ -213,6 +342,67 @@ + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Tracks + 0 + + 0 + + + 0 + + 1 + m_staticText12 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + 5 wxALL @@ -276,11 +466,11 @@ 5 wxEXPAND - 1 + 0 0 protected - 0 + 30 @@ -1217,6 +1407,313 @@ -1 + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline51 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; ; forward_declare + 0 + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline61 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; ; forward_declare + 0 + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline71 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; ; 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 + Curve points + 0 + + 0 + + + 0 + + 1 + m_stPoinCount + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 5 + 10 + + 0 + + 3 + + 0 + + 1 + m_spPointCount + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + ; ; forward_declare + 0 + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + @@ -1234,7 +1731,7 @@ none 5 - + wxTOP|wxBOTTOM 0 wxID_ANY @@ -1454,7 +1951,7 @@ 1 0 - 0 + 1 1 1 @@ -1505,7 +2002,7 @@ 5 wxEXPAND - 1 + 0 10 protected @@ -1530,7 +2027,7 @@ 1 0 - "Straight lines" "Curved for round pads" "Curved for all pad shapes" + "Straight lines" "Curved" 1 1 @@ -1545,7 +2042,7 @@ 0 0 wxID_ANY - Teardrop style + Round shapes teardrop style 1 0 @@ -1554,7 +2051,73 @@ 0 1 - m_rbShape + m_rbShapeRound + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Straight lines" "Curved" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Rect shapes teardrop style + 1 + + 0 + + + 0 + + 1 + m_rbShapeRect 1 @@ -1588,134 +2151,11 @@ 30 - - 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Curve points - 0 - - 0 - - - 0 - - 1 - m_stPoinCount - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -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 - 5 - 10 - - 0 - - 3 - - 0 - - 1 - m_spPointCount - 1 - - - protected - 1 - - Resizable - 1 - - wxSP_ARROW_KEYS - ; ; forward_declare - 0 - - - - - - - 5 - wxEXPAND + wxEXPAND|wxTOP 1 wxID_ANY diff --git a/pcbnew/teardrop/dialog_teardrop_base.h b/pcbnew/teardrop/dialog_teardrop_base.h index 8b52429c39..7bd82726d0 100644 --- a/pcbnew/teardrop/dialog_teardrop_base.h +++ b/pcbnew/teardrop/dialog_teardrop_base.h @@ -10,17 +10,17 @@ #include #include #include "dialog_shim.h" -#include -#include -#include -#include +#include +#include #include #include #include #include -#include +#include +#include +#include +#include #include -#include #include #include #include @@ -41,8 +41,11 @@ class TEARDROP_DIALOG_BASE : public DIALOG_SHIM private: protected: + wxStaticText* m_staticText10; wxStaticBitmap* m_bitmapTdCircularInfo; + wxStaticText* m_staticText11; wxStaticBitmap* m_bitmapTdRectangularInfo; + wxStaticText* m_staticText12; wxStaticBitmap* m_bitmapTdTrackInfo; wxStaticText* m_stMaxLen; wxTextCtrl* m_tcTdMaxLen; @@ -59,13 +62,17 @@ class TEARDROP_DIALOG_BASE : public DIALOG_SHIM wxStaticText* m_stVsetting; wxSpinCtrlDouble* m_spTeardropSizePercent; wxStaticText* m_stTdSizePercent; + wxStaticLine* m_staticline51; + wxStaticLine* m_staticline61; + wxStaticLine* m_staticline71; + wxStaticText* m_stPoinCount; + wxSpinCtrl* m_spPointCount; wxCheckBox* m_cbPadVia; wxCheckBox* m_cbRoundShapesOnly; wxCheckBox* m_cbSmdSimilarPads; wxCheckBox* m_cbTrack2Track; - wxRadioBox* m_rbShape; - wxStaticText* m_stPoinCount; - wxSpinCtrl* m_spPointCount; + wxRadioBox* m_rbShapeRound; + wxRadioBox* m_rbShapeRect; wxCheckBox* m_cbOptUseNextTrack; wxStaticLine* m_staticline1; wxStdDialogButtonSizer* m_sdbSizer; @@ -74,7 +81,7 @@ class TEARDROP_DIALOG_BASE : public DIALOG_SHIM public: - TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Teardrop Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 477,427 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Teardrop Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 532,470 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~TEARDROP_DIALOG_BASE(); diff --git a/pcbnew/teardrop/teardrop.cpp b/pcbnew/teardrop/teardrop.cpp index 21c7f81431..9380144e6c 100644 --- a/pcbnew/teardrop/teardrop.cpp +++ b/pcbnew/teardrop/teardrop.cpp @@ -39,6 +39,9 @@ #include +// The first priority level of a teardrop area (arbitrary value) +#define MAGIC_TEARDROP_ZONE_ID 30000 + void TEARDROP_MANAGER::SetTargets( bool aApplyToPadVias, bool aApplyToRoundShapesOnly, bool aApplyToSurfacePads, bool aApplyToTracks ) @@ -52,12 +55,14 @@ void TEARDROP_MANAGER::SetTargets( bool aApplyToPadVias, bool aApplyToRoundShape // Build a zone teardrop ZONE* TEARDROP_MANAGER::createTeardrop( TEARDROP_VARIANT aTeardropVariant, - std::vector& aPoints, PCB_TRACK* aTrack) + std::vector& aPoints, PCB_TRACK* aTrack) { ZONE* teardrop = new ZONE( m_board ); // Add zone properties (priority will be fixed later) - teardrop->SetIsTeardropArea( true ); + teardrop->SetTeardropAreaType( aTeardropVariant == TD_TYPE_PADVIA ? + TEARDROP_TYPE::TD_VIAPAD : + TEARDROP_TYPE::TD_TRACKEND ); teardrop->SetLayer( aTrack->GetLayer() ); teardrop->SetNetCode( aTrack->GetNetCode() ); teardrop->SetLocalClearance( 0 ); @@ -71,7 +76,7 @@ ZONE* TEARDROP_MANAGER::createTeardrop( TEARDROP_VARIANT aTeardropVariant, SHAPE_POLY_SET* outline = teardrop->Outline(); outline->NewOutline(); - for( wxPoint pt: aPoints ) + for( VECTOR2I pt: aPoints ) outline->Append(pt.x, pt.y); // Can be usefull: @@ -149,7 +154,7 @@ int TEARDROP_MANAGER::SetTeardrops( BOARD_COMMIT* aCommitter, if( aDiscardInSameZone && isViaAndTrackInSameZone( viapad, track ) ) continue; - std::vector points; + std::vector points; bool success = computeTeardropPolygonPoints( points, track, viapad, aFollowTracks, trackLookupList ); @@ -301,7 +306,7 @@ int TEARDROP_MANAGER::addTeardropsOnTracks( BOARD_COMMIT* aCommitter ) EDA_ITEM_FLAGS match_points; // to return the end point EDA_ITEM_FLAGS: // 0, STARTPOINT, ENDPOINT - wxPoint roundshape_pos = candidate->GetStart(); + VECTOR2I roundshape_pos = candidate->GetStart(); ENDPOINT_T endPointCandidate = ENDPOINT_START; match_points = track->IsPointOnEnds( roundshape_pos, m_Parameters.m_tolerance); @@ -327,7 +332,7 @@ int TEARDROP_MANAGER::addTeardropsOnTracks( BOARD_COMMIT* aCommitter ) if( match_points ) { VIAPAD viatrack( candidate, endPointCandidate ); - std::vector points; + std::vector points; bool success = computeTeardropPolygonPoints( points, track, viatrack, false, trackLookupList ); diff --git a/pcbnew/teardrop/teardrop.h b/pcbnew/teardrop/teardrop.h index 3b4c83969b..2707f0dd97 100644 --- a/pcbnew/teardrop/teardrop.h +++ b/pcbnew/teardrop/teardrop.h @@ -30,12 +30,8 @@ #include #include -// TODO: remove MAGIC_TEARDROP_ZONE_ID use to identifay teardrops -// Use only MAGIC_TEARDROP_NAME, and later a specific property -#define MAGIC_TEARDROP_ZONE_ID 0x4242 #define MAGIC_TEARDROP_PADVIA_NAME "$teardrop_padvia$" #define MAGIC_TEARDROP_TRACK_NAME "$teardrop_track$" -#define MAGIC_TEARDROP_BASE_NAME "$teardrop_" class TRACK_BUFFER; @@ -53,7 +49,7 @@ struct VIAPAD return m_Parent->IsOnLayer( aLayer ); } - wxPoint m_Pos; + VECTOR2I m_Pos; int m_Width; // The diameter of a round shape, or the min size for others int m_Drill; int m_NetCode; @@ -63,12 +59,11 @@ struct VIAPAD }; -enum class CURVED_OPTION -{ - OPTION_NONE, // No curved teardrop shape - OPTION_ROUND, // Curved teardrop shape for vias and round pads - OPTION_ALL_PADS, // Curved teardrop shape for all pads but custom -}; +// Curved shapes options +// The actual value is the ORed of options +#define CURVED_OPTION_NONE 0 /* No curved teardrop shape */ +#define CURVED_OPTION_ROUND 1 /* Curved teardrop shape for vias and round pad shapes */ +#define CURVED_OPTION_RECT 2 /* Curved teardrop shape for rect pad shapes */ /** @@ -88,7 +83,7 @@ public: m_heightRatio( 1.0 ), m_curveSegCount( 0 ), m_tolerance( Millimeter2iu( 0.01 ) ), - m_curveOpt( CURVED_OPTION::OPTION_NONE ) + m_curveShapeOpt( CURVED_OPTION_NONE ) { } @@ -117,23 +112,32 @@ public: * Set the params for teardrop using curved shape * note: if aCurveSegCount is < 3, the shape uses a straight line */ - void SetTeardropCurvedPrms( CURVED_OPTION aCurveOpt = CURVED_OPTION::OPTION_NONE, + void SetTeardropCurvedPrms( int aCurveShapeOpt = CURVED_OPTION_NONE, int aCurveSegCount = 5 ) { - m_curveOpt = aCurveOpt; + m_curveShapeOpt = aCurveShapeOpt; m_curveSegCount = aCurveSegCount; } protected: - int m_tdMaxLen; /// max allowed lenght for teardrops in IU. <= 0 to disable - int m_tdMaxHeight; /// max allowed height for teardrops in IU. <= 0 to disable - double m_lenghtRatio; /// The lenght of a teardrop as ratio between lenght and size of pad/via - double m_heightRatio; /// The height of a teardrop as ratio between height and size of pad/via - int m_curveSegCount; /// 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_tolerance; /// the max distance between a track end and a padvia position to see - /// them connected - CURVED_OPTION m_curveOpt; + /// max allowed lenght for teardrops in IU. <= 0 to disable + int m_tdMaxLen; + /// max allowed height for teardrops in IU. <= 0 to disable + int m_tdMaxHeight; + /// The lenght of a teardrop as ratio between lenght and size of pad/via + double m_lenghtRatio; + /// The height of a teardrop as ratio between height and size of pad/via + double m_heightRatio; + /// 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 max distance between a track end and a padvia position to see them connected + int m_tolerance; + /// Shape of teardrops for round and rect pad shapes + /// 0 = straight lines + /// m_curveShapeOpt & CURVED_OPTION_ROUND != 0 curved for round shapes + /// m_curveShapeOpt & CURVED_OPTION_RECT != 0 curved for rect shapes + int m_curveShapeOpt; }; @@ -217,10 +221,10 @@ public: * Set the params for teardrop using curved shape * note: if aSegCount is < 3, the shape uses a straight line */ - void SetTeardropCurvedPrms( CURVED_OPTION aCurveOpt = CURVED_OPTION::OPTION_NONE, + void SetTeardropCurvedPrms( int aCurveShapeOpt = CURVED_OPTION_NONE, int aCurveSegCount = 5 ) { - m_Parameters.SetTeardropCurvedPrms( aCurveOpt, aCurveSegCount ); + m_Parameters.SetTeardropCurvedPrms( aCurveShapeOpt, aCurveSegCount ); } /** @@ -276,10 +280,10 @@ private: * and do not give a good curve shape for other pad shapes * use m_m_heightRatio */ - void computeCurvedForRoundShape( std::vector& aPoly, + void computeCurvedForRoundShape( std::vector& aPoly, int aTrackHalfWidth, VECTOR2D aTrackDir, VIAPAD& aViaPad, - std::vector& aPts ) const; + std::vector& aPts ) const; /** @@ -287,16 +291,16 @@ private: * The Bezier curve control points are not optimized for a special shape, * so use computeCurvedForRoundShape() for round shapes for better result */ - void computeCurvedForRectShape( std::vector& aPoly, int aTdHeight, + void computeCurvedForRectShape( std::vector& aPoly, int aTdHeight, int aTrackHalfWidth, VIAPAD& aViaPad, - std::vector& aPts ) const; + std::vector& aPts ) const; /** * Compute all teardrop points of the polygon shape * @return true if the polygonal shape was calculated, false if not buildable * use m_lenghtRatio and m_heightRatio */ - bool computeTeardropPolygonPoints( std::vector& aCorners, + bool computeTeardropPolygonPoints( std::vector& aCorners, PCB_TRACK* aTrack, VIAPAD& aVia, bool aFollowTracks, TRACK_BUFFER& aTrackLookupList) const; @@ -314,7 +318,7 @@ private: * m_heightRatio is the factor to calculate the aViaPad teardrop size */ bool ComputePointsOnPadVia( PCB_TRACK* aTrack, VIAPAD& aViaPad, - std::vector& aPts ) const; + std::vector& aPts ) const; /** * Find a track connected to the end of another track @@ -325,7 +329,7 @@ private: * @param aTrackLookupList is the buffer of available tracks */ PCB_TRACK* findTouchingTrack( EDA_ITEM_FLAGS& aMatchType, PCB_TRACK* aTrackRef, - const wxPoint& aEndPoint, + const VECTOR2I& aEndPoint, TRACK_BUFFER& aTrackLookupList ) const; /** @@ -336,7 +340,7 @@ private: * (mainly for net info) */ ZONE* createTeardrop( TEARDROP_VARIANT aTeardropVariant, - std::vector& aPoints, PCB_TRACK* aTrack); + std::vector& aPoints, PCB_TRACK* aTrack); /** * Set priority of created teardrops. smaller have bigger priority @@ -356,7 +360,7 @@ private: * @param aTrackLookupList is the list of tracks to explore if aFollowTracks = true * m_lenghtRatio is the lenght of teardrop (ratio pad/via size/teardrop len) */ - bool findAnchorPointsOnTrack( wxPoint& aStartPoint, wxPoint& aEndPoint, + bool findAnchorPointsOnTrack( VECTOR2I& aStartPoint, VECTOR2I& aEndPoint, PCB_TRACK*& aTrack, VIAPAD& aViaPad, int* aEffectiveTeardropLen, bool aFollowTracks, TRACK_BUFFER& aTrackLookupList ) const; diff --git a/pcbnew/teardrop/teardrop_utils.cpp b/pcbnew/teardrop/teardrop_utils.cpp index bf4234db82..ea975db819 100644 --- a/pcbnew/teardrop/teardrop_utils.cpp +++ b/pcbnew/teardrop/teardrop_utils.cpp @@ -22,6 +22,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +/* + * Some calculations (mainly computeCurvedForRoundShape) are derived from + * https://github.com/NilujePerchut/kicad_scripts/tree/master/teardrops + */ #include #include @@ -144,8 +148,7 @@ void TEARDROP_MANAGER::collectTeardrops( std::vector< ZONE* >& aList ) { for( ZONE* zone : m_board->Zones() ) { - if( zone->GetZoneName().StartsWith( MAGIC_TEARDROP_BASE_NAME ) - || zone->GetPriority() >= MAGIC_TEARDROP_ZONE_ID ) + if( zone->IsTeardropArea() ) { aList.push_back( zone ); } @@ -158,8 +161,7 @@ bool TEARDROP_MANAGER::isViaAndTrackInSameZone( VIAPAD& aViapad, PCB_TRACK* aTra for( ZONE* zone: m_board->Zones() ) { // Skip teardrops - if( zone->GetZoneName().StartsWith( MAGIC_TEARDROP_BASE_NAME ) - || zone->GetPriority() >= MAGIC_TEARDROP_ZONE_ID ) + if( zone->IsTeardropArea() ) continue; // Only consider zones on the same layer @@ -175,7 +177,8 @@ bool TEARDROP_MANAGER::isViaAndTrackInSameZone( VIAPAD& aViapad, PCB_TRACK* aTra { PAD *pad = static_cast< PAD* >( aViapad.m_Parent ); - if( zone->GetPadConnection( pad ) == ZONE_CONNECTION::NONE ) + if( zone->GetPadConnection() == ZONE_CONNECTION::NONE + || pad->GetZoneConnection() == ZONE_CONNECTION::NONE ) return false; } @@ -189,7 +192,7 @@ bool TEARDROP_MANAGER::isViaAndTrackInSameZone( VIAPAD& aViapad, PCB_TRACK* aTra PCB_TRACK* TEARDROP_MANAGER::findTouchingTrack( EDA_ITEM_FLAGS& aMatchType, PCB_TRACK* aTrackRef, - const wxPoint& aEndPoint, + const VECTOR2I& aEndPoint, TRACK_BUFFER& aTrackLookupList ) const { EDA_ITEM_FLAGS match = 0; // to return the end point EDA_ITEM_FLAGS: @@ -231,7 +234,7 @@ PCB_TRACK* TEARDROP_MANAGER::findTouchingTrack( EDA_ITEM_FLAGS& aMatchType, PCB_ /** * @return a vector unit length from aVector */ -static VECTOR2D NormalizeVector( wxPoint aVector ) +static VECTOR2D NormalizeVector( VECTOR2I aVector ) { VECTOR2D vect( aVector ); double norm = vect.EuclideanNorm(); @@ -244,10 +247,10 @@ static VECTOR2D NormalizeVector( wxPoint aVector ) * The Bezier curve control points are optimized for a round pad/via shape, * and do not give a good curve shape for other pad shapes */ -void TEARDROP_MANAGER::computeCurvedForRoundShape( std::vector& aPoly, +void TEARDROP_MANAGER::computeCurvedForRoundShape( std::vector& aPoly, int aTrackHalfWidth, VECTOR2D aTrackDir, VIAPAD& aViaPad, - std::vector& pts ) const + std::vector& pts ) const { // in pts: // A and B are points on the track ( pts[0] and pts[1] ) @@ -269,22 +272,22 @@ void TEARDROP_MANAGER::computeCurvedForRoundShape( std::vector& aPoly, double biasBC = 0.5 * SEG( pts[1], pts[2] ).Length(); double biasAE = 0.5 * SEG( pts[4], pts[0] ).Length(); - wxPoint vecC = pts[2] - aViaPad.m_Pos; - wxPoint tangentC = wxPoint( pts[2].x - vecC.y * biasBC * weaken, + VECTOR2I vecC = (VECTOR2I)pts[2] - aViaPad.m_Pos; + VECTOR2I tangentC = VECTOR2I( pts[2].x - vecC.y * biasBC * weaken, pts[2].y + vecC.x * biasBC * weaken ); - wxPoint vecE = pts[4] - aViaPad.m_Pos; - wxPoint tangentE = wxPoint( pts[4].x + vecE.y * biasAE * weaken, + VECTOR2I vecE = (VECTOR2I)pts[4] - aViaPad.m_Pos; + VECTOR2I tangentE = VECTOR2I( pts[4].x + vecE.y * biasAE * weaken, pts[4].y - vecE.x * biasAE * weaken ); - wxPoint tangentB = wxPoint( pts[1].x - aTrackDir.x * biasBC, pts[1].y - aTrackDir.y * biasBC ); - wxPoint tangentA = wxPoint( pts[0].x - aTrackDir.x * biasAE, pts[0].y - aTrackDir.y * biasAE ); + VECTOR2I tangentB = VECTOR2I( pts[1].x - aTrackDir.x * biasBC, pts[1].y - aTrackDir.y * biasBC ); + VECTOR2I tangentA = VECTOR2I( pts[0].x - aTrackDir.x * biasAE, pts[0].y - aTrackDir.y * biasAE ); - std::vector curve_pts; + std::vector curve_pts; curve_pts.reserve( m_Parameters.m_curveSegCount ); BEZIER_POLY( pts[1], tangentB, tangentC, pts[2] ).GetPoly( curve_pts, 0, m_Parameters.m_curveSegCount ); - for( wxPoint& corner: curve_pts ) + for( VECTOR2I& corner: curve_pts ) aPoly.push_back( corner ); aPoly.push_back( pts[3] ); @@ -293,7 +296,7 @@ void TEARDROP_MANAGER::computeCurvedForRoundShape( std::vector& aPoly, BEZIER_POLY( pts[4], tangentE, tangentA, pts[0] ).GetPoly( curve_pts, 0, m_Parameters.m_curveSegCount ); - for( wxPoint& corner: curve_pts ) + for( VECTOR2I& corner: curve_pts ) aPoly.push_back( corner ); } @@ -302,9 +305,9 @@ void TEARDROP_MANAGER::computeCurvedForRoundShape( std::vector& aPoly, * Compute the curve part points for teardrops connected to a rectangular/polygonal shape * The Bezier curve control points are not optimized for a special shape */ -void TEARDROP_MANAGER::computeCurvedForRectShape( std::vector& aPoly, int aTdHeight, +void TEARDROP_MANAGER::computeCurvedForRectShape( std::vector& aPoly, int aTdHeight, int aTrackHalfWidth, VIAPAD& aViaPad, - std::vector& aPts ) const + std::vector& aPts ) const { // in aPts: // A and B are points on the track ( pts[0] and pts[1] ) @@ -316,12 +319,12 @@ void TEARDROP_MANAGER::computeCurvedForRectShape( std::vector& aPoly, i // side2 is ( aPts[4], aPts[0] ); from via to track VECTOR2I side2( aPts[4] - aPts[0] ); // vector from track to via - std::vector curve_pts; + std::vector curve_pts; curve_pts.reserve( m_Parameters.m_curveSegCount ); // Note: This side is from track to via - wxPoint ctrl1 = ( aPts[1] + aPts[1] + aPts[2] ) / 3; - wxPoint ctrl2 = ( aPts[1] + aPts[2] + aPts[2] ) / 3; + VECTOR2I ctrl1 = ( aPts[1] + aPts[1] + aPts[2] ) / 3; + VECTOR2I ctrl2 = ( aPts[1] + aPts[2] + aPts[2] ) / 3; // The control points must be moved toward the polygon inside, in order to give a curved shape // The move vector is perpendicular to the vertex (side 1 or side 2), and its @@ -351,7 +354,7 @@ void TEARDROP_MANAGER::computeCurvedForRectShape( std::vector& aPoly, i BEZIER_POLY( aPts[1], ctrl1, ctrl2, aPts[2] ).GetPoly( curve_pts, 0, m_Parameters.m_curveSegCount ); - for( wxPoint& corner: curve_pts ) + for( VECTOR2I& corner: curve_pts ) aPoly.push_back( corner ); aPoly.push_back( aPts[3] ); @@ -379,14 +382,14 @@ void TEARDROP_MANAGER::computeCurvedForRectShape( std::vector& aPoly, i BEZIER_POLY( aPts[4], ctrl1, ctrl2, aPts[0] ).GetPoly( curve_pts, 0, m_Parameters.m_curveSegCount ); - for( wxPoint& corner: curve_pts ) + for( VECTOR2I& corner: curve_pts ) aPoly.push_back( corner ); } bool TEARDROP_MANAGER::ComputePointsOnPadVia( PCB_TRACK* aTrack, VIAPAD& aViaPad, - std::vector& aPts ) const + std::vector& aPts ) const { // Compute the 2 anchor points on pad/via of the teardrop shape @@ -437,7 +440,7 @@ bool TEARDROP_MANAGER::ComputePointsOnPadVia( PCB_TRACK* aTrack, // teardrop_axis is the line from anchor point on the track and the end point // of the teardrop in the pad/via // this is the teardrop_axis of the teardrop shape to build - wxPoint ref_on_track = ( aPts[0] + aPts[1] ) / 2; + VECTOR2I ref_on_track = ( aPts[0] + aPts[1] ) / 2; VECTOR2I teardrop_axis( aPts[3] - ref_on_track ); double orient = teardrop_axis.Angle(); @@ -472,25 +475,25 @@ bool TEARDROP_MANAGER::ComputePointsOnPadVia( PCB_TRACK* aTrack, SHAPE_LINE_CHAIN& padpoly = c_buffer.Outline(0); std::vector points = padpoly.CPoints(); - std::vector initialPoints; + std::vector initialPoints; initialPoints.push_back( aPts[0] ); initialPoints.push_back( aPts[1] ); for( const VECTOR2I& pt: points ) initialPoints.emplace_back( pt.x, pt.y ); - std::vector hull; + std::vector hull; BuildConvexHull( hull, initialPoints ); // Search for end points of segments starting at aPts[0] or aPts[1] // In some cases, in convex hull, only one point (aPts[0] or aPts[1]) is still in list - wxPoint PointC; - wxPoint PointE; + VECTOR2I PointC; + VECTOR2I PointE; int found_start = -1; // 2 points (one start and one end) should be found int found_end = -1; - wxPoint start = aPts[0]; - wxPoint pend = aPts[1]; + VECTOR2I start = aPts[0]; + VECTOR2I pend = aPts[1]; for( unsigned ii = 0, jj = 0; jj < hull.size(); ii++, jj++ ) { @@ -536,7 +539,7 @@ bool TEARDROP_MANAGER::ComputePointsOnPadVia( PCB_TRACK* aTrack, PointE = hull[ii]; } - if( found_end < 0 ) // PointC was not initalized, because pend point does not exit + if( found_end < 0 ) // PointC was not initalized, because end point does not exit { int ii = found_start-1; @@ -568,15 +571,15 @@ bool TEARDROP_MANAGER::ComputePointsOnPadVia( PCB_TRACK* aTrack, } -bool TEARDROP_MANAGER::findAnchorPointsOnTrack( wxPoint& aStartPoint, wxPoint& aEndPoint, +bool TEARDROP_MANAGER::findAnchorPointsOnTrack( VECTOR2I& aStartPoint, VECTOR2I& aEndPoint, PCB_TRACK*& aTrack, VIAPAD& aViaPad, int* aEffectiveTeardropLen, bool aFollowTracks, TRACK_BUFFER& aTrackLookupList ) const { bool found = true; - wxPoint start = aTrack->GetStart(); - wxPoint end = aTrack->GetEnd(); + VECTOR2I start = aTrack->GetStart(); + VECTOR2I end = aTrack->GetEnd(); int radius = aViaPad.m_Width / 2; // Requested length of the teardrop: int targetLength = aViaPad.m_Width * m_Parameters.m_lenghtRatio; @@ -661,12 +664,12 @@ bool TEARDROP_MANAGER::findAnchorPointsOnTrack( wxPoint& aStartPoint, wxPoint& a } -bool TEARDROP_MANAGER::computeTeardropPolygonPoints( std::vector& aCorners, +bool TEARDROP_MANAGER::computeTeardropPolygonPoints( std::vector& aCorners, PCB_TRACK* aTrack, VIAPAD& aViaPad, bool aFollowTracks, TRACK_BUFFER& aTrackLookupList ) const { - wxPoint start, end; // Start and end points of the track anchor of the teardrop + VECTOR2I start, end; // Start and end points of the track anchor of the teardrop // the start point is inside the teardrop shape // the end point is outside. int track_stub_len; // the dist between the start point and the anchor point @@ -681,9 +684,9 @@ bool TEARDROP_MANAGER::computeTeardropPolygonPoints( std::vector& aCorn // find the 2 points on the track, sharp end of the teardrop int track_halfwidth = aTrack->GetWidth() / 2; - wxPoint pointB = start + wxPoint( vecT.x * track_stub_len + vecT.y * track_halfwidth, + VECTOR2I pointB = start + VECTOR2I( vecT.x * track_stub_len + vecT.y * track_halfwidth, vecT.y * track_stub_len - vecT.x * track_halfwidth ); - wxPoint pointA = start + wxPoint( vecT.x * track_stub_len - vecT.y * track_halfwidth, + VECTOR2I pointA = start + VECTOR2I( vecT.x * track_stub_len - vecT.y * track_halfwidth, vecT.y * track_stub_len + vecT.x * track_halfwidth ); // To build a polygonal valid shape pointA and point B must be outside the pad @@ -700,19 +703,19 @@ bool TEARDROP_MANAGER::computeTeardropPolygonPoints( std::vector& aCorn } // Introduce a last point to cover the via centre to ensure it is seen as connected - wxPoint pointD = aViaPad.m_Pos; + VECTOR2I pointD = aViaPad.m_Pos; // add a small offset in order to have the aViaPad.m_Pos reference point inside // the teardrop area, just in case... int offset = Millimeter2iu( 0.001 ); - pointD += wxPoint( int( -vecT.x*offset), int(-vecT.y*offset) ); + pointD += VECTOR2I( int( -vecT.x*offset), int(-vecT.y*offset) ); - wxPoint pointC, pointE; // Point on PADVIA outlines - std::vector pts = {pointA, pointB, pointC, pointD, pointE}; + VECTOR2I pointC, pointE; // Point on PADVIA outlines + std::vector pts = {pointA, pointB, pointC, pointD, pointE}; ComputePointsOnPadVia( aTrack, aViaPad, pts ); if( m_Parameters.m_curveSegCount <= 2 - || m_Parameters.m_curveOpt == CURVED_OPTION::OPTION_NONE ) + || m_Parameters.m_curveShapeOpt == CURVED_OPTION_NONE ) { aCorners = pts; return true; @@ -720,20 +723,28 @@ bool TEARDROP_MANAGER::computeTeardropPolygonPoints( std::vector& aCorn // See if we can use curved teardrop shape if( aViaPad.m_IsRound ) - computeCurvedForRoundShape( aCorners, track_halfwidth, - vecT, aViaPad, pts ); - else if( m_Parameters.m_curveOpt == CURVED_OPTION::OPTION_ALL_PADS ) { - int td_height = aViaPad.m_Width * m_Parameters.m_heightRatio; - - if( m_Parameters.m_tdMaxHeight > 0 && m_Parameters.m_tdMaxHeight < td_height ) - td_height = m_Parameters.m_tdMaxHeight; - - computeCurvedForRectShape( aCorners, td_height, track_halfwidth, - aViaPad, pts ); + if( m_Parameters.m_curveShapeOpt & CURVED_OPTION_ROUND ) + computeCurvedForRoundShape( aCorners, track_halfwidth, + vecT, aViaPad, pts ); + else + aCorners = pts; } else - aCorners = pts; + { + if( m_Parameters.m_curveShapeOpt & CURVED_OPTION_RECT ) + { + int td_height = aViaPad.m_Width * m_Parameters.m_heightRatio; + + if( m_Parameters.m_tdMaxHeight > 0 && m_Parameters.m_tdMaxHeight < td_height ) + td_height = m_Parameters.m_tdMaxHeight; + + computeCurvedForRectShape( aCorners, td_height, track_halfwidth, + aViaPad, pts ); + } + else + aCorners = pts; + } return true; } diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 7c05bcefa5..76abe5b9bf 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -608,6 +608,11 @@ void ZONE_FILLER::knockoutThermalReliefs( const ZONE* aZone, PCB_LAYER_ID aLayer continue; } + // a teardrop area is always fully connected to its pad + // (always equiv to ZONE_CONNECTION::FULL) + if( aZone->IsTeardropArea() ) + continue; + constraint = bds.m_DRCEngine->EvalZoneConnection( pad, aZone, aLayer ); ZONE_CONNECTION conn = constraint.m_ZoneConnection; @@ -935,7 +940,7 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE* aZone, PCB_LAYER_ID aLa if( otherZone->GetIsRuleArea() ) { - if( otherZone->GetDoNotAllowCopperPour() ) + if( otherZone->GetDoNotAllowCopperPour() && !aZone->IsTeardropArea() ) knockoutZoneClearance( otherZone ); } else @@ -957,7 +962,7 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE* aZone, PCB_LAYER_ID aLa if( otherZone->GetIsRuleArea() ) { - if( otherZone->GetDoNotAllowCopperPour() ) + if( otherZone->GetDoNotAllowCopperPour() && !aZone->IsTeardropArea() ) knockoutZoneClearance( otherZone ); } else @@ -1000,7 +1005,9 @@ void ZONE_FILLER::subtractHigherPriorityZones( const ZONE* aZone, PCB_LAYER_ID a if( otherZone->GetNetCode() == aZone->GetNetCode() && otherZone->GetPriority() > aZone->GetPriority() ) { - knockoutZoneOutline( otherZone ); + // Do not remove teardrop area: it is not useful and not good + if( !otherZone->IsTeardropArea() ) + knockoutZoneOutline( otherZone ); } } @@ -1011,7 +1018,9 @@ void ZONE_FILLER::subtractHigherPriorityZones( const ZONE* aZone, PCB_LAYER_ID a if( otherZone->GetNetCode() == aZone->GetNetCode() && otherZone->GetPriority() > aZone->GetPriority() ) { - knockoutZoneOutline( otherZone ); + // Do not remove teardrop area: it is not useful and not good + if( !otherZone->IsTeardropArea() ) + knockoutZoneOutline( otherZone ); } } }