KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
command_pcb_export_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 along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21#include <cli/exit_codes.h>
23#include <kiface_base.h>
24#include <string_utils.h>
25#include <wx/crt.h>
26
27#include <macros.h>
28#include <locale_io.h>
29
30#define ARG_COMPRESS "--compression"
31#define ARG_UNITS "--units"
32
35{
38
39 m_argParser.add_description( std::string( "Export the PCB in ODB++ format" ) );
40
41 m_argParser.add_argument( ARG_PRECISION )
42 .help( std::string( "Precision" ) )
43 .scan<'i', int>()
44 .default_value( 2 )
45 .metavar( "PRECISION" );
46
47 m_argParser.add_argument( ARG_COMPRESS )
48 .default_value( std::string( "zip" ) )
49 .help( std::string( "Compression mode" ) )
50 .choices( "none", "zip", "tgz" );
51
52 m_argParser.add_argument( ARG_UNITS )
53 .default_value( std::string( "mm" ) )
54 .help( std::string( "Units" ) )
55 .choices( "mm", "in" );
56}
57
58
60{
61 std::unique_ptr<JOB_EXPORT_PCB_ODB> job( new JOB_EXPORT_PCB_ODB() );
62
63 job->m_filename = m_argInput;
64 job->SetConfiguredOutputPath( m_argOutput );
65 job->m_drawingSheet = m_argDrawingSheet;
66 job->SetVarOverrides( m_argDefineVars );
67
68 if( !wxFile::Exists( job->m_filename ) )
69 {
70 wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
72 }
73
74 job->m_precision = m_argParser.get<int>( ARG_PRECISION );
75
76 wxString units = From_UTF8( m_argParser.get<std::string>( ARG_UNITS ).c_str() );
77
78 if( units == "mm" )
80 else if( units == "in" )
82
83 wxString compression = From_UTF8( m_argParser.get<std::string>( ARG_COMPRESS ).c_str() ).Lower();
84
85 if( compression == "zip" )
86 job->m_compressionMode = JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::ZIP;
87 else if( compression == "tgz" )
88 job->m_compressionMode = JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::TGZ;
89 else if( compression == "none" )
90 job->m_compressionMode = JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE;
91
93 return aKiway.ProcessJob( KIWAY::FACE_PCB, job.get() );
94}
argparse::ArgumentParser m_argParser
Definition: command.h:100
void addDefineArg()
Set up the drawing sheet arg used by many of the export commands.
Definition: command.cpp:168
void addDrawingSheetArg()
Set up the drawing sheet arg used by many of the export commands.
Definition: command.cpp:156
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:285
@ FACE_PCB
pcbnew DSO
Definition: kiway.h:293
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr)
Definition: kiway.cpp:711
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
#define ARG_UNITS
#define ARG_PRECISION
#define ARG_COMPRESS
#define _(s)
This file contains miscellaneous commonly used macros and functions.
static const int ERR_INVALID_INPUT_FILE
Definition: exit_codes.h:33
std::vector< FAB_LAYER_COLOR > dummy
wxString From_UTF8(const char *cstring)