2016-09-19 07:40:36 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Cirilo Bernardo
|
2019-01-29 06:15:38 +00:00
|
|
|
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-09-19 07:40:36 +00:00
|
|
|
*
|
|
|
|
* 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/choicdlg.h>
|
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
|
2018-01-29 20:58:58 +00:00
|
|
|
#include "pcb_edit_frame.h"
|
2016-09-19 07:40:36 +00:00
|
|
|
#include "kiface_i.h"
|
2017-08-09 17:17:26 +00:00
|
|
|
#include "confirm.h"
|
2018-03-19 14:36:21 +00:00
|
|
|
#include "reporter.h"
|
2016-09-19 07:40:36 +00:00
|
|
|
#include "class_board.h"
|
|
|
|
#include "dialog_export_step_base.h"
|
2017-11-23 13:05:26 +00:00
|
|
|
#include <widgets/text_ctrl_eval.h>
|
2018-03-19 14:36:21 +00:00
|
|
|
#include <wx_html_report_panel.h>
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
#define OPTKEY_STEP_ORIGIN_OPT "STEP_Origin_Opt"
|
2016-09-21 23:03:00 +00:00
|
|
|
#define OPTKEY_STEP_UORG_UNITS "STEP_UserOriginUnits"
|
|
|
|
#define OPTKEY_STEP_UORG_X "STEP_UserOriginX"
|
|
|
|
#define OPTKEY_STEP_UORG_Y "STEP_UserOriginY"
|
|
|
|
#define OPTKEY_STEP_NOVIRT "STEP_NoVirtual"
|
2016-09-19 07:40:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DIALOG_EXPORT_STEP: public DIALOG_EXPORT_STEP_BASE
|
|
|
|
{
|
2017-08-10 12:25:31 +00:00
|
|
|
public:
|
|
|
|
enum STEP_ORG_OPT
|
|
|
|
{
|
|
|
|
STEP_ORG_0, // absolute coordinates
|
|
|
|
STEP_ORG_PLOT_AXIS, // origin is plot/drill axis origin
|
|
|
|
STEP_ORG_GRID_AXIS, // origin is grid origin
|
|
|
|
STEP_ORG_BOARD_CENTER, // origin is board center
|
|
|
|
STEP_ORG_USER, // origin is entered by user
|
|
|
|
};
|
|
|
|
|
2016-09-19 07:40:36 +00:00
|
|
|
private:
|
|
|
|
PCB_EDIT_FRAME* m_parent;
|
|
|
|
wxConfigBase* m_config;
|
2017-08-10 12:25:31 +00:00
|
|
|
// The last preference for STEP Origin:
|
|
|
|
STEP_ORG_OPT m_STEP_org_opt;
|
2016-09-19 08:07:39 +00:00
|
|
|
bool m_noVirtual; // remember last preference for No Virtual Component
|
2016-09-19 07:40:36 +00:00
|
|
|
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
|
2018-03-19 14:36:21 +00:00
|
|
|
wxString m_boardPath; // path to the exported board file
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2018-02-18 00:02:45 +00:00
|
|
|
protected:
|
|
|
|
void onUpdateUnits( wxUpdateUIEvent& aEvent ) override;
|
|
|
|
void onUpdateXPos( wxUpdateUIEvent& aEvent ) override;
|
|
|
|
void onUpdateYPos( wxUpdateUIEvent& aEvent ) override;
|
2018-03-19 14:36:21 +00:00
|
|
|
void onExportButton( wxCommandEvent& aEvent ) override;
|
2018-02-18 00:02:45 +00:00
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
int GetOrgUnitsChoice() const
|
2016-09-19 07:40:36 +00:00
|
|
|
{
|
|
|
|
return m_STEP_OrgUnitChoice->GetSelection();
|
|
|
|
}
|
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
double GetXOrg() const
|
2016-09-19 07:40:36 +00:00
|
|
|
{
|
|
|
|
return DoubleValueFromString( UNSCALED_UNITS, m_STEP_Xorg->GetValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
double GetYOrg()
|
|
|
|
{
|
|
|
|
return DoubleValueFromString( UNSCALED_UNITS, m_STEP_Yorg->GetValue() );
|
|
|
|
}
|
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
STEP_ORG_OPT GetOriginOption();
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
bool GetNoVirtOption()
|
2016-09-19 07:40:36 +00:00
|
|
|
{
|
2017-08-10 12:25:31 +00:00
|
|
|
return m_cbRemoveVirtual->GetValue();
|
2016-09-19 07:40:36 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
public:
|
|
|
|
DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& aBoardPath );
|
|
|
|
|
|
|
|
~DIALOG_EXPORT_STEP()
|
|
|
|
{
|
|
|
|
GetOriginOption(); // Update m_STEP_org_opt member.
|
|
|
|
m_config->Write( OPTKEY_STEP_ORIGIN_OPT, (int)m_STEP_org_opt );
|
|
|
|
m_config->Write( OPTKEY_STEP_NOVIRT, m_cbRemoveVirtual->GetValue() );
|
|
|
|
m_config->Write( OPTKEY_STEP_UORG_UNITS, m_STEP_OrgUnitChoice->GetSelection() );
|
|
|
|
m_config->Write( OPTKEY_STEP_UORG_X, m_STEP_Xorg->GetValue() );
|
|
|
|
m_config->Write( OPTKEY_STEP_UORG_Y, m_STEP_Yorg->GetValue() );
|
|
|
|
}
|
2017-08-10 12:25:31 +00:00
|
|
|
};
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2018-02-18 00:02:45 +00:00
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& aBoardPath ) :
|
|
|
|
DIALOG_EXPORT_STEP_BASE( aParent )
|
2017-08-10 12:25:31 +00:00
|
|
|
{
|
2018-03-19 14:36:21 +00:00
|
|
|
m_parent = aParent;
|
|
|
|
m_boardPath = aBoardPath;
|
2017-08-10 12:25:31 +00:00
|
|
|
m_config = Kiface().KifaceSettings();
|
2018-05-09 11:24:42 +00:00
|
|
|
m_sdbSizerCancel->SetLabel( _( "Close" ) );
|
2018-09-24 18:57:02 +00:00
|
|
|
m_sdbSizerOK->SetLabel( _( "Export" ) );
|
2018-05-09 11:24:42 +00:00
|
|
|
m_sdbSizer->Layout();
|
2018-03-19 14:36:21 +00:00
|
|
|
|
|
|
|
// Build default output file name
|
2019-08-03 03:03:03 +00:00
|
|
|
wxString path = m_parent->GetLastPath( LAST_PATH_STEP );
|
|
|
|
|
|
|
|
if( path.IsEmpty() )
|
|
|
|
{
|
|
|
|
wxFileName brdFile = m_parent->GetBoard()->GetFileName();
|
|
|
|
brdFile.SetExt( "step" );
|
|
|
|
path = brdFile.GetFullPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_filePickerSTEP->SetPath( path );
|
2018-03-19 14:36:21 +00:00
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
SetFocus();
|
|
|
|
|
|
|
|
m_STEP_org_opt = STEP_ORG_0;;
|
|
|
|
int tmp = STEP_ORG_0;
|
|
|
|
|
|
|
|
if( m_config->Read( OPTKEY_STEP_ORIGIN_OPT, &tmp ) )
|
|
|
|
m_STEP_org_opt = (STEP_ORG_OPT) tmp;
|
|
|
|
|
|
|
|
switch( m_STEP_org_opt )
|
2016-09-19 08:07:39 +00:00
|
|
|
{
|
2017-08-10 12:25:31 +00:00
|
|
|
default: break;
|
2018-02-18 00:02:45 +00:00
|
|
|
case STEP_ORG_PLOT_AXIS: m_rbDrillAndPlotOrigin->SetValue( true ); break;
|
|
|
|
case STEP_ORG_GRID_AXIS: m_rbGridOrigin->SetValue( true ); break;
|
|
|
|
case STEP_ORG_USER: m_rbUserDefinedOrigin->SetValue( true ); break;
|
|
|
|
case STEP_ORG_BOARD_CENTER: m_rbBoardCenterOrigin->SetValue( true ); break;
|
2016-09-19 08:07:39 +00:00
|
|
|
}
|
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
m_config->Read( OPTKEY_STEP_UORG_UNITS, &m_OrgUnits, 0 );
|
|
|
|
m_config->Read( OPTKEY_STEP_UORG_X, &m_XOrg, 0.0 );
|
|
|
|
m_config->Read( OPTKEY_STEP_UORG_Y, &m_YOrg, 0.0 );
|
|
|
|
m_config->Read( OPTKEY_STEP_NOVIRT, &m_noVirtual );
|
|
|
|
m_cbRemoveVirtual->SetValue( m_noVirtual );
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
m_STEP_OrgUnitChoice->SetSelection( m_OrgUnits );
|
|
|
|
wxString tmpStr;
|
|
|
|
tmpStr << m_XOrg;
|
|
|
|
m_STEP_Xorg->SetValue( tmpStr );
|
|
|
|
tmpStr = "";
|
|
|
|
tmpStr << m_YOrg;
|
|
|
|
m_STEP_Yorg->SetValue( tmpStr );
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
|
|
|
}
|
2016-09-19 07:40:36 +00:00
|
|
|
|
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
DIALOG_EXPORT_STEP::STEP_ORG_OPT DIALOG_EXPORT_STEP::GetOriginOption()
|
|
|
|
{
|
|
|
|
m_STEP_org_opt = STEP_ORG_0;
|
|
|
|
|
2018-02-18 00:02:45 +00:00
|
|
|
if( m_rbDrillAndPlotOrigin->GetValue() )
|
2017-08-10 12:25:31 +00:00
|
|
|
m_STEP_org_opt = STEP_ORG_PLOT_AXIS;
|
2018-02-18 00:02:45 +00:00
|
|
|
else if( m_rbGridOrigin->GetValue() )
|
2017-08-10 12:25:31 +00:00
|
|
|
m_STEP_org_opt = STEP_ORG_GRID_AXIS;
|
2018-02-18 00:02:45 +00:00
|
|
|
else if( m_rbUserDefinedOrigin->GetValue() )
|
2017-08-10 12:25:31 +00:00
|
|
|
m_STEP_org_opt = STEP_ORG_USER;
|
2018-02-18 00:02:45 +00:00
|
|
|
else if( m_rbBoardCenterOrigin->GetValue() )
|
2017-08-10 12:25:31 +00:00
|
|
|
m_STEP_org_opt = STEP_ORG_BOARD_CENTER;
|
|
|
|
|
|
|
|
return m_STEP_org_opt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-19 07:40:36 +00:00
|
|
|
void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxFileName brdFile = GetBoard()->GetFileName();
|
|
|
|
|
|
|
|
if( GetScreen()->IsModify() || brdFile.GetFullPath().empty() )
|
|
|
|
{
|
2016-09-20 22:55:35 +00:00
|
|
|
if( !doAutoSave() )
|
2016-09-19 07:40:36 +00:00
|
|
|
{
|
2017-08-09 17:17:26 +00:00
|
|
|
DisplayErrorMessage( this,
|
|
|
|
_( "STEP export failed! Please save the PCB and try again" ) );
|
2016-09-20 22:55:35 +00:00
|
|
|
return;
|
2016-09-19 07:40:36 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
// Use auto-saved board for export
|
|
|
|
brdFile.SetName( GetAutoSaveFilePrefix() + brdFile.GetName() );
|
2016-09-19 07:40:36 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
DIALOG_EXPORT_STEP dlg( this, brdFile.GetFullPath() );
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
2016-09-21 23:03:00 +00:00
|
|
|
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
void DIALOG_EXPORT_STEP::onUpdateUnits( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EXPORT_STEP::onUpdateXPos( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
|
|
|
|
}
|
2016-09-19 07:40:36 +00:00
|
|
|
|
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
void DIALOG_EXPORT_STEP::onUpdateYPos( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.Enable( m_rbUserDefinedOrigin->GetValue() );
|
|
|
|
}
|
|
|
|
|
2018-06-18 15:34:43 +00:00
|
|
|
extern bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
|
2018-11-28 12:11:43 +00:00
|
|
|
wxString* aErrorText, unsigned int aTolerance,
|
|
|
|
wxPoint* aErrorLocation = nullptr );
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
|
|
|
|
{
|
2019-08-03 03:03:03 +00:00
|
|
|
m_parent->SetLastPath( LAST_PATH_STEP, m_filePickerSTEP->GetPath() );
|
|
|
|
|
2018-03-19 16:34:11 +00:00
|
|
|
SHAPE_POLY_SET outline;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
// Check if the board outline is continuous
|
2018-06-18 15:34:43 +00:00
|
|
|
if( !BuildBoardPolygonOutlines( m_parent->GetBoard(), outline, &msg, Millimeter2iu( 0.01 ) ) )
|
2018-03-19 16:34:11 +00:00
|
|
|
{
|
|
|
|
DisplayErrorMessage( this, _( "Cannot determine the board outline." ), msg );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
wxFileName fn = m_filePickerSTEP->GetFileName();
|
|
|
|
|
|
|
|
if( fn.FileExists() )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "File '%s' already exists. Do you want overwrite this file?" ),
|
|
|
|
fn.GetFullPath().GetData() );
|
|
|
|
|
|
|
|
if( wxMessageBox( msg, _( "STEP Export" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DIALOG_EXPORT_STEP::STEP_ORG_OPT orgOpt = GetOriginOption();
|
2017-08-10 12:25:31 +00:00
|
|
|
double xOrg = 0.0;
|
|
|
|
double yOrg = 0.0;
|
2016-09-19 07:40:36 +00:00
|
|
|
|
|
|
|
wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() );
|
2018-06-18 16:14:10 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
2018-06-13 02:35:42 +00:00
|
|
|
// On macOS, we have standalone applications inside the main bundle, so we handle that here:
|
2018-06-18 16:14:10 +00:00
|
|
|
if( appK2S.GetPath().find( "/Contents/Applications/pcbnew.app/Contents/MacOS" ) != wxNOT_FOUND )
|
2018-06-13 02:35:42 +00:00
|
|
|
{
|
2018-06-18 16:14:10 +00:00
|
|
|
appK2S.AppendDir( ".." );
|
|
|
|
appK2S.AppendDir( ".." );
|
|
|
|
appK2S.AppendDir( ".." );
|
|
|
|
appK2S.AppendDir( ".." );
|
2018-06-18 18:57:01 +00:00
|
|
|
appK2S.AppendDir( "MacOS" );
|
2018-06-13 02:35:42 +00:00
|
|
|
}
|
2018-06-18 16:14:10 +00:00
|
|
|
#endif
|
|
|
|
|
2016-09-19 07:40:36 +00:00
|
|
|
appK2S.SetName( "kicad2step" );
|
|
|
|
|
2016-09-21 23:03:00 +00:00
|
|
|
wxString cmdK2S = "\"";
|
|
|
|
cmdK2S.Append( appK2S.GetFullPath() );
|
|
|
|
cmdK2S.Append( "\"" );
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
if( GetNoVirtOption() )
|
2016-09-19 08:07:39 +00:00
|
|
|
cmdK2S.Append( " --no-virtual" );
|
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
switch( orgOpt )
|
|
|
|
{
|
|
|
|
case DIALOG_EXPORT_STEP::STEP_ORG_0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIALOG_EXPORT_STEP::STEP_ORG_PLOT_AXIS:
|
|
|
|
cmdK2S.Append( " --drill-origin" );
|
|
|
|
break;
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
case DIALOG_EXPORT_STEP::STEP_ORG_GRID_AXIS:
|
|
|
|
cmdK2S.Append( " --grid-origin" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIALOG_EXPORT_STEP::STEP_ORG_USER:
|
|
|
|
{
|
2018-03-19 14:36:21 +00:00
|
|
|
xOrg = GetXOrg();
|
|
|
|
yOrg = GetYOrg();
|
2017-08-10 12:25:31 +00:00
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
if( GetOrgUnitsChoice() == 1 )
|
2017-08-10 12:25:31 +00:00
|
|
|
{
|
|
|
|
// selected reference unit is in inches, and STEP units are mm
|
|
|
|
xOrg *= 25.4;
|
|
|
|
yOrg *= 25.4;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOCALE_IO dummy;
|
2018-09-22 15:45:32 +00:00
|
|
|
cmdK2S.Append( wxString::Format( " --user-origin=\"%.6f x %.6f\"", xOrg, yOrg ) );
|
2017-08-10 12:25:31 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2017-08-10 12:25:31 +00:00
|
|
|
case DIALOG_EXPORT_STEP::STEP_ORG_BOARD_CENTER:
|
|
|
|
{
|
2018-03-19 14:36:21 +00:00
|
|
|
EDA_RECT bbox = m_parent->GetBoard()->ComputeBoundingBox( true );
|
2017-08-10 12:25:31 +00:00
|
|
|
xOrg = Iu2Millimeter( bbox.GetCenter().x );
|
|
|
|
yOrg = Iu2Millimeter( bbox.GetCenter().y );
|
|
|
|
LOCALE_IO dummy;
|
2018-09-22 15:45:32 +00:00
|
|
|
cmdK2S.Append( wxString::Format( " --user-origin=\"%.6f x %.6f\"", xOrg, yOrg ) );
|
2017-08-10 12:25:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2019-01-29 06:15:38 +00:00
|
|
|
if( m_tolerance->GetSelection() != 1 )
|
|
|
|
{
|
2019-02-04 17:05:49 +00:00
|
|
|
LOCALE_IO dummy;
|
2019-01-30 16:38:34 +00:00
|
|
|
double tolerance = 0.001 * std::pow<double>( 10.0, m_tolerance->GetSelection() - 1 );
|
2019-01-29 06:15:38 +00:00
|
|
|
cmdK2S.Append( wxString::Format( " --min-distance=\"%.4f mm\"", tolerance ) );
|
|
|
|
}
|
|
|
|
|
2016-09-19 07:40:36 +00:00
|
|
|
cmdK2S.Append( " -f -o " );
|
2018-03-19 14:36:21 +00:00
|
|
|
cmdK2S.Append( wxString::Format("\"%s\"", m_filePickerSTEP->GetPath() ) ); // input file path
|
2016-09-19 07:40:36 +00:00
|
|
|
|
|
|
|
cmdK2S.Append( " " );
|
2018-03-19 14:36:21 +00:00
|
|
|
cmdK2S.Append( wxString::Format("\"%s\"", m_boardPath ) ); // output file path
|
2016-09-19 07:40:36 +00:00
|
|
|
|
2016-09-21 23:03:00 +00:00
|
|
|
int result = 0;
|
2018-03-19 14:36:21 +00:00
|
|
|
bool success = false;
|
|
|
|
wxArrayString output, errors;
|
|
|
|
REPORTER& reporter = m_messagesPanel->Reporter();
|
2018-05-21 22:28:26 +00:00
|
|
|
reporter.ReportHead( wxString::Format( _( "Executing '%s'" ), cmdK2S ), REPORTER::RPT_ACTION );
|
2016-09-21 23:03:00 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
wxBusyCursor dummy;
|
2018-03-19 14:36:21 +00:00
|
|
|
result = wxExecute( cmdK2S, output, errors, wxEXEC_SYNC | wxEXEC_HIDE_CONSOLE );
|
|
|
|
}
|
2016-09-21 23:03:00 +00:00
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
// Check the output log for an indication of success,
|
|
|
|
// the value returned by wxExecute is not conclusive
|
|
|
|
for( auto& l : output )
|
2016-09-19 07:40:36 +00:00
|
|
|
{
|
2018-03-19 14:36:21 +00:00
|
|
|
if( l.Contains( "Done" ) )
|
|
|
|
{
|
|
|
|
success = true;
|
|
|
|
break;
|
|
|
|
}
|
2016-09-19 07:40:36 +00:00
|
|
|
}
|
2018-02-18 00:02:45 +00:00
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
for( auto& err : errors )
|
|
|
|
reporter.Report( err, REPORTER::RPT_WARNING );
|
2018-02-18 00:02:45 +00:00
|
|
|
|
2018-03-19 14:36:21 +00:00
|
|
|
if( result ) // Any troubles?
|
|
|
|
{
|
|
|
|
if( !success )
|
|
|
|
{
|
2018-05-21 22:28:26 +00:00
|
|
|
reporter.ReportTail( _( "Unable to create STEP file. Check that the board has a "
|
2018-03-19 14:36:21 +00:00
|
|
|
"valid outline and models." ), REPORTER::RPT_ERROR );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-21 22:28:26 +00:00
|
|
|
reporter.ReportTail( _( "STEP file has been created, but there are warnings." ),
|
2018-03-19 14:36:21 +00:00
|
|
|
REPORTER::RPT_INFO );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-21 22:28:26 +00:00
|
|
|
reporter.ReportTail( _( "STEP file has been created successfully." ), REPORTER::RPT_INFO );
|
2018-03-19 14:36:21 +00:00
|
|
|
}
|
2018-02-18 00:02:45 +00:00
|
|
|
}
|