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#include <pgm_base.h>
28
29
30static std::map<JOB_PCB_RENDER::BG_STYLE, wxString> bgStyleMap = {
34};
35
36static std::map<JOB_PCB_RENDER::SIDE, wxString> sideMap = {
37 { JOB_PCB_RENDER::SIDE::BACK, _HKI( "Back" ) },
38 { JOB_PCB_RENDER::SIDE::BOTTOM, _HKI( "Bottom" ) },
39 { JOB_PCB_RENDER::SIDE::FRONT, _HKI( "Front" ) },
40 { JOB_PCB_RENDER::SIDE::LEFT, _HKI( "Left" ) },
41 { JOB_PCB_RENDER::SIDE::RIGHT, _HKI( "Right" ) },
43};
44
46 DIALOG_RENDER_JOB_BASE( aParent ),
47 m_job( aJob )
48{
49 SetTitle( aJob->GetSettingsDialogTitle() );
50
51 for( const auto& [k, name] : JOB_PCB_RENDER::GetFormatNameMap() )
52 m_choiceFormat->Append( wxGetTranslation( name ) );
53
54 for( const auto& [k, name] : bgStyleMap )
55 m_choiceBgStyle->Append( wxGetTranslation( name ) );
56
57 for( const auto& [k, name] : sideMap )
58 m_choiceSide->Append( wxGetTranslation( name ) );
59
61 {
62 for( const LAYER_PRESET_3D& preset : cfg->m_LayerPresets )
63 m_presetCtrl->Append( preset.name );
64 }
65
67}
68
69
71{
72 int selIndx = m_choiceFormat->GetSelection();
73 auto it = JOB_PCB_RENDER::GetFormatNameMap().begin();
74 std::advance( it, selIndx );
75 return it->first;
76}
77
78
80{
81 auto it = JOB_PCB_RENDER::GetFormatNameMap().find( aFormat );
82
84 {
85 int idx = std::distance( JOB_PCB_RENDER::GetFormatNameMap().begin(), it );
86 m_choiceFormat->SetSelection( idx );
87 }
88}
89
90
92{
93 int selIndx = m_choiceSide->GetSelection();
94 auto it = sideMap.begin();
95 std::advance( it, selIndx );
96 return it->first;
97}
98
99
101{
102 auto it = sideMap.find( aSide );
103
104 if( it != sideMap.end() )
105 {
106 int idx = std::distance( sideMap.begin(), it );
107 m_choiceSide->SetSelection( idx );
108 }
109}
110
111
113{
114 int selIndx = m_choiceBgStyle->GetSelection();
115 auto it = bgStyleMap.begin();
116 std::advance( it, selIndx );
117 return it->first;
118}
119
120
122{
123 auto it = bgStyleMap.find( aBgStyle );
124
125 if( it != bgStyleMap.end() )
126 {
127 int idx = std::distance( bgStyleMap.begin(), it );
128 m_choiceBgStyle->SetSelection( idx );
129 }
130}
131
132
134{
135 m_job->SetConfiguredOutputPath( m_textCtrlOutputFile->GetValue() );
136
137 m_job->m_format = getSelectedFormat();
139
140 if( m_presetCtrl->GetSelection() == 0 )
141 m_job->m_appearancePreset = "";
142 else if( m_presetCtrl->GetSelection() == 1 )
143 m_job->m_appearancePreset = wxString( FOLLOW_PCB ).ToStdString();
144 else if( m_presetCtrl->GetSelection() == 2 )
145 m_job->m_appearancePreset = wxString( FOLLOW_PLOT_SETTINGS ).ToStdString();
146 else
147 m_job->m_appearancePreset = m_presetCtrl->GetStringSelection();
148
149 m_job->m_useBoardStackupColors = m_cbUseBoardStackupColors->GetValue();
150
151 m_job->m_bgStyle = getSelectedBgStyle();
152 m_job->m_side = getSelectedSide();
153 m_job->m_zoom = m_spinCtrlZoom->GetValue();
154 m_job->m_proceduralTextures = m_cbRaytracing_proceduralTextures->GetValue();
155 m_job->m_floor = m_cbRaytracing_addFloor->GetValue();
156 m_job->m_antiAlias = m_cbRaytracing_antiAliasing->GetValue();
157 m_job->m_postProcess = m_cbRaytracing_postProcessing->GetValue();
158
159 m_job->m_width = m_spinCtrlWidth->GetValue();
160 m_job->m_height = m_spinCtrlHeight->GetValue();
161
162 m_job->m_pivot.x = m_spinCtrlPivotX->GetValue();
163 m_job->m_pivot.y = m_spinCtrlPivotY->GetValue();
164 m_job->m_pivot.z = m_spinCtrlPivotZ->GetValue();
165
166 m_job->m_pan.x = m_spinCtrlPanX->GetValue();
167 m_job->m_pan.y = m_spinCtrlPanY->GetValue();
168 m_job->m_pan.z = m_spinCtrlPanZ->GetValue();
169
170 m_job->m_rotation.x = m_spinCtrlRotX->GetValue();
171 m_job->m_rotation.y = m_spinCtrlRotY->GetValue();
172 m_job->m_rotation.z = m_spinCtrlRotZ->GetValue();
173
174 m_job->m_lightTopIntensity.SetAll( m_spinCtrlLightsTop->GetValue() );
175 m_job->m_lightBottomIntensity.SetAll( m_spinCtrlLightsBottom->GetValue() );
176 m_job->m_lightSideIntensity.SetAll( m_spinCtrlLightsSides->GetValue() );
177 m_job->m_lightCameraIntensity.SetAll( m_spinCtrlLightsCamera->GetValue() );
178
179 m_job->m_lightSideElevation = m_spinCtrlLightsSideElevation->GetValue();
180
181 m_radioProjection->GetSelection() == 0 ? m_job->m_perspective = true
182 : m_job->m_perspective = false;
183
184 return true;
185}
186
187
189{
190 m_textCtrlOutputFile->SetValue( m_job->GetConfiguredOutputPath() );
191
192 setSelectedFormat( m_job->m_format );
193
194 if( m_job->m_appearancePreset == wxString( FOLLOW_PCB ).ToStdString() )
195 m_presetCtrl->SetSelection( 1 );
196 else if( m_job->m_appearancePreset == wxString( FOLLOW_PLOT_SETTINGS ).ToStdString() )
197 m_presetCtrl->SetSelection( 2 );
198 else if( !m_presetCtrl->SetStringSelection( m_job->m_appearancePreset ) )
199 m_presetCtrl->SetSelection( 0 );
200
201 m_cbUseBoardStackupColors->SetValue( m_job->m_useBoardStackupColors );
202
203 setSelectedBgStyle( m_job->m_bgStyle );
204 setSelectedSide( m_job->m_side );
205 m_spinCtrlZoom->SetValue( m_job->m_zoom );
206 m_radioProjection->SetSelection( m_job->m_perspective ? 0 : 1 );
207 m_cbRaytracing_proceduralTextures->SetValue( m_job->m_proceduralTextures );
208 m_cbRaytracing_addFloor->SetValue( m_job->m_floor );
209 m_cbRaytracing_antiAliasing->SetValue( m_job->m_antiAlias );
210 m_cbRaytracing_postProcessing->SetValue( m_job->m_postProcess );
211
212 int width = m_job->m_width;
213 int height = m_job->m_height;
214
215 // if the values are the job constructor default, use the screen size
216 // as a reasonable default
217 if (width == 0 || height == 0)
218 {
219 int disp = wxDisplay::GetFromWindow( this );
220 wxRect rect = wxDisplay( disp ).GetGeometry();
221
222 if( width == 0 )
223 width = rect.GetWidth();
224
225 if( height == 0 )
226 height = rect.GetHeight();
227 }
228
229 m_spinCtrlWidth->SetValue( width );
230 m_spinCtrlHeight->SetValue( height );
231
232 m_spinCtrlPivotX->SetValue( m_job->m_pivot.x );
233 m_spinCtrlPivotY->SetValue( m_job->m_pivot.y );
234 m_spinCtrlPivotZ->SetValue( m_job->m_pivot.z );
235
236 m_spinCtrlPanX->SetValue( m_job->m_pan.x );
237 m_spinCtrlPanY->SetValue( m_job->m_pan.y );
238 m_spinCtrlPanZ->SetValue( m_job->m_pan.z );
239
240 m_spinCtrlRotX->SetValue( m_job->m_rotation.x );
241 m_spinCtrlRotY->SetValue( m_job->m_rotation.y );
242 m_spinCtrlRotZ->SetValue( m_job->m_rotation.z );
243
244 m_spinCtrlLightsTop->SetValue( m_job->m_lightTopIntensity.x );
245 m_spinCtrlLightsBottom->SetValue( m_job->m_lightBottomIntensity.x );
246 m_spinCtrlLightsSides->SetValue( m_job->m_lightSideIntensity.x );
247 m_spinCtrlLightsCamera->SetValue( m_job->m_lightCameraIntensity.x );
248
249 m_spinCtrlLightsSideElevation->SetValue( m_job->m_lightSideElevation );
250
251 return true;
252}
const char * name
wxSpinCtrlDouble * m_spinCtrlLightsBottom
wxSpinCtrlDouble * m_spinCtrlRotX
wxSpinCtrlDouble * m_spinCtrlLightsSides
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
DIALOG_RENDER_JOB_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Render PCB Job Options"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE)
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={})
static std::map< JOB_PCB_RENDER::FORMAT, wxString > & GetFormatNameMap()
wxString GetSettingsDialogTitle() const override
static std::map< JOB_PCB_RENDER::BG_STYLE, wxString > bgStyleMap
static std::map< JOB_PCB_RENDER::SIDE, wxString > sideMap
#define FOLLOW_PLOT_SETTINGS
#define FOLLOW_PCB
Some functions to handle hotkeys in KiCad.
#define _HKI(x)
Definition page_info.cpp:44
see class PGM_BASE
T * GetAppSettings(const char *aFilename)
wxString name
A name for this layer set.
VECTOR2I end