mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 21:43:43 +00:00
ODB++: Add to CLI and jobs system
This commit is contained in:
parent
76fc7d0c24
commit
f504a07556
@ -70,6 +70,7 @@ set( KICOMMON_SRCS
|
||||
jobs/job_export_pcb_gerber.cpp
|
||||
jobs/job_export_pcb_gerbers.cpp
|
||||
jobs/job_export_pcb_ipc2581.cpp
|
||||
jobs/job_export_pcb_odb.cpp
|
||||
jobs/job_export_pcb_pdf.cpp
|
||||
jobs/job_export_pcb_plot.cpp
|
||||
jobs/job_export_pcb_pos.cpp
|
||||
|
70
common/jobs/job_export_pcb_odb.cpp
Normal file
70
common/jobs/job_export_pcb_odb.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <jobs/job_export_pcb_odb.h>
|
||||
#include <jobs/job_registry.h>
|
||||
#include <i18n_utility.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_ODB::ODB_UNITS,
|
||||
{
|
||||
{ JOB_EXPORT_PCB_ODB::ODB_UNITS::INCHES, "in" },
|
||||
{ JOB_EXPORT_PCB_ODB::ODB_UNITS::MILLIMETERS, "mm" },
|
||||
} )
|
||||
|
||||
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::JOB_EXPORT_PCB_ODB() :
|
||||
JOB( "odb", false ),
|
||||
m_filename(),
|
||||
m_drawingSheet(),
|
||||
m_units( ODB_UNITS::MILLIMETERS ),
|
||||
m_precision( 2 ),
|
||||
m_compressionMode( ODB_COMPRESSION::ZIP )
|
||||
{
|
||||
m_params.emplace_back( new JOB_PARAM<wxString>( "drawing_sheet", &m_drawingSheet, m_drawingSheet ) );
|
||||
m_params.emplace_back( new JOB_PARAM<ODB_UNITS>( "units", &m_units, m_units ) );
|
||||
m_params.emplace_back( new JOB_PARAM<int>( "precision", &m_precision, m_precision ) );
|
||||
m_params.emplace_back( new JOB_PARAM<ODB_COMPRESSION>( "compression", &m_compressionMode,
|
||||
m_compressionMode ) );
|
||||
}
|
||||
|
||||
|
||||
wxString JOB_EXPORT_PCB_ODB::GetDescription()
|
||||
{
|
||||
return wxString::Format( _( "ODB++ export" ) );
|
||||
}
|
||||
|
||||
|
||||
void JOB_EXPORT_PCB_ODB::SetDefaultOutputPath( const wxString& aReferenceName )
|
||||
{
|
||||
wxFileName fn = aReferenceName;
|
||||
|
||||
fn.SetExt( "zip" );
|
||||
|
||||
SetOutputPath( fn.GetFullName() );
|
||||
}
|
||||
|
||||
REGISTER_JOB( pcb_export_odb, _HKI( "PCB: Export ODB++" ), KIWAY::FACE_PCB,
|
||||
JOB_EXPORT_PCB_ODB );
|
56
common/jobs/job_export_pcb_odb.h
Normal file
56
common/jobs/job_export_pcb_odb.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef JOB_EXPORT_PCB_ODB_H
|
||||
#define JOB_EXPORT_PCB_ODB_H
|
||||
|
||||
#include <kicommon.h>
|
||||
#include <wx/string.h>
|
||||
#include "job.h"
|
||||
|
||||
class KICOMMON_API JOB_EXPORT_PCB_ODB : public JOB
|
||||
{
|
||||
public:
|
||||
JOB_EXPORT_PCB_ODB();
|
||||
wxString GetDescription() override;
|
||||
|
||||
void SetDefaultOutputPath( const wxString& aReferenceName );
|
||||
|
||||
enum class ODB_UNITS
|
||||
{
|
||||
MILLIMETERS,
|
||||
INCHES,
|
||||
};
|
||||
|
||||
enum class ODB_COMPRESSION
|
||||
{
|
||||
NONE,
|
||||
ZIP,
|
||||
};
|
||||
|
||||
wxString m_filename;
|
||||
wxString m_drawingSheet;
|
||||
|
||||
ODB_UNITS m_units;
|
||||
int m_precision;
|
||||
|
||||
ODB_COMPRESSION m_compressionMode;
|
||||
};
|
||||
|
||||
#endif
|
@ -57,6 +57,7 @@ set( KICAD_CLI_SRCS
|
||||
cli/command_pcb_export_gerbers.cpp
|
||||
cli/command_pcb_export_gencad.cpp
|
||||
cli/command_pcb_export_ipc2581.cpp
|
||||
cli/command_pcb_export_odb.cpp
|
||||
cli/command_pcb_export_pdf.cpp
|
||||
cli/command_pcb_export_pos.cpp
|
||||
cli/command_pcb_export_svg.cpp
|
||||
|
101
kicad/cli/command_pcb_export_odb.cpp
Normal file
101
kicad/cli/command_pcb_export_odb.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "command_pcb_export_odb.h"
|
||||
#include <cli/exit_codes.h>
|
||||
#include "jobs/job_export_pcb_odb.h"
|
||||
#include <kiface_base.h>
|
||||
#include <string_utils.h>
|
||||
#include <wx/crt.h>
|
||||
|
||||
#include <macros.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
#include <locale_io.h>
|
||||
|
||||
#define ARG_COMPRESS "--compression"
|
||||
#define ARG_UNITS "--units"
|
||||
|
||||
CLI::PCB_EXPORT_ODB_COMMAND::PCB_EXPORT_ODB_COMMAND() :
|
||||
PCB_EXPORT_BASE_COMMAND( "odb" )
|
||||
{
|
||||
addDrawingSheetArg();
|
||||
addDefineArg();
|
||||
|
||||
m_argParser.add_description( std::string( "Export the PCB in ODB++ format" ) );
|
||||
|
||||
m_argParser.add_argument( ARG_PRECISION )
|
||||
.help( std::string( "Precision" ) )
|
||||
.scan<'i', int>()
|
||||
.default_value( 2 )
|
||||
.metavar( "PRECISION" );
|
||||
|
||||
m_argParser.add_argument( ARG_COMPRESS )
|
||||
.default_value( std::string( "zip" ) )
|
||||
.help( std::string( "Compression mode" ) )
|
||||
.choices( "none", "zip" );
|
||||
|
||||
m_argParser.add_argument( ARG_UNITS )
|
||||
.default_value( std::string( "mm" ) )
|
||||
.help( std::string( "Units" ) )
|
||||
.choices( "mm", "in" );
|
||||
}
|
||||
|
||||
|
||||
int CLI::PCB_EXPORT_ODB_COMMAND::doPerform( KIWAY& aKiway )
|
||||
{
|
||||
int exitCode = PCB_EXPORT_BASE_COMMAND::doPerform( aKiway );
|
||||
|
||||
if( exitCode != EXIT_CODES::OK )
|
||||
return exitCode;
|
||||
|
||||
std::unique_ptr<JOB_EXPORT_PCB_ODB> job( new JOB_EXPORT_PCB_ODB() );
|
||||
|
||||
job->m_filename = m_argInput;
|
||||
job->SetOutputPath( m_argOutput );
|
||||
job->m_drawingSheet = m_argDrawingSheet;
|
||||
job->SetVarOverrides( m_argDefineVars );
|
||||
|
||||
if( !wxFile::Exists( job->m_filename ) )
|
||||
{
|
||||
wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
|
||||
return EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
}
|
||||
|
||||
job->m_precision = m_argParser.get<int>( ARG_PRECISION );
|
||||
|
||||
wxString units = From_UTF8( m_argParser.get<std::string>( ARG_UNITS ).c_str() );
|
||||
|
||||
if( units == "mm" )
|
||||
job->m_units = JOB_EXPORT_PCB_ODB::ODB_UNITS::MILLIMETERS;
|
||||
else if( units == "in" )
|
||||
job->m_units = JOB_EXPORT_PCB_ODB::ODB_UNITS::INCHES;
|
||||
|
||||
wxString compression = From_UTF8( m_argParser.get<std::string>( ARG_COMPRESS ).c_str() );
|
||||
|
||||
if( compression == "zip" )
|
||||
job->m_compressionMode = JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::ZIP;
|
||||
else
|
||||
job->m_compressionMode = JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE;
|
||||
|
||||
LOCALE_IO dummy;
|
||||
exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, job.get() );
|
||||
|
||||
return exitCode;
|
||||
}
|
40
kicad/cli/command_pcb_export_odb.h
Normal file
40
kicad/cli/command_pcb_export_odb.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_EXPORT_PCB_ODB_H
|
||||
#define COMMAND_EXPORT_PCB_ODB_H
|
||||
|
||||
#include "command_pcb_export_base.h"
|
||||
|
||||
|
||||
namespace CLI
|
||||
{
|
||||
#define ARG_PRECISION "--precision"
|
||||
|
||||
class PCB_EXPORT_ODB_COMMAND : public PCB_EXPORT_BASE_COMMAND
|
||||
{
|
||||
public:
|
||||
PCB_EXPORT_ODB_COMMAND();
|
||||
|
||||
protected:
|
||||
int doPerform( KIWAY& aKiway ) override;
|
||||
};
|
||||
} // namespace CLI
|
||||
|
||||
#endif
|
@ -59,6 +59,7 @@
|
||||
#include "cli/command_pcb_export_gerbers.h"
|
||||
#include "cli/command_pcb_export_gencad.h"
|
||||
#include "cli/command_pcb_export_ipc2581.h"
|
||||
#include "cli/command_pcb_export_odb.h"
|
||||
#include "cli/command_pcb_export_pdf.h"
|
||||
#include "cli/command_pcb_export_pos.h"
|
||||
#include "cli/command_pcb_export_svg.h"
|
||||
@ -129,6 +130,7 @@ static CLI::PCB_EXPORT_GERBER_COMMAND exportPcbGerberCmd{};
|
||||
static CLI::PCB_EXPORT_GERBERS_COMMAND exportPcbGerbersCmd{};
|
||||
static CLI::PCB_EXPORT_GENCAD_COMMAND exportPcbGencadCmd{};
|
||||
static CLI::PCB_EXPORT_IPC2581_COMMAND exportPcbIpc2581Cmd{};
|
||||
static CLI::PCB_EXPORT_ODB_COMMAND exportPcbOdbCmd{};
|
||||
static CLI::PCB_EXPORT_COMMAND exportPcbCmd{};
|
||||
static CLI::SCH_EXPORT_COMMAND exportSchCmd{};
|
||||
static CLI::SCH_COMMAND schCmd{};
|
||||
@ -195,6 +197,7 @@ static std::vector<COMMAND_ENTRY> commandStack = {
|
||||
&exportPcbGencadCmd,
|
||||
&exportPcbGlbCmd,
|
||||
&exportPcbIpc2581Cmd,
|
||||
&exportPcbOdbCmd,
|
||||
&exportPcbPdfCmd,
|
||||
&exportPcbPosCmd,
|
||||
&exportPcbStepCmd,
|
||||
|
@ -20,25 +20,38 @@
|
||||
#include <dialogs/dialog_export_odbpp.h>
|
||||
|
||||
#include <board.h>
|
||||
#include <confirm.h>
|
||||
#include <footprint.h>
|
||||
#include <kidialog.h>
|
||||
#include <kiway_holder.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <pcbnew_settings.h>
|
||||
#include <pgm_base.h>
|
||||
#include <progress_reporter.h>
|
||||
#include <project.h>
|
||||
#include <project/board_project_settings.h>
|
||||
#include <project/project_file.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <widgets/std_bitmap_button.h>
|
||||
#include <jobs/job_export_pcb_odb.h>
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <core/thread_pool.h>
|
||||
#include <io/io_mgr.h>
|
||||
#include <jobs/job_export_pcb_odb.h>
|
||||
#include <pcb_io/pcb_io_mgr.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/dirdlg.h>
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/zipstrm.h>
|
||||
|
||||
static wxString s_oemColumn = wxEmptyString;
|
||||
|
||||
DIALOG_EXPORT_ODBPP::DIALOG_EXPORT_ODBPP( PCB_EDIT_FRAME* aParent ) :
|
||||
DIALOG_EXPORT_ODBPP_BASE( aParent ), m_parent( aParent )
|
||||
DIALOG_EXPORT_ODBPP_BASE( aParent ),
|
||||
m_parent( aParent ),
|
||||
m_job( nullptr )
|
||||
{
|
||||
m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
|
||||
|
||||
@ -63,6 +76,27 @@ DIALOG_EXPORT_ODBPP::DIALOG_EXPORT_ODBPP( PCB_EDIT_FRAME* aParent ) :
|
||||
}
|
||||
|
||||
|
||||
DIALOG_EXPORT_ODBPP::DIALOG_EXPORT_ODBPP( JOB_EXPORT_PCB_ODB* aJob, PCB_EDIT_FRAME* aEditFrame,
|
||||
wxWindow* aParent ) :
|
||||
DIALOG_EXPORT_ODBPP_BASE( aParent ),
|
||||
m_parent( aEditFrame ),
|
||||
m_job( aJob )
|
||||
{
|
||||
m_browseButton->Hide();
|
||||
|
||||
SetupStandardButtons( { { wxID_OK, _( "Save" ) }, { wxID_CANCEL, _( "Close" ) } } );
|
||||
|
||||
m_outputFileName->SetValue( m_job->GetOutputPath() );
|
||||
|
||||
// Fill wxChoice (and others) items with data before calling finishDialogSettings()
|
||||
// to calculate suitable widgets sizes
|
||||
Init();
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
finishDialogSettings();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_EXPORT_ODBPP::onBrowseClicked( wxCommandEvent& event )
|
||||
{
|
||||
// Build the absolute path of current output directory to preselect it in the file browser.
|
||||
@ -80,7 +114,8 @@ void DIALOG_EXPORT_ODBPP::onBrowseClicked( wxCommandEvent& event )
|
||||
|
||||
void DIALOG_EXPORT_ODBPP::onOKClick( wxCommandEvent& event )
|
||||
{
|
||||
m_parent->SetLastPath( LAST_PATH_ODBPP, m_outputFileName->GetValue() );
|
||||
if( !m_job )
|
||||
m_parent->SetLastPath( LAST_PATH_ODBPP, m_outputFileName->GetValue() );
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
@ -90,9 +125,18 @@ bool DIALOG_EXPORT_ODBPP::Init()
|
||||
{
|
||||
PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
||||
|
||||
m_choiceUnits->SetSelection( cfg->m_ExportODBPP.units );
|
||||
m_precision->SetValue( cfg->m_ExportODBPP.precision );
|
||||
m_cbCompress->SetValue( cfg->m_ExportODBPP.compress );
|
||||
if( !m_job )
|
||||
{
|
||||
m_choiceUnits->SetSelection( cfg->m_ExportODBPP.units );
|
||||
m_precision->SetValue( cfg->m_ExportODBPP.precision );
|
||||
m_cbCompress->SetValue( cfg->m_ExportODBPP.compress );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_choiceUnits->SetSelection( static_cast<int>( m_job->m_units ) );
|
||||
m_precision->SetValue( m_job->m_precision );
|
||||
m_cbCompress->SetValue( m_job->m_compressionMode == JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::ZIP );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -100,11 +144,295 @@ bool DIALOG_EXPORT_ODBPP::Init()
|
||||
|
||||
bool DIALOG_EXPORT_ODBPP::TransferDataFromWindow()
|
||||
{
|
||||
PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
||||
if( !m_job )
|
||||
{
|
||||
PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
||||
|
||||
cfg->m_ExportODBPP.units = m_choiceUnits->GetSelection();
|
||||
cfg->m_ExportODBPP.precision = m_precision->GetValue();
|
||||
cfg->m_ExportODBPP.compress = m_cbCompress->GetValue();
|
||||
cfg->m_ExportODBPP.units = m_choiceUnits->GetSelection();
|
||||
cfg->m_ExportODBPP.precision = m_precision->GetValue();
|
||||
cfg->m_ExportODBPP.compress = m_cbCompress->GetValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_job->SetOutputPath( m_outputFileName->GetValue() );
|
||||
|
||||
m_job->m_precision = m_precision->GetValue();
|
||||
m_job->m_units = static_cast<JOB_EXPORT_PCB_ODB::ODB_UNITS>( m_choiceUnits->GetSelection() );
|
||||
m_job->m_compressionMode = m_cbCompress->GetValue()
|
||||
? JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::ZIP
|
||||
: JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( const JOB_EXPORT_PCB_ODB& aJob, BOARD* aBoard,
|
||||
PCB_EDIT_FRAME* aParentFrame,
|
||||
PROGRESS_REPORTER* aProgressReporter,
|
||||
REPORTER* aReporter )
|
||||
{
|
||||
wxCHECK( aBoard, /* void */ );
|
||||
wxString outputPath = aJob.GetOutputPath();
|
||||
|
||||
if( outputPath.IsEmpty() )
|
||||
outputPath = wxFileName( aJob.m_filename ).GetPath();
|
||||
|
||||
wxFileName pcbFileName( outputPath );
|
||||
|
||||
// Write through symlinks, don't replace them
|
||||
WX_FILENAME::ResolvePossibleSymlinks( pcbFileName );
|
||||
|
||||
if( pcbFileName.GetPath().IsEmpty() && pcbFileName.HasName() )
|
||||
pcbFileName.MakeAbsolute();
|
||||
|
||||
wxString msg;
|
||||
|
||||
if( pcbFileName.IsDir() && !pcbFileName.IsDirWritable() )
|
||||
{
|
||||
msg.Printf( _( "Insufficient permissions to folder '%s'." ), pcbFileName.GetPath() );
|
||||
}
|
||||
else if( !pcbFileName.FileExists() && !pcbFileName.IsDirWritable() )
|
||||
{
|
||||
msg.Printf( _( "Insufficient permissions to save file '%s'." ), pcbFileName.GetFullPath() );
|
||||
}
|
||||
else if( pcbFileName.FileExists() && !pcbFileName.IsFileWritable() )
|
||||
{
|
||||
msg.Printf( _( "Insufficient permissions to save file '%s'." ), pcbFileName.GetFullPath() );
|
||||
}
|
||||
|
||||
if( !msg.IsEmpty() )
|
||||
{
|
||||
if( aReporter )
|
||||
aReporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( !wxFileName::DirExists( pcbFileName.GetFullPath() ) )
|
||||
{
|
||||
// Make every directory provided when the provided path doesn't exist
|
||||
if( !wxFileName::Mkdir( pcbFileName.GetFullPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
|
||||
{
|
||||
msg.Printf( _( "Cannot create output directory '%s'." ), pcbFileName.GetFullPath() );
|
||||
|
||||
if( aReporter )
|
||||
aReporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wxFileName zipFileName( pcbFileName.GetFullPath(),
|
||||
wxString::Format( wxS( "%s-odb.zip" ),
|
||||
aBoard->GetProject()->GetProjectName() ) );
|
||||
|
||||
wxFileName tempFile( pcbFileName.GetFullPath(), "" );
|
||||
|
||||
if( aJob.m_compressionMode != JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE )
|
||||
{
|
||||
if( zipFileName.Exists() )
|
||||
{
|
||||
if( aParentFrame )
|
||||
{
|
||||
msg = wxString::Format( _( "Output files '%s' already exists. "
|
||||
"Do you want to overwrite it?" ),
|
||||
zipFileName.GetFullPath() );
|
||||
|
||||
KIDIALOG errorDlg( aParentFrame, msg, _( "Confirmation" ),
|
||||
wxOK | wxCANCEL | wxICON_WARNING );
|
||||
errorDlg.SetOKLabel( _( "Overwrite" ) );
|
||||
|
||||
if( errorDlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
if( !wxRemoveFile( zipFileName.GetFullPath() ) )
|
||||
{
|
||||
msg.Printf( _( "Cannot remove existing output file '%s'." ),
|
||||
zipFileName.GetFullPath() );
|
||||
DisplayErrorMessage( aParentFrame, msg );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = wxString::Format( _( "Output file '%s' already exists." ),
|
||||
zipFileName.GetFullPath() );
|
||||
|
||||
if( aReporter )
|
||||
aReporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tempFile.AssignDir( wxFileName::GetTempDir() );
|
||||
tempFile.AppendDir( "kicad" );
|
||||
tempFile.AppendDir( "odb" );
|
||||
|
||||
if( !wxFileName::Mkdir( tempFile.GetFullPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
|
||||
{
|
||||
msg.Printf( _( "Cannot create temporary output directory." ) );
|
||||
|
||||
if( aReporter )
|
||||
aReporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Plugin will create the 'odb' subdirectory for us, so test for it here
|
||||
wxFileName odbDir( tempFile );
|
||||
odbDir.AppendDir( "odb" );
|
||||
wxDir testDir( odbDir.GetFullPath() );
|
||||
|
||||
if( testDir.IsOpened() && ( testDir.HasFiles() || testDir.HasSubDirs() ) )
|
||||
{
|
||||
if( aParentFrame )
|
||||
{
|
||||
msg = wxString::Format( _( "Output directory '%s' already exists and is not empty. "
|
||||
"Do you want to overwrite it?" ),
|
||||
odbDir.GetFullPath() );
|
||||
|
||||
KIDIALOG errorDlg( aParentFrame, msg, _( "Confirmation" ),
|
||||
wxOK | wxCANCEL | wxICON_WARNING );
|
||||
errorDlg.SetOKLabel( _( "Overwrite" ) );
|
||||
|
||||
if( errorDlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
if( !odbDir.Rmdir( wxPATH_RMDIR_RECURSIVE ) )
|
||||
{
|
||||
msg.Printf( _( "Cannot remove existing output directory '%s'." ),
|
||||
odbDir.GetFullPath() );
|
||||
DisplayErrorMessage( aParentFrame, msg );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = wxString::Format( _( "Output directory '%s' already exists." ),
|
||||
odbDir.GetFullPath() );
|
||||
|
||||
if( aReporter )
|
||||
aReporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxString upperTxt;
|
||||
wxString lowerTxt;
|
||||
std::map<std::string, UTF8> props;
|
||||
|
||||
props["units"] = aJob.m_units == JOB_EXPORT_PCB_ODB::ODB_UNITS::MILLIMETERS ? "mm" : "inch";
|
||||
props["sigfig"] = wxString::Format( "%d", aJob.m_precision );
|
||||
|
||||
auto saveFile =
|
||||
[&]() -> bool
|
||||
{
|
||||
try
|
||||
{
|
||||
IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( PCB_IO_MGR::ODBPP ) );
|
||||
pi->SetReporter( aReporter );
|
||||
pi->SetProgressReporter( aProgressReporter );
|
||||
pi->SaveBoard( tempFile.GetFullPath(), aBoard, &props );
|
||||
return true;
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
if( aReporter )
|
||||
{
|
||||
msg = wxString::Format( _( "Error generating ODBPP files '%s'.\n%s" ),
|
||||
tempFile.GetFullPath(), ioe.What() );
|
||||
aReporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||
}
|
||||
|
||||
// In case we started a file but didn't fully write it, clean up
|
||||
wxFileName::Rmdir( tempFile.GetFullPath() );
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
thread_pool& tp = GetKiCadThreadPool();
|
||||
auto ret = tp.submit( saveFile );
|
||||
|
||||
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
|
||||
|
||||
while( status != std::future_status::ready )
|
||||
{
|
||||
if( aProgressReporter)
|
||||
aProgressReporter->KeepRefreshing();
|
||||
|
||||
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if( !ret.get() )
|
||||
return;
|
||||
}
|
||||
catch( const std::exception& e )
|
||||
{
|
||||
if( aReporter )
|
||||
{
|
||||
aReporter->Report( wxString::Format( "Exception in ODB++ generation: %s", e.what() ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( aJob.m_compressionMode != JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE )
|
||||
{
|
||||
if( aProgressReporter )
|
||||
aProgressReporter->AdvancePhase( _( "Compressing output" ) );
|
||||
|
||||
wxFFileOutputStream fnout( zipFileName.GetFullPath() );
|
||||
wxZipOutputStream zipStream( fnout );
|
||||
|
||||
std::function<void( const wxString&, const wxString& )> addDirToZip =
|
||||
[&]( const wxString& dirPath, const wxString& parentPath )
|
||||
{
|
||||
wxDir dir( dirPath );
|
||||
wxString fileName;
|
||||
|
||||
bool cont = dir.GetFirst( &fileName, wxEmptyString, wxDIR_DEFAULT );
|
||||
|
||||
while( cont )
|
||||
{
|
||||
wxFileName fileInZip( dirPath, fileName );
|
||||
wxString relativePath =
|
||||
parentPath.IsEmpty()
|
||||
? fileName
|
||||
: parentPath + wxString( wxFileName::GetPathSeparator() )
|
||||
+ fileName;
|
||||
|
||||
if( wxFileName::DirExists( fileInZip.GetFullPath() ) )
|
||||
{
|
||||
zipStream.PutNextDirEntry( relativePath );
|
||||
addDirToZip( fileInZip.GetFullPath(), relativePath );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFFileInputStream fileStream( fileInZip.GetFullPath() );
|
||||
zipStream.PutNextEntry( relativePath );
|
||||
fileStream.Read( zipStream );
|
||||
}
|
||||
cont = dir.GetNext( &fileName );
|
||||
}
|
||||
};
|
||||
|
||||
addDirToZip( tempFile.GetFullPath(), wxEmptyString );
|
||||
|
||||
zipStream.Close();
|
||||
fnout.Close();
|
||||
|
||||
tempFile.Rmdir( wxPATH_RMDIR_RECURSIVE );
|
||||
}
|
||||
|
||||
if( aProgressReporter )
|
||||
aProgressReporter->SetCurrentProgress( 1 );
|
||||
}
|
||||
|
@ -22,11 +22,16 @@
|
||||
#include "dialog_export_odbpp_base.h"
|
||||
|
||||
class PCB_EDIT_FRAME;
|
||||
class JOB_EXPORT_PCB_ODB;
|
||||
class REPORTER;
|
||||
class PROGRESS_REPORTER;
|
||||
class BOARD;
|
||||
|
||||
class DIALOG_EXPORT_ODBPP : public DIALOG_EXPORT_ODBPP_BASE
|
||||
{
|
||||
public:
|
||||
DIALOG_EXPORT_ODBPP( PCB_EDIT_FRAME* aParent );
|
||||
DIALOG_EXPORT_ODBPP( JOB_EXPORT_PCB_ODB* aJob, PCB_EDIT_FRAME* aEditFrame, wxWindow* aParent );
|
||||
|
||||
wxString GetOutputPath() const { return m_outputFileName->GetValue(); }
|
||||
|
||||
@ -38,11 +43,17 @@ public:
|
||||
return wxT( "inch" );
|
||||
}
|
||||
|
||||
wxString GetPrecision() const { return wxString::Format( "%d", m_precision->GetValue() ); }
|
||||
int GetPrecision() const { return m_precision->GetValue(); }
|
||||
|
||||
|
||||
bool GetCompress() const { return m_cbCompress->GetValue(); }
|
||||
|
||||
// Runs the actual generation process; shared between GUI and CLI system
|
||||
static void GenerateODBPPFiles( const JOB_EXPORT_PCB_ODB& aJob, BOARD* aBoard,
|
||||
PCB_EDIT_FRAME* aParentFrame = nullptr,
|
||||
PROGRESS_REPORTER* aProgressReporter = nullptr,
|
||||
REPORTER* aErrorReporter = nullptr );
|
||||
|
||||
private:
|
||||
void onBrowseClicked( wxCommandEvent& event ) override;
|
||||
void onOKClick( wxCommandEvent& event ) override;
|
||||
@ -51,6 +62,7 @@ private:
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
PCB_EDIT_FRAME* m_parent;
|
||||
JOB_EXPORT_PCB_ODB* m_job;
|
||||
};
|
||||
|
||||
#endif // ODBPP_EXPORT_DIALOG_H
|
||||
#endif // ODBPP_EXPORT_DIALOG_H
|
||||
|
204
pcbnew/files.cpp
204
pcbnew/files.cpp
@ -64,6 +64,7 @@
|
||||
#include <dialogs/dialog_export_2581.h>
|
||||
#include <dialogs/dialog_map_layers.h>
|
||||
#include <dialogs/dialog_export_odbpp.h>
|
||||
#include <jobs/job_export_pcb_odb.h>
|
||||
#include <dialogs/dialog_import_choose_project.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
#include "footprint_info_impl.h"
|
||||
@ -1415,198 +1416,21 @@ void PCB_EDIT_FRAME::GenODBPPFiles( wxCommandEvent& event )
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
wxFileName pcbFileName = dlg.GetOutputPath();
|
||||
JOB_EXPORT_PCB_ODB job;
|
||||
|
||||
// Write through symlinks, don't replace them
|
||||
WX_FILENAME::ResolvePossibleSymlinks( pcbFileName );
|
||||
job.SetOutputPath( dlg.GetOutputPath() );
|
||||
job.m_filename = GetBoard()->GetFileName();
|
||||
job.m_compressionMode = dlg.GetCompress() ? JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::ZIP
|
||||
: JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE;
|
||||
job.m_precision = dlg.GetPrecision();
|
||||
job.m_units = dlg.GetUnitsString() == "mm" ? JOB_EXPORT_PCB_ODB::ODB_UNITS::MILLIMETERS
|
||||
: JOB_EXPORT_PCB_ODB::ODB_UNITS::INCHES;
|
||||
|
||||
if( !IsWritable( pcbFileName ) )
|
||||
{
|
||||
wxString msg = wxString::Format( _( "Insufficient permissions to write file '%s'." ),
|
||||
pcbFileName.GetFullPath() );
|
||||
WX_PROGRESS_REPORTER progressReporter( this, _( "Generating ODB++ output files" ), 3, false );
|
||||
WX_STRING_REPORTER reporter;
|
||||
|
||||
DisplayErrorMessage( this, msg );
|
||||
return;
|
||||
}
|
||||
DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( job, GetBoard(), this, &progressReporter, &reporter );
|
||||
|
||||
if( !wxFileName::DirExists( pcbFileName.GetFullPath() ) )
|
||||
{
|
||||
// Make every directory provided when the provided path doesn't exist
|
||||
if( !wxFileName::Mkdir( pcbFileName.GetFullPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( _( "Cannot create output directory '%s'." ), pcbFileName.GetFullPath() );
|
||||
|
||||
DisplayErrorMessage( this, msg );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wxFileName zipFileName( pcbFileName.GetFullPath(),
|
||||
wxString::Format( wxS( "%s-odb.zip" ), Prj().GetProjectName() ) );
|
||||
|
||||
wxFileName tempFile( pcbFileName.GetFullPath(), "" );
|
||||
tempFile.AppendDir( "odb" );
|
||||
|
||||
if( dlg.GetCompress() )
|
||||
{
|
||||
if( zipFileName.Exists() )
|
||||
{
|
||||
wxString msg = wxString::Format( _( "Output files '%s' already exists. "
|
||||
"Do you want to overwrite it?" ),
|
||||
zipFileName.GetFullPath() );
|
||||
|
||||
KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
|
||||
errorDlg.SetOKLabel( _( "Overwrite" ) );
|
||||
|
||||
if( errorDlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
if( !wxRemoveFile( zipFileName.GetFullPath() ) )
|
||||
{
|
||||
msg.Printf( _( "Cannot remove existing output file '%s'." ),
|
||||
zipFileName.GetFullPath() );
|
||||
DisplayErrorMessage( this, msg );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tempFile.AssignDir( wxFileName::GetTempDir() );
|
||||
tempFile.AppendDir( "kicad" );
|
||||
tempFile.AppendDir( "odb" );
|
||||
|
||||
if( !wxFileName::Mkdir( tempFile.GetFullPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Cannot create temporary output directory." ) );
|
||||
DisplayErrorMessage( this, msg );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wxDir testDir( tempFile.GetFullPath() );
|
||||
|
||||
if( testDir.IsOpened() && ( testDir.HasFiles() || testDir.HasSubDirs() ) )
|
||||
{
|
||||
wxString msg = wxString::Format( _( "Output directory '%s' already exists and is not empty. "
|
||||
"Do you want to overwrite it?" ),
|
||||
tempFile.GetFullPath() );
|
||||
|
||||
KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
|
||||
errorDlg.SetOKLabel( _( "Overwrite" ) );
|
||||
|
||||
if( errorDlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
if( !tempFile.Rmdir( wxPATH_RMDIR_RECURSIVE ) )
|
||||
{
|
||||
msg.Printf( _( "Cannot remove existing output directory '%s'." ),
|
||||
pcbFileName.GetFullPath() );
|
||||
DisplayErrorMessage( this, msg );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxString upperTxt;
|
||||
wxString lowerTxt;
|
||||
std::map<std::string, UTF8> props;
|
||||
|
||||
props["units"] = dlg.GetUnitsString();
|
||||
props["sigfig"] = dlg.GetPrecision();
|
||||
WX_PROGRESS_REPORTER reporter( this, _( "Generating ODB++ output files" ), 5 );
|
||||
|
||||
auto saveFile = [&]() -> bool
|
||||
{
|
||||
try
|
||||
{
|
||||
IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( PCB_IO_MGR::ODBPP ) );
|
||||
pi->SetProgressReporter( &reporter );
|
||||
pi->SaveBoard( tempFile.GetFullPath(), GetBoard(), &props );
|
||||
return true;
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DisplayError( this, wxString::Format( _( "Error generating ODBPP files '%s'.\n%s" ),
|
||||
tempFile.GetFullPath(), ioe.What() ) );
|
||||
|
||||
lowerTxt.Printf( _( "Failed to create directory '%s'." ), tempFile.GetFullPath() );
|
||||
|
||||
SetMsgPanel( upperTxt, lowerTxt );
|
||||
|
||||
// In case we started a file but didn't fully write it, clean up
|
||||
wxFileName::Rmdir( tempFile.GetFullPath() );
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
thread_pool& tp = GetKiCadThreadPool();
|
||||
auto ret = tp.submit( saveFile );
|
||||
|
||||
std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
|
||||
|
||||
while( status != std::future_status::ready )
|
||||
{
|
||||
reporter.KeepRefreshing();
|
||||
status = ret.wait_for( std::chrono::milliseconds( 250 ) );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if( !ret.get() )
|
||||
return;
|
||||
}
|
||||
catch( const std::exception& e )
|
||||
{
|
||||
wxLogError( "Exception in ODB++ generation: %s", e.what() );
|
||||
return;
|
||||
}
|
||||
|
||||
if( dlg.GetCompress() )
|
||||
{
|
||||
reporter.AdvancePhase( _( "Compressing output" ) );
|
||||
wxFFileOutputStream fnout( zipFileName.GetFullPath() );
|
||||
wxZipOutputStream zipStream( fnout );
|
||||
|
||||
std::function<void( const wxString&, const wxString& )> addDirToZip =
|
||||
[&]( const wxString& dirPath, const wxString& parentPath )
|
||||
{
|
||||
wxDir dir( dirPath );
|
||||
wxString fileName;
|
||||
|
||||
bool cont = dir.GetFirst( &fileName, wxEmptyString, wxDIR_DEFAULT );
|
||||
|
||||
while( cont )
|
||||
{
|
||||
wxFileName fileInZip( dirPath, fileName );
|
||||
wxString relativePath =
|
||||
parentPath.IsEmpty()
|
||||
? fileName
|
||||
: parentPath + wxString( wxFileName::GetPathSeparator() )
|
||||
+ fileName;
|
||||
|
||||
if( wxFileName::DirExists( fileInZip.GetFullPath() ) )
|
||||
{
|
||||
zipStream.PutNextDirEntry( relativePath );
|
||||
addDirToZip( fileInZip.GetFullPath(), relativePath );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFFileInputStream fileStream( fileInZip.GetFullPath() );
|
||||
zipStream.PutNextEntry( relativePath );
|
||||
fileStream.Read( zipStream );
|
||||
}
|
||||
cont = dir.GetNext( &fileName );
|
||||
}
|
||||
};
|
||||
|
||||
addDirToZip( tempFile.GetFullPath(), wxEmptyString );
|
||||
|
||||
zipStream.Close();
|
||||
fnout.Close();
|
||||
|
||||
tempFile.Rmdir( wxPATH_RMDIR_RECURSIVE );
|
||||
}
|
||||
if( reporter.HasMessage() )
|
||||
DisplayError( this, reporter.GetMessages() );
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <jobs/job_fp_export_svg.h>
|
||||
#include <jobs/job_fp_upgrade.h>
|
||||
#include <jobs/job_export_pcb_ipc2581.h>
|
||||
#include <jobs/job_export_pcb_odb.h>
|
||||
#include <jobs/job_export_pcb_gerber.h>
|
||||
#include <jobs/job_export_pcb_gerbers.h>
|
||||
#include <jobs/job_export_pcb_drill.h>
|
||||
@ -81,6 +82,7 @@
|
||||
#include <dialogs/dialog_gendrill.h>
|
||||
#include <dialogs/dialog_gen_footprint_position.h>
|
||||
#include <dialogs/dialog_export_2581.h>
|
||||
#include <dialogs/dialog_export_odbpp.h>
|
||||
#include <dialogs/dialog_export_step.h>
|
||||
#include <dialogs/dialog_plot.h>
|
||||
|
||||
@ -237,6 +239,19 @@ PCBNEW_JOBS_HANDLER::PCBNEW_JOBS_HANDLER( KIWAY* aKiway ) :
|
||||
DIALOG_EXPORT_2581 dlg( ipcJob, editFrame, aParent );
|
||||
dlg.ShowModal();
|
||||
|
||||
return dlg.GetReturnCode() == wxID_OK;
|
||||
} );
|
||||
Register( "odb",
|
||||
std::bind( &PCBNEW_JOBS_HANDLER::JobExportOdb, this, std::placeholders::_1 ),
|
||||
[aKiway]( JOB* job, wxWindow* aParent ) -> bool
|
||||
{
|
||||
JOB_EXPORT_PCB_ODB* odbJob = dynamic_cast<JOB_EXPORT_PCB_ODB*>( job );
|
||||
|
||||
PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( aKiway->Player( FRAME_PCB_EDITOR, false ) );
|
||||
|
||||
DIALOG_EXPORT_ODBPP dlg( odbJob, editFrame, aParent );
|
||||
dlg.ShowModal();
|
||||
|
||||
return dlg.GetReturnCode() == wxID_OK;
|
||||
} );
|
||||
}
|
||||
@ -1764,6 +1779,33 @@ int PCBNEW_JOBS_HANDLER::JobExportIpc2581( JOB* aJob )
|
||||
}
|
||||
|
||||
|
||||
int PCBNEW_JOBS_HANDLER::JobExportOdb( JOB* aJob )
|
||||
{
|
||||
JOB_EXPORT_PCB_ODB* job = dynamic_cast<JOB_EXPORT_PCB_ODB*>( aJob );
|
||||
|
||||
if( job == nullptr )
|
||||
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
|
||||
BOARD* brd = getBoard( job->m_filename );
|
||||
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
if( job->OutputPathFullSpecified() )
|
||||
{
|
||||
wxFileName fn = brd->GetFileName();
|
||||
fn.SetName( fn.GetName() );
|
||||
fn.SetExt( "zip" );
|
||||
|
||||
job->SetOutputPath( fn.GetName() );
|
||||
}
|
||||
|
||||
DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( *job, brd, nullptr, m_progressReporter, m_reporter );
|
||||
|
||||
return CLI::EXIT_CODES::SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DS_PROXY_VIEW_ITEM* PCBNEW_JOBS_HANDLER::getDrawingSheetProxyView( BOARD* aBrd )
|
||||
{
|
||||
DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( pcbIUScale,
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
int JobExportFpSvg( JOB* aJob );
|
||||
int JobExportDrc( JOB* aJob );
|
||||
int JobExportIpc2581( JOB* aJob );
|
||||
int JobExportOdb( JOB* aJob );
|
||||
|
||||
private:
|
||||
BOARD* getBoard( const wxString& aPath = wxEmptyString );
|
||||
@ -62,4 +63,4 @@ private:
|
||||
BOARD* m_cliBoard;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user