KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_drill_chart.h
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#ifndef PCB_DRILL_CHART_H
21#define PCB_DRILL_CHART_H
22
23#include <map>
24#include <optional>
25#include <vector>
26
30#include <drill/drill_span.h>
32#include <pcb_generated_table.h>
33
34
39{
40 std::vector<std::optional<int>> m_RowShapes;
42};
43
44
52{
53 explicit DRILL_PROFILE_PENDING( BOARD& aBoard );
54
55 void Commit( BOARD& aBoard ) override;
56
58};
59
60
68{
69public:
70 PCB_DRILL_CHART( BOARD_ITEM* aParent );
71
72 PCB_DRILL_CHART( const PCB_DRILL_CHART& aOther );
73
74 ~PCB_DRILL_CHART() override = default;
75
77
78 static inline bool ClassOf( const EDA_ITEM* aItem )
79 {
80 return aItem && PCB_DRILL_CHART_T == aItem->Type();
81 }
82
83 wxString GetClass() const override { return wxT( "PCB_DRILL_CHART" ); }
84
85 EDA_ITEM* Clone() const override { return new PCB_DRILL_CHART( *this ); }
86
87 const GENERATED_TABLE_SCHEMA& Schema() const override { return DrillChartSchema(); }
88
90 const DRILL_CHART_FILTER& Filter() const { return m_filter; }
91
92 bool GetShowTotals() const { return m_showTotals; }
93
98 void SetShowTotals( bool aShow );
99
103 void RestoreShowTotals( bool aShow ) { m_showTotals = aShow; }
104
105 // One pair per filter entry, for the property manager
106 bool GetIncludePlated() const { return m_filter.m_Plated; }
107 void SetIncludePlated( bool aInclude ) { m_filter.m_Plated = aInclude; }
108 bool GetIncludeNonPlated() const { return m_filter.m_NonPlated; }
109 void SetIncludeNonPlated( bool aInclude ) { m_filter.m_NonPlated = aInclude; }
110 bool GetIncludeVias() const { return m_filter.m_Vias; }
111 void SetIncludeVias( bool aInclude ) { m_filter.m_Vias = aInclude; }
112 bool GetIncludeSlots() const { return m_filter.m_Slots; }
113 void SetIncludeSlots( bool aInclude ) { m_filter.m_Slots = aInclude; }
114 bool GetIncludeBackdrills() const { return m_filter.m_Backdrills; }
115 void SetIncludeBackdrills( bool aInclude ) { m_filter.m_Backdrills = aInclude; }
116 bool GetIncludeCastellated() const { return m_filter.m_Castellated; }
117 void SetIncludeCastellated( bool aInclude ) { m_filter.m_Castellated = aInclude; }
118
123 uint64_t GetBuiltGeneration() const { return m_builtGeneration; }
124
128 void ApplyTemplate( const DRILL_CHART_TEMPLATE& aTemplate );
129
133 bool IsStale( const BOARD& aBoard ) const override;
134
135 void ApplySettings( const PCB_GENERATED_TABLE& aOther ) override;
136
144 const std::map<int, int>& RowShapes() const { return m_rowShapes; }
145 std::map<int, int>& RowShapes() { return m_rowShapes; }
146
150 bool IsDataRow( int aRow ) const override;
151
155 int GetSymbolColumn() const { return m_symbolColumn; }
156 void SetSymbolColumn( int aCol ) { m_symbolColumn = aCol; }
157
158 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
159
160 bool operator==( const BOARD_ITEM& aOther ) const override;
161
162 void Serialize( google::protobuf::Any& aContainer ) const override;
163 bool Deserialize( const google::protobuf::Any& aContainer ) override;
164
165protected:
166 std::unique_ptr<GENERATED_TABLE_CONTENT> generate( const BOARD& aBoard,
167 GENERATED_TABLE_REFRESH* aRefresh ) const override;
168
169 void onRebuilt( const BOARD& aBoard, const GENERATED_TABLE_CONTENT& aContent ) override;
170
171 void onColumnsReversed() override;
172
173 void onRowsMigrated() override { m_laidOutShowTotals.reset(); }
174
175 void swapData( BOARD_ITEM* aImage ) override;
176
177private:
181 std::vector<DRILL_CHART_GROUP> buildGroups( const BOARD& aBoard, const DRILL_SYMBOL_PROFILE& aProfile ) const;
182
187 DRILL_CHART_COLUMN_ID columnId( int aCol ) const;
188
190
192
193 std::optional<bool> m_laidOutShowTotals;
194
195 std::map<int, int> m_rowShapes;
197
199};
200
201#endif // PCB_DRILL_CHART_H
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
The column set and formatting a new chart starts from.
Grouping rules and symbol assignments, shared by reference so a chart and its map can never disagree ...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
Board state a table rebuild wants to change, held back until the whole refresh has succeeded.
One pass of rebuilding tables.
The columns one generator (the drill chart, a stackup table, ...) can produce, and the units and prec...
bool GetIncludeNonPlated() const
~PCB_DRILL_CHART() override=default
bool GetIncludeBackdrills() const
bool GetIncludeCastellated() const
PCB_DRILL_CHART(BOARD_ITEM *aParent)
void SetSymbolColumn(int aCol)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
static bool ClassOf(const EDA_ITEM *aItem)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void SetIncludePlated(bool aInclude)
const GENERATED_TABLE_SCHEMA & Schema() const override
void ApplyTemplate(const DRILL_CHART_TEMPLATE &aTemplate)
Copy a template's formatting.
void onRowsMigrated() override
Called once a rebuild has moved the rows to where the new content puts them, before anything asks whi...
const std::map< int, int > & RowShapes() const
Curated shape index for each generated row, by table row.
std::map< int, int > & RowShapes()
void swapData(BOARD_ITEM *aImage) override
std::optional< bool > m_laidOutShowTotals
Set only between a change and the next rebuild.
uint64_t GetBuiltGeneration() const
Board drill generation the cells were built at.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void onRebuilt(const BOARD &aBoard, const GENERATED_TABLE_CONTENT &aContent) override
Called once the cells are laid out, with the content they were built from.
std::map< int, int > m_rowShapes
wxString GetClass() const override
Return the class name.
void onColumnsReversed() override
Called once the columns have been reversed, for any column index a subclass keeps.
void ApplySettings(const PCB_GENERATED_TABLE &aOther) override
Take aOther's settings and placement but keep this table's cells, so formatting applied to them survi...
PCB_DRILL_CHART & operator=(const PCB_DRILL_CHART &)=delete
uint64_t m_builtGeneration
void SetShowTotals(bool aShow)
A chart without row keys can only tell its totals row by position, so it remembers the setting its ro...
bool operator==(const BOARD_ITEM &aOther) const override
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.
bool GetIncludeSlots() const
std::vector< DRILL_CHART_GROUP > buildGroups(const BOARD &aBoard, const DRILL_SYMBOL_PROFILE &aProfile) const
The board data this chart reports on, as chart rows grouped the way aProfile says.
bool IsDataRow(int aRow) const override
True for a row that reports a drill group, false for the title, heading and totals.
void SetIncludeVias(bool aInclude)
void SetIncludeCastellated(bool aInclude)
bool GetShowTotals() const
void SetIncludeNonPlated(bool aInclude)
bool GetIncludeVias() const
DRILL_CHART_FILTER & Filter()
void SetIncludeSlots(bool aInclude)
bool GetIncludePlated() const
const DRILL_CHART_FILTER & Filter() const
int GetSymbolColumn() const
Table column the symbol is drawn in, or -1 when the chart has no symbol column.
void RestoreShowTotals(bool aShow)
Set it without that, for a loader whose cells were laid out with this setting.
bool IsStale(const BOARD &aBoard) const override
One integer comparison, so a board with nothing drill related changed pays nothing.
DRILL_CHART_COLUMN_ID columnId(int aCol) const
The typed id a column at this index holds, so generate's switch stays exhaustive even though a stored...
DRILL_CHART_FILTER m_filter
void SetIncludeBackdrills(bool aInclude)
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
PCB_GENERATED_TABLE(BOARD_ITEM *aParent, KICAD_T aType, int aLineWidth)
const GENERATED_TABLE_SCHEMA & DrillChartSchema()
Every column the drill chart schema knows how to build, in the order the schema lists them.
DRILL_CHART_COLUMN_ID
Hole classification and drill span, shared by the drill model and the drill writers.
A drill chart's rows, with the symbol each one is drawn with.
std::vector< std::optional< int > > m_RowShapes
Per m_Rows entry, empty when the mark is not a shape.
Which holes a chart reports on.
DRILL_SYMBOL_PROFILE m_Profile
void Commit(BOARD &aBoard) override
DRILL_PROFILE_PENDING(BOARD &aBoard)
What a generated table reports, one entry per cell below the heading row.
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
Definition typeinfo.h:239