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 <api/serializable.h>
33
34class BOARD;
36class OUTPUTFORMATTER;
37
38// A enum to manage the different layers inside the stackup layers.
39// Note the stackup layers include both dielectric and some layers handled by the board editor
40// Therefore a stackup layer item is not exactly like a board layer
42{
43 BS_ITEM_TYPE_UNDEFINED, // For not yet initialized BOARD_STACKUP_ITEM item
44 BS_ITEM_TYPE_COPPER, // A initialized BOARD_STACKUP_ITEM item for copper layers
45 BS_ITEM_TYPE_DIELECTRIC, // A initialized BOARD_STACKUP_ITEM item for the
46 // dielectric between copper layers
47 BS_ITEM_TYPE_SOLDERPASTE, // A initialized BOARD_STACKUP_ITEM item for solder paste layers
48 BS_ITEM_TYPE_SOLDERMASK, // A initialized BOARD_STACKUP_ITEM item for solder mask layers
49 // note: this is a specialized dielectric material
50 BS_ITEM_TYPE_SILKSCREEN, // A initialized BOARD_STACKUP_ITEM item for silkscreen layers
51};
52
53// A enum to manage edge connector fab info
55{
56 BS_EDGE_CONNECTOR_NONE, // No edge connector in board
57 BS_EDGE_CONNECTOR_IN_USE, // some edge connector in board
58 BS_EDGE_CONNECTOR_BEVELLED // Some connector in board, and the connector must be beveled
59};
60
61
66{
67public:
69 m_Thickness(0), m_ThicknessLocked( false ),
70 m_EpsilonR( 1.0 ), m_LossTangent( 0.0 )
71 {}
72
73 bool operator==( const DIELECTRIC_PRMS& aOther ) const;
74 bool operator!=( const DIELECTRIC_PRMS& aOther ) const { return !operator==( aOther ); }
75
76private:
77 friend class BOARD_STACKUP_ITEM;
78
79 wxString m_Material;
83 double m_EpsilonR;
85 wxString m_Color;
86};
87
88
95{
96public:
99
100 bool operator==( const BOARD_STACKUP_ITEM& aOther ) const;
101 bool operator!=( const BOARD_STACKUP_ITEM& aOther ) const { return !operator==( aOther ); }
102
109 void AddDielectricPrms( int aDielectricPrmsIdx );
110
116 void RemoveDielectricPrms( int aDielectricPrmsIdx );
117
120 bool HasEpsilonRValue() const;
121
124 bool HasLossTangentValue() const;
125
127 bool HasMaterialValue( int aDielectricSubLayer = 0 ) const;
128
130 bool IsMaterialEditable() const;
131
133 bool IsColorEditable() const;
134
136 bool IsThicknessEditable() const;
137
139 static int GetCopperDefaultThickness();
140
142 static int GetMaskDefaultThickness();
143
146 int GetSublayersCount() const { return m_DielectricPrmsList.size(); }
147
149 wxString FormatEpsilonR( int aDielectricSubLayer = 0 ) const;
150
152 wxString FormatLossTangent( int aDielectricSubLayer = 0 ) const;
153
155 wxString FormatDielectricLayerName() const;
156
157 // Getters:
158 bool IsEnabled() const { return m_enabled; }
159
162 wxString GetLayerName() const { return m_LayerName; }
163 wxString GetTypeName() const { return m_TypeName; }
165
166 wxString GetColor( int aDielectricSubLayer = 0 ) const;
167 int GetThickness( int aDielectricSubLayer = 0 ) const;
168 bool IsThicknessLocked( int aDielectricSubLayer = 0 ) const;
169 double GetEpsilonR( int aDielectricSubLayer = 0 ) const;
170 double GetLossTangent( int aDielectricSubLayer = 0 ) const;
171 wxString GetMaterial( int aDielectricSubLayer = 0 ) const;
172
173 // Setters:
174 void SetEnabled( bool aEnable) { m_enabled = aEnable; }
175 void SetBrdLayerId( PCB_LAYER_ID aBrdLayerId ) { m_LayerId = aBrdLayerId; }
176 void SetLayerName( const wxString& aName ) { m_LayerName = aName; }
177 void SetTypeName( const wxString& aName ) { m_TypeName = aName; }
178 void SetDielectricLayerId( int aLayerId ) { m_DielectricLayerId = aLayerId; }
179
180 void SetColor( const wxString& aColorName, int aDielectricSubLayer = 0 );
181 void SetThickness( int aThickness, int aDielectricSubLayer = 0 );
182 void SetThicknessLocked( bool aLocked, int aDielectricSubLayer = 0 );
183 void SetEpsilonR( double aEpsilon, int aDielectricSubLayer = 0 );
184 void SetLossTangent( double aTg, int aDielectricSubLayer = 0 );
185 void SetMaterial( const wxString& aName, int aDielectricSubLayer = 0 );
186
187private:
189 wxString m_LayerName;
190 wxString m_TypeName;
201 std::vector<DIELECTRIC_PRMS> m_DielectricPrmsList;
202
205};
206
207
218{
219public:
221 BOARD_STACKUP( const BOARD_STACKUP& aOther );
222 BOARD_STACKUP& operator=( const BOARD_STACKUP& aOther );
223
224 bool operator==( const BOARD_STACKUP& aOther ) const;
225 bool operator!=( const BOARD_STACKUP& aOther ) const { return !operator==( aOther ); }
226
228
229 void Serialize( google::protobuf::Any &aContainer ) const override;
230
231 bool Deserialize( const google::protobuf::Any &aContainer ) override;
232
233 const std::vector<BOARD_STACKUP_ITEM*>& GetList() const { return m_list; }
234
236 BOARD_STACKUP_ITEM* GetStackupLayer( int aIndex );
237
243 {
246 }
247
248
250 void RemoveAll();
251
253 int GetCount() const { return (int) m_list.size(); }
254
257
259 void Add( BOARD_STACKUP_ITEM* aItem ) { m_list.push_back( aItem ); }
260
269
278 void BuildDefaultStackupList( const BOARD_DESIGN_SETTINGS* aSettings,
279 int aActiveCopperLayersCount = 0 );
280
287 void FormatBoardStackup( OUTPUTFORMATTER* aFormatter,
288 const BOARD* aBoard, int aNestLevel ) const;
289
304 int GetLayerDistance( PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer ) const;
305
309 wxString m_FinishType;
310
319
324
333
336
337private:
338 // The list of items describing the stackup for fabrication.
339 // this is not just copper layers, but also mask dielectric layers
340 std::vector<BOARD_STACKUP_ITEM*> m_list;
341};
342
343
344#endif // BOARD_STACKUP_H
BS_EDGE_CONNECTOR_CONSTRAINTS
Definition: board_stackup.h:55
@ BS_EDGE_CONNECTOR_BEVELLED
Definition: board_stackup.h:58
@ BS_EDGE_CONNECTOR_NONE
Definition: board_stackup.h:56
@ BS_EDGE_CONNECTOR_IN_USE
Definition: board_stackup.h:57
BOARD_STACKUP_ITEM_TYPE
Definition: board_stackup.h:42
@ BS_ITEM_TYPE_UNDEFINED
Definition: board_stackup.h:43
@ BS_ITEM_TYPE_COPPER
Definition: board_stackup.h:44
@ BS_ITEM_TYPE_SILKSCREEN
Definition: board_stackup.h:50
@ BS_ITEM_TYPE_DIELECTRIC
Definition: board_stackup.h:45
@ BS_ITEM_TYPE_SOLDERPASTE
Definition: board_stackup.h:47
@ BS_ITEM_TYPE_SOLDERMASK
Definition: board_stackup.h:48
Container for design settings for a BOARD object.
Manage one layer needed to make a physical board.
Definition: board_stackup.h:95
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:281
A helper class to manage a dielectric layer set of parameters.
Definition: board_stackup.h:66
double m_EpsilonR
true for dielectric layers with a fixed thickness (for impedance controlled purposes),...
Definition: board_stackup.h:83
int m_Thickness
type of material (for dielectric and solder mask)
Definition: board_stackup.h:80
wxString m_Material
Definition: board_stackup.h:79
bool operator==(const DIELECTRIC_PRMS &aOther) const
wxString m_Color
For dielectric (and solder mask) the dielectric loss.
Definition: board_stackup.h:85
bool operator!=(const DIELECTRIC_PRMS &aOther) const
Definition: board_stackup.h:74
bool m_ThicknessLocked
the physical layer thickness in internal units
Definition: board_stackup.h:81
double m_LossTangent
For dielectric (and solder mask) the dielectric constant.
Definition: board_stackup.h:84
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:574
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:891
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:823
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:101
@ B_Mask
Definition: layer_ids.h:106
@ F_Mask
Definition: layer_ids.h:107
@ B_Paste
Definition: layer_ids.h:100
@ F_SilkS
Definition: layer_ids.h:104
@ B_SilkS
Definition: layer_ids.h:103