KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_characteristics_table.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
25#include <board.h>
27#include <board_item.h>
28#include <pcb_table.h>
29#include <pcb_tablecell.h>
30#include <pcb_edit_frame.h>
32
33
35{
36 BOARD_DESIGN_SETTINGS& settings = aBoard->GetDesignSettings();
37 BOARD_STACKUP& stackup = settings.GetStackupDescriptor();
38 UNITS_PROVIDER units_provider( pcbIUScale, aDisplayUnits );
39
40 stackup.SynchronizeWithBoard( &settings );
41
42 BOARD_STATISTICS_DATA brd_stat_data;
44 ComputeBoardStatistics( aBoard, opts, brd_stat_data );
45
46 PCB_TABLE* table = new PCB_TABLE( aBoard, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) );
47 table->SetColCount( 4 );
48
49 auto addHeaderCell =
50 [&]( const wxString& text )
51 {
53 c->SetTextSize( VECTOR2I( pcbIUScale.mmToIU( 2.0 ), pcbIUScale.mmToIU( 2.0 ) ) );
54 c->SetTextThickness( pcbIUScale.mmToIU( 0.4 ) );
55 c->SetText( text );
56 c->SetColSpan( table->GetColCount() );
57 table->AddCell( c );
58 };
59
60 auto addDataCell =
61 [&]( const wxString& text )
62 {
64 c->SetTextSize( VECTOR2I( pcbIUScale.mmToIU( 1.5 ), pcbIUScale.mmToIU( 1.5 ) ) );
65 c->SetTextThickness( pcbIUScale.mmToIU( 0.2 ) );
66 c->SetText( text );
67 table->AddCell( c );
68 };
69
70 addHeaderCell( _( "BOARD CHARACTERISTICS" ) );
71
72 for( int col = 1; col < table->GetColCount(); ++col )
73 {
74 addHeaderCell( wxEmptyString );
75 table->GetCell( 0, col )->SetColSpan( 0 );
76 }
77
78 addDataCell( _( "Copper layer count: " ) );
80 settings.GetCopperLayerCount(), false ) );
81
82 addDataCell( _( "Board thickness: " ) );
83 addDataCell( units_provider.MessageTextFromValue( brd_stat_data.boardThickness, true ) );
84
85 SHAPE_POLY_SET outline;
86 aBoard->GetBoardPolygonOutlines( outline );
87 BOX2I size = outline.BBox();
88
89 addDataCell( _( "Board overall dimensions: " ) );
90 addDataCell( wxString::Format( wxT( "%s x %s" ),
91 units_provider.MessageTextFromValue( size.GetWidth(), true ),
92 units_provider.MessageTextFromValue( size.GetHeight(), true ) ) );
93
94 addDataCell( wxEmptyString );
95 addDataCell( wxEmptyString );
96
97 addDataCell( _( "Min track/spacing: " ) );
98 addDataCell( wxString::Format( wxT( "%s / %s" ),
99 units_provider.MessageTextFromValue( brd_stat_data.minTrackWidth, true ),
100 units_provider.MessageTextFromValue( brd_stat_data.minClearanceTrackToTrack, true ) ) );
101
102 double min_holeSize = brd_stat_data.minDrillSize;
103
104 addDataCell( _( "Min hole diameter: " ) );
105 addDataCell( units_provider.MessageTextFromValue( min_holeSize, true ) );
106
107 addDataCell( _( "Copper finish: " ) );
108 addDataCell( stackup.m_FinishType );
109
110 addDataCell( _( "Impedance control: " ) );
111 addDataCell( stackup.m_HasDielectricConstrains ? _( "Yes" ) : _( "No" ) );
112
113 addDataCell( _( "Castellated pads: " ) );
114 int castellated_pad_count = aBoard->GetPadWithCastellatedAttrCount();
115 addDataCell( castellated_pad_count ? _( "Yes" ) : _( "No" ) );
116
117 addDataCell( _( "Press-fit pads: " ) );
118 int pressfit_pad_count = aBoard->GetPadWithPressFitAttrCount();
119 addDataCell( pressfit_pad_count ? _( "Yes" ) : _( "No" ) );
120
121 addDataCell( _( "Plated board edge: " ) );
122 addDataCell( stackup.m_EdgePlating ? _( "Yes" ) : _( "No" ) );
123
124 wxString msg;
125
126 switch( stackup.m_EdgeConnectorConstraints )
127 {
128 case BS_EDGE_CONNECTOR_NONE: msg = _( "No" ); break;
129 case BS_EDGE_CONNECTOR_IN_USE: msg = _( "Yes" ); break;
130 case BS_EDGE_CONNECTOR_BEVELLED: msg = _( "Yes, Bevelled" ); break;
131 }
132
133 addDataCell( _( "Edge card connectors: " ) );
134 addDataCell( msg );
135
136 // We are building a table having 4 columns.
137 // So we must have a cell count multible of 4, to have fully build row.
138 // Othewise the table is really badly drawn.
139 std::vector<PCB_TABLECELL*> cells_list = table->GetCells();
140 int cell_to_add_cnt = cells_list.size() % table->GetColCount();
141
142 for( int ii = 0; ii < cell_to_add_cnt; ii++ )
143 addDataCell( wxEmptyString );
144
145 table->SetStrokeExternal( false );
146 table->SetStrokeHeaderSeparator( false );
147 table->SetStrokeColumns( false );
148 table->SetStrokeRows( false );
149 table->Autosize();
150
151 return table;
152}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
constexpr EDA_IU_SCALE unityScale
Definition base_units.h:115
PCB_TABLE * Build_Board_Characteristics_Table(BOARD *aBoard, EDA_UNITS aDisplayUnits)
#define DEFAULT_LINE_WIDTH
@ BS_EDGE_CONNECTOR_BEVELLED
@ BS_EDGE_CONNECTOR_NONE
@ BS_EDGE_CONNECTOR_IN_USE
void ComputeBoardStatistics(BOARD *aBoard, const BOARD_STATISTICS_OPTIONS &aOptions, BOARD_STATISTICS_DATA &aData)
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
Container for design settings for a BOARD object.
BOARD_STACKUP & GetStackupDescriptor()
Manage layers needed to make a physical board.
bool SynchronizeWithBoard(BOARD_DESIGN_SETTINGS *aSettings)
Synchronize the BOARD_STACKUP_ITEM* list with the board.
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.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr, bool aAllowUseArcsInPolygons=false, bool aIncludeNPTHAsOutlines=false)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
Definition board.cpp:2787
int GetPadWithCastellatedAttrCount()
Definition board.cpp:3413
int GetPadWithPressFitAttrCount()
Definition board.cpp:3395
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1041
constexpr size_type GetWidth() const
Definition box2.h:214
constexpr size_type GetHeight() const
Definition box2.h:215
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:544
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition eda_text.cpp:295
virtual void SetText(const wxString &aText)
Definition eda_text.cpp:281
void SetColSpan(int aSpan)
Represent a set of closed polygons.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
#define _(s)
EDA_UNITS
Definition eda_units.h:48
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.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695