KiCad PCB EDA Suite
Loading...
Searching...
No Matches
teardrop_parameters.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef TEARDROP_PARAMS_H
26#define TEARDROP_PARAMS_H
27
28#include <string>
29#include <vector>
30#include <base_units.h>
31
32// IDs for targets when creating teardrops
34{
39 TARGET_COUNT = 3
40};
41
48{
49public:
51 m_TdMaxLen( pcbIUScale.mmToIU( 1.0 ) ),
52 m_TdMaxWidth( pcbIUScale.mmToIU( 2.0 ) ),
54 m_BestWidthRatio( 1.0 ),
56 m_CurveSegCount( 0 ),
57 m_Enabled( false ),
58 m_AllowUseTwoTracks( true ),
59 m_TdOnPadsInZones( false )
60 {
61 }
62
67 void SetTeardropMaxSize( int aMaxLen, int aMaxHeight )
68 {
69 m_TdMaxLen = aMaxLen;
70 m_TdMaxWidth = aMaxHeight;
71 }
72
78 void SetTeardropSizeRatio( double aLenghtRatio = 0.5, double aHeightRatio = 1.0 )
79 {
80 m_BestLengthRatio = aLenghtRatio;
81 m_BestWidthRatio = aHeightRatio;
82 }
83
87 void SetTeardropCurvedPrm( int aCurveSegCount = 0 )
88 {
89 m_CurveSegCount = aCurveSegCount;
90 }
91
92 bool IsCurved() const { return m_CurveSegCount > 0; }
93
94 bool operator== ( const TEARDROP_PARAMETERS& aOther ) const
95 {
96 return m_Enabled == aOther.m_Enabled &&
98 m_TdMaxLen == aOther.m_TdMaxLen &&
99 m_TdMaxWidth == aOther.m_TdMaxWidth &&
105 }
106
107 bool operator!= ( const TEARDROP_PARAMETERS& aOther ) const
108 {
109 return !( *this == aOther );
110 }
111
112public:
126
133};
134
135
136
142{
143 std::vector<TEARDROP_PARAMETERS> m_params_list;
144
145public:
157
158public:
160 m_TargetVias( true ),
161 m_TargetPTHPads( true ),
162 m_TargetSMDPads( true ),
163 m_TargetTrack2Track( false ),
164 m_UseRoundShapesOnly( false )
165 {
166 m_params_list.emplace_back(); // parameters for TARGET_ROUND
167 m_params_list.emplace_back(); // parameters for TARGET_RECT
168 m_params_list.emplace_back(); // parameters for TARGET_TRACK
169 }
170
175 {
176 return &m_params_list.at( aTdType );
177 }
178
183 {
184 return m_params_list.size();
185 }
186};
187
188
193std::string GetTeardropTargetCanonicalName( TARGET_TD aTdType );
194
199TARGET_TD GetTeardropTargetTypeFromCanonicalName( const std::string& aTargetName );
200
201#endif // ifndef TEARDROP_PARAMS_H
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
TEARDROP_PARAMETERS_LIST is a helper class to handle the list of TEARDROP_PARAMETERS needed to build ...
std::vector< TEARDROP_PARAMETERS > m_params_list
bool m_UseRoundShapesOnly
True to create teardrops for round shapes only.
bool m_TargetVias
True to create teardrops for vias.
bool m_TargetPTHPads
True to create teardrops for pads with holes.
bool m_TargetTrack2Track
True to create teardrops at the end of a track connected to the end of another track having a differe...
TEARDROP_PARAMETERS * GetParameters(TARGET_TD aTdType)
bool m_TargetSMDPads
True to create teardrops for pads SMD, edge connectors,.
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
True if the teardrop should be curved.
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
void SetTeardropMaxSize(int aMaxLen, int aMaxHeight)
Set max allowed length and height for teardrops in IU.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool operator==(const TEARDROP_PARAMETERS &aOther) const
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
bool operator!=(const TEARDROP_PARAMETERS &aOther) const
void SetTeardropCurvedPrm(int aCurveSegCount=0)
Set the teardrop curved or straight.
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
bool m_TdOnPadsInZones
A filter to exclude pads inside zone fills.
bool m_Enabled
Flag to enable teardrops.
void SetTeardropSizeRatio(double aLenghtRatio=0.5, double aHeightRatio=1.0)
Set prefered length and height ratio for teardrops the prefered length and height are VIAPAD width * ...
std::string GetTeardropTargetCanonicalName(TARGET_TD aTdType)
TARGET_TD GetTeardropTargetTypeFromCanonicalName(const std::string &aTargetName)
@ TARGET_UNKNOWN
@ TARGET_COUNT
@ TARGET_ROUND
@ TARGET_RECT
@ TARGET_TRACK