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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef TEARDROP_PARAMS_H
22#define TEARDROP_PARAMS_H
23
24#include <string>
25#include <vector>
26#include <base_units.h>
27
28// IDs for targets when creating teardrops
37
44{
45public:
47 m_TdMaxLen( pcbIUScale.mmToIU( 1.0 ) ),
48 m_TdMaxWidth( pcbIUScale.mmToIU( 2.0 ) ),
50 m_BestWidthRatio( 1.0 ),
52 m_CurvedEdges( false ),
53 m_Enabled( false ),
54 m_AllowUseTwoTracks( true ),
55 m_TdOnPadsInZones( false )
56 {
57 }
58
63 void SetTeardropMaxSize( int aMaxLen, int aMaxHeight )
64 {
65 m_TdMaxLen = aMaxLen;
66 m_TdMaxWidth = aMaxHeight;
67 }
68
74 void SetTeardropSizeRatio( double aLenghtRatio = 0.5, double aHeightRatio = 1.0 )
75 {
76 m_BestLengthRatio = aLenghtRatio;
77 m_BestWidthRatio = aHeightRatio;
78 }
79
80 bool operator== ( const TEARDROP_PARAMETERS& aOther ) const
81 {
82 return m_Enabled == aOther.m_Enabled &&
84 m_TdMaxLen == aOther.m_TdMaxLen &&
85 m_TdMaxWidth == aOther.m_TdMaxWidth &&
88 m_CurvedEdges == aOther.m_CurvedEdges &&
91 }
92
93 bool operator!= ( const TEARDROP_PARAMETERS& aOther ) const
94 {
95 return !( *this == aOther );
96 }
97
98public:
112
119};
120
121
122
128{
129 std::vector<TEARDROP_PARAMETERS> m_params_list;
130
131public:
143
144public:
146 m_TargetVias( true ),
147 m_TargetPTHPads( true ),
148 m_TargetSMDPads( true ),
149 m_TargetTrack2Track( false ),
150 m_UseRoundShapesOnly( false )
151 {
152 m_params_list.emplace_back(); // parameters for TARGET_ROUND
153 m_params_list.emplace_back(); // parameters for TARGET_RECT
154 m_params_list.emplace_back(); // parameters for TARGET_TRACK
155 }
156
161 {
162 return &m_params_list.at( aTdType );
163 }
164
169 {
170 return m_params_list.size();
171 }
172};
173
174
179std::string GetTeardropTargetCanonicalName( TARGET_TD aTdType );
180
185TARGET_TD GetTeardropTargetTypeFromCanonicalName( const std::string& aTargetName );
186
187#endif // ifndef TEARDROP_PARAMS_H
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
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...
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
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.
bool m_CurvedEdges
True if the teardrop should be curved.
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