KiCad PCB EDA Suite
Loading...
Searching...
No Matches
job_export_bom.cpp
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 (C) 2023 Mark Roszko <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <jobs/job_export_bom.h>
22#include <jobs/job_registry.h>
23#include <i18n_utility.h>
24
25
27 JOB( "bom", false ),
28 m_filename(),
29
34 m_keepTabs( false ),
35 m_keepLineBreaks( false ),
37
42 m_sortAsc( true ),
45 m_excludeDNP( false ),
46 m_groupSymbols( true ),
48{
49 m_params.emplace_back( new JOB_PARAM<wxString>( "field_delimiter",
52 m_params.emplace_back( new JOB_PARAM<wxString>( "string_delimiter",
55 m_params.emplace_back( new JOB_PARAM<wxString>( "ref_delimiter",
58 m_params.emplace_back( new JOB_PARAM<wxString>( "ref_range_delimiter",
61 m_params.emplace_back( new JOB_PARAM<bool>( "keep_tabs", &m_keepTabs, m_keepTabs ) );
62 m_params.emplace_back( new JOB_PARAM<bool>( "keep_line_breaks",
65 m_params.emplace_back( new JOB_PARAM<bool>( "include_byte_order_mark",
68 m_params.emplace_back( new JOB_PARAM_LIST<wxString>( "fields_ordered",
71 m_params.emplace_back( new JOB_PARAM_LIST<wxString>( "fields_labels",
74 m_params.emplace_back( new JOB_PARAM_LIST<wxString>( "fields_group_by",
77 m_params.emplace_back( new JOB_PARAM<wxString>( "sort_field", &m_sortField, m_sortField ) );
78 m_params.emplace_back( new JOB_PARAM<bool>( "sort_asc", &m_sortAsc, m_sortAsc ) );
79 m_params.emplace_back( new JOB_PARAM<wxString>( "filter_string", &m_filterString, m_filterString ) );
80 m_params.emplace_back( new JOB_PARAM<BOM_FILTER_SCOPE>( "filter_scope", &m_filterScope, m_filterScope ) );
81 m_params.emplace_back( new JOB_PARAM<bool>( "exclude_dnp", &m_excludeDNP, m_excludeDNP ) );
82 m_params.emplace_back( new JOB_PARAM<bool>( "group_symbols", &m_groupSymbols, m_groupSymbols ) );
83
84 m_params.emplace_back( new JOB_PARAM<wxString>( "bom_preset_name",
87 m_params.emplace_back( new JOB_PARAM<wxString>( "bom_format_preset_name",
90
91 m_params.emplace_back( new JOB_PARAM_LIST<wxString>( "variant_names",
94}
95
96
97void JOB_EXPORT_BOM::FromJson( const nlohmann::json& aJson )
98{
99 JOB::FromJson( aJson );
100 m_bomPresetName = wxEmptyString;
101 m_bomFmtPresetName = wxEmptyString;
102}
103
104
106{
107 if( !m_variantNames.empty() )
108 return m_variantNames.front();
109
110 return wxEmptyString;
111}
112
113
114void JOB_EXPORT_BOM::SetSelectedVariant( const wxString& aVariant )
115{
116 m_variantNames.clear();
117
118 if( !aVariant.IsEmpty() )
119 m_variantNames.push_back( aVariant );
120}
121
122
124{
125 return wxString::Format( _( "Generate bill of materials" ) );
126}
127
128
130{
131 return wxString::Format( _( "Generate Bill of Materials Job Settings" ) );
132}
133
134
135REGISTER_JOB( sch_export_bom, _HKI( "Schematic: Generate Bill of Materials" ), KIWAY::FACE_SCH,
137REGISTER_JOB( pcb_export_bom, _HKI( "PCB: Generate Bill of Materials" ), KIWAY::FACE_PCB,
BOM_FILTER_SCOPE
wxString GetSelectedVariant() const
std::vector< wxString > m_variantNames
wxString m_stringDelimiter
wxString m_fieldDelimiter
bool m_includeByteOrderMark
wxString m_filename
wxString GetDefaultDescription() const override
wxString GetSettingsDialogTitle() const override
wxString m_filterString
void FromJson(const nlohmann::json &aJson) override
std::vector< wxString > m_fieldsOrdered
wxString m_refRangeDelimiter
std::vector< wxString > m_fieldsLabels
wxString m_refDelimiter
void SetSelectedVariant(const wxString &aVariant)
std::vector< wxString > m_fieldsGroupBy
wxString m_bomFmtPresetName
wxString m_sortField
wxString m_bomPresetName
BOM_FILTER_SCOPE m_filterScope
virtual void FromJson(const nlohmann::json &j)
Definition job.cpp:60
std::vector< JOB_PARAM_BASE * > m_params
Definition job.h:277
JOB(const std::string &aType, bool aOutputIsDirectory)
Definition job.cpp:26
@ FACE_SCH
eeschema DSO
Definition kiway.h:347
@ FACE_PCB
pcbnew DSO
Definition kiway.h:348
#define _(s)
Some functions to handle hotkeys in KiCad.
#define REGISTER_JOB(job_name, title, face, T)
#define _HKI(x)
Definition page_info.cpp:40