KiCad PCB EDA Suite
Loading...
Searching...
No Matches
job_export_pcb_stats.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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
21
22#include <jobs/job_registry.h>
24#include <wx/filename.h>
25
39
41 JOB( "stats", false ),
42 m_filename(),
48{
49 m_params.emplace_back( new JOB_PARAM<OUTPUT_FORMAT>( "output_format", &m_format, m_format ) );
50 m_params.emplace_back( new JOB_PARAM<UNITS>( "units", &m_units, m_units ) );
51 m_params.emplace_back( new JOB_PARAM<bool>( "exclude_footprints_without_pads", &m_excludeFootprintsWithoutPads,
53 m_params.emplace_back( new JOB_PARAM<bool>( "subtract_holes_from_board", &m_subtractHolesFromBoardArea,
55 m_params.emplace_back( new JOB_PARAM<bool>( "subtract_holes_from_copper", &m_subtractHolesFromCopperAreas,
57}
58
59
61{
62 return _( "Export board statistics" );
63}
64
65
67{
68 return _( "Export Board Statistics Job Settings" );
69}
70
71
72void JOB_EXPORT_PCB_STATS::SetDefaultOutputPath( const wxString& aReferenceName )
73{
74 wxFileName fn( aReferenceName );
75
76 // We have other report file types (ERC/DRC) and JSON outputs so make sure we default
77 // to something that won't overwrite them.
78 fn.SetName( fn.GetName() + wxS( "_statistics" ) );
79
81 fn.SetExt( FILEEXT::JsonFileExtension );
82 else
84
85 SetWorkingOutputPath( fn.GetFullName() );
86}
87
88
89REGISTER_JOB( pcb_export_stats, _( "PCB: Export Board Statistics" ), KIWAY::FACE_PCB, JOB_EXPORT_PCB_STATS );
wxString GetDefaultDescription() const override
wxString GetSettingsDialogTitle() const override
void SetDefaultOutputPath(const wxString &aReferenceName)
std::vector< JOB_PARAM_BASE * > m_params
Definition job.h:277
JOB(const std::string &aType, bool aOutputIsDirectory)
Definition job.cpp:26
void SetWorkingOutputPath(const wxString &aPath)
Sets a transient output path for the job, it takes priority over the configured output path when GetF...
Definition job.h:241
@ FACE_PCB
pcbnew DSO
Definition kiway.h:356
#define _(s)
static const std::string ReportFileExtension
static const std::string JsonFileExtension
NLOHMANN_JSON_SERIALIZE_ENUM(JOB_EXPORT_PCB_STATS::OUTPUT_FORMAT, { { JOB_EXPORT_PCB_STATS::OUTPUT_FORMAT::REPORT, "report" }, { JOB_EXPORT_PCB_STATS::OUTPUT_FORMAT::JSON, "json" }, { JOB_EXPORT_PCB_STATS::OUTPUT_FORMAT::REPORT, 0 }, { JOB_EXPORT_PCB_STATS::OUTPUT_FORMAT::JSON, 1 }, }) NLOHMANN_JSON_SERIALIZE_ENUM(JOB_EXPORT_PCB_STATS
#define REGISTER_JOB(job_name, title, face, T)
Definition of file extensions used in Kicad.