KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_rc_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) 2024 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 along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
22#include <map>
23#include <i18n_utility.h>
25
26static std::map<JOB_RC::OUTPUT_FORMAT, wxString> outputFormatMap = {
27 { JOB_RC::OUTPUT_FORMAT::REPORT, _HKI( "Report" ) },
29};
30
31
32DIALOG_RC_JOB::DIALOG_RC_JOB( wxWindow* parent, JOB_RC* aJob, const wxString& aTitle ) :
33 DIALOG_RC_JOB_BASE( parent, wxID_ANY, aTitle ),
34 m_job( aJob )
35{
36 for( const auto& [format, name] : outputFormatMap )
37 m_choiceFormat->Append( wxGetTranslation( name ) );
38
40}
41
42
44{
45 int selIndx = m_choiceFormat->GetSelection();
46 auto it = outputFormatMap.begin();
47 std::advance( it, selIndx );
48 return it->first;
49}
50
51
53{
54 auto it = outputFormatMap.find( format );
55 if( it != outputFormatMap.end() )
56 {
57 int idx = std::distance( outputFormatMap.begin(), it );
58 m_choiceFormat->SetSelection( idx );
59 }
60}
61
62
63void DIALOG_RC_JOB::OnFormatChoice( wxCommandEvent& event )
64{
66
67 if( !m_textCtrlOutputPath->GetValue().IsEmpty() )
68 {
69 wxFileName fn( m_textCtrlOutputPath->GetValue() );
70
71 switch( selectedFormat )
72 {
75 }
76
77 m_textCtrlOutputPath->SetValue( fn.GetFullPath() );
78 }
79}
80
81
83{
87
88 m_cbViolationErrors->SetValue( m_job->m_severity & SEVERITY::RPT_SEVERITY_ERROR );
89 m_cbViolationWarnings->SetValue( m_job->m_severity & SEVERITY::RPT_SEVERITY_WARNING );
90
91 return true;
92}
93
94
96{
100
101 m_job->m_severity = 0;
102
103 if( m_cbViolationErrors->GetValue() )
104 m_job->m_severity |= SEVERITY::RPT_SEVERITY_ERROR;
105
106 if( m_cbViolationWarnings->GetValue() )
107 m_job->m_severity |= SEVERITY::RPT_SEVERITY_WARNING;
108
109 return true;
110}
const char * name
Definition: DXF_plotter.cpp:57
Class DIALOG_RC_JOB_BASE.
wxCheckBox * m_cbHaltOutput
wxTextCtrl * m_textCtrlOutputPath
wxCheckBox * m_cbViolationWarnings
wxCheckBox * m_cbViolationErrors
void setSelectedFormat(JOB_RC::OUTPUT_FORMAT aFormat)
void OnFormatChoice(wxCommandEvent &aEvent) override
JOB_RC::OUTPUT_FORMAT getSelectedFormat()
bool TransferDataFromWindow() override
JOB_RC * m_job
Definition: dialog_rc_job.h:40
bool TransferDataToWindow() override
DIALOG_RC_JOB(wxWindow *aParent, JOB_RC *aJob, const wxString &aTitle)
void SetupStandardButtons(std::map< int, wxString > aLabels={})
Definition: job_rc.h:29
bool m_exitCodeViolations
Definition: job_rc.h:55
int m_severity
Definition: job_rc.h:45
OUTPUT_FORMAT m_format
Definition: job_rc.h:53
OUTPUT_FORMAT
Definition: job_rc.h:48
void SetOutputPath(const wxString &aPath)
Definition: job.cpp:138
wxString GetOutputPath() const
Definition: job.h:155
#define _HKI(x)
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.
Definition of file extensions used in Kicad.