KiCad PCB EDA Suite
Loading...
Searching...
No Matches
generated_table_schema.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 GENERATED_TABLE_SCHEMA_H
21#define GENERATED_TABLE_SCHEMA_H
22
23#include <cstdint>
24#include <vector>
25
26#include <eda_units.h>
27#include <lset.h>
28#include <wx/string.h>
29
30
37
38
45
46
51constexpr int GENERATED_TABLE_MAX_COLUMN_WIDTH = 1000 * 1000000;
52
55
56
63constexpr int64_t GENERATED_TABLE_MAX_TOTAL_WIDTH = 10LL * 1000 * 1000000;
64
65
72{
73 int m_Id = 0;
74 wxString m_Heading;
76 int m_Width = 0; // minimum width, 0 = autosize
77 bool m_Visible = true;
78
79 bool operator==( const GENERATED_TABLE_COLUMN& aOther ) const = default;
80};
81
82
88{
89 int m_Id;
90 const char* m_Token; // file and JSON token, never translated
91 const wxChar* m_Heading; // _HKI() string, translated when used
93 bool m_DefaultShown; // part of Defaults()
94 const wxChar* m_Label = nullptr; // _HKI() UI name, the heading when null
95};
96
97
107{
108public:
109 GENERATED_TABLE_SCHEMA( std::vector<GENERATED_TABLE_COLUMN_DEF> aDefs, GENERATED_TABLE_UNITS aDefaultUnits,
110 int aDefaultPrecision );
111
112 const std::vector<GENERATED_TABLE_COLUMN_DEF>& Defs() const { return m_defs; }
113
114 const GENERATED_TABLE_COLUMN_DEF* Find( int aId ) const;
115 const GENERATED_TABLE_COLUMN_DEF* FindToken( const wxString& aToken ) const;
116
121 const char* Token( int aId ) const;
122
123 GENERATED_TABLE_COLUMN DefaultColumn( int aId ) const;
124 std::vector<GENERATED_TABLE_COLUMN> Defaults() const;
125
132 bool Validate( std::vector<GENERATED_TABLE_COLUMN>& aColumns ) const;
133
135 int DefaultPrecision() const { return m_defaultPrecision; }
136
137private:
138 std::vector<GENERATED_TABLE_COLUMN_DEF> m_defs;
141};
142
143
149wxString FormatGeneratedTableLength( int aValue, GENERATED_TABLE_UNITS aUnits, int aPrecision );
150
151
156
157
163bool GeneratedTableUnitsFromToken( const wxString& aToken, GENERATED_TABLE_UNITS& aUnits );
165bool GeneratedTableAlignFromToken( const wxString& aToken, GENERATED_TABLE_ALIGN& aAlign );
166
167
175
176#endif // GENERATED_TABLE_SCHEMA_H
const char * Token(int aId) const
The file token for a known id, or a stable placeholder for one the schema does not recognize,...
GENERATED_TABLE_COLUMN DefaultColumn(int aId) const
std::vector< GENERATED_TABLE_COLUMN > Defaults() const
GENERATED_TABLE_UNITS m_defaultUnits
const std::vector< GENERATED_TABLE_COLUMN_DEF > & Defs() const
const GENERATED_TABLE_COLUMN_DEF * FindToken(const wxString &aToken) const
const GENERATED_TABLE_COLUMN_DEF * Find(int aId) const
GENERATED_TABLE_SCHEMA(std::vector< GENERATED_TABLE_COLUMN_DEF > aDefs, GENERATED_TABLE_UNITS aDefaultUnits, int aDefaultPrecision)
GENERATED_TABLE_UNITS DefaultUnits() const
bool Validate(std::vector< GENERATED_TABLE_COLUMN > &aColumns) const
Drop a column whose id the schema does not know and a column that repeats an id already kept,...
std::vector< GENERATED_TABLE_COLUMN_DEF > m_defs
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
EDA_UNITS
Definition eda_units.h:45
GENERATED_TABLE_UNITS ToGeneratedTableUnits(EDA_UNITS aUnits)
The table units a user's display units seed.
bool GeneratedTableUnitsFromToken(const wxString &aToken, GENERATED_TABLE_UNITS &aUnits)
const char * GeneratedTableUnitsToken(GENERATED_TABLE_UNITS aUnits)
Stable file tokens, independent of enum ordering so inserting a value later cannot change what an exi...
LSET DocumentationLayers()
Layers a generated table or drill map may live on.
wxString FormatGeneratedTableLength(int aValue, GENERATED_TABLE_UNITS aUnits, int aPrecision)
Render a length the way a generated table's cell shows it.
bool GeneratedTableAlignFromToken(const wxString &aToken, GENERATED_TABLE_ALIGN &aAlign)
GENERATED_TABLE_UNITS
constexpr int GENERATED_TABLE_MAX_COLUMN_WIDTH
A column can be no wider than this.
constexpr int64_t GENERATED_TABLE_MAX_TOTAL_WIDTH
A column set can be no wider than this in total, summed after each column is clamped to GENERATED_TAB...
constexpr int GENERATED_TABLE_MAX_PRECISION
The most digits a generated table prints after the decimal point.
GENERATED_TABLE_ALIGN
const char * GeneratedTableAlignToken(GENERATED_TABLE_ALIGN aAlign)
@ INCH
Definition rs274x.cpp:61
The column a schema knows how to build, independent of whether any particular table shows it.
A column as a generated table actually carries it: what a row's cell in that column holds and how it ...
GENERATED_TABLE_ALIGN m_Align
bool operator==(const GENERATED_TABLE_COLUMN &aOther) const =default
static const long long MM