KiCad PCB EDA Suite
board_stackup_reporter.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
29 #include "wx/string.h"
30 
31 #include <base_units.h>
32 #include <locale_io.h>
33 
34 #include "board_stackup.h"
36 
37 #include "board_stackup_reporter.h"
38 
39 
40 wxString BuildStackupReport( BOARD_STACKUP& aStackup, EDA_UNITS aUnits )
41 {
42  // Build a ascii representation of stackup and copy it in the clipboard
43  wxString report;
44 
45  wxString txt;
46  LOCALE_IO toggle; // toggles on the C locale to write floating values, then off.
47 
48  for( const BOARD_STACKUP_ITEM* item : aStackup.GetList() )
49  {
50  // Skip stackup items useless for the current board
51  if( !item->IsEnabled() )
52  continue;
53 
54  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
55  {
56  wxString sublayer_text;
57 
58  if( item->GetSublayersCount() )
59  {
60  sublayer_text.Printf( wxT( "\n sublayer \"1/%d\"" ),
61  item->GetSublayersCount() );
62  }
63 
64  txt.Printf( wxT( "layer \"%s\" type \"%s\"%s" ),
65  item->FormatDielectricLayerName(),
66  item->GetTypeName(), sublayer_text );
67  }
68  else
69  {
70  txt.Printf( wxT( "layer \"%s\" type \"%s\"" ),
71  item->GetLayerName(),
72  item->GetTypeName() );
73  }
74 
75  report << txt;
76 
77  if( item->IsColorEditable() )
78  {
79  txt.Printf( wxT( " Color \"%s\"" ), item->GetColor() );
80  report << txt;
81  }
82 
83  for( int idx = 0; idx < item->GetSublayersCount(); idx++ )
84  {
85  if( idx ) // not printed for the main (first) layer.
86  {
87  txt.Printf( wxT( "\n sublayer \"%d/%d\"" ), idx+1, item->GetSublayersCount() );
88  report << txt;
89  }
90 
91  if( item->IsThicknessEditable() )
92  {
93  txt.Printf( wxT( " Thickness %s" ),
94  StringFromValue( aUnits, item->GetThickness( idx ), true ) );
95  report << txt;
96 
97  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && item->IsThicknessLocked( idx ) )
98  {
99  txt.Printf( wxT( " Locked" ) );
100  report << txt;
101  }
102  }
103 
104  if( item->IsMaterialEditable() )
105  {
106  txt.Printf( wxT( " Material \"%s\"" ), item->GetMaterial( idx ) );
107  report << txt;
108  }
109 
110  if( item->HasEpsilonRValue() )
111  {
112  txt.Printf( wxT( " EpsilonR %s" ), item->FormatEpsilonR( idx ) );
113  report << txt;
114  }
115 
116  if( item->HasLossTangentValue() )
117  {
118  txt.Printf( wxT( " LossTg %s" ), item->FormatLossTangent( idx ) );
119  report << txt;
120  }
121  }
122 
123  report << '\n';
124  }
125 
126  // Finish and other options:
127  txt.Printf( wxT( "Finish \"%s\"" ), aStackup.m_FinishType );
128  report << txt;
129 
130  if( aStackup.m_HasDielectricConstrains )
131  report << wxT( " Option \"Impedance Controlled\"" );
132 
133  if( aStackup.m_EdgePlating )
134  report << wxT( " Option \"Plated edges\"" );
135 
136  if( aStackup.m_CastellatedPads )
137  report << wxT( " Option \"Castellated Pads\"" );
138 
140  {
141  wxString conn_txt = wxT( "yes" );
142 
144  conn_txt << wxT( ",bevelled" );
145 
146  txt.Printf( wxT( " EdgeConnector \"%s\"" ), conn_txt );
147  report << txt;
148  }
149 
150  report << '\n';
151 
152  return report;
153 
154 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
Manage layers needed to make a physical board.
Implementation of conversion functions that require both schematic and board internal units.
wxString m_FinishType
The name of external copper finish.
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_CastellatedPads
True if castellated pads exist.
bool m_HasDielectricConstrains
True if some layers have impedance controlled tracks or have specific constrains for micro-wave appli...
wxString BuildStackupReport(BOARD_STACKUP &aStackup, EDA_UNITS aUnits)
Manage one layer needed to make a physical board.
Definition: board_stackup.h:89
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
EDA_UNITS
Definition: eda_units.h:38
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:204