Fix various STEP export dialog issues.
The file filter wild card was defined incorrectly causing the file picker to not display *.stp and *.step file extensions. Change the wildcard per wxFileDialog documentation. Prevent the file extension from being forced to .stp even when the user defined a different extension in the file picker. Override TransferDataFromWindow to test for file existence and warn user only once if a file overwrite can occur. Minor STEP export dialog string and layout improvements. Make kicad2step honor user's file extension rather than always setting it to .stp. Fixes lp:1709636 https://bugs.launchpad.net/kicad/+bug/1709636
This commit is contained in:
parent
8a1a3ed36c
commit
15478bda41
|
@ -6,6 +6,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Cirilo Bernardo
|
||||
* Copyright (C) 2016-2017 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
|
||||
|
@ -30,6 +31,8 @@
|
|||
|
||||
#include "wxPcbStruct.h"
|
||||
#include "kiface_i.h"
|
||||
#include "confirm.h"
|
||||
|
||||
#include "pcbnew.h"
|
||||
#include "class_board.h"
|
||||
#include "dialog_export_step_base.h"
|
||||
|
@ -176,9 +179,32 @@ public:
|
|||
event.Skip();
|
||||
}
|
||||
|
||||
bool TransferDataFromWindow() override;
|
||||
};
|
||||
|
||||
|
||||
bool DIALOG_EXPORT_STEP::TransferDataFromWindow()
|
||||
{
|
||||
if( !wxDialog::TransferDataFromWindow() )
|
||||
return false;
|
||||
|
||||
wxFileName fn = m_filePickerSTEP->GetFileName();
|
||||
|
||||
if( fn.FileExists() )
|
||||
{
|
||||
wxString msg( _( "File: " ) );
|
||||
msg.append( fn.GetFullPath() );
|
||||
msg.append( "\n" );
|
||||
msg.append( _( "already exists. Do you want overwrite this file?" ) );
|
||||
|
||||
if( wxMessageBox( msg, _( "STEP Export" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event )
|
||||
{
|
||||
|
||||
|
@ -189,8 +215,8 @@ void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event )
|
|||
{
|
||||
if( !doAutoSave() )
|
||||
{
|
||||
wxMessageBox( _( "STEP export failed; please save the PCB and try again" ),
|
||||
_( "STEP Export" ) );
|
||||
DisplayErrorMessage( this,
|
||||
_( "STEP export failed! Please save the PCB and try again" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -211,45 +237,13 @@ void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event )
|
|||
|
||||
DIALOG_EXPORT_STEP dlg( this );
|
||||
dlg.FilePicker()->SetPath( brdFile.GetFullPath() );
|
||||
bool fileOverwrite = false;
|
||||
wxString outputFile;
|
||||
|
||||
while( !fileOverwrite )
|
||||
{
|
||||
if ( dlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
if ( dlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
brdFile = dlg.FilePicker()->GetPath();
|
||||
brdFile.SetExt( "stp" );
|
||||
outputFile = brdFile.GetFullPath();
|
||||
|
||||
if( wxFile::Exists( outputFile ) )
|
||||
{
|
||||
wxString msg( _( "File: " ) );
|
||||
msg.append( outputFile );
|
||||
msg.append( "\n" );
|
||||
msg.append( _( "File exists, overwrite?" ) );
|
||||
int resp = wxMessageBox( msg, _( "STEP Export" ), wxYES_NO | wxCANCEL, this );
|
||||
|
||||
switch( resp )
|
||||
{
|
||||
case wxCANCEL:
|
||||
return;
|
||||
|
||||
case wxYES:
|
||||
fileOverwrite = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileOverwrite = true;
|
||||
}
|
||||
}
|
||||
wxString outputFile = dlg.FilePicker()->GetPath();
|
||||
|
||||
brdFile.SetExt( brdExt );
|
||||
outputFile.Prepend( "\"" );
|
||||
outputFile.Append( "\"" );
|
||||
bool aUseDrillOrg = dlg.GetDrillOrgOption();
|
||||
|
@ -307,10 +301,7 @@ void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event )
|
|||
|
||||
if( result )
|
||||
{
|
||||
wxMessageBox(
|
||||
_( "Unable to create STEP file; check that the board has a valid outline and models." ),
|
||||
_( "STEP Export" ), wxOK );
|
||||
DisplayErrorMessage( this, _( "Unable to create STEP file. Check that the board has a "
|
||||
"valid outline and models." ), cmdK2S );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Sep 8 2016)
|
||||
// C++ code generated with wxFormBuilder (version Jun 5 2014)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -16,11 +16,11 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
|
|||
wxBoxSizer* bSizerSTEPFile;
|
||||
bSizerSTEPFile = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_txtBrdFile = new wxStaticText( this, wxID_ANY, _("STEP File name:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_txtBrdFile = new wxStaticText( this, wxID_ANY, _("File name:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_txtBrdFile->Wrap( -1 );
|
||||
bSizerSTEPFile->Add( m_txtBrdFile, 0, wxALL, 5 );
|
||||
|
||||
m_filePickerSTEP = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("Select a STEP export filename"), wxT("*.stp,*.step"), wxDefaultPosition, wxSize( 450,-1 ), wxFLP_OVERWRITE_PROMPT|wxFLP_SAVE|wxFLP_USE_TEXTCTRL );
|
||||
m_filePickerSTEP = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("Select a STEP export filename"), wxT("STEP files (*.stp;*.step)|*.stp;*.step"), wxDefaultPosition, wxSize( -1,-1 ), wxFLP_SAVE|wxFLP_USE_TEXTCTRL );
|
||||
bSizerSTEPFile->Add( m_filePickerSTEP, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
|
@ -32,9 +32,9 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
|
|||
wxBoxSizer* bSizer7;
|
||||
bSizer7 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText6 = new wxStaticText( this, wxID_ANY, _("STEP coordinates origin options:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText6 = new wxStaticText( this, wxID_ANY, _("Coordinate origin options:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText6->Wrap( -1 );
|
||||
m_staticText6->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
m_staticText6->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
|
||||
|
||||
bSizer7->Add( m_staticText6, 0, wxALL, 5 );
|
||||
|
||||
|
@ -78,7 +78,7 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
|
|||
|
||||
m_staticText2 = new wxStaticText( this, wxID_ANY, _("User defined origin:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText2->Wrap( -1 );
|
||||
m_staticText2->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
m_staticText2->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
|
||||
|
||||
bSizer3->Add( m_staticText2, 0, wxALL, 5 );
|
||||
|
||||
|
@ -103,37 +103,23 @@ 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 = 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_STEP_Xorg = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
#ifdef __WXGTK__
|
||||
if ( !m_STEP_Xorg->HasFlag( wxTE_MULTILINE ) )
|
||||
{
|
||||
m_STEP_Xorg->SetMaxLength( 8 );
|
||||
}
|
||||
#else
|
||||
m_STEP_Xorg->SetMaxLength( 8 );
|
||||
#endif
|
||||
fgSizer1->Add( m_STEP_Xorg, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
fgSizer1->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_staticText4 = new wxStaticText( this, wxID_ANY, _("Y Position:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
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_STEP_Yorg = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
#ifdef __WXGTK__
|
||||
if ( !m_STEP_Yorg->HasFlag( wxTE_MULTILINE ) )
|
||||
{
|
||||
m_STEP_Yorg->SetMaxLength( 8 );
|
||||
}
|
||||
#else
|
||||
m_STEP_Yorg->SetMaxLength( 8 );
|
||||
#endif
|
||||
fgSizer1->Add( m_STEP_Yorg, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
|
@ -147,7 +133,7 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
|
|||
|
||||
m_staticText7 = new wxStaticText( this, wxID_ANY, _("Other options:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText7->Wrap( -1 );
|
||||
m_staticText7->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
m_staticText7->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
|
||||
|
||||
bSizer8->Add( m_staticText7, 0, wxALL, 5 );
|
||||
|
||||
|
@ -159,7 +145,7 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
|
|||
|
||||
fgSizer3->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_cbRemoveVirtual = new wxCheckBox( this, wxID_ANY, _("Ignore Virtual Components"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_cbRemoveVirtual = new wxCheckBox( this, wxID_ANY, _("Ignore virtual components"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer3->Add( m_cbRemoveVirtual, 0, wxALL, 5 );
|
||||
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">STEP File name:</property>
|
||||
<property name="label">File name:</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -225,8 +225,8 @@
|
|||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size">450,-1</property>
|
||||
<property name="style">wxFLP_OVERWRITE_PROMPT|wxFLP_SAVE|wxFLP_USE_TEXTCTRL</property>
|
||||
<property name="size">-1,-1</property>
|
||||
<property name="style">wxFLP_SAVE|wxFLP_USE_TEXTCTRL</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
|
@ -235,7 +235,7 @@
|
|||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="value"></property>
|
||||
<property name="wildcard">*.stp,*.step</property>
|
||||
<property name="wildcard">STEP files (*.stp;*.step)|*.stp;*.step</property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
|
@ -396,7 +396,7 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">STEP coordinates origin options:</property>
|
||||
<property name="label">Coordinate origin options:</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -1092,7 +1092,7 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">X Position:</property>
|
||||
<property name="label">X position:</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -1276,7 +1276,7 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Y Position:</property>
|
||||
<property name="label">Y position:</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -1573,7 +1573,7 @@
|
|||
<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="label">Ignore virtual components</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Sep 8 2016)
|
||||
// C++ code generated with wxFormBuilder (version Jun 5 2014)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of kicad2mcad
|
||||
*
|
||||
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2016-2017 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
|
||||
|
@ -219,12 +220,16 @@ int KICAD2MCAD::OnRun()
|
|||
else
|
||||
tfname.Assign( m_outputFile );
|
||||
|
||||
// Set the file extension if the user's requested file name does not have an extension.
|
||||
if( !tfname.HasExt() )
|
||||
{
|
||||
#ifdef SUPPORTS_IGES
|
||||
if( m_fmtIGES )
|
||||
tfname.SetExt( "igs" );
|
||||
else
|
||||
if( m_fmtIGES )
|
||||
tfname.SetExt( "igs" );
|
||||
else
|
||||
#endif
|
||||
tfname.SetExt( "stp" );
|
||||
tfname.SetExt( "stp" );
|
||||
}
|
||||
|
||||
wxString outfile = tfname.GetFullPath();
|
||||
|
||||
|
|
Loading…
Reference in New Issue