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  sublayer_text.Printf( "\n sublayer \"1/%d\"", item->GetSublayersCount() );
60 
61  txt.Printf( "layer \"%s\" type \"%s\"%s",
62  item->FormatDielectricLayerName(),
63  item->GetTypeName(), sublayer_text );
64  }
65  else
66  txt.Printf( "layer \"%s\" type \"%s\"", item->GetLayerName(),
67  item->GetTypeName() );
68 
69  report << txt;
70 
71  if( item->IsColorEditable() )
72  {
73  txt.Printf( " Color \"%s\"", item->GetColor() );
74  report << txt;
75  }
76 
77  for( int idx = 0; idx < item->GetSublayersCount(); idx++ )
78  {
79  if( idx ) // not printed for the main (first) layer.
80  {
81  txt.Printf( "\n sublayer \"%d/%d\"", idx+1, item->GetSublayersCount() );
82  report << txt;
83  }
84 
85  if( item->IsThicknessEditable() )
86  {
87  txt.Printf( " Thickness %s",
88  StringFromValue( aUnits, item->GetThickness( idx ), true ) );
89  report << txt;
90 
91  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && item->IsThicknessLocked( idx ) )
92  {
93  txt.Printf( " Locked" );
94  report << txt;
95  }
96  }
97 
98  if( item->IsMaterialEditable() )
99  {
100  txt.Printf( " Material \"%s\"", item->GetMaterial( idx ) );
101  report << txt;
102  }
103 
104  if( item->HasEpsilonRValue() )
105  {
106  txt.Printf( " EpsilonR %s", item->FormatEpsilonR( idx ) );
107  report << txt;
108  }
109 
110  if( item->HasLossTangentValue() )
111  {
112  txt.Printf( " LossTg %s", item->FormatLossTangent( idx ) );
113  report << txt;
114  }
115  }
116 
117  report << '\n';
118  }
119 
120  // Finish and other options:
121  txt.Printf( "Finish \"%s\"", aStackup.m_FinishType );
122  report << txt;
123 
124  if( aStackup.m_HasDielectricConstrains )
125  report << " Option \"Impedance Controlled\"";
126 
127  if( aStackup.m_EdgePlating )
128  report << " Option \"Plated edges\"";
129 
130  if( aStackup.m_CastellatedPads )
131  report << " Option \"Castellated Pads\"";
132 
134  {
135  wxString conn_txt = "yes";
136 
138  conn_txt << ",bevelled";
139 
140  txt.Printf( " EdgeConnector \"%s\"", conn_txt );
141  report << txt;
142  }
143 
144  report << '\n';
145 
146  return report;
147 
148 }
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