KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_board_stats_job.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) 2025 Mike Williams <[email protected]>
5 * Copyright (C) 2024 Mark Roszko <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
23#include <map>
24#include <i18n_utility.h>
26
27static std::map<JOB_EXPORT_PCB_STATS::OUTPUT_FORMAT, wxString> outputFormatMap = {
30};
31
32
34 DIALOG_BOARD_STATS_JOB_BASE( parent, wxID_ANY ),
35 m_job( aJob )
36{
37 for( const auto& [format, name] : outputFormatMap )
38 m_choiceFormat->Append( wxGetTranslation( name ) );
39
41}
42
43
45{
46 int selIndx = m_choiceFormat->GetSelection();
47 auto it = outputFormatMap.begin();
48 std::advance( it, selIndx );
49 return it->first;
50}
51
52
54{
55 auto it = outputFormatMap.find( format );
56 if( it != outputFormatMap.end() )
57 {
58 int idx = std::distance( outputFormatMap.begin(), it );
59 m_choiceFormat->SetSelection( idx );
60 }
61}
62
63
64void DIALOG_BOARD_STATS_JOB::OnFormatChoice( wxCommandEvent& event )
65{
67
68 if( !m_textCtrlOutputPath->GetValue().IsEmpty() )
69 {
70 wxFileName fn( m_textCtrlOutputPath->GetValue() );
71
72 switch( selectedFormat )
73 {
76 }
77
78 m_textCtrlOutputPath->SetValue( fn.GetFullPath() );
79 }
80}
81
82
84{
85 m_textCtrlOutputPath->SetValue( m_job->GetConfiguredOutputPath() );
86 setSelectedFormat( m_job->m_format );
87 m_choiceUnits->SetSelection( m_job->m_units == JOB_EXPORT_PCB_STATS::UNITS::MM ? 0 : 1 );
88 m_checkBoxExcludeFootprintsWithoutPads->SetValue( m_job->m_excludeFootprintsWithoutPads );
89 m_checkBoxSubtractHoles->SetValue( m_job->m_subtractHolesFromBoardArea );
90 m_checkBoxSubtractHolesFromCopper->SetValue( m_job->m_subtractHolesFromCopperAreas );
91
92 return true;
93}
94
95
97{
98 m_job->SetConfiguredOutputPath( m_textCtrlOutputPath->GetValue() );
99 m_job->m_format = getSelectedFormat();
100 m_job->m_units =
102 m_job->m_excludeFootprintsWithoutPads = m_checkBoxExcludeFootprintsWithoutPads->GetValue();
103 m_job->m_subtractHolesFromBoardArea = m_checkBoxSubtractHoles->GetValue();
104 m_job->m_subtractHolesFromCopperAreas = m_checkBoxSubtractHolesFromCopper->GetValue();
105
106 return true;
107}
const char * name
DIALOG_BOARD_STATS_JOB_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(496, 301), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void OnFormatChoice(wxCommandEvent &aEvent) override
DIALOG_BOARD_STATS_JOB(wxWindow *aParent, JOB_EXPORT_PCB_STATS *aJob)
JOB_EXPORT_PCB_STATS * m_job
void setSelectedFormat(JOB_EXPORT_PCB_STATS::OUTPUT_FORMAT aFormat)
JOB_EXPORT_PCB_STATS::OUTPUT_FORMAT getSelectedFormat()
void SetupStandardButtons(std::map< int, wxString > aLabels={})
static std::map< JOB_RC::OUTPUT_FORMAT, wxString > outputFormatMap
static const std::string ReportFileExtension
static const std::string JsonFileExtension
Some functions to handle hotkeys in KiCad.
#define _HKI(x)
Definition page_info.cpp:44
Definition of file extensions used in Kicad.