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, see <https://www.gnu.org/licenses/>.
18 */
19
22
23#include <board.h>
24#include <pad.h>
25#include <pcb_track.h>
26
27
29{
30 // Only consider trace connections when determining via electrical span. Pads are excluded
31 // because they have their own pad-to-die length handling, and including them would cause
32 // through-hole vias to incorrectly span to layers where TH pads exist (e.g., connector pins)
33 // rather than just the layers where traces actually connect.
34 static std::initializer_list<KICAD_T> traceTypes = { PCB_TRACE_T, PCB_ARC_T };
35
36 PCB_LAYER_ID top_layer = UNDEFINED_LAYER;
37 PCB_LAYER_ID bottom_layer = UNDEFINED_LAYER;
38
39 const LSET layers = aBoard->GetDesignSettings().GetEnabledLayers();
40
41 for( auto layer_it = layers.copper_layers_begin(); layer_it != layers.copper_layers_end(); ++layer_it )
42 {
43 if( aBoard->GetConnectivity()->IsConnectedOnLayer( m_via, *layer_it, traceTypes ) )
44 {
45 if( top_layer == UNDEFINED_LAYER )
46 top_layer = *layer_it;
47 else
48 bottom_layer = *layer_it;
49 }
50 }
51
52 if( top_layer == UNDEFINED_LAYER )
53 top_layer = m_via->TopLayer();
54 if( bottom_layer == UNDEFINED_LAYER )
55 bottom_layer = m_via->BottomLayer();
56
57 SetLayers( top_layer, bottom_layer );
58}
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:372
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1149
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:634
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:919
copper_layers_iterator copper_layers_begin() const
Definition lset.cpp:913
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:91
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:89