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
|
|
|
|
* Copyright (C) 2009-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "class_board_stackup.h"
|
|
|
|
#include <convert_to_biu.h>
|
|
|
|
#include <base_units.h>
|
|
|
|
#include <layers_id_colors_and_visibility.h>
|
|
|
|
#include <board_design_settings.h>
|
|
|
|
#include <class_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:
|
2019-09-06 18:59:13 +00:00
|
|
|
m_TypeName = KEY_CORE; // or prepreg
|
2019-11-11 18:34:48 +00:00
|
|
|
SetMaterial( "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:
|
|
|
|
m_TypeName = "solderpaste";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_SOLDERMASK:
|
|
|
|
m_TypeName = "soldermask";
|
2019-09-24 12:33:28 +00:00
|
|
|
m_Color = "Green";
|
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:
|
|
|
|
m_TypeName = "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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM& aOther )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
m_DielectricPrmsList.emplace( m_DielectricPrmsList.begin() + aDielectricPrmsIdx,
|
|
|
|
new_prms );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_STACKUP_ITEM::RemoveDielectricPrms( int aDielectricPrmsIdx )
|
|
|
|
{
|
|
|
|
// Remove a DIELECTRIC_PRMS item from m_DielectricPrmsList if possible
|
|
|
|
|
|
|
|
if( GetSublayersCount() < 2 || aDielectricPrmsIdx < 0 || aDielectricPrmsIdx >= GetSublayersCount() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|| 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::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
|
2019-11-14 15:26:05 +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
|
|
|
{
|
|
|
|
// The material is editable only for dielectric
|
2019-09-24 12:33:28 +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
|
|
|
{
|
|
|
|
return m_Type == BS_ITEM_TYPE_SOLDERMASK || m_Type == BS_ITEM_TYPE_SILKSCREEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
bool BOARD_STACKUP_ITEM::IsThicknessEditable() const
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
|
|
|
switch( m_Type )
|
|
|
|
{
|
|
|
|
case BS_ITEM_TYPE_COPPER:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_DIELECTRIC:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_SOLDERMASK:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_SOLDERPASTE:
|
|
|
|
return false;
|
|
|
|
|
|
|
|
case BS_ITEM_TYPE_SILKSCREEN:
|
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
wxString txt;
|
2019-11-14 15:26:05 +00:00
|
|
|
txt.Printf( "%.1f", 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
|
|
|
|
wxString txt;
|
2019-11-14 15:26:05 +00:00
|
|
|
txt.Printf( "%g", 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
|
|
|
{
|
|
|
|
// return a wxString to print/display a dielectriv name
|
|
|
|
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
|
|
|
|
m_FinishType = "None"; // undefined finish type
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOARD_STACKUP::BOARD_STACKUP( BOARD_STACKUP& aOther )
|
|
|
|
{
|
|
|
|
m_HasDielectricConstrains = aOther.m_HasDielectricConstrains;
|
|
|
|
m_EdgeConnectorConstraints = aOther.m_EdgeConnectorConstraints;
|
|
|
|
m_CastellatedPads = aOther.m_CastellatedPads;
|
|
|
|
m_EdgePlating = aOther.m_EdgePlating;
|
|
|
|
m_FinishType = aOther.m_FinishType;
|
|
|
|
|
|
|
|
// All items in aOther.m_list have to be duplicated, because aOther.m_list
|
|
|
|
// manage pointers to these items
|
|
|
|
for( auto item : aOther.m_list )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* dup_item = new BOARD_STACKUP_ITEM( *item );
|
|
|
|
Add( dup_item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOARD_STACKUP& BOARD_STACKUP::operator=( const BOARD_STACKUP& aOther )
|
|
|
|
{
|
|
|
|
m_HasDielectricConstrains = aOther.m_HasDielectricConstrains;
|
|
|
|
m_EdgeConnectorConstraints = aOther.m_EdgeConnectorConstraints;
|
|
|
|
m_CastellatedPads = aOther.m_CastellatedPads;
|
|
|
|
m_EdgePlating = aOther.m_EdgePlating;
|
|
|
|
m_FinishType = aOther.m_FinishType;
|
|
|
|
|
|
|
|
RemoveAll();
|
|
|
|
|
|
|
|
// All items in aOther.m_list have to be duplicated, because aOther.m_list
|
|
|
|
// manage pointers to these items
|
|
|
|
for( auto item : aOther.m_list )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP_ITEM* dup_item = new BOARD_STACKUP_ITEM( *item );
|
|
|
|
Add( dup_item );
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_STACKUP::RemoveAll()
|
|
|
|
{
|
|
|
|
for( auto item : m_list )
|
|
|
|
delete item;
|
|
|
|
|
|
|
|
m_list.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOARD_STACKUP_ITEM* BOARD_STACKUP::GetStackupLayer( int aIndex )
|
|
|
|
{
|
|
|
|
if( aIndex < 0 || aIndex >= GetCount() )
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return GetList()[aIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int BOARD_STACKUP::BuildBoardTicknessFromStackup() const
|
|
|
|
{
|
|
|
|
// return the board thickness from the thickness of BOARD_STACKUP_ITEM list
|
|
|
|
int thickness = 0;
|
|
|
|
|
|
|
|
for( auto item : m_list )
|
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
if( item->IsThicknessEditable() && item->IsEnabled() )
|
|
|
|
thickness += item->GetThickness();
|
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
|
|
|
|
for( BOARD_STACKUP_ITEM* item: stackup.GetList() )
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
// Search for initial settings:
|
|
|
|
for( BOARD_STACKUP_ITEM* initial_item: m_list )
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Transfer other stackup settings from aSettings
|
|
|
|
BOARD_STACKUP& source_stackup = aSettings->GetStackupDescriptor();
|
|
|
|
m_HasDielectricConstrains = source_stackup.m_HasDielectricConstrains;
|
|
|
|
m_EdgeConnectorConstraints = source_stackup.m_EdgeConnectorConstraints;
|
|
|
|
m_CastellatedPads = source_stackup.m_CastellatedPads;
|
|
|
|
m_EdgePlating = source_stackup.m_EdgePlating;
|
|
|
|
m_FinishType = source_stackup.m_FinishType;
|
|
|
|
|
|
|
|
*this = stackup;
|
|
|
|
|
|
|
|
return change;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
void BOARD_STACKUP::BuildDefaultStackupList( BOARD_DESIGN_SETTINGS* aSettings,
|
|
|
|
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;
|
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 );
|
|
|
|
item->SetMaterial( "FR4" );
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
item->SetTypeName( KEY_PREPREG );
|
|
|
|
item->SetMaterial( "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 )
|
|
|
|
{
|
|
|
|
BOARD_STACKUP& source_stackup = aSettings->GetStackupDescriptor();
|
|
|
|
m_HasDielectricConstrains = source_stackup.m_HasDielectricConstrains;
|
|
|
|
m_EdgeConnectorConstraints = source_stackup.m_EdgeConnectorConstraints;
|
|
|
|
m_CastellatedPads = source_stackup.m_CastellatedPads;
|
|
|
|
m_EdgePlating = source_stackup.m_EdgePlating;
|
|
|
|
m_FinishType = source_stackup.m_FinishType;
|
|
|
|
}
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_STACKUP::FormatBoardStackup( OUTPUTFORMATTER* aFormatter,
|
|
|
|
BOARD* aBoard, int aNestLevel ) const
|
|
|
|
{
|
|
|
|
// 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 )
|
2019-06-23 11:20:22 +00:00
|
|
|
{
|
2019-11-11 18:34:48 +00:00
|
|
|
layer_name.Printf( "dielectric %d", item->GetDielectricLayerId() );
|
2019-06-23 11:20:22 +00:00
|
|
|
}
|
|
|
|
else
|
2019-11-11 18:34:48 +00:00
|
|
|
layer_name = aBoard->GetLayerName( 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() ) )
|
|
|
|
aFormatter->Print( 0, " (color %s)",
|
|
|
|
aFormatter->Quotew( item->GetColor() ).c_str() );
|
|
|
|
|
|
|
|
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 ) )
|
2019-06-23 11:20:22 +00:00
|
|
|
aFormatter->Print( nest_level, "(copper_finish %s)\n",
|
|
|
|
aFormatter->Quotew( m_FinishType ).c_str() );
|
|
|
|
|
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 )
|
|
|
|
aFormatter->Print( nest_level, "(edge_connector %s)\n",
|
|
|
|
m_EdgeConnectorConstraints > 1 ? "bevelled": "yes" );
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|