7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-03-30 04:56:54 +00:00

Initial jobset creation and running within the CLI and GUI.

Incomplete, just pushing this before feature freeze, much fixing left
This commit is contained in:
Marek Roszko 2024-07-15 18:20:13 -04:00
parent 6255586d5b
commit d74caace0a
150 changed files with 9950 additions and 3247 deletions
common
eeschema
include
kicad
pcbnew
qa/tests
resources/schemas

View File

@ -61,12 +61,16 @@ set( KICOMMON_SRCS
gal/color4d.cpp
# Jobs
jobs/job.cpp
jobs/job_registry.cpp
jobs/jobs_output_archive.cpp
jobs/jobs_output_folder.cpp
jobs/job_export_pcb_drill.cpp
jobs/job_export_pcb_dxf.cpp
jobs/job_export_pcb_gerber.cpp
jobs/job_export_pcb_gerbers.cpp
jobs/job_export_pcb_ipc2581.cpp
jobs/job_export_pcb_pdf.cpp
jobs/job_export_pcb_plot.cpp
jobs/job_export_pcb_pos.cpp
jobs/job_export_pcb_svg.cpp
jobs/job_export_pcb_gencad.cpp
@ -75,6 +79,7 @@ set( KICOMMON_SRCS
jobs/job_export_sch_netlist.cpp
jobs/job_export_sch_plot.cpp
jobs/job_export_sch_pythonbom.cpp
jobs/jobset.cpp
jobs/job_fp_export_svg.cpp
jobs/job_fp_upgrade.cpp
jobs/job_pcb_render.cpp

View File

@ -120,6 +120,7 @@ static const wxChar ResolveTextRecursionDepth[] = wxT( "ResolveTextRecursionDept
static const wxChar EnableExtensionSnaps[] = wxT( "EnableExtensionSnaps" );
static const wxChar EnableSnapAnchorsDebug[] = wxT( "EnableSnapAnchorsDebug" );
static const wxChar EnableODB[] = wxT( "EnableODB" );
static const wxChar EnableJobset[] = wxT( "EnableJobset" );
} // namespace KEYS
@ -248,6 +249,7 @@ ADVANCED_CFG::ADVANCED_CFG()
m_EnableDesignBlocks = false;
m_EnableGenerators = false;
m_EnableGit = false;
m_EnableJobset = false;
m_EnableLibWithText = false;
m_EnableLibDir = false;
@ -479,6 +481,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableGit,
&m_EnableGit, m_EnableGit ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableJobset,
&m_EnableJobset, m_EnableJobset ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableLibWithText,
&m_EnableLibWithText, m_EnableLibWithText ) );
@ -528,7 +533,7 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::ResolveTextRecursionDepth,
&m_ResolveTextRecursionDepth,
m_ResolveTextRecursionDepth, 0, 10 ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableODB,
&m_EnableODB, m_EnableODB ) );

View File

@ -274,7 +274,7 @@ EDA_BASE_FRAME::~EDA_BASE_FRAME()
Disconnect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
delete m_autoSaveTimer;
delete m_fileHistory;

View File

@ -39,6 +39,10 @@
#include <launch_ext.h>
#include "wx/tokenzr.h"
#include <wx/wfstream.h>
#include <wx/fs_zip.h>
#include <wx/zipstrm.h>
#include <filesystem>
void QuoteString( wxString& string )
@ -369,3 +373,99 @@ bool RmDirRecursive( const wxString& aFileName, wxString* aErrors )
return true;
}
bool CopyDirectory( const wxString& aSourceDir, const wxString& aDestDir, wxString& aErrors )
{
wxDir dir( aSourceDir );
if( !dir.IsOpened() )
{
aErrors += wxString::Format( _( "Could not open source directory: %s" ), aSourceDir );
aErrors += wxT( "\n" );
return false;
}
if( !wxFileName::Mkdir( aDestDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
{
aErrors += wxString::Format( _( "Could not create destination directory: %s" ), aDestDir );
aErrors += wxT( "\n" );
return false;
}
wxString filename;
bool cont = dir.GetFirst( &filename );
while( cont )
{
wxString sourcePath = aSourceDir + wxFileName::GetPathSeparator() + filename;
wxString destPath = aDestDir + wxFileName::GetPathSeparator() + filename;
if( wxFileName::DirExists( sourcePath ) )
{
// Recursively copy subdirectories
if( !CopyDirectory( sourcePath, destPath, aErrors ) )
{
return false;
}
}
else
{
// Copy files
if( !wxCopyFile( sourcePath, destPath ) )
{
aErrors += wxString::Format( _( "Could not copy file: %s to %s" ), sourcePath, destPath );
return false;
}
}
cont = dir.GetNext( &filename );
}
return true;
}
bool AddDirectoryToZip( wxZipOutputStream& aZip, const wxString& aSourceDir, wxString& aErrors,
const wxString& aParentDir )
{
wxDir dir( aSourceDir );
if( !dir.IsOpened() )
{
aErrors += wxString::Format( _( "Could not open source directory: %s" ), aSourceDir );
aErrors += "\n";
return false;
}
wxString filename;
bool cont = dir.GetFirst( &filename );
while( cont )
{
wxString sourcePath = aSourceDir + wxFileName::GetPathSeparator() + filename;
wxString zipPath = aParentDir + filename;
if( wxFileName::DirExists( sourcePath ) )
{
// Add directory entry to the ZIP file
aZip.PutNextDirEntry( zipPath + "/" );
// Recursively add subdirectories
if( !AddDirectoryToZip( aZip, sourcePath, aErrors, zipPath + "/" ) )
{
return false;
}
}
else
{
// Add file entry to the ZIP file
aZip.PutNextEntry( zipPath );
wxFFileInputStream fileStream( sourcePath );
if( !fileStream.IsOk() )
{
aErrors += wxString::Format( _( "Could not read file: %s" ), sourcePath );
return false;
}
aZip.Write( fileStream );
}
cont = dir.GetNext( &filename );
}
return true;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2023 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
* 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
@ -19,10 +19,152 @@
*/
#include <jobs/job.h>
#include <wx/filename.h>
JOB::JOB( const std::string& aType, bool aIsCli ) :
JOB::JOB( const std::string& aType, bool aOutputIsDirectory, bool aIsCli ) :
m_type( aType ),
m_isCli( aIsCli ),
m_varOverrides()
m_varOverrides(),
m_tempOutputDirectory(),
m_outputPath(),
m_outputPathIsDirectory( aOutputIsDirectory )
{
if( m_outputPathIsDirectory )
{
m_params.emplace_back(
new JOB_PARAM<wxString>( "output_dir", &m_outputPath, m_outputPath ) );
}
else
{
m_params.emplace_back(
new JOB_PARAM<wxString>( "output_filename", &m_outputPath, m_outputPath ) );
}
}
JOB::~JOB()
{
for( JOB_PARAM_BASE* param : m_params )
delete param;
m_params.clear();
}
void JOB::FromJson( const nlohmann::json& j )
{
for( JOB_PARAM_BASE* param : m_params )
param->FromJson( j );
}
void JOB::ToJson( nlohmann::json& j ) const
{
for( JOB_PARAM_BASE* param : m_params )
param->ToJson( j );
}
wxString JOB::GetDescription()
{
return wxEmptyString;
}
void JOB::SetTempOutputDirectory( const wxString& aBase )
{
m_tempOutputDirectory = aBase;
}
void PrependDirectoryToPath( wxFileName& aFileName, const wxString aDirPath )
{
wxFileName fn( aDirPath + wxFileName::GetPathSeparator() + aFileName.GetFullPath() );
aFileName = fn;
}
wxString JOB::GetFullOutputPath() const
{
if( !m_tempOutputDirectory.IsEmpty() )
{
if( m_outputPathIsDirectory )
{
wxFileName fn( m_outputPath );
if( fn.IsAbsolute() || m_outputPath.IsEmpty() )
{
fn.AssignDir( m_tempOutputDirectory );
}
else
{
PrependDirectoryToPath( fn, m_tempOutputDirectory );
}
return fn.GetFullPath();
}
else
{
wxFileName fn( m_outputPath );
if( fn.IsAbsolute() || m_outputPath.IsEmpty() )
{
// uhhh, do nothing
// either its a full path passed by cli, so we return as-is
// or it's a empty path from either...in which case things will fail but who cares
// the job handlers should have fixed empty paths
}
else
{
PrependDirectoryToPath( fn, m_tempOutputDirectory );
}
return fn.GetFullPath();
}
}
return m_outputPath;
}
void JOB::SetOutputPath( const wxString& aPath )
{
m_outputPath = aPath;
}
bool JOB::OutputPathFullSpecified() const
{
if( m_outputPath.IsEmpty() )
{
return false;
}
wxFileName fn( m_outputPath );
if( m_outputPathIsDirectory )
{
return fn.IsDir();
}
else
{
return !fn.IsDir();
}
}
KICOMMON_API void to_json( nlohmann::json& j, const JOB& f )
{
f.ToJson( j );
}
KICOMMON_API void from_json( const nlohmann::json& j, JOB& f )
{
f.FromJson( j );
}
JOB_PARAM_BASE::JOB_PARAM_BASE( const std::string& aJsonPath ) :
m_jsonPath( aJsonPath )
{
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* 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
@ -18,12 +18,55 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef JOB_H
#define JOB_H
#pragma once
#include <kicommon.h>
#include <map>
#include <wx/string.h>
#include <settings/json_settings.h>
class KICOMMON_API JOB_PARAM_BASE
{
public:
JOB_PARAM_BASE( const std::string& aJsonPath );
virtual ~JOB_PARAM_BASE() = default;
virtual void FromJson( const nlohmann::json& j ) const = 0;
virtual void ToJson( nlohmann::json& j ) = 0;
protected:
std::string m_jsonPath;
};
template <typename ValueType>
class JOB_PARAM : public JOB_PARAM_BASE
{
public:
JOB_PARAM( const std::string& aJsonPath, ValueType* aPtr,
ValueType aDefault ) :
JOB_PARAM_BASE( aJsonPath ), m_ptr( aPtr ), m_default( aDefault )
{
}
virtual void FromJson( const nlohmann::json& j ) const override
{
*m_ptr = j.value( m_jsonPath, m_default );
}
virtual void ToJson( nlohmann::json& j ) override { j[m_jsonPath] = *m_ptr; }
protected:
ValueType* m_ptr;
ValueType m_default;
};
struct KICOMMON_API JOB_OUTPUT
{
wxString m_outputPath;
};
/**
* An simple container class that lets us dispatch output jobs to kifaces
@ -31,9 +74,9 @@
class KICOMMON_API JOB
{
public:
JOB( const std::string& aType, bool aIsCli );
JOB( const std::string& aType, bool aOutputIsDirectory, bool aIsCli );
virtual ~JOB() {}
virtual ~JOB();
const std::string& GetType() const { return m_type; };
bool IsCli() const { return m_isCli; };
@ -45,10 +88,51 @@ public:
m_varOverrides = aVarOverrides;
}
virtual void FromJson( const nlohmann::json& j );
virtual void ToJson( nlohmann::json& j ) const;
virtual wxString GetDescription();
const std::vector<JOB_PARAM_BASE*>& GetParams() {
return m_params;
}
void ClearExistingOutputs() {
m_outputs.clear();
}
const std::vector<JOB_OUTPUT>& GetOutputs() {
return m_outputs;
}
void AddOutput( wxString aOutputPath ) {
m_outputs.emplace_back( aOutputPath );
}
void SetTempOutputDirectory( const wxString& aBase );
void SetOutputPath( const wxString& aPath );
wxString GetOutputPath() const { return m_outputPath; }
wxString GetFullOutputPath() const;
bool OutputPathFullSpecified() const;
protected:
std::string m_type;
bool m_isCli;
std::map<wxString, wxString> m_varOverrides;
wxString m_tempOutputDirectory;
wxString m_outputPath;
bool m_outputPathIsDirectory;
std::vector<JOB_PARAM_BASE*> m_params;
std::vector<JOB_OUTPUT> m_outputs;
};
#endif
KICOMMON_API void from_json( const nlohmann::json& j, JOB& f );
KICOMMON_API void to_json( nlohmann::json& j, const JOB& f );

View File

@ -23,6 +23,7 @@
#include <reporter.h>
#include <wx/debug.h>
class wxWindow;
JOB_DISPATCHER::JOB_DISPATCHER( KIWAY* aKiway ) :
m_kiway( aKiway )
@ -33,14 +34,18 @@ JOB_DISPATCHER::JOB_DISPATCHER( KIWAY* aKiway ) :
void JOB_DISPATCHER::Register( const std::string& aJobTypeName,
std::function<int( JOB* job )> aHandler )
std::function<int( JOB* job )> aHandler,
std::function<bool( JOB* aJob, wxWindow* aParent )> aConfigHandler )
{
m_jobHandlers.emplace( aJobTypeName, aHandler );
m_jobConfigHandlers.emplace( aJobTypeName, aConfigHandler );
}
int JOB_DISPATCHER::RunJob( JOB* job )
{
job->ClearExistingOutputs();
if( m_jobHandlers.count( job->GetType() ) )
{
return m_jobHandlers[job->GetType()]( job );
@ -50,6 +55,17 @@ int JOB_DISPATCHER::RunJob( JOB* job )
}
bool JOB_DISPATCHER::HandleJobConfig( JOB* job, wxWindow* aParent )
{
if( m_jobConfigHandlers.count( job->GetType() ) )
{
return m_jobConfigHandlers[job->GetType()]( job, aParent );
}
return false;
}
void JOB_DISPATCHER::SetReporter( REPORTER* aReporter )
{
wxCHECK( aReporter != nullptr, /*void*/ );

View File

@ -30,13 +30,16 @@
class KIWAY;
class REPORTER;
class PROGRESS_REPORTER;
class wxWindow;
class JOB_DISPATCHER
{
public:
JOB_DISPATCHER( KIWAY* aKiway );
void Register( const std::string& aJobTypeName, std::function<int( JOB* job )> aHandler );
int RunJob( JOB* job );
void Register( const std::string& aJobTypeName, std::function<int( JOB* job )> aHandler,
std::function<bool( JOB* job, wxWindow* aParent )> aConfigHandler );
int RunJob( JOB* aJob );
bool HandleJobConfig( JOB* aJob, wxWindow* aParent );
void SetReporter( REPORTER* aReporter );
void SetProgressReporter( PROGRESS_REPORTER* aReporter );
@ -47,6 +50,8 @@ protected:
private:
std::map<std::string, std::function<int( JOB* job )>> m_jobHandlers;
std::map<std::string, std::function<bool( JOB* job, wxWindow* aParent )>>
m_jobConfigHandlers;
};

View File

@ -19,7 +19,27 @@
*/
#include <jobs/job_export_pcb_3d.h>
#include <jobs/job_registry.h>
#include <i18n_utility.h>
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_3D::FORMAT,
{
{ JOB_EXPORT_PCB_3D::FORMAT::UNKNOWN, nullptr },
{ JOB_EXPORT_PCB_3D::FORMAT::STEP, "step" },
{ JOB_EXPORT_PCB_3D::FORMAT::BREP, "brep" },
{ JOB_EXPORT_PCB_3D::FORMAT::GLB, "step" },
{ JOB_EXPORT_PCB_3D::FORMAT::VRML, "vrml" },
{ JOB_EXPORT_PCB_3D::FORMAT::XAO, "xao" },
} )
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_3D::VRML_UNITS,
{
{ JOB_EXPORT_PCB_3D::VRML_UNITS::INCHES, "in" },
{ JOB_EXPORT_PCB_3D::VRML_UNITS::METERS, "m" },
{ JOB_EXPORT_PCB_3D::VRML_UNITS::MILLIMETERS, "mm" },
{ JOB_EXPORT_PCB_3D::VRML_UNITS::TENTHS, "tenths" },
} )
wxString EXPORTER_STEP_PARAMS::GetDefaultExportExtension() const
{
@ -49,7 +69,7 @@ wxString EXPORTER_STEP_PARAMS::GetFormatName() const
JOB_EXPORT_PCB_3D::JOB_EXPORT_PCB_3D( bool aIsCli ) :
JOB( "3d", aIsCli ),
JOB( "3d", false, aIsCli ),
m_hasUserOrigin( false ),
m_filename(),
m_format( JOB_EXPORT_PCB_3D::FORMAT::UNKNOWN ),
@ -57,4 +77,58 @@ JOB_EXPORT_PCB_3D::JOB_EXPORT_PCB_3D( bool aIsCli ) :
m_vrmlModelDir( wxEmptyString ),
m_vrmlRelativePaths( false )
{
m_params.emplace_back(
new JOB_PARAM<bool>( "overwrite", &m_3dparams.m_Overwrite, m_3dparams.m_Overwrite ) );
m_params.emplace_back( new JOB_PARAM<bool>( "use_grid_origin", &m_3dparams.m_UseGridOrigin,
m_3dparams.m_UseGridOrigin ) );
m_params.emplace_back( new JOB_PARAM<bool>( "use_drill_origin", &m_3dparams.m_UseDrillOrigin,
m_3dparams.m_UseDrillOrigin ) );
m_params.emplace_back(
new JOB_PARAM<bool>( "board_only", &m_3dparams.m_BoardOnly, m_3dparams.m_BoardOnly ) );
m_params.emplace_back( new JOB_PARAM<bool>( "include_unspecified",
&m_3dparams.m_IncludeUnspecified,
m_3dparams.m_IncludeUnspecified ) );
m_params.emplace_back( new JOB_PARAM<bool>( "include_dnp", &m_3dparams.m_IncludeDNP,
m_3dparams.m_IncludeDNP ) );
m_params.emplace_back( new JOB_PARAM<bool>( "subst_models", &m_3dparams.m_SubstModels,
m_3dparams.m_SubstModels ) );
m_params.emplace_back( new JOB_PARAM<bool>( "optimize_step", &m_3dparams.m_OptimizeStep,
m_3dparams.m_OptimizeStep ) );
m_params.emplace_back( new JOB_PARAM<double>( "user_origin.x", &m_3dparams.m_Origin.x,
m_3dparams.m_Origin.x ) );
m_params.emplace_back( new JOB_PARAM<double>( "user_origin.y", &m_3dparams.m_Origin.y,
m_3dparams.m_Origin.y ) );
m_params.emplace_back( new JOB_PARAM<double>( "board_outlines_chaining_epsilon",
&m_3dparams.m_BoardOutlinesChainingEpsilon,
m_3dparams.m_BoardOutlinesChainingEpsilon ) );
m_params.emplace_back( new JOB_PARAM<bool>( "export_board_body", &m_3dparams.m_ExportBoardBody,
m_3dparams.m_ExportBoardBody ) );
m_params.emplace_back( new JOB_PARAM<bool>( "export_components", &m_3dparams.m_ExportComponents,
m_3dparams.m_ExportComponents ) );
m_params.emplace_back( new JOB_PARAM<bool>( "export_tracks", &m_3dparams.m_ExportTracksVias,
m_3dparams.m_ExportTracksVias ) );
m_params.emplace_back( new JOB_PARAM<bool>( "export_pads", &m_3dparams.m_ExportPads,
m_3dparams.m_ExportPads ) );
m_params.emplace_back( new JOB_PARAM<bool>( "export_zones", &m_3dparams.m_ExportZones,
m_3dparams.m_ExportZones ) );
m_params.emplace_back( new JOB_PARAM<bool>( "export_inner_copper",
&m_3dparams.m_ExportInnerCopper,
m_3dparams.m_ExportInnerCopper ) );
m_params.emplace_back( new JOB_PARAM<bool>( "export_silkscreen", &m_3dparams.m_ExportSilkscreen,
m_3dparams.m_ExportInnerCopper ) );
m_params.emplace_back( new JOB_PARAM<bool>( "export_soldermask", &m_3dparams.m_ExportSoldermask,
m_3dparams.m_ExportSoldermask ) );
m_params.emplace_back( new JOB_PARAM<bool>( "fuse_shapes", &m_3dparams.m_FuseShapes,
m_3dparams.m_FuseShapes ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "vrml_model_dir", &m_vrmlModelDir, m_vrmlModelDir ) );
m_params.emplace_back( new JOB_PARAM<bool>( "vrml_relative_paths", &m_vrmlRelativePaths,
m_vrmlRelativePaths ) );
}
wxString JOB_EXPORT_PCB_3D::GetDescription()
{
return wxString::Format( _( "3D model export" ) );
}
REGISTER_JOB( pcb_export_3d, _HKI( "PCB: Export 3D Model" ), KIWAY::FACE_PCB, JOB_EXPORT_PCB_3D );

View File

@ -53,7 +53,8 @@ public:
m_ExportSoldermask( false ),
m_FuseShapes( false ),
m_OptimizeStep( true ),
m_Format( FORMAT::STEP )
m_Format( FORMAT::STEP ),
m_OutputFile()
{};
enum class FORMAT
@ -64,7 +65,6 @@ public:
GLB
};
wxString m_OutputFile;
wxString m_NetFilter;
wxString m_ComponentFilter;
@ -89,6 +89,7 @@ public:
bool m_FuseShapes;
bool m_OptimizeStep;
FORMAT m_Format;
wxString m_OutputFile;
wxString GetDefaultExportExtension() const;
wxString GetFormatName() const;
@ -99,6 +100,7 @@ class KICOMMON_API JOB_EXPORT_PCB_3D : public JOB
{
public:
JOB_EXPORT_PCB_3D( bool aIsCli );
wxString GetDescription() override;
enum class FORMAT
{

View File

@ -19,11 +19,47 @@
*/
#include <jobs/job_export_pcb_drill.h>
#include <jobs/job_registry.h>
#include <i18n_utility.h>
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_DRILL::DRILL_FORMAT,
{
{ JOB_EXPORT_PCB_DRILL::DRILL_FORMAT::EXCELLON, "excellon" },
{ JOB_EXPORT_PCB_DRILL::DRILL_FORMAT::GERBER, "gerber" },
} )
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_DRILL::DRILL_ORIGIN,
{
{ JOB_EXPORT_PCB_DRILL::DRILL_ORIGIN::ABS, "abs" },
{ JOB_EXPORT_PCB_DRILL::DRILL_ORIGIN::PLOT, "plot" },
} )
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_DRILL::DRILL_UNITS,
{
{ JOB_EXPORT_PCB_DRILL::DRILL_UNITS::INCHES, "in" },
{ JOB_EXPORT_PCB_DRILL::DRILL_UNITS::MILLIMETERS, "mm" },
} )
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_DRILL::ZEROS_FORMAT,
{
{ JOB_EXPORT_PCB_DRILL::ZEROS_FORMAT::DECIMAL, "decimal" },
{ JOB_EXPORT_PCB_DRILL::ZEROS_FORMAT::SUPPRESS_LEADING, "surpress_leading" },
{ JOB_EXPORT_PCB_DRILL::ZEROS_FORMAT::SUPPRESS_TRAILING, "surpress_trailing" },
{ JOB_EXPORT_PCB_DRILL::ZEROS_FORMAT::KEEP_ZEROS, "keep_zeros" },
} )
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_DRILL::MAP_FORMAT,
{
{ JOB_EXPORT_PCB_DRILL::MAP_FORMAT::DXF, "dxf" },
{ JOB_EXPORT_PCB_DRILL::MAP_FORMAT::GERBER_X2, "gerberx2" },
{ JOB_EXPORT_PCB_DRILL::MAP_FORMAT::PDF, "pdf" },
{ JOB_EXPORT_PCB_DRILL::MAP_FORMAT::POSTSCRIPT, "postscript" },
{ JOB_EXPORT_PCB_DRILL::MAP_FORMAT::SVG, "svg" },
} )
JOB_EXPORT_PCB_DRILL::JOB_EXPORT_PCB_DRILL( bool aIsCli ) :
JOB( "drill", aIsCli ),
JOB( "drill", true, aIsCli ),
m_filename(),
m_outputDir(),
m_excellonMirrorY( false ),
m_excellonMinimalHeader( false ),
m_excellonCombinePTHNPTH( true ),
@ -36,4 +72,56 @@ JOB_EXPORT_PCB_DRILL::JOB_EXPORT_PCB_DRILL( bool aIsCli ) :
m_gerberPrecision( 5 ),
m_generateMap( false )
{
}
m_params.emplace_back( new JOB_PARAM<bool>( "excellon.mirror_y",
&m_excellonMirrorY,
m_excellonMirrorY ) );
m_params.emplace_back( new JOB_PARAM<bool>( "excellon.minimal_header",
&m_excellonMinimalHeader,
m_excellonMinimalHeader ) );
m_params.emplace_back( new JOB_PARAM<bool>( "excellon.combine_pth_npth",
&m_excellonCombinePTHNPTH,
m_excellonCombinePTHNPTH ) );
m_params.emplace_back( new JOB_PARAM<bool>( "excellon.oval_drill_route",
&m_excellonOvalDrillRoute,
m_excellonOvalDrillRoute ) );
m_params.emplace_back( new JOB_PARAM<DRILL_FORMAT>( "format",
&m_format,
m_format ) );
m_params.emplace_back( new JOB_PARAM<DRILL_ORIGIN>( "drill_origin",
&m_drillOrigin,
m_drillOrigin ) );
m_params.emplace_back( new JOB_PARAM<DRILL_UNITS>( "units",
&m_drillUnits,
m_drillUnits ) );
m_params.emplace_back( new JOB_PARAM<ZEROS_FORMAT>( "zero_format",
&m_zeroFormat,
m_zeroFormat ) );
m_params.emplace_back( new JOB_PARAM<bool>( "generate_map",
&m_generateMap,
m_generateMap ) );
m_params.emplace_back( new JOB_PARAM<MAP_FORMAT>( "map_format",
&m_mapFormat,
m_mapFormat ) );
m_params.emplace_back( new JOB_PARAM<int>( "gerber_precision",
&m_gerberPrecision,
m_gerberPrecision ) );
}
wxString JOB_EXPORT_PCB_DRILL::GetDescription()
{
return wxString::Format( _( "Drill data export" ), m_format );
}
REGISTER_JOB( pcb_export_drill, _HKI( "PCB: Export drill data" ), KIWAY::FACE_PCB,
JOB_EXPORT_PCB_DRILL );

View File

@ -31,8 +31,9 @@ class KICOMMON_API JOB_EXPORT_PCB_DRILL : public JOB
public:
JOB_EXPORT_PCB_DRILL( bool aIsCli );
wxString GetDescription() override;
wxString m_filename;
wxString m_outputDir;
bool m_excellonMirrorY;
bool m_excellonMinimalHeader;

View File

@ -19,19 +19,43 @@
*/
#include <jobs/job_export_pcb_dxf.h>
#include <jobs/job_registry.h>
#include <i18n_utility.h>
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_DXF::DXF_UNITS,
{
{ JOB_EXPORT_PCB_DXF::DXF_UNITS::INCHES, "in" },
{ JOB_EXPORT_PCB_DXF::DXF_UNITS::MILLIMETERS, "mm" },
} )
JOB_EXPORT_PCB_DXF::JOB_EXPORT_PCB_DXF( bool aIsCli ) :
JOB( "dxf", aIsCli ),
m_filename(),
m_outputFile(),
m_drawingSheet(),
m_plotFootprintValues( true ),
m_plotRefDes( true ),
JOB_EXPORT_PCB_PLOT( JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF, "dxf", false, aIsCli ),
m_plotGraphicItemsUsingContours( true ),
m_useDrillOrigin( false ),
m_plotBorderTitleBlocks( false ),
m_dxfUnits( DXF_UNITS::INCHES ),
m_printMaskLayer()
m_dxfUnits( DXF_UNITS::INCHES )
{
}
m_plotDrawingSheet = false;
m_params.emplace_back(
new JOB_PARAM<wxString>( "drawing_sheet", &m_drawingSheet, m_drawingSheet ) );
m_params.emplace_back(
new JOB_PARAM<bool>( "plot_footprint_values", &m_plotFootprintValues, m_plotFootprintValues ) );
m_params.emplace_back( new JOB_PARAM<bool>( "plot_ref_des", &m_plotRefDes, m_plotRefDes ) );
m_params.emplace_back( new JOB_PARAM<bool>( "plot_graphic_items_using_contours", &m_plotGraphicItemsUsingContours,
m_plotGraphicItemsUsingContours ) );
m_params.emplace_back(
new JOB_PARAM<bool>( "use_drill_origin", &m_useDrillOrigin, m_useDrillOrigin ) );
m_params.emplace_back( new JOB_PARAM<bool>( "plot_border_title_blocks", &m_plotDrawingSheet,
m_plotDrawingSheet ) );
m_params.emplace_back( new JOB_PARAM<DXF_UNITS>( "units", &m_dxfUnits, m_dxfUnits ) );
m_params.emplace_back(
new JOB_PARAM<LSEQ>( "layers", &m_printMaskLayer, m_printMaskLayer ) );
}
wxString JOB_EXPORT_PCB_DXF::GetDescription()
{
return wxString::Format( _( "PCB DXF export" ) );
}
REGISTER_JOB( pcb_export_dxf, _HKI( "PCB: Export DXF" ), KIWAY::FACE_PCB, JOB_EXPORT_PCB_DXF );

View File

@ -25,12 +25,14 @@
#include <layer_ids.h>
#include <lseq.h>
#include <wx/string.h>
#include <jobs/job_export_pcb_plot.h>
#include "job.h"
class KICOMMON_API JOB_EXPORT_PCB_DXF : public JOB
class KICOMMON_API JOB_EXPORT_PCB_DXF : public JOB_EXPORT_PCB_PLOT
{
public:
JOB_EXPORT_PCB_DXF( bool aIsCli );
wxString GetDescription() override;
enum class DXF_UNITS
{
@ -38,18 +40,9 @@ public:
MILLIMETERS
};
wxString m_filename;
wxString m_outputFile;
wxString m_drawingSheet;
bool m_plotFootprintValues;
bool m_plotRefDes;
bool m_plotGraphicItemsUsingContours;
bool m_useDrillOrigin;
bool m_plotBorderTitleBlocks;
DXF_UNITS m_dxfUnits;
LSEQ m_printMaskLayer;
};
#endif

View File

@ -22,7 +22,7 @@
JOB_EXPORT_PCB_GENCAD::JOB_EXPORT_PCB_GENCAD( bool aIsCli ) :
JOB( "gencad", aIsCli ),
JOB( "gencad", false, aIsCli ),
m_flipBottomPads( false ),
m_useIndividualShapes( false ),
m_storeOriginCoords( false ),

View File

@ -31,8 +31,6 @@ class KICOMMON_API JOB_EXPORT_PCB_GENCAD : public JOB
{
public:
JOB_EXPORT_PCB_GENCAD( bool aIsCli );
wxString m_outputFile;
wxString m_filename;
bool m_flipBottomPads;

View File

@ -19,29 +19,65 @@
*/
#include <jobs/job_export_pcb_gerber.h>
#include <jobs/job_registry.h>
#include <i18n_utility.h>
JOB_EXPORT_PCB_GERBER::JOB_EXPORT_PCB_GERBER( const std::string& aType, bool aIsCli ) :
JOB( aType, aIsCli ),
m_filename(),
m_outputFile(),
m_drawingSheet(),
m_plotFootprintValues( true ),
m_plotRefDes( true ),
m_plotBorderTitleBlocks( false ),
JOB_EXPORT_PCB_PLOT( JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER, aType, false, aIsCli ),
m_subtractSolderMaskFromSilk( false ),
m_includeNetlistAttributes( true ),
m_useX2Format( true ),
m_disableApertureMacros( false ),
m_useAuxOrigin( false ),
m_useProtelFileExtension( true ),
m_precision( 5 ),
m_printMaskLayer()
m_precision( 5 )
{
m_plotDrawingSheet = false;
m_params.emplace_back( new JOB_PARAM<wxString>( "drawing_sheet",
&m_drawingSheet,
m_drawingSheet ) );
m_params.emplace_back( new JOB_PARAM<bool>( "plot_footprint_values",
&m_plotFootprintValues,
m_plotFootprintValues ) );
m_params.emplace_back( new JOB_PARAM<bool>( "plot_ref_des", &m_plotRefDes, m_plotRefDes ) );
m_params.emplace_back( new JOB_PARAM<bool>( "plot_drawing_sheet",
&m_plotDrawingSheet,
m_plotDrawingSheet ) );
m_params.emplace_back( new JOB_PARAM<bool>( "subtract_solder_mask_from_silk",
&m_subtractSolderMaskFromSilk,
m_subtractSolderMaskFromSilk ) );
m_params.emplace_back( new JOB_PARAM<bool>( "include_netlist_attributes",
&m_includeNetlistAttributes,
m_includeNetlistAttributes ) );
m_params.emplace_back( new JOB_PARAM<bool>( "use_x2_format", &m_useX2Format, m_useX2Format ) );
m_params.emplace_back( new JOB_PARAM<bool>( "disable_aperture_macros", &m_disableApertureMacros,
m_disableApertureMacros ) );
m_params.emplace_back( new JOB_PARAM<bool>( "use_aux_origin",
&m_useAuxOrigin,
m_useAuxOrigin ) );
m_params.emplace_back( new JOB_PARAM<bool>( "use_protel_file_extension",
&m_useProtelFileExtension,
m_useProtelFileExtension ) );
m_params.emplace_back( new JOB_PARAM<int>( "precision", &m_precision, m_precision ) );
m_params.emplace_back( new JOB_PARAM<LSEQ>( "layers", &m_printMaskLayer, m_printMaskLayer ) );
}
JOB_EXPORT_PCB_GERBER::JOB_EXPORT_PCB_GERBER( bool aIsCli ) :
JOB_EXPORT_PCB_GERBER( "gerber", aIsCli )
{
}
wxString JOB_EXPORT_PCB_GERBER::GetDescription()
{
return wxString::Format( _( "Single gerber export" ) );
}

View File

@ -25,21 +25,15 @@
#include <layer_ids.h>
#include <lseq.h>
#include <wx/string.h>
#include "job.h"
#include <jobs/job_export_pcb_plot.h>
class KICOMMON_API JOB_EXPORT_PCB_GERBER : public JOB
class KICOMMON_API JOB_EXPORT_PCB_GERBER : public JOB_EXPORT_PCB_PLOT
{
public:
JOB_EXPORT_PCB_GERBER( const std::string& aType, bool aIsCli );
JOB_EXPORT_PCB_GERBER( bool aIsCli );
wxString GetDescription() override;
wxString m_filename;
wxString m_outputFile;
wxString m_drawingSheet;
bool m_plotFootprintValues;
bool m_plotRefDes;
bool m_plotBorderTitleBlocks;
bool m_subtractSolderMaskFromSilk;
bool m_includeNetlistAttributes;
bool m_useX2Format;
@ -48,9 +42,6 @@ public:
bool m_useProtelFileExtension;
int m_precision;
LSEQ m_printMaskLayer;
};
#endif

View File

@ -19,7 +19,9 @@
*/
#include <jobs/job_export_pcb_gerbers.h>
#include <jobs/lset_json.h>
#include <jobs/job_registry.h>
#include <i18n_utility.h>
JOB_EXPORT_PCB_GERBERS::JOB_EXPORT_PCB_GERBERS( bool aIsCli ) :
JOB_EXPORT_PCB_GERBER( "gerbers", aIsCli ),
@ -27,4 +29,22 @@ JOB_EXPORT_PCB_GERBERS::JOB_EXPORT_PCB_GERBERS( bool aIsCli ) :
m_layersIncludeOnAllSet( false ),
m_useBoardPlotParams( false )
{
}
m_params.emplace_back( new JOB_PARAM<bool>( "use_board_plot_params", &m_useBoardPlotParams,
m_useBoardPlotParams ) );
m_params.emplace_back( new JOB_PARAM<bool>( "layers_include_on_all_set", &m_layersIncludeOnAllSet,
m_layersIncludeOnAllSet ) );
m_params.emplace_back( new JOB_PARAM<LSET>( "layers_include_on_all", &m_layersIncludeOnAll,
m_layersIncludeOnAll ) );
}
wxString JOB_EXPORT_PCB_GERBERS::GetDescription()
{
return wxString::Format( _( "Multi gerber export" ) );
}
REGISTER_JOB( pcb_export_gerbers, _HKI( "PCB: Export Gerbers" ), KIWAY::FACE_PCB,
JOB_EXPORT_PCB_GERBERS );

View File

@ -32,6 +32,7 @@ class KICOMMON_API JOB_EXPORT_PCB_GERBERS : public JOB_EXPORT_PCB_GERBER
{
public:
JOB_EXPORT_PCB_GERBERS( bool aIsCli );
wxString GetDescription() override;
LSET m_layersIncludeOnAll;

View File

@ -19,11 +19,25 @@
*/
#include <jobs/job_export_pcb_ipc2581.h>
#include <jobs/job_registry.h>
#include <i18n_utility.h>
#include <wildcards_and_files_ext.h>
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_IPC2581::IPC2581_UNITS,
{
{ JOB_EXPORT_PCB_IPC2581::IPC2581_UNITS::INCHES, "in" },
{ JOB_EXPORT_PCB_IPC2581::IPC2581_UNITS::MILLIMETERS, "mm" },
} )
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_IPC2581::IPC2581_VERSION,
{
{ JOB_EXPORT_PCB_IPC2581::IPC2581_VERSION::B, "B" },
{ JOB_EXPORT_PCB_IPC2581::IPC2581_VERSION::C, "C" },
} )
JOB_EXPORT_PCB_IPC2581::JOB_EXPORT_PCB_IPC2581( bool aIsCli ) :
JOB( "ipc2581", aIsCli ),
JOB( "ipc2581", false, aIsCli ),
m_filename(),
m_outputFile(),
m_drawingSheet(),
m_units( IPC2581_UNITS::MILLIMETERS ),
m_version( IPC2581_VERSION::C ),
@ -35,4 +49,38 @@ JOB_EXPORT_PCB_IPC2581::JOB_EXPORT_PCB_IPC2581( bool aIsCli ) :
m_colDistPn(),
m_colDist()
{
}
m_params.emplace_back( new JOB_PARAM<wxString>( "drawing_sheet", &m_drawingSheet, m_drawingSheet ) );
m_params.emplace_back( new JOB_PARAM<IPC2581_UNITS>( "units", &m_units, m_units ) );
m_params.emplace_back( new JOB_PARAM<IPC2581_VERSION>( "version", &m_version, m_version ) );
m_params.emplace_back( new JOB_PARAM<int>( "precision", &m_precision, m_precision ) );
m_params.emplace_back( new JOB_PARAM<bool>( "compress", &m_compress, m_compress ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "field_bom_map.internal_id",
&m_colInternalId,
m_colInternalId ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "field_bom_map.mfg_pn",
&m_colMfgPn, m_colMfgPn ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "field_bom_map.mfg", &m_colMfg, m_colMfg ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "field_bom_map.dist_pn",
&m_colDistPn,
m_colDistPn ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "field_bom_map.dist", &m_colDist, m_colDist ) );
}
wxString JOB_EXPORT_PCB_IPC2581::GetDescription()
{
return wxString::Format( _( "IPC2581 export" ) );
}
void JOB_EXPORT_PCB_IPC2581::SetDefaultOutputPath( const wxString& aReferenceName )
{
wxFileName fn = aReferenceName;
fn.SetExt( FILEEXT::Ipc2581FileExtension );
SetOutputPath( fn.GetFullName() );
}
REGISTER_JOB( pcb_export_ipc2581, _HKI( "PCB: Export IPC2581" ), KIWAY::FACE_PCB,
JOB_EXPORT_PCB_IPC2581 );

View File

@ -29,6 +29,9 @@ class KICOMMON_API JOB_EXPORT_PCB_IPC2581 : public JOB
{
public:
JOB_EXPORT_PCB_IPC2581( bool aIsCli );
wxString GetDescription() override;
void SetDefaultOutputPath( const wxString& aReferenceName );
enum class IPC2581_UNITS
{
@ -43,7 +46,6 @@ public:
};
wxString m_filename;
wxString m_outputFile;
wxString m_drawingSheet;
IPC2581_UNITS m_units;

View File

@ -19,25 +19,39 @@
*/
#include <jobs/job_export_pcb_pdf.h>
#include <jobs/job_registry.h>
#include <i18n_utility.h>
JOB_EXPORT_PCB_PDF::JOB_EXPORT_PCB_PDF( bool aIsCli ) :
JOB( "pdf", aIsCli ),
m_filename(),
m_outputFile(),
m_colorTheme(),
m_drawingSheet(),
m_mirror( false ),
m_blackAndWhite( false ),
m_negative( false ),
m_plotFootprintValues( true ),
m_plotRefDes( true ),
m_plotBorderTitleBlocks( false ),
m_printMaskLayer(),
m_sketchPadsOnFabLayers( false ),
m_hideDNPFPsOnFabLayers( false ),
m_sketchDNPFPsOnFabLayers( true ),
m_crossoutDNPFPsOnFabLayers( true ),
m_drillShapeOption( 2 )
JOB_EXPORT_PCB_PLOT( JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF, "pdf", false, aIsCli )
{
}
m_plotDrawingSheet = false;
m_params.emplace_back( new JOB_PARAM<wxString>( "color_theme", &m_colorTheme, m_colorTheme ) );
m_params.emplace_back(
new JOB_PARAM<wxString>( "drawing_sheet", &m_drawingSheet, m_drawingSheet ) );
m_params.emplace_back( new JOB_PARAM<bool>( "mirror", &m_mirror, m_mirror ) );
m_params.emplace_back(
new JOB_PARAM<bool>( "black_and_white", &m_blackAndWhite, m_blackAndWhite ) );
m_params.emplace_back( new JOB_PARAM<bool>( "negative", &m_negative, m_negative ) );
m_params.emplace_back( new JOB_PARAM<bool>( "plot_footprint_values", &m_plotFootprintValues,
m_plotFootprintValues ) );
m_params.emplace_back( new JOB_PARAM<bool>( "plot_ref_des", &m_plotRefDes, m_plotRefDes ) );
m_params.emplace_back( new JOB_PARAM<bool>( "plot_border_title_blocks", &m_plotDrawingSheet,
m_plotDrawingSheet ) );
m_params.emplace_back( new JOB_PARAM<LSEQ>( "layers", &m_printMaskLayer, m_printMaskLayer ) );
m_params.emplace_back( new JOB_PARAM<bool>(
"sketch_pads_on_fab_layers", &m_sketchPadsOnFabLayers, m_sketchPadsOnFabLayers ) );
m_params.emplace_back(
new JOB_PARAM<int>( "drill_shape", &m_drillShapeOption, m_drillShapeOption ) );
}
wxString JOB_EXPORT_PCB_PDF::GetDescription()
{
return wxString::Format( _( "PCB PDF export" ) );
}
REGISTER_JOB( pcb_export_pdf, _HKI( "PCB: Export PDF" ), KIWAY::FACE_PCB, JOB_EXPORT_PCB_PDF );

View File

@ -26,35 +26,13 @@
#include <layer_ids.h>
#include <lseq.h>
#include <wx/string.h>
#include "job.h"
#include <jobs/job_export_pcb_plot.h>
class KICOMMON_API JOB_EXPORT_PCB_PDF : public JOB
class KICOMMON_API JOB_EXPORT_PCB_PDF : public JOB_EXPORT_PCB_PLOT
{
public:
JOB_EXPORT_PCB_PDF( bool aIsCli );
wxString m_filename;
wxString m_outputFile;
wxString m_colorTheme;
wxString m_drawingSheet;
bool m_mirror;
bool m_blackAndWhite;
bool m_negative;
bool m_plotFootprintValues;
bool m_plotRefDes;
bool m_plotBorderTitleBlocks;
LSEQ m_printMaskLayer;
bool m_sketchPadsOnFabLayers;
bool m_hideDNPFPsOnFabLayers;
bool m_sketchDNPFPsOnFabLayers;
bool m_crossoutDNPFPsOnFabLayers;
// How holes in pads/vias are plotted:
// 0 = no hole, 1 = small shape, 2 = actual shape
int m_drillShapeOption;
wxString GetDescription() override;
};
#endif

View File

@ -0,0 +1,27 @@
#include <jobs/job_export_pcb_plot.h>
JOB_EXPORT_PCB_PLOT::JOB_EXPORT_PCB_PLOT( PLOT_FORMAT aFormat, const std::string& aType,
bool aOutputIsDirectory,
bool aIsCli )
: JOB( aType, aOutputIsDirectory, aIsCli ),
m_plotFormat( aFormat ),
m_filename(),
m_colorTheme(),
m_drawingSheet(),
m_mirror( false ),
m_blackAndWhite( false ),
m_negative( false ),
m_sketchPadsOnFabLayers( false ),
m_hideDNPFPsOnFabLayers( false ),
m_sketchDNPFPsOnFabLayers( true ),
m_crossoutDNPFPsOnFabLayers( true ),
m_plotFootprintValues( true ),
m_plotRefDes( true ),
m_plotDrawingSheet( true ),
m_printMaskLayer(),
m_drillShapeOption( 2 )
{
}

Some files were not shown because too many files have changed in this diff Show More