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 if( EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) )
63 {
64 for( const LAYER_PRESET_3D& preset : cfg->m_LayerPresets )
65 m_presetCtrl->Append( preset.name );
66 }
67
69}
70
71
73{
74 int selIndx = m_choiceFormat->GetSelection();
75 auto it = JOB_PCB_RENDER::GetFormatNameMap().begin();
76 std::advance( it, selIndx );
77 return it->first;
78}
79
80
82{
83 auto it = JOB_PCB_RENDER::GetFormatNameMap().find( aFormat );
84
86 {
87 int idx = std::distance( JOB_PCB_RENDER::GetFormatNameMap().begin(), it );
88 m_choiceFormat->SetSelection( idx );
89 }
90}
91
92
94{
95 int selIndx = m_choiceSide->GetSelection();
96 auto it = sideMap.begin();
97 std::advance( it, selIndx );
98 return it->first;
99}
100
101
103{
104 auto it = sideMap.find( aSide );
105
106 if( it != sideMap.end() )
107 {
108 int idx = std::distance( sideMap.begin(), it );
109 m_choiceSide->SetSelection( idx );
110 }
111}
112
113
115{
116 int selIndx = m_choiceBgStyle->GetSelection();
117 auto it = bgStyleMap.begin();
118 std::advance( it, selIndx );
119 return it->first;
120}
121
122
124{
125 auto it = bgStyleMap.find( aBgStyle );
126
127 if( it != bgStyleMap.end() )
128 {
129 int idx = std::distance( bgStyleMap.begin(), it );
130 m_choiceBgStyle->SetSelection( idx );
131 }
132}
133
134
136{
138
141
142 if( m_presetCtrl->GetSelection() == 0 )
144 else
145 m_job->m_appearancePreset = m_presetCtrl->GetStringSelection();
146
149 m_job->m_zoom = m_spinCtrlZoom->GetValue();
154
155 m_job->m_width = m_spinCtrlWidth->GetValue();
156 m_job->m_height = m_spinCtrlHeight->GetValue();
157
158 m_job->m_pivot.x = m_spinCtrlPivotX->GetValue();
159 m_job->m_pivot.y = m_spinCtrlPivotY->GetValue();
160 m_job->m_pivot.z = m_spinCtrlPivotZ->GetValue();
161
162 m_job->m_pan.x = m_spinCtrlPanX->GetValue();
163 m_job->m_pan.y = m_spinCtrlPanY->GetValue();
164 m_job->m_pan.z = m_spinCtrlPanZ->GetValue();
165
166 m_job->m_rotation.x = m_spinCtrlRotX->GetValue();
167 m_job->m_rotation.y = m_spinCtrlRotY->GetValue();
168 m_job->m_rotation.z = m_spinCtrlRotZ->GetValue();
169
174
176
177 m_radioProjection->GetSelection() == 0 ? m_job->m_perspective = true
178 : m_job->m_perspective = false;
179
180 return true;
181}
182
183
185{
187
189
190 if( !m_presetCtrl->SetStringSelection( m_job->m_appearancePreset ) )
191 m_presetCtrl->SetSelection( 0 );
192
195 m_spinCtrlZoom->SetValue( m_job->m_zoom );
196 m_radioProjection->SetSelection( m_job->m_perspective ? 0 : 1 );
201
202 int width = m_job->m_width;
203 int height = m_job->m_height;
204
205 // if the values are the job constructor default, use the screen size
206 // as a reasonable default
207 if (width == 0 || height == 0)
208 {
209 int disp = wxDisplay::GetFromWindow( this );
210 wxRect rect = wxDisplay( disp ).GetGeometry();
211
212 if( width == 0 )
213 width = rect.GetWidth();
214
215 if( height == 0 )
216 height = rect.GetHeight();
217 }
218
219 m_spinCtrlWidth->SetValue( width );
220 m_spinCtrlHeight->SetValue( height );
221
222 m_spinCtrlPivotX->SetValue( m_job->m_pivot.x );
223 m_spinCtrlPivotY->SetValue( m_job->m_pivot.y );
224 m_spinCtrlPivotZ->SetValue( m_job->m_pivot.z );
225
226 m_spinCtrlPanX->SetValue( m_job->m_pan.x );
227 m_spinCtrlPanY->SetValue( m_job->m_pan.y );
228 m_spinCtrlPanZ->SetValue( m_job->m_pan.z );
229
230 m_spinCtrlRotX->SetValue( m_job->m_rotation.x );
231 m_spinCtrlRotY->SetValue( m_job->m_rotation.y );
232 m_spinCtrlRotZ->SetValue( m_job->m_rotation.z );
233
238
240
241 return true;
242}
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
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:226
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
T * GetAppSettings(const char *aFilename)
Return a handle to the a given settings by type.
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.
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1071
see class PGM_BASE
wxString name
A name for this layer set.
VECTOR2I end