24#include <wx/translation.h>
39 return !( lhs == rhs );
62 j.at(
"name" ).get_to( f.
name );
63 j.at(
"label" ).get_to( f.
label );
64 j.at(
"show" ).get_to( f.
show );
65 j.at(
"group_by" ).get_to( f.
groupBy );
69bool operator!=(
const BOM_PRESET& lhs,
const BOM_PRESET& rhs )
71 return !( lhs == rhs );
75bool operator<(
const BOM_PRESET& lhs,
const BOM_PRESET& rhs )
77 return lhs.name < rhs.name;
81void to_json( nlohmann::json& j,
const BOM_PRESET& p )
85 {
"fields_ordered", p.fieldsOrdered },
86 {
"sort_field", p.sortField },
87 {
"sort_asc", p.sortAsc },
88 {
"filter_string", p.filterString },
89 {
"filter_scope", p.filterScope },
90 {
"group_symbols", p.groupSymbols },
91 {
"exclude_dnp", p.excludeDNP },
92 {
"include_excluded_from_bom", p.includeExcludedFromBOM },
97void from_json(
const nlohmann::json& j, BOM_PRESET& f )
99 j.at(
"name" ).get_to( f.name );
100 f.fieldsOrdered = j.value(
"fields_ordered", std::vector<BOM_FIELD>{} );
101 j.at(
"sort_field" ).get_to( f.sortField );
102 j.at(
"sort_asc" ).get_to( f.sortAsc );
103 j.at(
"filter_string" ).get_to( f.filterString );
105 j.at(
"group_symbols" ).get_to( f.groupSymbols );
106 j.at(
"exclude_dnp" ).get_to( f.excludeDNP );
109 f.includeExcludedFromBOM = j.value(
"include_excluded_from_bom",
false );
114bool BOM_PRESET::operator==(
const BOM_PRESET& rhs )
const
116 return this->
name == rhs.name
117 && this->readOnly == rhs.readOnly
118 && this->fieldsOrdered == rhs.fieldsOrdered
119 && this->sortField == rhs.sortField
120 && this->sortAsc == rhs.sortAsc
121 && this->filterString == rhs.filterString
122 && this->filterScope == rhs.filterScope
123 && this->groupSymbols == rhs.groupSymbols
124 && this->excludeDNP == rhs.excludeDNP
125 && this->includeExcludedFromBOM == rhs.includeExcludedFromBOM;
129BOM_PRESET BOM_PRESET::DefaultEditing()
136 p.fieldsOrdered = std::vector<BOM_FIELD>{
137 {
"Reference",
"Reference",
true,
false },
138 {
"${QUANTITY}",
"Qty",
true,
false },
139 {
"Value",
"Value",
true,
true },
140 {
"${DNP}",
"DNP",
true,
true },
141 {
"${EXCLUDE_FROM_BOM}",
"Exclude from BOM",
true,
true },
142 {
"${EXCLUDE_FROM_BOARD}",
"Exclude from Board",
true,
true },
143 {
"${EXCLUDE_FROM_SIM}",
"Exclude from Simulation",
true,
true },
144 {
"${EXCLUDE_FROM_POS_FILES}",
"Exclude from Position Files",
true,
true },
145 {
"Footprint",
"Footprint",
true,
true },
146 {
"Datasheet",
"Datasheet",
true,
false },
153BOM_PRESET BOM_PRESET::GroupedByValue()
160 p.fieldsOrdered = std::vector<BOM_FIELD>{
161 {
"Reference",
"Reference",
true,
false },
162 {
"Value",
"Value",
true,
true },
163 {
"Datasheet",
"Datasheet",
true,
false },
164 {
"Footprint",
"Footprint",
true,
false },
165 {
"${QUANTITY}",
"Qty",
true,
false },
166 {
"${DNP}",
"DNP",
true,
true },
173BOM_PRESET BOM_PRESET::GroupedByValueFootprint()
176 _HKI(
"Grouped By Value and Footprint" ),
true, {}, wxS(
"Reference" ),
true,
"",
180 p.fieldsOrdered = std::vector<BOM_FIELD>{
181 {
"Reference",
"Reference",
true,
false },
182 {
"Value",
"Value",
true,
true },
183 {
"Datasheet",
"Datasheet",
true,
false },
184 {
"Footprint",
"Footprint",
true,
true },
185 {
"${QUANTITY}",
"Qty",
true,
false },
186 {
"${DNP}",
"DNP",
true,
true },
193BOM_PRESET BOM_PRESET::Attributes()
200 p.fieldsOrdered = std::vector<BOM_FIELD>{
201 {
"Reference",
"Reference",
true,
false },
202 {
"Value",
"Value",
true,
true },
203 {
"Datasheet",
"Datasheet",
false,
false },
204 {
"Footprint",
"Footprint",
false,
true },
205 {
"${DNP}",
"Do Not Place",
true,
false },
206 {
"${EXCLUDE_FROM_BOM}",
"Exclude from BOM",
true,
false },
207 {
"${EXCLUDE_FROM_BOARD}",
"Exclude from Board",
true,
false },
208 {
"${EXCLUDE_FROM_SIM}",
"Exclude from Simulation",
true,
false },
209 {
"${EXCLUDE_FROM_POS_FILES}",
"Exclude from Position Files",
true,
false },
216std::vector<BOM_PRESET> BOM_PRESET::BuiltInPresets()
218 return { BOM_PRESET::DefaultEditing(),
219 BOM_PRESET::GroupedByValue(),
220 BOM_PRESET::GroupedByValueFootprint(),
221 BOM_PRESET::Attributes() };
242 return !( lhs == rhs );
254 j = nlohmann::json{ {
"name", p.
name },
267 j.at(
"name" ).get_to( f.
name );
272 j.at(
"keep_tabs" ).get_to( f.
keepTabs );
281 return {
_HKI(
"CSV" ),
true, wxS(
"," ), wxT(
"\"" ), wxT(
"," ), wxT(
"" ),
false,
false,
false };
287 return {
_HKI(
"TSV" ),
true, wxS(
"\t" ), wxT(
"" ), wxT(
"," ), wxT(
"" ),
false,
false,
false };
294 _HKI(
"Semicolons" ),
true, wxS(
";" ), wxT(
"'" ), wxT(
"," ), wxT(
"" ),
false,
false,
false
305#if !defined( __MINGW32__ )
void to_json(nlohmann::json &j, const BOM_FIELD &f)
bool operator<(const BOM_FIELD &lhs, const BOM_FIELD &rhs)
void from_json(const nlohmann::json &j, BOM_FIELD &f)
bool operator!=(const BOM_FIELD &lhs, const BOM_FIELD &rhs)
bool operator==(const BOM_FIELD &rhs) const
bool operator==(const BOM_FMT_PRESET &rhs) const
bool includeByteOrderMark
static BOM_FMT_PRESET CSV()
static std::vector< BOM_FMT_PRESET > BuiltInPresets()
static BOM_FMT_PRESET TSV()
wxString refRangeDelimiter
static BOM_FMT_PRESET Semicolons()