diff --git a/common/jobs/job_export_pcb_pos.h b/common/jobs/job_export_pcb_pos.h index 4ca58d3575..d20b92ef7a 100644 --- a/common/jobs/job_export_pcb_pos.h +++ b/common/jobs/job_export_pcb_pos.h @@ -35,6 +35,7 @@ public: m_useDrillPlaceFileOrigin( true ), m_smdOnly( false ), m_excludeFootprintsWithTh( false ), + m_excludeDNP( false ), m_negateBottomX( false ) { m_side = SIDE::BOTH; @@ -49,6 +50,7 @@ public: bool m_useDrillPlaceFileOrigin; bool m_smdOnly; bool m_excludeFootprintsWithTh; + bool m_excludeDNP; bool m_negateBottomX; enum class SIDE diff --git a/kicad/cli/command_export_pcb_pos.cpp b/kicad/cli/command_export_pcb_pos.cpp index 5ec235a5c5..686b09f80f 100644 --- a/kicad/cli/command_export_pcb_pos.cpp +++ b/kicad/cli/command_export_pcb_pos.cpp @@ -36,6 +36,7 @@ #define ARG_USE_DRILL_FILE_ORIGIN "--use-drill-file-origin" #define ARG_SMD_ONLY "--smd-only" #define ARG_EXCLUDE_FOOTPRINTS_TH "--exclude-fp-th" +#define ARG_EXCLUDE_DNP "--exclude-dnp" #define ARG_GERBER_BOARD_EDGE "--gerber-board-edge" @@ -78,6 +79,12 @@ CLI::EXPORT_PCB_POS_COMMAND::EXPORT_PCB_POS_COMMAND() : EXPORT_PCB_BASE_COMMAND( .implicit_value( true ) .default_value( false ); + m_argParser.add_argument( ARG_EXCLUDE_DNP ) + .help( UTF8STDSTR( + _( "Exclude all footprints with the Do Not Populate flag set" ) ) ) + .implicit_value( true ) + .default_value( false ); + m_argParser.add_argument( ARG_GERBER_BOARD_EDGE ) .help( UTF8STDSTR( _( "Include board edge layer (gerber only)" ) ) ) .implicit_value( true ) @@ -106,6 +113,7 @@ int CLI::EXPORT_PCB_POS_COMMAND::doPerform( KIWAY& aKiway ) aPosJob->m_smdOnly = m_argParser.get( ARG_SMD_ONLY ); aPosJob->m_excludeFootprintsWithTh = m_argParser.get( ARG_EXCLUDE_FOOTPRINTS_TH ); aPosJob->m_useDrillPlaceFileOrigin = m_argParser.get( ARG_USE_DRILL_FILE_ORIGIN ); + aPosJob->m_excludeDNP = m_argParser.get( ARG_EXCLUDE_DNP ); aPosJob->m_gerberBoardEdge = m_argParser.get( ARG_GERBER_BOARD_EDGE ); wxString format = FROM_UTF8( m_argParser.get( ARG_FORMAT ).c_str() ); diff --git a/pcbnew/dialogs/dialog_gen_footprint_position.cpp b/pcbnew/dialogs/dialog_gen_footprint_position.cpp index b71a8abd6d..89189b5990 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position.cpp +++ b/pcbnew/dialogs/dialog_gen_footprint_position.cpp @@ -156,6 +156,11 @@ private: return m_excludeTH->GetValue(); } + bool ExcludeDNP() + { + return m_excludeDNP->GetValue(); + } + private: PCB_EDIT_FRAME* m_parent; REPORTER* m_reporter; @@ -356,8 +361,8 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles() // Test for any footprint candidate in list. { - PLACE_FILE_EXPORTER exporter( brd, UnitsMM(), OnlySMD(), ExcludeAllTH(), topSide, - bottomSide, useCSVfmt, useAuxOrigin, negateBottomX ); + PLACE_FILE_EXPORTER exporter( brd, UnitsMM(), OnlySMD(), ExcludeAllTH(), ExcludeDNP(), + topSide, bottomSide, useCSVfmt, useAuxOrigin, negateBottomX ); exporter.GenPositionData(); if( exporter.GetFootprintCount() == 0 ) @@ -422,8 +427,9 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles() } int fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(), OnlySMD(), - ExcludeAllTH(), topSide, bottomSide, - useCSVfmt, useAuxOrigin, negateBottomX ); + ExcludeAllTH(), ExcludeDNP(), topSide, + bottomSide, useCSVfmt, useAuxOrigin, + negateBottomX ); if( fpcount < 0 ) { msg.Printf( _( "Failed to create file '%s'." ), fn.GetFullPath() ); @@ -467,7 +473,8 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles() } fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(), OnlySMD(), - ExcludeAllTH(), topSide, bottomSide, useCSVfmt, + ExcludeAllTH(), ExcludeDNP(), topSide, + bottomSide, useCSVfmt, useAuxOrigin, negateBottomX ); if( fpcount < 0 ) @@ -509,8 +516,8 @@ int BOARD_EDITOR_CONTROL::GeneratePosFile( const TOOL_EVENT& aEvent ) int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName, bool aUnitsMM, - bool aOnlySMD, bool aNoTHItems, bool aTopSide, - bool aBottomSide, bool aFormatCSV, + bool aOnlySMD, bool aNoTHItems, bool aExcludeDNP, + bool aTopSide, bool aBottomSide, bool aFormatCSV, bool aUseAuxOrigin, bool aNegateBottomX ) { FILE * file = nullptr; @@ -524,8 +531,8 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName, } std::string data; - PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, aOnlySMD, aNoTHItems, aTopSide, aBottomSide, - aFormatCSV, aUseAuxOrigin, aNegateBottomX ); + PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, aOnlySMD, aNoTHItems, aExcludeDNP, aTopSide, + aBottomSide, aFormatCSV, aUseAuxOrigin, aNegateBottomX ); data = exporter.GenPositionData(); // if aFullFileName is empty, the file is not created, only the @@ -586,6 +593,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool std::string data; PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, false, false, // SMD aOnlySMD, aNoTHItems + false, // aExcludeDNP true, true, // aTopSide, aBottomSide false, true, false // aFormatCSV, aUseAuxOrigin, aNegateBottomX ); diff --git a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp index 1b7a8d05ac..9ab5c00fd4 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp +++ b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) +// C++ code generated with wxFormBuilder (version 3.10.1-254-gc2ef7767) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -78,6 +78,9 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow m_excludeTH = new wxCheckBox( this, wxID_ANY, _("Exclude all footprints with through hole pads"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerLower->Add( m_excludeTH, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_excludeDNP = new wxCheckBox( this, wxID_ANY, _("Exclude all footprints with the Do Not Populate flag set"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerLower->Add( m_excludeDNP, 0, wxALL, 5 ); + m_cbIncludeBoardEdge = new wxCheckBox( this, wxID_ANY, _("Include board edge layer"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerLower->Add( m_cbIncludeBoardEdge, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); @@ -118,6 +121,7 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow m_radioBoxFilesCount->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUIFileOpt ), NULL, this ); m_onlySMD->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUIOnlySMD ), NULL, this ); m_excludeTH->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUIExcludeTH ), NULL, this ); + m_excludeDNP->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUIExcludeTH ), NULL, this ); m_cbIncludeBoardEdge->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUIincludeBoardEdge ), NULL, this ); m_negateXcb->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUInegXcoord ), NULL, this ); m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::OnGenerate ), NULL, this ); @@ -132,6 +136,7 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::~DIALOG_GEN_FOOTPRINT_POSITION_BASE() m_radioBoxFilesCount->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUIFileOpt ), NULL, this ); m_onlySMD->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUIOnlySMD ), NULL, this ); m_excludeTH->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUIExcludeTH ), NULL, this ); + m_excludeDNP->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUIExcludeTH ), NULL, this ); m_cbIncludeBoardEdge->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUIincludeBoardEdge ), NULL, this ); m_negateXcb->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::onUpdateUInegXcoord ), NULL, this ); m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::OnGenerate ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp index 82efb2e2c5..ed57bafc2d 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp +++ b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp @@ -642,6 +642,72 @@ onUpdateUIExcludeTH + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Exclude all footprints with the Do Not Populate flag set + + 0 + + + 0 + + 1 + m_excludeDNP + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onUpdateUIExcludeTH + + 5 wxBOTTOM|wxRIGHT|wxLEFT diff --git a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h index 58d7f982fb..aa4058e96e 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h +++ b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) +// C++ code generated with wxFormBuilder (version 3.10.1-254-gc2ef7767) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -51,6 +51,7 @@ class DIALOG_GEN_FOOTPRINT_POSITION_BASE : public DIALOG_SHIM wxRadioBox* m_radioBoxFilesCount; wxCheckBox* m_onlySMD; wxCheckBox* m_excludeTH; + wxCheckBox* m_excludeDNP; wxCheckBox* m_cbIncludeBoardEdge; wxCheckBox* m_useDrillPlaceOrigin; wxCheckBox* m_negateXcb; diff --git a/pcbnew/exporters/place_file_exporter.cpp b/pcbnew/exporters/place_file_exporter.cpp index 0156e82f78..dd060074ad 100644 --- a/pcbnew/exporters/place_file_exporter.cpp +++ b/pcbnew/exporters/place_file_exporter.cpp @@ -74,13 +74,15 @@ enum SELECT_SIDE }; PLACE_FILE_EXPORTER::PLACE_FILE_EXPORTER( BOARD* aBoard, bool aUnitsMM, bool aOnlySMD, - bool aExcludeAllTH, bool aTopSide, bool aBottomSide, - bool aFormatCSV, bool aUseAuxOrigin, bool aNegateBottomX ) + bool aExcludeAllTH, bool aExcludeDNP, bool aTopSide, + bool aBottomSide, bool aFormatCSV, bool aUseAuxOrigin, + bool aNegateBottomX ) { m_board = aBoard; m_unitsMM = aUnitsMM; m_onlySMD = aOnlySMD; m_excludeAllTH = aExcludeAllTH; + m_excludeDNP = aExcludeDNP; m_fpCount = 0; m_negateBottomX = aNegateBottomX; @@ -142,6 +144,9 @@ std::string PLACE_FILE_EXPORTER::GenPositionData() if( m_excludeAllTH && footprint->HasThroughHolePads() ) continue; + if( m_excludeDNP && ( footprint->GetAttributes() & FP_DNP ) ) + continue; + m_fpCount++; LIST_MOD item; diff --git a/pcbnew/exporters/place_file_exporter.h b/pcbnew/exporters/place_file_exporter.h index 41b9e29761..e379343f78 100644 --- a/pcbnew/exporters/place_file_exporter.h +++ b/pcbnew/exporters/place_file_exporter.h @@ -58,6 +58,7 @@ public: * @param aOnlySMD true to force only footprints flagged smd to be in the list * @param aExcludeAllTH true to include only footprints with no TH pads no matter * the footprint flag + * @param aExcludeDNP true to exclude footprints flagged DNP * @param aTopSide true to generate top side info * @param aBottomSide true to generate bottom side info * @param aFormatCSV true to generate a csv format info, false to generate a ascii info @@ -65,8 +66,8 @@ public: * @param aUseAuxOrigin true to use auxiliary axis as an origin for the position data */ PLACE_FILE_EXPORTER( BOARD* aBoard, bool aUnitsMM, bool aOnlySMD, bool aExcludeAllTH, - bool aTopSide, bool aBottomSide, bool aFormatCSV, bool aUseAuxOrigin, - bool aNegateBottomX ); + bool aExcludeDNP, bool aTopSide, bool aBottomSide, bool aFormatCSV, + bool aUseAuxOrigin, bool aNegateBottomX ); /** * build a string filled with the position data @@ -95,6 +96,7 @@ private: BOARD* m_board; bool m_unitsMM; // true for mm, false for inches bool m_onlySMD; // Include only SMD components + bool m_excludeDNP; // Exclude DNP components bool m_excludeAllTH; // Exclude any footprints with through-hole pads int m_side; // PCB_BACK_SIDE, PCB_FRONT_SIDE, PCB_BOTH_SIDES bool m_formatCSV; // true for csv format, false for ascii (utf8) format diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index d80e402734..1ff1c91ced 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -314,6 +314,7 @@ public: * @param aOnlySMD true to force only footprints flagged smd to be in the list * @param aNoTHItems true to include only footprints with no TH pads no matter * the footprint flag + * @param aExcludeDNP true to exclude footprints flagged DNP * @param aTopSide true to list footprints on front (top) side. * @param aBottomSide true to list footprints on back (bottom) side, if \a aTopSide and * \a aTopSide are true, list footprints on both sides. @@ -323,7 +324,7 @@ public: * @return the number of footprints found on aSide side or -1 if the file could not be created. */ int DoGenFootprintsPositionFile( const wxString& aFullFileName, bool aUnitsMM, bool aOnlySMD, - bool aNoTHItems, bool aTopSide, bool aBottomSide, + bool aNoTHItems, bool aExcludeDNP, bool aTopSide, bool aBottomSide, bool aFormatCSV, bool aUseAuxOrigin, bool aNegateBottomX ); /** diff --git a/pcbnew/pcbnew_jobs_handler.cpp b/pcbnew/pcbnew_jobs_handler.cpp index 7b4292d10c..b561025c8d 100644 --- a/pcbnew/pcbnew_jobs_handler.cpp +++ b/pcbnew/pcbnew_jobs_handler.cpp @@ -600,6 +600,7 @@ int PCBNEW_JOBS_HANDLER::JobExportPos( JOB* aJob ) PLACE_FILE_EXPORTER exporter( brd, aPosJob->m_units == JOB_EXPORT_PCB_POS::UNITS::MILLIMETERS, aPosJob->m_smdOnly, aPosJob->m_excludeFootprintsWithTh, + aPosJob->m_excludeDNP, frontSide, backSide, aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV, aPosJob->m_useDrillPlaceFileOrigin,