Fix in kicadpcb reader. Update dialog export step

kicad2step: code cleanup, and more activity messages displayed
This commit is contained in:
jean-pierre charras 2018-10-02 08:34:07 +02:00
parent 110b05fe78
commit b68bdc22d7
16 changed files with 573 additions and 501 deletions

View File

@ -68,7 +68,7 @@ namespace SEXPR
std::string const & GetSymbol() const;
SEXPR_LIST* GetList();
std::string AsString( size_t aLevel = 0) const;
size_t GetLineNumber() { return m_lineNumber; }
size_t GetLineNumber() const { return m_lineNumber; }
};
struct SEXPR_INTEGER : public SEXPR

View File

@ -21,6 +21,7 @@
#include <stdexcept>
#include <iomanip>
#include <sstream>
#include <wx/debug.h>
namespace SEXPR
{
@ -128,7 +129,9 @@ namespace SEXPR
{
if( m_type != SEXPR_TYPE::SEXPR_TYPE_ATOM_SYMBOL )
{
throw INVALID_TYPE_EXCEPTION("SEXPR is not a symbol type!");
std::string err_msg( "GetSymbol(): SEXPR is not a symbol type! error line ");
err_msg += std::to_string( GetLineNumber() );
throw INVALID_TYPE_EXCEPTION( err_msg );
}
return static_cast< SEXPR_SYMBOL const * >(this)->m_value;
@ -375,7 +378,7 @@ namespace SEXPR
}
else
{
throw std::invalid_argument( "SEXPR is not a symbol type!" );
throw std::invalid_argument( "operator>>: SEXPR is not a symbol type!" );
}
}
else

View File

@ -24,6 +24,7 @@
#include <wx/choicdlg.h>
#include <wx/stdpaths.h>
#include <wx/process.h>
#include "pcb_edit_frame.h"
#include "kiface_i.h"
@ -35,6 +36,7 @@
#include <widgets/text_ctrl_eval.h>
#include <wx_html_report_panel.h>
#define OPTKEY_STEP_OVERWRITE "STEP_Overwrite"
class DIALOG_EXPORT_STEP: public DIALOG_EXPORT_STEP_BASE
{
@ -53,6 +55,7 @@ private:
// The last preference for STEP Origin:
STEP_ORG_OPT m_STEP_org_opt;
bool m_noVirtual; // remember last preference for No Virtual Component
bool m_overwriteFile; // remember last preference for overwrite file
int m_OrgUnits; // remember last units for User Origin
double m_XOrg; // remember last User Origin X value
double m_YOrg; // remember last User Origin Y value
@ -86,6 +89,11 @@ protected:
return m_cbRemoveVirtual->GetValue();
}
bool GetOverwriteFile()
{
return m_cbOverwriteFile->GetValue();
}
public:
DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& aBoardPath );
@ -153,6 +161,8 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString&
m_noVirtual = cfg->m_ExportStep.no_virtual;
m_cbRemoveVirtual->SetValue( m_noVirtual );
m_config->Read( OPTKEY_STEP_OVERWRITE, &m_overwriteFile, false );
m_cbOverwriteFile->SetValue( m_overwriteFile );
m_STEP_OrgUnitChoice->SetSelection( m_OrgUnits );
wxString tmpStr;
@ -243,7 +253,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
wxFileName fn = m_filePickerSTEP->GetFileName();
if( fn.FileExists() )
if( fn.FileExists() && !GetOverwriteFile() )
{
msg.Printf( _( "File '%s' already exists. Do you want overwrite this file?" ),
fn.GetFullPath().GetData() );
@ -333,49 +343,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
cmdK2S.Append( " " );
cmdK2S.Append( wxString::Format("\"%s\"", m_boardPath ) ); // output file path
int result = 0;
bool success = false;
wxArrayString output, errors;
REPORTER& reporter = m_messagesPanel->Reporter();
reporter.ReportHead( wxString::Format( _( "Executing '%s'" ), cmdK2S ), RPT_SEVERITY_ACTION );
wxExecute( cmdK2S, wxEXEC_ASYNC | wxEXEC_SHOW_CONSOLE );
{
wxBusyCursor dummy;
result = wxExecute( cmdK2S, output, errors, wxEXEC_SYNC | wxEXEC_SHOW_CONSOLE );
}
// Check the output log for an indication of success,
// the value returned by wxExecute is not conclusive
for( auto& l : output )
{
if( !l.IsEmpty() )
reporter.ReportTail( l, REPORTER::RPT_INFO );
if( l.Contains( "Done" ) )
{
success = true;
break;
}
}
for( auto& err : errors )
reporter.Report( err, RPT_SEVERITY_WARNING );
if( result ) // Any troubles?
{
if( !success )
{
reporter.ReportTail( _( "Unable to create STEP file. Check that the board has a "
"valid outline and models." ), RPT_SEVERITY_ERROR );
}
else
{
reporter.ReportTail( _( "STEP file has been created, but there are warnings." ),
RPT_SEVERITY_INFO );
}
}
else
{
reporter.ReportTail( _( "STEP file has been created successfully." ), RPT_SEVERITY_INFO );
}
aEvent.Skip(); // Close the dialog
}

View File

@ -1,12 +1,11 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jan 17 2019)
// C++ code generated with wxFormBuilder (version Dec 1 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/text_ctrl_eval.h"
#include "wx_html_report_panel.h"
#include "dialog_export_step_base.h"
@ -73,9 +72,9 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
fgSizer1->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_staticText5 = new wxStaticText( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5->Wrap( -1 );
fgSizer1->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticTextUnits = new wxStaticText( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextUnits->Wrap( -1 );
fgSizer1->Add( m_staticTextUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxString m_STEP_OrgUnitChoiceChoices[] = { _("mm"), _("inch") };
int m_STEP_OrgUnitChoiceNChoices = sizeof( m_STEP_OrgUnitChoiceChoices ) / sizeof( wxString );
@ -86,9 +85,9 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
fgSizer1->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_staticText3 = new wxStaticText( this, wxID_ANY, _("X position:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3->Wrap( -1 );
fgSizer1->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticTextXpos = new wxStaticText( this, wxID_ANY, _("X position:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextXpos->Wrap( -1 );
fgSizer1->Add( m_staticTextXpos, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_STEP_Xorg = new TEXT_CTRL_EVAL( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
@ -104,9 +103,9 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
fgSizer1->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_staticText4 = new wxStaticText( this, wxID_ANY, _("Y position:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
fgSizer1->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticTextYpos = new wxStaticText( this, wxID_ANY, _("Y position:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextYpos->Wrap( -1 );
fgSizer1->Add( m_staticTextYpos, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_STEP_Yorg = new TEXT_CTRL_EVAL( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
@ -134,34 +133,25 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
bSizer8->Add( m_staticText7, 0, wxALL, 5 );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer* fgSizer3;
fgSizer3 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer3->SetFlexibleDirection( wxBOTH );
fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
fgSizer3->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_cbRemoveVirtual = new wxCheckBox( this, wxID_ANY, _("Ignore virtual components"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer3->Add( m_cbRemoveVirtual, 0, wxALL, 5 );
bSizer8->Add( m_cbRemoveVirtual, 0, wxALL, 5 );
m_cbOverwriteFile = new wxCheckBox( this, wxID_ANY, _("Overwrite old file"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer8->Add( m_cbOverwriteFile, 0, wxALL, 5 );
bSizer6->Add( fgSizer3, 1, wxEXPAND, 5 );
m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizer8->Add( m_staticline3, 0, wxEXPAND | wxALL, 5 );
wxFlexGridSizer* fgSizer4;
fgSizer4 = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizer4->SetFlexibleDirection( wxBOTH );
fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticText9 = new wxStaticText( this, wxID_ANY, _("Board outline builder:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText9->Wrap( -1 );
bSizer8->Add( m_staticText9, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerTolerance;
bSizerTolerance = new wxBoxSizer( wxHORIZONTAL );
fgSizer4->Add( 0, 0, 0, wxALL|wxEXPAND, 5 );
m_staticText8 = new wxStaticText( this, wxID_ANY, _("Tolerance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText8->Wrap( -1 );
fgSizer4->Add( m_staticText8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticTextTolerance = new wxStaticText( this, wxID_ANY, _("Tolerance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextTolerance->Wrap( -1 );
bSizerTolerance->Add( m_staticTextTolerance, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxString m_toleranceChoices[] = { _("Tight"), _("Standard"), _("Loose"), _("Very loose") };
int m_toleranceNChoices = sizeof( m_toleranceChoices ) / sizeof( wxString );
@ -169,22 +159,16 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
m_tolerance->SetSelection( 1 );
m_tolerance->SetToolTip( _("Tolerance sets the distance between two points that are considered joined. Standard is 0.001mm.") );
fgSizer4->Add( m_tolerance, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
bSizerTolerance->Add( m_tolerance, 1, wxALL, 5 );
bSizer6->Add( fgSizer4, 1, wxEXPAND, 10 );
bSizer8->Add( bSizer6, 1, wxEXPAND, 5 );
bSizer8->Add( bSizerTolerance, 0, wxEXPAND, 5 );
bSizer2->Add( bSizer8, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
bSizerSTEPFile->Add( bSizer2, 0, wxEXPAND, 5 );
m_messagesPanel = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
bSizerSTEPFile->Add( m_messagesPanel, 1, wxEXPAND | wxALL, 5 );
bSizerSTEPFile->Add( bSizer2, 1, wxEXPAND, 5 );
m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerSTEPFile->Add( m_staticline, 0, wxEXPAND | wxALL, 5 );

View File

@ -45,7 +45,7 @@
<property name="minimum_size"></property>
<property name="name">DIALOG_EXPORT_STEP_BASE</property>
<property name="pos"></property>
<property name="size">650,361</property>
<property name="size">560,277</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Export STEP</property>
@ -245,7 +245,7 @@
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer2</property>
@ -716,7 +716,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText5</property>
<property name="name">m_staticTextUnits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -852,7 +852,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText3</property>
<property name="name">m_staticTextXpos</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -988,7 +988,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText4</property>
<property name="name">m_staticTextYpos</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1147,258 +1147,385 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Ignore virtual components</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbRemoveVirtual</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Overwrite old file</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbOverwriteFile</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticline3</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Board outline builder:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText9</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer6</property>
<property name="orient">wxVERTICAL</property>
<property name="name">bSizerTolerance</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="0">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Tolerance:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizer3</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="spacer" expanded="0">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Ignore virtual components</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbRemoveVirtual</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<property name="moveable">1</property>
<property name="name">m_staticTextTolerance</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND</property>
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">3</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Tight&quot; &quot;Standard&quot; &quot;Loose&quot; &quot;Very loose&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizer4</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Tolerance:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText8</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Tight&quot; &quot;Standard&quot; &quot;Loose&quot; &quot;Very loose&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_tolerance</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Tolerance sets the distance between two points that are considered joined. Standard is 0.001mm.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<property name="moveable">1</property>
<property name="name">m_tolerance</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Tolerance sets the distance between two points that are considered joined. Standard is 0.001mm.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
@ -1407,63 +1534,6 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">1</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_messagesPanel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass">WX_HTML_REPORT_PANEL; wx_html_report_panel.h</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jan 17 2019)
// C++ code generated with wxFormBuilder (version Dec 1 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -11,7 +11,6 @@
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class TEXT_CTRL_EVAL;
class WX_HTML_REPORT_PANEL;
#include "dialog_shim.h"
#include <wx/string.h>
@ -28,7 +27,6 @@ class WX_HTML_REPORT_PANEL;
#include <wx/textctrl.h>
#include <wx/valtext.h>
#include <wx/checkbox.h>
#include <wx/panel.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -51,17 +49,19 @@ class DIALOG_EXPORT_STEP_BASE : public DIALOG_SHIM
wxRadioButton* m_rbUserDefinedOrigin;
wxRadioButton* m_rbBoardCenterOrigin;
wxStaticText* m_staticText2;
wxStaticText* m_staticText5;
wxStaticText* m_staticTextUnits;
wxChoice* m_STEP_OrgUnitChoice;
wxStaticText* m_staticText3;
wxStaticText* m_staticTextXpos;
TEXT_CTRL_EVAL* m_STEP_Xorg;
wxStaticText* m_staticText4;
wxStaticText* m_staticTextYpos;
TEXT_CTRL_EVAL* m_STEP_Yorg;
wxStaticText* m_staticText7;
wxCheckBox* m_cbRemoveVirtual;
wxStaticText* m_staticText8;
wxCheckBox* m_cbOverwriteFile;
wxStaticLine* m_staticline3;
wxStaticText* m_staticText9;
wxStaticText* m_staticTextTolerance;
wxChoice* m_tolerance;
WX_HTML_REPORT_PANEL* m_messagesPanel;
wxStaticLine* m_staticline;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
@ -76,7 +76,7 @@ class DIALOG_EXPORT_STEP_BASE : public DIALOG_SHIM
public:
DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Export STEP"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 650,361 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Export STEP"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 560,277 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EXPORT_STEP_BASE();
};

View File

@ -5,6 +5,7 @@ include_directories( SYSTEM
set( KS2_LIB_FILES
kicad2step.cpp
kicad2step_frame_base.cpp
pcb/3d_resolver.cpp
pcb/base.cpp
pcb/kicadmodel.cpp

View File

@ -48,11 +48,11 @@ public:
virtual bool OnCmdLineParsed(wxCmdLineParser& parser) override;
private:
KICAD2STEP_FRAME * m_frame;
KICAD2MCAD_PRMS m_params;
public:
PANEL_KICAD2STEP* m_Panel;
KICAD2STEP_FRAME * m_frame;
};
wxIMPLEMENT_APP(KICAD2MCAD_APP);
@ -80,6 +80,7 @@ KICAD2MCAD_PRMS::KICAD2MCAD_PRMS()
}
void ReportMessage( const wxString& aMessage )
{
KICAD2MCAD_APP& app = wxGetApp();
@ -124,13 +125,12 @@ bool KICAD2MCAD_APP::OnInit()
return false;
// create the main application window
m_frame = new KICAD2STEP_FRAME("Kicad2step");
m_frame = new KICAD2STEP_FRAME( "Kicad2step" );
m_Panel = m_frame->m_panelKicad2Step;
m_Panel->m_params = m_params;
// and show it (the frames, unlike simple controls, are not shown when
// created initially)
// and show it (a wxRrame is not shown when created initially)
m_frame->Show( true );
m_frame->Iconize( false );
@ -140,9 +140,9 @@ bool KICAD2MCAD_APP::OnInit()
int KICAD2MCAD_APP::OnRun()
{
m_frame->Show(true);
m_Panel->RunConverter();
return 0;
int diag = m_Panel->RunConverter();
wxApp::OnRun(); // Start the main loop event, to manage the main frame
return diag;
}
@ -178,7 +178,8 @@ PANEL_KICAD2STEP::PANEL_KICAD2STEP( wxWindow* parent, wxWindowID id,
void PANEL_KICAD2STEP::AppendMessage( const wxString& aMessage )
{
m_tcMessages->AppendText( aMessage ); wxSafeYield();
m_tcMessages->AppendText( aMessage );
wxSafeYield();
}
@ -331,41 +332,44 @@ int PANEL_KICAD2STEP::RunConverter()
return -1;
}
wxFileName tfname;
wxFileName out_fname;
if( m_params.m_outputFile.empty() )
{
tfname.Assign( fname.GetFullPath() );
tfname.SetExt( m_params.getOutputExt() );
out_fname.Assign( fname.GetFullPath() );
out_fname.SetExt( m_params.getOutputExt() );
}
else
{
tfname.Assign( m_params.m_outputFile );
out_fname.Assign( m_params.m_outputFile );
// Set the file extension if the user's requested
// file name does not have an extension.
if( !tfname.HasExt() )
tfname.SetExt( m_params.getOutputExt() );
if( !out_fname.HasExt() )
out_fname.SetExt( m_params.getOutputExt() );
}
if( tfname.FileExists() && !m_params.m_overwrite )
if( out_fname.FileExists() && !m_params.m_overwrite )
{
wxMessageBox( "** Output already exists.\n"
ReportMessage( "** Output already exists.\n"
"Enable the force overwrite flag to overwrite it." );
return -1;
}
wxString outfile = tfname.GetFullPath();
KICADPCB pcb( m_tcMessages );
wxString outfile = out_fname.GetFullPath();
KICADPCB pcb;
pcb.SetOrigin( m_params.m_xOrigin, m_params.m_yOrigin );
pcb.SetMinDistance( m_params.m_minDistance );
m_tcMessages->AppendText( wxString::Format( "Read: %s\n", m_params.m_filename ) );
ReportMessage( wxString::Format( "Read: %s\n", m_params.m_filename ) );
// create the new stream to "redirect" cout's output to
// create the new streams to "redirect" cout and cerr output to
// msgs_from_opencascade and errors_from_opencascade
std::ostringstream msgs_from_opencascade;
STREAMBUF_SWAPPER swapper(cout, msgs_from_opencascade);
std::ostringstream errors_from_opencascade;
STREAMBUF_SWAPPER swapper_cout(cout, msgs_from_opencascade);
STREAMBUF_SWAPPER swapper_cerr(cerr, errors_from_opencascade);
if( pcb.ReadFile( m_params.m_filename ) )
{
@ -379,9 +383,10 @@ int PANEL_KICAD2STEP::RunConverter()
try
{
m_tcMessages->AppendText( "Build STEP data\n" );
ReportMessage( "Build STEP data\n" );
pcb.ComposePCB( m_params.m_includeVirtual );
m_tcMessages->AppendText( "Start WriteSTEP\n" );
ReportMessage( "Write STEP file\n" );
#ifdef SUPPORTS_IGES
if( m_fmtIGES )
@ -392,30 +397,57 @@ int PANEL_KICAD2STEP::RunConverter()
if( !res )
{
wxMessageBox( "Error WriteSTEP" );
wxMessageBox( "Error Write STEP file" );
return -1;
}
m_tcMessages->AppendText( wxString::Format( "Step file %s created\n", outfile ) );
}
catch( const Standard_Failure& e )
{
e.Print( std::cerr );
wxMessageBox( "Error Read" );
wxString err = e.GetMessageString();
//e.Print( std::cerr );
wxMessageBox( err, "Export Error" );
ReportMessage( wxString::Format( "\nExport Error: %s\n", err ) );
ReportMessage( "\n*** Abort export ***\n" );
return -1;
}
catch( ... )
{
wxMessageBox( "(no exception information)", "Unknown error" );
ReportMessage( "\nUnknown error\n*** Abort export ***\n" );
return -1;
}
}
wxString msg;
msg << msgs_from_opencascade.str();
m_tcMessages->AppendText( msg );
wxString msgs, errs;
msgs << msgs_from_opencascade.str();
ReportMessage( msgs );
wxMessageBox( "End kicad2step" );
ReportMessage( wxString::Format( "\nStep file %s created\n\n", outfile ) );
errs << errors_from_opencascade.str();
ReportMessage( errs );
// Check the output log for an indication of success
bool success = msgs.Contains( "Done" );
wxString msg;
if( !errs.IsEmpty() ) // Any troubles?
{
if( !success )
msg = "Unable to create STEP file.\n"
"Check that the board has a valid outline and models.";
else
{
msg = "STEP file has been created, but there are warnings.";
}
}
else // No error messages: the file is expected OK
{
msg.Printf( "STEP file:\n%s\nhas been created successfully.", outfile );
}
ReportMessage( msg );
return 0;
}
@ -428,5 +460,5 @@ wxString KICAD2MCAD_PRMS::getOutputExt() const
return wxString( "igs" );
else
#endif
return wxString( "stp" );
return wxString( "step" );
}

View File

@ -17,7 +17,7 @@ KICAD2STEP_FRAME_BASE::KICAD2STEP_FRAME_BASE( wxWindow* parent, wxWindowID id, c
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_panelKicad2Step = new PANEL_KICAD2STEP( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
bSizerMain->Add( m_panelKicad2Step, 1, wxEXPAND | wxALL, 5 );
bSizerMain->Add( m_panelKicad2Step, 1, wxEXPAND, 5 );
this->SetSizer( bSizerMain );

View File

@ -109,7 +109,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>

View File

@ -27,21 +27,19 @@
///////////////////////////////////////////////////////////////////////////////
/// Class KICAD2STEP_FRAME_BASE
///////////////////////////////////////////////////////////////////////////////
class KICAD2STEP_FRAME_BASE : public wxFrame
class KICAD2STEP_FRAME_BASE : public wxFrame
{
private:
protected:
public:
PANEL_KICAD2STEP* m_panelKicad2Step;
KICAD2STEP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY,
const wxString& title = _("Kicad2step Converter"), const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
KICAD2STEP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Kicad2step Converter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
~KICAD2STEP_FRAME_BASE();
};
#endif //__KICAD2STEP_FRAME_BASE_H__

View File

@ -396,7 +396,7 @@ wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName )
if( !( m_errflags & ERRFLG_ENVPATH ) )
{
m_errflags |= ERRFLG_ENVPATH;
wxString errmsg = "[3D File Resolver] No such path; ensure the environment var is defined\n";
wxString errmsg = "[3D File Resolver] file not found:\n";
errmsg << tname << "\n";
ReportMessage( errmsg );
}

View File

@ -147,13 +147,17 @@ std::string KICADCURVE::Describe() const
case CURVE_LINE:
desc << "line start: " << m_start << " end: " << m_end;
break;
case CURVE_ARC:
desc << "arc center: " << m_start << " radius: " << m_radius
<< " angle: " << 180.0 * m_angle / M_PI;
<< " angle: " << 180.0 * m_angle / M_PI
<< " arc start: " << m_end << " arc end: " << m_ep;
break;
case CURVE_CIRCLE:
desc << "circle center: " << m_start << " radius: " << m_radius;
break;
default:
desc << "<invalid curve type>";
break;

View File

@ -86,19 +86,18 @@ static wxString GetKicadConfigPath()
}
KICADPCB::KICADPCB( wxTextCtrl* aMessageWindow )
KICADPCB::KICADPCB()
{
wxFileName cfgdir( GetKicadConfigPath(), "" );
cfgdir.AppendDir( "3d" );
m_resolver.Set3DConfigDir( cfgdir.GetPath() );
m_thickness = 1.6;
m_pcb = NULL;
m_pcb_model = nullptr;
m_minDistance = MIN_DISTANCE;
m_useGridOrigin = false;
m_useDrillOrigin = false;
m_hasGridOrigin = false;
m_hasDrillOrigin = false;
m_messageWindow = aMessageWindow;
}
@ -110,19 +109,12 @@ KICADPCB::~KICADPCB()
for( auto i : m_curves )
delete i;
if( m_pcb )
delete m_pcb;
delete m_pcb_model;
return;
}
void KICADPCB::ReportMessage( const wxString& aMessage )
{
m_messageWindow->AppendText( aMessage ); wxSafeYield();
}
bool KICADPCB::ReadFile( const wxString& aFileName )
{
wxFileName fname( aFileName );
@ -175,9 +167,9 @@ bool KICADPCB::ReadFile( const wxString& aFileName )
bool KICADPCB::WriteSTEP( const wxString& aFileName )
{
if( m_pcb )
if( m_pcb_model )
{
return m_pcb->WriteSTEP( aFileName );
return m_pcb_model->WriteSTEP( aFileName );
}
return false;
@ -187,9 +179,9 @@ bool KICADPCB::WriteSTEP( const wxString& aFileName )
#ifdef SUPPORTS_IGES
bool KICADPCB::WriteIGES( const wxString& aFileName )
{
if( m_pcb )
if( m_pcb_model )
{
return m_pcb->WriteIGES( aFileName );
return m_pcb_model->WriteIGES( aFileName );
}
return false;
@ -406,12 +398,12 @@ bool KICADPCB::parseCurve( SEXPR::SEXPR* data, CURVE_TYPE aCurveType )
bool KICADPCB::ComposePCB( bool aComposeVirtual )
{
if( m_pcb )
if( m_pcb_model )
return true;
if( m_modules.empty() && m_curves.empty() )
{
ReportMessage( "Error: no PCB data to render\n" );
ReportMessage( "Error: no PCB data (no footprint, no outline) to render\n" );
return false;
}
@ -432,9 +424,9 @@ bool KICADPCB::ComposePCB( bool aComposeVirtual )
origin = m_origin;
}
m_pcb = new PCBMODEL();
m_pcb->SetPCBThickness( m_thickness );
m_pcb->SetMinDistance( m_minDistance );
m_pcb_model = new PCBMODEL();
m_pcb_model->SetPCBThickness( m_thickness );
m_pcb_model->SetMinDistance( m_minDistance );
for( auto i : m_curves )
{
@ -451,17 +443,19 @@ bool KICADPCB::ComposePCB( bool aComposeVirtual )
if( CURVE_ARC == lcurve.m_form )
lcurve.m_angle = -lcurve.m_angle;
m_pcb->AddOutlineSegment( &lcurve );
m_pcb_model->AddOutlineSegment( &lcurve );
}
for( auto i : m_modules )
i->ComposePCB( m_pcb, &m_resolver, origin, aComposeVirtual );
i->ComposePCB( m_pcb_model, &m_resolver, origin, aComposeVirtual );
if( !m_pcb->CreatePCB() )
ReportMessage( "Create PCB solid model\n" );
if( !m_pcb_model->CreatePCB() )
{
ReportMessage( "could not create PCB solid model\n" );
delete m_pcb;
m_pcb = NULL;
delete m_pcb_model;
m_pcb_model = NULL;
return false;
}

View File

@ -55,7 +55,7 @@ class KICADPCB
private:
S3D_RESOLVER m_resolver;
wxString m_filename;
PCBMODEL* m_pcb;
PCBMODEL* m_pcb_model;
DOUBLET m_origin;
DOUBLET m_gridOrigin;
DOUBLET m_drillOrigin;
@ -73,7 +73,6 @@ private:
double m_thickness;
std::vector< KICADMODULE* > m_modules;
std::vector< KICADCURVE* > m_curves;
wxTextCtrl* m_messageWindow; // to print messages
bool parsePCB( SEXPR::SEXPR* data );
bool parseGeneral( SEXPR::SEXPR* data );
@ -83,12 +82,9 @@ private:
bool parseCurve( SEXPR::SEXPR* data, CURVE_TYPE aCurveType );
public:
KICADPCB( wxTextCtrl* aMessageWindow );
KICADPCB();
virtual ~KICADPCB();
// print aMessage to to called window
void ReportMessage( const wxString& aMessage );
int GetLayerId( std::string& aLayerName );
void SetOrigin( double aXOrigin, double aYOrigin )

View File

@ -165,9 +165,9 @@ FormatType fileType( const char* aFileName )
if( !lfile.FileExists() )
{
std::ostringstream ostr;
#ifdef __WXDEBUG__
#ifdef DEBUG
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
#endif /* DEBUG */
ostr << " * no such file: '" << aFileName << "'\n";
wxLogMessage( "%s", ostr.str().c_str() );
@ -258,9 +258,9 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
if( distance < m_minDistance2 )
{
std::ostringstream ostr;
#ifdef __WXDEBUG__
#ifdef DEBUG
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
#endif /* DEBUG */
ostr << " * rejected a zero-length " << aCurve->Describe() << "\n";
wxLogMessage( "%s", ostr.str().c_str() );
return false;
@ -277,9 +277,9 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
if( rad < m_minDistance2 )
{
std::ostringstream ostr;
#ifdef __WXDEBUG__
#ifdef DEBUG
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
#endif /* DEBUG */
ostr << " * rejected a zero-radius " << aCurve->Describe() << "\n";
wxLogMessage( "%s", ostr.str().c_str() );
return false;
@ -317,9 +317,9 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
if( rad < m_minDistance2 )
{
std::ostringstream ostr;
#ifdef __WXDEBUG__
#ifdef DEBUG
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
#endif /* DEBUG */
ostr << " * rejected an arc with equivalent end points, "
<< aCurve->Describe() << "\n";
wxLogMessage( "%s", ostr.str().c_str() );
@ -423,9 +423,9 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
do
{
std::ostringstream ostr;
#ifdef __WXDEBUG__
#ifdef DEBUG
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
#endif /* DEBUG */
ostr << " * unsupported curve type: '" << aCurve->m_form << "'\n";
wxLogMessage( "%s", ostr.str().c_str() );
} while( 0 );
@ -659,11 +659,13 @@ bool PCBMODEL::CreatePCB()
m_hasPCB = true; // whether or not operations fail we note that CreatePCB has been invoked
TopoDS_Shape board;
OUTLINE oln; // loop to assemble (represents PCB outline and cutouts)
OUTLINE oln; // loop to assemble (represents PCB outline and cutouts)
oln.SetMinSqDistance( m_minDistance2 );
oln.AddSegment( *m_mincurve );
m_curves.erase( m_mincurve );
ReportMessage( wxString::Format( "Build board outline (%d items)\n", (int)m_curves.size() ) );
while( !m_curves.empty() )
{
if( oln.IsClosed() )
@ -756,10 +758,6 @@ bool PCBMODEL::CreatePCB()
}
else
{
std::ostringstream ostr;
#ifdef __WXDEBUG__
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
ReportMessage( "could not create board cutout\n" );
}
}
@ -769,7 +767,33 @@ bool PCBMODEL::CreatePCB()
for( const auto& i : m_cutouts )
board = BRepAlgoAPI_Cut( board, i );
if( m_cutouts.size() )
ReportMessage( wxString::Format( "Build board cutout (%d holes)\n", (int)m_cutouts.size() ) );
// Substract holes (cutouts) can be time consuming, so display activity
// state to be sure there is no hang:
int char_count = 0;
int cur_count = 0;
int cntmax = m_cutouts.size();
for( auto hole : m_cutouts )
{
board = BRepAlgoAPI_Cut( board, hole );
cur_count++;
char_count++;
if( char_count < 80 )
ReportMessage( "." );
else
{
char_count = 0;
ReportMessage( wxString::Format( ". %d/%d\n", cur_count, cntmax ) );
}
}
// push the board to the data structure
ReportMessage( "\nGenerate board full shape\n" );
m_pcb_label = m_assy->AddComponent( m_assy_label, board );
if( m_pcb_label.IsNull() )
@ -1172,9 +1196,9 @@ TDF_Label PCBMODEL::transferModel( Handle( TDocStd_Document )& source,
scaled_shape = brep.Shape();
} else {
std::ostringstream ostr;
#ifdef __WXDEBUG__
#ifdef DEBUG
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
#endif /* __WXDEBUG */
#endif /* DEBUG */
ostr << " * failed to scale model\n";
wxLogMessage( "%s", ostr.str().c_str() );
scaled_shape = shape;
@ -1385,15 +1409,15 @@ bool OUTLINE::MakeShape( TopoDS_Shape& aShape, double aThickness )
}
catch( const Standard_Failure& e )
{
ReportMessage( wxString::Format( "Exception caught: %s", e.GetMessageString() ) );
ReportMessage( wxString::Format( "Exception caught: %s\n", e.GetMessageString() ) );
success = false;
}
if( !success )
{
ReportMessage( wxString::Format( "failed to add an edge: %d\n",
"last valid outline point: %f %f\n",
i.Describe(), lastPoint.x, lastPoint.y ) );
ReportMessage( wxString::Format(
"failed to add an edge:\n%s\nlast valid outline point: %f %f\n",
i.Describe().c_str(), lastPoint.x, lastPoint.y ) );
return false;
}
}
@ -1445,10 +1469,8 @@ bool OUTLINE::addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBL
break;
default:
{
ReportMessage( wxString::Format( "unsupported curve type: %d\n", aCurve.m_form ) );
return false;
}
ReportMessage( wxString::Format( "unsupported curve type: %d\n", aCurve.m_form ) );
return false;
}
if( edge.IsNull() )