KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_board_stackup_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) 2026 Krishna Swaroop <[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
22#include <map>
23#include <i18n_utility.h>
25#include <wx/filename.h>
26
27
28static std::map<JOB_EXPORT_PCB_STACKUP::OUTPUT_FORMAT, wxString> stackupOutputFormatMap = {
31};
32
33
35 DIALOG_BOARD_STACKUP_JOB_BASE( aParent, wxID_ANY ),
36 m_job( aJob )
37{
38 for( const auto& [format, name] : stackupOutputFormatMap )
39 m_choiceFormat->Append( wxGetTranslation( name ) );
40
41 if( aJob )
42 SetTitle( aJob->GetSettingsDialogTitle() );
43
45
47}
48
49
51{
52 int selIndx = m_choiceFormat->GetSelection();
53
54 if( selIndx < 0 )
56
57 auto it = stackupOutputFormatMap.begin();
58 std::advance( it, selIndx );
59 return it->first;
60}
61
62
64{
65 auto it = stackupOutputFormatMap.find( aFormat );
66
67 if( it != stackupOutputFormatMap.end() )
68 m_choiceFormat->SetSelection( std::distance( stackupOutputFormatMap.begin(), it ) );
69}
70
71
72void DIALOG_BOARD_STACKUP_JOB::OnFormatChoice( wxCommandEvent& aEvent )
73{
75
76 if( !m_textCtrlOutputPath->GetValue().IsEmpty() )
77 {
78 wxFileName fn( m_textCtrlOutputPath->GetValue() );
79
80 switch( getSelectedFormat() )
81 {
84 }
85
86 m_textCtrlOutputPath->SetValue( fn.GetFullPath() );
87 }
88}
89
90
92{
94
95 m_labelUnits->Enable( csv );
96 m_choiceUnits->Enable( csv );
97 m_sbSizerFields->GetStaticBox()->Enable( csv );
98 m_cbThickness->Enable( csv );
99 m_cbMaterial->Enable( csv );
100 m_cbColor->Enable( csv );
101 m_cbEpsilonR->Enable( csv );
102 m_cbLossTangent->Enable( csv );
103 m_cbFinish->Enable( csv );
104 m_cbBoardOptions->Enable( csv );
105}
106
107
109{
110 m_textCtrlOutputPath->SetValue( m_job->GetConfiguredOutputPath() );
111 setSelectedFormat( m_job->m_format );
112 m_choiceUnits->SetSelection( m_job->m_units == JOB_EXPORT_PCB_STACKUP::UNITS::MM ? 0 : 1 );
113 m_cbThickness->SetValue( m_job->m_includeThickness );
114 m_cbMaterial->SetValue( m_job->m_includeMaterial );
115 m_cbColor->SetValue( m_job->m_includeColor );
116 m_cbEpsilonR->SetValue( m_job->m_includeEpsilonR );
117 m_cbLossTangent->SetValue( m_job->m_includeLossTangent );
118 m_cbFinish->SetValue( m_job->m_includeFinish );
119 m_cbBoardOptions->SetValue( m_job->m_includeBoardOptions );
120
122
123 return true;
124}
125
126
128{
129 m_job->SetConfiguredOutputPath( m_textCtrlOutputPath->GetValue() );
130 m_job->m_format = getSelectedFormat();
131 m_job->m_units = m_choiceUnits->GetSelection() == 0 ? JOB_EXPORT_PCB_STACKUP::UNITS::MM
133 m_job->m_includeThickness = m_cbThickness->GetValue();
134 m_job->m_includeMaterial = m_cbMaterial->GetValue();
135 m_job->m_includeColor = m_cbColor->GetValue();
136 m_job->m_includeEpsilonR = m_cbEpsilonR->GetValue();
137 m_job->m_includeLossTangent = m_cbLossTangent->GetValue();
138 m_job->m_includeFinish = m_cbFinish->GetValue();
139 m_job->m_includeBoardOptions = m_cbBoardOptions->GetValue();
140
141 return true;
142}
const char * name
DIALOG_BOARD_STACKUP_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)
JOB_EXPORT_PCB_STACKUP::OUTPUT_FORMAT getSelectedFormat()
DIALOG_BOARD_STACKUP_JOB(wxWindow *aParent, JOB_EXPORT_PCB_STACKUP *aJob)
void OnFormatChoice(wxCommandEvent &aEvent) override
void setSelectedFormat(JOB_EXPORT_PCB_STACKUP::OUTPUT_FORMAT aFormat)
JOB_EXPORT_PCB_STACKUP * m_job
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_EXPORT_PCB_STACKUP::OUTPUT_FORMAT, wxString > stackupOutputFormatMap
static const std::string JsonFileExtension
static const std::string CsvFileExtension
Some functions to handle hotkeys in KiCad.
#define _HKI(x)
Definition page_info.cpp:40
Definition of file extensions used in Kicad.