KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_render_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 <jobs/job_pcb_render.h>
23#include <i18n_utility.h>
24#include <wx/display.h>
25
26static std::map<JOB_PCB_RENDER::BG_STYLE, wxString> bgStyleMap = {
30};
31
32static std::map<JOB_PCB_RENDER::QUALITY, wxString> qualityMap = {
36};
37
38static std::map<JOB_PCB_RENDER::SIDE, wxString> sideMap = {
39 { JOB_PCB_RENDER::SIDE::BACK, _HKI( "Back" ) },
40 { JOB_PCB_RENDER::SIDE::BOTTOM, _HKI( "Bottom" ) },
41 { JOB_PCB_RENDER::SIDE::FRONT, _HKI( "Front" ) },
42 { JOB_PCB_RENDER::SIDE::LEFT, _HKI( "Left" ) },
43 { JOB_PCB_RENDER::SIDE::RIGHT, _HKI( "Right" ) },
45};
46
48 DIALOG_RENDER_JOB_BASE( aParent ), m_job( aJob )
49{
50 SetTitle( aJob->GetOptionsDialogTitle() );
51
52 for( const auto& [k, name] : JOB_PCB_RENDER::GetFormatNameMap() )
53 m_choiceFormat->Append( wxGetTranslation( name ) );
54
55 for( const auto& [k, name] : bgStyleMap )
56 m_choiceBgStyle->Append( wxGetTranslation( name ) );
57
58 for( const auto& [k, name] : qualityMap )
59 m_choiceQuality->Append( wxGetTranslation( name ) );
60
61 for( const auto& [k, name] : sideMap )
62 m_choiceSide->Append( wxGetTranslation( name ) );
63
65}
66
67
69{
70 int selIndx = m_choiceFormat->GetSelection();
71 auto it = JOB_PCB_RENDER::GetFormatNameMap().begin();
72 std::advance( it, selIndx );
73 return it->first;
74}
75
76
78{
79 auto it = JOB_PCB_RENDER::GetFormatNameMap().find( aFormat );
80
81 if( it != JOB_PCB_RENDER::GetFormatNameMap().end() )
82 {
83 int idx = std::distance( JOB_PCB_RENDER::GetFormatNameMap().begin(), it );
84 m_choiceFormat->SetSelection( idx );
85 }
86}
87
88
90{
91 int selIndx = m_choiceSide->GetSelection();
92 auto it = sideMap.begin();
93 std::advance( it, selIndx );
94 return it->first;
95}
96
97
99{
100 auto it = sideMap.find( aSide );
101
102 if( it != sideMap.end() )
103 {
104 int idx = std::distance( sideMap.begin(), it );
105 m_choiceSide->SetSelection( idx );
106 }
107}
108
109
111{
112 int selIndx = m_choiceQuality->GetSelection();
113 auto it = qualityMap.begin();
114 std::advance( it, selIndx );
115 return it->first;
116}
117
118
120{
121 auto it = qualityMap.find( aQuality );
122
123 if( it != qualityMap.end() )
124 {
125 int idx = std::distance( qualityMap.begin(), it );
126 m_choiceQuality->SetSelection( idx );
127 }
128}
129
130
132{
133 int selIndx = m_choiceBgStyle->GetSelection();
134 auto it = bgStyleMap.begin();
135 std::advance( it, selIndx );
136 return it->first;
137}
138
139
141{
142 auto it = bgStyleMap.find( aBgStyle );
143
144 if( it != bgStyleMap.end() )
145 {
146 int idx = std::distance( bgStyleMap.begin(), it );
147 m_choiceBgStyle->SetSelection( idx );
148 }
149}
150
151
153{
155
160 m_job->m_zoom = m_spinCtrlZoom->GetValue();
161 m_job->m_floor = m_cbFloor->GetValue();
162
163 m_job->m_width = m_spinCtrlWidth->GetValue();
164 m_job->m_height = m_spinCtrlHeight->GetValue();
165
166 m_radioProjection->GetSelection() == 0 ? m_job->m_perspective = true
167 : m_job->m_perspective = false;
168
169 return true;
170}
171
172
174{
176
181 m_spinCtrlZoom->SetValue( m_job->m_zoom );
182 m_radioProjection->SetSelection( m_job->m_perspective ? 0 : 1 );
183 m_cbFloor->SetValue( m_job->m_floor );
184
185 int width = m_job->m_width;
186 int height = m_job->m_height;
187
188 // if the values are the job constructor default, use the screen size
189 // as a reasonable default
190 if (width == 0 || height == 0)
191 {
192 int disp = wxDisplay::GetFromWindow( this );
193 wxRect rect = wxDisplay( disp ).GetGeometry();
194
195 if( width == 0 )
196 width = rect.GetWidth();
197
198 if( height == 0 )
199 height = rect.GetHeight();
200 }
201
202 m_spinCtrlWidth->SetValue( width );
203 m_spinCtrlHeight->SetValue( height );
204
205 return true;
206}
const char * name
Definition: DXF_plotter.cpp:57
Class DIALOG_RENDER_JOB_BASE.
wxSpinCtrlDouble * m_spinCtrlZoom
JOB_PCB_RENDER::FORMAT getSelectedFormat()
DIALOG_RENDER_JOB(wxWindow *aParent, JOB_PCB_RENDER *aJob)
void setSelectedFormat(JOB_PCB_RENDER::FORMAT aFormat)
void setSelectedBgStyle(JOB_PCB_RENDER::BG_STYLE aBgStyle)
void setSelectedQuality(JOB_PCB_RENDER::QUALITY aSide)
JOB_PCB_RENDER::SIDE getSelectedSide()
JOB_PCB_RENDER::QUALITY getSelectedQuality()
JOB_PCB_RENDER::BG_STYLE getSelectedBgStyle()
JOB_PCB_RENDER * m_job
bool TransferDataFromWindow() override
void setSelectedSide(JOB_PCB_RENDER::SIDE aSide)
bool TransferDataToWindow() override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
static std::map< JOB_PCB_RENDER::FORMAT, wxString > & GetFormatNameMap()
BG_STYLE m_bgStyle
wxString GetOptionsDialogTitle() const override
void SetOutputPath(const wxString &aPath)
Definition: job.cpp:138
wxString GetOutputPath() const
Definition: job.h:155
#define _HKI(x)
static std::map< JOB_PCB_RENDER::BG_STYLE, wxString > bgStyleMap
static std::map< JOB_PCB_RENDER::SIDE, wxString > sideMap
static std::map< JOB_PCB_RENDER::QUALITY, wxString > qualityMap
Some functions to handle hotkeys in KiCad.