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, see <https://www.gnu.org/licenses/>.
18 */
19
20
21#include <board.h>
24#include <board_item.h>
25#include <pcb_table.h>
26#include <pcb_tablecell.h>
27#include <pcb_edit_frame.h>
29
30
32{
33 BOARD_DESIGN_SETTINGS& settings = aBoard->GetDesignSettings();
34 BOARD_STACKUP& stackup = settings.GetStackupDescriptor();
35 UNITS_PROVIDER units_provider( pcbIUScale, aDisplayUnits );
36
37 stackup.SynchronizeWithBoard( &settings );
38
39 BOARD_STATISTICS_DATA brd_stat_data;
41 ComputeBoardStatistics( aBoard, opts, brd_stat_data );
42
43 PCB_TABLE* table = new PCB_TABLE( aBoard, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) );
44 table->SetColCount( 4 );
45
46 auto addHeaderCell =
47 [&]( const wxString& text )
48 {
50 c->SetTextSize( VECTOR2I( pcbIUScale.mmToIU( 2.0 ), pcbIUScale.mmToIU( 2.0 ) ) );
51 c->SetTextThickness( pcbIUScale.mmToIU( 0.4 ) );
52 c->SetText( text );
53 c->SetColSpan( table->GetColCount() );
54 table->AddCell( c );
55 };
56
57 auto addDataCell =
58 [&]( const wxString& text )
59 {
61 c->SetTextSize( VECTOR2I( pcbIUScale.mmToIU( 1.5 ), pcbIUScale.mmToIU( 1.5 ) ) );
62 c->SetTextThickness( pcbIUScale.mmToIU( 0.2 ) );
63 c->SetText( text );
64 table->AddCell( c );
65 };
66
67 addHeaderCell( _( "BOARD CHARACTERISTICS" ) );
68
69 for( int col = 1; col < table->GetColCount(); ++col )
70 {
71 addHeaderCell( wxEmptyString );
72 table->GetCell( 0, col )->SetColSpan( 0 );
73 }
74
75 addDataCell( _( "Copper layer count: " ) );
77 settings.GetCopperLayerCount(), false ) );
78
79 addDataCell( _( "Board thickness: " ) );
80 addDataCell( units_provider.MessageTextFromValue( brd_stat_data.boardThickness, true ) );
81
82 SHAPE_POLY_SET outline;
83 aBoard->GetBoardPolygonOutlines( outline, false );
84 BOX2I size = outline.BBox();
85
86 addDataCell( _( "Board overall dimensions: " ) );
87 addDataCell( wxString::Format( wxT( "%s x %s" ),
88 units_provider.MessageTextFromValue( size.GetWidth(), true ),
89 units_provider.MessageTextFromValue( size.GetHeight(), true ) ) );
90
91 addDataCell( wxEmptyString );
92 addDataCell( wxEmptyString );
93
94 addDataCell( _( "Min track/spacing: " ) );
95 addDataCell( wxString::Format( wxT( "%s / %s" ),
96 units_provider.MessageTextFromValue( brd_stat_data.minTrackWidth, true ),
97 units_provider.MessageTextFromValue( brd_stat_data.minClearanceTrackToTrack, true ) ) );
98
99 double min_holeSize = brd_stat_data.minDrillSize;
100
101 addDataCell( _( "Min hole diameter: " ) );
102 addDataCell( units_provider.MessageTextFromValue( min_holeSize, true ) );
103
104 addDataCell( _( "Copper finish: " ) );
105 addDataCell( stackup.m_FinishType );
106
107 addDataCell( _( "Impedance control: " ) );
108 addDataCell( stackup.m_HasDielectricConstrains ? _( "Yes" ) : _( "No" ) );
109
110 addDataCell( _( "Castellated pads: " ) );
111 int castellated_pad_count = aBoard->GetPadWithCastellatedAttrCount();
112 addDataCell( castellated_pad_count ? _( "Yes" ) : _( "No" ) );
113
114 addDataCell( _( "Press-fit pads: " ) );
115 int pressfit_pad_count = aBoard->GetPadWithPressFitAttrCount();
116 addDataCell( pressfit_pad_count ? _( "Yes" ) : _( "No" ) );
117
118 addDataCell( _( "Plated board edge: " ) );
119 addDataCell( stackup.m_EdgePlating ? _( "Yes" ) : _( "No" ) );
120
121 wxString msg;
122
123 switch( stackup.m_EdgeConnectorConstraints )
124 {
125 case BS_EDGE_CONNECTOR_NONE: msg = _( "No" ); break;
126 case BS_EDGE_CONNECTOR_IN_USE: msg = _( "Yes" ); break;
127 case BS_EDGE_CONNECTOR_BEVELLED: msg = _( "Yes, Bevelled" ); break;
128 }
129
130 addDataCell( _( "Edge card connectors: " ) );
131 addDataCell( msg );
132
133 // We are building a table having 4 columns.
134 // So we must have a cell count multible of 4, to have fully build row.
135 // Othewise the table is really badly drawn.
136 std::vector<PCB_TABLECELL*> cells_list = table->GetCells();
137 int cell_to_add_cnt = cells_list.size() % table->GetColCount();
138
139 for( int ii = 0; ii < cell_to_add_cnt; ii++ )
140 addDataCell( wxEmptyString );
141
142 table->SetStrokeExternal( false );
143 table->SetStrokeHeaderSeparator( false );
144 table->SetStrokeColumns( false );
145 table->SetStrokeRows( false );
146 table->Autosize();
147 table->SetPosition( VECTOR2I( 0, 0 ) );
148
149 return table;
150}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
constexpr EDA_IU_SCALE unityScale
Definition base_units.h:131
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:914
Container for design settings for a BOARD object.
BOARD_STACKUP & GetStackupDescriptor()
Manage layers needed to make a physical board.
bool SynchronizeWithBoard(const 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:411
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, bool aInferOutlineIfNecessary, 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:3604
int GetPadWithCastellatedAttrCount()
Definition board.cpp:4329
int GetPadWithPressFitAttrCount()
Definition board.cpp:4311
BOARD_DESIGN_SETTINGS & GetDesignSettings()
Definition board.cpp:1290
constexpr size_type GetWidth() const
Definition box2.h:211
constexpr size_type GetHeight() const
Definition box2.h:212
virtual void SetText(const wxString &aText)
Definition eda_text.cpp:236
void SetColSpan(int aSpan)
void SetTextThickness(int aWidth) override
The TextThickness is that set by the user.
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true) override
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: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.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708