KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
24
25#include "wx/string.h"
26
27#include <base_units.h>
28#include <locale_io.h>
29
30#include "board_stackup.h"
32
34
35
36wxString BuildStackupReport( BOARD_STACKUP& aStackup, EDA_UNITS aUnits )
37{
38 // Build a ascii representation of stackup and copy it in the clipboard
39 wxString report;
40
41 wxString txt;
42 LOCALE_IO toggle; // toggles on the C locale to write floating values, then off.
43
44 for( const BOARD_STACKUP_ITEM* item : aStackup.GetList() )
45 {
46 // Skip stackup items useless for the current board
47 if( !item->IsEnabled() )
48 continue;
49
50 if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
51 {
52 wxString sublayer_text;
53
54 if( item->GetSublayersCount() )
55 {
56 sublayer_text.Printf( wxT( "\n sublayer \"1/%d\"" ),
57 item->GetSublayersCount() );
58 }
59
60 txt.Printf( wxT( "layer \"%s\" type \"%s\"%s" ),
61 item->FormatDielectricLayerName(),
62 item->GetTypeName(), sublayer_text );
63 }
64 else
65 {
66 txt.Printf( wxT( "layer \"%s\" type \"%s\"" ),
67 item->GetLayerName(),
68 item->GetTypeName() );
69 }
70
71 report << txt;
72
73 if( item->IsColorEditable() )
74 {
75 txt.Printf( wxT( " Color \"%s\"" ), item->GetColor() );
76 report << txt;
77 }
78
79 for( int idx = 0; idx < item->GetSublayersCount(); idx++ )
80 {
81 if( idx ) // not printed for the main (first) layer.
82 {
83 txt.Printf( wxT( "\n sublayer \"%d/%d\"" ), idx+1, item->GetSublayersCount() );
84 report << txt;
85 }
86
87 if( item->IsThicknessEditable() )
88 {
89 txt.Printf( wxT( " Thickness %s" ),
90 EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, aUnits, item->GetThickness( idx ), true ) );
91 report << txt;
92
93 if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && item->IsThicknessLocked( idx ) )
94 {
95 txt.Printf( wxT( " Locked" ) );
96 report << txt;
97 }
98 }
99
100 if( item->IsMaterialEditable() )
101 {
102 txt.Printf( wxT( " Material \"%s\"" ), item->GetMaterial( idx ) );
103 report << txt;
104 }
105
106 if( item->HasEpsilonRValue() )
107 {
108 txt.Printf( wxT( " EpsilonR %s" ), item->FormatEpsilonR( idx ) );
109 report << txt;
110 }
111
112 if( item->HasLossTangentValue() )
113 {
114 txt.Printf( wxT( " LossTg %s" ), item->FormatLossTangent( idx ) );
115 report << txt;
116 }
117 }
118
119 report << '\n';
120 }
121
122 // Finish and other options:
123 txt.Printf( wxT( "Finish \"%s\"" ), aStackup.m_FinishType );
124 report << txt;
125
126 if( aStackup.m_HasDielectricConstrains )
127 report << wxT( " Option \"Impedance Controlled\"" );
128
129 if( aStackup.m_EdgePlating )
130 report << wxT( " Option \"Plated edges\"" );
131
133 {
134 wxString conn_txt = wxT( "yes" );
135
137 conn_txt << wxT( ",bevelled" );
138
139 txt.Printf( wxT( " EdgeConnector \"%s\"" ), conn_txt );
140 report << txt;
141 }
142
143 report << '\n';
144
145 return report;
146
147}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
@ BS_EDGE_CONNECTOR_BEVELLED
@ BS_EDGE_CONNECTOR_NONE
@ BS_ITEM_TYPE_DIELECTRIC
wxString BuildStackupReport(BOARD_STACKUP &aStackup, EDA_UNITS aUnits)
Manage one layer needed to make a physical board.
Manage layers needed to make a physical board.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
bool m_HasDielectricConstrains
True if some layers have impedance controlled tracks or have specific constrains for micro-wave appli...
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...
wxString m_FinishType
The name of external copper finish.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
EDA_UNITS
Definition eda_units.h:44
KICOMMON_API wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Return the string from aValue according to aUnits (inch, mm ...) for display.