2019-06-23 11:20:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2021-04-16 21:07:06 +00:00
|
|
|
* Copyright (C) 2009-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-06-23 11:20:22 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 3
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-04-16 21:07:06 +00:00
|
|
|
#include "board_stackup.h"
|
2019-06-23 11:20:22 +00:00
|
|
|
#include <convert_to_biu.h>
|
|
|
|
#include <base_units.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2019-06-23 11:20:22 +00:00
|
|
|
#include <board_design_settings.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2019-07-14 08:19:53 +00:00
|
|
|
#include <i18n_utility.h> // For _HKI definition
|
2019-06-23 11:20:22 +00:00
|
|
|
#include "stackup_predefined_prms.h"
|
|
|
|
|
2019-09-27 15:12:24 +00:00
|
|
|
|
2019-06-23 11:20:22 +00:00
|
|
|
BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM_TYPE aType )
|
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
DIELECTRIC_PRMS item_prms;
|
|
|
|
m_DielectricPrmsList.emplace_back( item_prms );
|
2019-06-23 11:20:22 +00:00
|
|
|
m_LayerId = UNDEFINED_LAYER;
|
|
|
|
m_Type = aType;
|
2019-11-14 15:26:05 +00:00
|
|
|
SetDielectricLayerId( 1 );
|
2019-11-11 18:34:48 +00:00
|
|
|
SetEnabled( true );
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
// Initialize parameters to a usual value for allowed types:
|
|
|
|
switch( m_Type )
|
|
|
|
{
|
|
|
|
case BS_ITEM_TYPE_COPPER:
|
2019-09-06 18:59:13 +00:00
|
|
|
m_TypeName = KEY_COPPER;
|
2019-11-11 18:34:48 +00:00
|
|
|
SetThickness( GetCopperDefaultThickness() );
|
2019-06-23 11:20:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_DIELECTRIC:
|
2022-02-04 22:44:59 +00:00
|
|
|
m_TypeName = KEY_CORE; // or prepreg
|
|
|
|
SetMaterial( wxT( "FR4" ) ); // or other dielectric name
|
|
|
|
SetLossTangent( 0.02 ); // for FR4
|
|
|
|
SetEpsilonR( 4.5 ); // for FR4
|
2019-06-23 11:20:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_SOLDERPASTE:
|
2022-02-04 22:44:59 +00:00
|
|
|
m_TypeName = wxT( "solderpaste" );
|
2019-06-23 11:20:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_SOLDERMASK:
|
2022-02-04 22:44:59 +00:00
|
|
|
m_TypeName = wxT( "soldermask" );
|
2021-11-07 15:35:14 +00:00
|
|
|
m_Color = NotSpecifiedPrm();
|
2019-11-11 18:34:48 +00:00
|
|
|
SetMaterial( NotSpecifiedPrm() ); // or other solder mask material name
|
|
|
|
SetThickness( GetMaskDefaultThickness() );
|
|
|
|
SetEpsilonR( DEFAULT_EPSILON_R_SOLDERMASK );
|
2019-06-23 11:20:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_SILKSCREEN:
|
2022-02-04 22:44:59 +00:00
|
|
|
m_TypeName = wxT( "silkscreen" );
|
2019-09-27 15:12:24 +00:00
|
|
|
m_Color = NotSpecifiedPrm();
|
2019-11-11 18:34:48 +00:00
|
|
|
SetMaterial( NotSpecifiedPrm() ); // or other silkscreen material name
|
|
|
|
SetEpsilonR( DEFAULT_EPSILON_R_SILKSCREEN );
|
2019-06-23 11:20:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_UNDEFINED:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( const BOARD_STACKUP_ITEM& aOther )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
m_LayerId = aOther.m_LayerId;
|
2019-11-14 15:26:05 +00:00
|
|
|
m_DielectricLayerId = aOther.m_DielectricLayerId;
|
2019-06-23 11:20:22 +00:00
|
|
|
m_Type = aOther.m_Type;
|
2019-11-11 18:34:48 +00:00
|
|
|
m_enabled = aOther.m_enabled;
|
|
|
|
m_DielectricPrmsList = aOther.m_DielectricPrmsList;
|
2019-06-23 11:20:22 +00:00
|
|
|
m_TypeName = aOther.m_TypeName;
|
2019-09-06 09:26:27 +00:00
|
|
|
m_LayerName = aOther.m_LayerName;
|
2019-11-11 18:34:48 +00:00
|
|
|
m_Color = aOther.GetColor();
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
void BOARD_STACKUP_ITEM::AddDielectricPrms( int aDielectricPrmsIdx )
|
|
|
|
{
|
|
|
|
// add a DIELECTRIC_PRMS item to m_DielectricPrmsList
|
|
|
|
DIELECTRIC_PRMS new_prms;
|
|
|
|
|
2021-08-16 18:57:15 +00:00
|
|
|
m_DielectricPrmsList.emplace( m_DielectricPrmsList.begin() + aDielectricPrmsIdx, new_prms );
|
2019-11-14 15:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_STACKUP_ITEM::RemoveDielectricPrms( int aDielectricPrmsIdx )
|
|
|
|
{
|
|
|
|
// Remove a DIELECTRIC_PRMS item from m_DielectricPrmsList if possible
|
|
|
|
|
2021-08-16 18:57:15 +00:00
|
|
|
if( GetSublayersCount() < 2
|
|
|
|
|| aDielectricPrmsIdx < 0
|
2020-09-22 21:50:59 +00:00
|
|
|
|| aDielectricPrmsIdx >= GetSublayersCount() )
|
2021-08-16 18:57:15 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
return;
|
2021-08-16 18:57:15 +00:00
|
|
|
}
|
2019-11-14 15:26:05 +00:00
|
|
|
|
|
|
|
m_DielectricPrmsList.erase( m_DielectricPrmsList.begin() + aDielectricPrmsIdx );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
int BOARD_STACKUP_ITEM::GetCopperDefaultThickness()
|
|
|
|
{
|
|
|
|
// A reasonable thickness for copper layers:
|
|
|
|
return Millimeter2iu( 0.035 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int BOARD_STACKUP_ITEM::GetMaskDefaultThickness()
|
|
|
|
{
|
|
|
|
// A reasonable thickness for solder mask:
|
|
|
|
return Millimeter2iu( 0.01 );
|
|
|
|
}
|
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
// Getters:
|
2019-11-14 15:26:05 +00:00
|
|
|
int BOARD_STACKUP_ITEM::GetThickness( int aDielectricSubLayer ) const
|
2019-11-11 18:34:48 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() );
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
return m_DielectricPrmsList[aDielectricSubLayer].m_Thickness;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
double BOARD_STACKUP_ITEM::GetLossTangent( int aDielectricSubLayer ) const
|
2019-11-11 18:34:48 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() );
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
return m_DielectricPrmsList[aDielectricSubLayer].m_LossTangent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
double BOARD_STACKUP_ITEM::GetEpsilonR( int aDielectricSubLayer ) const
|
2019-11-11 18:34:48 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() );
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
return m_DielectricPrmsList[aDielectricSubLayer].m_EpsilonR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
bool BOARD_STACKUP_ITEM::IsThicknessLocked( int aDielectricSubLayer ) const
|
2019-11-11 18:34:48 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() );
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
return m_DielectricPrmsList[aDielectricSubLayer].m_ThicknessLocked;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
wxString BOARD_STACKUP_ITEM::GetMaterial( int aDielectricSubLayer ) const
|
2019-11-11 18:34:48 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() );
|
2019-11-11 18:34:48 +00:00
|
|
|
|
|
|
|
return m_DielectricPrmsList[aDielectricSubLayer].m_Material;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Setters:
|
|
|
|
void BOARD_STACKUP_ITEM::SetThickness( int aThickness, int aDielectricSubLayer )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() );
|
|
|
|
|
|
|
|
if( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() )
|
|
|
|
m_DielectricPrmsList[aDielectricSubLayer].m_Thickness = aThickness;
|
2019-11-11 18:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_STACKUP_ITEM::SetLossTangent( double aTg, int aDielectricSubLayer )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() );
|
|
|
|
|
|
|
|
if( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() )
|
|
|
|
m_DielectricPrmsList[aDielectricSubLayer].m_LossTangent = aTg;
|
2019-11-11 18:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_STACKUP_ITEM::SetEpsilonR( double aEpsilon, int aDielectricSubLayer )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() );
|
|
|
|
|
|
|
|
if( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() )
|
|
|
|
m_DielectricPrmsList[aDielectricSubLayer].m_EpsilonR = aEpsilon;
|
2019-11-11 18:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_STACKUP_ITEM::SetThicknessLocked( bool aLocked, int aDielectricSubLayer )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() );
|
2019-11-11 18:34:48 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() )
|
|
|
|
m_DielectricPrmsList[aDielectricSubLayer].m_ThicknessLocked = aLocked;
|
2019-11-11 18:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_STACKUP_ITEM::SetMaterial( const wxString& aName, int aDielectricSubLayer )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
wxASSERT( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() );
|
|
|
|
|
|
|
|
if( aDielectricSubLayer >= 0 && aDielectricSubLayer < GetSublayersCount() )
|
|
|
|
m_DielectricPrmsList[aDielectricSubLayer].m_Material = aName;
|
2019-11-11 18:34:48 +00:00
|
|
|
}
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
bool BOARD_STACKUP_ITEM::HasEpsilonRValue() const
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2019-09-24 12:33:28 +00:00
|
|
|
return m_Type == BS_ITEM_TYPE_DIELECTRIC
|
2021-08-16 18:57:15 +00:00
|
|
|
|| m_Type == BS_ITEM_TYPE_SOLDERMASK;
|
2019-06-23 11:20:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
bool BOARD_STACKUP_ITEM::HasLossTangentValue() const
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2019-09-24 12:33:28 +00:00
|
|
|
return m_Type == BS_ITEM_TYPE_DIELECTRIC
|
2021-08-16 18:57:15 +00:00
|
|
|
|| m_Type == BS_ITEM_TYPE_SOLDERMASK;
|
2019-06-23 11:20:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
bool BOARD_STACKUP_ITEM::HasMaterialValue( int aDielectricSubLayer ) const
|
2019-09-24 12:33:28 +00:00
|
|
|
{
|
|
|
|
// return true if the material is specified
|
2019-11-14 15:26:05 +00:00
|
|
|
return IsMaterialEditable() && IsPrmSpecified( GetMaterial( aDielectricSubLayer ) );
|
2019-09-24 12:33:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
bool BOARD_STACKUP_ITEM::IsMaterialEditable() const
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2021-08-16 18:57:15 +00:00
|
|
|
return m_Type == BS_ITEM_TYPE_DIELECTRIC
|
|
|
|
|| m_Type == BS_ITEM_TYPE_SOLDERMASK
|
|
|
|
|| m_Type == BS_ITEM_TYPE_SILKSCREEN;
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
bool BOARD_STACKUP_ITEM::IsColorEditable() const
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2021-08-16 18:57:15 +00:00
|
|
|
return m_Type == BS_ITEM_TYPE_DIELECTRIC
|
|
|
|
|| m_Type == BS_ITEM_TYPE_SOLDERMASK
|
|
|
|
|| m_Type == BS_ITEM_TYPE_SILKSCREEN;
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
bool BOARD_STACKUP_ITEM::IsThicknessEditable() const
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2021-08-16 18:57:15 +00:00
|
|
|
return m_Type == BS_ITEM_TYPE_COPPER
|
|
|
|
|| m_Type == BS_ITEM_TYPE_DIELECTRIC
|
|
|
|
|| m_Type == BS_ITEM_TYPE_SOLDERMASK;
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
wxString BOARD_STACKUP_ITEM::FormatEpsilonR( int aDielectricSubLayer ) const
|
2019-09-09 14:45:21 +00:00
|
|
|
{
|
|
|
|
// return a wxString to print/display Epsilon R
|
2021-08-14 07:42:05 +00:00
|
|
|
// note: we do not want scientific notation
|
|
|
|
wxString txt = Double2Str( GetEpsilonR( aDielectricSubLayer ) );
|
2019-09-09 14:45:21 +00:00
|
|
|
return txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
wxString BOARD_STACKUP_ITEM::FormatLossTangent( int aDielectricSubLayer ) const
|
2019-09-09 14:45:21 +00:00
|
|
|
{
|
|
|
|
// return a wxString to print/display Loss Tangent
|
2021-08-14 07:42:05 +00:00
|
|
|
// note: we do not want scientific notation
|
|
|
|
wxString txt = Double2Str( GetLossTangent( aDielectricSubLayer ) );
|
2019-09-09 14:45:21 +00:00
|
|
|
return txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
wxString BOARD_STACKUP_ITEM::FormatDielectricLayerName() const
|
2019-11-11 18:34:48 +00:00
|
|
|
{
|
2020-09-22 21:50:59 +00:00
|
|
|
// return a wxString to print/display a dielectric name
|
2019-11-11 18:34:48 +00:00
|
|
|
wxString lname;
|
|
|
|
lname.Printf( _( "Dielectric %d" ), GetDielectricLayerId() );
|
|
|
|
|
|
|
|
return lname;
|
|
|
|
}
|
|
|
|
|
2019-09-09 14:45:21 +00:00
|
|
|
|
2019-06-23 11:20:22 +00:00
|
|
|
BOARD_STACKUP::BOARD_STACKUP()
|
|
|
|
{
|
|
|
|
m_HasDielectricConstrains = false; // True if some dielectric layers have constrains
|
|
|
|
// (Loss tg and Epison R)
|
|
|
|
m_HasThicknessConstrains = false; // True if some dielectric or copper layers have constrains
|
|
|
|
m_EdgeConnectorConstraints = BS_EDGE_CONNECTOR_NONE;
|
|
|
|
m_CastellatedPads = false; // True if some castellated pads exist
|
|
|
|
m_EdgePlating = false; // True if edge board is plated
|
2022-02-04 22:44:59 +00:00
|
|
|
m_FinishType = wxT( "None" ); // undefined finish type
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
BOARD_STACKUP::BOARD_STACKUP( const BOARD_STACKUP& aOther )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2020-01-12 13:00:42 +00:00
|
|
|
m_HasDielectricConstrains = aOther.m_HasDielectricConstrains;
|
|
|
|
m_HasThicknessConstrains = aOther.m_HasThicknessConstrains;
|
2019-06-23 11:20:22 +00:00
|
|
|
m_EdgeConnectorConstraints = aOther.m_EdgeConnectorConstraints;
|
2020-01-12 13:00:42 +00:00
|
|
|
m_CastellatedPads = aOther.m_CastellatedPads;
|
|
|
|
m_EdgePlating = aOther.m_EdgePlating;
|
|
|
|
m_FinishType = aOther.m_FinishType;
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
// All items in aOther.m_list have to be duplicated, because aOther.m_list
|
|
|
|
// manage pointers to these items
|
2021-08-16 18:57:15 +00:00
|
|
|
for( BOARD_STACKUP_ITEM* item : aOther.m_list )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* dup_item = new BOARD_STACKUP_ITEM( *item );
|
|
|
|
Add( dup_item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOARD_STACKUP& BOARD_STACKUP::operator=( const BOARD_STACKUP& aOther )
|
|
|
|
{
|
2020-01-12 13:00:42 +00:00
|
|
|
m_HasDielectricConstrains = aOther.m_HasDielectricConstrains;
|
|
|
|
m_HasThicknessConstrains = aOther.m_HasThicknessConstrains;
|
2019-06-23 11:20:22 +00:00
|
|
|
m_EdgeConnectorConstraints = aOther.m_EdgeConnectorConstraints;
|
2020-01-12 13:00:42 +00:00
|
|
|
m_CastellatedPads = aOther.m_CastellatedPads;
|
|
|
|
m_EdgePlating = aOther.m_EdgePlating;
|
|
|
|
m_FinishType = aOther.m_FinishType;
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
RemoveAll();
|
|
|
|
|
|
|
|
// All items in aOther.m_list have to be duplicated, because aOther.m_list
|
|
|
|
// manage pointers to these items
|
2021-08-16 18:57:15 +00:00
|
|
|
for( BOARD_STACKUP_ITEM* item : aOther.m_list )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* dup_item = new BOARD_STACKUP_ITEM( *item );
|
|
|
|
Add( dup_item );
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_STACKUP::RemoveAll()
|
|
|
|
{
|
2021-08-16 18:57:15 +00:00
|
|
|
for( BOARD_STACKUP_ITEM* item : m_list )
|
2019-06-23 11:20:22 +00:00
|
|
|
delete item;
|
|
|
|
|
|
|
|
m_list.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOARD_STACKUP_ITEM* BOARD_STACKUP::GetStackupLayer( int aIndex )
|
|
|
|
{
|
|
|
|
if( aIndex < 0 || aIndex >= GetCount() )
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return GetList()[aIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-11 19:25:49 +00:00
|
|
|
int BOARD_STACKUP::BuildBoardThicknessFromStackup() const
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
// return the board thickness from the thickness of BOARD_STACKUP_ITEM list
|
|
|
|
int thickness = 0;
|
|
|
|
|
2021-08-16 18:57:15 +00:00
|
|
|
for( BOARD_STACKUP_ITEM* item : m_list )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->IsThicknessEditable() && item->IsEnabled() )
|
2022-02-18 17:09:02 +00:00
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
thickness += item->GetThickness();
|
2022-02-18 17:09:02 +00:00
|
|
|
|
|
|
|
// dielectric layers can have more than one main layer
|
|
|
|
// add thickness of all sublayers
|
|
|
|
for( int idx = 1; idx < item->GetSublayersCount(); idx++ )
|
|
|
|
{
|
|
|
|
thickness += item->GetThickness( idx );
|
|
|
|
}
|
|
|
|
}
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return thickness;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool BOARD_STACKUP::SynchronizeWithBoard( BOARD_DESIGN_SETTINGS* aSettings )
|
|
|
|
{
|
|
|
|
bool change = false;
|
|
|
|
// Build the suitable stackup:
|
|
|
|
BOARD_STACKUP stackup;
|
|
|
|
stackup.BuildDefaultStackupList( aSettings );
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
// First, find removed layers:
|
|
|
|
for( BOARD_STACKUP_ITEM* curr_item: m_list )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
for( BOARD_STACKUP_ITEM* item: stackup.GetList() )
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
if( curr_item->GetBrdLayerId() != UNDEFINED_LAYER )
|
|
|
|
{
|
|
|
|
if( item->GetBrdLayerId() == curr_item->GetBrdLayerId() )
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // curr_item = dielectric layer
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetBrdLayerId() != UNDEFINED_LAYER )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item->GetDielectricLayerId() == curr_item->GetDielectricLayerId() )
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !found ) // a layer was removed: a change is found
|
|
|
|
{
|
|
|
|
change = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now initialize all stackup items to the initial values, when exist
|
2020-12-20 18:50:45 +00:00
|
|
|
for( BOARD_STACKUP_ITEM* item : stackup.GetList() )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
// Search for initial settings:
|
2020-12-20 18:44:13 +00:00
|
|
|
for( const BOARD_STACKUP_ITEM* initial_item : m_list )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->GetBrdLayerId() != UNDEFINED_LAYER )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->GetBrdLayerId() == initial_item->GetBrdLayerId() )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
*item = *initial_item;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // dielectric layer: see m_DielectricLayerId for identification
|
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
// Compare dielectric layer with dielectric layer
|
|
|
|
if( initial_item->GetBrdLayerId() != UNDEFINED_LAYER )
|
|
|
|
continue;
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->GetDielectricLayerId() == initial_item->GetDielectricLayerId() )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
*item = *initial_item;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !found )
|
2019-11-14 15:26:05 +00:00
|
|
|
{
|
2019-06-23 11:20:22 +00:00
|
|
|
change = true;
|
2019-11-14 15:26:05 +00:00
|
|
|
}
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
|
2021-09-26 14:10:17 +00:00
|
|
|
// Transfert layer settings:
|
|
|
|
*this = stackup;
|
|
|
|
|
2019-06-23 11:20:22 +00:00
|
|
|
// Transfer other stackup settings from aSettings
|
2020-12-20 18:50:45 +00:00
|
|
|
const BOARD_STACKUP& source_stackup = aSettings->GetStackupDescriptor();
|
|
|
|
m_HasDielectricConstrains = source_stackup.m_HasDielectricConstrains;
|
2019-06-23 11:20:22 +00:00
|
|
|
m_EdgeConnectorConstraints = source_stackup.m_EdgeConnectorConstraints;
|
|
|
|
m_CastellatedPads = source_stackup.m_CastellatedPads;
|
2020-12-20 18:50:45 +00:00
|
|
|
m_EdgePlating = source_stackup.m_EdgePlating;
|
|
|
|
m_FinishType = source_stackup.m_FinishType;
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
void BOARD_STACKUP::BuildDefaultStackupList( const BOARD_DESIGN_SETTINGS* aSettings,
|
2019-07-27 19:09:43 +00:00
|
|
|
int aActiveCopperLayersCount )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
// Creates a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
|
2019-07-14 08:19:53 +00:00
|
|
|
// Note: the m_TypeName string is made translatable using _HKI marker, but is not
|
|
|
|
// translated when building the stackup.
|
|
|
|
// It will be used as this in files, and can be translated only in dialog
|
2019-07-27 19:09:43 +00:00
|
|
|
// if aSettings == NULL, build a full stackup (with 32 copper layers)
|
|
|
|
LSET enabledLayer = aSettings ? aSettings->GetEnabledLayers() : StackupAllowedBrdLayers();
|
|
|
|
int copperLayerCount = aSettings ? aSettings->GetCopperLayerCount() : B_Cu+1;
|
|
|
|
|
|
|
|
// We need to calculate a suitable dielectric layer thickness.
|
|
|
|
// If no settings, and if aActiveCopperLayersCount is given, use it
|
|
|
|
// (If no settings, and no aActiveCopperLayersCount, the full 32 layers are used)
|
|
|
|
int activeCuLayerCount = copperLayerCount;
|
|
|
|
|
|
|
|
if( aSettings == nullptr && aActiveCopperLayersCount > 0 )
|
|
|
|
activeCuLayerCount = aActiveCopperLayersCount;
|
|
|
|
|
|
|
|
int brd__thickness = aSettings ? aSettings->GetBoardThickness() : Millimeter2iu( 1.6 );
|
|
|
|
int diel_thickness = brd__thickness -
|
|
|
|
( BOARD_STACKUP_ITEM::GetCopperDefaultThickness() * activeCuLayerCount );
|
|
|
|
|
|
|
|
// Take in account the solder mask thickness:
|
|
|
|
int sm_count = ( enabledLayer & LSET( 2, F_Mask, B_Mask) ).count();
|
|
|
|
diel_thickness -= BOARD_STACKUP_ITEM::GetMaskDefaultThickness() * sm_count;
|
2021-10-09 20:11:16 +00:00
|
|
|
diel_thickness /= std::max( 1, activeCuLayerCount - 1 );
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
int dielectric_idx = 0;
|
|
|
|
|
|
|
|
// Add silk screen, solder mask and solder paste layers on top
|
|
|
|
if( enabledLayer[F_SilkS] )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* item = new BOARD_STACKUP_ITEM( BS_ITEM_TYPE_SILKSCREEN );
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetBrdLayerId( F_SilkS );
|
|
|
|
item->SetTypeName( _HKI( "Top Silk Screen" ) );
|
2019-06-23 11:20:22 +00:00
|
|
|
Add( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( enabledLayer[F_Paste] )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* item = new BOARD_STACKUP_ITEM( BS_ITEM_TYPE_SOLDERPASTE );
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetBrdLayerId( F_Paste );
|
|
|
|
item->SetTypeName( _HKI( "Top Solder Paste" ) );
|
2019-06-23 11:20:22 +00:00
|
|
|
Add( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( enabledLayer[F_Mask] )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* item = new BOARD_STACKUP_ITEM( BS_ITEM_TYPE_SOLDERMASK );
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetBrdLayerId( F_Mask );
|
|
|
|
item->SetTypeName( _HKI( "Top Solder Mask" ) );
|
2019-06-23 11:20:22 +00:00
|
|
|
Add( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add copper and dielectric layers
|
|
|
|
for( int ii = 0; ii < copperLayerCount; ii++ )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* item = new BOARD_STACKUP_ITEM( BS_ITEM_TYPE_COPPER );
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetBrdLayerId( ( PCB_LAYER_ID )ii );
|
|
|
|
item->SetTypeName( KEY_COPPER );
|
2019-06-23 11:20:22 +00:00
|
|
|
Add( item );
|
|
|
|
|
|
|
|
if( ii == copperLayerCount-1 )
|
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetBrdLayerId( B_Cu );
|
2019-06-23 11:20:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the dielectric layer:
|
|
|
|
item = new BOARD_STACKUP_ITEM( BS_ITEM_TYPE_DIELECTRIC );
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetThickness( diel_thickness );
|
|
|
|
item->SetDielectricLayerId( dielectric_idx + 1 );
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
// Display a dielectric default layer name:
|
|
|
|
if( (dielectric_idx & 1) == 0 )
|
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetTypeName( KEY_CORE );
|
2022-02-04 22:44:59 +00:00
|
|
|
item->SetMaterial( wxT( "FR4" ) );
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetTypeName( KEY_PREPREG );
|
2022-02-04 22:44:59 +00:00
|
|
|
item->SetMaterial( wxT( "FR4" ) );
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Add( item );
|
|
|
|
dielectric_idx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add silk screen, solder mask and solder paste layers on bottom
|
|
|
|
if( enabledLayer[B_Mask] )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* item = new BOARD_STACKUP_ITEM( BS_ITEM_TYPE_SOLDERMASK );
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetBrdLayerId( B_Mask );
|
|
|
|
item->SetTypeName( _HKI( "Bottom Solder Mask" ) );
|
2019-06-23 11:20:22 +00:00
|
|
|
Add( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( enabledLayer[B_Paste] )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* item = new BOARD_STACKUP_ITEM( BS_ITEM_TYPE_SOLDERPASTE );
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetBrdLayerId( B_Paste );
|
|
|
|
item->SetTypeName( _HKI( "Bottom Solder Paste" ) );
|
2019-06-23 11:20:22 +00:00
|
|
|
Add( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( enabledLayer[B_SilkS] )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* item = new BOARD_STACKUP_ITEM( BS_ITEM_TYPE_SILKSCREEN );
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetBrdLayerId( B_SilkS );
|
|
|
|
item->SetTypeName( _HKI( "Bottom Silk Screen" ) );
|
2019-06-23 11:20:22 +00:00
|
|
|
Add( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Transfer other stackup settings from aSettings
|
2019-07-27 19:09:43 +00:00
|
|
|
if( aSettings )
|
|
|
|
{
|
2020-12-20 18:44:13 +00:00
|
|
|
const BOARD_STACKUP& source_stackup = aSettings->GetStackupDescriptor();
|
2019-07-27 19:09:43 +00:00
|
|
|
m_EdgeConnectorConstraints = source_stackup.m_EdgeConnectorConstraints;
|
|
|
|
m_CastellatedPads = source_stackup.m_CastellatedPads;
|
2020-12-20 18:50:45 +00:00
|
|
|
m_EdgePlating = source_stackup.m_EdgePlating;
|
|
|
|
m_FinishType = source_stackup.m_FinishType;
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_STACKUP::FormatBoardStackup( OUTPUTFORMATTER* aFormatter,
|
2020-12-20 18:44:13 +00:00
|
|
|
const BOARD* aBoard, int aNestLevel ) const
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
// Board stackup is the ordered list from top to bottom of
|
|
|
|
// physical layers and substrate used to build the board.
|
|
|
|
if( m_list.empty() )
|
|
|
|
return;
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
aFormatter->Print( aNestLevel, "(stackup\n" );
|
2019-06-23 11:20:22 +00:00
|
|
|
int nest_level = aNestLevel+1;
|
|
|
|
|
2019-09-27 15:12:24 +00:00
|
|
|
// Note:
|
|
|
|
// Unspecified parameters are not stored in file.
|
2019-06-23 11:20:22 +00:00
|
|
|
for( BOARD_STACKUP_ITEM* item: m_list )
|
|
|
|
{
|
|
|
|
wxString layer_name;
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->GetBrdLayerId() == UNDEFINED_LAYER )
|
2022-02-04 22:44:59 +00:00
|
|
|
layer_name.Printf( wxT( "dielectric %d" ), item->GetDielectricLayerId() );
|
2019-06-23 11:20:22 +00:00
|
|
|
else
|
2020-09-22 21:50:59 +00:00
|
|
|
layer_name = LSET::Name( item->GetBrdLayerId() );
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
aFormatter->Print( nest_level, "(layer %s (type %s)",
|
|
|
|
aFormatter->Quotew( layer_name ).c_str(),
|
2019-11-11 18:34:48 +00:00
|
|
|
aFormatter->Quotew( item->GetTypeName() ).c_str() );
|
2019-06-23 11:20:22 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->IsColorEditable() && IsPrmSpecified( item->GetColor() ) )
|
2021-08-16 18:57:15 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
aFormatter->Print( 0, " (color %s)",
|
|
|
|
aFormatter->Quotew( item->GetColor() ).c_str() );
|
2021-08-16 18:57:15 +00:00
|
|
|
}
|
2019-11-14 15:26:05 +00:00
|
|
|
|
|
|
|
for( int idx = 0; idx < item->GetSublayersCount(); idx++ )
|
2019-07-27 19:09:43 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
if( idx ) // not for the main (first) layer.
|
|
|
|
{
|
|
|
|
aFormatter->Print( 0, "\n" );
|
|
|
|
aFormatter->Print( nest_level+1, "addsublayer" );
|
|
|
|
}
|
2019-06-23 11:20:22 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->IsThicknessEditable() )
|
|
|
|
{
|
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && item->IsThicknessLocked( idx ) )
|
|
|
|
aFormatter->Print( 0, " (thickness %s locked)",
|
|
|
|
FormatInternalUnits( item->GetThickness( idx ) ).c_str() );
|
|
|
|
else
|
|
|
|
aFormatter->Print( 0, " (thickness %s)",
|
|
|
|
FormatInternalUnits( item->GetThickness( idx ) ).c_str() );
|
|
|
|
}
|
2019-06-23 11:20:22 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->HasMaterialValue( idx ) )
|
|
|
|
aFormatter->Print( 0, " (material %s)",
|
|
|
|
aFormatter->Quotew( item->GetMaterial( idx ) ).c_str() );
|
2019-06-23 11:20:22 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->HasEpsilonRValue() && item->HasMaterialValue( idx ) )
|
|
|
|
aFormatter->Print( 0, " (epsilon_r %g)", item->GetEpsilonR( idx ) );
|
2019-06-23 11:20:22 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->HasLossTangentValue() && item->HasMaterialValue( idx ) )
|
|
|
|
aFormatter->Print( 0, " (loss_tangent %s)",
|
|
|
|
Double2Str(item->GetLossTangent( idx ) ).c_str() );
|
|
|
|
}
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
aFormatter->Print( 0, ")\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Other infos about board, related to layers and other fabrication specifications
|
2019-09-27 15:12:24 +00:00
|
|
|
if( IsPrmSpecified( m_FinishType ) )
|
2021-08-16 18:57:15 +00:00
|
|
|
{
|
2019-06-23 11:20:22 +00:00
|
|
|
aFormatter->Print( nest_level, "(copper_finish %s)\n",
|
|
|
|
aFormatter->Quotew( m_FinishType ).c_str() );
|
2021-08-16 18:57:15 +00:00
|
|
|
}
|
2019-06-23 11:20:22 +00:00
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
aFormatter->Print( nest_level, "(dielectric_constraints %s)\n",
|
2019-06-23 11:20:22 +00:00
|
|
|
m_HasDielectricConstrains ? "yes" : "no" );
|
|
|
|
|
|
|
|
if( m_EdgeConnectorConstraints > 0 )
|
2021-08-16 18:57:15 +00:00
|
|
|
{
|
2019-06-23 11:20:22 +00:00
|
|
|
aFormatter->Print( nest_level, "(edge_connector %s)\n",
|
|
|
|
m_EdgeConnectorConstraints > 1 ? "bevelled": "yes" );
|
2021-08-16 18:57:15 +00:00
|
|
|
}
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
if( m_CastellatedPads )
|
|
|
|
aFormatter->Print( nest_level, "(castellated_pads yes)\n" );
|
|
|
|
|
|
|
|
if( m_EdgePlating )
|
|
|
|
aFormatter->Print( nest_level, "(edge_plating yes)\n" );
|
|
|
|
|
|
|
|
aFormatter->Print( aNestLevel, ")\n" );
|
|
|
|
}
|
2019-09-27 15:12:24 +00:00
|
|
|
|
|
|
|
|
2021-04-04 17:58:51 +00:00
|
|
|
int BOARD_STACKUP::GetLayerDistance( PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer ) const
|
|
|
|
{
|
|
|
|
wxASSERT( IsCopperLayer( aFirstLayer ) && IsCopperLayer( aSecondLayer ) );
|
|
|
|
|
|
|
|
if( aFirstLayer == aSecondLayer )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if( aSecondLayer < aFirstLayer )
|
|
|
|
std::swap( aFirstLayer, aSecondLayer );
|
|
|
|
|
|
|
|
int total = 0;
|
2021-05-08 18:55:02 +00:00
|
|
|
bool start = false;
|
2021-05-11 01:48:50 +00:00
|
|
|
bool half = false;
|
2021-04-04 17:58:51 +00:00
|
|
|
|
|
|
|
for( BOARD_STACKUP_ITEM* item : m_list )
|
|
|
|
{
|
|
|
|
// Will be UNDEFINED_LAYER for dielectrics
|
|
|
|
PCB_LAYER_ID layer = item->GetBrdLayerId();
|
|
|
|
|
|
|
|
if( layer != UNDEFINED_LAYER && !IsCopperLayer( layer ) )
|
|
|
|
continue; // Silk/mask layer
|
2021-05-08 18:55:02 +00:00
|
|
|
|
|
|
|
// Reached the start copper layer? Start counting the next dielectric after it
|
|
|
|
if( !start && ( layer != UNDEFINED_LAYER && layer >= aFirstLayer ) )
|
|
|
|
{
|
|
|
|
start = true;
|
2021-05-11 01:48:50 +00:00
|
|
|
half = true;
|
2021-05-08 18:55:02 +00:00
|
|
|
}
|
|
|
|
else if( !start )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Reached the stop copper layer? we're done
|
|
|
|
if( start && ( layer != UNDEFINED_LAYER && layer >= aSecondLayer ) )
|
2021-05-11 01:48:50 +00:00
|
|
|
half = true;
|
2021-04-04 17:58:51 +00:00
|
|
|
|
|
|
|
for( int sublayer = 0; sublayer < item->GetSublayersCount(); sublayer++ )
|
2021-05-11 01:48:50 +00:00
|
|
|
{
|
|
|
|
int subThickness = item->GetThickness( sublayer );
|
|
|
|
total += half ? ( subThickness / 2 ) : subThickness;
|
|
|
|
}
|
|
|
|
|
|
|
|
half = false;
|
|
|
|
|
|
|
|
if( layer != UNDEFINED_LAYER && layer >= aSecondLayer )
|
|
|
|
break;
|
2021-04-04 17:58:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-27 15:12:24 +00:00
|
|
|
bool IsPrmSpecified( const wxString& aPrmValue )
|
|
|
|
{
|
|
|
|
// return true if the param value is specified:
|
|
|
|
|
|
|
|
if( !aPrmValue.IsEmpty()
|
|
|
|
&& ( aPrmValue.CmpNoCase( NotSpecifiedPrm() ) != 0 )
|
|
|
|
&& aPrmValue != wxGetTranslation( NotSpecifiedPrm() ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|