KiCad PCB EDA Suite
Loading...
Searching...
No Matches
job_export_pcb_odb.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
21#include <jobs/job_registry.h>
22#include <i18n_utility.h>
24#include <lset.h>
25#include <json_conversions.h>
26
27
29{
30 aOverride = {};
31
32 if( !aJson.is_object() || !aJson.contains( "layer" ) || !aJson["layer"].is_string() )
33 return;
34
35 if( ( aJson.contains( "include" ) && !aJson["include"].is_boolean() )
36 || ( aJson.contains( "odb_name" ) && !aJson["odb_name"].is_string() )
37 || ( aJson.contains( "odb_type" ) && !aJson["odb_type"].is_string() ) )
38 {
39 return;
40 }
41
42 wxString layerName = aJson["layer"].get<wxString>();
43 aOverride.m_layer = static_cast<PCB_LAYER_ID>( LSET::NameToLayer( layerName ) );
44
45 if( aJson.contains( "include" ) )
46 aOverride.m_include = aJson["include"].get<bool>();
47
48 if( aJson.contains( "odb_name" ) )
49 aOverride.m_odbName = aJson["odb_name"].get<wxString>();
50
51 if( aJson.contains( "odb_type" ) )
52 aOverride.m_odbType = aJson["odb_type"].get<wxString>();
53}
54
55
57{
58 aJson = { { "layer", LSET::Name( aOverride.m_layer ) }, { "include", aOverride.m_include } };
59
60 if( !aOverride.m_odbName.IsEmpty() )
61 aJson["odb_name"] = aOverride.m_odbName;
62
63 if( !aOverride.m_odbType.IsEmpty() )
64 aJson["odb_type"] = aOverride.m_odbType;
65}
66
67
80
82 {
86 } )
87
88
90 JOB_EXPORT_PCB_FAB( "odb" ),
91 m_compressionMode( ODB_COMPRESSION::ZIP )
92{
93 m_params.emplace_back( new JOB_PARAM<ODB_COMPRESSION>( "compression", &m_compressionMode, m_compressionMode ) );
94 m_params.emplace_back(
95 new JOB_PARAM<VARIANT_PACKAGING>( "variant_packaging", &m_variantPackaging, m_variantPackaging ) );
96 m_params.emplace_back( new JOB_PARAM<ORIGIN>( "origin", &m_origin, m_origin ) );
97 m_params.emplace_back( new JOB_PARAM<wxString>( "product_name", &m_productName, m_productName ) );
98 m_params.emplace_back( new JOB_PARAM<bool>( "board_metadata", &m_boardMetadata, m_boardMetadata ) );
99 m_params.emplace_back( new JOB_PARAM_LIST<ODB_LAYER_OVERRIDE>( "layers", &m_layerOverrides, m_layerOverrides ) );
100}
101
102
104{
105 switch( aDataSet )
106 {
111 case DATA_SET::TEST:
112 return true;
113
114 // An ODB++ product has no BOM-only or stencil-only form
115 default:
116 return false;
117 }
118}
119
120
122{
123 return _( "Export ODB++" );
124}
125
126
128{
129 return _( "Export ODB++ Job Settings" );
130}
131
132
133void JOB_EXPORT_PCB_ODB::SetDefaultOutputPath( const wxString& aReferenceName )
134{
135 wxFileName fn = aReferenceName;
136
137 fn.SetExt( "zip" );
138
139 SetConfiguredOutputPath( fn.GetFullName() );
140}
141
142REGISTER_JOB( pcb_export_odb, _HKI( "PCB: Export ODB++" ), KIWAY::FACE_PCB,
DATA_SET
Columns of the IPC-2581C function mode table, Table 4 p 80.
void SetDefaultOutputPath(const wxString &aReferenceName)
wxString GetSettingsDialogTitle() const override
bool SupportsDataSet(DATA_SET aDataSet) const override
wxString GetDefaultDescription() const override
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
Definition job.cpp:157
@ FACE_PCB
pcbnew DSO
Definition kiway.h:356
static int NameToLayer(wxString &aName)
Return the layer number from a layer name.
Definition lset.cpp:113
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition lset.cpp:184
#define _(s)
Some functions to handle hotkeys in KiCad.
NLOHMANN_JSON_SERIALIZE_ENUM(JOB_EXPORT_PCB_ODB::ODB_COMPRESSION, { { JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE, "none" }, { JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::ZIP, "zip" }, { JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::TGZ, "tgz" }, }) NLOHMANN_JSON_SERIALIZE_ENUM(JOB_EXPORT_PCB_ODB
#define REGISTER_JOB(job_name, title, face, T)
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
#define _HKI(x)
Definition page_info.cpp:40
static KICOMMON_API void from_json(const json &aJson, ODB_LAYER_OVERRIDE &aOverride)
static KICOMMON_API void to_json(json &aJson, const ODB_LAYER_OVERRIDE &aOverride)
Definition of file extensions used in Kicad.