Use wildcard routine for extension matching

Move STEP export dialog wildcard to extension matching
This commit is contained in:
Seth Hillbrand 2021-08-20 14:07:00 -07:00
parent 44ea3a75f2
commit db5ce824af
6 changed files with 38 additions and 25 deletions

View File

@ -141,18 +141,18 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
filetypes << wxT("|");
/* Special gerber filetypes */
filetypes += _( "Top layer" ) + wxT( " (*.GTL)|*.GTL;*.gtl|" );
filetypes += _( "Bottom layer" ) + wxT( " (*.GBL)|*.GBL;*.gbl|" );
filetypes += _( "Bottom solder resist" ) + wxT( " (*.GBS)|*.GBS;*.gbs|" );
filetypes += _( "Top solder resist" ) + wxT( " (*.GTS)|*.GTS;*.gts|" );
filetypes += _( "Bottom overlay" ) + wxT( " (*.GBO)|*.GBO;*.gbo|" );
filetypes += _( "Top overlay" ) + wxT( " (*.GTO)|*.GTO;*.gto|" );
filetypes += _( "Bottom paste" ) + wxT( " (*.GBP)|*.GBP;*.gbp|" );
filetypes += _( "Top paste" ) + wxT( " (*.GTP)|*.GTP;*.gtp|" );
filetypes += _( "Keep-out layer" ) + wxT( " (*.GKO)|*.GKO;*.gko|" );
filetypes += _( "Mechanical layers" ) + wxT( " (*.GMx)|*.GM1;*.gm1;*.GM2;*.gm2;*.GM3;*.gm3|" );
filetypes += _( "Top Pad Master" ) + wxT( " (*.GPT)|*.GPT;*.gpt|" );
filetypes += _( "Bottom Pad Master" ) + wxT( " (*.GPB)|*.GPB;*.gpb|" );
filetypes += _( "Top layer" ) + AddFileExtListToFilter( { "GTL" } );
filetypes += _( "Bottom layer" ) + AddFileExtListToFilter( { "GBL" } );
filetypes += _( "Bottom solder resist" ) + AddFileExtListToFilter( { "GBS" } );
filetypes += _( "Top solder resist" ) + AddFileExtListToFilter( { "GTS" } );
filetypes += _( "Bottom overlay" ) + AddFileExtListToFilter( { "GBO" } );
filetypes += _( "Top overlay" ) + AddFileExtListToFilter( { "GTO" } );
filetypes += _( "Bottom paste" ) + AddFileExtListToFilter( { "GBP" } );
filetypes += _( "Top paste" ) + AddFileExtListToFilter( { "GTP" } );
filetypes += _( "Keep-out layer" ) + AddFileExtListToFilter( { "GKO" } );
filetypes += _( "Mechanical layers" ) + AddFileExtListToFilter( { "GM1", "GM2", "GM3", "GM4", "GM5", "GM6", "GM7", "GM8", "GM9" } );
filetypes += _( "Top Pad Master" ) + AddFileExtListToFilter( { "GPT" } );
filetypes += _( "Bottom Pad Master" ) + AddFileExtListToFilter( { "GPB" } );
// All filetypes
filetypes += AllFilesWildcard();

View File

@ -25,6 +25,7 @@
#include <wx/choicdlg.h>
#include <wx/stdpaths.h>
#include <wx/process.h>
#include <wx/string.h>
#include <pgm_base.h>
#include <board.h>
@ -39,6 +40,7 @@
#include <project/project_file.h> // LAST_PATH_TYPE
#include <reporter.h>
#include <widgets/text_ctrl_eval.h>
#include <wildcards_and_files_ext.h>
#include <filename_resolver.h>
class DIALOG_EXPORT_STEP: public DIALOG_EXPORT_STEP_BASE
@ -116,7 +118,6 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString&
m_sdbSizerOK->SetLabel( _( "Export" ) );
m_sdbSizer->Layout();
// Build default output file name
wxString path = m_parent->GetLastPath( LAST_PATH_STEP );
@ -127,7 +128,19 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString&
path = brdFile.GetFullPath();
}
m_filePickerSTEP->SetPath( path );
// Reset this picker bc wxFormBuilder doesn't allow untranslated strings
wxSizerItem* sizer_item = bSizerTop->GetItem( 1UL );
wxWindow* widget = sizer_item->GetWindow();
bSizerTop->Hide( widget );
widget->Destroy();
m_filePickerSTEP = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString,
_( "Select a STEP export filename" ), _( "STEP files" ) + AddFileExtListToFilter( { "STEP", "STP" } ), wxDefaultPosition,
wxSize( -1, -1 ), wxFLP_SAVE | wxFLP_USE_TEXTCTRL );
bSizerTop->Add( m_filePickerSTEP, 1, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
Layout();
bSizerSTEPFile->Fit( this );
SetFocus();

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020)
// C++ code generated with wxFormBuilder (version 3.9.0 Apr 22 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -15,17 +15,15 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerSTEPFile;
bSizerSTEPFile = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerTop;
bSizerTop = new wxBoxSizer( wxHORIZONTAL );
m_txtBrdFile = new wxStaticText( this, wxID_ANY, _("File:"), wxDefaultPosition, wxDefaultSize, 0 );
m_txtBrdFile->Wrap( -1 );
bSizerTop->Add( m_txtBrdFile, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT, 5 );
m_filePickerSTEP = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("Select a STEP export filename"), _("STEP files (*.stp;*.step)|*.stp;*.step"), wxDefaultPosition, wxSize( -1,-1 ), wxFLP_SAVE|wxFLP_USE_TEXTCTRL );
m_filePickerSTEP = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("temp"), _("temp"), wxDefaultPosition, wxSize( -1,-1 ), wxFLP_SAVE|wxFLP_USE_TEXTCTRL );
bSizerTop->Add( m_filePickerSTEP, 1, wxTOP|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );

View File

@ -59,7 +59,7 @@
<property name="minimum_size">-1,-1</property>
<property name="name">bSizerSTEPFile</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxALL</property>
@ -68,7 +68,7 @@
<property name="minimum_size"></property>
<property name="name">bSizerTop</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT</property>
@ -165,7 +165,7 @@
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="message">Select a STEP export filename</property>
<property name="message">temp</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">-1,-1</property>
@ -189,7 +189,7 @@
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="wildcard">STEP files (*.stp;*.step)|*.stp;*.step</property>
<property name="wildcard">temp</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020)
// C++ code generated with wxFormBuilder (version 3.9.0 Apr 22 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -41,6 +41,8 @@ class DIALOG_EXPORT_STEP_BASE : public DIALOG_SHIM
private:
protected:
wxBoxSizer* bSizerSTEPFile;
wxBoxSizer* bSizerTop;
wxStaticText* m_txtBrdFile;
wxFilePickerCtrl* m_filePickerSTEP;
wxRadioButton* m_rbDrillAndPlotOrigin;
@ -63,7 +65,7 @@ class DIALOG_EXPORT_STEP_BASE : public DIALOG_SHIM
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
// Virtual event handlers, override them in your derived class
virtual void onUpdateUnits( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void onUpdateXPos( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void onUpdateYPos( wxUpdateUIEvent& event ) { event.Skip(); }

View File

@ -425,7 +425,7 @@ int BOARD_EDITOR_CONTROL::ExportNetlist( const TOOL_EVENT& aEvent )
fn.SetExt( "pcb_net" );
wxFileDialog dlg( m_frame, _( "Export Board Netlist" ), fn.GetPath(), fn.GetFullName(),
_( "KiCad board netlist files" ) + wxT( " (*.pcb_net)|*.pcb_net" ),
_( "KiCad board netlist files" ) + AddFileExtListToFilter( { "pcb_net" } ),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
dlg.SetExtraControlCreator( &NETLIST_OPTIONS_HELPER::Create );