31#include <google/protobuf/any.pb.h>
32#include <api/board/board.pb.h>
148 || aDielectricPrmsIdx < 0
176 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
183 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
191 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
199 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
207 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
215 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
224 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
233 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
242 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
251 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
260 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
269 wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer <
GetSublayersCount() );
412 if( !std::equal( std::begin(
m_list ), std::end(
m_list ), std::begin( aOther.
m_list ),
427 kiapi::board::BoardStackup stackup;
431 kiapi::board::BoardStackupLayer* layer = stackup.mutable_layers()->Add();
434 layer->mutable_thickness()->set_value_nm( item->GetThickness() );
435 layer->set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>(
436 item->GetBrdLayerId() ) );
438 switch( item->GetType() )
440 case BOARD_STACKUP_ITEM_TYPE::BS_ITEM_TYPE_COPPER:
442 layer->mutable_copper()->New();
453 aContainer.PackFrom( stackup );
474 if( aIndex < 0 || aIndex >=
GetCount() )
488 if( item->IsThicknessEditable() && item->IsEnabled() )
490 thickness += item->GetThickness();
494 for(
int idx = 1; idx < item->GetSublayersCount(); idx++ )
496 thickness += item->GetThickness( idx );
521 if( item->GetBrdLayerId() == curr_item->GetBrdLayerId() )
532 if( item->GetDielectricLayerId() == curr_item->GetDielectricLayerId() )
556 if( item->GetBrdLayerId() == initial_item->GetBrdLayerId() )
558 *item = *initial_item;
569 if( item->GetDielectricLayerId() == initial_item->GetDielectricLayerId() )
571 *item = *initial_item;
600 int aActiveCopperLayersCount )
613 int activeCuLayerCount = copperLayerCount;
615 if( aSettings ==
nullptr && aActiveCopperLayersCount > 0 )
616 activeCuLayerCount = aActiveCopperLayersCount;
619 int diel_thickness = brd__thickness -
625 diel_thickness /= std::max( 1, activeCuLayerCount - 1 );
627 int dielectric_idx = 0;
646 if( enabledLayer[
F_Mask] )
671 if( (dielectric_idx & 1) == 0 )
687 if( enabledLayer[
B_Mask] )
725 const BOARD* aBoard,
int aNestLevel )
const
732 aFormatter->
Print( aNestLevel,
"(stackup\n" );
733 int nest_level = aNestLevel+1;
742 layer_name.Printf( wxT(
"dielectric %d" ), item->GetDielectricLayerId() );
744 layer_name =
LSET::Name( item->GetBrdLayerId() );
746 aFormatter->
Print( nest_level,
"(layer %s (type %s)",
747 aFormatter->
Quotew( layer_name ).c_str(),
748 aFormatter->
Quotew( item->GetTypeName() ).c_str() );
751 for(
int idx = 0; idx < item->GetSublayersCount(); idx++ )
755 aFormatter->
Print( 0,
"\n" );
756 aFormatter->
Print( nest_level+1,
"addsublayer" );
759 if( item->IsColorEditable() &&
IsPrmSpecified( item->GetColor( idx ) ) )
761 aFormatter->
Print( 0,
" (color %s)",
762 aFormatter->
Quotew( item->GetColor( idx ) ).c_str() );
765 if( item->IsThicknessEditable() )
768 aFormatter->
Print( 0,
" (thickness %s locked)",
771 aFormatter->
Print( 0,
" (thickness %s)",
775 if( item->HasMaterialValue( idx ) )
776 aFormatter->
Print( 0,
" (material %s)",
777 aFormatter->
Quotew( item->GetMaterial( idx ) ).c_str() );
779 if( item->HasEpsilonRValue() && item->HasMaterialValue( idx ) )
780 aFormatter->
Print( 0,
" (epsilon_r %g)", item->GetEpsilonR( idx ) );
782 if( item->HasLossTangentValue() && item->HasMaterialValue( idx ) )
783 aFormatter->
Print( 0,
" (loss_tangent %s)",
787 aFormatter->
Print( 0,
")\n" );
793 aFormatter->
Print( nest_level,
"(copper_finish %s)\n",
797 aFormatter->
Print( nest_level,
"(dielectric_constraints %s)\n",
802 aFormatter->
Print( nest_level,
"(edge_connector %s)\n",
807 aFormatter->
Print( nest_level,
"(castellated_pads yes)\n" );
810 aFormatter->
Print( nest_level,
"(edge_plating yes)\n" );
812 aFormatter->
Print( aNestLevel,
")\n" );
820 if( aFirstLayer == aSecondLayer )
824 if( aSecondLayer !=
B_Cu && ( aSecondLayer < aFirstLayer || aFirstLayer ==
B_Cu ) )
825 std::swap( aFirstLayer, aSecondLayer );
852 for(
int sublayer = 0; sublayer < item->GetSublayersCount(); sublayer++ )
854 int subThickness = item->GetThickness( sublayer );
855 total += half ? ( subThickness / 2 ) : subThickness;
872 if( !aPrmValue.IsEmpty()
constexpr EDA_IU_SCALE pcbIUScale
bool IsPrmSpecified(const wxString &aPrmValue)
@ BS_ITEM_TYPE_SILKSCREEN
@ BS_ITEM_TYPE_DIELECTRIC
@ BS_ITEM_TYPE_SOLDERPASTE
@ BS_ITEM_TYPE_SOLDERMASK
Container for design settings for a BOARD object.
LSET GetEnabledLayers() const
Return a bit-mask of all the layers that are enabled.
int GetBoardThickness() const
The full thickness of the board including copper and masks.
BOARD_STACKUP & GetStackupDescriptor()
int GetCopperLayerCount() const
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.
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
void SetMaterial(const wxString &aName, int aDielectricSubLayer=0)
BOARD_STACKUP_ITEM(BOARD_STACKUP_ITEM_TYPE aType)
bool HasLossTangentValue() 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()
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 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()
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.
wxString m_FinishType
The name of external copper finish.
Information pertinent to a Pcbnew printed circuit board.
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),...
int m_Thickness
type of material (for dielectric and solder mask)
bool operator==(const DIELECTRIC_PRMS &aOther) const
wxString m_Color
For dielectric (and solder mask) the dielectric loss.
bool m_ThicknessLocked
the physical layer thickness in internal units
double m_LossTangent
For dielectric (and solder mask) the dielectric constant.
LSET is a set of PCB_LAYER_IDs.
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Some functions to handle hotkeys in KiCad.
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
wxString NotSpecifiedPrm()
#define DEFAULT_EPSILON_R_SILKSCREEN
#define DEFAULT_EPSILON_R_SOLDERMASK
std::string UIDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
constexpr int mmToIU(double mm) const