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 <algorithm>
24#include <map>
25
28#include <drill/drill_span.h>
29#include <pcb_table.h>
30
31
39void RefreshDrillCharts( BOARD& aBoard );
40
41
51{
52public:
53 PCB_DRILL_CHART( BOARD_ITEM* aParent );
54
55 PCB_DRILL_CHART( const PCB_DRILL_CHART& aOther );
56
57 ~PCB_DRILL_CHART() override = default;
58
60
61 static inline bool ClassOf( const EDA_ITEM* aItem )
62 {
63 return aItem && PCB_DRILL_CHART_T == aItem->Type();
64 }
65
66 wxString GetClass() const override { return wxT( "PCB_DRILL_CHART" ); }
67
68 EDA_ITEM* Clone() const override { return new PCB_DRILL_CHART( *this ); }
69
71 const DRILL_CHART_FILTER& Filter() const { return m_filter; }
72
73 std::vector<DRILL_CHART_COLUMN>& Columns() { return m_columns; }
74 const std::vector<DRILL_CHART_COLUMN>& Columns() const { return m_columns; }
75
77 void SetUnits( DRILL_CHART_UNITS aUnits ) { m_units = aUnits; }
78
79 int GetPrecision() const { return m_precision; }
80
85 void SetPrecision( int aPrecision ) { m_precision = std::clamp( aPrecision, 0, 6 ); }
86
87 bool GetShowTotals() const { return m_showTotals; }
88 void SetShowTotals( bool aShow ) { m_showTotals = aShow; }
89
94 uint64_t GetBuiltGeneration() const { return m_builtGeneration; }
95
99 void ApplyTemplate( const DRILL_CHART_TEMPLATE& aTemplate );
100
101
111 void RebuildCells( const BOARD& aBoard, DRILL_SYMBOL_PROFILE* aAssignedProfile = nullptr );
112
120 const std::map<int, int>& RowShapes() const { return m_rowShapes; }
121 std::map<int, int>& RowShapes() { return m_rowShapes; }
122
130 const std::map<int, std::string>& RowKeys() const { return m_rowKeys; }
131 std::map<int, std::string>& RowKeys() { return m_rowKeys; }
132
136 bool IsDataRow( int aRow ) const;
137
141 int GetSymbolColumn() const { return m_symbolColumn; }
142 void SetSymbolColumn( int aCol ) { m_symbolColumn = aCol; }
143
144 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
145 const std::vector<KICAD_T>& aScanTypes ) override;
146
147 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
148
149 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
150
151 double Similarity( const BOARD_ITEM& aOther ) const override;
152
153 bool operator==( const BOARD_ITEM& aOther ) const override;
154
155 void Serialize( google::protobuf::Any& aContainer ) const override;
156 bool Deserialize( const google::protobuf::Any& aContainer ) override;
157
158protected:
159 void swapData( BOARD_ITEM* aImage ) override;
160
161private:
165 std::vector<DRILL_CHART_GROUP> buildGroups( const BOARD& aBoard ) const;
166
175 void migrateRows( int aRows, int aCols, int aFirstDataRow,
176 const std::vector<std::string>& aNewRowKeys );
177
179
180 std::vector<DRILL_CHART_COLUMN> m_columns;
181
185
186 std::map<int, int> m_rowShapes;
187 std::map<int, std::string> m_rowKeys;
189
191};
192
193#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:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
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 ...
The base class for create windows for drawing purpose.
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
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
~PCB_DRILL_CHART() override=default
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)
DRILL_CHART_UNITS GetUnits() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
std::map< int, std::string > m_rowKeys
void ApplyTemplate(const DRILL_CHART_TEMPLATE &aTemplate)
Copy a template's formatting.
const std::map< int, int > & RowShapes() const
Curated shape index for each generated row, by table row.
std::map< int, int > & RowShapes()
std::vector< DRILL_CHART_COLUMN > & Columns()
void swapData(BOARD_ITEM *aImage) override
uint64_t GetBuiltGeneration() const
Board drill generation the cells were built at.
DRILL_CHART_UNITS m_units
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
std::map< int, int > m_rowShapes
void RebuildCells(const BOARD &aBoard, DRILL_SYMBOL_PROFILE *aAssignedProfile=nullptr)
Regenerate the cells from the board.
wxString GetClass() const override
Return the class name.
const std::map< int, std::string > & RowKeys() const
Drill group each generated row reports on, by table row.
PCB_DRILL_CHART & operator=(const PCB_DRILL_CHART &)=delete
std::vector< DRILL_CHART_COLUMN > m_columns
uint64_t m_builtGeneration
void SetShowTotals(bool aShow)
std::vector< DRILL_CHART_GROUP > buildGroups(const BOARD &aBoard) const
The board data this chart reports on, as chart rows.
bool operator==(const BOARD_ITEM &aOther) const override
const std::vector< DRILL_CHART_COLUMN > & Columns() const
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
int GetPrecision() const
void SetPrecision(int aPrecision)
Clamped.
void migrateRows(int aRows, int aCols, int aFirstDataRow, const std::vector< std::string > &aNewRowKeys)
Move each row's cells to the row that reports the same drill group.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
bool GetShowTotals() const
bool IsDataRow(int aRow) const
True for a row that reports a drill group, false for the title, heading and totals.
std::map< int, std::string > & RowKeys()
void SetUnits(DRILL_CHART_UNITS aUnits)
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
DRILL_CHART_FILTER & Filter()
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.
DRILL_CHART_FILTER m_filter
PCB_TABLE(BOARD_ITEM *aParent, int aLineWidth)
Definition pcb_table.cpp:55
DRILL_CHART_UNITS
Hole classification and drill span, shared by the drill model and the drill writers.
INSPECT_RESULT
Definition eda_item.h:44
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
void RefreshDrillCharts(BOARD &aBoard)
Bring every chart on the board up to date.
Which holes a chart reports on.
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
Definition typeinfo.h:239