Teardrop: add separate settings for round, rect shapes and tracks

This commit is contained in:
jean-pierre charras 2022-01-16 10:24:23 +01:00
parent 9b661aea10
commit 5b0527bdfe
7 changed files with 2541 additions and 1494 deletions

View File

@ -32,33 +32,54 @@
#include <widgets/unit_binder.h>
// 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 */
#define CURVED_OPTION_TRACK 4 /* Curved teardrop shape for track to track shapes */
class TEARDROP_DIALOG: public TEARDROP_DIALOG_BASE
{
public:
TEARDROP_DIALOG( PCB_EDIT_FRAME* aParent ):
TEARDROP_DIALOG_BASE( aParent ),
m_frame( aParent ),
m_teardropMaxLenSetting( aParent,m_stMaxLen, m_tcTdMaxLen, m_stLenUnit ),
m_teardropMaxHeightSetting( aParent, m_stTdMaxSize, m_tcMaxSize, m_stSizeUnit )
m_teardropMaxLenSettingRound( aParent,m_stMaxLenRound, m_tcTdMaxLenRound, nullptr ),
m_teardropMaxHeightSettingRound( aParent, m_stTdMaxSizeRound, m_tcMaxHeightRound, m_stLenUnitRound ),
m_teardropMaxLenSettingRect( aParent,m_stMaxLenRect, m_tcTdMaxLenRect, nullptr ),
m_teardropMaxHeightSettingRect( aParent, m_stTdMaxSizeRect, m_tcMaxHeightRect, m_stLenUnitRect ),
m_teardropMaxLenSettingTrack( aParent,m_stMaxLenTrack, m_tcTdMaxLenTrack, nullptr ),
m_teardropMaxHeightSettingTrack( aParent, m_stTdMaxSizeTrack, m_tcMaxHeightTrack, m_stLenUnitTrack )
{
// Setup actual bitmaps that cannot be set inside wxFormBuilder:
m_bitmapTdCircularInfo->SetBitmap( KiBitmap( BITMAPS::teardrop_sizes ) );
m_bitmapTdRectangularInfo->SetBitmap( KiBitmap( BITMAPS::teardrop_rect_sizes ) );
m_bitmapTdTrackInfo->SetBitmap( KiBitmap( BITMAPS::teardrop_track_sizes ) );
m_spTeardropLenPercent->SetValue( m_teardropLenPrm );
m_spTeardropSizePercent->SetValue( m_teardropSizePrm );
m_cbSmdSimilarPads->SetValue( m_includeNotPTH );
m_cbRoundShapesOnly->SetValue( m_roundShapesOnly );
m_rbShapeRound->SetSelection( m_curveOptionRoundShapes );
m_rbShapeRect->SetSelection( m_curveOptionRectShapes );
m_rbShapeTrack->SetSelection( m_curveOptionTrackShapes );
m_cbOptUseNextTrack->SetValue( m_canUseTwoTracks );
m_spPointCount->SetValue( m_curveSegCount );
m_cbTrack2Track->SetValue( m_track2Track );
m_cbPadVia->SetValue( m_includeViasAndPTH );
m_teardropMaxLenSetting.SetValue( m_teardropMaxLenPrm );
m_teardropMaxHeightSetting.SetValue( m_teardropMaxSizePrm );
m_teardropMaxLenSettingRound.SetValue( m_teardropMaxLenPrmRound );
m_teardropMaxHeightSettingRound.SetValue( m_teardropMaxSizePrmRound );
m_spTeardropLenPercentRound->SetValue( m_teardropLenPrmRound );
m_spTeardropSizePercentRound->SetValue( m_teardropSizePrmRound );
m_teardropMaxLenSettingRect.SetValue( m_teardropMaxLenPrmRect );
m_teardropMaxHeightSettingRect.SetValue( m_teardropMaxSizePrmRect );
m_spTeardropLenPercentRect->SetValue( m_teardropLenPrmRect );
m_spTeardropSizePercentRect->SetValue( m_teardropSizePrmRect );
m_teardropMaxLenSettingTrack.SetValue( m_teardropMaxLenPrmTrack );
m_teardropMaxHeightSettingTrack.SetValue( m_teardropMaxSizePrmTrack );
m_spTeardropLenPercentTrack->SetValue( m_teardropLenPrmTrack );
m_spTeardropSizePercentTrack->SetValue( m_teardropSizePrmTrack );
// recalculate sizers, now the bitmap is initialized
finishDialogSettings();
@ -66,14 +87,26 @@ public:
~TEARDROP_DIALOG()
{
m_teardropLenPrm = m_spTeardropLenPercent->GetValue();
m_teardropSizePrm = m_spTeardropSizePercent->GetValue();
m_teardropMaxLenPrm = m_teardropMaxLenSetting.GetValue();
m_teardropMaxSizePrm = m_teardropMaxHeightSetting.GetValue();
m_teardropLenPrmRound = m_spTeardropLenPercentRound->GetValue();
m_teardropSizePrmRound = m_spTeardropSizePercentRound->GetValue();
m_teardropMaxLenPrmRound = m_teardropMaxLenSettingRound.GetValue();
m_teardropMaxSizePrmRound = m_teardropMaxHeightSettingRound.GetValue();
m_teardropLenPrmRect = m_spTeardropLenPercentRect->GetValue();
m_teardropSizePrmRect = m_spTeardropSizePercentRect->GetValue();
m_teardropMaxLenPrmRect = m_teardropMaxLenSettingRect.GetValue();
m_teardropMaxSizePrmRect = m_teardropMaxHeightSettingRect.GetValue();
m_teardropLenPrmTrack = m_spTeardropLenPercentTrack->GetValue();
m_teardropSizePrmTrack = m_spTeardropSizePercentTrack->GetValue();
m_teardropMaxLenPrmTrack = m_teardropMaxLenSettingTrack.GetValue();
m_teardropMaxSizePrmTrack = m_teardropMaxHeightSettingTrack.GetValue();
m_roundShapesOnly = m_cbRoundShapesOnly->GetValue();
m_includeNotPTH = m_cbSmdSimilarPads->GetValue();
m_curveOptionRoundShapes = m_rbShapeRound->GetSelection();
m_curveOptionRectShapes = m_rbShapeRect->GetSelection();
m_curveOptionTrackShapes = m_rbShapeTrack->GetSelection();
m_canUseTwoTracks = m_cbOptUseNextTrack->GetValue();
m_curveSegCount = m_spPointCount->GetValue();
m_track2Track = m_cbTrack2Track->GetValue();
@ -90,15 +123,30 @@ public:
if( m_rbShapeRect->GetSelection() )
opt |= CURVED_OPTION_RECT;
if( m_rbShapeTrack->GetSelection() )
opt |= CURVED_OPTION_TRACK;
return opt;
}
// Options for curved shapes
int GetCurvePointCount() { return m_spPointCount->GetValue(); }
double GetTeardropLenPercent() { return m_spTeardropLenPercent->GetValue()/100.0; }
double GetTeardropSizePercent() { return m_spTeardropSizePercent->GetValue()/100.0; }
int GetTeardropMaxLen() { return m_teardropMaxLenSetting.GetValue(); }
int GetTeardropMaxHeight() { return m_teardropMaxHeightSetting.GetValue(); }
// Getters for size parameters
double GetTeardropLenPercentRound() { return m_spTeardropLenPercentRound->GetValue()/100.0; }
double GetTeardropSizePercentRound() { return m_spTeardropSizePercentRound->GetValue()/100.0; }
int GetTeardropMaxLenRound() { return m_teardropMaxLenSettingRound.GetValue(); }
int GetTeardropMaxHeightRound() { return m_teardropMaxHeightSettingRound.GetValue(); }
double GetTeardropLenPercentRect() { return m_spTeardropLenPercentRect->GetValue()/100.0; }
double GetTeardropSizePercentRect() { return m_spTeardropSizePercentRect->GetValue()/100.0; }
int GetTeardropMaxLenRect() { return m_teardropMaxLenSettingRect.GetValue(); }
int GetTeardropMaxHeightRect() { return m_teardropMaxHeightSettingRect.GetValue(); }
double GetTeardropLenPercentTrack() { return m_spTeardropLenPercentTrack->GetValue()/100.0; }
double GetTeardropSizePercentTrack() { return m_spTeardropSizePercentTrack->GetValue()/100.0; }
int GetTeardropMaxLenTrack() { return m_teardropMaxLenSettingTrack.GetValue(); }
int GetTeardropMaxHeightTrack() { return m_teardropMaxHeightSettingTrack.GetValue(); }
// Optins to filter pads
bool TeardropOnPadVia() { return m_cbPadVia->GetValue(); }
@ -111,18 +159,34 @@ public:
private:
PCB_EDIT_FRAME* m_frame;
UNIT_BINDER m_teardropMaxLenSetting;
UNIT_BINDER m_teardropMaxHeightSetting;
UNIT_BINDER m_teardropMaxLenSettingRound;
UNIT_BINDER m_teardropMaxHeightSettingRound;
UNIT_BINDER m_teardropMaxLenSettingRect;
UNIT_BINDER m_teardropMaxHeightSettingRect;
UNIT_BINDER m_teardropMaxLenSettingTrack;
UNIT_BINDER m_teardropMaxHeightSettingTrack;
// Used to store settings during a session:
static double m_teardropLenPrm;
static double m_teardropSizePrm;
static int m_teardropMaxLenPrm;
static int m_teardropMaxSizePrm;
static double m_teardropLenPrmRound;
static double m_teardropSizePrmRound;
static int m_teardropMaxLenPrmRound;
static int m_teardropMaxSizePrmRound;
static double m_teardropLenPrmRect;
static double m_teardropSizePrmRect;
static int m_teardropMaxLenPrmRect;
static int m_teardropMaxSizePrmRect;
static double m_teardropLenPrmTrack;
static double m_teardropSizePrmTrack;
static int m_teardropMaxLenPrmTrack;
static int m_teardropMaxSizePrmTrack;
static bool m_includeNotPTH;
static bool m_roundShapesOnly;
static int m_curveOptionRoundShapes;
static int m_curveOptionRectShapes;
static int m_curveOptionTrackShapes;
static bool m_canUseTwoTracks;
static int m_curveSegCount;
static bool m_track2Track;
@ -131,14 +195,26 @@ private:
};
// Store settings during a session:
double TEARDROP_DIALOG::m_teardropLenPrm = 50;
double TEARDROP_DIALOG::m_teardropSizePrm = 100;
int TEARDROP_DIALOG::m_teardropMaxLenPrm = Millimeter2iu( 1.0 );
int TEARDROP_DIALOG::m_teardropMaxSizePrm = Millimeter2iu( 2.0 );
double TEARDROP_DIALOG::m_teardropLenPrmRound = 50;
double TEARDROP_DIALOG::m_teardropSizePrmRound = 100;
int TEARDROP_DIALOG::m_teardropMaxLenPrmRound = Millimeter2iu( 1.0 );
int TEARDROP_DIALOG::m_teardropMaxSizePrmRound = Millimeter2iu( 2.0 );
double TEARDROP_DIALOG::m_teardropLenPrmRect = 50;
double TEARDROP_DIALOG::m_teardropSizePrmRect = 100;
int TEARDROP_DIALOG::m_teardropMaxLenPrmRect = Millimeter2iu( 1.0 );
int TEARDROP_DIALOG::m_teardropMaxSizePrmRect = Millimeter2iu( 2.0 );
double TEARDROP_DIALOG::m_teardropLenPrmTrack = 100;
double TEARDROP_DIALOG::m_teardropSizePrmTrack = 100;
int TEARDROP_DIALOG::m_teardropMaxLenPrmTrack = Millimeter2iu( 2.0 );
int TEARDROP_DIALOG::m_teardropMaxSizePrmTrack = Millimeter2iu( 2.0 );
bool TEARDROP_DIALOG::m_includeNotPTH = true;
bool TEARDROP_DIALOG::m_roundShapesOnly = false;
int TEARDROP_DIALOG::m_curveOptionRoundShapes = 0;
int TEARDROP_DIALOG::m_curveOptionRectShapes = 0;
int TEARDROP_DIALOG::m_curveOptionTrackShapes = 0;
bool TEARDROP_DIALOG::m_canUseTwoTracks = true;
int TEARDROP_DIALOG::m_curveSegCount = 5;
bool TEARDROP_DIALOG::m_track2Track = true;
@ -160,9 +236,26 @@ void PCB_EDIT_FRAME::OnRunTeardropTool( wxCommandEvent& event )
int shape_seg_count = dlg.GetCurvePointCount();
trdm.SetTeardropMaxSize( dlg.GetTeardropMaxLen(), dlg.GetTeardropMaxHeight() );
trdm.SetTeardropSizeRatio( dlg.GetTeardropLenPercent(), dlg.GetTeardropSizePercent() );
trdm.SetTeardropCurvedPrms( dlg.CurvedShapeOption(), shape_seg_count );
trdm.SetTeardropMaxSize( TARGET_ROUND, dlg.GetTeardropMaxLenRound(),
dlg.GetTeardropMaxHeightRound() );
trdm.SetTeardropSizeRatio( TARGET_ROUND, dlg.GetTeardropLenPercentRound(),
dlg.GetTeardropSizePercentRound() );
trdm.SetTeardropCurvedPrm( TARGET_ROUND, (dlg.CurvedShapeOption() & CURVED_OPTION_ROUND)
? shape_seg_count : 0 );
trdm.SetTeardropMaxSize( TARGET_RECT, dlg.GetTeardropMaxLenRect(),
dlg.GetTeardropMaxHeightRect() );
trdm.SetTeardropSizeRatio( TARGET_RECT, dlg.GetTeardropLenPercentRect(),
dlg.GetTeardropSizePercentRect() );
trdm.SetTeardropCurvedPrm( TARGET_RECT, (dlg.CurvedShapeOption() & CURVED_OPTION_RECT)
? shape_seg_count : 0 );
trdm.SetTeardropMaxSize( TARGET_TRACK, dlg.GetTeardropMaxLenTrack(),
dlg.GetTeardropMaxHeightTrack() );
trdm.SetTeardropSizeRatio( TARGET_TRACK, dlg.GetTeardropLenPercentTrack(),
dlg.GetTeardropSizePercentTrack() );
trdm.SetTeardropCurvedPrm( TARGET_TRACK, (dlg.CurvedShapeOption() & CURVED_OPTION_TRACK)
? shape_seg_count : 0 );
const bool discardTeardropInSameZone = true;
trdm.SetTargets( dlg.TeardropOnPadVia(), dlg.RoundShapesOnly(),

View File

@ -23,123 +23,183 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
bSizerTop = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizeScopeSize;
bSizeScopeSize = new wxBoxSizer( wxHORIZONTAL );
bSizeScopeSize = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer* fgSizerBitmaps;
fgSizerBitmaps = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizerBitmaps = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizerBitmaps->AddGrowableCol( 2 );
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_staticTextRndS = new wxStaticText( this, wxID_ANY, wxT("Round shapes"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRndS->Wrap( -1 );
fgSizerBitmaps->Add( m_staticTextRndS, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_bitmapTdCircularInfo = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerBitmaps->Add( m_bitmapTdCircularInfo, 0, wxALL, 5 );
fgSizerBitmaps->Add( m_bitmapTdCircularInfo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 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 );
wxFlexGridSizer* fgSizerParmRound;
fgSizerParmRound = new wxFlexGridSizer( 0, 5, 0, 0 );
fgSizerParmRound->AddGrowableCol( 1 );
fgSizerParmRound->AddGrowableCol( 3 );
fgSizerParmRound->SetFlexibleDirection( wxBOTH );
fgSizerParmRound->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_stMaxLenRound = new wxStaticText( this, wxID_ANY, wxT("Max length"), wxDefaultPosition, wxDefaultSize, 0 );
m_stMaxLenRound->Wrap( -1 );
fgSizerParmRound->Add( m_stMaxLenRound, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_tcTdMaxLenRound = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerParmRound->Add( m_tcTdMaxLenRound, 0, wxALL|wxEXPAND, 5 );
m_stTdMaxSizeRound = new wxStaticText( this, wxID_ANY, wxT("Max height"), wxDefaultPosition, wxDefaultSize, 0 );
m_stTdMaxSizeRound->Wrap( -1 );
fgSizerParmRound->Add( m_stTdMaxSizeRound, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_tcMaxHeightRound = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerParmRound->Add( m_tcMaxHeightRound, 0, wxALL|wxEXPAND, 5 );
m_stLenUnitRound = new wxStaticText( this, wxID_ANY, wxT("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_stLenUnitRound->Wrap( -1 );
fgSizerParmRound->Add( m_stLenUnitRound, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_stHsettingRound = new wxStaticText( this, wxID_ANY, wxT("Best length"), wxDefaultPosition, wxDefaultSize, 0 );
m_stHsettingRound->Wrap( -1 );
fgSizerParmRound->Add( m_stHsettingRound, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_spTeardropLenPercentRound = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 20, 100, 50.000000, 10 );
m_spTeardropLenPercentRound->SetDigits( 0 );
fgSizerParmRound->Add( m_spTeardropLenPercentRound, 0, wxALL|wxEXPAND, 5 );
m_stVsettingRound = new wxStaticText( this, wxID_ANY, wxT("Best height"), wxDefaultPosition, wxDefaultSize, 0 );
m_stVsettingRound->Wrap( -1 );
fgSizerParmRound->Add( m_stVsettingRound, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_spTeardropSizePercentRound = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 60, 100, 100.000000, 10 );
m_spTeardropSizePercentRound->SetDigits( 0 );
fgSizerParmRound->Add( m_spTeardropSizePercentRound, 0, wxALL|wxEXPAND, 5 );
m_stLenPercentRound = new wxStaticText( this, wxID_ANY, wxT("% of d"), wxDefaultPosition, wxDefaultSize, 0 );
m_stLenPercentRound->Wrap( -1 );
fgSizerParmRound->Add( m_stLenPercentRound, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
fgSizerBitmaps->Add( fgSizerParmRound, 1, wxEXPAND, 5 );
m_staticTextRectS = new wxStaticText( this, wxID_ANY, wxT("Rect shapes"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRectS->Wrap( -1 );
fgSizerBitmaps->Add( m_staticTextRectS, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_bitmapTdRectangularInfo = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerBitmaps->Add( m_bitmapTdRectangularInfo, 0, wxALL, 5 );
fgSizerBitmaps->Add( m_bitmapTdRectangularInfo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 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 );
wxFlexGridSizer* fgSizerParmRect;
fgSizerParmRect = new wxFlexGridSizer( 0, 5, 0, 0 );
fgSizerParmRect->AddGrowableCol( 1 );
fgSizerParmRect->AddGrowableCol( 3 );
fgSizerParmRect->SetFlexibleDirection( wxBOTH );
fgSizerParmRect->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_stMaxLenRect = new wxStaticText( this, wxID_ANY, wxT("Max length"), wxDefaultPosition, wxDefaultSize, 0 );
m_stMaxLenRect->Wrap( -1 );
fgSizerParmRect->Add( m_stMaxLenRect, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_tcTdMaxLenRect = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerParmRect->Add( m_tcTdMaxLenRect, 0, wxALL|wxEXPAND, 5 );
m_stTdMaxSizeRect = new wxStaticText( this, wxID_ANY, wxT("Max height"), wxDefaultPosition, wxDefaultSize, 0 );
m_stTdMaxSizeRect->Wrap( -1 );
fgSizerParmRect->Add( m_stTdMaxSizeRect, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_tcMaxHeightRect = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerParmRect->Add( m_tcMaxHeightRect, 0, wxALL|wxEXPAND, 5 );
m_stLenUnitRect = new wxStaticText( this, wxID_ANY, wxT("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_stLenUnitRect->Wrap( -1 );
fgSizerParmRect->Add( m_stLenUnitRect, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_stHsettingRect = new wxStaticText( this, wxID_ANY, wxT("Best length"), wxDefaultPosition, wxDefaultSize, 0 );
m_stHsettingRect->Wrap( -1 );
fgSizerParmRect->Add( m_stHsettingRect, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_spTeardropLenPercentRect = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 20, 100, 50.000000, 10 );
m_spTeardropLenPercentRect->SetDigits( 0 );
fgSizerParmRect->Add( m_spTeardropLenPercentRect, 0, wxALL|wxEXPAND, 5 );
m_stVsettingRect = new wxStaticText( this, wxID_ANY, wxT("Best height"), wxDefaultPosition, wxDefaultSize, 0 );
m_stVsettingRect->Wrap( -1 );
fgSizerParmRect->Add( m_stVsettingRect, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_spTeardropSizePercentRect = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 60, 100, 100.000000, 10 );
m_spTeardropSizePercentRect->SetDigits( 0 );
fgSizerParmRect->Add( m_spTeardropSizePercentRect, 0, wxALL|wxEXPAND, 5 );
m_stLenPercentRect = new wxStaticText( this, wxID_ANY, wxT("% of d"), wxDefaultPosition, wxDefaultSize, 0 );
m_stLenPercentRect->Wrap( -1 );
fgSizerParmRect->Add( m_stLenPercentRect, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
fgSizerBitmaps->Add( fgSizerParmRect, 1, wxEXPAND, 5 );
m_staticTextTrck = new wxStaticText( this, wxID_ANY, wxT("Tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextTrck->Wrap( -1 );
fgSizerBitmaps->Add( m_staticTextTrck, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_bitmapTdTrackInfo = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerBitmaps->Add( m_bitmapTdTrackInfo, 0, wxALL, 5 );
fgSizerBitmaps->Add( m_bitmapTdTrackInfo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxFlexGridSizer* fgSizerParmTrack;
fgSizerParmTrack = new wxFlexGridSizer( 0, 5, 0, 0 );
fgSizerParmTrack->AddGrowableCol( 1 );
fgSizerParmTrack->AddGrowableCol( 3 );
fgSizerParmTrack->SetFlexibleDirection( wxBOTH );
fgSizerParmTrack->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_stMaxLenTrack = new wxStaticText( this, wxID_ANY, wxT("Max length"), wxDefaultPosition, wxDefaultSize, 0 );
m_stMaxLenTrack->Wrap( -1 );
fgSizerParmTrack->Add( m_stMaxLenTrack, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_tcTdMaxLenTrack = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerParmTrack->Add( m_tcTdMaxLenTrack, 0, wxALL|wxEXPAND, 5 );
m_stTdMaxSizeTrack = new wxStaticText( this, wxID_ANY, wxT("Max height"), wxDefaultPosition, wxDefaultSize, 0 );
m_stTdMaxSizeTrack->Wrap( -1 );
fgSizerParmTrack->Add( m_stTdMaxSizeTrack, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_tcMaxHeightTrack = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerParmTrack->Add( m_tcMaxHeightTrack, 0, wxALL|wxEXPAND, 5 );
m_stLenUnitTrack = new wxStaticText( this, wxID_ANY, wxT("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_stLenUnitTrack->Wrap( -1 );
fgSizerParmTrack->Add( m_stLenUnitTrack, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_stHsettingtrack = new wxStaticText( this, wxID_ANY, wxT("Best length"), wxDefaultPosition, wxDefaultSize, 0 );
m_stHsettingtrack->Wrap( -1 );
fgSizerParmTrack->Add( m_stHsettingtrack, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_spTeardropLenPercentTrack = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 20, 100, 100.000000, 10 );
m_spTeardropLenPercentTrack->SetDigits( 0 );
fgSizerParmTrack->Add( m_spTeardropLenPercentTrack, 0, wxALL|wxEXPAND, 5 );
m_stVsettingtrack = new wxStaticText( this, wxID_ANY, wxT("Best height"), wxDefaultPosition, wxDefaultSize, 0 );
m_stVsettingtrack->Wrap( -1 );
fgSizerParmTrack->Add( m_stVsettingtrack, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
m_spTeardropSizePercentTrack = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 60, 100, 100.000000, 10 );
m_spTeardropSizePercentTrack->SetDigits( 0 );
fgSizerParmTrack->Add( m_spTeardropSizePercentTrack, 0, wxALL|wxEXPAND, 5 );
m_stLenPercentTrack = new wxStaticText( this, wxID_ANY, wxT("% of d"), wxDefaultPosition, wxDefaultSize, 0 );
m_stLenPercentTrack->Wrap( -1 );
fgSizerParmTrack->Add( m_stLenPercentTrack, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 );
fgSizerBitmaps->Add( fgSizerParmTrack, 1, wxEXPAND, 5 );
bSizeScopeSize->Add( fgSizerBitmaps, 1, wxLEFT|wxEXPAND, 5 );
bSizeScopeSize->Add( 30, 0, 0, wxEXPAND, 5 );
wxFlexGridSizer* fgSizerSizes;
fgSizerSizes = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizerSizes->SetFlexibleDirection( wxBOTH );
fgSizerSizes->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_stMaxLen = new wxStaticText( this, wxID_ANY, wxT("Max lenght"), wxDefaultPosition, wxDefaultSize, 0 );
m_stMaxLen->Wrap( -1 );
fgSizerSizes->Add( m_stMaxLen, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_tcTdMaxLen = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSizes->Add( m_tcTdMaxLen, 0, wxALL, 5 );
m_stLenUnit = new wxStaticText( this, wxID_ANY, wxT("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_stLenUnit->Wrap( -1 );
fgSizerSizes->Add( m_stLenUnit, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_stHsetting = new wxStaticText( this, wxID_ANY, wxT("Best lenght"), wxDefaultPosition, wxDefaultSize, 0 );
m_stHsetting->Wrap( -1 );
fgSizerSizes->Add( m_stHsetting, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_spTeardropLenPercent = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 20, 100, 50.000000, 10 );
m_spTeardropLenPercent->SetDigits( 0 );
fgSizerSizes->Add( m_spTeardropLenPercent, 0, wxALL|wxEXPAND, 5 );
m_stLenPercent = new wxStaticText( this, wxID_ANY, wxT("% of d"), wxDefaultPosition, wxDefaultSize, 0 );
m_stLenPercent->Wrap( -1 );
fgSizerSizes->Add( m_stLenPercent, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_staticline5 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
fgSizerSizes->Add( m_staticline5, 0, wxEXPAND | wxALL, 5 );
m_staticline6 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
fgSizerSizes->Add( m_staticline6, 0, wxEXPAND | wxALL, 5 );
m_staticline7 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
fgSizerSizes->Add( m_staticline7, 0, wxEXPAND | wxALL, 5 );
m_stTdMaxSize = new wxStaticText( this, wxID_ANY, wxT("Max height"), wxDefaultPosition, wxDefaultSize, 0 );
m_stTdMaxSize->Wrap( -1 );
fgSizerSizes->Add( m_stTdMaxSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_tcMaxSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSizes->Add( m_tcMaxSize, 0, wxALL, 5 );
m_stSizeUnit = new wxStaticText( this, wxID_ANY, wxT("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_stSizeUnit->Wrap( -1 );
fgSizerSizes->Add( m_stSizeUnit, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_stVsetting = new wxStaticText( this, wxID_ANY, wxT("Best height"), wxDefaultPosition, wxDefaultSize, 0 );
m_stVsetting->Wrap( -1 );
fgSizerSizes->Add( m_stVsetting, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_spTeardropSizePercent = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 60, 100, 100.000000, 10 );
m_spTeardropSizePercent->SetDigits( 0 );
fgSizerSizes->Add( m_spTeardropSizePercent, 0, wxALL|wxEXPAND, 5 );
m_stTdSizePercent = new wxStaticText( this, wxID_ANY, wxT("% of d"), wxDefaultPosition, wxDefaultSize, 0 );
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 );
bSizerTop->Add( bSizeScopeSize, 0, wxEXPAND, 5 );
@ -184,6 +244,12 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
m_rbShapeRect->SetSelection( 0 );
bSizerShape->Add( m_rbShapeRect, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxString m_rbShapeTrackChoices[] = { wxT("Straight lines"), wxT("Curved") };
int m_rbShapeTrackNChoices = sizeof( m_rbShapeTrackChoices ) / sizeof( wxString );
m_rbShapeTrack = new wxRadioBox( this, wxID_ANY, wxT("Track teardrop style"), wxDefaultPosition, wxDefaultSize, m_rbShapeTrackNChoices, m_rbShapeTrackChoices, 1, wxRA_SPECIFY_COLS );
m_rbShapeTrack->SetSelection( 0 );
bSizerShape->Add( m_rbShapeTrack, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bSizerShape->Add( 30, 0, 0, 0, 5 );
@ -191,16 +257,26 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
bSizerUpper->Add( bSizerShape, 0, wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerOptions;
sbSizerOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Options") ), wxVERTICAL );
sbSizerOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Options") ), wxHORIZONTAL );
m_cbOptUseNextTrack = new wxCheckBox( sbSizerOptions->GetStaticBox(), wxID_ANY, wxT("Allows use two tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbOptUseNextTrack->SetValue(true);
m_cbOptUseNextTrack->SetToolTip( wxT("Allows a teardrop to spread over 2 tracks if the first track segment is too short") );
sbSizerOptions->Add( m_cbOptUseNextTrack, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
sbSizerOptions->Add( m_cbOptUseNextTrack, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bSizerUpper->Add( sbSizerOptions, 1, wxEXPAND|wxTOP, 5 );
sbSizerOptions->Add( 30, 0, 0, 0, 5 );
m_stPointCount = new wxStaticText( sbSizerOptions->GetStaticBox(), wxID_ANY, wxT("Curve points"), wxDefaultPosition, wxDefaultSize, 0 );
m_stPointCount->Wrap( -1 );
sbSizerOptions->Add( m_stPointCount, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_spPointCount = new wxSpinCtrl( sbSizerOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 3, 10, 5 );
sbSizerOptions->Add( m_spPointCount, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bSizerUpper->Add( sbSizerOptions, 0, wxEXPAND|wxTOP, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerUpper->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );

File diff suppressed because it is too large Load Diff

View File

@ -20,13 +20,13 @@
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/statbmp.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/spinctrl.h>
#include <wx/statline.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -41,39 +41,52 @@ class TEARDROP_DIALOG_BASE : public DIALOG_SHIM
private:
protected:
wxStaticText* m_staticText10;
wxStaticText* m_staticTextRndS;
wxStaticBitmap* m_bitmapTdCircularInfo;
wxStaticText* m_staticText11;
wxStaticText* m_stMaxLenRound;
wxTextCtrl* m_tcTdMaxLenRound;
wxStaticText* m_stTdMaxSizeRound;
wxTextCtrl* m_tcMaxHeightRound;
wxStaticText* m_stLenUnitRound;
wxStaticText* m_stHsettingRound;
wxSpinCtrlDouble* m_spTeardropLenPercentRound;
wxStaticText* m_stVsettingRound;
wxSpinCtrlDouble* m_spTeardropSizePercentRound;
wxStaticText* m_stLenPercentRound;
wxStaticText* m_staticTextRectS;
wxStaticBitmap* m_bitmapTdRectangularInfo;
wxStaticText* m_staticText12;
wxStaticText* m_stMaxLenRect;
wxTextCtrl* m_tcTdMaxLenRect;
wxStaticText* m_stTdMaxSizeRect;
wxTextCtrl* m_tcMaxHeightRect;
wxStaticText* m_stLenUnitRect;
wxStaticText* m_stHsettingRect;
wxSpinCtrlDouble* m_spTeardropLenPercentRect;
wxStaticText* m_stVsettingRect;
wxSpinCtrlDouble* m_spTeardropSizePercentRect;
wxStaticText* m_stLenPercentRect;
wxStaticText* m_staticTextTrck;
wxStaticBitmap* m_bitmapTdTrackInfo;
wxStaticText* m_stMaxLen;
wxTextCtrl* m_tcTdMaxLen;
wxStaticText* m_stLenUnit;
wxStaticText* m_stHsetting;
wxSpinCtrlDouble* m_spTeardropLenPercent;
wxStaticText* m_stLenPercent;
wxStaticLine* m_staticline5;
wxStaticLine* m_staticline6;
wxStaticLine* m_staticline7;
wxStaticText* m_stTdMaxSize;
wxTextCtrl* m_tcMaxSize;
wxStaticText* m_stSizeUnit;
wxStaticText* m_stVsetting;
wxSpinCtrlDouble* m_spTeardropSizePercent;
wxStaticText* m_stTdSizePercent;
wxStaticLine* m_staticline51;
wxStaticLine* m_staticline61;
wxStaticLine* m_staticline71;
wxStaticText* m_stPoinCount;
wxSpinCtrl* m_spPointCount;
wxStaticText* m_stMaxLenTrack;
wxTextCtrl* m_tcTdMaxLenTrack;
wxStaticText* m_stTdMaxSizeTrack;
wxTextCtrl* m_tcMaxHeightTrack;
wxStaticText* m_stLenUnitTrack;
wxStaticText* m_stHsettingtrack;
wxSpinCtrlDouble* m_spTeardropLenPercentTrack;
wxStaticText* m_stVsettingtrack;
wxSpinCtrlDouble* m_spTeardropSizePercentTrack;
wxStaticText* m_stLenPercentTrack;
wxCheckBox* m_cbPadVia;
wxCheckBox* m_cbRoundShapesOnly;
wxCheckBox* m_cbSmdSimilarPads;
wxCheckBox* m_cbTrack2Track;
wxRadioBox* m_rbShapeRound;
wxRadioBox* m_rbShapeRect;
wxRadioBox* m_rbShapeTrack;
wxCheckBox* m_cbOptUseNextTrack;
wxStaticText* m_stPointCount;
wxSpinCtrl* m_spPointCount;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
@ -81,7 +94,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( 532,470 ), 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( 648,479 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~TEARDROP_DIALOG_BASE();

View File

@ -55,7 +55,7 @@ void TEARDROP_MANAGER::SetTargets( bool aApplyToPadVias, bool aApplyToRoundShape
// Build a zone teardrop
ZONE* TEARDROP_MANAGER::createTeardrop( TEARDROP_VARIANT aTeardropVariant,
std::vector<VECTOR2I>& aPoints, PCB_TRACK* aTrack)
std::vector<VECTOR2I>& aPoints, PCB_TRACK* aTrack) const
{
ZONE* teardrop = new ZONE( m_board );
@ -90,7 +90,9 @@ int TEARDROP_MANAGER::SetTeardrops( BOARD_COMMIT* aCommitter,
bool aDiscardInSameZone, bool aFollowTracks )
{
// Init parameters:
m_Parameters.m_tolerance = Millimeter2iu( 0.01 );
m_Parameters[TARGET_ROUND].m_tolerance = Millimeter2iu( 0.01 );
m_Parameters[TARGET_RECT].m_tolerance = Millimeter2iu( 0.01 );
m_Parameters[TARGET_TRACK].m_tolerance = Millimeter2iu( 0.01 );
int count = 0; // Number of created teardrop
@ -132,6 +134,10 @@ int TEARDROP_MANAGER::SetTeardrops( BOARD_COMMIT* aCommitter,
// if both track ends are inside or outside, one cannot build a teadrop
for( VIAPAD& viapad: viapad_list )
{
// Pad and track must be on the same layer
if( !viapad.IsOnLayer( track->GetLayer() ) )
continue;
bool start_in_pad = viapad.m_Parent->HitTest( track->GetStart() );
bool end_in_pad = viapad.m_Parent->HitTest( track->GetEnd() );
@ -139,14 +145,15 @@ int TEARDROP_MANAGER::SetTeardrops( BOARD_COMMIT* aCommitter,
// the track is inside or outside the via pad. Cannot create a teardrop
continue;
if( viapad.m_IsRound )
m_CurrParams = &m_Parameters[TARGET_ROUND];
else
m_CurrParams = &m_Parameters[TARGET_RECT];
// Ensure a teardrop shape can be built:
// The track width must be < teardrop height
if( track->GetWidth() >= m_Parameters.m_tdMaxHeight
|| track->GetWidth() >= viapad.m_Width * m_Parameters.m_heightRatio )
continue;
// Pad and track must be on the same layer
if( !viapad.IsOnLayer( track->GetLayer() ) )
if( track->GetWidth() >= m_CurrParams->m_tdMaxHeight
|| track->GetWidth() >= viapad.m_Width * m_CurrParams->m_heightRatio )
continue;
// Skip case where pad/via and the track is within a copper zone with the same net
@ -251,6 +258,7 @@ int TEARDROP_MANAGER::addTeardropsOnTracks( BOARD_COMMIT* aCommitter )
std::vector< VIAPAD > viapad_list;
collectVias( viapad_list );
collectPadsCandidate( viapad_list, true, true );
m_CurrParams = &m_Parameters[TARGET_TRACK];
// Explore groups (a group is a set of tracks on the same layer and the same net):
for( auto grp : trackLookupList.GetBuffer() )
@ -308,12 +316,13 @@ int TEARDROP_MANAGER::addTeardropsOnTracks( BOARD_COMMIT* aCommitter )
VECTOR2I roundshape_pos = candidate->GetStart();
ENDPOINT_T endPointCandidate = ENDPOINT_START;
match_points = track->IsPointOnEnds( roundshape_pos, m_Parameters.m_tolerance);
match_points = track->IsPointOnEnds( roundshape_pos, m_CurrParams->m_tolerance );
if( !match_points )
{
roundshape_pos = candidate->GetEnd();
match_points = track->IsPointOnEnds( roundshape_pos, m_Parameters.m_tolerance);
match_points = track->IsPointOnEnds( roundshape_pos,
m_CurrParams->m_tolerance );
endPointCandidate = ENDPOINT_END;
}

View File

@ -59,12 +59,14 @@ struct VIAPAD
};
// 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 */
// IDs for targets when creating teardrops
enum TARGET_TD
{
TARGET_ROUND = 0,
TARGET_RECT = 1,
TARGET_TRACK = 2,
TARGET_COUNT = 3
};
/**
* TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops
@ -82,8 +84,7 @@ public:
m_lenghtRatio( 0.5),
m_heightRatio( 1.0 ),
m_curveSegCount( 0 ),
m_tolerance( Millimeter2iu( 0.01 ) ),
m_curveShapeOpt( CURVED_OPTION_NONE )
m_tolerance( Millimeter2iu( 0.01 ) )
{
}
@ -112,13 +113,13 @@ public:
* Set the params for teardrop using curved shape
* note: if aCurveSegCount is < 3, the shape uses a straight line
*/
void SetTeardropCurvedPrms( int aCurveShapeOpt = CURVED_OPTION_NONE,
int aCurveSegCount = 5 )
void SetTeardropCurvedPrm( int aCurveSegCount = 0 )
{
m_curveShapeOpt = aCurveShapeOpt;
m_curveSegCount = aCurveSegCount;
}
bool IsCurved() const { return m_curveSegCount > 2; }
protected:
/// max allowed lenght for teardrops in IU. <= 0 to disable
int m_tdMaxLen;
@ -133,11 +134,6 @@ protected:
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;
};
@ -167,6 +163,7 @@ public:
};
TEARDROP_MANAGER( BOARD* aBoard, PCB_EDIT_FRAME* aFrame ) :
m_CurrParams( &m_Parameters[TARGET_ROUND] ),
m_applyToViaPads( true ),
m_applyToRoundShapesOnly( false ),
m_applyToSurfacePads( true ),
@ -200,9 +197,9 @@ public:
* Set max allowed lenght and height for teardrops in IU.
* a value <= 0 disable the constraint
*/
void SetTeardropMaxSize( int aMaxLen, int aMaxHeight )
void SetTeardropMaxSize( TARGET_TD aTdType, int aMaxLen, int aMaxHeight )
{
m_Parameters.SetTeardropMaxSize( aMaxLen, aMaxHeight );
m_Parameters[aTdType].SetTeardropMaxSize( aMaxLen, aMaxHeight );
}
@ -211,9 +208,9 @@ public:
* the prefered lenght and height are VIAPAD width * aLenghtRatio and
* VIAPAD width * aHeightRatio
*/
void SetTeardropSizeRatio( double aLenghtRatio = 0.5, double aHeightRatio = 1.0 )
void SetTeardropSizeRatio( TARGET_TD aTdType, double aLenghtRatio = 0.5, double aHeightRatio = 1.0 )
{
m_Parameters.SetTeardropSizeRatio( aLenghtRatio, aHeightRatio );
m_Parameters[aTdType].SetTeardropSizeRatio( aLenghtRatio, aHeightRatio );
}
@ -221,10 +218,9 @@ public:
* Set the params for teardrop using curved shape
* note: if aSegCount is < 3, the shape uses a straight line
*/
void SetTeardropCurvedPrms( int aCurveShapeOpt = CURVED_OPTION_NONE,
int aCurveSegCount = 5 )
void SetTeardropCurvedPrm( TARGET_TD aTdType, int aCurveSegCount = 0 )
{
m_Parameters.SetTeardropCurvedPrms( aCurveShapeOpt, aCurveSegCount );
m_Parameters[aTdType].SetTeardropCurvedPrm( aCurveSegCount );
}
/**
@ -238,13 +234,16 @@ public:
void SetTargets( bool aApplyToPadVias, bool aApplyToRoundShapesOnly,
bool aApplyToSurfacePads, bool aApplyToTracks );
TEARDROP_PARAMETERS m_Parameters;
TEARDROP_PARAMETERS m_Parameters[TARGET_COUNT];
// A pointer to one of available m_Parameters items
TEARDROP_PARAMETERS* m_CurrParams;
private:
/**
* Collect and build the list of all vias from the given board
*/
void collectVias( std::vector< VIAPAD >& aList );
void collectVias( std::vector< VIAPAD >& aList ) const;
/**
* Build a list of pads candidate for teardrops from the given board
@ -256,13 +255,13 @@ private:
*/
void collectPadsCandidate( std::vector< VIAPAD >& aList,
bool aRoundShapesOnly,
bool aIncludeNotDrilled );
bool aIncludeNotDrilled ) const;
/**
* Build a list of all teardrops on the current board
* @param aList is the list to populate
*/
void collectTeardrops( std::vector< ZONE* >& aList );
void collectTeardrops( std::vector< ZONE* >& aList ) const;
/**
* Add teardrop on tracks of different sizes connected by their end
@ -340,7 +339,7 @@ private:
* (mainly for net info)
*/
ZONE* createTeardrop( TEARDROP_VARIANT aTeardropVariant,
std::vector<VECTOR2I>& aPoints, PCB_TRACK* aTrack);
std::vector<VECTOR2I>& aPoints, PCB_TRACK* aTrack) const;
/**
* Set priority of created teardrops. smaller have bigger priority
@ -408,7 +407,7 @@ public:
private:
// Build an index from the layer id and the netcode, to store a track in buffer
int idxFromLayNet( int aLayer, int aNetcode )
int idxFromLayNet( int aLayer, int aNetcode ) const
{
return ( aNetcode << 8 ) + ( aLayer & 0xFF );
}

View File

@ -97,7 +97,7 @@ VIAPAD::VIAPAD( PCB_TRACK* aTrack, ENDPOINT_T aEndPoint ) :
}
void TEARDROP_MANAGER::collectVias( std::vector< VIAPAD >& aList )
void TEARDROP_MANAGER::collectVias( std::vector< VIAPAD >& aList ) const
{
for( PCB_TRACK* item : m_board->Tracks() )
{
@ -111,7 +111,7 @@ void TEARDROP_MANAGER::collectVias( std::vector< VIAPAD >& aList )
void TEARDROP_MANAGER::collectPadsCandidate( std::vector< VIAPAD >& aList,
bool aRoundShapesOnly,
bool aIncludeNotDrilled )
bool aIncludeNotDrilled ) const
{
for( FOOTPRINT* fp : m_board->Footprints() )
{
@ -144,7 +144,7 @@ void TEARDROP_MANAGER::collectPadsCandidate( std::vector< VIAPAD >& aList,
}
void TEARDROP_MANAGER::collectTeardrops( std::vector< ZONE* >& aList )
void TEARDROP_MANAGER::collectTeardrops( std::vector< ZONE* >& aList ) const
{
for( ZONE* zone : m_board->Zones() )
{
@ -208,7 +208,7 @@ PCB_TRACK* TEARDROP_MANAGER::findTouchingTrack( EDA_ITEM_FLAGS& aMatchType, PCB_
if( curr_track == aTrackRef )
continue;
match = curr_track->IsPointOnEnds( aEndPoint, m_Parameters.m_tolerance);
match = curr_track->IsPointOnEnds( aEndPoint, m_Parameters[TARGET_ROUND].m_tolerance);
if( match )
{
@ -256,14 +256,14 @@ void TEARDROP_MANAGER::computeCurvedForRoundShape( std::vector<VECTOR2I>& aPoly,
// A and B are points on the track ( pts[0] and pts[1] )
// C and E are points on the aViaPad ( pts[2] and pts[4] )
// D is the aViaPad centre ( pts[3] )
double Vpercent = m_Parameters.m_heightRatio;
double Vpercent = m_CurrParams->m_heightRatio;
int td_height = aViaPad.m_Width * Vpercent;
// First, calculate a aVpercent equivalent to the td_height clamped by aTdMaxHeight
// We cannot use the initial aVpercent because it gives bad shape with points
// on aViaPad calculated for a clamped aViaPad size
if( m_Parameters.m_tdMaxHeight > 0 && m_Parameters.m_tdMaxHeight < td_height )
Vpercent *= (double)m_Parameters.m_tdMaxHeight / td_height;
if( m_CurrParams->m_tdMaxHeight > 0 && m_CurrParams->m_tdMaxHeight < td_height )
Vpercent *= (double)m_CurrParams->m_tdMaxHeight / td_height;
int radius = aViaPad.m_Width / 2;
double minVpercent = double( aTrackHalfWidth ) / radius;
@ -283,9 +283,9 @@ void TEARDROP_MANAGER::computeCurvedForRoundShape( std::vector<VECTOR2I>& aPoly,
VECTOR2I tangentA = VECTOR2I( pts[0].x - aTrackDir.x * biasAE, pts[0].y - aTrackDir.y * biasAE );
std::vector<VECTOR2I> curve_pts;
curve_pts.reserve( m_Parameters.m_curveSegCount );
curve_pts.reserve( m_CurrParams->m_curveSegCount );
BEZIER_POLY( pts[1], tangentB, tangentC, pts[2] ).GetPoly( curve_pts, 0,
m_Parameters.m_curveSegCount );
m_CurrParams->m_curveSegCount );
for( VECTOR2I& corner: curve_pts )
aPoly.push_back( corner );
@ -294,7 +294,7 @@ void TEARDROP_MANAGER::computeCurvedForRoundShape( std::vector<VECTOR2I>& aPoly,
curve_pts.clear();
BEZIER_POLY( pts[4], tangentE, tangentA, pts[0] ).GetPoly( curve_pts, 0,
m_Parameters.m_curveSegCount );
m_CurrParams->m_curveSegCount );
for( VECTOR2I& corner: curve_pts )
aPoly.push_back( corner );
@ -320,7 +320,7 @@ void TEARDROP_MANAGER::computeCurvedForRectShape( std::vector<VECTOR2I>& aPoly,
VECTOR2I side2( aPts[4] - aPts[0] ); // vector from track to via
std::vector<VECTOR2I> curve_pts;
curve_pts.reserve( m_Parameters.m_curveSegCount );
curve_pts.reserve( m_CurrParams->m_curveSegCount );
// Note: This side is from track to via
VECTOR2I ctrl1 = ( aPts[1] + aPts[1] + aPts[2] ) / 3;
@ -352,7 +352,7 @@ void TEARDROP_MANAGER::computeCurvedForRectShape( std::vector<VECTOR2I>& aPoly,
ctrl2.y += bias.y;
BEZIER_POLY( aPts[1], ctrl1, ctrl2, aPts[2] ).GetPoly( curve_pts, 0,
m_Parameters.m_curveSegCount );
m_CurrParams->m_curveSegCount );
for( VECTOR2I& corner: curve_pts )
aPoly.push_back( corner );
@ -380,7 +380,7 @@ void TEARDROP_MANAGER::computeCurvedForRectShape( std::vector<VECTOR2I>& aPoly,
ctrl2.y += bias.y;
BEZIER_POLY( aPts[4], ctrl1, ctrl2, aPts[0] ).GetPoly( curve_pts, 0,
m_Parameters.m_curveSegCount );
m_CurrParams->m_curveSegCount );
for( VECTOR2I& corner: curve_pts )
aPoly.push_back( corner );
@ -401,14 +401,14 @@ bool TEARDROP_MANAGER::ComputePointsOnPadVia( PCB_TRACK* aTrack,
// For rectangular (and similar) shapes, the preferred_height is calculated from the min
// dim of the rectangle = aViaPad.m_Width
int preferred_height = aViaPad.m_Width * m_Parameters.m_heightRatio;
int preferred_height = aViaPad.m_Width * m_CurrParams->m_heightRatio;
// force_clip_shape = true to force the via/pad polygon to be clipped to follow
// contraints
// Clipping is also needed for rectangular shapes, because the teardrop shape is
// restricted to a polygonal area smaller than the pad area (the teardrop height
// use the smaller value of X and Y sizes).
bool force_clip_shape = m_Parameters.m_heightRatio < 1.0;
bool force_clip_shape = m_CurrParams->m_heightRatio < 1.0;
// To find the anchor points on via/pad shape, we build the polygonal shape, and clip the polygon
// to the max size (preferred_height or m_tdMaxHeight) by a rectangle centered on the
@ -424,7 +424,7 @@ bool TEARDROP_MANAGER::ComputePointsOnPadVia( PCB_TRACK* aTrack,
wxASSERT( pad );
force_clip_shape = true;
preferred_height = aViaPad.m_Width * m_Parameters.m_heightRatio;
preferred_height = aViaPad.m_Width * m_CurrParams->m_heightRatio;
pad->TransformShapeWithClearanceToPolygon( c_buffer, aTrack->GetLayer(), 0,
ARC_LOW_DEF, ERROR_INSIDE );
}
@ -432,10 +432,10 @@ bool TEARDROP_MANAGER::ComputePointsOnPadVia( PCB_TRACK* aTrack,
// Clip the pad/via shape to match the m_tdMaxHeight constraint, and for
// not rounded pad, clip the shape at the aViaPad.m_Width, i.e. the value
// of the smallest value between size.x and size.y values.
if( force_clip_shape || ( m_Parameters.m_tdMaxHeight > 0
&& m_Parameters.m_tdMaxHeight < preferred_height ) )
if( force_clip_shape || ( m_CurrParams->m_tdMaxHeight > 0
&& m_CurrParams->m_tdMaxHeight < preferred_height ) )
{
int halfsize = std::min( m_Parameters.m_tdMaxHeight, preferred_height )/2;
int halfsize = std::min( m_CurrParams->m_tdMaxHeight, preferred_height )/2;
// teardrop_axis is the line from anchor point on the track and the end point
// of the teardrop in the pad/via
@ -581,11 +581,12 @@ bool TEARDROP_MANAGER::findAnchorPointsOnTrack( VECTOR2I& aStartPoint, VECTOR2I&
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;
if( m_Parameters.m_tdMaxLen > 0 )
targetLength = std::min( m_Parameters.m_tdMaxLen, targetLength );
// Requested length of the teardrop:
int targetLength = aViaPad.m_Width * m_CurrParams->m_lenghtRatio;
if( m_CurrParams->m_tdMaxLen > 0 )
targetLength = std::min( m_CurrParams->m_tdMaxLen, targetLength );
int actualTdLen; // The actual teardrop lenght, limited by the available track lenght
@ -714,8 +715,7 @@ bool TEARDROP_MANAGER::computeTeardropPolygonPoints( std::vector<VECTOR2I>& aCor
ComputePointsOnPadVia( aTrack, aViaPad, pts );
if( m_Parameters.m_curveSegCount <= 2
|| m_Parameters.m_curveShapeOpt == CURVED_OPTION_NONE )
if( !m_CurrParams->IsCurved() )
{
aCorners = pts;
return true;
@ -724,26 +724,17 @@ bool TEARDROP_MANAGER::computeTeardropPolygonPoints( std::vector<VECTOR2I>& aCor
// See if we can use curved teardrop shape
if( aViaPad.m_IsRound )
{
if( m_Parameters.m_curveShapeOpt & CURVED_OPTION_ROUND )
computeCurvedForRoundShape( aCorners, track_halfwidth,
vecT, aViaPad, pts );
else
aCorners = pts;
computeCurvedForRoundShape( aCorners, track_halfwidth, vecT, aViaPad, pts );
}
else
{
if( m_Parameters.m_curveShapeOpt & CURVED_OPTION_RECT )
{
int td_height = aViaPad.m_Width * m_Parameters.m_heightRatio;
int td_height = aViaPad.m_Width * m_CurrParams->m_heightRatio;
if( m_Parameters.m_tdMaxHeight > 0 && m_Parameters.m_tdMaxHeight < td_height )
td_height = m_Parameters.m_tdMaxHeight;
if( m_CurrParams->m_tdMaxHeight > 0 && m_CurrParams->m_tdMaxHeight < td_height )
td_height = m_CurrParams->m_tdMaxHeight;
computeCurvedForRectShape( aCorners, td_height, track_halfwidth,
aViaPad, pts );
}
else
aCorners = pts;
computeCurvedForRectShape( aCorners, td_height, track_halfwidth,
aViaPad, pts );
}
return true;