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() )
|
|
|
|
sublayer_text.Printf( "\n sublayer \"1/%d\"", item->GetSublayersCount() );
|
|
|
|
|
|
|
|
txt.Printf( "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
|
|
|
|
txt.Printf( "layer \"%s\" type \"%s\"", item->GetLayerName(),
|
|
|
|
item->GetTypeName() );
|
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
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
txt.Printf( " 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.
|
|
|
|
{
|
|
|
|
txt.Printf( "\n sublayer \"%d/%d\"", idx+1, item->GetSublayersCount() );
|
|
|
|
report << txt;
|
|
|
|
}
|
2019-09-06 09:26:27 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
if( item->IsThicknessEditable() )
|
|
|
|
{
|
|
|
|
txt.Printf( " Thickness %s",
|
2020-10-02 20:51:24 +00:00
|
|
|
StringFromValue( 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 ) )
|
|
|
|
{
|
|
|
|
txt.Printf( " Locked" );
|
|
|
|
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
|
|
|
{
|
2019-11-14 15:26:05 +00:00
|
|
|
txt.Printf( " 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() )
|
|
|
|
{
|
|
|
|
txt.Printf( " EpsilonR %s", item->FormatEpsilonR( idx ) );
|
|
|
|
report << txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->HasLossTangentValue() )
|
|
|
|
{
|
|
|
|
txt.Printf( " LossTg %s", item->FormatLossTangent( idx ) );
|
|
|
|
report << txt;
|
|
|
|
}
|
2019-09-06 09:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
report << '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finish and other options:
|
|
|
|
txt.Printf( "Finish \"%s\"", aStackup.m_FinishType );
|
|
|
|
report << txt;
|
|
|
|
|
|
|
|
if( aStackup.m_HasDielectricConstrains )
|
|
|
|
report << " Option \"Impedance Controlled\"";
|
|
|
|
|
|
|
|
if( aStackup.m_EdgePlating )
|
|
|
|
report << " Option \"Plated edges\"";
|
|
|
|
|
|
|
|
if( aStackup.m_CastellatedPads )
|
|
|
|
report << " Option \"Castellated Pads\"";
|
|
|
|
|
|
|
|
if( aStackup.m_EdgeConnectorConstraints != BS_EDGE_CONNECTOR_NONE )
|
|
|
|
{
|
|
|
|
wxString conn_txt = "yes";
|
|
|
|
|
|
|
|
if( aStackup.m_EdgeConnectorConstraints == BS_EDGE_CONNECTOR_BEVELLED )
|
|
|
|
conn_txt << ",bevelled";
|
|
|
|
|
|
|
|
txt.Printf( " EdgeConnector \"%s\"", conn_txt );
|
|
|
|
report << txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
report << '\n';
|
|
|
|
|
|
|
|
return report;
|
|
|
|
|
|
|
|
}
|