2019-09-06 09:26:27 +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) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-09-06 09:26:27 +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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file board_stackup_reporter.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wx/string.h"
|
|
|
|
|
|
|
|
#include <base_units.h>
|
2020-10-24 01:38:50 +00:00
|
|
|
#include <locale_io.h>
|
2019-09-06 09:26:27 +00:00
|
|
|
|
2021-04-16 21:07:06 +00:00
|
|
|
#include "board_stackup.h"
|
2019-09-06 09:26:27 +00:00
|
|
|
#include "stackup_predefined_prms.h"
|
|
|
|
|
|
|
|
#include "board_stackup_reporter.h"
|
|
|
|
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString BuildStackupReport( BOARD_STACKUP& aStackup, EDA_UNITS aUnits )
|
2019-09-06 09:26:27 +00:00
|
|
|
{
|
|
|
|
// Build a ascii representation of stackup and copy it in the clipboard
|
|
|
|
wxString report;
|
|
|
|
|
|
|
|
wxString txt;
|
|
|
|
LOCALE_IO toggle; // toggles on the C locale to write floating values, then off.
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
for( const BOARD_STACKUP_ITEM* item : aStackup.GetList() )
|
2019-09-06 09:26:27 +00:00
|
|
|
{
|
|
|
|
// Skip stackup items useless for the current board
|
2019-11-11 18:34:48 +00:00
|
|
|
if( !item->IsEnabled() )
|
2019-09-06 09:26:27 +00:00
|
|
|
continue;
|
2019-11-14 15:26:05 +00:00
|
|
|
|
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
|
|
|
{
|
|
|
|
wxString sublayer_text;
|
|
|
|
|
|
|
|
if( item->GetSublayersCount() )
|
2022-02-04 22:44:59 +00:00
|
|
|
{
|
|
|
|
sublayer_text.Printf( wxT( "\n sublayer \"1/%d\"" ),
|
|
|
|
item->GetSublayersCount() );
|
|
|
|
}
|
2019-11-14 15:26:05 +00:00
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
txt.Printf( wxT( "layer \"%s\" type \"%s\"%s" ),
|
|
|
|
item->FormatDielectricLayerName(),
|
|
|
|
item->GetTypeName(), sublayer_text );
|
2019-09-06 09:26:27 +00:00
|
|
|
}
|
2019-11-14 15:26:05 +00:00
|
|
|
else
|
2022-02-04 22:44:59 +00:00
|
|
|
{
|
|
|
|
txt.Printf( wxT( "layer \"%s\" type \"%s\"" ),
|
|
|
|
item->GetLayerName(),
|
2019-11-14 15:26:05 +00:00
|
|
|
item->GetTypeName() );
|
2022-02-04 22:44:59 +00:00
|
|
|
}
|
2019-09-06 09:26:27 +00:00
|
|
|
|
|
|
|
report << txt;
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->IsColorEditable() )
|
2019-09-06 09:26:27 +00:00
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
txt.Printf( wxT( " Color \"%s\"" ), item->GetColor() );
|
2019-09-06 09:26:27 +00:00
|
|
|
report << txt;
|
|
|
|
}
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
for( int idx = 0; idx < item->GetSublayersCount(); idx++ )
|
2019-09-06 09:26:27 +00:00
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
if( idx ) // not printed for the main (first) layer.
|
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
txt.Printf( wxT( "\n sublayer \"%d/%d\"" ), idx+1, item->GetSublayersCount() );
|
2019-11-14 15:26:05 +00:00
|
|
|
report << txt;
|
|
|
|
}
|
2019-09-06 09:26:27 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->IsThicknessEditable() )
|
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
txt.Printf( wxT( " Thickness %s" ),
|
2022-09-16 04:38:10 +00:00
|
|
|
EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, aUnits, item->GetThickness( idx ), true ) );
|
2019-11-14 15:26:05 +00:00
|
|
|
report << txt;
|
2019-09-06 09:26:27 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && item->IsThicknessLocked( idx ) )
|
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
txt.Printf( wxT( " Locked" ) );
|
2019-11-14 15:26:05 +00:00
|
|
|
report << txt;
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 09:26:27 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->IsMaterialEditable() )
|
2019-09-06 09:26:27 +00:00
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
txt.Printf( wxT( " Material \"%s\"" ), item->GetMaterial( idx ) );
|
2019-09-06 09:26:27 +00:00
|
|
|
report << txt;
|
|
|
|
}
|
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->HasEpsilonRValue() )
|
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
txt.Printf( wxT( " EpsilonR %s" ), item->FormatEpsilonR( idx ) );
|
2019-11-14 15:26:05 +00:00
|
|
|
report << txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->HasLossTangentValue() )
|
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
txt.Printf( wxT( " LossTg %s" ), item->FormatLossTangent( idx ) );
|
2019-11-14 15:26:05 +00:00
|
|
|
report << txt;
|
|
|
|
}
|
2019-09-06 09:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
report << '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finish and other options:
|
2022-02-04 22:44:59 +00:00
|
|
|
txt.Printf( wxT( "Finish \"%s\"" ), aStackup.m_FinishType );
|
2019-09-06 09:26:27 +00:00
|
|
|
report << txt;
|
|
|
|
|
|
|
|
if( aStackup.m_HasDielectricConstrains )
|
2022-02-04 22:44:59 +00:00
|
|
|
report << wxT( " Option \"Impedance Controlled\"" );
|
2019-09-06 09:26:27 +00:00
|
|
|
|
|
|
|
if( aStackup.m_EdgePlating )
|
2022-02-04 22:44:59 +00:00
|
|
|
report << wxT( " Option \"Plated edges\"" );
|
2019-09-06 09:26:27 +00:00
|
|
|
|
|
|
|
if( aStackup.m_CastellatedPads )
|
2022-02-04 22:44:59 +00:00
|
|
|
report << wxT( " Option \"Castellated Pads\"" );
|
2019-09-06 09:26:27 +00:00
|
|
|
|
|
|
|
if( aStackup.m_EdgeConnectorConstraints != BS_EDGE_CONNECTOR_NONE )
|
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
wxString conn_txt = wxT( "yes" );
|
2019-09-06 09:26:27 +00:00
|
|
|
|
|
|
|
if( aStackup.m_EdgeConnectorConstraints == BS_EDGE_CONNECTOR_BEVELLED )
|
2022-02-04 22:44:59 +00:00
|
|
|
conn_txt << wxT( ",bevelled" );
|
2019-09-06 09:26:27 +00:00
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
txt.Printf( wxT( " EdgeConnector \"%s\"" ), conn_txt );
|
2019-09-06 09:26:27 +00:00
|
|
|
report << txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
report << '\n';
|
|
|
|
|
|
|
|
return report;
|
|
|
|
|
|
|
|
}
|