BOM Generator: wire up forced exclusion, optional DNP exclusion
This commit is contained in:
parent
79a829395d
commit
9c3d93eb34
|
@ -88,11 +88,14 @@ const bool operator<( const BOM_PRESET& lhs, const BOM_PRESET& rhs )
|
|||
|
||||
void to_json( nlohmann::json& j, const BOM_PRESET& p )
|
||||
{
|
||||
j = nlohmann::json{ { "name", p.name },
|
||||
{ "sort_field", p.sortField },
|
||||
{ "sort_asc", p.sortAsc },
|
||||
{ "filter_string", p.filterString },
|
||||
{ "group_symbols", p.groupSymbols } };
|
||||
j = nlohmann::json{
|
||||
{ "name", p.name },
|
||||
{ "sort_field", p.sortField },
|
||||
{ "sort_asc", p.sortAsc },
|
||||
{ "filter_string", p.filterString },
|
||||
{ "group_symbols", p.groupSymbols },
|
||||
{ "exclude_dnp", p.excludeDNP },
|
||||
};
|
||||
|
||||
if( p.fieldsOrdered.size() > 0 )
|
||||
j["fields_ordered"] = p.fieldsOrdered;
|
||||
|
@ -107,15 +110,20 @@ void from_json( const nlohmann::json& j, BOM_PRESET& f )
|
|||
j.at( "sort_asc" ).get_to( f.sortAsc );
|
||||
j.at( "filter_string" ).get_to( f.filterString );
|
||||
j.at( "group_symbols" ).get_to( f.groupSymbols );
|
||||
j.at( "exclude_dnp" ).get_to( f.excludeDNP );
|
||||
}
|
||||
|
||||
|
||||
// Implementations for BOM_PRESET
|
||||
bool BOM_PRESET::operator==( const BOM_PRESET& rhs ) const
|
||||
{
|
||||
return this->name == rhs.name && this->readOnly == rhs.readOnly
|
||||
&& this->fieldsOrdered == rhs.fieldsOrdered && this->sortField == rhs.sortField
|
||||
&& this->sortAsc == rhs.sortAsc && this->groupSymbols == rhs.groupSymbols;
|
||||
return this->name == rhs.name
|
||||
&& this->readOnly == rhs.readOnly
|
||||
&& this->fieldsOrdered == rhs.fieldsOrdered
|
||||
&& this->sortField == rhs.sortField
|
||||
&& this->sortAsc == rhs.sortAsc
|
||||
&& this->groupSymbols == rhs.groupSymbols
|
||||
&& this->excludeDNP == rhs.excludeDNP;
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,7 +133,8 @@ BOM_PRESET BOM_PRESET::GroupedByValue()
|
|||
.readOnly = true,
|
||||
.sortField = _( "Reference" ),
|
||||
.sortAsc = true,
|
||||
.groupSymbols = true };
|
||||
.groupSymbols = true,
|
||||
.excludeDNP = false };
|
||||
|
||||
p.fieldsOrdered = std::vector<BOM_FIELD>( {
|
||||
( BOM_FIELD ){
|
||||
|
@ -150,7 +159,8 @@ BOM_PRESET BOM_PRESET::GroupedByValueFootprint()
|
|||
.readOnly = true,
|
||||
.sortField = _( "Reference" ),
|
||||
.sortAsc = true,
|
||||
.groupSymbols = true };
|
||||
.groupSymbols = true,
|
||||
.excludeDNP = false };
|
||||
|
||||
p.fieldsOrdered = std::vector<BOM_FIELD>( {
|
||||
( BOM_FIELD ){
|
||||
|
|
|
@ -193,6 +193,10 @@ 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
|
||||
|
@ -793,6 +797,17 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnGroupSymbolsToggled( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_SYMBOL_FIELDS_TABLE::OnExcludeDNPToggled( wxCommandEvent& event )
|
||||
{
|
||||
m_schSettings.m_BomSettings.excludeDNP = m_checkExludeDNP->GetValue();
|
||||
m_dataModel->SetExcludeDNP( m_checkExludeDNP->GetValue() );
|
||||
m_dataModel->RebuildRows();
|
||||
m_grid->ForceRefresh();
|
||||
|
||||
syncBomPresetSelection();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SYMBOL_FIELDS_TABLE::OnColSort( wxGridEvent& aEvent )
|
||||
{
|
||||
int sortCol = aEvent.GetCol();
|
||||
|
@ -1006,7 +1021,13 @@ void DIALOG_SYMBOL_FIELDS_TABLE::PreviewRefresh()
|
|||
current.keepTabs = m_checkKeepTabs->GetValue();
|
||||
current.keepLineBreaks = m_checkKeepLineBreaks->GetValue();
|
||||
|
||||
m_dataModel->SetIncludeExcludedFromBOM( false );
|
||||
m_dataModel->RebuildRows();
|
||||
|
||||
m_textOutput->SetValue( m_dataModel->Export( current ) );
|
||||
|
||||
m_dataModel->SetIncludeExcludedFromBOM( true );
|
||||
m_dataModel->RebuildRows();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1530,6 +1551,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::doApplyBomPreset( const BOM_PRESET& aPreset )
|
|||
m_grid->SetSortingColumn( m_dataModel->GetSortCol(), m_dataModel->GetSortAsc() );
|
||||
m_groupSymbolsBox->SetValue( m_dataModel->GetGroupingEnabled() );
|
||||
m_filter->ChangeValue( m_dataModel->GetFilter() );
|
||||
m_checkExludeDNP->SetValue( m_dataModel->GetExcludeDNP() );
|
||||
|
||||
SetupColumnProperties();
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ private:
|
|||
|
||||
void OnColumnItemToggled( wxDataViewEvent& event ) override;
|
||||
void OnGroupSymbolsToggled( wxCommandEvent& event ) override;
|
||||
void OnExcludeDNPToggled( wxCommandEvent& event ) override;
|
||||
void OnRegroupSymbols( wxCommandEvent& aEvent ) override;
|
||||
void OnTableValueChanged( wxGridEvent& event ) override;
|
||||
void OnTableCellClick( wxGridEvent& event ) override;
|
||||
|
|
|
@ -93,7 +93,6 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
|
|||
bControls->Add( m_separator1, 0, wxALL, 5 );
|
||||
|
||||
m_checkExludeDNP = new wxCheckBox( m_rightPanel, wxID_ANY, _("Exclude DNP"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_checkExludeDNP->SetValue(true);
|
||||
bControls->Add( m_checkExludeDNP, 0, wxALL, 5 );
|
||||
|
||||
m_separator2 = new BITMAP_BUTTON( m_rightPanel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE );
|
||||
|
@ -159,7 +158,7 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
|
|||
m_panelEdit->SetSizer( bEditSizer );
|
||||
m_panelEdit->Layout();
|
||||
bEditSizer->Fit( m_panelEdit );
|
||||
m_notebook1->AddPage( m_panelEdit, _("Edit"), false );
|
||||
m_notebook1->AddPage( m_panelEdit, _("Edit"), true );
|
||||
m_panelExport = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxGridBagSizer* gbExport;
|
||||
gbExport = new wxGridBagSizer( 0, 0 );
|
||||
|
@ -276,7 +275,7 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
|
|||
m_panelExport->SetSizer( gbExport );
|
||||
m_panelExport->Layout();
|
||||
gbExport->Fit( m_panelExport );
|
||||
m_notebook1->AddPage( m_panelExport, _("Export"), true );
|
||||
m_notebook1->AddPage( m_panelExport, _("Export"), false );
|
||||
|
||||
bMainSizer->Add( m_notebook1, 1, wxEXPAND | wxALL, 5 );
|
||||
|
||||
|
@ -322,6 +321,7 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
|
|||
m_renameFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnRenameField ), NULL, this );
|
||||
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_checkExludeDNP->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnExcludeDNPToggled ), 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 );
|
||||
|
@ -356,6 +356,7 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::~DIALOG_SYMBOL_FIELDS_TABLE_BASE()
|
|||
m_renameFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnRenameField ), NULL, this );
|
||||
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_checkExludeDNP->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnExcludeDNPToggled ), 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 );
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
<object class="notebookpage" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="label">Edit</property>
|
||||
<property name="select">0</property>
|
||||
<property name="select">1</property>
|
||||
<object class="wxPanel" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
|
@ -924,7 +924,7 @@
|
|||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="checked">1</property>
|
||||
<property name="checked">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
|
@ -968,6 +968,7 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnCheckBox">OnExcludeDNPToggled</event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
|
@ -1362,7 +1363,7 @@
|
|||
<object class="notebookpage" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="label">Export</property>
|
||||
<property name="select">1</property>
|
||||
<property name="select">0</property>
|
||||
<object class="wxPanel" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
|
|
|
@ -107,6 +107,7 @@ class DIALOG_SYMBOL_FIELDS_TABLE_BASE : public DIALOG_SHIM
|
|||
virtual void OnRenameField( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnFilterMouseMoved( wxMouseEvent& event ) { event.Skip(); }
|
||||
virtual void OnFilterText( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnExcludeDNPToggled( 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(); }
|
||||
|
|
|
@ -133,7 +133,8 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( int aRow, int aCol )
|
|||
|
||||
wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( const DATA_MODEL_ROW& group, int aCol,
|
||||
const wxString& refDelimiter,
|
||||
const wxString& refRangeDelimiter )
|
||||
const wxString& refRangeDelimiter,
|
||||
bool resolveVars )
|
||||
{
|
||||
std::vector<SCH_REFERENCE> references;
|
||||
wxString fieldValue;
|
||||
|
@ -364,9 +365,13 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows()
|
|||
SCH_REFERENCE ref = m_symbolsList[i];
|
||||
|
||||
if( !m_filter.IsEmpty() && !WildCompareString( m_filter, ref.GetFullRef(), false ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( m_excludeDNP && ref.GetSymbol()->GetDNP() )
|
||||
continue;
|
||||
|
||||
if( !m_includeExcluded && !ref.GetSymbol()->GetIncludeInBom() )
|
||||
continue;
|
||||
|
||||
bool matchFound = false;
|
||||
|
||||
|
@ -633,6 +638,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::ApplyBomPreset( const BOM_PRESET& aPreset )
|
|||
aPreset.sortAsc );
|
||||
|
||||
SetFilter( aPreset.filterString );
|
||||
SetExcludeDNP( aPreset.excludeDNP );
|
||||
|
||||
RebuildRows();
|
||||
}
|
||||
|
@ -699,8 +705,8 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::Export( const BOM_FMT_PRESET& settings )
|
|||
continue;
|
||||
|
||||
// Get the unanottated version of the field, e.g. no "> " or "v " by
|
||||
out.Append( formatField( GetRawValue( (int) row, (int) col, settings.refDelimiter,
|
||||
settings.refRangeDelimiter ),
|
||||
out.Append( formatField( GetExportValue( (int) row, (int) col, settings.refDelimiter,
|
||||
settings.refRangeDelimiter ),
|
||||
col == last_col ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,8 @@ class FIELDS_EDITOR_GRID_DATA_MODEL : public wxGridTableBase
|
|||
public:
|
||||
FIELDS_EDITOR_GRID_DATA_MODEL( SCH_REFERENCE_LIST& aSymbolsList ) :
|
||||
m_symbolsList( aSymbolsList ), m_edited( false ), m_sortColumn( 0 ),
|
||||
m_sortAscending( false ), m_groupingEnabled( false )
|
||||
m_sortAscending( false ), m_groupingEnabled( false ), m_excludeDNP( false ),
|
||||
m_includeExcluded( false )
|
||||
{
|
||||
m_symbolsList.SplitReferences();
|
||||
}
|
||||
|
@ -101,11 +102,12 @@ public:
|
|||
wxString GetValue( int aRow, int aCol ) override;
|
||||
wxString GetValue( const DATA_MODEL_ROW& group, int aCol,
|
||||
const wxString& refDelimiter = wxT( ", " ),
|
||||
const wxString& refRangeDelimiter = wxT( "-" ) );
|
||||
wxString GetRawValue( int aRow, int aCol, const wxString& refDelimiter,
|
||||
const wxString& refRangeDelimiter )
|
||||
const wxString& refRangDelimiter = wxT( "-" ),
|
||||
bool resolveVars = false );
|
||||
wxString GetExportValue( int aRow, int aCol, const wxString& refDelimiter,
|
||||
const wxString& refRangeDelimiter )
|
||||
{
|
||||
return GetValue( m_rows[aRow], aCol, refDelimiter, refRangeDelimiter );
|
||||
return GetValue( m_rows[aRow], aCol, refDelimiter, refRangeDelimiter, true );
|
||||
}
|
||||
void SetValue( int aRow, int aCol, const wxString& aValue ) override;
|
||||
|
||||
|
@ -148,6 +150,16 @@ public:
|
|||
void SetGroupingEnabled( bool group ) { m_groupingEnabled = group; }
|
||||
bool GetGroupingEnabled() { return m_groupingEnabled; }
|
||||
|
||||
/* These contradictorily named functions force including symbols that
|
||||
* have the Exclude from BOM check box ticked. This is needed so we can view
|
||||
* these parts in the symbol fields table dialog, while also excluding from the
|
||||
* BOM export */
|
||||
void SetIncludeExcludedFromBOM( bool include ) { m_includeExcluded = include; }
|
||||
bool GetIncludeExcludedFromBOM() { return m_includeExcluded; }
|
||||
|
||||
void SetExcludeDNP( bool exclude ) { m_excludeDNP = exclude; }
|
||||
bool GetExcludeDNP() { return m_excludeDNP; }
|
||||
|
||||
void SetGroupColumn( int aCol, bool group )
|
||||
{
|
||||
wxCHECK_RET( aCol >= 0 && aCol < (int) m_cols.size(), "Invalid Column Number" );
|
||||
|
@ -189,6 +201,8 @@ protected:
|
|||
bool m_sortAscending;
|
||||
wxString m_filter;
|
||||
bool m_groupingEnabled;
|
||||
bool m_excludeDNP;
|
||||
bool m_includeExcluded;
|
||||
|
||||
std::vector<DATA_MODEL_COL> m_cols;
|
||||
std::vector<DATA_MODEL_ROW> m_rows;
|
||||
|
|
|
@ -55,6 +55,7 @@ struct BOM_PRESET
|
|||
bool sortAsc = true;
|
||||
wxString filterString;
|
||||
bool groupSymbols = false;
|
||||
bool excludeDNP = false;
|
||||
|
||||
bool operator==( const BOM_PRESET& rhs ) const;
|
||||
|
||||
|
|
|
@ -62,6 +62,11 @@ CLI::EXPORT_SCH_BOM_COMMAND::EXPORT_SCH_BOM_COMMAND() : EXPORT_PCB_BASE_COMMAND(
|
|||
.implicit_value( true )
|
||||
.default_value( true );
|
||||
|
||||
m_argParser.add_argument( ARG_EXCLUDE_DNP )
|
||||
.help( UTF8STDSTR( _( ARG_EXCLUDE_DNP_DESC ) ) )
|
||||
.implicit_value( true )
|
||||
.default_value( true );
|
||||
|
||||
// Output formatting options
|
||||
m_argParser.add_argument( ARG_FIELD_DELIMITER )
|
||||
.help( UTF8STDSTR( _( ARG_FIELD_DELIMITER_DESC ) ) )
|
||||
|
@ -136,6 +141,7 @@ int CLI::EXPORT_SCH_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_groupSymbols = m_argParser.get<bool>( ARG_GROUP_SYMBOLS );
|
||||
bomJob->m_groupSymbols = m_argParser.get<bool>( ARG_EXCLUDE_DNP );
|
||||
|
||||
if( !wxFile::Exists( bomJob->m_filename ) )
|
||||
{
|
||||
|
|
|
@ -67,6 +67,9 @@ namespace CLI
|
|||
#define ARG_GROUP_SYMBOLS "--group"
|
||||
#define ARG_GROUP_SYMBOLS_DESC "Enable grouping of references with matching group-by fields."
|
||||
|
||||
#define ARG_EXCLUDE_DNP "--exclude-dnp"
|
||||
#define ARG_EXCLUDE_DNP_DESC "Exclude symbols marked Do-Not-Populate."
|
||||
|
||||
class EXPORT_SCH_BOM_COMMAND : public EXPORT_PCB_BASE_COMMAND
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue