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