KiCad PCB EDA Suite
Loading...
Searching...
No Matches
length_delay_calculation_item.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
26
27#include <board.h>
28
29
31{
32 // Only consider trace connections when determining via electrical span. Pads are excluded
33 // because they have their own pad-to-die length handling, and including them would cause
34 // through-hole vias to incorrectly span to layers where TH pads exist (e.g., connector pins)
35 // rather than just the layers where traces actually connect.
36 static std::initializer_list<KICAD_T> traceTypes = { PCB_TRACE_T, PCB_ARC_T };
37
38 PCB_LAYER_ID top_layer = UNDEFINED_LAYER;
39 PCB_LAYER_ID bottom_layer = UNDEFINED_LAYER;
40
41 const LSET layers = aBoard->GetDesignSettings().GetEnabledLayers();
42
43 for( auto layer_it = layers.copper_layers_begin(); layer_it != layers.copper_layers_end(); ++layer_it )
44 {
45 if( aBoard->GetConnectivity()->IsConnectedOnLayer( m_via, *layer_it, traceTypes ) )
46 {
47 if( top_layer == UNDEFINED_LAYER )
48 top_layer = *layer_it;
49 else
50 bottom_layer = *layer_it;
51 }
52 }
53
54 if( top_layer == UNDEFINED_LAYER )
55 top_layer = m_via->TopLayer();
56 if( bottom_layer == UNDEFINED_LAYER )
57 bottom_layer = m_via->BottomLayer();
58
59 SetLayers( top_layer, bottom_layer );
60}
const LSET & GetEnabledLayers() const
Return a bit-mask of all the layers that are enabled.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1084
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:563
bool IsConnectedOnLayer(const BOARD_CONNECTED_ITEM *aItem, int aLayer, const std::initializer_list< KICAD_T > &aTypes={}) const
const PCB_VIA * m_via
A proxied PCB_VIA object. Set to nullptr if not proxying a VIA.
void CalculateViaLayers(const BOARD *aBoard)
Calculates active via payers for a proxied VIA object.
void SetLayers(const PCB_LAYER_ID aStart, const PCB_LAYER_ID aEnd=PCB_LAYER_ID::UNDEFINED_LAYER)
Sets the first and last layers associated with this item.
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
copper_layers_iterator copper_layers_end() const
Definition lset.cpp:924
copper_layers_iterator copper_layers_begin() const
Definition lset.cpp:918
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ UNDEFINED_LAYER
Definition layer_ids.h:61
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:98
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:96