From 22c4fa29f1191e9f4cd19d5fd53372c0c0181750 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Thu, 25 Apr 2024 21:10:31 +0300 Subject: [PATCH] STEP/BREP export: expose Net Filter option in the UI. --- pcbnew/dialogs/dialog_export_step.cpp | 13 ++- pcbnew/dialogs/dialog_export_step_base.cpp | 9 ++ pcbnew/dialogs/dialog_export_step_base.fbp | 127 +++++++++++++++++++++ pcbnew/dialogs/dialog_export_step_base.h | 2 + 4 files changed, 149 insertions(+), 2 deletions(-) diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index a743a438cf..728af17f23 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -123,6 +123,7 @@ private: static bool m_exportZones; // remember last preference to export zones (stored only for the session) static bool m_fuseShapes; // remember last preference to fuse shapes (stored only for the session) static bool m_exportInnerCopper; // remember last preference to export inner layers (stored only for the session) + wxString m_netFilter; // filter copper nets wxString m_boardPath; // path to the exported board file static int m_toleranceLastChoice; // Store m_tolerance option during a session }; @@ -185,6 +186,7 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& m_noUnspecified = cfg->m_ExportStep.no_unspecified; m_noDNP = cfg->m_ExportStep.no_dnp; + m_txtNetFilter->SetValue( m_netFilter ); m_cbOptimizeStep->SetValue( m_optimizeStep ); m_cbExportBody->SetValue( m_exportBoardBody ); m_cbExportComponents->SetValue( m_exportComponents ); @@ -283,6 +285,7 @@ DIALOG_EXPORT_STEP::~DIALOG_EXPORT_STEP() cfg->m_ExportStep.no_dnp = m_cbRemoveDNP->GetValue(); } + m_netFilter = m_txtNetFilter->GetValue(); m_toleranceLastChoice = m_choiceTolerance->GetSelection(); m_optimizeStep = m_cbOptimizeStep->GetValue(); m_exportBoardBody = m_cbExportBody->GetValue(); @@ -394,6 +397,8 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent ) return; } + m_netFilter = m_txtNetFilter->GetValue(); + double tolerance; // default value in mm m_toleranceLastChoice = m_choiceTolerance->GetSelection(); m_optimizeStep = m_cbOptimizeStep->GetValue(); @@ -508,13 +513,17 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent ) if( m_fuseShapes ) cmdK2S.Append( wxT( " --fuse-shapes" ) ); - // TODO: --net-filter - // Note: for some reason, using \" to insert a quote in a format string, under MacOS // wxString::Format does not work. So use a %c format in string int quote = '\''; int dblquote = '"'; + if( !m_netFilter.empty() ) + { + cmdK2S.Append( wxString::Format( wxT( " --net-filter %c%s%c" ), dblquote, m_netFilter, + dblquote ) ); + } + switch( GetOriginOption() ) { case STEP_ORIGIN_0: diff --git a/pcbnew/dialogs/dialog_export_step_base.cpp b/pcbnew/dialogs/dialog_export_step_base.cpp index 9c5f9b8649..b54bc30e5d 100644 --- a/pcbnew/dialogs/dialog_export_step_base.cpp +++ b/pcbnew/dialogs/dialog_export_step_base.cpp @@ -193,6 +193,15 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i sbOtherOptions->Add( m_cbExportSolderpaste_hidden, 0, wxBOTTOM|wxRIGHT, 5 ); + m_staticTextNetFilter = new wxStaticText( sbOtherOptions->GetStaticBox(), wxID_ANY, _("Net filter (supports wildcards):"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextNetFilter->Wrap( -1 ); + sbOtherOptions->Add( m_staticTextNetFilter, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); + + m_txtNetFilter = new wxTextCtrl( sbOtherOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_txtNetFilter->SetToolTip( _("Only copper items belonging to nets matching this filter will be exported.") ); + + sbOtherOptions->Add( m_txtNetFilter, 0, wxALL|wxEXPAND, 5 ); + m_staticTextTolerance = new wxStaticText( sbOtherOptions->GetStaticBox(), wxID_ANY, _("Board outline chaining tolerance:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextTolerance->Wrap( -1 ); sbOtherOptions->Add( m_staticTextTolerance, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); diff --git a/pcbnew/dialogs/dialog_export_step_base.fbp b/pcbnew/dialogs/dialog_export_step_base.fbp index bf300ef92c..47dbcff7fd 100644 --- a/pcbnew/dialogs/dialog_export_step_base.fbp +++ b/pcbnew/dialogs/dialog_export_step_base.fbp @@ -2079,6 +2079,133 @@ + + 5 + wxLEFT|wxRIGHT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Net filter (supports wildcards): + 0 + + 0 + + + 0 + + 1 + m_staticTextNetFilter + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_txtNetFilter + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Only copper items belonging to nets matching this filter will be exported. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + 5 wxLEFT|wxRIGHT|wxTOP diff --git a/pcbnew/dialogs/dialog_export_step_base.h b/pcbnew/dialogs/dialog_export_step_base.h index 9be34cdab8..b171b8e743 100644 --- a/pcbnew/dialogs/dialog_export_step_base.h +++ b/pcbnew/dialogs/dialog_export_step_base.h @@ -77,6 +77,8 @@ class DIALOG_EXPORT_STEP_BASE : public DIALOG_SHIM wxCheckBox* m_cbExportSilkscreen_hidden; wxCheckBox* m_cbExportSoldermask_hidden; wxCheckBox* m_cbExportSolderpaste_hidden; + wxStaticText* m_staticTextNetFilter; + wxTextCtrl* m_txtNetFilter; wxStaticText* m_staticTextTolerance; wxChoice* m_choiceTolerance; wxStdDialogButtonSizer* m_sdbSizer;