KiCad PCB EDA Suite
Loading...
Searching...
No Matches
job_pcb_render.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) 2023 Mark Roszko <[email protected]>
5 * Copyright (C) 2024 Alex Shvartzkop <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <jobs/job_registry.h>
23#include <jobs/job_pcb_render.h>
24#include <i18n_utility.h>
25
26
27namespace nlohmann
28{
29template <>
30struct adl_serializer<VECTOR3D>
31{
32 static void from_json( const json& j, VECTOR3D& s )
33 {
34 if( !j.is_array() || j.size() != 3 )
35 throw std::invalid_argument( "JSON array size should be 3 for VECTOR3D" );
36
37 s.x = j[0];
38 s.y = j[1];
39 s.z = j[2];
40 }
41
42 static void to_json( json& j, const VECTOR3D& s ) { j = json::array( { s.x, s.y, s.z } ); }
43};
44} // namespace nlohmann
45
46
47std::map<JOB_PCB_RENDER::FORMAT, wxString> outputFormatNameMap = {
48 { JOB_PCB_RENDER::FORMAT::JPEG, wxT( "JPEG" ) },
49 { JOB_PCB_RENDER::FORMAT::PNG, wxT( "PNG" ) }
50};
51
52
54 {
57 } )
58
60 {
64 } )
65
67 {
69 { JOB_PCB_RENDER::SIDE::BOTTOM, "bottom" },
70 { JOB_PCB_RENDER::SIDE::FRONT, "front" },
72 { JOB_PCB_RENDER::SIDE::RIGHT, "right" },
74 } )
75
77 {
81 } )
82
84 JOB( "render", false ), m_filename()
85{
86 m_params.emplace_back( new JOB_PARAM<FORMAT>( "format", &m_format, m_format ) );
87 m_params.emplace_back( new JOB_PARAM<QUALITY>( "quality", &m_quality, m_quality ) );
88 m_params.emplace_back( new JOB_PARAM<BG_STYLE>( "bg_style", &m_bgStyle, m_bgStyle ) );
89 m_params.emplace_back( new JOB_PARAM<SIDE>( "side", &m_side, m_side ) );
90
91 m_params.emplace_back( new JOB_PARAM<double>( "zoom", &m_zoom, m_zoom ) );
92 m_params.emplace_back( new JOB_PARAM<bool>( "perspective", &m_perspective, m_perspective ) );
93 m_params.emplace_back( new JOB_PARAM<bool>( "floor", &m_floor, m_floor ) );
94
95 m_params.emplace_back( new JOB_PARAM<int>( "width", &m_width, m_width ) );
96 m_params.emplace_back( new JOB_PARAM<int>( "height", &m_height, m_height ) );
97
98 m_params.emplace_back( new JOB_PARAM<double>( "pivot_x", &m_pivot.x, m_pivot.x ) );
99 m_params.emplace_back( new JOB_PARAM<double>( "pivot_y", &m_pivot.y, m_pivot.y ) );
100 m_params.emplace_back( new JOB_PARAM<double>( "pivot_z", &m_pivot.z, m_pivot.z ) );
101
102 m_params.emplace_back( new JOB_PARAM<double>( "pan_x", &m_pan.x, m_pan.x ) );
103 m_params.emplace_back( new JOB_PARAM<double>( "pan_y", &m_pan.y, m_pan.y ) );
104 m_params.emplace_back( new JOB_PARAM<double>( "pan_z", &m_pan.z, m_pan.z ) );
105
106 m_params.emplace_back( new JOB_PARAM<double>( "rotation_x", &m_rotation.x, m_rotation.x ) );
107 m_params.emplace_back( new JOB_PARAM<double>( "rotation_y", &m_rotation.y, m_rotation.y ) );
108 m_params.emplace_back( new JOB_PARAM<double>( "rotation_z", &m_rotation.z, m_rotation.z ) );
109
110 m_params.emplace_back( new JOB_PARAM<VECTOR3D>( "light_top_intensity", &m_lightTopIntensity, m_lightTopIntensity ) );
111 m_params.emplace_back( new JOB_PARAM<VECTOR3D>( "light_bottom_intensity", &m_lightBottomIntensity, m_lightBottomIntensity ) );
112 m_params.emplace_back( new JOB_PARAM<VECTOR3D>( "light_side_intensity", &m_lightSideIntensity, m_lightSideIntensity ) );
113 m_params.emplace_back( new JOB_PARAM<VECTOR3D>( "light_camera_intensity", &m_lightCameraIntensity, m_lightCameraIntensity ) );
114
115 m_params.emplace_back( new JOB_PARAM<int>( "light_side_elevation", &m_lightSideElevation, m_lightSideElevation ) );
116}
117
118
119std::map<JOB_PCB_RENDER::FORMAT, wxString>& JOB_PCB_RENDER::GetFormatNameMap()
120{
121 return outputFormatNameMap;
122}
123
124
126{
127 return wxString::Format( _( "Render %s" ), GetFormatNameMap()[m_format] );
128}
129
130
132{
133 return _( "Render PCB Job Settings" );
134}
135
136
137REGISTER_JOB( pcb_render, _HKI( "PCB: Render" ), KIWAY::FACE_PCB, JOB_PCB_RENDER );
Definition: job.h:50
wxString GetDefaultDescription() const override
static std::map< JOB_PCB_RENDER::FORMAT, wxString > & GetFormatNameMap()
wxString GetSettingsDialogTitle() const override
An simple container class that lets us dispatch output jobs to kifaces.
Definition: job.h:182
@ FACE_PCB
pcbnew DSO
Definition: kiway.h:293
T y
Definition: vector3.h:64
T z
Definition: vector3.h:65
T x
Definition: vector3.h:63
#define _HKI(x)
#define _(s)
nlohmann::json json
Definition: gerbview.cpp:47
Some functions to handle hotkeys in KiCad.
std::map< JOB_PCB_RENDER::FORMAT, wxString > outputFormatNameMap
NLOHMANN_JSON_SERIALIZE_ENUM(JOB_PCB_RENDER::FORMAT, { { JOB_PCB_RENDER::FORMAT::JPEG, "jpeg" }, { JOB_PCB_RENDER::FORMAT::PNG, "png" } }) NLOHMANN_JSON_SERIALIZE_ENUM(JOB_PCB_RENDER
#define REGISTER_JOB(job_name, title, face, T)
Definition: job_registry.h:64
static void to_json(json &j, const VECTOR3D &s)
static void from_json(const json &j, VECTOR3D &s)