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
60 if( EDA_3D_VIEWER_SETTINGS* cfg = GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) )
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{
136
139
140 if( m_presetCtrl->GetSelection() == 0 )
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
150
153 m_job->m_zoom = m_spinCtrlZoom->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
178
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{
191
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
202
205 m_spinCtrlZoom->SetValue( m_job->m_zoom );
206 m_radioProjection->SetSelection( m_job->m_perspective ? 0 : 1 );
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
248
250
251 return true;
252}
const char * name
Definition: DXF_plotter.cpp:62
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
bool m_useBoardStackupColors
VECTOR3D m_pivot
VECTOR3D m_lightSideIntensity
std::string m_appearancePreset
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:232
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
#define FOLLOW_PLOT_SETTINGS
#define FOLLOW_PCB
Some functions to handle hotkeys in KiCad.
see class PGM_BASE
wxString name
A name for this layer set.
VECTOR2I end