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 (C) 2009-2021 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 along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
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>
34
35class BOARD;
37class OUTPUTFORMATTER;
38
39// A enum to manage the different layers inside the stackup layers.
40// Note the stackup layers include both dielectric and some layers handled by the board editor
41// Therefore a stackup layer item is not exactly like a board layer
43{
44 BS_ITEM_TYPE_UNDEFINED, // For not yet initialized BOARD_STACKUP_ITEM item
45 BS_ITEM_TYPE_COPPER, // A initialized BOARD_STACKUP_ITEM item for copper layers
46 BS_ITEM_TYPE_DIELECTRIC, // A initialized BOARD_STACKUP_ITEM item for the
47 // dielectric between copper layers
48 BS_ITEM_TYPE_SOLDERPASTE, // A initialized BOARD_STACKUP_ITEM item for solder paste layers
49 BS_ITEM_TYPE_SOLDERMASK, // A initialized BOARD_STACKUP_ITEM item for solder mask layers
50 // note: this is a specialized dielectric material
51 BS_ITEM_TYPE_SILKSCREEN, // A initialized BOARD_STACKUP_ITEM item for silkscreen layers
52};
53
54// A enum to manage edge connector fab info
56{
57 BS_EDGE_CONNECTOR_NONE, // No edge connector in board
58 BS_EDGE_CONNECTOR_IN_USE, // some edge connector in board
59 BS_EDGE_CONNECTOR_BEVELLED // Some connector in board, and the connector must be beveled
60};
61
62
67{
68public:
70 m_Thickness(0), m_ThicknessLocked( false ),
71 m_EpsilonR( 1.0 ), m_LossTangent( 0.0 )
72 {}
73
74 bool operator==( const DIELECTRIC_PRMS& aOther ) const;
75 bool operator!=( const DIELECTRIC_PRMS& aOther ) const { return !operator==( aOther ); }
76
77private:
78 friend class BOARD_STACKUP_ITEM;
79
80 wxString m_Material;
84 double m_EpsilonR;
86 wxString m_Color;
87};
88
89
96{
97public:
100
101 bool operator==( const BOARD_STACKUP_ITEM& aOther ) const;
102 bool operator!=( const BOARD_STACKUP_ITEM& aOther ) const { return !operator==( aOther ); }
103
110 void AddDielectricPrms( int aDielectricPrmsIdx );
111
117 void RemoveDielectricPrms( int aDielectricPrmsIdx );
118
121 bool HasEpsilonRValue() const;
122
125 bool HasLossTangentValue() const;
126
128 bool HasMaterialValue( int aDielectricSubLayer = 0 ) const;
129
131 bool IsMaterialEditable() const;
132
134 bool IsColorEditable() const;
135
137 bool IsThicknessEditable() const;
138
140 static int GetCopperDefaultThickness();
141
143 static int GetMaskDefaultThickness();
144
147 int GetSublayersCount() const { return m_DielectricPrmsList.size(); }
148
150 wxString FormatEpsilonR( int aDielectricSubLayer = 0 ) const;
151
153 wxString FormatLossTangent( int aDielectricSubLayer = 0 ) const;
154
156 wxString FormatDielectricLayerName() const;
157
158 // Getters:
159 bool IsEnabled() const { return m_enabled; }
160
163 wxString GetLayerName() const { return m_LayerName; }
164 wxString GetTypeName() const { return m_TypeName; }
166
167 wxString GetColor( int aDielectricSubLayer = 0 ) const;
168 int GetThickness( int aDielectricSubLayer = 0 ) const;
169 bool IsThicknessLocked( int aDielectricSubLayer = 0 ) const;
170 double GetEpsilonR( int aDielectricSubLayer = 0 ) const;
171 double GetLossTangent( int aDielectricSubLayer = 0 ) const;
172 wxString GetMaterial( int aDielectricSubLayer = 0 ) const;
173
174 // Setters:
175 void SetEnabled( bool aEnable) { m_enabled = aEnable; }
176 void SetBrdLayerId( PCB_LAYER_ID aBrdLayerId ) { m_LayerId = aBrdLayerId; }
177 void SetLayerName( const wxString& aName ) { m_LayerName = aName; }
178 void SetTypeName( const wxString& aName ) { m_TypeName = aName; }
179 void SetDielectricLayerId( int aLayerId ) { m_DielectricLayerId = aLayerId; }
180
181 void SetColor( const wxString& aColorName, int aDielectricSubLayer = 0 );
182 void SetThickness( int aThickness, int aDielectricSubLayer = 0 );
183 void SetThicknessLocked( bool aLocked, int aDielectricSubLayer = 0 );
184 void SetEpsilonR( double aEpsilon, int aDielectricSubLayer = 0 );
185 void SetLossTangent( double aTg, int aDielectricSubLayer = 0 );
186 void SetMaterial( const wxString& aName, int aDielectricSubLayer = 0 );
187
188private:
190 wxString m_LayerName;
191 wxString m_TypeName;
202 std::vector<DIELECTRIC_PRMS> m_DielectricPrmsList;
203
206};
207
208
219{
220public:
222 BOARD_STACKUP( const BOARD_STACKUP& aOther );
223 BOARD_STACKUP& operator=( const BOARD_STACKUP& aOther );
224
225 bool operator==( const BOARD_STACKUP& aOther ) const;
226 bool operator!=( const BOARD_STACKUP& aOther ) const { return !operator==( aOther ); }
227
229
230 void Serialize( google::protobuf::Any &aContainer ) const override;
231
232 bool Deserialize( const google::protobuf::Any &aContainer ) override;
233
234 const std::vector<BOARD_STACKUP_ITEM*>& GetList() const { return m_list; }
235
237 BOARD_STACKUP_ITEM* GetStackupLayer( int aIndex );
238
244 {
245 return LSET( { F_SilkS, F_Mask, F_Paste, B_SilkS, B_Mask, B_Paste } )
247 }
248
249
251 void RemoveAll();
252
254 int GetCount() const { return (int) m_list.size(); }
255
258
260 void Add( BOARD_STACKUP_ITEM* aItem ) { m_list.push_back( aItem ); }
261
270
279 void BuildDefaultStackupList( const BOARD_DESIGN_SETTINGS* aSettings,
280 int aActiveCopperLayersCount = 0 );
281
288 void FormatBoardStackup( OUTPUTFORMATTER* aFormatter,
289 const BOARD* aBoard, int aNestLevel ) const;
290
305 int GetLayerDistance( PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer ) const;
306
310 wxString m_FinishType;
311
320
325
334
337
338private:
339 // The list of items describing the stackup for fabrication.
340 // this is not just copper layers, but also mask dielectric layers
341 std::vector<BOARD_STACKUP_ITEM*> m_list;
342};
343
344
345#endif // BOARD_STACKUP_H
BS_EDGE_CONNECTOR_CONSTRAINTS
Definition: board_stackup.h:56
@ BS_EDGE_CONNECTOR_BEVELLED
Definition: board_stackup.h:59
@ BS_EDGE_CONNECTOR_NONE
Definition: board_stackup.h:57
@ BS_EDGE_CONNECTOR_IN_USE
Definition: board_stackup.h:58
BOARD_STACKUP_ITEM_TYPE
Definition: board_stackup.h:43
@ BS_ITEM_TYPE_UNDEFINED
Definition: board_stackup.h:44
@ BS_ITEM_TYPE_COPPER
Definition: board_stackup.h:45
@ BS_ITEM_TYPE_SILKSCREEN
Definition: board_stackup.h:51
@ BS_ITEM_TYPE_DIELECTRIC
Definition: board_stackup.h:46
@ BS_ITEM_TYPE_SOLDERPASTE
Definition: board_stackup.h:48
@ BS_ITEM_TYPE_SOLDERMASK
Definition: board_stackup.h:49
Container for design settings for a BOARD object.
Manage one layer needed to make a physical board.
Definition: board_stackup.h:96
void AddDielectricPrms(int aDielectricPrmsIdx)
Add (insert) a DIELECTRIC_PRMS item to m_DielectricPrmsList all values are set to default.
wxString GetTypeName() 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)
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
bool HasMaterialValue(int aDielectricSubLayer=0) const
void SetThicknessLocked(bool aLocked, int aDielectricSubLayer=0)
wxString FormatDielectricLayerName() const
wxString GetLayerName() const
void SetMaterial(const wxString &aName, int aDielectricSubLayer=0)
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)
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()
Manage layers needed to make a physical board.
void RemoveAll()
Delete all items in list and clear the list.
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, const BOARD *aBoard, int aNestLevel) const
Write the stackup info on board file.
bool m_CastellatedPads
True if castellated pads exist.
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...
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:290
A helper class to manage a dielectric layer set of parameters.
Definition: board_stackup.h:67
double m_EpsilonR
true for dielectric layers with a fixed thickness (for impedance controlled purposes),...
Definition: board_stackup.h:84
int m_Thickness
type of material (for dielectric and solder mask)
Definition: board_stackup.h:81
wxString m_Material
Definition: board_stackup.h:80
bool operator==(const DIELECTRIC_PRMS &aOther) const
wxString m_Color
For dielectric (and solder mask) the dielectric loss.
Definition: board_stackup.h:86
bool operator!=(const DIELECTRIC_PRMS &aOther) const
Definition: board_stackup.h:75
bool m_ThicknessLocked
the physical layer thickness in internal units
Definition: board_stackup.h:82
double m_LossTangent
For dielectric (and solder mask) the dielectric constant.
Definition: board_stackup.h:85
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:36
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:694
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
Definition: lset.cpp:665
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
Interface for objects that can be serialized to Protobuf messages.
Definition: serializable.h:36
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_Paste
Definition: layer_ids.h:104
@ B_Mask
Definition: layer_ids.h:98
@ F_Mask
Definition: layer_ids.h:97
@ B_Paste
Definition: layer_ids.h:105
@ F_SilkS
Definition: layer_ids.h:100
@ B_SilkS
Definition: layer_ids.h:101