KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fab_component_row.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_component_row.h"
21
22#include "fab_pin.h"
23#include <algorithm>
24#include <footprint.h>
25#include <pad.h>
26#include <pcb_field.h>
27
28
29wxString FAB_COMPONENT_ROW::Field( const wxString& aName ) const
30{
31 const PCB_FIELD* field = m_footprint->GetField( aName );
32 return field ? field->GetShownText( m_variant, RESOLVED ) : wxString();
33}
34
35
37{
38 const PCB_FIELD* field = m_footprint->GetField( FIELD_T::VALUE );
39 return field ? field->GetShownText( m_variant, RESOLVED ) : m_footprint->GetValue();
40}
41
42
43FAB_COMPONENT_ROW MakeFabComponentRow( const FOOTPRINT& aFootprint, const wxString& aVariant )
44{
45 bool pressFit = std::any_of( aFootprint.Pads().begin(), aFootprint.Pads().end(),
46 []( const PAD* aPad )
47 {
48 return GetFabPadRole( *aPad ) == FAB_PAD_ROLE::PRESSFIT;
49 } );
51
52 if( aFootprint.GetAttributes() & FP_SMD )
53 mount = FAB_MOUNT::SMT;
54 else if( aFootprint.GetAttributes() & FP_THROUGH_HOLE )
55 mount = FAB_MOUNT::THT;
56
57 return { &aFootprint,
58 aVariant,
59 aFootprint.GetDNPForVariant( aVariant ),
60 aFootprint.GetExcludedFromBOMForVariant( aVariant ),
61 pressFit,
62 mount };
63}
std::deque< PAD * > & Pads()
Definition footprint.h:405
int GetAttributes() const
Definition footprint.h:551
bool GetDNPForVariant(const wxString &aVariantName) const
Get the DNP status for a specific variant.
bool GetExcludedFromBOMForVariant(const wxString &aVariantName) const
Get the exclude-from-BOM status for a specific variant.
Definition pad.h:61
wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Return the string actually shown after processing of the base text.
@ RESOLVED
Definition common.h:95
FAB_COMPONENT_ROW MakeFabComponentRow(const FOOTPRINT &aFootprint, const wxString &aVariant)
FAB_MOUNT
Definition fab_pin.h:42
@ FP_SMD
Definition footprint.h:87
@ FP_THROUGH_HOLE
Definition footprint.h:86
Footprint facts resolved for one assembly variant.
wxString Value() const
wxString Field(const wxString &aName) const
Variant-resolved shown text, empty when the field is missing.
const FOOTPRINT * m_footprint
@ VALUE
Field Value of part, i.e. "3.3K".