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 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 
33 #include "class_board_stackup.h"
35 
36 #include "board_stackup_reporter.h"
37 
38 
39 wxString BuildStackupReport( BOARD_STACKUP& aStackup, EDA_UNITS aUnits )
40 {
41  // Build a ascii representation of stackup and copy it in the clipboard
42  wxString report;
43 
44  wxString txt;
45  LOCALE_IO toggle; // toggles on the C locale to write floating values, then off.
46 
47  for( const BOARD_STACKUP_ITEM* item : aStackup.GetList() )
48  {
49  // Skip stackup items useless for the current board
50  if( !item->IsEnabled() )
51  continue;
52 
53  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
54  {
55  wxString sublayer_text;
56 
57  if( item->GetSublayersCount() )
58  sublayer_text.Printf( "\n sublayer \"1/%d\"", item->GetSublayersCount() );
59 
60  txt.Printf( "layer \"%s\" type \"%s\"%s",
61  item->FormatDielectricLayerName(),
62  item->GetTypeName(), sublayer_text );
63  }
64  else
65  txt.Printf( "layer \"%s\" type \"%s\"", item->GetLayerName(),
66  item->GetTypeName() );
67 
68  report << txt;
69 
70  if( item->IsColorEditable() )
71  {
72  txt.Printf( " Color \"%s\"", item->GetColor() );
73  report << txt;
74  }
75 
76  for( int idx = 0; idx < item->GetSublayersCount(); idx++ )
77  {
78  if( idx ) // not printed for the main (first) layer.
79  {
80  txt.Printf( "\n sublayer \"%d/%d\"", idx+1, item->GetSublayersCount() );
81  report << txt;
82  }
83 
84  if( item->IsThicknessEditable() )
85  {
86  txt.Printf( " Thickness %s",
87  StringFromValue( aUnits, item->GetThickness( idx ), true, true ) );
88  report << txt;
89 
90  if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && item->IsThicknessLocked( idx ) )
91  {
92  txt.Printf( " Locked" );
93  report << txt;
94  }
95  }
96 
97  if( item->IsMaterialEditable() )
98  {
99  txt.Printf( " Material \"%s\"", item->GetMaterial( idx ) );
100  report << txt;
101  }
102 
103  if( item->HasEpsilonRValue() )
104  {
105  txt.Printf( " EpsilonR %s", item->FormatEpsilonR( idx ) );
106  report << txt;
107  }
108 
109  if( item->HasLossTangentValue() )
110  {
111  txt.Printf( " LossTg %s", item->FormatLossTangent( idx ) );
112  report << txt;
113  }
114  }
115 
116  report << '\n';
117  }
118 
119  // Finish and other options:
120  txt.Printf( "Finish \"%s\"", aStackup.m_FinishType );
121  report << txt;
122 
123  if( aStackup.m_HasDielectricConstrains )
124  report << " Option \"Impedance Controlled\"";
125 
126  if( aStackup.m_EdgePlating )
127  report << " Option \"Plated edges\"";
128 
129  if( aStackup.m_CastellatedPads )
130  report << " Option \"Castellated Pads\"";
131 
133  {
134  wxString conn_txt = "yes";
135 
137  conn_txt << ",bevelled";
138 
139  txt.Printf( " EdgeConnector \"%s\"", conn_txt );
140  report << txt;
141  }
142 
143  report << '\n';
144 
145  return report;
146 
147 }
EDA_UNITS
Definition: common.h:198
std::vector< BOARD_STACKUP_ITEM * > & GetList()
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
this class manage the layers needed to make a physical board they are solder mask,...
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 specifed in job file: BS_EDGE_CONNECTOR...
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)
this class manage one layer needed to make a physical board it can be a solder mask,...
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils, EDA_DATA_TYPE aType)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:233