KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pad_flashing.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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25
26#include <board.h>
27#include <footprint.h>
28#include <pad.h>
29#include <memory>
30
31BOOST_AUTO_TEST_SUITE( PadFlashing )
32
33BOOST_AUTO_TEST_CASE( PadsInSameFootprintDoNotForceInnerLayerFlashing )
34{
35 BOARD board;
37
38 auto footprint = std::make_unique<FOOTPRINT>( &board );
39
40 auto net = new NETINFO_ITEM( &board, "P1", 1 );
41 board.Add( net );
42
43 auto pad1 = new PAD( footprint.get() );
44 auto pad2 = new PAD( footprint.get() );
45
46 const int diameter = pcbIUScale.mmToIU( 1.0 );
47 const int drill = pcbIUScale.mmToIU( 0.5 );
48
49 pad1->SetAttribute( PAD_ATTRIB::PTH );
50 pad2->SetAttribute( PAD_ATTRIB::PTH );
51 pad1->SetLayerSet( LSET::AllCuMask() );
52 pad2->SetLayerSet( LSET::AllCuMask() );
53 pad1->SetSize( PADSTACK::ALL_LAYERS, VECTOR2I( diameter, diameter ) );
54 pad2->SetSize( PADSTACK::ALL_LAYERS, VECTOR2I( diameter, diameter ) );
55 pad1->SetDrillSize( VECTOR2I( drill, drill ) );
56 pad2->SetDrillSize( VECTOR2I( drill, drill ) );
57 pad1->SetPosition( VECTOR2I( 0, 0 ) );
58 pad2->SetPosition( VECTOR2I( 0, 0 ) );
61 pad1->SetNet( net );
62 pad2->SetNet( net );
63
64 footprint->Add( pad1 );
65 footprint->Add( pad2 );
66 board.Add( footprint.release() );
67
68 board.BuildConnectivity();
69
70 BOOST_CHECK( pad1->FlashLayer( F_Cu ) );
71 BOOST_CHECK( pad2->FlashLayer( B_Cu ) );
72 BOOST_CHECK( !pad1->FlashLayer( In1_Cu ) );
73 BOOST_CHECK( !pad2->FlashLayer( In1_Cu ) );
74}
75
76BOOST_AUTO_TEST_CASE( PadsInDifferentFootprintsDoNotForceInnerLayerFlashing )
77{
78 BOARD board;
80
81 auto footprint1 = std::make_unique<FOOTPRINT>( &board );
82 auto footprint2 = std::make_unique<FOOTPRINT>( &board );
83
84 auto net = new NETINFO_ITEM( &board, "P1", 1 );
85 board.Add( net );
86
87 auto pad1 = new PAD( footprint1.get() );
88 auto pad2 = new PAD( footprint2.get() );
89
90 const int diameter = pcbIUScale.mmToIU( 1.0 );
91 const int drill = pcbIUScale.mmToIU( 0.5 );
92
93 pad1->SetAttribute( PAD_ATTRIB::PTH );
94 pad2->SetAttribute( PAD_ATTRIB::PTH );
95 pad1->SetLayerSet( LSET::AllCuMask() );
96 pad2->SetLayerSet( LSET::AllCuMask() );
97 pad1->SetSize( PADSTACK::ALL_LAYERS, VECTOR2I( diameter, diameter ) );
98 pad2->SetSize( PADSTACK::ALL_LAYERS, VECTOR2I( diameter, diameter ) );
99 pad1->SetDrillSize( VECTOR2I( drill, drill ) );
100 pad2->SetDrillSize( VECTOR2I( drill, drill ) );
101 pad1->SetPosition( VECTOR2I( 0, 0 ) );
102 pad2->SetPosition( VECTOR2I( 0, 0 ) );
105 pad1->SetNet( net );
106 pad2->SetNet( net );
107
108 footprint1->Add( pad1 );
109 footprint2->Add( pad2 );
110 board.Add( footprint1.release() );
111 board.Add( footprint2.release() );
112
113 board.BuildConnectivity();
114
115 BOOST_CHECK( pad1->FlashLayer( F_Cu ) );
116 BOOST_CHECK( pad2->FlashLayer( B_Cu ) );
117 BOOST_CHECK( !pad1->FlashLayer( In1_Cu ) );
118 BOOST_CHECK( !pad2->FlashLayer( In1_Cu ) );
119}
120
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
@ FPHOLDER
Definition board.h:309
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:317
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1163
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition board.h:329
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition board.cpp:188
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:582
Handle the data for a net.
Definition netinfo.h:54
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:145
@ B_Cu
Definition layer_ids.h:65
@ In1_Cu
Definition layer_ids.h:66
@ F_Cu
Definition layer_ids.h:64
@ PTH
Plated through hole pad.
Definition padstack.h:82
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(PadsInSameFootprintDoNotForceInnerLayerFlashing)
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695