From bdecdce1b4fa178072fc7a7b51bcef129b9a93cb Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Tue, 8 Aug 2023 12:32:08 -0400 Subject: [PATCH] Exclude from Sim: move from field to attribute --- eeschema/dialogs/dialog_change_symbols.cpp | 1 + .../dialogs/dialog_lib_symbol_properties.cpp | 60 ++----------------- .../dialogs/dialog_lib_symbol_properties.h | 1 - .../dialog_lib_symbol_properties_base.cpp | 8 +-- .../dialog_lib_symbol_properties_base.fbp | 4 +- .../dialog_lib_symbol_properties_base.h | 3 +- eeschema/dialogs/dialog_symbol_properties.cpp | 56 +---------------- eeschema/dialogs/dialog_symbol_properties.h | 3 +- .../dialogs/dialog_symbol_properties_base.cpp | 5 +- .../dialogs/dialog_symbol_properties_base.fbp | 4 +- .../dialogs/dialog_symbol_properties_base.h | 1 - eeschema/dialogs/dialog_text_properties.cpp | 4 +- eeschema/erc.cpp | 2 +- eeschema/fields_data_model.cpp | 4 +- eeschema/lib_symbol.cpp | 13 ++++ eeschema/lib_symbol.h | 11 +++- .../netlist_exporter_spice.cpp | 4 +- eeschema/sch_edit_frame.cpp | 2 +- eeschema/sch_file_versions.h | 3 +- eeschema/sch_item.h | 4 +- .../database/sch_database_plugin.cpp | 17 ++++++ .../kicad/sch_sexpr_lib_plugin_cache.cpp | 2 + .../sch_plugins/kicad/sch_sexpr_parser.cpp | 30 +++++++++- .../sch_plugins/kicad/sch_sexpr_plugin.cpp | 9 +-- eeschema/sch_symbol.cpp | 37 +++--------- eeschema/sch_symbol.h | 15 ++--- eeschema/sch_text.cpp | 10 ++-- eeschema/sch_text.h | 6 +- eeschema/sch_textbox.cpp | 10 ++-- eeschema/sch_textbox.h | 6 +- eeschema/sim/sim_model.cpp | 35 +++-------- eeschema/sim/sim_model.h | 8 +++ eeschema/sim/sim_model_raw_spice.h | 6 -- eeschema/tools/sch_edit_tool.cpp | 6 +- include/database/database_lib_settings.h | 1 + 35 files changed, 161 insertions(+), 230 deletions(-) diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 0432547711..b77ef0731f 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -594,6 +594,7 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( SCH_COMMIT* aCommit, { // Fetch the attributes from the *flattened* library symbol. They are not supported // in derived symbols. + symbol->SetExcludedFromSim( symbol->GetLibSymbolRef()->GetExcludedFromSim() ); symbol->SetExcludedFromBOM( symbol->GetLibSymbolRef()->GetExcludedFromBOM() ); symbol->SetExcludedFromBoard( symbol->GetLibSymbolRef()->GetExcludedFromBoard() ); } diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index 1e42040029..8c3a4ca201 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -182,9 +182,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow() if( m_libEntry->IsPower() ) m_spiceFieldsButton->Hide(); - LIB_FIELD* simEnableField = m_libEntry->FindField( SIM_ENABLE_FIELD ); - m_excludeFromSim->SetValue( simEnableField && simEnableField->GetText() == wxT( "0" ) ); - + m_excludeFromSimCheckBox->SetValue( m_libEntry->GetExcludedFromSim() ); m_excludeFromBomCheckBox->SetValue( m_libEntry->GetExcludedFromBOM() ); m_excludeFromBoardCheckBox->SetValue( m_libEntry->GetExcludedFromBoard() ); @@ -227,45 +225,6 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow() } -void DIALOG_LIB_SYMBOL_PROPERTIES::OnExcludeFromSimulation( wxCommandEvent& event ) -{ - int simEnableFieldRow = -1; - - for( int ii = MANDATORY_FIELDS; ii < m_grid->GetNumberRows(); ++ii ) - { - if( m_grid->GetCellValue( ii, FDC_NAME ) == SIM_ENABLE_FIELD ) - simEnableFieldRow = ii; - } - - if( event.IsChecked() ) - { - if( simEnableFieldRow == -1 ) - { - simEnableFieldRow = (int) m_fields->size(); - m_fields->emplace_back( m_libEntry, simEnableFieldRow, SIM_ENABLE_FIELD ); - - // notify the grid - wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 ); - m_grid->ProcessTableMessage( msg ); - } - - m_grid->SetCellValue( simEnableFieldRow, FDC_VALUE, wxT( "0" ) ); - m_grid->SetCellValue( simEnableFieldRow, FDC_SHOWN, wxT( "0" ) ); - m_grid->SetCellValue( simEnableFieldRow, FDC_SHOW_NAME, wxT( "0" ) ); - } - else if( simEnableFieldRow >= 0 ) - { - m_fields->erase( m_fields->begin() + simEnableFieldRow ); - - // notify the grid - wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, simEnableFieldRow, 1 ); - m_grid->ProcessTableMessage( msg ); - } - - OnModify(); -} - - bool DIALOG_LIB_SYMBOL_PROPERTIES::Validate() { if( !m_grid->CommitPendingChanges() ) @@ -437,6 +396,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() m_libEntry->SetNormal(); } + m_libEntry->SetExcludedFromSim( m_excludeFromSimCheckBox->GetValue() ); m_libEntry->SetExcludedFromBOM( m_excludeFromBomCheckBox->GetValue() ); m_libEntry->SetExcludedFromBoard( m_excludeFromBoardCheckBox->GetValue() ); @@ -895,19 +855,6 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) m_delayedFocusRow = -1; m_delayedFocusColumn = -1; } - - wxString simEnable; - - for( int ii = MANDATORY_FIELDS; ii < m_fields->GetNumberRows(); ++ii ) - { - if( m_fields->GetValue( ii, FDC_NAME ) == SIM_ENABLE_FIELD ) - { - simEnable = m_fields->GetValue( ii, FDC_VALUE ); - break; - } - } - - m_excludeFromSim->SetValue( simEnable == wxS( "0" ) ); } @@ -940,16 +887,19 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::onPowerCheckBox( wxCommandEvent& aEvent ) { if( m_OptionPower->IsChecked() ) { + m_excludeFromSimCheckBox->SetValue( true ); m_excludeFromBomCheckBox->SetValue( true ); m_excludeFromBoardCheckBox->SetValue( true ); m_excludeFromBomCheckBox->Enable( false ); m_excludeFromBoardCheckBox->Enable( false ); + m_excludeFromSimCheckBox->Enable( false ); m_spiceFieldsButton->Show( false ); } else { m_excludeFromBomCheckBox->Enable( true ); m_excludeFromBoardCheckBox->Enable( true ); + m_excludeFromSimCheckBox->Enable( true ); m_spiceFieldsButton->Show( true ); } diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.h b/eeschema/dialogs/dialog_lib_symbol_properties.h index a6efd7c485..930379721c 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.h +++ b/eeschema/dialogs/dialog_lib_symbol_properties.h @@ -70,7 +70,6 @@ private: void OnUpdateUI( wxUpdateUIEvent& event ) override; void OnFilterDClick( wxMouseEvent& event ) override; void OnCancelButtonClick( wxCommandEvent& event ) override; - void OnExcludeFromSimulation( wxCommandEvent& event ) override; void adjustGridColumns(); void syncControlStates( bool aIsAlias ); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp b/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp index 09d384023d..711f4426fa 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp @@ -267,8 +267,8 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* wxStaticBoxSizer* sbSizerAttributes; sbSizerAttributes = new wxStaticBoxSizer( new wxStaticBox( m_PanelBasic, wxID_ANY, _("Attributes") ), wxVERTICAL ); - m_excludeFromSim = new wxCheckBox( sbSizerAttributes->GetStaticBox(), wxID_ANY, _("Exclude from simulation"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizerAttributes->Add( m_excludeFromSim, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_excludeFromSimCheckBox = new wxCheckBox( sbSizerAttributes->GetStaticBox(), wxID_ANY, _("Exclude from simulation"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerAttributes->Add( m_excludeFromSimCheckBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); sbSizerAttributes->Add( 0, 10, 0, wxEXPAND, 5 ); @@ -397,7 +397,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* m_ShowPinNameButt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_PinsNameInsideButt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_nameOffsetCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnText ), NULL, this ); - m_excludeFromSim->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnExcludeFromSimulation ), NULL, this ); + m_excludeFromSimCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_excludeFromBomCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_excludeFromBoardCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_FootprintFilterListBox->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnFilterDClick ), NULL, this ); @@ -432,7 +432,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::~DIALOG_LIB_SYMBOL_PROPERTIES_BASE() m_ShowPinNameButt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_PinsNameInsideButt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_nameOffsetCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnText ), NULL, this ); - m_excludeFromSim->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnExcludeFromSimulation ), NULL, this ); + m_excludeFromSimCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_excludeFromBomCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_excludeFromBoardCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_FootprintFilterListBox->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnFilterDClick ), NULL, this ); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp b/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp index df864dccae..da444df47d 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp @@ -1903,7 +1903,7 @@ 0 1 - m_excludeFromSim + m_excludeFromSimCheckBox 1 @@ -1924,7 +1924,7 @@ - OnExcludeFromSimulation + OnCheckBox diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.h b/eeschema/dialogs/dialog_lib_symbol_properties_base.h index d2a2c6df7c..01eafc34c2 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.h +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.h @@ -74,7 +74,7 @@ class DIALOG_LIB_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_nameOffsetLabel; wxTextCtrl* m_nameOffsetCtrl; wxStaticText* m_nameOffsetUnits; - wxCheckBox* m_excludeFromSim; + wxCheckBox* m_excludeFromSimCheckBox; wxCheckBox* m_excludeFromBomCheckBox; wxCheckBox* m_excludeFromBoardCheckBox; wxPanel* m_PanelFootprintFilter; @@ -103,7 +103,6 @@ class DIALOG_LIB_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM virtual void OnSpinCtrlText( wxCommandEvent& event ) { event.Skip(); } virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); } virtual void onPowerCheckBox( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExcludeFromSimulation( wxCommandEvent& event ) { event.Skip(); } virtual void OnFilterDClick( wxMouseEvent& event ) { event.Skip(); } virtual void OnEditFootprintFilter( wxCommandEvent& event ) { event.Skip(); } virtual void OnAddFootprintFilter( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index aaba70cfb3..6aa0294bfb 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -511,7 +511,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow() case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break; } - m_cbExcludeFromSim->SetValue( m_symbol->GetFieldText( SIM_ENABLE_FIELD ) == wxS( "0" ) ); + m_cbExcludeFromSim->SetValue( m_symbol->GetExcludedFromSim() ); m_cbExcludeFromBom->SetValue( m_symbol->GetExcludedFromBOM() ); m_cbExcludeFromBoard->SetValue( m_symbol->GetExcludedFromBoard() ); m_cbDNP->SetValue( m_symbol->GetDNP() ); @@ -533,45 +533,6 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow() } -void DIALOG_SYMBOL_PROPERTIES::OnExcludeFromSimulation( wxCommandEvent& event ) -{ - int simEnableFieldRow = -1; - - for( int ii = MANDATORY_FIELDS; ii < m_fieldsGrid->GetNumberRows(); ++ii ) - { - if( m_fieldsGrid->GetCellValue( ii, FDC_NAME ) == SIM_ENABLE_FIELD ) - simEnableFieldRow = ii; - } - - if( event.IsChecked() ) - { - if( simEnableFieldRow == -1 ) - { - simEnableFieldRow = (int) m_fields->size(); - m_fields->emplace_back( VECTOR2I( 0, 0 ), simEnableFieldRow, m_symbol, SIM_ENABLE_FIELD ); - - // notify the grid - wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 ); - m_fieldsGrid->ProcessTableMessage( msg ); - } - - m_fieldsGrid->SetCellValue( simEnableFieldRow, FDC_VALUE, wxT( "0" ) ); - m_fieldsGrid->SetCellValue( simEnableFieldRow, FDC_SHOWN, wxT( "0" ) ); - m_fieldsGrid->SetCellValue( simEnableFieldRow, FDC_SHOW_NAME, wxT( "0" ) ); - } - else if( simEnableFieldRow >= 0 ) - { - m_fields->erase( m_fields->begin() + simEnableFieldRow ); - - // notify the grid - wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, simEnableFieldRow, 1 ); - m_fieldsGrid->ProcessTableMessage( msg ); - } - - OnModify(); -} - - void DIALOG_SYMBOL_PROPERTIES::OnEditSpiceModel( wxCommandEvent& event ) { if( !m_fieldsGrid->CommitPendingChanges() ) @@ -780,6 +741,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() m_symbol->SetValueFieldText( m_fields->at( VALUE_FIELD ).GetText() ); m_symbol->SetFootprintFieldText( m_fields->at( FOOTPRINT_FIELD ).GetText() ); + m_symbol->SetExcludedFromSim( m_cbExcludeFromSim->IsChecked() ); m_symbol->SetExcludedFromBOM( m_cbExcludeFromBom->IsChecked() ); m_symbol->SetExcludedFromBoard( m_cbExcludeFromBoard->IsChecked() ); m_symbol->SetDNP( m_cbDNP->IsChecked() ); @@ -847,6 +809,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() otherUnit->GetFields().erase( otherUnit->GetFields().begin() + ii ); } + otherUnit->SetExcludedFromSim( m_cbExcludeFromSim->IsChecked() ); otherUnit->SetExcludedFromBOM( m_cbExcludeFromBom->IsChecked() ); otherUnit->SetExcludedFromBoard( m_cbExcludeFromBoard->IsChecked() ); otherUnit->SetDNP( m_cbDNP->IsChecked() ); @@ -1168,19 +1131,6 @@ void DIALOG_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) if( !m_fieldsGrid->IsCellEditControlShown() ) AdjustFieldsGridColumns(); } - - wxString simEnable; - - for( int ii = MANDATORY_FIELDS; ii < m_fieldsGrid->GetNumberRows(); ++ii ) - { - if( m_fieldsGrid->GetCellValue( ii, FDC_NAME ) == SIM_ENABLE_FIELD ) - { - simEnable = m_fieldsGrid->GetCellValue( ii, FDC_VALUE ); - break; - } - } - - m_cbExcludeFromSim->SetValue( simEnable == wxS( "0" ) ); } diff --git a/eeschema/dialogs/dialog_symbol_properties.h b/eeschema/dialogs/dialog_symbol_properties.h index f85d72905b..8bc9492ebf 100644 --- a/eeschema/dialogs/dialog_symbol_properties.h +++ b/eeschema/dialogs/dialog_symbol_properties.h @@ -83,8 +83,7 @@ private: void OnGridEditorShown( wxGridEvent& event ) override; void OnGridEditorHidden( wxGridEvent& event ) override; void OnUnitChoice( wxCommandEvent& event ) override; - void OnCheckBox( wxCommandEvent& event ) override; - void OnExcludeFromSimulation( wxCommandEvent& event ) override; + void OnCheckBox( wxCommandEvent& event ) override; void OnEditSymbol( wxCommandEvent& ) override; void OnEditLibrarySymbol( wxCommandEvent& ) override; diff --git a/eeschema/dialogs/dialog_symbol_properties_base.cpp b/eeschema/dialogs/dialog_symbol_properties_base.cpp index b8878e12fd..7d2100388f 100644 --- a/eeschema/dialogs/dialog_symbol_properties_base.cpp +++ b/eeschema/dialogs/dialog_symbol_properties_base.cpp @@ -199,7 +199,6 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent, sbAttributes = new wxStaticBoxSizer( new wxStaticBox( generalPage, wxID_ANY, _("Attributes") ), wxVERTICAL ); m_cbExcludeFromSim = new wxCheckBox( sbAttributes->GetStaticBox(), wxID_ANY, _("Exclude from simulation"), wxDefaultPosition, wxDefaultSize, 0 ); - m_cbExcludeFromSim->SetValue(true); sbAttributes->Add( m_cbExcludeFromSim, 0, wxRIGHT|wxLEFT, 5 ); @@ -362,7 +361,7 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent, m_mirrorCtrl->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnChoice ), NULL, this ); m_ShowPinNumButt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_ShowPinNameButt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); - m_cbExcludeFromSim->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnExcludeFromSimulation ), NULL, this ); + m_cbExcludeFromSim->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_cbExcludeFromBom->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_cbExcludeFromBoard->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_updateSymbolBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnUpdateSymbol ), NULL, this ); @@ -395,7 +394,7 @@ DIALOG_SYMBOL_PROPERTIES_BASE::~DIALOG_SYMBOL_PROPERTIES_BASE() m_mirrorCtrl->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnChoice ), NULL, this ); m_ShowPinNumButt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_ShowPinNameButt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); - m_cbExcludeFromSim->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnExcludeFromSimulation ), NULL, this ); + m_cbExcludeFromSim->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_cbExcludeFromBom->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_cbExcludeFromBoard->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_updateSymbolBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnUpdateSymbol ), NULL, this ); diff --git a/eeschema/dialogs/dialog_symbol_properties_base.fbp b/eeschema/dialogs/dialog_symbol_properties_base.fbp index f8aaa68548..78e6c2e186 100644 --- a/eeschema/dialogs/dialog_symbol_properties_base.fbp +++ b/eeschema/dialogs/dialog_symbol_properties_base.fbp @@ -1296,7 +1296,7 @@ 1 0 - 1 + 0 1 1 @@ -1340,7 +1340,7 @@ - OnExcludeFromSimulation + OnCheckBox diff --git a/eeschema/dialogs/dialog_symbol_properties_base.h b/eeschema/dialogs/dialog_symbol_properties_base.h index 973dd3a8d9..3980f7da53 100644 --- a/eeschema/dialogs/dialog_symbol_properties_base.h +++ b/eeschema/dialogs/dialog_symbol_properties_base.h @@ -93,7 +93,6 @@ class DIALOG_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM virtual void OnUnitChoice( wxCommandEvent& event ) { event.Skip(); } virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); } virtual void OnChoice( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExcludeFromSimulation( wxCommandEvent& event ) { event.Skip(); } virtual void OnUpdateSymbol( wxCommandEvent& event ) { event.Skip(); } virtual void OnExchangeSymbol( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditSymbol( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index 12ab5c3800..d3f5ab5689 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -262,7 +262,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() m_textCtrl->SetValue( schematic.ConvertKIIDsToRefs( m_currentText->GetText() ) ); m_textCtrl->EmptyUndoBuffer(); - m_excludeFromSim->SetValue( m_currentItem->GetExcludeFromSim() ); + m_excludeFromSim->SetValue( m_currentItem->GetExcludedFromSim() ); m_fontCtrl->SetFontSelection( m_currentText->GetFont() ); m_textSize.SetValue( m_currentText->GetTextWidth() ); @@ -482,7 +482,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() return false; } - m_currentItem->SetExcludeFromSim( m_excludeFromSim->GetValue() ); + m_currentItem->SetExcludedFromSim( m_excludeFromSim->GetValue() ); if( !m_currentText->ValidateHyperlink( m_hyperlinkCombo->GetValue() ) ) { diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 9227ebe26f..ad7eec292b 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -1032,7 +1032,7 @@ int ERC_TESTER::TestSimModelIssues() // Power symbols and other symbols which have the reference starting with "#" are // not included in simulation - if( symbol->GetRef( &sheet ).StartsWith( '#' ) || symbol->GetExcludeFromSim() ) + if( symbol->GetRef( &sheet ).StartsWith( '#' ) || symbol->GetExcludedFromSim() ) continue; // Reset for each symbol diff --git a/eeschema/fields_data_model.cpp b/eeschema/fields_data_model.cpp index 08aa0bf685..5af17c8e49 100644 --- a/eeschema/fields_data_model.cpp +++ b/eeschema/fields_data_model.cpp @@ -430,7 +430,7 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::getAttributeValue( const SCH_REFERENCE& return aRef.GetSymbol()->GetExcludedFromBOM() ? wxS( "1" ) : wxS( "0" ); if( aAttributeName == wxS( "${EXCLUDE_FROM_SIM}" ) ) - return aRef.GetSymbol()->GetExcludeFromSim() ? wxS( "1" ) : wxS( "0" ); + return aRef.GetSymbol()->GetExcludedFromSim() ? wxS( "1" ) : wxS( "0" ); return wxS( "0" ); } @@ -446,7 +446,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::setAttributeValue( const SCH_REFERENCE& aRef else if( aAttributeName == wxS( "${EXCLUDE_FROM_BOM}" ) ) aRef.GetSymbol()->SetExcludedFromBOM( aValue == wxS( "1" ) ); else if( aAttributeName == wxS( "${EXCLUDE_FROM_SIM}" ) ) - aRef.GetSymbol()->SetExcludeFromSim( aValue == wxS( "1" ) ); + aRef.GetSymbol()->SetExcludedFromSim( aValue == wxS( "1" ) ); } diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 6197dfa6d3..df41cae708 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -108,6 +108,7 @@ struct null_deleter LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, SYMBOL_LIB* aLibrary ) : EDA_ITEM( LIB_SYMBOL_T ), m_me( this, null_deleter() ), + m_excludedFromSim( false ), m_excludedFromBOM( false ), m_excludedFromBoard( false ) { @@ -147,6 +148,7 @@ LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) : m_unitsLocked = aSymbol.m_unitsLocked; m_pinNameOffset = aSymbol.m_pinNameOffset; m_showPinNumbers = aSymbol.m_showPinNumbers; + m_excludedFromSim = aSymbol.m_excludedFromSim; m_excludedFromBOM = aSymbol.m_excludedFromBOM; m_excludedFromBoard = aSymbol.m_excludedFromBoard; m_showPinNames = aSymbol.m_showPinNames; @@ -200,6 +202,7 @@ const LIB_SYMBOL& LIB_SYMBOL::operator=( const LIB_SYMBOL& aSymbol ) m_pinNameOffset = aSymbol.m_pinNameOffset; m_showPinNumbers = aSymbol.m_showPinNumbers; m_showPinNames = aSymbol.m_showPinNames; + m_excludedFromSim = aSymbol.m_excludedFromSim; m_excludedFromBOM = aSymbol.m_excludedFromBOM; m_excludedFromBoard = aSymbol.m_excludedFromBoard; m_lastModDate = aSymbol.m_lastModDate; @@ -467,6 +470,15 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR return retv; } + if( m_excludedFromSim != aRhs.m_excludedFromSim ) + { + retv = ( m_excludedFromSim ) ? -1 : 1; + REPORT( _( "Exclude from simulation settings differ." ) ); + + if( !aReporter ) + return retv; + } + if( m_excludedFromBOM != aRhs.m_excludedFromBOM ) { retv = ( m_excludedFromBOM ) ? -1 : 1; @@ -634,6 +646,7 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const retv->SetKeyWords( m_keyWords.IsEmpty() ? parent->GetKeyWords() : m_keyWords ); retv->SetFPFilters( m_fpFilters.IsEmpty() ? parent->GetFPFilters() : m_fpFilters ); + retv->SetExcludedFromSim( parent->GetExcludedFromSim() ); retv->SetExcludedFromBOM( parent->GetExcludedFromBOM() ); retv->SetExcludedFromBoard( parent->GetExcludedFromBoard() ); diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index affabf80c8..8c04609740 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -294,7 +294,7 @@ public: * or NULL if not found. * @param aFieldName is the name of the field to find. * @param aCaseInsensitive ignore the filed name case if true. - * + * * @return the field if found or NULL if the field was not found. */ LIB_FIELD* FindField( const wxString& aFieldName, bool aCaseInsensitive = false ); @@ -653,6 +653,14 @@ public: void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; } bool ShowPinNumbers() const { return m_showPinNumbers; } + /** + * Set or clear the exclude from simulation flag. + * + * @param aExcludeFromSim true to exclude symbol from simulation + */ + void SetExcludedFromSim( bool aExcludeFromSim ) { m_excludedFromSim = aExcludeFromSim; } + bool GetExcludedFromSim() const { return m_excludedFromSim; } + /** * Set or clear the exclude from schematic bill of materials flag. * @@ -759,6 +767,7 @@ private: bool m_showPinNames; bool m_showPinNumbers; + bool m_excludedFromSim; bool m_excludedFromBOM; bool m_excludedFromBoard; LIBRENTRYOPTIONS m_options; ///< Special symbol features such as POWER or NORMAL.) diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.cpp b/eeschema/netlist_exporters/netlist_exporter_spice.cpp index 45520d21be..9a0086ac3f 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_spice.cpp @@ -210,7 +210,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions { SCH_SYMBOL* symbol = findNextSymbol( item, &sheet ); - if( !symbol || symbol->GetExcludeFromSim() ) + if( !symbol || symbol->GetExcludedFromSim() ) continue; SPICE_ITEM spiceItem; @@ -332,7 +332,7 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions ) { for( SCH_ITEM* item : sheet.LastScreen()->Items() ) { - if( item->GetExcludeFromSim() ) + if( item->GetExcludedFromSim() ) continue; if( item->Type() == SCH_TEXT_T ) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index f3e4a14737..3f97d073ba 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1490,7 +1490,7 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay() // Power symbols and other symbols which have the reference starting with "#" are // not included in simulation - if( ref.StartsWith( '#' ) || symbol->GetExcludeFromSim() ) + if( ref.StartsWith( '#' ) || symbol->GetExcludedFromSim() ) continue; for( SCH_PIN* pin : pins ) diff --git a/eeschema/sch_file_versions.h b/eeschema/sch_file_versions.h index cabceb15ca..d6c141202f 100644 --- a/eeschema/sch_file_versions.h +++ b/eeschema/sch_file_versions.h @@ -98,4 +98,5 @@ //#define SEXPR_SCHEMATIC_FILE_VERSION 20230121 // SCH_MARKER specific sheet path serialisation //#define SEXPR_SCHEMATIC_FILE_VERSION 20230221 // Modern power symbols (editable value = net) //#define SEXPR_SCHEMATIC_FILE_VERSION 20230409 // Add exclude_from_sim markup -#define SEXPR_SCHEMATIC_FILE_VERSION 20230620 // ki_description -> Description Field +//#define SEXPR_SCHEMATIC_FILE_VERSION 20230620 // ki_description -> Description Field +#define SEXPR_SCHEMATIC_FILE_VERSION 20230808 // Move Sim.Enable field to exclude_from_sim attr diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index a0abc024e4..f4ea44816f 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -206,8 +206,8 @@ public: */ SCH_ITEM* Duplicate( bool doClone = false ) const; - virtual void SetExcludeFromSim( bool aExclude ) { } - virtual bool GetExcludeFromSim() const { return false; } + virtual void SetExcludedFromSim( bool aExclude ) { } + virtual bool GetExcludedFromSim() const { return false; } /** * @return true for items which are moved with the anchor point at mouse cursor diff --git a/eeschema/sch_plugins/database/sch_database_plugin.cpp b/eeschema/sch_plugins/database/sch_database_plugin.cpp index 7f94d7b8af..fdce5e266a 100644 --- a/eeschema/sch_plugins/database/sch_database_plugin.cpp +++ b/eeschema/sch_plugins/database/sch_database_plugin.cpp @@ -331,6 +331,7 @@ void SCH_DATABASE_PLUGIN::connect() columns.insert( tableIter.properties.description ); columns.insert( tableIter.properties.footprint_filters ); columns.insert( tableIter.properties.keywords ); + columns.insert( tableIter.properties.exclude_from_sim ); columns.insert( tableIter.properties.exclude_from_bom ); columns.insert( tableIter.properties.exclude_from_board ); @@ -483,6 +484,22 @@ LIB_SYMBOL* SCH_DATABASE_PLUGIN::loadSymbolFromRow( const wxString& aSymbolName, symbol->SetFPFilters( filters ); } + if( !aTable.properties.exclude_from_sim.empty() + && aRow.count( aTable.properties.exclude_from_sim ) ) + { + std::optional val = boolFromAny( aRow.at( aTable.properties.exclude_from_sim ) ); + + if( val ) + { + symbol->SetExcludedFromSim( *val ); + } + else + { + wxLogTrace( traceDatabase, wxT( "loadSymbolFromRow: exclude_from_sim value for %s " + "could not be cast to a boolean" ), aSymbolName ); + } + } + if( !aTable.properties.exclude_from_board.empty() && aRow.count( aTable.properties.exclude_from_board ) ) { diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp index 0cbd65fa27..ec00ac20da 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp @@ -181,6 +181,8 @@ void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& a aFormatter.Print( 0, ")" ); } + aFormatter.Print( 0, " (exclude_from_sim %s)", + ( aSymbol->GetExcludedFromSim() ) ? "yes" : "no" ); aFormatter.Print( 0, " (in_bom %s)", ( aSymbol->GetExcludedFromBOM() ) ? "no" : "yes" ); aFormatter.Print( 0, " (on_board %s)", ( aSymbol->GetExcludedFromBoard() ) ? "no" : "yes" ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 1f716b2626..701dc1bbdb 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -60,6 +60,7 @@ #include #include #include +#include using namespace TSCHEMATIC_T; @@ -274,6 +275,11 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLibMap ) NeedRIGHT(); break; + case T_exclude_from_sim: + symbol->SetExcludedFromSim( parseBool() ); + NeedRIGHT(); + break; + case T_in_bom: symbol->SetExcludedFromBOM( !parseBool() ); NeedRIGHT(); @@ -2734,6 +2740,11 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol() NeedRIGHT(); break; + case T_exclude_from_sim: + symbol->SetExcludedFromSim( parseBool() ); + NeedRIGHT(); + break; + case T_in_bom: symbol->SetExcludedFromBOM( !parseBool() ); NeedRIGHT(); @@ -2886,6 +2897,21 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol() // the field positions are set. field = parseSchField( symbol.get() ); + // Exclude from simulation used to be managed by a Sim.Enable field set to "0" when + // simulation was disabled. + if( field->GetCanonicalName() == SIM_ENABLE_FIELD ) + { + symbol->SetExcludedFromSim( field->GetText() == wxS( "0" ) ); + break; + } + + // Even longer ago, we had a "Spice_Netlist_Enabled" field + if( field->GetCanonicalName() == SIM_LEGACY_ENABLE_FIELD ) + { + symbol->SetExcludedFromSim( field->GetText() == wxS( "N" ) ); + break; + } + if( ( field->GetId() >= MANDATORY_FIELDS ) && m_fieldIDsRead.count( field->GetId() ) ) { int nextAvailableId = field->GetId() + 1; @@ -3800,7 +3826,7 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() switch( token ) { case T_exclude_from_sim: - text->SetExcludeFromSim( parseBool() ); + text->SetExcludedFromSim( parseBool() ); NeedRIGHT(); break; @@ -3983,7 +4009,7 @@ SCH_TEXTBOX* SCH_SEXPR_PARSER::parseSchTextBox() switch( token ) { case T_exclude_from_sim: - textBox->SetExcludeFromSim( parseBool() ); + textBox->SetExcludedFromSim( parseBool() ); NeedRIGHT(); break; diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 913f949be7..81dd622963 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -724,7 +724,9 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchema m_out->Print( 0, "\n" ); - m_out->Print( aNestLevel + 1, "(in_bom %s)", ( aSymbol->GetExcludedFromBOM() ) ? "no" : "yes" ); + m_out->Print( aNestLevel + 1, "(exclude_from_sim %s)", + ( aSymbol->GetExcludedFromSim() ) ? "yes" : "no" ); + m_out->Print( 0, " (in_bom %s)", ( aSymbol->GetExcludedFromBOM() ) ? "no" : "yes" ); m_out->Print( 0, " (on_board %s)", ( aSymbol->GetExcludedFromBoard() ) ? "no" : "yes" ); m_out->Print( 0, " (dnp %s)", ( aSymbol->GetDNP() ) ? "yes" : "no" ); @@ -1270,8 +1272,7 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) if( aText->Type() == SCH_TEXT_T ) { - m_out->Print( 0, " (exclude_from_sim %s)\n", - aText->GetExcludeFromSim() ? "yes" : "no" ); + m_out->Print( 0, " (exclude_from_sim %s)\n", aText->GetExcludedFromSim() ? "yes" : "no" ); } else if( aText->Type() == SCH_DIRECTIVE_LABEL_T ) { @@ -1354,7 +1355,7 @@ void SCH_SEXPR_PLUGIN::saveTextBox( SCH_TEXTBOX* aTextBox, int aNestLevel ) VECTOR2I size = aTextBox->GetEnd() - pos; m_out->Print( aNestLevel + 1, "(exclude_from_sim %s) (at %s %s %s) (size %s %s)\n", - aTextBox->GetExcludeFromSim() ? "yes" : "no", + aTextBox->GetExcludedFromSim() ? "yes" : "no", EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.x ).c_str(), EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.y ).c_str(), EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(), diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index e9ea03e0d9..2bd0a110e8 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -42,7 +42,6 @@ #include #include "plotters/plotter.h" -#include "sim/sim_model.h" std::unordered_map SCH_SYMBOL::s_transformToOrientationCache; @@ -137,6 +136,7 @@ SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, // Inherit the include in bill of materials and board netlist settings from flattened // library symbol. + m_excludedFromSim = m_part->GetExcludedFromSim(); m_excludedFromBOM = m_part->GetExcludedFromBOM(); m_excludedFromBoard = m_part->GetExcludedFromBoard(); m_DNP = false; @@ -169,6 +169,7 @@ SCH_SYMBOL::SCH_SYMBOL( const SCH_SYMBOL& aSymbol ) : m_convert = aSymbol.m_convert; m_lib_id = aSymbol.m_lib_id; m_isInNetlist = aSymbol.m_isInNetlist; + m_excludedFromSim = aSymbol.m_excludedFromSim; m_excludedFromBOM = aSymbol.m_excludedFromBOM; m_excludedFromBoard = aSymbol.m_excludedFromBoard; m_DNP = aSymbol.m_DNP; @@ -217,6 +218,7 @@ void SCH_SYMBOL::Init( const VECTOR2I& pos ) m_prefix = wxString( wxT( "U" ) ); m_isInNetlist = true; + m_excludedFromSim = false; m_excludedFromBOM = false; m_excludedFromBoard = false; } @@ -496,30 +498,6 @@ void SCH_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffse } -void SCH_SYMBOL::SetExcludeFromSim( bool aExclude ) -{ - SCH_FIELD* enable = FindField( SIM_ENABLE_FIELD ); - - if( aExclude ) - { - if( !enable ) - enable = AddField( SCH_FIELD( VECTOR2I( 0, 0 ), -1, this, SIM_ENABLE_FIELD ) ); - - enable->SetText( wxS( "0" ) ); - } - else - { - RemoveField( SIM_ENABLE_FIELD ); - } -} - - -bool SCH_SYMBOL::GetExcludeFromSim() const -{ - return GetFieldText( SIM_ENABLE_FIELD ) == wxS( "0" ); -} - - bool SCH_SYMBOL::GetInstance( SCH_SYMBOL_INSTANCE& aInstance, const KIID_PATH& aSheetPath, bool aTestFromEnd ) const { @@ -1159,6 +1137,7 @@ void SCH_SYMBOL::SwapData( SCH_ITEM* aItem ) m_transform = symbol->m_transform; symbol->m_transform = tmp; + std::swap( m_excludedFromSim, symbol->m_excludedFromSim ); std::swap( m_excludedFromBOM, symbol->m_excludedFromBOM ); std::swap( m_DNP, symbol->m_DNP ); std::swap( m_excludedFromBoard, symbol->m_excludedFromBoard ); @@ -1331,8 +1310,8 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, i } else if( token->IsSameAs( wxT( "EXCLUDE_FROM_SIM" ) ) ) { - *token = this->GetExcludeFromSim() ? _( "Excluded from simulation" ) - : wxString( wxT( "" ) ); + *token = this->GetExcludedFromSim() ? _( "Excluded from simulation" ) + : wxString( wxT( "" ) ); return true; } else if( token->IsSameAs( wxT( "DNP" ) ) ) @@ -1720,7 +1699,7 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector( _HKI( "Exclude from simulation" ), - &SCH_SYMBOL::SetExcludeFromSim, &SCH_SYMBOL::GetExcludeFromSim ), + &SCH_SYMBOL::SetExcludedFromSim, &SCH_SYMBOL::GetExcludedFromSim ), groupAttributes ); propMgr.AddProperty( new PROPERTY( _HKI( "Exclude from bill of materials" ), &SCH_SYMBOL::SetExcludedFromBOM, &SCH_SYMBOL::GetExcludedFromBOM ), diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index d4598060f1..78f6599daa 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -152,9 +152,6 @@ public: void SortInstances( bool ( *aSortFunction )( const SCH_SYMBOL_INSTANCE& aLhs, const SCH_SYMBOL_INSTANCE& aRhs ) ); - void SetExcludeFromSim( bool aExclude ) override; - bool GetExcludeFromSim() const override; - void ViewGetLayers( int aLayers[], int& aCount ) const override; /** @@ -748,6 +745,9 @@ public: bool HasBrightenedPins(); + bool GetExcludedFromSim() const override { return m_excludedFromSim; } + void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; } + bool GetExcludedFromBOM() const { return m_excludedFromBOM; } void SetExcludedFromBOM( bool aIncludeInBOM ) { m_excludedFromBOM = aIncludeInBOM; } @@ -803,10 +803,11 @@ private: std::vector> m_pins; ///< a SCH_PIN for every LIB_PIN (all units) std::unordered_map m_pinMap; ///< library pin pointer : SCH_PIN's index - bool m_isInNetlist; ///< True if the symbol should appear in the netlist - bool m_excludedFromBOM; ///< True to include in bill of materials export. - bool m_excludedFromBoard; ///< True to include in netlist when updating board. - bool m_DNP; ///< True if symbol is set to 'Do Not Populate'. + bool m_isInNetlist; ///< True if the symbol should appear in the netlist + bool m_excludedFromSim; ///< True to exclude from simulation. + bool m_excludedFromBOM; ///< True to exclude from bill of materials export. + bool m_excludedFromBoard; ///< True to exclude from netlist when updating board. + bool m_DNP; ///< True if symbol is set to 'Do Not Populate'. // Defines the hierarchical path and reference of the symbol. This allows support // for multiple references to a single sub-sheet. diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 63bfb96e94..f8c1f1a6bc 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -122,7 +122,7 @@ SCH_TEXT::SCH_TEXT( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) : SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT ); SetMultilineAllowed( true ); - m_excludeFromSim = false; + m_excludedFromSim = false; } @@ -131,7 +131,7 @@ SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) : EDA_TEXT( aText ), m_spin_style( aText.m_spin_style ) { - m_excludeFromSim = aText.m_excludeFromSim; + m_excludedFromSim = aText.m_excludedFromSim; } @@ -258,8 +258,8 @@ bool SCH_TEXT::operator<( const SCH_ITEM& aItem ) const if( GetPosition().y != other->GetPosition().y ) return GetPosition().y < other->GetPosition().y; - if( GetExcludeFromSim() != other->GetExcludeFromSim() ) - return GetExcludeFromSim() - other->GetExcludeFromSim(); + if( GetExcludedFromSim() != other->GetExcludedFromSim() ) + return GetExcludedFromSim() - other->GetExcludedFromSim(); return GetText() < other->GetText(); } @@ -503,7 +503,7 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetName() : _( "Default" ) ); diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index b08b55f887..5f319d98fc 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -143,8 +143,8 @@ public: void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override; - void SetExcludeFromSim( bool aExclude ) override { m_excludeFromSim = aExclude; } - bool GetExcludeFromSim() const override { return m_excludeFromSim; } + void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; } + bool GetExcludedFromSim() const override { return m_excludedFromSim; } /** * Set a spin or rotation angle, along with specific horizontal and vertical justification @@ -248,7 +248,7 @@ protected: */ TEXT_SPIN_STYLE m_spin_style; - bool m_excludeFromSim; + bool m_excludedFromSim; }; diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index a2a1a42e88..214f68f577 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -53,7 +53,7 @@ SCH_TEXTBOX::SCH_TEXTBOX( int aLineWidth, FILL_T aFillType, const wxString& text SetVertJustify( GR_TEXT_V_ALIGN_TOP ); SetMultilineAllowed( true ); - m_excludeFromSim = false; + m_excludedFromSim = false; } @@ -61,7 +61,7 @@ SCH_TEXTBOX::SCH_TEXTBOX( const SCH_TEXTBOX& aText ) : SCH_SHAPE( aText ), EDA_TEXT( aText ) { - m_excludeFromSim = aText.m_excludeFromSim; + m_excludedFromSim = aText.m_excludedFromSim; } @@ -213,8 +213,8 @@ bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const if( GetPosition().y != other->GetPosition().y ) return GetPosition().y < other->GetPosition().y; - if( GetExcludeFromSim() != other->GetExcludeFromSim() ) - return GetExcludeFromSim() - other->GetExcludeFromSim(); + if( GetExcludedFromSim() != other->GetExcludedFromSim() ) + return GetExcludedFromSim() - other->GetExcludedFromSim(); return GetText() < other->GetText(); } @@ -445,7 +445,7 @@ void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetName() : _( "Default" ) ); diff --git a/eeschema/sch_textbox.h b/eeschema/sch_textbox.h index 58062b78d2..c116bbc728 100644 --- a/eeschema/sch_textbox.h +++ b/eeschema/sch_textbox.h @@ -70,8 +70,8 @@ public: void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override; - void SetExcludeFromSim( bool aExclude ) override { m_excludeFromSim = aExclude; } - bool GetExcludeFromSim() const override { return m_excludeFromSim; } + void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; } + bool GetExcludedFromSim() const override { return m_excludedFromSim; } void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override; @@ -126,7 +126,7 @@ protected: const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); } protected: - bool m_excludeFromSim; + bool m_excludedFromSim; }; diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index 6f53652509..ccb36c824a 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -1590,19 +1590,19 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject ) FIELD_INFO pinMapInfo; bool modelFromValueField = false; - if( aSymbol.FindField( wxT( "Spice_Primitive" ) ) - || aSymbol.FindField( wxT( "Spice_Node_Sequence" ) ) - || aSymbol.FindField( wxT( "Spice_Model" ) ) - || aSymbol.FindField( wxT( "Spice_Netlist_Enabled" ) ) - || aSymbol.FindField( wxT( "Spice_Lib_File" ) ) ) + if( aSymbol.FindField( SIM_LEGACY_DEVICE_TYPE_FIELD ) + || aSymbol.FindField( SIM_LEGACY_PINS_FIELD ) + || aSymbol.FindField( SIM_LEGACY_TYPE_FIELD ) + || aSymbol.FindField( SIM_LEGACY_ENABLE_FIELD ) + || aSymbol.FindField( SIM_LEGACY_LIBRARY_FIELD ) ) { - if( T_field* primitiveField = aSymbol.FindField( wxT( "Spice_Primitive" ) ) ) + if( T_field* primitiveField = aSymbol.FindField( SIM_LEGACY_DEVICE_TYPE_FIELD ) ) { spiceDeviceInfo = FIELD_INFO( primitiveField->GetText(), primitiveField ); aSymbol.RemoveField( primitiveField ); } - if( T_field* nodeSequenceField = aSymbol.FindField( wxT( "Spice_Node_Sequence" ) ) ) + if( T_field* nodeSequenceField = aSymbol.FindField( SIM_LEGACY_PINS_FIELD ) ) { const wxString delimiters( "{:,; }" ); const wxString& nodeSequence = nodeSequenceField->GetText(); @@ -1628,7 +1628,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject ) aSymbol.RemoveField( nodeSequenceField ); } - if( T_field* modelField = aSymbol.FindField( wxT( "Spice_Model" ) ) ) + if( T_field* modelField = aSymbol.FindField( SIM_LEGACY_TYPE_FIELD ) ) { spiceModelInfo = FIELD_INFO( getSIValue( modelField ), modelField ); aSymbol.RemoveField( modelField ); @@ -1639,24 +1639,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject ) modelFromValueField = true; } - if( T_field* netlistEnabledField = aSymbol.FindField( wxT( "Spice_Netlist_Enabled" ) ) ) - { - wxString netlistEnabled = netlistEnabledField->GetText().Lower(); - - if( netlistEnabled.StartsWith( wxT( "0" ) ) - || netlistEnabled.StartsWith( wxT( "n" ) ) - || netlistEnabled.StartsWith( wxT( "f" ) ) ) - { - netlistEnabledField->SetName( SIM_ENABLE_FIELD ); - netlistEnabledField->SetText( wxT( "0" ) ); - } - else - { - aSymbol.RemoveField( netlistEnabledField ); - } - } - - if( T_field* libFileField = aSymbol.FindField( wxT( "Spice_Lib_File" ) ) ) + if( T_field* libFileField = aSymbol.FindField( SIM_LEGACY_LIBRARY_FIELD ) ) { spiceLibInfo = FIELD_INFO( libFileField->GetText(), libFileField ); aSymbol.RemoveField( libFileField ); diff --git a/eeschema/sim/sim_model.h b/eeschema/sim/sim_model.h index 120a75c632..83c3278a53 100644 --- a/eeschema/sim/sim_model.h +++ b/eeschema/sim/sim_model.h @@ -53,10 +53,18 @@ class PROJECT; #define SIM_TYPE_FIELD wxT( "Sim.Type" ) #define SIM_PINS_FIELD wxT( "Sim.Pins" ) #define SIM_PARAMS_FIELD wxT( "Sim.Params" ) +// Note: this has been moved to an actual attribute and is no longer written +// out as a field #define SIM_ENABLE_FIELD wxT( "Sim.Enable" ) #define SIM_LIBRARY_FIELD wxT( "Sim.Library" ) #define SIM_NAME_FIELD wxT( "Sim.Name" ) +#define SIM_LEGACY_DEVICE_TYPE_FIELD wxS( "Spice_Primitive" ) +#define SIM_LEGACY_TYPE_FIELD wxS( "Spice_Model" ) +#define SIM_LEGACY_PINS_FIELD wxS( "Spice_Node_Sequence" ) +#define SIM_LEGACY_ENABLE_FIELD wxS( "Spice_Netlist_Enabled" ) +#define SIM_LEGACY_LIBRARY_FIELD wxS( "Spice_Lib_File" ) + class SIM_MODEL { diff --git a/eeschema/sim/sim_model_raw_spice.h b/eeschema/sim/sim_model_raw_spice.h index 6bd87c3b44..fde9d2403c 100644 --- a/eeschema/sim/sim_model_raw_spice.h +++ b/eeschema/sim/sim_model_raw_spice.h @@ -56,12 +56,6 @@ public: LIB ) - static constexpr auto LEGACY_TYPE_FIELD = "Spice_Primitive"; - static constexpr auto LEGACY_PINS_FIELD = "Spice_Node_Sequence"; - static constexpr auto LEGACY_MODEL_FIELD = "Spice_Model"; - static constexpr auto LEGACY_ENABLED_FIELD = "Spice_Netlist_Enabled"; - static constexpr auto LEGACY_LIB_FIELD = "Spice_Lib_File"; - SIM_MODEL_RAW_SPICE( const std::string& aSpiceSource = "" ); void SetSource( const std::string& aSpiceSource ) { m_spiceCode = aSpiceSource; } diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 024834a22f..f28e0317ea 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -2543,7 +2543,7 @@ int SCH_EDIT_TOOL::SetAttribute( const TOOL_EVENT& aEvent ) symbol->SetDNP( true ); if( aEvent.IsAction( &EE_ACTIONS::setExcludeFromSimulation ) ) - symbol->SetExcludeFromSim( true ); + symbol->SetExcludedFromSim( true ); if( aEvent.IsAction( &EE_ACTIONS::setExcludeFromBOM ) ) symbol->SetExcludedFromBOM( true ); @@ -2580,7 +2580,7 @@ int SCH_EDIT_TOOL::UnsetAttribute( const TOOL_EVENT& aEvent ) symbol->SetDNP( false ); if( aEvent.IsAction( &EE_ACTIONS::unsetExcludeFromSimulation ) ) - symbol->SetExcludeFromSim( false ); + symbol->SetExcludedFromSim( false ); if( aEvent.IsAction( &EE_ACTIONS::unsetExcludeFromBOM ) ) symbol->SetExcludedFromBOM( false ); @@ -2617,7 +2617,7 @@ int SCH_EDIT_TOOL::ToggleAttribute( const TOOL_EVENT& aEvent ) symbol->SetDNP( !symbol->GetDNP() ); if( aEvent.IsAction( &EE_ACTIONS::toggleExcludeFromSimulation ) ) - symbol->SetExcludeFromSim( !symbol->GetExcludeFromSim() ); + symbol->SetExcludedFromSim( !symbol->GetExcludedFromSim() ); if( aEvent.IsAction( &EE_ACTIONS::toggleExcludeFromBOM ) ) symbol->SetExcludedFromBOM( !symbol->GetExcludedFromBOM() ); diff --git a/include/database/database_lib_settings.h b/include/database/database_lib_settings.h index 520bd72290..06de70ce49 100644 --- a/include/database/database_lib_settings.h +++ b/include/database/database_lib_settings.h @@ -58,6 +58,7 @@ struct MAPPABLE_SYMBOL_PROPERTIES std::string description; std::string footprint_filters; std::string keywords; + std::string exclude_from_sim; std::string exclude_from_bom; std::string exclude_from_board; };