ADDED: DNP flag for position file export

Adds ability to exclude footprints with DNP flag from position files in
dialog and cli

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15353
This commit is contained in:
Seth Hillbrand 2023-08-04 11:02:10 -07:00
parent 02335010ff
commit c38ed7044a
10 changed files with 115 additions and 16 deletions

View File

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

View File

@ -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<bool>( ARG_SMD_ONLY );
aPosJob->m_excludeFootprintsWithTh = m_argParser.get<bool>( ARG_EXCLUDE_FOOTPRINTS_TH );
aPosJob->m_useDrillPlaceFileOrigin = m_argParser.get<bool>( ARG_USE_DRILL_FILE_ORIGIN );
aPosJob->m_excludeDNP = m_argParser.get<bool>( ARG_EXCLUDE_DNP );
aPosJob->m_gerberBoardEdge = m_argParser.get<bool>( ARG_GERBER_BOARD_EDGE );
wxString format = FROM_UTF8( m_argParser.get<std::string>( ARG_FORMAT ).c_str() );

View File

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

View File

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

View File

@ -642,6 +642,72 @@
<event name="OnUpdateUI">onUpdateUIExcludeTH</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Exclude all footprints with the Do Not Populate flag set</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_excludeDNP</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnUpdateUI">onUpdateUIExcludeTH</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>

View File

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

View File

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

View File

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

View File

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

View File

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