IDFv3: control whether DNP/unspecified components are exported

This commit is contained in:
Mike Williams 2024-05-08 10:22:25 -04:00
parent d22d32697f
commit 482cf659a7
7 changed files with 906 additions and 718 deletions

View File

@ -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 );

View File

@ -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 );

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,7 @@ class TEXT_CTRL_EVAL;
#include <wx/textctrl.h>
#include <wx/valtext.h>
#include <wx/radiobox.h>
#include <wx/statbox.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -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;

View File

@ -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 ) )
{

View File

@ -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.

View File

@ -176,6 +176,8 @@ public:
double ref_x;
double ref_y;
bool units_mils;
bool no_unspecified;
bool no_dnp;
};
struct DIALOG_EXPORT_STEP