Add (off by default) build option to link kicad2step directly into pcbnew

Because debugging it separately is annoying.
This commit is contained in:
Marek Roszko 2021-09-11 12:40:20 -04:00
parent f42505b422
commit 74fd23f573
9 changed files with 448 additions and 259 deletions

View File

@ -156,6 +156,9 @@ cmake_dependent_option( KICAD_WIN32_INSTALL_PDBS
OFF "WIN32"
OFF )
option( KICAD_STEP_EXPORT_LIB
"Build and use kicad2step as a library, meant for debugging"
OFF )
# Global setting: exports are explicit
set( CMAKE_CXX_VISIBILITY_PRESET "hidden" )

View File

@ -655,6 +655,17 @@ add_dependencies( pcbnew_kiface_objects dxflib_qcad )
add_dependencies( pcbnew_kiface_objects tinyspline_lib )
add_dependencies( pcbnew_kiface_objects nanosvg )
if( KICAD_STEP_EXPORT_LIB )
target_include_directories( pcbnew_kiface_objects PRIVATE
$<TARGET_PROPERTY:kicad2step_lib,INTERFACE_INCLUDE_DIRECTORIES>
)
add_dependencies( pcbnew_kiface_objects kicad2step_lib )
list( APPEND PCBNEW_EXTRA_LIBS kicad2step_lib )
add_definitions( -DKICAD_STEP_EXPORT_LIB )
endif()
add_library( pcbnew_kiface MODULE $<TARGET_OBJECTS:pcbnew_kiface_objects> )
set_target_properties( pcbnew_kiface PROPERTIES

View File

@ -43,6 +43,10 @@
#include <wildcards_and_files_ext.h>
#include <filename_resolver.h>
#ifdef KICAD_STEP_EXPORT_LIB
#include <kicad2step.h>
#endif
class DIALOG_EXPORT_STEP: public DIALOG_EXPORT_STEP_BASE
{
public:
@ -358,6 +362,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
double xOrg = 0.0;
double yOrg = 0.0;
#ifndef KICAD_STEP_EXPORT_LIB
wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
#ifdef __WXMAC__
@ -438,5 +443,62 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
wxExecute( cmdK2S, wxEXEC_ASYNC | wxEXEC_SHOW_CONSOLE );
#else
KICAD2MCAD_PRMS params;
params.m_filename = m_boardPath;
params.m_outputFile = m_filePickerSTEP->GetPath();
params.m_includeVirtual = !GetNoVirtOption();
params.m_substModels = GetSubstOption();
params.m_minDistance = tolerance;
params.m_overwrite = true;
switch( orgOpt )
{
case DIALOG_EXPORT_STEP::STEP_ORG_0:
break;
case DIALOG_EXPORT_STEP::STEP_ORG_PLOT_AXIS:
params.m_useDrillOrigin = true;
break;
case DIALOG_EXPORT_STEP::STEP_ORG_GRID_AXIS:
params.m_useGridOrigin = true;
break;
case DIALOG_EXPORT_STEP::STEP_ORG_USER:
{
xOrg = GetXOrg();
yOrg = GetYOrg();
if( GetOrgUnitsChoice() == 1 )
{
// selected reference unit is in inches, and STEP units are mm
xOrg *= 25.4;
yOrg *= 25.4;
}
params.m_xOrigin = xOrg;
params.m_yOrigin = yOrg;
}
break;
case DIALOG_EXPORT_STEP::STEP_ORG_BOARD_CENTER:
{
EDA_RECT bbox = m_parent->GetBoard()->ComputeBoundingBox( true );
xOrg = Iu2Millimeter( bbox.GetCenter().x );
yOrg = Iu2Millimeter( bbox.GetCenter().y );
params.m_xOrigin = xOrg;
params.m_yOrigin = yOrg;
}
break;
}
KICAD2STEP converter( params );
converter.Run();
#endif
aEvent.Skip(); // Close the dialog
}

View File

@ -16,6 +16,10 @@ set( KS2_LIB_FILES
pcb/oce_utils.cpp
)
if( MINGW )
list( APPEND KS2_LIB_FILES ${CMAKE_SOURCE_DIR}/common/streamwrapper.cpp )
endif( MINGW )
# Break the library out for re-use by both kicad2step and any qa that needs it
# In future, this could move for re-use by other programs needing s-expr support (?)
add_library( kicad2step_lib STATIC
@ -30,40 +34,43 @@ target_include_directories( kicad2step_lib PUBLIC
target_link_libraries( kicad2step_lib
sexpr
${wxWidgets_LIBRARIES}
${OCC_LIBRARIES}
${ZLIB_LIBRARIES}
)
set( K2S_FILES
kicad2step.cpp
kicad2step_app.cpp
)
if( MINGW )
list( APPEND K2S_FILES ${CMAKE_SOURCE_DIR}/common/streamwrapper.cpp )
endif( MINGW )
add_executable( kicad2step WIN32 ${K2S_FILES} )
add_executable( kicad2step_bin WIN32 ${K2S_FILES} )
target_link_libraries( kicad2step
kicad2step_lib
${wxWidgets_LIBRARIES}
${OCC_LIBRARIES}
${ZLIB_LIBRARIES} )
target_link_libraries( kicad2step_bin
kicad2step_lib )
target_include_directories( kicad2step_lib PRIVATE
$<TARGET_PROPERTY:gzip-hpp,INTERFACE_INCLUDE_DIRECTORIES>
)
set_target_properties( kicad2step_bin
PROPERTIES OUTPUT_NAME kicad2step)
if( APPLE )
# puts binaries into the *.app bundle while linking
set_target_properties( kicad2step PROPERTIES
set_target_properties( kicad2step_bin PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
)
else()
install( TARGETS kicad2step
DESTINATION ${KICAD_BIN}
install( TARGETS kicad2step_bin kicad2step_lib
RUNTIME DESTINATION ${KICAD_BIN}
COMPONENT binary )
endif()
if( KICAD_WIN32_INSTALL_PDBS )
# Get the PDBs to copy over for MSVC
install(FILES $<TARGET_PDB_FILE:kicad2step> DESTINATION ${KICAD_BIN})
install(FILES $<TARGET_PDB_FILE:kicad2step_bin> DESTINATION ${KICAD_BIN})
endif()

View File

@ -32,44 +32,26 @@
#include <iostream>
#include <sstream>
#include "kicad2step.h"
#include "pcb/kicadpcb.h"
#include "kicad2step_frame_base.h"
#include "panel_kicad2step.h"
#include <Standard_Failure.hxx> // In open cascade
class KICAD2STEP_FRAME;
class KICAD2MCAD_APP : public wxApp
{
public:
KICAD2MCAD_APP() :
wxApp(),
m_Panel( nullptr ),
m_frame( nullptr )
{}
virtual bool OnInit() override;
virtual int OnRun() override;
virtual void OnInitCmdLine(wxCmdLineParser& parser) override;
virtual bool OnCmdLineParsed(wxCmdLineParser& parser) override;
PANEL_KICAD2STEP* m_Panel;
private:
KICAD2STEP_FRAME* m_frame;
KICAD2MCAD_PRMS m_params;
};
wxIMPLEMENT_APP( KICAD2MCAD_APP );
class KICAD2STEP_FRAME : public KICAD2STEP_FRAME_BASE
{
public:
KICAD2STEP_FRAME( const wxString& title );
};
// Horrible hack until we decouple things more
static PANEL_KICAD2STEP* openPanel = nullptr;
void ReportMessage( const wxString& aMessage )
{
if( openPanel != nullptr )
openPanel->AppendMessage( aMessage );
}
KICAD2MCAD_PRMS::KICAD2MCAD_PRMS()
{
@ -88,90 +70,11 @@ KICAD2MCAD_PRMS::KICAD2MCAD_PRMS()
}
void ReportMessage( const wxString& aMessage )
{
KICAD2MCAD_APP& app = wxGetApp();
app.m_Panel->AppendMessage( aMessage );
}
static const wxCmdLineEntryDesc cmdLineDesc[] = {
{ wxCMD_LINE_PARAM, NULL, NULL, _( "pcb_filename" ).mb_str(), wxCMD_LINE_VAL_STRING,
wxCMD_LINE_OPTION_MANDATORY },
{ wxCMD_LINE_OPTION, "o", "output-filename", _( "output filename" ).mb_str(),
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
#ifdef SUPPORTS_IGES
{ wxCMD_LINE_SWITCH, "fmt-iges", NULL, _( "IGES output (default STEP)" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
#endif
{ wxCMD_LINE_SWITCH, "f", "force", _( "overwrite output file" ).mb_str(), wxCMD_LINE_VAL_NONE,
wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, NULL, "drill-origin", _( "Use Drill Origin for output origin" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, NULL, "grid-origin", _( "Use Grid Origin for output origin" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, NULL, "user-origin",
_( "User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm (default mm)" ).mb_str(),
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, NULL, "no-virtual",
_( "Exclude 3D models for components with 'virtual' attribute" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, NULL, "subst-models",
_( "Substitute STEP or IGS models with the same name in place of VRML models" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, NULL, "min-distance",
_( "Minimum distance between points to treat them as separate ones (default 0.01 mm)" )
.mb_str(),
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, "h", NULL, _( "display this message" ).mb_str(), wxCMD_LINE_VAL_NONE,
wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_NONE, nullptr, nullptr, nullptr, wxCMD_LINE_VAL_NONE, 0 }
};
bool KICAD2MCAD_APP::OnInit()
{
if( !wxApp::OnInit() )
return false;
// create the main application window
m_frame = new KICAD2STEP_FRAME( "Kicad2step" );
m_Panel = m_frame->m_panelKicad2Step;
m_Panel->m_params = m_params;
// and show it (a wxFrame is not shown when created initially)
m_frame->Show( true );
m_frame->Iconize( false );
return true;
}
int KICAD2MCAD_APP::OnRun()
{
int diag = m_Panel->RunConverter();
wxApp::OnRun(); // Start the main loop event, to manage the main frame
return diag;
}
KICAD2STEP_FRAME::KICAD2STEP_FRAME( const wxString& title ) :
KICAD2STEP_FRAME_BASE( NULL, wxID_ANY, title )
{
}
void KICAD2MCAD_APP::OnInitCmdLine( wxCmdLineParser& parser )
{
parser.SetDesc( cmdLineDesc );
parser.SetSwitchChars( "-" );
}
PANEL_KICAD2STEP::PANEL_KICAD2STEP( wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style ) :
wxPanel( parent, id, pos, size, style )
@ -195,122 +98,6 @@ void PANEL_KICAD2STEP::AppendMessage( const wxString& aMessage )
}
bool KICAD2MCAD_APP::OnCmdLineParsed( wxCmdLineParser& parser )
{
#ifdef SUPPORTS_IGES
if( parser.Found( "fmt-iges" ) )
m_fmtIGES = true;
#endif
if( parser.Found( "f" ) )
m_params.m_overwrite = true;
if( parser.Found( "grid-origin" ) )
m_params.m_useGridOrigin = true;
if( parser.Found( "drill-origin" ) )
m_params. m_useDrillOrigin = true;
if( parser.Found( "no-virtual" ) )
m_params.m_includeVirtual = false;
if( parser.Found( "subst-models" ) )
m_params.m_substModels = true;
wxString tstr;
if( parser.Found( "user-origin", &tstr ) )
{
std::istringstream istr;
istr.str( std::string( tstr.ToUTF8() ) );
istr >> m_params.m_xOrigin;
if( istr.fail() )
{
parser.Usage();
return false;
}
char tmpc;
istr >> tmpc;
if( istr.fail() || ( tmpc != 'x' && tmpc != 'X' ) )
{
parser.Usage();
return false;
}
istr >> m_params.m_yOrigin;
if( istr.fail() )
{
parser.Usage();
return false;
}
if( !istr.eof() )
{
std::string tunit;
istr >> tunit;
if( !tunit.compare( "in" ) || !tunit.compare( "inch" ) )
{
m_params.m_xOrigin *= 25.4;
m_params.m_yOrigin *= 25.4;
}
else if( tunit.compare( "mm" ) )
{
parser.Usage();
return false;
}
}
}
if( parser.Found( "min-distance", &tstr ) )
{
std::istringstream istr;
istr.str( std::string( tstr.ToUTF8() ) );
istr >> m_params.m_minDistance;
if( istr.fail() )
{
parser.Usage();
return false;
}
if( !istr.eof() )
{
std::string tunit;
istr >> tunit;
if( !tunit.compare( "in" ) || !tunit.compare( "inch" ) )
{
m_params.m_minDistance *= 25.4;
}
else if( tunit.compare( "mm" ) )
{
parser.Usage();
return false;
}
}
}
if( parser.Found( "o", &tstr ) )
m_params.m_outputFile = tstr;
if( parser.GetParamCount() < 1 )
{
parser.Usage();
return false;
}
m_params.m_filename = parser.GetParam( 0 );
return true;
}
// Smart class that will swap streambufs and replace them when object goes out of scope.
// ( ensure the initial stream buffer is restored )
// see:
@ -477,3 +264,36 @@ wxString KICAD2MCAD_PRMS::getOutputExt() const
#endif
return wxString( "step" );
}
KICAD2STEP::KICAD2STEP( KICAD2MCAD_PRMS aParams ) : m_params( aParams ), m_panel( nullptr )
{
}
int KICAD2STEP::Run()
{
// create the main application window
KICAD2STEP_FRAME* frame = new KICAD2STEP_FRAME( "Kicad2step" );
m_panel = frame->m_panelKicad2Step;
m_panel->m_params = m_params;
// and show it (a wxFrame is not shown when created initially)
frame->Show( true );
frame->Iconize( false );
openPanel = m_panel;
int diag = m_panel->RunConverter();
openPanel = nullptr;
return diag;
}
void KICAD2STEP::ReportMessage( const wxString& aMessage )
{
m_panel->AppendMessage( aMessage );
}

View File

@ -0,0 +1,69 @@
/*
* This program source code file is part of kicad2mcad
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2016-2021 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 2
* 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, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef KICAD2STEP_H
#define KICAD2STEP_H
#include <wx/string.h>
#include <import_export.h>
class PANEL_KICAD2STEP;
class APIEXPORT KICAD2MCAD_PRMS // A small class to handle parameters of conversion
{
public:
KICAD2MCAD_PRMS();
///< Return file extension for the selected output format
wxString getOutputExt() const;
#ifdef SUPPORTS_IGES
bool m_fmtIGES;
#endif
bool m_overwrite;
bool m_useGridOrigin;
bool m_useDrillOrigin;
bool m_includeVirtual;
bool m_substModels;
wxString m_filename;
wxString m_outputFile;
double m_xOrigin;
double m_yOrigin;
double m_minDistance;
};
class APIEXPORT KICAD2STEP
{
public:
KICAD2STEP( KICAD2MCAD_PRMS aParams );
int Run();
void ReportMessage( const wxString& aMessage );
private:
KICAD2MCAD_PRMS m_params;
PANEL_KICAD2STEP* m_panel;
};
#endif

View File

@ -0,0 +1,237 @@
/*
* This program source code file is part of kicad2mcad
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2016-2021 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 2
* 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, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wx/app.h>
#include <wx/cmdline.h>
#include <wx/log.h>
#include <wx/msgdlg.h>
#include <wx/string.h>
#include <wx/filename.h>
#include <sstream>
#include <iostream>
#include <sstream>
#include "kicad2step.h"
#include "pcb/kicadpcb.h"
#include "kicad2step_frame_base.h"
#include <Standard_Failure.hxx> // In open cascade
class KICAD2MCAD_APP : public wxApp
{
public:
KICAD2MCAD_APP() : wxApp(), m_converter( nullptr ) {}
virtual bool OnInit() override;
virtual int OnRun() override;
virtual void OnInitCmdLine( wxCmdLineParser& parser ) override;
virtual bool OnCmdLineParsed( wxCmdLineParser& parser ) override;
private:
KICAD2STEP* m_converter;
KICAD2MCAD_PRMS m_params;
};
wxIMPLEMENT_APP( KICAD2MCAD_APP );
static const wxCmdLineEntryDesc cmdLineDesc[] = {
{ wxCMD_LINE_PARAM, NULL, NULL, _( "pcb_filename" ).mb_str(), wxCMD_LINE_VAL_STRING,
wxCMD_LINE_OPTION_MANDATORY },
{ wxCMD_LINE_OPTION, "o", "output-filename", _( "output filename" ).mb_str(),
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
#ifdef SUPPORTS_IGES
{ wxCMD_LINE_SWITCH, "fmt-iges", NULL, _( "IGES output (default STEP)" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
#endif
{ wxCMD_LINE_SWITCH, "f", "force", _( "overwrite output file" ).mb_str(), wxCMD_LINE_VAL_NONE,
wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, NULL, "drill-origin", _( "Use Drill Origin for output origin" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, NULL, "grid-origin", _( "Use Grid Origin for output origin" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, NULL, "user-origin",
_( "User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm (default mm)" ).mb_str(),
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, NULL, "no-virtual",
_( "Exclude 3D models for components with 'virtual' attribute" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, NULL, "subst-models",
_( "Substitute STEP or IGS models with the same name in place of VRML models" ).mb_str(),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, NULL, "min-distance",
_( "Minimum distance between points to treat them as separate ones (default 0.01 mm)" )
.mb_str(),
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, "h", NULL, _( "display this message" ).mb_str(), wxCMD_LINE_VAL_NONE,
wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_NONE, nullptr, nullptr, nullptr, wxCMD_LINE_VAL_NONE, 0 }
};
void KICAD2MCAD_APP::OnInitCmdLine( wxCmdLineParser& parser )
{
parser.SetDesc( cmdLineDesc );
parser.SetSwitchChars( "-" );
}
bool KICAD2MCAD_APP::OnInit()
{
if( !wxApp::OnInit() )
return false;
// create the main application window
m_converter = new KICAD2STEP( m_params );
return true;
}
int KICAD2MCAD_APP::OnRun()
{
int diag = m_converter->Run();
wxApp::OnRun(); // Start the main loop event, to manage the main frame
return diag;
}
bool KICAD2MCAD_APP::OnCmdLineParsed( wxCmdLineParser& parser )
{
#ifdef SUPPORTS_IGES
if( parser.Found( "fmt-iges" ) )
m_fmtIGES = true;
#endif
if( parser.Found( "f" ) )
m_params.m_overwrite = true;
if( parser.Found( "grid-origin" ) )
m_params.m_useGridOrigin = true;
if( parser.Found( "drill-origin" ) )
m_params.m_useDrillOrigin = true;
if( parser.Found( "no-virtual" ) )
m_params.m_includeVirtual = false;
if( parser.Found( "subst-models" ) )
m_params.m_substModels = true;
wxString tstr;
if( parser.Found( "user-origin", &tstr ) )
{
std::istringstream istr;
istr.str( std::string( tstr.ToUTF8() ) );
istr >> m_params.m_xOrigin;
if( istr.fail() )
{
parser.Usage();
return false;
}
char tmpc;
istr >> tmpc;
if( istr.fail() || ( tmpc != 'x' && tmpc != 'X' ) )
{
parser.Usage();
return false;
}
istr >> m_params.m_yOrigin;
if( istr.fail() )
{
parser.Usage();
return false;
}
if( !istr.eof() )
{
std::string tunit;
istr >> tunit;
if( !tunit.compare( "in" ) || !tunit.compare( "inch" ) )
{
m_params.m_xOrigin *= 25.4;
m_params.m_yOrigin *= 25.4;
}
else if( tunit.compare( "mm" ) )
{
parser.Usage();
return false;
}
}
}
if( parser.Found( "min-distance", &tstr ) )
{
std::istringstream istr;
istr.str( std::string( tstr.ToUTF8() ) );
istr >> m_params.m_minDistance;
if( istr.fail() )
{
parser.Usage();
return false;
}
if( !istr.eof() )
{
std::string tunit;
istr >> tunit;
if( !tunit.compare( "in" ) || !tunit.compare( "inch" ) )
{
m_params.m_minDistance *= 25.4;
}
else if( tunit.compare( "mm" ) )
{
parser.Usage();
return false;
}
}
}
if( parser.Found( "o", &tstr ) )
m_params.m_outputFile = tstr;
if( parser.GetParamCount() < 1 )
{
parser.Usage();
return false;
}
m_params.m_filename = parser.GetParam( 0 );
return true;
}

View File

@ -34,29 +34,7 @@
#include <wx/textctrl.h>
#include <wx/panel.h>
class KICAD2MCAD_PRMS // A small class to handle parameters of conversion
{
public:
KICAD2MCAD_PRMS();
///< Return file extension for the selected output format
wxString getOutputExt() const;
#ifdef SUPPORTS_IGES
bool m_fmtIGES;
#endif
bool m_overwrite;
bool m_useGridOrigin;
bool m_useDrillOrigin;
bool m_includeVirtual;
bool m_substModels;
wxString m_filename;
wxString m_outputFile;
double m_xOrigin;
double m_yOrigin;
double m_minDistance;
};
#include "kicad2step.h"
class PANEL_KICAD2STEP: public wxPanel
{

View File

@ -34,6 +34,8 @@
#include <ostream>
#include <import_export.h>
///< Default minimum distance between points to treat them as separate ones (mm)
static constexpr double MIN_DISTANCE = 0.01;
@ -94,7 +96,7 @@ struct TRIPLET
std::ostream& operator<<( std::ostream& aStream, const TRIPLET& aTriplet );
bool Get2DPositionAndRotation( const SEXPR::SEXPR* data, DOUBLET& aPosition, double& aRotation );
APIEXPORT bool Get2DPositionAndRotation( const SEXPR::SEXPR* data, DOUBLET& aPosition, double& aRotation );
bool Get2DCoordinate( const SEXPR::SEXPR* data, DOUBLET& aCoordinate );
bool Get3DCoordinate( const SEXPR::SEXPR* data, TRIPLET& aCoordinate );
bool GetXYZRotation( const SEXPR::SEXPR* data, TRIPLET& aRotation );
@ -107,6 +109,6 @@ bool GetXYZRotation( const SEXPR::SEXPR* data, TRIPLET& aRotation );
* @param aLayerElem the s-expr element to get the name from.
* @return the layer name if valid, else empty.
*/
OPT<std::string> GetLayerName( const SEXPR::SEXPR& aLayerElem );
APIEXPORT OPT<std::string> GetLayerName( const SEXPR::SEXPR& aLayerElem );
#endif // KICADBASE_H