KiCad PCB EDA Suite
class_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-2019 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 CLASS_BOARD_STACKUP_H
26 #define CLASS_BOARD_STACKUP_H
27 
28 
29 #include <vector>
30 #include <wx/string.h>
32 
34 class OUTPUTFORMATTER;
35 
36 // A enum to manage the different layers inside the stackup layers.
37 // Note the stackup layers include both dielectric and some layers handled by the board editor
38 // Therefore a stackup layer item is not exactely like a board layer
40 {
41  BS_ITEM_TYPE_UNDEFINED, // For not yet initialized BOARD_STACKUP_ITEM item
42  BS_ITEM_TYPE_COPPER, // A initialized BOARD_STACKUP_ITEM item for copper layers
43  BS_ITEM_TYPE_DIELECTRIC, // A initialized BOARD_STACKUP_ITEM item for the
44  // dielectric between copper layers
45  BS_ITEM_TYPE_SOLDERPASTE, // A initialized BOARD_STACKUP_ITEM item for solder paste layers
46  BS_ITEM_TYPE_SOLDERMASK, // A initialized BOARD_STACKUP_ITEM item for solder mask layers
47  // note: this is a specialized dielectric material
48  BS_ITEM_TYPE_SILKSCREEN, // A initialized BOARD_STACKUP_ITEM item for silkscreen layers
49 };
50 
51 // A enum to manage edge connector fab info
53 {
54  BS_EDGE_CONNECTOR_NONE, // No edge connector in board
55  BS_EDGE_CONNECTOR_IN_USE, // some edge connector in board
56  BS_EDGE_CONNECTOR_BEVELLED // Some connector in board, and the connector must be bevelled
57 };
58 
59 
64 {
65  friend class BOARD_STACKUP_ITEM;
66 
67 private:
68  wxString m_Material;
71  double m_EpsilonR;
73  double m_LossTangent;
74 
75 public:
77  m_Thickness(0), m_ThicknessLocked( false ),
78  m_EpsilonR( 1.0 ), m_LossTangent( 0.0 )
79  {}
80 };
81 
82 
88 {
89 public:
92 
93 
94 private:
96  wxString m_LayerName;
97  wxString m_TypeName;
98  wxString m_Color;
103  std::vector<DIELECTRIC_PRMS> m_DielectricPrmsList;
110 
111  bool m_enabled;
112 
114 public:
121  void AddDielectricPrms( int aDielectricPrmsIdx );
122 
128  void RemoveDielectricPrms( int aDielectricPrmsIdx );
129 
132  bool HasEpsilonRValue() const;
133 
136  bool HasLossTangentValue() const;
137 
139  bool HasMaterialValue( int aDielectricSubLayer = 0 ) const;
140 
142  bool IsMaterialEditable() const;
143 
145  bool IsColorEditable() const;
146 
148  bool IsThicknessEditable() const;
149 
151  static int GetCopperDefaultThickness();
152 
154  static int GetMaskDefaultThickness();
155 
158  int GetSublayersCount() const { return m_DielectricPrmsList.size(); }
159 
161  wxString FormatEpsilonR( int aDielectricSubLayer = 0 ) const;
162 
164  wxString FormatLossTangent( int aDielectricSubLayer = 0 ) const;
165 
167  wxString FormatDielectricLayerName() const;
168 
169  // Getters:
170  bool IsEnabled() const {return m_enabled; }
171 
174  wxString GetColor() const { return m_Color; }
175  wxString GetLayerName() const { return m_LayerName; }
176  wxString GetTypeName() const { return m_TypeName; }
178 
179  int GetThickness( int aDielectricSubLayer = 0 ) const;
180  bool IsThicknessLocked( int aDielectricSubLayer = 0 ) const;
181  double GetEpsilonR( int aDielectricSubLayer = 0 ) const;
182  double GetLossTangent( int aDielectricSubLayer = 0 ) const;
183  wxString GetMaterial( int aDielectricSubLayer = 0 ) const;
184 
185  // Setters:
186  void SetEnabled( bool aEnable) { m_enabled = aEnable; }
187  void SetBrdLayerId( PCB_LAYER_ID aBrdLayerId ) { m_LayerId = aBrdLayerId; }
188  void SetColor( const wxString& aColorName ){ m_Color = aColorName; }
189  void SetLayerName( const wxString& aName ) { m_LayerName = aName; }
190  void SetTypeName( const wxString& aName ) { m_TypeName = aName; }
191  void SetDielectricLayerId( int aLayerId ) { m_DielectricLayerId = aLayerId; }
192 
193  void SetThickness( int aThickness, int aDielectricSubLayer = 0 );
194  void SetThicknessLocked( bool aLocked, int aDielectricSubLayer = 0 );
195  void SetEpsilonR( double aEpsilon, int aDielectricSubLayer = 0 );
196  void SetLossTangent( double aTg, int aDielectricSubLayer = 0 );
197  void SetMaterial( const wxString& aName, int aDielectricSubLayer = 0 );
198 };
199 
200 
210 {
211  // The list of items describing the stackup for fabrication.
212  // this is not just copper layers, but also mask dielectric layers
213  std::vector<BOARD_STACKUP_ITEM*> m_list;
214 
215 public:
218  wxString m_FinishType;
219 
227 
231 
239 
242 
243 public:
244  BOARD_STACKUP();
245  BOARD_STACKUP( BOARD_STACKUP& aOther );
246  BOARD_STACKUP& operator=( const BOARD_STACKUP& aOther );
247 
249 
250  std::vector<BOARD_STACKUP_ITEM*>& GetList() { return m_list; }
251 
253  BOARD_STACKUP_ITEM* GetStackupLayer( int aIndex );
254 
259  {
260  return LSET( 6, F_SilkS, F_Mask, F_Paste, B_SilkS, B_Mask, B_Paste )
262  }
263 
264 
266  void RemoveAll();
267 
269  int GetCount() { return (int) m_list.size(); }
270 
272  int BuildBoardTicknessFromStackup() const;
273 
275  void Add( BOARD_STACKUP_ITEM* aItem ) { m_list.push_back( aItem ); }
276 
284  bool SynchronizeWithBoard( BOARD_DESIGN_SETTINGS* aSettings );
285 
294  void BuildDefaultStackupList( BOARD_DESIGN_SETTINGS* aSettings, int aActiveCopperLayersCount = 0 );
295 
302  void FormatBoardStackup( OUTPUTFORMATTER* aFormatter,
303  BOARD* aBoard, int aNestLevel ) const;
304 };
305 
306 
307 #endif // #ifndef CLASS_BOARD_STACKUP_H
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, BOARD *aBoard, int aNestLevel) const
Writes the stackup info on board file.
int BuildBoardTicknessFromStackup() const
BOARD_STACKUP_ITEM_TYPE GetType() const
int m_Thickness
type of material (for dielectric and solder mask)
void SetBrdLayerId(PCB_LAYER_ID aBrdLayerId)
void SetTypeName(const wxString &aName)
BOARD_STACKUP_ITEM * GetStackupLayer(int aIndex)
std::vector< BOARD_STACKUP_ITEM * > & GetList()
bool HasMaterialValue(int aDielectricSubLayer=0) const
this class manage the layers needed to make a physical board they are solder mask,...
wxString m_FinishType
The name of external copper finish.
bool m_EdgePlating
True if the edge board is plated.
bool IsThicknessLocked(int aDielectricSubLayer=0) const
BS_EDGE_CONNECTOR_CONSTRAINTS m_EdgeConnectorConstraints
If the board has edge connector cards, some constrains can be specifed in job file: BS_EDGE_CONNECTOR...
bool m_CastellatedPads
True if castellated pads exist.
wxString GetColor() const
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
wxString m_TypeName
name of layer as shown in layer manager. Usefull to create reports
BOARD_STACKUP & operator=(const BOARD_STACKUP &aOther)
double GetLossTangent(int aDielectricSubLayer=0) const
double m_EpsilonR
true for dielectric layers with a fixed thickness (for impendace controled purposes),...
static int GetCopperDefaultThickness()
bool SynchronizeWithBoard(BOARD_DESIGN_SETTINGS *aSettings)
Synchronize the BOARD_STACKUP_ITEM* list with the board.
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...
bool m_ThicknessLocked
the physical layer thickness in internal units
DIELECTRIC_PRMS()
For dielectric (and solder mask) the dielectric loss.
bool m_HasDielectricConstrains
True if some layers have impedance controlled tracks or have specific constrains for micro-wave appli...
void SetLayerName(const wxString &aName)
PCB_LAYER_ID
A quick note on layer IDs:
BS_EDGE_CONNECTOR_CONSTRAINTS
bool IsThicknessEditable() const
Class LSET is a set of PCB_LAYER_IDs.
static LSET StackupAllowedBrdLayers()
int GetThickness(int aDielectricSubLayer=0) const
void SetDielectricLayerId(int aLayerId)
bool HasLossTangentValue() const
A helper class to manage a dielectric layer set of parameters.
double GetEpsilonR(int aDielectricSubLayer=0) const
PCB_LAYER_ID m_LayerId
mainly for silkscreen and solder mask
wxString FormatEpsilonR(int aDielectricSubLayer=0) const
static LSET InternalCuMask()
Function InternalCuMask() returns a complete set of internal copper layers, which is all Cu layers ex...
Definition: lset.cpp:636
static LSET ExternalCuMask()
Function ExternalCuMask returns a mask holding the Front and Bottom layers.
Definition: lset.cpp:706
wxString GetTypeName() const
wxString FormatLossTangent(int aDielectricSubLayer=0) const
void SetMaterial(const wxString &aName, int aDielectricSubLayer=0)
std::vector< BOARD_STACKUP_ITEM * > m_list
bool m_HasThicknessConstrains
True if some layers (copper and/or dielectric) have specific thickness.
this class manage one layer needed to make a physical board it can be a solder mask,...
void SetEpsilonR(double aEpsilon, int aDielectricSubLayer=0)
PCB_LAYER_ID GetBrdLayerId() const
void AddDielectricPrms(int aDielectricPrmsIdx)
true if this stackup item must be taken in account, false to ignore it.
void SetThickness(int aThickness, int aDielectricSubLayer=0)
static int GetMaskDefaultThickness()
wxString GetLayerName() const
double m_LossTangent
For dielectric (and solder mask) the dielectric constant.
void SetThicknessLocked(bool aLocked, int aDielectricSubLayer=0)
wxString m_Color
type name of layer (copper, silk screen, core, prepreg ...)
void RemoveAll()
Delete all items in list and clear the list.
BOARD_STACKUP_ITEM(BOARD_STACKUP_ITEM_TYPE aType)
Board layer functions and definitions.
int GetDielectricLayerId() const
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
BOARD_STACKUP_ITEM_TYPE
void SetColor(const wxString &aColorName)
void Add(BOARD_STACKUP_ITEM *aItem)
Add a new item in stackup layer.
BOARD_STACKUP_ITEM_TYPE m_Type
void SetLossTangent(double aTg, int aDielectricSubLayer=0)
wxString GetMaterial(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 dielectic la...
wxString FormatDielectricLayerName() const
void BuildDefaultStackupList(BOARD_DESIGN_SETTINGS *aSettings, int aActiveCopperLayersCount=0)
Creates a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
void SetEnabled(bool aEnable)
void RemoveDielectricPrms(int aDielectricPrmsIdx)
Remove a DIELECTRIC_PRMS item from m_DielectricPrmsList.