From ea3101587a452e4436e447812b588e231af5fa6a Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sat, 19 Aug 2023 19:01:05 -0400 Subject: [PATCH] Add gltf export to step dialog --- common/wildcards_and_files_ext.cpp | 4 ++++ include/wildcards_and_files_ext.h | 4 ++++ pcbnew/dialogs/dialog_export_step.cpp | 18 +++++++++++++++--- pcbnew/dialogs/dialog_export_step_base.fbp | 2 +- pcbnew/dialogs/dialog_export_step_base.h | 2 +- .../dialog_export_step_process_base.fbp | 2 +- .../dialogs/dialog_export_step_process_base.h | 2 +- 7 files changed, 27 insertions(+), 7 deletions(-) diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index f6f5aa7763..f23caa9907 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -192,6 +192,10 @@ const std::string CsvFileExtension( "csv" ); const std::string XmlFileExtension( "xml" ); const std::string JsonFileExtension( "json" ); +const std::string StepFileExtension( "step" ); +const std::string StepFileAbrvExtension( "stp" ); +const std::string GltfBinaryFileExtension( "glb" ); + const wxString GerberFileExtensionsRegex( "(gbr|gko|pho|(g[tb][alops])|(gm?\\d\\d*)|(gp[tb]))" ); diff --git a/include/wildcards_and_files_ext.h b/include/wildcards_and_files_ext.h index 7c524cc8d0..8fccfb34c9 100644 --- a/include/wildcards_and_files_ext.h +++ b/include/wildcards_and_files_ext.h @@ -178,6 +178,10 @@ extern const std::string CsvFileExtension; extern const std::string XmlFileExtension; extern const std::string JsonFileExtension; +extern const std::string StepFileExtension; +extern const std::string StepFileAbrvExtension; +extern const std::string GltfBinaryFileExtension; + extern const wxString GerberFileExtensionsRegex; bool IsGerberFileExtension( const wxString& ext ); diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index df18be4f29..946ab0e02a 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -148,9 +148,14 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& bSizerTop->Hide( widget ); widget->Destroy(); + wxString filter = _( "STEP files" ) + + AddFileExtListToFilter( { StepFileExtension, StepFileAbrvExtension } ) + "|" + + _( "Binary GTLF files" ) + + AddFileExtListToFilter( { GltfBinaryFileExtension } ); + m_filePickerSTEP = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _( "Select a STEP export filename" ), - _( "STEP files" ) + AddFileExtListToFilter( { "STEP", "STP" } ), + filter, wxDefaultPosition, wxSize( -1, -1 ), wxFLP_SAVE | wxFLP_USE_TEXTCTRL ); bSizerTop->Add( m_filePickerSTEP, 1, wxTOP | wxRIGHT | wxLEFT | wxALIGN_CENTER_VERTICAL, 5 ); @@ -368,7 +373,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent ) msg.Printf( _( "File '%s' already exists. Do you want overwrite this file?" ), fn.GetFullPath() ); - if( wxMessageBox( msg, _( "STEP Export" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO ) + if( wxMessageBox( msg, _( "STEP/GLTF Export" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO ) return; } @@ -400,7 +405,14 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent ) cmdK2S.Append( wxT( " pcb" ) ); cmdK2S.Append( wxT( " export" ) ); - cmdK2S.Append( wxT( " step" ) ); + cmdK2S.Append( wxT( " 3d" ) ); + + cmdK2S.Append( wxT( " --format" ) ); + + if( fn.GetExt() == GltfBinaryFileExtension ) + cmdK2S.Append( wxT( " glb" ) ); + else + cmdK2S.Append( wxT( " step" ) ); if( GetNoUnspecifiedOption() ) cmdK2S.Append( wxT( " --no-unspecified" ) ); diff --git a/pcbnew/dialogs/dialog_export_step_base.fbp b/pcbnew/dialogs/dialog_export_step_base.fbp index e480e5daa7..57c3bf986f 100644 --- a/pcbnew/dialogs/dialog_export_step_base.fbp +++ b/pcbnew/dialogs/dialog_export_step_base.fbp @@ -50,7 +50,7 @@ -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h - Export STEP + Export STEP / GLTF 0 diff --git a/pcbnew/dialogs/dialog_export_step_base.h b/pcbnew/dialogs/dialog_export_step_base.h index 37ce7f890a..4f6dbfa14d 100644 --- a/pcbnew/dialogs/dialog_export_step_base.h +++ b/pcbnew/dialogs/dialog_export_step_base.h @@ -74,7 +74,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( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Export STEP / GLTF"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_EXPORT_STEP_BASE(); diff --git a/pcbnew/dialogs/dialog_export_step_process_base.fbp b/pcbnew/dialogs/dialog_export_step_process_base.fbp index f5477d672b..f2be8e2861 100644 --- a/pcbnew/dialogs/dialog_export_step_process_base.fbp +++ b/pcbnew/dialogs/dialog_export_step_process_base.fbp @@ -50,7 +50,7 @@ -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h - STEP Export + 3D Export 0 diff --git a/pcbnew/dialogs/dialog_export_step_process_base.h b/pcbnew/dialogs/dialog_export_step_process_base.h index 89a666deca..9e7cd19005 100644 --- a/pcbnew/dialogs/dialog_export_step_process_base.h +++ b/pcbnew/dialogs/dialog_export_step_process_base.h @@ -43,7 +43,7 @@ class DIALOG_EXPORT_STEP_PROCESS_BASE : public DIALOG_SHIM public: - DIALOG_EXPORT_STEP_PROCESS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("STEP Export"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_EXPORT_STEP_PROCESS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("3D Export"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_EXPORT_STEP_PROCESS_BASE();