KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 <mark.roszko@gmail.com>
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::SIDE, wxString> sideMap = {
33 { JOB_PCB_RENDER::SIDE::BACK, _HKI( "Back" ) },
34 { JOB_PCB_RENDER::SIDE::BOTTOM, _HKI( "Bottom" ) },
35 { JOB_PCB_RENDER::SIDE::FRONT, _HKI( "Front" ) },
36 { JOB_PCB_RENDER::SIDE::LEFT, _HKI( "Left" ) },
37 { JOB_PCB_RENDER::SIDE::RIGHT, _HKI( "Right" ) },
39};
40
42 DIALOG_RENDER_JOB_BASE( aParent ), m_job( aJob )
43{
44 SetTitle( aJob->GetSettingsDialogTitle() );
45
46 for( const auto& [k, name] : JOB_PCB_RENDER::GetFormatNameMap() )
47 m_choiceFormat->Append( wxGetTranslation( name ) );
48
49 for( const auto& [k, name] : bgStyleMap )
50 m_choiceBgStyle->Append( wxGetTranslation( name ) );
51
52 for( const auto& [k, name] : sideMap )
53 m_choiceSide->Append( wxGetTranslation( name ) );
54
56}
57
58
60{
61 int selIndx = m_choiceFormat->GetSelection();
62 auto it = JOB_PCB_RENDER::GetFormatNameMap().begin();
63 std::advance( it, selIndx );
64 return it->first;
65}
66
67
69{
70 auto it = JOB_PCB_RENDER::GetFormatNameMap().find( aFormat );
71
73 {
74 int idx = std::distance( JOB_PCB_RENDER::GetFormatNameMap().begin(), it );
75 m_choiceFormat->SetSelection( idx );
76 }
77}
78
79
81{
82 int selIndx = m_choiceSide->GetSelection();
83 auto it = sideMap.begin();
84 std::advance( it, selIndx );
85 return it->first;
86}
87
88
90{
91 auto it = sideMap.find( aSide );
92
93 if( it != sideMap.end() )
94 {
95 int idx = std::distance( sideMap.begin(), it );
96 m_choiceSide->SetSelection( idx );
97 }
98}
99
100
102{
103 int selIndx = m_choiceBgStyle->GetSelection();
104 auto it = bgStyleMap.begin();
105 std::advance( it, selIndx );
106 return it->first;
107}
108
109
111{
112 auto it = bgStyleMap.find( aBgStyle );
113
114 if( it != bgStyleMap.end() )
115 {
116 int idx = std::distance( bgStyleMap.begin(), it );
117 m_choiceBgStyle->SetSelection( idx );
118 }
119}
120
121
123{
125
130 m_job->m_zoom = m_spinCtrlZoom->GetValue();
135
136 m_job->m_width = m_spinCtrlWidth->GetValue();
137 m_job->m_height = m_spinCtrlHeight->GetValue();
138
139 m_job->m_pivot.x = m_spinCtrlPivotX->GetValue();
140 m_job->m_pivot.y = m_spinCtrlPivotY->GetValue();
141 m_job->m_pivot.z = m_spinCtrlPivotZ->GetValue();
142
143 m_job->m_pan.x = m_spinCtrlPanX->GetValue();
144 m_job->m_pan.y = m_spinCtrlPanY->GetValue();
145 m_job->m_pan.z = m_spinCtrlPanZ->GetValue();
146
147 m_job->m_rotation.x = m_spinCtrlRotX->GetValue();
148 m_job->m_rotation.y = m_spinCtrlRotY->GetValue();
149 m_job->m_rotation.z = m_spinCtrlRotZ->GetValue();
150
155
157
158 m_radioProjection->GetSelection() == 0 ? m_job->m_perspective = true
159 : m_job->m_perspective = false;
160
161 return true;
162}
163
164
166{
168
172 m_spinCtrlZoom->SetValue( m_job->m_zoom );
173 m_radioProjection->SetSelection( m_job->m_perspective ? 0 : 1 );
178
179 int width = m_job->m_width;
180 int height = m_job->m_height;
181
182 // if the values are the job constructor default, use the screen size
183 // as a reasonable default
184 if (width == 0 || height == 0)
185 {
186 int disp = wxDisplay::GetFromWindow( this );
187 wxRect rect = wxDisplay( disp ).GetGeometry();
188
189 if( width == 0 )
190 width = rect.GetWidth();
191
192 if( height == 0 )
193 height = rect.GetHeight();
194 }
195
196 m_spinCtrlWidth->SetValue( width );
197 m_spinCtrlHeight->SetValue( height );
198
199 m_spinCtrlPivotX->SetValue( m_job->m_pivot.x );
200 m_spinCtrlPivotY->SetValue( m_job->m_pivot.y );
201 m_spinCtrlPivotZ->SetValue( m_job->m_pivot.z );
202
203 m_spinCtrlPanX->SetValue( m_job->m_pan.x );
204 m_spinCtrlPanY->SetValue( m_job->m_pan.y );
205 m_spinCtrlPanZ->SetValue( m_job->m_pan.z );
206
207 m_spinCtrlRotX->SetValue( m_job->m_rotation.x );
208 m_spinCtrlRotY->SetValue( m_job->m_rotation.y );
209 m_spinCtrlRotZ->SetValue( m_job->m_rotation.z );
210
215
217
218 return true;
219}
const char * name
Definition: DXF_plotter.cpp:59
Class DIALOG_RENDER_JOB_BASE.
wxSpinCtrlDouble * m_spinCtrlLightsBottom
wxSpinCtrlDouble * m_spinCtrlRotX
wxCheckBox * m_cbRaytracing_postProcessing
wxSpinCtrlDouble * m_spinCtrlLightsSides
wxCheckBox * m_cbRaytracing_antiAliasing
wxSpinCtrl * m_spinCtrlLightsSideElevation
wxCheckBox * m_cbRaytracing_proceduralTextures
wxSpinCtrlDouble * m_spinCtrlZoom
wxSpinCtrlDouble * m_spinCtrlPanX
wxSpinCtrlDouble * m_spinCtrlPivotY
wxSpinCtrlDouble * m_spinCtrlLightsTop
wxSpinCtrlDouble * m_spinCtrlRotY
wxSpinCtrlDouble * m_spinCtrlPanZ
wxSpinCtrlDouble * m_spinCtrlPivotX
wxSpinCtrlDouble * m_spinCtrlPanY
wxSpinCtrlDouble * m_spinCtrlPivotZ
wxSpinCtrlDouble * m_spinCtrlLightsCamera
wxSpinCtrlDouble * m_spinCtrlRotZ
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)
JOB_PCB_RENDER::SIDE getSelectedSide()
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={})
VECTOR3D m_lightBottomIntensity
VECTOR3D m_lightTopIntensity
static std::map< JOB_PCB_RENDER::FORMAT, wxString > & GetFormatNameMap()
BG_STYLE m_bgStyle
VECTOR3D m_lightCameraIntensity
VECTOR3D m_rotation
bool m_proceduralTextures
wxString GetSettingsDialogTitle() const override
VECTOR3D m_pivot
VECTOR3D m_lightSideIntensity
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
Definition: job.cpp:153
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
Definition: job.h:226
T y
Definition: vector3.h:64
T z
Definition: vector3.h:65
VECTOR3< T > SetAll(T val)
Set all elements to val.
Definition: vector3.h:175
T x
Definition: vector3.h:63
#define _HKI(x)
static std::map< JOB_PCB_RENDER::BG_STYLE, wxString > bgStyleMap
static std::map< JOB_PCB_RENDER::SIDE, wxString > sideMap
Some functions to handle hotkeys in KiCad.
VECTOR2I end