KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fab_pin.cpp
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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include "fab_pin.h"
21
22#include <footprint.h>
23#include <pad.h>
24
25
48
49
50FAB_PIN MakeFabPin( const PAD& aPad, size_t aIndexInFootprint )
51{
53 pin.m_name = aPad.GetNumber();
54 pin.m_role = GetFabPadRole( aPad );
55
56 // Pins need names, so NPTH and unnumbered pads use their footprint ordinal
57 if( aPad.GetAttribute() == PAD_ATTRIB::NPTH || pin.m_name.IsEmpty() )
58 {
59 const FOOTPRINT* footprint = aPad.GetParentFootprint();
60 wxASSERT( footprint && aIndexInFootprint < footprint->Pads().size()
61 && footprint->Pads()[aIndexInFootprint] == &aPad );
62
63 if( aPad.GetAttribute() == PAD_ATTRIB::NPTH )
64 {
65 pin.m_name = wxString::Format( "NPTH%zu", aIndexInFootprint );
66 }
67 else
68 {
69 pin.m_name = wxString::Format( "PAD%zu", aIndexInFootprint );
70 }
71 }
72
73 if( aPad.GetAttribute() == PAD_ATTRIB::NPTH )
74 {
75 pin.m_electrical = FAB_ELECTRICAL::MECHANICAL;
76 }
77 else if( aPad.IsOnCopperLayer() )
78 {
79 pin.m_electrical = FAB_ELECTRICAL::ELECTRICAL;
80 }
81
82 if( ( aPad.HasHole() && aPad.IsOnCopperLayer() ) || aPad.GetAttribute() == PAD_ATTRIB::PTH )
83 {
84 pin.m_mount = FAB_MOUNT::THT;
85 }
86 else if( aPad.HasHole() && aPad.GetAttribute() == PAD_ATTRIB::NPTH )
87 {
88 pin.m_mount = FAB_MOUNT::HOLE;
89 }
90 else if( aPad.GetAttribute() == PAD_ATTRIB::SMD )
91 {
92 pin.m_mount = FAB_MOUNT::SMT;
93 }
94
95 return pin;
96}
FOOTPRINT * GetParentFootprint() const
std::deque< PAD * > & Pads()
Definition footprint.h:405
Definition pad.h:61
PAD_PROP GetProperty() const
Definition pad.h:563
PAD_ATTRIB GetAttribute() const
Definition pad.h:560
const wxString & GetNumber() const
Definition pad.h:143
bool IsOnCopperLayer() const override
Definition pad.cpp:1900
bool HasHole() const override
Definition pad.h:113
FAB_PAD_ROLE GetFabPadRole(const PAD &aPad)
Explicit fabrication properties take precedence over the unnumbered NPTH fallback.
Definition fab_pin.cpp:26
FAB_PIN MakeFabPin(const PAD &aPad, size_t aIndexInFootprint)
aIndexInFootprint is the pad's position in its footprint, used to name NPTH and unnumbered pads
Definition fab_pin.cpp:50
FAB_PAD_ROLE
Definition fab_pin.h:28
@ FIDUCIAL_LOCAL
Definition fab_pin.h:32
@ FIDUCIAL_GLOBAL
Definition fab_pin.h:31
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:102
@ SMD
Smd pad, appears on the solder paste layer (default)
Definition padstack.h:98
@ PTH
Plated through hole pad.
Definition padstack.h:97
@ FIDUCIAL_LOCAL
a fiducial (usually a smd) local to the parent footprint
Definition padstack.h:117
@ FIDUCIAL_GLBL
a fiducial (usually a smd) for the full board
Definition padstack.h:116
@ MECHANICAL
a pad used for mechanical support
Definition padstack.h:121
@ PRESSFIT
a PTH with a hole diameter with tight tolerances for press fit pin
Definition padstack.h:122
@ HEATSINK
a pad used as heat sink, usually in SMD footprints
Definition padstack.h:119
@ NONE
no special fabrication property
Definition padstack.h:114
@ TESTPOINT
a test point pad
Definition padstack.h:118
@ CASTELLATED
a pad with a castellated through hole
Definition padstack.h:120
@ BGA
Smd pad, used in BGA footprints.
Definition padstack.h:115
KIBIS_PIN * pin