KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_stackup.h
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 (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
24
25#ifndef BOARD_STACKUP_H
26#define BOARD_STACKUP_H
27
28
29#include <vector>
30#include <wx/string.h>
31#include <layer_ids.h>
32#include <lset.h>
33#include <api/serializable.h>
35
36class BOARD;
38class OUTPUTFORMATTER;
39
40namespace kiapi::board
41{
42 class BoardStackup;
43}
44
45// A enum to manage the different layers inside the stackup layers.
46// Note the stackup layers include both dielectric and some layers handled by the board editor
47// Therefore a stackup layer item is not exactly like a board layer
49{
50 BS_ITEM_TYPE_UNDEFINED, // For not yet initialized BOARD_STACKUP_ITEM item
51 BS_ITEM_TYPE_COPPER, // A initialized BOARD_STACKUP_ITEM item for copper layers
52 BS_ITEM_TYPE_DIELECTRIC, // A initialized BOARD_STACKUP_ITEM item for the
53 // dielectric between copper layers
54 BS_ITEM_TYPE_SOLDERPASTE, // A initialized BOARD_STACKUP_ITEM item for solder paste layers
55 BS_ITEM_TYPE_SOLDERMASK, // A initialized BOARD_STACKUP_ITEM item for solder mask layers
56 // note: this is a specialized dielectric material
57 BS_ITEM_TYPE_SILKSCREEN, // A initialized BOARD_STACKUP_ITEM item for silkscreen layers
58};
59
60// A enum to manage edge connector fab info
62{
63 BS_EDGE_CONNECTOR_NONE, // No edge connector in board
64 BS_EDGE_CONNECTOR_IN_USE, // some edge connector in board
65 BS_EDGE_CONNECTOR_BEVELLED // Some connector in board, and the connector must be beveled
66};
67
68
73{
74public:
76 m_Thickness( 0 ),
77 m_ThicknessLocked( false ),
78 m_EpsilonR( 1.0 ),
79 m_LossTangent( 0.0 ),
80 m_SpecFreq( 0.0 ),
82 {}
83
84 bool operator==( const DIELECTRIC_PRMS& aOther ) const;
85 bool operator!=( const DIELECTRIC_PRMS& aOther ) const { return !operator==( aOther ); }
86
87private:
88 friend class BOARD_STACKUP_ITEM;
89
90 wxString m_Material;
94 double m_EpsilonR;
96 double m_SpecFreq;
98 wxString m_Color;
99};
100
101
108{
109public:
111 BOARD_STACKUP_ITEM( const BOARD_STACKUP_ITEM& aOther );
112
113 bool operator==( const BOARD_STACKUP_ITEM& aOther ) const;
114 bool operator!=( const BOARD_STACKUP_ITEM& aOther ) const { return !operator==( aOther ); }
115
122 void AddDielectricPrms( int aDielectricPrmsIdx );
123
129 void RemoveDielectricPrms( int aDielectricPrmsIdx );
130
133 bool HasEpsilonRValue() const;
134
137 bool HasLossTangentValue() const;
138
141 bool HasSpecFreqValue() const;
142
144 bool HasMaterialValue( int aDielectricSubLayer = 0 ) const;
145
147 bool IsMaterialEditable() const;
148
150 bool IsColorEditable() const;
151
153 bool IsThicknessEditable() const;
154
156 static int GetCopperDefaultThickness();
157
159 static int GetMaskDefaultThickness();
160
163 int GetSublayersCount() const { return m_DielectricPrmsList.size(); }
164
166 wxString FormatEpsilonR( int aDielectricSubLayer = 0 ) const;
167
169 wxString FormatLossTangent( int aDielectricSubLayer = 0 ) const;
170
172 wxString FormatDielectricLayerName() const;
173
174 // Getters:
175 bool IsEnabled() const { return m_enabled; }
176
179 wxString GetLayerName() const { return m_LayerName; }
180 wxString GetTypeName() const { return m_TypeName; }
182
183 wxString GetColor( int aDielectricSubLayer = 0 ) const;
184 int GetThickness( int aDielectricSubLayer = 0 ) const;
185 bool IsThicknessLocked( int aDielectricSubLayer = 0 ) const;
186 double GetEpsilonR( int aDielectricSubLayer = 0 ) const;
187 double GetLossTangent( int aDielectricSubLayer = 0 ) const;
188 double GetSpecFreq( int aDielectricSubLayer = 0 ) const;
189 DIELECTRIC_MODEL GetDielectricModel( int aDielectricSubLayer = 0 ) const;
190 wxString GetMaterial( int aDielectricSubLayer = 0 ) const;
191
192 // Setters:
193 void SetEnabled( bool aEnable) { m_enabled = aEnable; }
194 void SetBrdLayerId( PCB_LAYER_ID aBrdLayerId ) { m_LayerId = aBrdLayerId; }
195 void SetLayerName( const wxString& aName ) { m_LayerName = aName; }
196 void SetTypeName( const wxString& aName ) { m_TypeName = aName; }
197 void SetDielectricLayerId( int aLayerId ) { m_DielectricLayerId = aLayerId; }
198
199 void SetColor( const wxString& aColorName, int aDielectricSubLayer = 0 );
200 void SetThickness( int aThickness, int aDielectricSubLayer = 0 );
201 void SetThicknessLocked( bool aLocked, int aDielectricSubLayer = 0 );
202 void SetEpsilonR( double aEpsilon, int aDielectricSubLayer = 0 );
203 void SetLossTangent( double aTg, int aDielectricSubLayer = 0 );
204 void SetSpecFreq( double aSpecFreq, int aDielectricSubLayer = 0 );
205 void SetDielectricModel( DIELECTRIC_MODEL aModel, int aDielectricSubLayer = 0 );
206 void SetMaterial( const wxString& aName, int aDielectricSubLayer = 0 );
207
208private:
210 wxString m_LayerName;
211 wxString m_TypeName;
222 std::vector<DIELECTRIC_PRMS> m_DielectricPrmsList;
223
226};
227
228
239{
240public:
242 BOARD_STACKUP( const BOARD_STACKUP& aOther );
243 BOARD_STACKUP& operator=( const BOARD_STACKUP& aOther );
244
245 bool operator==( const BOARD_STACKUP& aOther ) const;
246 bool operator!=( const BOARD_STACKUP& aOther ) const { return !operator==( aOther ); }
247
249
250 void Serialize( google::protobuf::Any &aContainer ) const override;
251
252 bool Deserialize( const google::protobuf::Any &aContainer ) override;
253
254 void Serialize( kiapi::board::BoardStackup& aOutput ) const;
255 bool Deserialize( const kiapi::board::BoardStackup& aInput );
256
257 const std::vector<BOARD_STACKUP_ITEM*>& GetList() const { return m_list; }
258
260 BOARD_STACKUP_ITEM* GetStackupLayer( int aIndex );
261
271
272
274 void RemoveAll();
275
277 int GetCount() const { return (int) m_list.size(); }
278
281
283 void Add( BOARD_STACKUP_ITEM* aItem ) { m_list.push_back( aItem ); }
284
293
302 void BuildDefaultStackupList( const BOARD_DESIGN_SETTINGS* aSettings,
303 int aActiveCopperLayersCount = 0 );
304
310 void FormatBoardStackup( OUTPUTFORMATTER* aFormatter, const BOARD* aBoard ) const;
311
326 int GetLayerDistance( PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer ) const;
327
331 wxString m_FinishType;
332
341
346
355
357
358private:
359 // The list of items describing the stackup for fabrication.
360 // this is not just copper layers, but also mask dielectric layers
361 std::vector<BOARD_STACKUP_ITEM*> m_list;
362};
363
364
365#endif // BOARD_STACKUP_H
BS_EDGE_CONNECTOR_CONSTRAINTS
@ BS_EDGE_CONNECTOR_BEVELLED
@ BS_EDGE_CONNECTOR_NONE
@ BS_EDGE_CONNECTOR_IN_USE
BOARD_STACKUP_ITEM_TYPE
@ BS_ITEM_TYPE_UNDEFINED
@ BS_ITEM_TYPE_COPPER
@ BS_ITEM_TYPE_SILKSCREEN
@ BS_ITEM_TYPE_DIELECTRIC
@ BS_ITEM_TYPE_SOLDERPASTE
@ BS_ITEM_TYPE_SOLDERMASK
Container for design settings for a BOARD object.
Manage one layer needed to make a physical board.
void AddDielectricPrms(int aDielectricPrmsIdx)
Add (insert) a DIELECTRIC_PRMS item to m_DielectricPrmsList all values are set to default.
wxString GetTypeName() const
DIELECTRIC_MODEL GetDielectricModel(int aDielectricSubLayer=0) const
bool operator!=(const BOARD_STACKUP_ITEM &aOther) const
PCB_LAYER_ID m_LayerId
type name of layer (copper, silk screen, core, prepreg ...)
int GetSublayersCount() const
void SetDielectricLayerId(int aLayerId)
bool HasSpecFreqValue() const
double GetEpsilonR(int aDielectricSubLayer=0) const
wxString GetColor(int aDielectricSubLayer=0) const
bool HasEpsilonRValue() const
void SetThickness(int aThickness, int aDielectricSubLayer=0)
bool IsMaterialEditable() const
BOARD_STACKUP_ITEM_TYPE m_Type
void SetDielectricModel(DIELECTRIC_MODEL aModel, int aDielectricSubLayer=0)
bool HasMaterialValue(int aDielectricSubLayer=0) const
void SetThicknessLocked(bool aLocked, int aDielectricSubLayer=0)
wxString FormatDielectricLayerName() const
wxString GetLayerName() const
void SetSpecFreq(double aSpecFreq, int aDielectricSubLayer=0)
void SetMaterial(const wxString &aName, int aDielectricSubLayer=0)
BOARD_STACKUP_ITEM(BOARD_STACKUP_ITEM_TYPE aType)
bool HasLossTangentValue() const
PCB_LAYER_ID GetBrdLayerId() const
bool IsThicknessEditable() const
void SetLossTangent(double aTg, int aDielectricSubLayer=0)
int GetThickness(int aDielectricSubLayer=0) const
void SetEnabled(bool aEnable)
std::vector< DIELECTRIC_PRMS > m_DielectricPrmsList
the "layer" id for dielectric layers, from 1 (top) to 31 (bottom) (only 31 dielectric layers for 32 c...
static int GetMaskDefaultThickness()
bool IsEnabled() const
BOARD_STACKUP_ITEM_TYPE GetType() const
wxString GetMaterial(int aDielectricSubLayer=0) const
wxString m_TypeName
name of layer as shown in layer manager. Useful to create reports
void SetBrdLayerId(PCB_LAYER_ID aBrdLayerId)
void SetTypeName(const wxString &aName)
bool IsThicknessLocked(int aDielectricSubLayer=0) const
wxString FormatEpsilonR(int aDielectricSubLayer=0) const
int m_DielectricLayerId
the layer id (F.Cu to B.Cu, F.Silk, B.silk, F.Mask, B.Mask) and UNDEFINED_LAYER (-1) for dielectric l...
void SetColor(const wxString &aColorName, int aDielectricSubLayer=0)
void SetEpsilonR(double aEpsilon, int aDielectricSubLayer=0)
void SetLayerName(const wxString &aName)
double GetSpecFreq(int aDielectricSubLayer=0) const
void RemoveDielectricPrms(int aDielectricPrmsIdx)
Remove a DIELECTRIC_PRMS item from m_DielectricPrmsList.
int GetDielectricLayerId() const
bool operator==(const BOARD_STACKUP_ITEM &aOther) const
bool IsColorEditable() const
wxString FormatLossTangent(int aDielectricSubLayer=0) const
double GetLossTangent(int aDielectricSubLayer=0) const
static int GetCopperDefaultThickness()
void RemoveAll()
Delete all items in list and clear the list.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
static LSET StackupAllowedBrdLayers()
int GetCount() const
bool SynchronizeWithBoard(BOARD_DESIGN_SETTINGS *aSettings)
Synchronize the BOARD_STACKUP_ITEM* list with the board.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
bool operator==(const BOARD_STACKUP &aOther) const
int BuildBoardThicknessFromStackup() const
bool m_HasDielectricConstrains
True if some layers have impedance controlled tracks or have specific constrains for micro-wave appli...
void Add(BOARD_STACKUP_ITEM *aItem)
Add a new item in stackup layer.
void BuildDefaultStackupList(const BOARD_DESIGN_SETTINGS *aSettings, int aActiveCopperLayersCount=0)
Create a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
BOARD_STACKUP & operator=(const BOARD_STACKUP &aOther)
BOARD_STACKUP_ITEM * GetStackupLayer(int aIndex)
int GetLayerDistance(PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const
Calculate the distance (height) between the two given copper layers.
std::vector< BOARD_STACKUP_ITEM * > m_list
bool m_EdgePlating
True if the edge board is plated.
BS_EDGE_CONNECTOR_CONSTRAINTS m_EdgeConnectorConstraints
If the board has edge connector cards, some constrains can be specified in job file: BS_EDGE_CONNECTO...
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, const BOARD *aBoard) const
Write the stackup info on board file.
bool m_HasThicknessConstrains
True if some layers (copper and/or dielectric) have specific thickness.
bool operator!=(const BOARD_STACKUP &aOther) const
wxString m_FinishType
The name of external copper finish.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
A helper class to manage a dielectric layer set of parameters.
double m_EpsilonR
true for dielectric layers with a fixed thickness (for impedance controlled purposes),...
double m_SpecFreq
For dielectric (and solder mask) the dielectric loss.
int m_Thickness
type of material (for dielectric and solder mask)
wxString m_Material
bool operator==(const DIELECTRIC_PRMS &aOther) const
wxString m_Color
For dielectric the dielectric frequency correction model.
DIELECTRIC_MODEL m_DielectricModel
For dielectric the frequency (Hz) at which E_R is specified.
bool operator!=(const DIELECTRIC_PRMS &aOther) const
bool m_ThicknessLocked
the physical layer thickness in internal units
double m_LossTangent
For dielectric (and solder mask) the dielectric constant.
friend class BOARD_STACKUP_ITEM
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition lset.cpp:630
static const LSET & InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
Definition lset.cpp:573
An interface used to output 8 bit text in a convenient way.
Definition richio.h:294
Interface for objects that can be serialized to Protobuf messages.
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_Paste
Definition layer_ids.h:100
@ B_Mask
Definition layer_ids.h:94
@ F_Mask
Definition layer_ids.h:93
@ B_Paste
Definition layer_ids.h:101
@ F_SilkS
Definition layer_ids.h:96
@ B_SilkS
Definition layer_ids.h:97
DIELECTRIC_MODEL
Frequency-domain model used for the substrate dielectric properties.