Symbol Fields Table: configurable excluded from BOM filtering
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/17747
This commit is contained in:
parent
b7f035964f
commit
ea904c9fb1
|
@ -39,6 +39,7 @@ JOB_EXPORT_SCH_BOM::JOB_EXPORT_SCH_BOM( bool aIsCli ) :
|
|||
m_sortField(),
|
||||
m_sortAsc( true ),
|
||||
m_filterString(),
|
||||
m_excludeDNP( false )
|
||||
m_excludeDNP( false ),
|
||||
m_includeExcludedFromBOM( false )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
bool m_sortAsc;
|
||||
wxString m_filterString;
|
||||
bool m_excludeDNP;
|
||||
bool m_includeExcludedFromBOM;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -82,6 +82,7 @@ void to_json( nlohmann::json& j, const BOM_PRESET& p )
|
|||
{ "filter_string", p.filterString },
|
||||
{ "group_symbols", p.groupSymbols },
|
||||
{ "exclude_dnp", p.excludeDNP },
|
||||
{ "include_excluded_from_bom", p.includeExcludedFromBOM },
|
||||
};
|
||||
|
||||
if( p.fieldsOrdered.size() > 0 )
|
||||
|
@ -98,6 +99,8 @@ void from_json( const nlohmann::json& j, BOM_PRESET& f )
|
|||
j.at( "filter_string" ).get_to( f.filterString );
|
||||
j.at( "group_symbols" ).get_to( f.groupSymbols );
|
||||
j.at( "exclude_dnp" ).get_to( f.excludeDNP );
|
||||
// Was not present in initial BOM settings in 8.0, so default to false if not found
|
||||
f.includeExcludedFromBOM = j.value( "include_excluded_from_bom", false );
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,13 +113,37 @@ bool BOM_PRESET::operator==( const BOM_PRESET& rhs ) const
|
|||
&& this->sortField == rhs.sortField
|
||||
&& this->sortAsc == rhs.sortAsc
|
||||
&& this->groupSymbols == rhs.groupSymbols
|
||||
&& this->excludeDNP == rhs.excludeDNP;
|
||||
&& this->excludeDNP == rhs.excludeDNP
|
||||
&& this->includeExcludedFromBOM == rhs.includeExcludedFromBOM;
|
||||
}
|
||||
|
||||
|
||||
BOM_PRESET BOM_PRESET::DefaultEditing()
|
||||
{
|
||||
BOM_PRESET p{
|
||||
_HKI( "Default Editing" ), true, {}, _( "Reference" ), true, "", true, false, true
|
||||
};
|
||||
|
||||
p.fieldsOrdered = std::vector<BOM_FIELD>{
|
||||
{ "Reference", "Reference", true, false },
|
||||
{ "${QUANTITY}", "Qty", true, false },
|
||||
{ "Value", "Value", true, true },
|
||||
{ "${DNP}", "DNP", true, true },
|
||||
{ "${EXCLUDE_FROM_BOM}", "Exclude from BOM", true, true },
|
||||
{ "${EXCLUDE_FROM_BOARD}", "Exclude from Board", true, true },
|
||||
{ "Footprint", "Footprint", true, true },
|
||||
{ "Datasheet", "Datasheet", true, false },
|
||||
};
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
BOM_PRESET BOM_PRESET::GroupedByValue()
|
||||
{
|
||||
BOM_PRESET p{ _HKI( "Grouped By Value" ), true, {}, _( "Reference" ), true, "", true, false };
|
||||
BOM_PRESET p{
|
||||
_HKI( "Grouped By Value" ), true, {}, _( "Reference" ), true, "", true, false, false
|
||||
};
|
||||
|
||||
p.fieldsOrdered = std::vector<BOM_FIELD>{
|
||||
{ "Reference", "Reference", true, false },
|
||||
|
@ -134,7 +161,7 @@ BOM_PRESET BOM_PRESET::GroupedByValue()
|
|||
BOM_PRESET BOM_PRESET::GroupedByValueFootprint()
|
||||
{
|
||||
BOM_PRESET p{
|
||||
_HKI( "Grouped By Value and Footprint" ), true, {}, _( "Reference" ), true, "", true, false
|
||||
_HKI( "Grouped By Value and Footprint" ), true, {}, _( "Reference" ), true, "", true, false, false
|
||||
};
|
||||
|
||||
p.fieldsOrdered = std::vector<BOM_FIELD>{
|
||||
|
@ -153,7 +180,7 @@ BOM_PRESET BOM_PRESET::GroupedByValueFootprint()
|
|||
BOM_PRESET BOM_PRESET::Attributes()
|
||||
{
|
||||
BOM_PRESET p{
|
||||
_HKI( "Attributes" ), true, {}, _( "Reference" ), true, "", true, false
|
||||
_HKI( "Attributes" ), true, {}, _( "Reference" ), true, "", true, false, true
|
||||
};
|
||||
|
||||
p.fieldsOrdered = std::vector<BOM_FIELD>{
|
||||
|
@ -172,8 +199,8 @@ BOM_PRESET BOM_PRESET::Attributes()
|
|||
|
||||
std::vector<BOM_PRESET> BOM_PRESET::BuiltInPresets()
|
||||
{
|
||||
return { BOM_PRESET::GroupedByValue(), BOM_PRESET::GroupedByValueFootprint(),
|
||||
BOM_PRESET::Attributes() };
|
||||
return { BOM_PRESET::DefaultEditing(), BOM_PRESET::GroupedByValue(),
|
||||
BOM_PRESET::GroupedByValueFootprint(), BOM_PRESET::Attributes() };
|
||||
}
|
||||
|
||||
//Implementations for BOM_FMT_PRESET
|
||||
|
@ -248,4 +275,4 @@ std::vector<BOM_FMT_PRESET> BOM_FMT_PRESET::BuiltInPresets()
|
|||
#if !defined( __MINGW32__ )
|
||||
template class KICOMMON_API PARAM_LIST<BOM_PRESET>;
|
||||
template class KICOMMON_API PARAM_LIST<BOM_FMT_PRESET>;
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -216,10 +216,6 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent )
|
|||
m_filter->SetDescriptiveText( _( "Filter" ) );
|
||||
m_dataModel = new FIELDS_EDITOR_GRID_DATA_MODEL( m_symbolsList );
|
||||
|
||||
// We want to show excluded symbols because the Edit page needs to show all symbols,
|
||||
// they will still be excluded from the export.
|
||||
m_dataModel->SetIncludeExcludedFromBOM( true );
|
||||
|
||||
LoadFieldNames(); // loads rows into m_fieldsCtrl and columns into m_dataModel
|
||||
|
||||
// Now that the fields are loaded we can set the initial location of the splitter
|
||||
|
@ -896,6 +892,16 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnExcludeDNPToggled( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_SYMBOL_FIELDS_TABLE::OnShowExcludedToggled( wxCommandEvent& event )
|
||||
{
|
||||
m_dataModel->SetIncludeExcludedFromBOM( m_checkShowExcluded->GetValue() );
|
||||
m_dataModel->RebuildRows();
|
||||
m_grid->ForceRefresh();
|
||||
|
||||
syncBomPresetSelection();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SYMBOL_FIELDS_TABLE::OnColSort( wxGridEvent& aEvent )
|
||||
{
|
||||
int sortCol = aEvent.GetCol();
|
||||
|
@ -1156,13 +1162,8 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnPreviewRefresh( wxCommandEvent& event )
|
|||
|
||||
void DIALOG_SYMBOL_FIELDS_TABLE::PreviewRefresh()
|
||||
{
|
||||
m_dataModel->SetIncludeExcludedFromBOM( false );
|
||||
m_dataModel->RebuildRows();
|
||||
|
||||
m_textOutput->SetValue( m_dataModel->Export( GetCurrentBomFmtSettings() ) );
|
||||
|
||||
m_dataModel->SetIncludeExcludedFromBOM( true );
|
||||
m_dataModel->RebuildRows();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1468,7 +1469,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::rebuildBomPresetsWidget()
|
|||
m_cbBomPresets->Append( wxGetTranslation( pair.first ),
|
||||
static_cast<void*>( &pair.second ) );
|
||||
|
||||
if( pair.first == BOM_PRESET::GroupedByValue().name )
|
||||
if( pair.first == BOM_PRESET::DefaultEditing().name )
|
||||
default_idx = idx;
|
||||
|
||||
idx++;
|
||||
|
@ -1790,6 +1791,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::doApplyBomPreset( const BOM_PRESET& aPreset )
|
|||
m_groupSymbolsBox->SetValue( m_dataModel->GetGroupingEnabled() );
|
||||
m_filter->ChangeValue( m_dataModel->GetFilter() );
|
||||
m_checkExcludeDNP->SetValue( m_dataModel->GetExcludeDNP() );
|
||||
m_checkShowExcluded->SetValue( m_dataModel->GetIncludeExcludedFromBOM() );
|
||||
|
||||
SetupAllColumnProperties();
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ private:
|
|||
void OnColumnItemToggled( wxDataViewEvent& event ) override;
|
||||
void OnGroupSymbolsToggled( wxCommandEvent& event ) override;
|
||||
void OnExcludeDNPToggled( wxCommandEvent& event ) override;
|
||||
void OnShowExcludedToggled( wxCommandEvent& event ) override;
|
||||
void OnRegroupSymbols( wxCommandEvent& aEvent ) override;
|
||||
void OnScopeChanged( wxCommandEvent& aEvent ) override;
|
||||
void UpdateScope();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf-dirty)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -100,6 +100,10 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
|
|||
m_checkExcludeDNP = new wxCheckBox( m_rightPanel, wxID_ANY, _("Exclude DNP"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bControls->Add( m_checkExcludeDNP, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
m_checkShowExcluded = new wxCheckBox( m_rightPanel, wxID_ANY, _("Show 'Exclude from BOM'"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_checkShowExcluded->SetValue(true);
|
||||
bControls->Add( m_checkShowExcluded, 0, wxALL, 5 );
|
||||
|
||||
m_staticline32 = new wxStaticLine( m_rightPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
|
||||
bControls->Add( m_staticline32, 0, wxEXPAND | wxALL, 3 );
|
||||
|
||||
|
@ -362,6 +366,7 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
|
|||
m_filter->Connect( wxEVT_MOTION, wxMouseEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnFilterMouseMoved ), NULL, this );
|
||||
m_filter->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnFilterText ), NULL, this );
|
||||
m_checkExcludeDNP->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnExcludeDNPToggled ), NULL, this );
|
||||
m_checkShowExcluded->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnShowExcludedToggled ), NULL, this );
|
||||
m_groupSymbolsBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnGroupSymbolsToggled ), NULL, this );
|
||||
m_bRefresh->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnRegroupSymbols ), NULL, this );
|
||||
m_grid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableValueChanged ), NULL, this );
|
||||
|
@ -400,6 +405,7 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::~DIALOG_SYMBOL_FIELDS_TABLE_BASE()
|
|||
m_filter->Disconnect( wxEVT_MOTION, wxMouseEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnFilterMouseMoved ), NULL, this );
|
||||
m_filter->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnFilterText ), NULL, this );
|
||||
m_checkExcludeDNP->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnExcludeDNPToggled ), NULL, this );
|
||||
m_checkShowExcluded->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnShowExcludedToggled ), NULL, this );
|
||||
m_groupSymbolsBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnGroupSymbolsToggled ), NULL, this );
|
||||
m_bRefresh->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnRegroupSymbols ), NULL, this );
|
||||
m_grid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableValueChanged ), NULL, this );
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf-dirty)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -67,6 +67,7 @@ class DIALOG_SYMBOL_FIELDS_TABLE_BASE : public DIALOG_SHIM
|
|||
wxSearchCtrl* m_filter;
|
||||
wxStaticLine* m_staticline31;
|
||||
wxCheckBox* m_checkExcludeDNP;
|
||||
wxCheckBox* m_checkShowExcluded;
|
||||
wxStaticLine* m_staticline32;
|
||||
wxCheckBox* m_groupSymbolsBox;
|
||||
wxStaticLine* m_staticline3;
|
||||
|
@ -119,6 +120,7 @@ class DIALOG_SYMBOL_FIELDS_TABLE_BASE : public DIALOG_SHIM
|
|||
virtual void OnFilterMouseMoved( wxMouseEvent& event ) { event.Skip(); }
|
||||
virtual void OnFilterText( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnExcludeDNPToggled( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnShowExcludedToggled( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnGroupSymbolsToggled( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRegroupSymbols( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnTableValueChanged( wxGridEvent& event ) { event.Skip(); }
|
||||
|
|
|
@ -524,6 +524,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
|
|||
preset.filterString = aBomJob->m_filterString;
|
||||
preset.groupSymbols = ( aBomJob->m_fieldsGroupBy.size() > 0 );
|
||||
preset.excludeDNP = aBomJob->m_excludeDNP;
|
||||
preset.includeExcludedFromBOM = aBomJob->m_includeExcludedFromBOM;
|
||||
}
|
||||
|
||||
dataModel.ApplyBomPreset( preset );
|
||||
|
|
|
@ -856,6 +856,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::ApplyBomPreset( const BOM_PRESET& aPreset )
|
|||
|
||||
SetFilter( aPreset.filterString );
|
||||
SetExcludeDNP( aPreset.excludeDNP );
|
||||
SetIncludeExcludedFromBOM( aPreset.includeExcludedFromBOM );
|
||||
|
||||
RebuildRows();
|
||||
}
|
||||
|
|
|
@ -199,8 +199,8 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
|
|||
m_params.emplace_back( new PARAM<wxString>( "bom_export_filename",
|
||||
&m_BomExportFileName, "${PROJECTNAME}.csv" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<BOM_PRESET>( "bom_settings",
|
||||
&m_BomSettings, BOM_PRESET::GroupedByValue() ) );
|
||||
m_params.emplace_back(
|
||||
new PARAM<BOM_PRESET>( "bom_settings", &m_BomSettings, BOM_PRESET::DefaultEditing() ) );
|
||||
m_params.emplace_back( new PARAM_LIST<BOM_PRESET>( "bom_presets",
|
||||
&m_BomPresets, {} ) );
|
||||
|
||||
|
|
|
@ -56,9 +56,11 @@ struct KICOMMON_API BOM_PRESET
|
|||
wxString filterString;
|
||||
bool groupSymbols = false;
|
||||
bool excludeDNP = false;
|
||||
bool includeExcludedFromBOM = false;
|
||||
|
||||
bool operator==( const BOM_PRESET& rhs ) const;
|
||||
|
||||
static BOM_PRESET DefaultEditing();
|
||||
static BOM_PRESET GroupedByValue();
|
||||
static BOM_PRESET GroupedByValueFootprint();
|
||||
static BOM_PRESET Attributes();
|
||||
|
|
|
@ -168,6 +168,7 @@ int CLI::SCH_EXPORT_BOM_COMMAND::doPerform( KIWAY& aKiway )
|
|||
bomJob->m_sortAsc = m_argParser.get<bool>( ARG_SORT_ASC );
|
||||
bomJob->m_filterString = From_UTF8( m_argParser.get<std::string>( ARG_FILTER ).c_str() );
|
||||
bomJob->m_excludeDNP = m_argParser.get<bool>( ARG_EXCLUDE_DNP );
|
||||
bomJob->m_includeExcludedFromBOM = m_argParser.get<bool>( ARG_INCLUDE_EXCLUDED_FROM_BOM );
|
||||
|
||||
if( !wxFile::Exists( bomJob->m_filename ) )
|
||||
{
|
||||
|
|
|
@ -77,6 +77,9 @@ namespace CLI
|
|||
#define ARG_EXCLUDE_DNP "--exclude-dnp"
|
||||
#define ARG_EXCLUDE_DNP_DESC "Exclude symbols marked Do-Not-Populate."
|
||||
|
||||
#define ARG_INCLUDE_EXCLUDED_FROM_BOM "--include-excluded-from-bom"
|
||||
#define ARG_INCLUDE_EXCLUDED_FROM_BOM_DESC "Include symbols marked 'Exclude from BOM'."
|
||||
|
||||
class SCH_EXPORT_BOM_COMMAND : public COMMAND
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue