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
40 if( aJob )
41 SetTitle( aJob->GetSettingsDialogTitle() );
42
44
46}
47
48
50{
51 int selIndx = m_choiceFormat->GetSelection();
52 auto it = outputFormatMap.begin();
53 std::advance( it, selIndx );
54 return it->first;
55}
56
57
59{
60 auto it = outputFormatMap.find( format );
61
62 if( it != outputFormatMap.end() )
63 {
64 int idx = std::distance( outputFormatMap.begin(), it );
65 m_choiceFormat->SetSelection( idx );
66 }
67}
68
69
70void DIALOG_BOARD_STATS_JOB::OnFormatChoice( wxCommandEvent& event )
71{
73
74 if( !m_textCtrlOutputPath->GetValue().IsEmpty() )
75 {
76 wxFileName fn( m_textCtrlOutputPath->GetValue() );
77
78 switch( selectedFormat )
79 {
82 }
83
84 m_textCtrlOutputPath->SetValue( fn.GetFullPath() );
85 }
86}
87
88
90{
91 m_textCtrlOutputPath->SetValue( m_job->GetConfiguredOutputPath() );
92 setSelectedFormat( m_job->m_format );
93 m_choiceUnits->SetSelection( m_job->m_units == JOB_EXPORT_PCB_STATS::UNITS::MM ? 0 : 1 );
94 m_checkBoxExcludeFootprintsWithoutPads->SetValue( m_job->m_excludeFootprintsWithoutPads );
95 m_checkBoxSubtractHoles->SetValue( m_job->m_subtractHolesFromBoardArea );
96 m_checkBoxSubtractHolesFromCopper->SetValue( m_job->m_subtractHolesFromCopperAreas );
97
98 return true;
99}
100
101
103{
104 m_job->SetConfiguredOutputPath( m_textCtrlOutputPath->GetValue() );
105 m_job->m_format = getSelectedFormat();
106 m_job->m_units = m_choiceUnits->GetSelection() == 0 ? JOB_EXPORT_PCB_STATS::UNITS::MM
108 m_job->m_excludeFootprintsWithoutPads = m_checkBoxExcludeFootprintsWithoutPads->GetValue();
109 m_job->m_subtractHolesFromBoardArea = m_checkBoxSubtractHoles->GetValue();
110 m_job->m_subtractHolesFromCopperAreas = m_checkBoxSubtractHolesFromCopper->GetValue();
111
112 return true;
113}
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(-1,-1), 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={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
wxString GetSettingsDialogTitle() const override
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.