KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drill_chart_template.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 DRILL_CHART_TEMPLATE_H
21#define DRILL_CHART_TEMPLATE_H
22
23#include <optional>
24#include <vector>
25
26#include <lset.h>
27#include <math/vector2d.h>
28#include <wx/string.h>
29
30
46
47
54
55
56
58{
61};
62
63
71
72
78constexpr int DRILL_CHART_MAX_COLUMN_WIDTH = 1000 * 1000000;
79constexpr int64_t DRILL_CHART_MAX_TOTAL_WIDTH = 10LL * 1000 * 1000000;
80
81
82
92
93
98bool ValidateDrillChartColumns( std::vector<DRILL_CHART_COLUMN>& aColumns );
99
100
106
107
112{
113 bool m_Plated = true;
114 bool m_NonPlated = true;
115 bool m_Vias = true;
116 bool m_Slots = true;
117 bool m_Backdrills = true;
118 bool m_Castellated = true;
119
120 bool operator==( const DRILL_CHART_FILTER& aOther ) const;
121};
122
123
131{
132public:
134
136
137 void SetName( const wxString& aName ) { m_name = aName; }
138
139 std::vector<DRILL_CHART_COLUMN>& Columns() { return m_columns; }
140 const std::vector<DRILL_CHART_COLUMN>& Columns() const { return m_columns; }
141
143 void SetUnits( DRILL_CHART_UNITS aUnits ) { m_units = aUnits; }
144
145 int GetPrecision() const { return m_precision; }
146 void SetPrecision( int aPrecision ) { m_precision = aPrecision; }
147
148 bool GetShowTotals() const { return m_showTotals; }
149 void SetShowTotals( bool aShow ) { m_showTotals = aShow; }
150
158 bool SaveToFile( const wxString& aPath, wxString* aError ) const;
159 bool LoadFromFile( const wxString& aPath, wxString* aError );
160
161private:
166 wxString m_name;
168
169 std::vector<DRILL_CHART_COLUMN> m_columns;
173};
174
179const char* DrillChartUnitsToken( DRILL_CHART_UNITS aUnits );
181const char* DrillChartAlignToken( DRILL_CHART_ALIGN aAlign );
182
183bool DrillChartUnitsFromToken( const wxString& aToken, DRILL_CHART_UNITS& aUnits );
184bool DrillChartColumnFromToken( const wxString& aToken, DRILL_CHART_COLUMN_ID& aId );
185bool DrillChartAlignFromToken( const wxString& aToken, DRILL_CHART_ALIGN& aAlign );
186
187#endif // DRILL_CHART_TEMPLATE_H
DRILL_CHART_UNITS GetUnits() const
bool SaveToFile(const wxString &aPath, wxString *aError) const
Read and write a template as JSON.
void SetName(const wxString &aName)
void SetPrecision(int aPrecision)
void SetUnits(DRILL_CHART_UNITS aUnits)
wxString m_name
Identify the template file to whoever opens it.
const std::vector< DRILL_CHART_COLUMN > & Columns() const
void SetShowTotals(bool aShow)
bool LoadFromFile(const wxString &aPath, wxString *aError)
std::vector< DRILL_CHART_COLUMN > & Columns()
static DRILL_CHART_TEMPLATE MakeDefault()
std::vector< DRILL_CHART_COLUMN > m_columns
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition symbol.h:59
DRILL_CHART_ALIGN
const char * DrillChartColumnToken(DRILL_CHART_COLUMN_ID aId)
bool DrillChartAlignFromToken(const wxString &aToken, DRILL_CHART_ALIGN &aAlign)
constexpr int DRILL_CHART_MAX_COLUMN_WIDTH
A chart column can be no wider than this, and no chart wider than that in total.
DRILL_CHART_COLUMN_ID
bool DrillChartDefaultColumn(DRILL_CHART_COLUMN_ID aId, DRILL_CHART_COLUMN &aColumn)
The heading and alignment a column starts with, so the writer can leave them out of the file and the ...
bool ValidateDrillChartColumns(std::vector< DRILL_CHART_COLUMN > &aColumns)
Reject a column set that repeats an id or is implausibly wide.
constexpr int64_t DRILL_CHART_MAX_TOTAL_WIDTH
bool DrillChartUnitsFromToken(const wxString &aToken, DRILL_CHART_UNITS &aUnits)
const char * DrillChartUnitsToken(DRILL_CHART_UNITS aUnits)
Stable file tokens, independent of enum ordering so inserting a value later cannot change what an exi...
DRILL_CHART_UNITS
LSET DrillDocumentationLayers()
Layers a chart or map may live on.
bool DrillChartColumnFromToken(const wxString &aToken, DRILL_CHART_COLUMN_ID &aId)
const char * DrillChartAlignToken(DRILL_CHART_ALIGN aAlign)
@ INCH
Definition rs274x.cpp:58
bool operator==(const DRILL_CHART_COLUMN &aOther) const
DRILL_CHART_COLUMN_ID m_Id
DRILL_CHART_ALIGN m_Align
Which holes a chart reports on.
bool operator==(const DRILL_CHART_FILTER &aOther) const
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
static const long long MM