KiCad PCB EDA Suite
Loading...
Searching...
No Matches
generated_table_refresh.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
21
22#include <board.h>
23#include <pcb_generated_table.h>
24
25
30
31
33{
34 for( auto& [type, pending] : m_pending )
35 pending->Commit( m_board );
36}
37
38
40{
41 // Pending state is committed only once every table has rebuilt, so a table that throws
42 // cannot leave half a profile behind
44 int rebuilt = 0;
45
46 for( BOARD_ITEM* item : aBoard.Drawings() )
47 {
48 if( !IsGeneratedTableType( item->Type() ) )
49 continue;
50
51 PCB_GENERATED_TABLE* table = static_cast<PCB_GENERATED_TABLE*>( item );
52
53 if( !table->IsStale( aBoard ) )
54 continue;
55
56 table->RebuildCells( aBoard, &refresh );
57 rebuilt++;
58 }
59
60 if( rebuilt )
61 refresh.Commit();
62
63 return rebuilt;
64}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:410
const DRAWINGS & Drawings() const
Definition board.h:466
One pass of rebuilding tables.
void Commit()
Write every pending state back to the board, in the order it was first asked for.
std::vector< std::pair< std::type_index, std::unique_ptr< GENERATED_TABLE_PENDING > > > m_pending
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
int RefreshGeneratedTables(BOARD &aBoard)
Bring every generated table on the board up to date and return how many were rebuilt.
constexpr bool IsGeneratedTableType(const KICAD_T aType)
A PCB_TABLE subclass whose cells are generated from the board rather than typed by the user.
Definition typeinfo.h:325