Mini-refactor step to a generic "3d" cli option (step command still exists for now)
This commit is contained in:
parent
a2627fec60
commit
5870b4f373
|
@ -24,11 +24,11 @@
|
|||
#include <wx/string.h>
|
||||
#include "job.h"
|
||||
|
||||
class JOB_EXPORT_PCB_STEP : public JOB
|
||||
class JOB_EXPORT_PCB_3D : public JOB
|
||||
{
|
||||
public:
|
||||
JOB_EXPORT_PCB_STEP( bool aIsCli ) :
|
||||
JOB( "step", aIsCli ),
|
||||
JOB_EXPORT_PCB_3D( bool aIsCli ) :
|
||||
JOB( "3d", aIsCli ),
|
||||
m_overwrite( false ),
|
||||
m_useGridOrigin( false ),
|
||||
m_useDrillOrigin( false ),
|
||||
|
@ -42,23 +42,31 @@ public:
|
|||
m_yOrigin( 0.0 ),
|
||||
// max dist to chain 2 items (lines or curves) to build the board outlines
|
||||
m_BoardOutlinesChainingEpsilon( 0.01 ), // 0.01 mm is a good value
|
||||
m_exportTracks( false ) // Extremely time consuming if true
|
||||
m_exportTracks( false ), // Extremely time consuming if true
|
||||
m_format( JOB_EXPORT_PCB_3D::FORMAT::UNKNOWN )
|
||||
{
|
||||
}
|
||||
|
||||
bool m_overwrite;
|
||||
bool m_useGridOrigin;
|
||||
bool m_useDrillOrigin;
|
||||
bool m_boardOnly;
|
||||
bool m_includeUnspecified;
|
||||
bool m_includeDNP;
|
||||
bool m_substModels;
|
||||
wxString m_filename;
|
||||
wxString m_outputFile;
|
||||
double m_xOrigin;
|
||||
double m_yOrigin;
|
||||
double m_BoardOutlinesChainingEpsilon;
|
||||
bool m_exportTracks;
|
||||
enum class FORMAT
|
||||
{
|
||||
UNKNOWN, // defefer to arg
|
||||
STEP
|
||||
};
|
||||
|
||||
bool m_overwrite;
|
||||
bool m_useGridOrigin;
|
||||
bool m_useDrillOrigin;
|
||||
bool m_boardOnly;
|
||||
bool m_includeUnspecified;
|
||||
bool m_includeDNP;
|
||||
bool m_substModels;
|
||||
wxString m_filename;
|
||||
wxString m_outputFile;
|
||||
double m_xOrigin;
|
||||
double m_yOrigin;
|
||||
double m_BoardOutlinesChainingEpsilon;
|
||||
bool m_exportTracks;
|
||||
JOB_EXPORT_PCB_3D::FORMAT m_format;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -37,13 +37,13 @@ set( KICAD_CLI_SRCS
|
|||
cli/command.cpp
|
||||
cli/command_pcb_export_base.cpp
|
||||
cli/command_pcb_drc.cpp
|
||||
cli/command_pcb_export_3d.cpp
|
||||
cli/command_pcb_export_drill.cpp
|
||||
cli/command_pcb_export_dxf.cpp
|
||||
cli/command_pcb_export_gerber.cpp
|
||||
cli/command_pcb_export_gerbers.cpp
|
||||
cli/command_pcb_export_pdf.cpp
|
||||
cli/command_pcb_export_pos.cpp
|
||||
cli/command_pcb_export_step.cpp
|
||||
cli/command_pcb_export_svg.cpp
|
||||
cli/command_fp_export_svg.cpp
|
||||
cli/command_fp_upgrade.cpp
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "command_pcb_export_step.h"
|
||||
#include "command_pcb_export_3d.h"
|
||||
#include <cli/exit_codes.h>
|
||||
#include "jobs/job_export_pcb_step.h"
|
||||
#include <kiface_base.h>
|
||||
#include <regex>
|
||||
#include <locale_io.h>
|
||||
#include <wx/crt.h>
|
||||
|
||||
#include <macros.h>
|
||||
|
||||
|
@ -39,13 +39,24 @@
|
|||
#define ARG_USER_ORIGIN "--user-origin"
|
||||
#define ARG_BOARD_ONLY "--board-only"
|
||||
#define ARG_EXPORT_TRACKS "--export-tracks"
|
||||
#define ARG_FORMAT "--format"
|
||||
|
||||
#define REGEX_QUANTITY "([\\s]*[+-]?[\\d]*[.]?[\\d]*)"
|
||||
#define REGEX_DELIMITER "(?:[\\s]*x)"
|
||||
#define REGEX_UNIT "([m]{2}|(?:in))"
|
||||
|
||||
CLI::PCB_EXPORT_STEP_COMMAND::PCB_EXPORT_STEP_COMMAND() : COMMAND( "step" )
|
||||
CLI::PCB_EXPORT_3D_COMMAND::PCB_EXPORT_3D_COMMAND( const std::string& aName,
|
||||
JOB_EXPORT_PCB_3D::FORMAT aFormat ) :
|
||||
COMMAND( aName ),
|
||||
m_format( aFormat )
|
||||
{
|
||||
if( m_format == JOB_EXPORT_PCB_3D::FORMAT::UNKNOWN )
|
||||
{
|
||||
m_argParser.add_argument( ARG_FORMAT )
|
||||
.default_value( std::string( "step" ) )
|
||||
.help( UTF8STDSTR( _( "Output file format, options: step" ) ) );
|
||||
}
|
||||
|
||||
m_argParser.add_argument( ARG_DRILL_ORIGIN )
|
||||
.help( UTF8STDSTR( _( "Use Drill Origin for output origin" ) ) )
|
||||
.implicit_value( true )
|
||||
|
@ -101,9 +112,9 @@ CLI::PCB_EXPORT_STEP_COMMAND::PCB_EXPORT_STEP_COMMAND() : COMMAND( "step" )
|
|||
m_argParser.add_argument( ARG_INPUT ).help( UTF8STDSTR( _( "Input file" ) ) );
|
||||
}
|
||||
|
||||
int CLI::PCB_EXPORT_STEP_COMMAND::doPerform( KIWAY& aKiway )
|
||||
int CLI::PCB_EXPORT_3D_COMMAND::doPerform( KIWAY& aKiway )
|
||||
{
|
||||
std::unique_ptr<JOB_EXPORT_PCB_STEP> step( new JOB_EXPORT_PCB_STEP( true ) );
|
||||
std::unique_ptr<JOB_EXPORT_PCB_3D> step( new JOB_EXPORT_PCB_3D( true ) );
|
||||
|
||||
step->m_useDrillOrigin = m_argParser.get<bool>( ARG_DRILL_ORIGIN );
|
||||
step->m_useGridOrigin = m_argParser.get<bool>( ARG_GRID_ORIGIN );
|
||||
|
@ -115,6 +126,22 @@ int CLI::PCB_EXPORT_STEP_COMMAND::doPerform( KIWAY& aKiway )
|
|||
step->m_outputFile = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
|
||||
step->m_boardOnly = m_argParser.get<bool>( ARG_BOARD_ONLY );
|
||||
step->m_exportTracks = m_argParser.get<bool>( ARG_EXPORT_TRACKS );
|
||||
step->m_format = m_format;
|
||||
|
||||
if( step->m_format == JOB_EXPORT_PCB_3D::FORMAT::UNKNOWN )
|
||||
{
|
||||
wxString format = FROM_UTF8( m_argParser.get<std::string>( ARG_FORMAT ).c_str() );
|
||||
|
||||
if( format == wxS( "step" ) )
|
||||
{
|
||||
step->m_format = JOB_EXPORT_PCB_3D::FORMAT::STEP;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFprintf( stderr, _( "Invalid format specified\n" ) );
|
||||
return EXIT_CODES::ERR_ARGS;
|
||||
}
|
||||
}
|
||||
|
||||
wxString userOrigin = FROM_UTF8( m_argParser.get<std::string>( ARG_USER_ORIGIN ).c_str() );
|
||||
|
|
@ -18,19 +18,22 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_EXPORT_PCB_STEP_H
|
||||
#define COMMAND_EXPORT_PCB_STEP_H
|
||||
#ifndef COMMAND_EXPORT_PCB_3D_H
|
||||
#define COMMAND_EXPORT_PCB_3D_H
|
||||
|
||||
#include "command.h"
|
||||
#include "jobs/job_export_pcb_3d.h"
|
||||
|
||||
namespace CLI
|
||||
{
|
||||
struct PCB_EXPORT_STEP_COMMAND : public COMMAND
|
||||
struct PCB_EXPORT_3D_COMMAND : public COMMAND
|
||||
{
|
||||
PCB_EXPORT_STEP_COMMAND();
|
||||
PCB_EXPORT_3D_COMMAND( const std::string& aName,
|
||||
JOB_EXPORT_PCB_3D::FORMAT aFormat = JOB_EXPORT_PCB_3D::FORMAT::UNKNOWN );
|
||||
|
||||
protected:
|
||||
int doPerform( KIWAY& aKiway ) override;
|
||||
JOB_EXPORT_PCB_3D::FORMAT m_format;
|
||||
};
|
||||
}
|
||||
|
|
@ -49,6 +49,7 @@
|
|||
#include "cli/command_pcb.h"
|
||||
#include "cli/command_pcb_export.h"
|
||||
#include "cli/command_pcb_drc.h"
|
||||
#include "cli/command_pcb_export_3d.h"
|
||||
#include "cli/command_pcb_export_drill.h"
|
||||
#include "cli/command_pcb_export_dxf.h"
|
||||
#include "cli/command_pcb_export_gerber.h"
|
||||
|
@ -56,7 +57,6 @@
|
|||
#include "cli/command_pcb_export_pdf.h"
|
||||
#include "cli/command_pcb_export_pos.h"
|
||||
#include "cli/command_pcb_export_svg.h"
|
||||
#include "cli/command_pcb_export_step.h"
|
||||
#include "cli/command_sch_export_bom.h"
|
||||
#include "cli/command_sch_export_pythonbom.h"
|
||||
#include "cli/command_sch_export_netlist.h"
|
||||
|
@ -128,9 +128,10 @@ struct COMMAND_ENTRY
|
|||
|
||||
static CLI::PCB_COMMAND pcbCmd{};
|
||||
static CLI::PCB_DRC_COMMAND pcbDrcCmd{};
|
||||
static CLI::PCB_EXPORT_3D_COMMAND exportPcb3dCmd{ "3d" };
|
||||
static CLI::PCB_EXPORT_DRILL_COMMAND exportPcbDrillCmd{};
|
||||
static CLI::PCB_EXPORT_DXF_COMMAND exportPcbDxfCmd{};
|
||||
static CLI::PCB_EXPORT_STEP_COMMAND exportPcbStepCmd{};
|
||||
static CLI::PCB_EXPORT_3D_COMMAND exportPcbStepCmd{ "step", JOB_EXPORT_PCB_3D::FORMAT::STEP };
|
||||
static CLI::PCB_EXPORT_SVG_COMMAND exportPcbSvgCmd{};
|
||||
static CLI::PCB_EXPORT_PDF_COMMAND exportPcbPdfCmd{};
|
||||
static CLI::PCB_EXPORT_POS_COMMAND exportPcbPosCmd{};
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <jobs/job_export_pcb_pdf.h>
|
||||
#include <jobs/job_export_pcb_pos.h>
|
||||
#include <jobs/job_export_pcb_svg.h>
|
||||
#include <jobs/job_export_pcb_step.h>
|
||||
#include <jobs/job_export_pcb_3d.h>
|
||||
#include <jobs/job_pcb_drc.h>
|
||||
#include <cli/exit_codes.h>
|
||||
#include <exporters/place_file_exporter.h>
|
||||
|
@ -65,8 +65,7 @@
|
|||
|
||||
PCBNEW_JOBS_HANDLER::PCBNEW_JOBS_HANDLER()
|
||||
{
|
||||
Register( "step",
|
||||
std::bind( &PCBNEW_JOBS_HANDLER::JobExportStep, this, std::placeholders::_1 ) );
|
||||
Register( "3d", std::bind( &PCBNEW_JOBS_HANDLER::JobExportStep, this, std::placeholders::_1 ) );
|
||||
Register( "svg", std::bind( &PCBNEW_JOBS_HANDLER::JobExportSvg, this, std::placeholders::_1 ) );
|
||||
Register( "dxf", std::bind( &PCBNEW_JOBS_HANDLER::JobExportDxf, this, std::placeholders::_1 ) );
|
||||
Register( "pdf", std::bind( &PCBNEW_JOBS_HANDLER::JobExportPdf, this, std::placeholders::_1 ) );
|
||||
|
@ -81,14 +80,13 @@ PCBNEW_JOBS_HANDLER::PCBNEW_JOBS_HANDLER()
|
|||
std::bind( &PCBNEW_JOBS_HANDLER::JobExportFpUpgrade, this, std::placeholders::_1 ) );
|
||||
Register( "fpsvg",
|
||||
std::bind( &PCBNEW_JOBS_HANDLER::JobExportFpSvg, this, std::placeholders::_1 ) );
|
||||
Register( "drc",
|
||||
std::bind( &PCBNEW_JOBS_HANDLER::JobExportDrc, this, std::placeholders::_1 ) );
|
||||
Register( "drc", std::bind( &PCBNEW_JOBS_HANDLER::JobExportDrc, this, std::placeholders::_1 ) );
|
||||
}
|
||||
|
||||
|
||||
int PCBNEW_JOBS_HANDLER::JobExportStep( JOB* aJob )
|
||||
{
|
||||
JOB_EXPORT_PCB_STEP* aStepJob = dynamic_cast<JOB_EXPORT_PCB_STEP*>( aJob );
|
||||
JOB_EXPORT_PCB_3D* aStepJob = dynamic_cast<JOB_EXPORT_PCB_3D*>( aJob );
|
||||
|
||||
if( aStepJob == nullptr )
|
||||
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
|
|
Loading…
Reference in New Issue