diff --git a/pcbnew/dialogs/dialog_export_idf.cpp b/pcbnew/dialogs/dialog_export_idf.cpp index 5e6de084e3..039673d183 100644 --- a/pcbnew/dialogs/dialog_export_idf.cpp +++ b/pcbnew/dialogs/dialog_export_idf.cpp @@ -57,6 +57,9 @@ public: m_XRef = cfg->m_ExportIdf.ref_x; m_YRef = cfg->m_ExportIdf.ref_y; + m_cbRemoveUnspecified->SetValue( cfg->m_ExportIdf.no_unspecified ); + m_cbRemoveDNP->SetValue( cfg->m_ExportIdf.no_dnp ); + m_cbAutoAdjustOffset->SetValue( m_AutoAdjust ); m_cbAutoAdjustOffset->Bind( wxEVT_CHECKBOX, &DIALOG_EXPORT_IDF3::OnAutoAdjustOffset, this ); @@ -109,6 +112,9 @@ public: cfg->m_ExportIdf.ref_units = m_RefUnits; cfg->m_ExportIdf.ref_x = m_XRef; cfg->m_ExportIdf.ref_y = m_YRef; + + cfg->m_ExportIdf.no_unspecified = m_cbRemoveUnspecified->GetValue(); + cfg->m_ExportIdf.no_dnp = m_cbRemoveDNP->GetValue(); } } @@ -137,6 +143,16 @@ public: return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_IDF_Yref->GetValue() ); } + bool GetNoUnspecifiedOption() + { + return m_cbRemoveUnspecified->GetValue(); + } + + bool GetNoDNPOption() + { + return m_cbRemoveDNP->GetValue(); + } + bool GetAutoAdjustOffset() { return m_cbAutoAdjustOffset->GetValue(); @@ -230,7 +246,8 @@ void PCB_EDIT_FRAME::OnExportIDF3( wxCommandEvent& event ) wxString fullFilename = dlg.FilePicker()->GetPath(); SetLastPath( LAST_PATH_IDF, fullFilename ); - if( !Export_IDF3( GetBoard(), fullFilename, thou, aXRef, aYRef ) ) + if( !Export_IDF3( GetBoard(), fullFilename, thou, aXRef, aYRef, !dlg.GetNoUnspecifiedOption(), + !dlg.GetNoDNPOption() ) ) { wxString msg = wxString::Format( _( "Failed to create file '%s'." ), fullFilename ); wxMessageBox( msg ); diff --git a/pcbnew/dialogs/dialog_export_idf_base.cpp b/pcbnew/dialogs/dialog_export_idf_base.cpp index b7f8d952f1..8cea211cb3 100644 --- a/pcbnew/dialogs/dialog_export_idf_base.cpp +++ b/pcbnew/dialogs/dialog_export_idf_base.cpp @@ -105,8 +105,17 @@ DIALOG_EXPORT_IDF3_BASE::DIALOG_EXPORT_IDF3_BASE( wxWindow* parent, wxWindowID i m_rbUnitSelection->SetSelection( 0 ); bSizer2->Add( m_rbUnitSelection, 0, wxALL, 5 ); + wxStaticBoxSizer* sbOtherOptions; + sbOtherOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Other Options") ), wxVERTICAL ); - bSizer2->Add( 0, 0, 1, wxEXPAND, 5 ); + m_cbRemoveDNP = new wxCheckBox( sbOtherOptions->GetStaticBox(), wxID_ANY, _("Ignore 'Do not populate' components"), wxDefaultPosition, wxDefaultSize, 0 ); + sbOtherOptions->Add( m_cbRemoveDNP, 0, wxALL, 5 ); + + m_cbRemoveUnspecified = new wxCheckBox( sbOtherOptions->GetStaticBox(), wxID_ANY, _("Ignore 'Unspecified' components"), wxDefaultPosition, wxDefaultSize, 0 ); + sbOtherOptions->Add( m_cbRemoveUnspecified, 0, wxALL, 5 ); + + + bSizer2->Add( sbOtherOptions, 1, wxEXPAND|wxLEFT|wxRIGHT, 10 ); bSizerIDFFile->Add( bSizer2, 1, wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_export_idf_base.fbp b/pcbnew/dialogs/dialog_export_idf_base.fbp index a584165e97..20eb9563fc 100644 --- a/pcbnew/dialogs/dialog_export_idf_base.fbp +++ b/pcbnew/dialogs/dialog_export_idf_base.fbp @@ -1,71 +1,354 @@ - + - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_export_idf_base - 1000 - none - - - 1 - dialog_export_idf3_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 1 - 0 - - 0 - wxAUI_MGR_DEFAULT + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_export_idf_base + 1000 + none + + + 1 + dialog_export_idf3_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_EXPORT_IDF3_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Export IDFv3 + + 0 + + + + + -1,-1 + bSizerIDFFile + wxVERTICAL + none + + 5 + wxBOTTOM|wxLEFT|wxRIGHT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + - wxBOTH + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left + 0 1 - impl_virtual - + 1 + 0 0 wxID_ANY + File name: + 0 + + 0 + + 0 - DIALOG_EXPORT_IDF3_BASE + 1 + m_txtBrdFile + 1 + + + protected + 1 - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Export IDFv3 + Resizable + 1 + + + + 0 - 0 - - -1,-1 - bSizerIDFFile + -1 + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + Select an IDF export filename + + 0 + -1,-1 + 1 + m_filePickerIDF + 1 + + + protected + 1 + + Resizable + 1 + 450,-1 + wxFLP_OVERWRITE_PROMPT|wxFLP_SAVE|wxFLP_USE_TEXTCTRL + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + *.emn + + + + + + + 5 + wxEXPAND + 1 + + + bSizer2 + wxHORIZONTAL + none + + 5 + wxEXPAND|wxLEFT + 1 + + + bSizer3 wxVERTICAL none - - 5 - wxBOTTOM|wxLEFT|wxRIGHT|wxTOP - 0 - + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Grid reference point: + 0 + + 0 + + + 0 + + 1 + m_staticText2 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Adjust automatically + + 0 + + + 0 + + 1 + m_cbAutoAdjustOffset + 1 + + + protected + 1 + + Resizable + 1 + + wxCHK_2STATE + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer6 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + 1 1 1 @@ -86,6 +369,7 @@ Dock 0 Left + 0 1 1 @@ -93,7 +377,7 @@ 0 0 wxID_ANY - File name: + Units: 0 0 @@ -102,7 +386,7 @@ 0 1 - m_txtBrdFile + m_staticText5 1 @@ -120,13 +404,13 @@ -1 + - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + 1 1 1 @@ -140,6 +424,7 @@ 1 0 + "mm" "inch" 1 1 @@ -147,6 +432,7 @@ Dock 0 Left + 0 1 1 @@ -157,12 +443,11 @@ 0 - Select an IDF export filename 0 - -1,-1 + 1 - m_filePickerIDF + m_IDF_RefUnitChoice 1 @@ -170,9 +455,10 @@ 1 Resizable + 0 1 - 450,-1 - wxFLP_OVERWRITE_PROMPT|wxFLP_SAVE|wxFLP_USE_TEXTCTRL + + 0 @@ -180,663 +466,523 @@ wxFILTER_NONE wxDefaultValidator - - *.emn + + - - 5 - wxEXPAND - 1 - + + 5 + wxEXPAND + 1 + + + bSizer4 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + X position: + 0 + + 0 + + + 0 + + 1 + m_staticText3 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 8 + + 0 - bSizer2 - wxHORIZONTAL - none - - 5 - wxEXPAND|wxLEFT - 1 - - - bSizer3 - wxVERTICAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Grid reference point: - 0 - - 0 - - - 0 - - 1 - m_staticText2 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Adjust automatically - - 0 - - - 0 - - 1 - m_cbAutoAdjustOffset - 1 - - - protected - 1 - - Resizable - 1 - - wxCHK_2STATE - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxEXPAND - 1 - - - bSizer6 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Units: - 0 - - 0 - - - 0 - - 1 - m_staticText5 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "mm" "inch" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_IDF_RefUnitChoice - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxEXPAND - 1 - - - bSizer4 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - X position: - 0 - - 0 - - - 0 - - 1 - m_staticText3 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 8 - - 0 - - 1 - m_IDF_Xref - 1 - - - protected - 1 - - Resizable - 1 - - - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h - 0 - - - wxFILTER_NUMERIC - wxTextValidator - - 0 - - - - - - - - - 5 - wxEXPAND - 1 - - - bSizer5 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Y position: - 0 - - 0 - - - 0 - - 1 - m_staticText4 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 8 - - 0 - - 1 - m_IDF_Yref - 1 - - - protected - 1 - - Resizable - 1 - - - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h - 0 - - - wxFILTER_NUMERIC - wxTextValidator - - 0 - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Millimeters" "Mils" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Output Units - 1 - - 0 - - - 0 - - 1 - m_rbUnitSelection - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - + 1 + m_IDF_Xref + 1 + + + protected + 1 + + Resizable + 1 + + + TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + 0 + + + wxFILTER_NUMERIC + wxTextValidator + + 0 + + + + + - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxTOP - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 + + 5 + wxEXPAND + 1 + + + bSizer5 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Y position: + 0 + + 0 + + + 0 + + 1 + m_staticText4 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 8 + + 0 - m_sdbSizer + 1 + m_IDF_Yref + 1 + + protected + 1 + + Resizable + 1 + + + TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + 0 + + + wxFILTER_NUMERIC + wxTextValidator + + 0 + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Millimeters" "Mils" + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Output Units + 1 + + 0 + + + 0 + + 1 + m_rbUnitSelection + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 10 + wxEXPAND|wxLEFT|wxRIGHT + 1 + + wxID_ANY + Other Options + + sbOtherOptions + wxVERTICAL + 1 + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Ignore 'Do not populate' components + + 0 + + + 0 + + 1 + m_cbRemoveDNP + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Ignore 'Unspecified' components + + 0 + + + 0 + + 1 + m_cbRemoveUnspecified + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + 5 + wxBOTTOM|wxEXPAND|wxLEFT|wxTOP + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + + diff --git a/pcbnew/dialogs/dialog_export_idf_base.h b/pcbnew/dialogs/dialog_export_idf_base.h index 1b63131979..6192c29d4c 100644 --- a/pcbnew/dialogs/dialog_export_idf_base.h +++ b/pcbnew/dialogs/dialog_export_idf_base.h @@ -26,6 +26,7 @@ class TEXT_CTRL_EVAL; #include #include #include +#include #include #include @@ -50,6 +51,8 @@ class DIALOG_EXPORT_IDF3_BASE : public DIALOG_SHIM wxStaticText* m_staticText4; TEXT_CTRL_EVAL* m_IDF_Yref; wxRadioBox* m_rbUnitSelection; + wxCheckBox* m_cbRemoveDNP; + wxCheckBox* m_cbRemoveUnspecified; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; diff --git a/pcbnew/exporters/export_idf.cpp b/pcbnew/exporters/export_idf.cpp index e983b645c0..a6cb6fc29c 100644 --- a/pcbnew/exporters/export_idf.cpp +++ b/pcbnew/exporters/export_idf.cpp @@ -269,7 +269,8 @@ UseBoundingBox: * BOARD_OUTLINE section as appropriate, Compiles data for the PLACEMENT section and compiles * data for the library ELECTRICAL section. */ -static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD& aIDFBoard ) +static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD& aIDFBoard, + bool aIncludeUnspecified, bool aIncludeDNP ) { // Reference Designator std::string crefdes = TO_UTF8( aFootprint->Reference().GetShownText( false ) ); @@ -412,6 +413,12 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD } } + if( ( !(aFootprint->GetAttributes() & (FP_THROUGH_HOLE|FP_SMD)) ) && !aIncludeUnspecified ) + return; + + if( aFootprint->IsDNP() && !aIncludeDNP ) + return; + // add any valid models to the library item list std::string refdes; @@ -599,7 +606,8 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD * PCB design. */ bool PCB_EDIT_FRAME::Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, - bool aUseThou, double aXRef, double aYRef ) + bool aUseThou, double aXRef, double aYRef, + bool aIncludeUnspecified, bool aIncludeDNP ) { IDF3_BOARD idfBoard( IDF3::CAD_ELEC ); @@ -645,7 +653,7 @@ bool PCB_EDIT_FRAME::Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, // Output the drill holes and footprint (library) data. for( FOOTPRINT* footprint : aPcb->Footprints() ) - idf_export_footprint( aPcb, footprint, idfBoard ); + idf_export_footprint( aPcb, footprint, idfBoard, aIncludeUnspecified, aIncludeDNP ); if( !idfBoard.WriteFile( aFullFileName, idfUnit, false ) ) { diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 8c11767328..1364f0e957 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -525,10 +525,13 @@ public: * @param aUseThou set to true if the desired IDF unit is thou (mil). * @param aXRef the board Reference Point in mm, X value. * @param aYRef the board Reference Point in mm, Y value. + * @param aIncludeUnspecified true to include unspecified-type footprint models + * @param aIncludeDNP true to include DNP footprint models * @return true if OK. */ bool Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, - bool aUseThou, double aXRef, double aYRef ); + bool aUseThou, double aXRef, double aYRef, + bool aIncludeUnspecified, bool aIncludeDNP ); /** * Export the current BOARD to a STEP assembly. diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index 03e6d5cb91..ff5b858877 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -176,6 +176,8 @@ public: double ref_x; double ref_y; bool units_mils; + bool no_unspecified; + bool no_dnp; }; struct DIALOG_EXPORT_STEP