KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_stackup_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#include <pcb_stackup_table.h>
21
22#include <base_units.h>
25#include <pcb_tablecell.h>
28#include <api/board/board_types.pb.h>
29
30
38
39
40wxString PCB_STACKUP_TABLE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
41{
42 return wxString::Format( _( "Stackup Table (%d rows)" ), GetRowCount() );
43}
44
45
46bool PCB_STACKUP_TABLE::operator==( const BOARD_ITEM& aOther ) const
47{
48 if( aOther.Type() != Type() )
49 return false;
50
51 return generatedEquals( static_cast<const PCB_STACKUP_TABLE&>( aOther ) );
52}
53
54
55std::unique_ptr<GENERATED_TABLE_CONTENT> PCB_STACKUP_TABLE::generate( const BOARD& aBoard,
56 GENERATED_TABLE_REFRESH* aRefresh ) const
57{
58 auto content = std::make_unique<GENERATED_TABLE_CONTENT>();
59 content->m_Rows = BuildStackupTableRows( aBoard, m_columns, m_units, m_precision );
60
61 return content;
62}
63
64
65void PCB_STACKUP_TABLE::styleNewCell( PCB_TABLECELL* aCell, bool aIsHeading )
66{
67 aCell->SetTextSize( VECTOR2I( pcbIUScale.mmToIU( 1.5 ), pcbIUScale.mmToIU( 1.5 ) ) );
68 aCell->SetTextThickness( pcbIUScale.mmToIU( aIsHeading ? 0.3 : 0.2 ) );
69}
70
71
72void PCB_STACKUP_TABLE::Serialize( google::protobuf::Any& aContainer ) const
73{
74 kiapi::board::types::StackupTable table;
75
76 PackGeneratedTable( *this, table );
77
78 if( !aContainer.PackFrom( table ) )
79 wxFAIL_MSG( wxT( "Failed to pack PCB_STACKUP_TABLE" ) );
80}
81
82
83bool PCB_STACKUP_TABLE::Deserialize( const google::protobuf::Any& aContainer )
84{
85 kiapi::board::types::StackupTable table;
86
87 if( !aContainer.UnpackTo( &table ) )
88 return false;
89
90 return UnpackGeneratedTable( table, *this );
91}
92
93
void PackGeneratedTable(const PCB_GENERATED_TABLE &aTable, MSG &aMsg)
Pack what every generated table shares into its message.
bool UnpackGeneratedTable(const MSG &aMsg, PCB_GENERATED_TABLE &aTable)
The reverse of PackGeneratedTable.
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
#define DEFAULT_LINE_WIDTH
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:99
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
One pass of rebuilding tables.
std::vector< GENERATED_TABLE_COLUMN > Defaults() const
GENERATED_TABLE_UNITS DefaultUnits() const
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
std::vector< GENERATED_TABLE_COLUMN > m_columns
GENERATED_TABLE_UNITS m_units
bool generatedEquals(const PCB_GENERATED_TABLE &aOther) const
Equality of the members this class owns and of the underlying PCB_TABLE.
PCB_GENERATED_TABLE(BOARD_ITEM *aParent, KICAD_T aType, int aLineWidth)
A board stackup table placed on the board, kept in step with the stackup.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
PCB_STACKUP_TABLE(BOARD_ITEM *aParent)
bool operator==(const BOARD_ITEM &aOther) const override
void styleNewCell(PCB_TABLECELL *aCell, bool aIsHeading) override
The text style of the one-shot stackup table this replaces, so a placed table looks the same.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
std::unique_ptr< GENERATED_TABLE_CONTENT > generate(const BOARD &aBoard, GENERATED_TABLE_REFRESH *aRefresh) const override
The rows this table reports.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int GetRowCount() const
Definition pcb_table.h:128
void SetTextThickness(int aWidth) override
The TextThickness is that set by the user.
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true) override
Provide class metadata.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
#define _(s)
static struct PCB_STACKUP_TABLE_DESC _PCB_STACKUP_TABLE_DESC
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
Definition property.h:74
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
std::vector< GENERATED_TABLE_ROW > BuildStackupTableRows(const BOARD &aBoard, const std::vector< GENERATED_TABLE_COLUMN > &aColumns, GENERATED_TABLE_UNITS aUnits, int aPrecision)
One row per stackup layer, and per sublayer of a split dielectric, top to bottom.
const GENERATED_TABLE_SCHEMA & StackupTableSchema()
Every column a stackup table can show, all of them by default.
const std::string table
@ PCB_STACKUP_TABLE_T
class PCB_STACKUP_TABLE, a live stackup table derived from PCB_TABLE
Definition typeinfo.h:242
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708