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_Enabled( false ),
52 m_AllowUseTwoTracks( true ),
53 m_TdMaxLen( pcbIUScale.mmToIU( 1.0 ) ),
54 m_TdMaxWidth( pcbIUScale.mmToIU( 2.0 ) ),
56 m_BestWidthRatio( 1.0 ),
57 m_CurveSegCount( 0 ),
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
88 void SetTeardropCurvedPrm( int aCurveSegCount = 0 )
89 {
90 m_CurveSegCount = aCurveSegCount;
91 }
92
93 bool IsCurved() const { return m_CurveSegCount > 2; }
94
95 bool operator== ( const TEARDROP_PARAMETERS& aOther ) const
96 {
97 return m_Enabled == aOther.m_Enabled &&
99 m_TdMaxLen == aOther.m_TdMaxLen &&
100 m_TdMaxWidth == aOther.m_TdMaxWidth &&
106 }
107
108 bool operator!= ( const TEARDROP_PARAMETERS& aOther ) const
109 {
110 return !( *this == aOther );
111 }
112
113public:
133};
134
135
136
142{
143 std::vector<TEARDROP_PARAMETERS> m_params_list;
144
145public:
155
156public:
158 m_TargetViasPads( true ),
160 m_TargetTrack2Track( false ),
161 m_UseRoundShapesOnly( false )
162 {
163 m_params_list.emplace_back(); // parameters for TARGET_ROUND
164 m_params_list.emplace_back(); // parameters for TARGET_RECT
165 m_params_list.emplace_back(); // parameters for TARGET_TRACK
166 }
167
172 {
173 return &m_params_list.at( aTdType );
174 }
175
180 {
181 return m_params_list.size();
182 }
183};
184
185
190std::string GetTeardropTargetCanonicalName( TARGET_TD aTdType );
191
196TARGET_TD GetTeardropTargetTypeFromCanonicalName( const std::string& aTargetName );
197
198#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 ...
bool m_TargetPadsWithNoHole
True to create teardrops for pads without holes (SMD and others.
bool m_TargetViasPads
True to create teardrops for vias and pads with holes.
std::vector< TEARDROP_PARAMETERS > m_params_list
bool m_UseRoundShapesOnly
True to create teardrops for round shapes only.
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)
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
number of segments to build the curved sides of a teardrop area must be > 2.
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 params for teardrop using curved shape note: if aCurveSegCount is < 3, the shape uses a strai...
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.
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