From 170ff66cbbd4f17ebf6fddf24efa7b4d227c15a1 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 9 Jan 2019 21:42:14 -0800 Subject: [PATCH] libedit: Allow SPICE parameter editing This fixes a regression to allow SPICE parameters to be added to the symbol in libedit. Fixes: lp:1793062 * https://bugs.launchpad.net/kicad/+bug/1793062 --- .../dialogs/dialog_edit_component_in_lib.cpp | 35 + .../dialogs/dialog_edit_component_in_lib.h | 1 + .../dialog_edit_component_in_lib_base.cpp | 355 +-- .../dialog_edit_component_in_lib_base.fbp | 1357 ++--------- .../dialog_edit_component_in_lib_base.h | 24 +- .../dialog_edit_component_in_schematic.cpp | 2 +- ...ialog_edit_component_in_schematic_base.fbp | 1992 ++++++++--------- eeschema/dialogs/dialog_spice_model.cpp | 105 +- eeschema/dialogs/dialog_spice_model.h | 17 +- eeschema/lib_field.cpp | 8 + eeschema/lib_field.h | 2 + eeschema/sch_component.cpp | 5 +- 12 files changed, 1523 insertions(+), 2380 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index 40c22d79d0..1019527d1f 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -39,10 +39,16 @@ #include #include #include +#include #include #include #include +#ifdef KICAD_SPICE +#include +#include +#endif /* KICAD_SPICE */ + #include @@ -556,6 +562,35 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::transferAliasDataToBuffer() } +void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnEditSpiceModel( wxCommandEvent& event ) +{ +#ifdef KICAD_SPICE + int diff = m_fields->size(); + auto cmp = SCH_COMPONENT( *m_libEntry, m_libEntry->GetLibId(), nullptr ); + + DIALOG_SPICE_MODEL dialog( this, cmp, m_fields ); + + if( dialog.ShowModal() != wxID_OK ) + return; + + diff = m_fields->size() - diff; + + if( diff > 0 ) + { + wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, diff ); + m_grid->ProcessTableMessage( msg ); + } + else if( diff < 0 ) + { + wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, diff ); + m_grid->ProcessTableMessage( msg ); + } + + m_grid->ForceRefresh(); +#endif /* KICAD_SPICE */ +} + + void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnSelectAlias( wxCommandEvent& event ) { if( m_delayedFocusCtrl || !m_aliasGrid->CommitPendingChanges() ) diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.h b/eeschema/dialogs/dialog_edit_component_in_lib.h index 837c72c9f4..6f0678c5bd 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.h +++ b/eeschema/dialogs/dialog_edit_component_in_lib.h @@ -96,6 +96,7 @@ private: void OnAliasGridCellChanging( wxGridEvent& event ); void OnAliasNameKillFocus( wxFocusEvent& event ) override; void OnAliasNameText( wxCommandEvent& event ) override; + void OnEditSpiceModel( wxCommandEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent& event ) override; void updateAliasName( bool aFromGrid, const wxString& aName ); diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp b/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp index b8cb691f0b..0f2ec3c547 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Nov 23 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -14,30 +14,30 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - + wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); - + wxBoxSizer* bUpperSizer; bUpperSizer = new wxBoxSizer( wxVERTICAL ); - + m_NoteBook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0|wxTAB_TRAVERSAL ); m_PanelBasic = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizerBasicPanel; bSizerBasicPanel = new wxBoxSizer( wxVERTICAL ); - + wxStaticBoxSizer* sbSizer4; sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( m_PanelBasic, wxID_ANY, _("Fields") ), wxVERTICAL ); - + m_grid = new WX_GRID( sbSizer4->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - + // Grid m_grid->CreateGrid( 4, 11 ); m_grid->EnableEditing( true ); m_grid->EnableGridLines( true ); m_grid->EnableDragGridSize( false ); m_grid->SetMargins( 0, 0 ); - + // Columns m_grid->SetColSize( 0, 72 ); m_grid->SetColSize( 1, 120 ); @@ -64,199 +64,199 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_grid->SetColLabelValue( 8, _("Orientation") ); m_grid->SetColLabelValue( 9, _("X Position") ); m_grid->SetColLabelValue( 10, _("Y Position") ); - m_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - + m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + // Rows m_grid->EnableDragRowSize( true ); m_grid->SetRowLabelSize( 0 ); - m_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - + m_grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + // Label Appearance - + // Cell Defaults m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_grid->SetMinSize( wxSize( -1,180 ) ); - + sbSizer4->Add( m_grid, 0, wxTOP|wxBOTTOM|wxEXPAND, 5 ); - + wxBoxSizer* bButtonSize; bButtonSize = new wxBoxSizer( wxHORIZONTAL ); - - m_bpAdd = new wxBitmapButton( sbSizer4->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + + m_bpAdd = new wxBitmapButton( sbSizer4->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_bpAdd->SetToolTip( _("Add field") ); m_bpAdd->SetMinSize( wxSize( 30,29 ) ); - + bButtonSize->Add( m_bpAdd, 0, wxRIGHT|wxLEFT, 5 ); - - m_bpMoveUp = new wxBitmapButton( sbSizer4->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + + m_bpMoveUp = new wxBitmapButton( sbSizer4->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_bpMoveUp->SetToolTip( _("Move up") ); m_bpMoveUp->SetMinSize( wxSize( 30,29 ) ); - + bButtonSize->Add( m_bpMoveUp, 0, wxRIGHT, 5 ); - - m_bpMoveDown = new wxBitmapButton( sbSizer4->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + + m_bpMoveDown = new wxBitmapButton( sbSizer4->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_bpMoveDown->SetToolTip( _("Move down") ); m_bpMoveDown->SetMinSize( wxSize( 30,29 ) ); - + bButtonSize->Add( m_bpMoveDown, 0, wxRIGHT, 5 ); - - + + bButtonSize->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - m_bpDelete = new wxBitmapButton( sbSizer4->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + + m_bpDelete = new wxBitmapButton( sbSizer4->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_bpDelete->SetToolTip( _("Delete field") ); m_bpDelete->SetMinSize( wxSize( 30,29 ) ); - + bButtonSize->Add( m_bpDelete, 0, wxRIGHT|wxLEFT, 10 ); - - + + sbSizer4->Add( bButtonSize, 1, wxEXPAND|wxBOTTOM, 5 ); - - + + bSizerBasicPanel->Add( sbSizer4, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - + wxBoxSizer* bSizerMidBasicPanel; bSizerMidBasicPanel = new wxBoxSizer( wxVERTICAL ); - + wxFlexGridSizer* fgSizerFPID; fgSizerFPID = new wxFlexGridSizer( 4, 2, 3, 0 ); fgSizerFPID->AddGrowableCol( 1 ); fgSizerFPID->SetFlexibleDirection( wxBOTH ); fgSizerFPID->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + wxStaticText* staticNameLabel; staticNameLabel = new wxStaticText( m_PanelBasic, wxID_ANY, _("Symbol name:"), wxDefaultPosition, wxDefaultSize, 0 ); staticNameLabel->Wrap( -1 ); fgSizerFPID->Add( staticNameLabel, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - + m_SymbolNameCtrl = new wxTextCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerFPID->Add( m_SymbolNameCtrl, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + wxStaticText* staticDescriptionLabel; staticDescriptionLabel = new wxStaticText( m_PanelBasic, wxID_ANY, _("Description:"), wxDefaultPosition, wxDefaultSize, 0 ); staticDescriptionLabel->Wrap( -1 ); fgSizerFPID->Add( staticDescriptionLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - + m_DescCtrl = new wxTextCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerFPID->Add( m_DescCtrl, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + staticKeywordsLabel = new wxStaticText( m_PanelBasic, wxID_ANY, _("Keywords:"), wxDefaultPosition, wxDefaultSize, 0 ); staticKeywordsLabel->Wrap( -1 ); fgSizerFPID->Add( staticKeywordsLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - + m_KeywordCtrl = new wxTextCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerFPID->Add( m_KeywordCtrl, 0, wxRIGHT|wxLEFT|wxEXPAND, 5 ); - - + + bSizerMidBasicPanel->Add( fgSizerFPID, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - - + + bSizerBasicPanel->Add( bSizerMidBasicPanel, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + wxBoxSizer* bSizerLowerBasicPanel; bSizerLowerBasicPanel = new wxBoxSizer( wxHORIZONTAL ); - + wxBoxSizer* bSizerLeftCol; bSizerLeftCol = new wxBoxSizer( wxVERTICAL ); - + wxStaticBoxSizer* sbSizerSymbol; sbSizerSymbol = new wxStaticBoxSizer( new wxStaticBox( m_PanelBasic, wxID_ANY, _("Symbol") ), wxVERTICAL ); - + m_AsConvertButt = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Has alternate symbol (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 ); m_AsConvertButt->SetToolTip( _("Check this option if the symbol has an alternate body style (De Morgan)") ); - + sbSizerSymbol->Add( m_AsConvertButt, 0, wxRIGHT|wxLEFT, 5 ); - + m_OptionPower = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Define as power symbol"), wxDefaultPosition, wxDefaultSize, 0 ); m_OptionPower->SetToolTip( _("Check this option when the symbol is a power symbol") ); - + sbSizerSymbol->Add( m_OptionPower, 0, wxALL, 5 ); - + wxBoxSizer* bSizerUnitCount; bSizerUnitCount = new wxBoxSizer( wxHORIZONTAL ); - + m_staticTextNbUnits = new wxStaticText( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Number of Units:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextNbUnits->Wrap( -1 ); m_staticTextNbUnits->SetToolTip( _("Enter the number of units for a symbol that contains more than one unit") ); - + bSizerUnitCount->Add( m_staticTextNbUnits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - + m_SelNumberOfUnits = new wxSpinCtrl( sbSizerSymbol->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 26, 1 ); bSizerUnitCount->Add( m_SelNumberOfUnits, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); - - + + sbSizerSymbol->Add( bSizerUnitCount, 1, wxEXPAND, 5 ); - + m_OptionPartsLocked = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("All units are not interchangeable"), wxDefaultPosition, wxDefaultSize, 0 ); m_OptionPartsLocked->SetToolTip( _("Check this option when creating multiple unit symbols and all units are not interchangeable") ); - + sbSizerSymbol->Add( m_OptionPartsLocked, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - + + bSizerLeftCol->Add( sbSizerSymbol, 0, wxEXPAND|wxALL, 5 ); - - + + bSizerLowerBasicPanel->Add( bSizerLeftCol, 1, wxEXPAND, 5 ); - + wxBoxSizer* bSizerRightCol; bSizerRightCol = new wxBoxSizer( wxVERTICAL ); - + wxStaticBoxSizer* sbSizerAnnotations; sbSizerAnnotations = new wxStaticBoxSizer( new wxStaticBox( m_PanelBasic, wxID_ANY, _("Annotations") ), wxVERTICAL ); - + m_ShowPinNumButt = new wxCheckBox( sbSizerAnnotations->GetStaticBox(), wxID_ANY, _("Show pin number"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ShowPinNumButt->SetValue(true); + m_ShowPinNumButt->SetValue(true); m_ShowPinNumButt->SetToolTip( _("Show or hide pin numbers") ); - + sbSizerAnnotations->Add( m_ShowPinNumButt, 0, wxRIGHT|wxLEFT, 5 ); - + m_ShowPinNameButt = new wxCheckBox( sbSizerAnnotations->GetStaticBox(), wxID_ANY, _("Show pin name"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ShowPinNameButt->SetValue(true); + m_ShowPinNameButt->SetValue(true); m_ShowPinNameButt->SetToolTip( _("Show or hide pin names") ); - + sbSizerAnnotations->Add( m_ShowPinNameButt, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - + + sbSizerAnnotations->Add( 0, 0, 1, wxEXPAND, 5 ); - + m_PinsNameInsideButt = new wxCheckBox( sbSizerAnnotations->GetStaticBox(), wxID_ANY, _("Place pin names inside"), wxDefaultPosition, wxDefaultSize, 0 ); - m_PinsNameInsideButt->SetValue(true); + m_PinsNameInsideButt->SetValue(true); m_PinsNameInsideButt->SetToolTip( _("Check this option to have pin names inside the body and pin number outside.\nIf not checked pins names and pins numbers are outside.") ); - + sbSizerAnnotations->Add( m_PinsNameInsideButt, 0, wxALL, 5 ); - + wxBoxSizer* bSizerNameOffset; bSizerNameOffset = new wxBoxSizer( wxHORIZONTAL ); - + m_nameOffsetLabel = new wxStaticText( sbSizerAnnotations->GetStaticBox(), wxID_ANY, _("Position offset:"), wxDefaultPosition, wxDefaultSize, 0 ); m_nameOffsetLabel->Wrap( -1 ); m_nameOffsetLabel->SetToolTip( _("Margin (in 0.001 inches) between a pin name position and the component body.\nA value from 10 to 40 is usually good.") ); - + bSizerNameOffset->Add( m_nameOffsetLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 30 ); - + m_nameOffsetCtrl = new wxTextCtrl( sbSizerAnnotations->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizerNameOffset->Add( m_nameOffsetCtrl, 1, wxLEFT|wxRIGHT, 5 ); - + m_nameOffsetUnits = new wxStaticText( sbSizerAnnotations->GetStaticBox(), wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); m_nameOffsetUnits->Wrap( -1 ); bSizerNameOffset->Add( m_nameOffsetUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - + + sbSizerAnnotations->Add( bSizerNameOffset, 0, wxEXPAND, 5 ); - - + + sbSizerAnnotations->Add( 0, 0, 1, wxEXPAND, 5 ); - - + + bSizerRightCol->Add( sbSizerAnnotations, 1, wxEXPAND|wxALL, 5 ); - - + + bSizerLowerBasicPanel->Add( bSizerRightCol, 1, wxEXPAND, 5 ); - - + + bSizerBasicPanel->Add( bSizerLowerBasicPanel, 0, wxEXPAND, 5 ); - - + + m_PanelBasic->SetSizer( bSizerBasicPanel ); m_PanelBasic->Layout(); bSizerBasicPanel->Fit( m_PanelBasic ); @@ -264,58 +264,58 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_PanelAlias = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizerMainPanelAlias; bSizerMainPanelAlias = new wxBoxSizer( wxHORIZONTAL ); - + wxBoxSizer* bLeftBoxSizerPanelAlias; bLeftBoxSizerPanelAlias = new wxBoxSizer( wxVERTICAL ); - + wxStaticText* staticAliasesLabel; staticAliasesLabel = new wxStaticText( m_PanelAlias, wxID_ANY, _("Aliases:"), wxDefaultPosition, wxDefaultSize, 0 ); staticAliasesLabel->Wrap( -1 ); bLeftBoxSizerPanelAlias->Add( staticAliasesLabel, 0, wxRIGHT|wxLEFT, 5 ); - - m_aliasListBox = new wxListBox( m_PanelAlias, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + + m_aliasListBox = new wxListBox( m_PanelAlias, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); bLeftBoxSizerPanelAlias->Add( m_aliasListBox, 1, wxEXPAND|wxLEFT, 5 ); - + wxBoxSizer* bSizerButtons; bSizerButtons = new wxBoxSizer( wxHORIZONTAL ); - - m_addAliasButton = new wxBitmapButton( m_PanelAlias, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + + m_addAliasButton = new wxBitmapButton( m_PanelAlias, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_addAliasButton->SetToolTip( _("Add alias") ); m_addAliasButton->SetMinSize( wxSize( 30,29 ) ); - + bSizerButtons->Add( m_addAliasButton, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - + + bSizerButtons->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - m_deleteAliasButton = new wxBitmapButton( m_PanelAlias, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + + m_deleteAliasButton = new wxBitmapButton( m_PanelAlias, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_deleteAliasButton->SetToolTip( _("Delete alias") ); m_deleteAliasButton->SetMinSize( wxSize( 30,29 ) ); - + bSizerButtons->Add( m_deleteAliasButton, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - + + bLeftBoxSizerPanelAlias->Add( bSizerButtons, 0, wxEXPAND, 5 ); - - + + bSizerMainPanelAlias->Add( bLeftBoxSizerPanelAlias, 2, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - + wxBoxSizer* bRightBoxSizerPanelAlias; bRightBoxSizerPanelAlias = new wxBoxSizer( wxVERTICAL ); - + m_staticText12 = new wxStaticText( m_PanelAlias, wxID_ANY, _("Alias field substitutions:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText12->Wrap( -1 ); bRightBoxSizerPanelAlias->Add( m_staticText12, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - + m_aliasGrid = new WX_GRID( m_PanelAlias, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - + // Grid m_aliasGrid->CreateGrid( 4, 2 ); m_aliasGrid->EnableEditing( true ); m_aliasGrid->EnableGridLines( true ); m_aliasGrid->EnableDragGridSize( false ); m_aliasGrid->SetMargins( 0, 0 ); - + // Columns m_aliasGrid->SetColSize( 0, 72 ); m_aliasGrid->SetColSize( 1, 420 ); @@ -333,58 +333,58 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_aliasGrid->SetColLabelValue( 8, _("Orientation") ); m_aliasGrid->SetColLabelValue( 9, _("X Position") ); m_aliasGrid->SetColLabelValue( 10, _("Y Position") ); - m_aliasGrid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - + m_aliasGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + // Rows m_aliasGrid->EnableDragRowSize( true ); m_aliasGrid->SetRowLabelSize( 0 ); - m_aliasGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - + m_aliasGrid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + // Label Appearance - + // Cell Defaults m_aliasGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); bRightBoxSizerPanelAlias->Add( m_aliasGrid, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - + + bRightBoxSizerPanelAlias->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - + wxFlexGridSizer* fgSizerFPID1; fgSizerFPID1 = new wxFlexGridSizer( 6, 1, 0, 0 ); fgSizerFPID1->AddGrowableCol( 0 ); fgSizerFPID1->SetFlexibleDirection( wxBOTH ); fgSizerFPID1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + wxStaticText* staticAliasNameLabel; staticAliasNameLabel = new wxStaticText( m_PanelAlias, wxID_ANY, _("Alias name:"), wxDefaultPosition, wxDefaultSize, 0 ); staticAliasNameLabel->Wrap( -1 ); fgSizerFPID1->Add( staticAliasNameLabel, 0, wxLEFT|wxRIGHT, 5 ); - + m_AliasNameCtrl = new wxTextCtrl( m_PanelAlias, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerFPID1->Add( m_AliasNameCtrl, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5 ); - + wxStaticText* staticAliasDescLabel; staticAliasDescLabel = new wxStaticText( m_PanelAlias, wxID_ANY, _("Alias description:"), wxDefaultPosition, wxDefaultSize, 0 ); staticAliasDescLabel->Wrap( -1 ); fgSizerFPID1->Add( staticAliasDescLabel, 0, wxLEFT|wxRIGHT, 5 ); - + m_AliasDescCtrl = new wxTextCtrl( m_PanelAlias, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerFPID1->Add( m_AliasDescCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - + staticAliasKeywordsLabel = new wxStaticText( m_PanelAlias, wxID_ANY, _("Alias keywords:"), wxDefaultPosition, wxDefaultSize, 0 ); staticAliasKeywordsLabel->Wrap( -1 ); fgSizerFPID1->Add( staticAliasKeywordsLabel, 0, wxLEFT|wxRIGHT, 5 ); - + m_AliasKeywordsCtrl = new wxTextCtrl( m_PanelAlias, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizerFPID1->Add( m_AliasKeywordsCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - + + bRightBoxSizerPanelAlias->Add( fgSizerFPID1, 1, wxEXPAND, 5 ); - - + + bSizerMainPanelAlias->Add( bRightBoxSizerPanelAlias, 7, wxEXPAND|wxRIGHT|wxTOP, 20 ); - - + + m_PanelAlias->SetSizer( bSizerMainPanelAlias ); m_PanelAlias->Layout(); bSizerMainPanelAlias->Fit( m_PanelAlias ); @@ -392,71 +392,86 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_PanelFootprintFilter = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bPanelFpFilterBoxSizer; bPanelFpFilterBoxSizer = new wxBoxSizer( wxHORIZONTAL ); - + wxBoxSizer* bFpFilterLeftBoxSizer; bFpFilterLeftBoxSizer = new wxBoxSizer( wxVERTICAL ); - + m_staticTextFootprints = new wxStaticText( m_PanelFootprintFilter, wxID_ANY, _("Footprint filters:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextFootprints->Wrap( -1 ); m_staticTextFootprints->SetToolTip( _("A list of footprints names that can be used for this symbol.\nFootprints names can used wildcards like sm* to allow all footprints names starting by sm.") ); - + bFpFilterLeftBoxSizer->Add( m_staticTextFootprints, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_FootprintFilterListBox = new wxListBox( m_PanelFootprintFilter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + + m_FootprintFilterListBox = new wxListBox( m_PanelFootprintFilter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); bFpFilterLeftBoxSizer->Add( m_FootprintFilterListBox, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + wxBoxSizer* bFpFilterRightBoxSizer; bFpFilterRightBoxSizer = new wxBoxSizer( wxHORIZONTAL ); - - m_addFilterButton = new wxBitmapButton( m_PanelFootprintFilter, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 30,30 ), 0 ); + + m_addFilterButton = new wxBitmapButton( m_PanelFootprintFilter, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 30,30 ), wxBU_AUTODRAW|0 ); m_addFilterButton->SetToolTip( _("Add footprint filter") ); - + bFpFilterRightBoxSizer->Add( m_addFilterButton, 0, wxTOP|wxBOTTOM|wxLEFT, 5 ); - - m_editFilterButton = new wxBitmapButton( m_PanelFootprintFilter, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 30,30 ), 0 ); + + m_editFilterButton = new wxBitmapButton( m_PanelFootprintFilter, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 30,30 ), wxBU_AUTODRAW|0 ); m_editFilterButton->SetToolTip( _("Edit footprint filter") ); - + bFpFilterRightBoxSizer->Add( m_editFilterButton, 0, wxALL, 5 ); - - + + bFpFilterRightBoxSizer->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - m_deleteFilterButton = new wxBitmapButton( m_PanelFootprintFilter, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 30,30 ), 0 ); + + m_deleteFilterButton = new wxBitmapButton( m_PanelFootprintFilter, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 30,30 ), wxBU_AUTODRAW|0 ); m_deleteFilterButton->SetToolTip( _("Delete footprint filter") ); - + bFpFilterRightBoxSizer->Add( m_deleteFilterButton, 0, wxALL, 5 ); - - + + bFpFilterLeftBoxSizer->Add( bFpFilterRightBoxSizer, 0, 0, 5 ); - - + + bPanelFpFilterBoxSizer->Add( bFpFilterLeftBoxSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - + + m_PanelFootprintFilter->SetSizer( bPanelFpFilterBoxSizer ); m_PanelFootprintFilter->Layout(); bPanelFpFilterBoxSizer->Fit( m_PanelFootprintFilter ); m_NoteBook->AddPage( m_PanelFootprintFilter, _("Footprint Filters"), false ); - + bUpperSizer->Add( m_NoteBook, 1, wxEXPAND, 5 ); - - + + bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 ); - + + wxBoxSizer* bSizer101; + bSizer101 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer101->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_spiceFieldsButton = new wxButton( this, wxID_ANY, _("Edit Spice Model..."), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer101->Add( m_spiceFieldsButton, 0, wxEXPAND|wxALL, 5 ); + + + bSizer101->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 15 ); + m_stdSizerButton = new wxStdDialogButtonSizer(); m_stdSizerButtonOK = new wxButton( this, wxID_OK ); m_stdSizerButton->AddButton( m_stdSizerButtonOK ); m_stdSizerButtonCancel = new wxButton( this, wxID_CANCEL ); m_stdSizerButton->AddButton( m_stdSizerButtonCancel ); m_stdSizerButton->Realize(); - - bMainSizer->Add( m_stdSizerButton, 0, wxEXPAND|wxALL, 5 ); - - + + bSizer101->Add( m_stdSizerButton, 0, wxEXPAND|wxALL, 5 ); + + + bMainSizer->Add( bSizer101, 0, wxEXPAND, 5 ); + + this->SetSizer( bMainSizer ); this->Layout(); bMainSizer->Fit( this ); - + // Connect Events this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnUpdateUI ) ); m_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnSizeGrid ), NULL, this ); @@ -475,6 +490,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_addFilterButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnAddFootprintFilter ), NULL, this ); m_editFilterButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnEditFootprintFilter ), NULL, this ); m_deleteFilterButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnDeleteFootprintFilter ), NULL, this ); + m_spiceFieldsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnEditSpiceModel ), NULL, this ); } DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::~DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE() @@ -497,5 +513,6 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::~DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE() m_addFilterButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnAddFootprintFilter ), NULL, this ); m_editFilterButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnEditFootprintFilter ), NULL, this ); m_deleteFilterButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnDeleteFootprintFilter ), NULL, this ); - + m_spiceFieldsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::OnEditSpiceModel ), NULL, this ); + } diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp b/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp index 3875dc90bc..79637104bb 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ dialog_edit_component_in_lib_base 1000 none + 1 DIALOG_EDIT_COMPONENT_IN_LIBRARY_FBP @@ -52,41 +53,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnUpdateUI @@ -159,31 +125,6 @@ wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - General @@ -239,29 +180,6 @@ wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - bSizerBasicPanel @@ -279,7 +197,6 @@ wxVERTICAL 1 none - 5 wxTOP|wxBOTTOM|wxEXPAND @@ -306,10 +223,10 @@ wxALIGN_TOP 0 1 - wxALIGN_CENTRE + wxALIGN_CENTER 22 "Name" "Value" "Show" "H Align" "V Align" "Italic" "Bold" "Text Size" "Orientation" "X Position" "Y Position" - wxALIGN_CENTRE + wxALIGN_CENTER 11 72,120,48,72,72,48,48,84,84,84,84 @@ -352,10 +269,10 @@ 1 Resizable - wxALIGN_CENTRE + wxALIGN_CENTER 0 - wxALIGN_CENTRE + wxALIGN_CENTER 4 1 @@ -366,61 +283,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnSizeGrid - @@ -454,6 +317,7 @@ 1 1 + 0 0 @@ -467,9 +331,10 @@ 0 0 - wxID_ANY Add Field + + 0 0 @@ -484,8 +349,9 @@ protected 1 + + Resizable - 1 @@ -500,29 +366,6 @@ OnAddField - - - - - - - - - - - - - - - - - - - - - - - @@ -547,6 +390,7 @@ 1 1 + 0 0 @@ -560,9 +404,10 @@ 0 0 - wxID_ANY Move Up + + 0 0 @@ -577,8 +422,9 @@ protected 1 + + Resizable - 1 @@ -593,29 +439,6 @@ OnMoveUp - - - - - - - - - - - - - - - - - - - - - - - @@ -640,6 +463,7 @@ 1 1 + 0 0 @@ -653,9 +477,10 @@ 0 0 - wxID_ANY Move Down + + 0 0 @@ -670,8 +495,9 @@ protected 1 + + Resizable - 1 @@ -686,29 +512,6 @@ OnMoveDown - - - - - - - - - - - - - - - - - - - - - - - @@ -743,6 +546,7 @@ 1 1 + 0 0 @@ -756,9 +560,10 @@ 0 0 - wxID_ANY Delete Field + + 0 0 @@ -773,8 +578,9 @@ protected 1 + + Resizable - 1 @@ -789,29 +595,6 @@ OnDeleteField - - - - - - - - - - - - - - - - - - - - - - - @@ -876,6 +659,7 @@ 0 wxID_ANY Symbol name: + 0 0 @@ -901,29 +685,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -988,33 +749,8 @@ - - - - - OnSymbolNameKillFocus - - - - - - - - - - - - - - - - OnSymbolNameText - - - - @@ -1050,6 +786,7 @@ 0 wxID_ANY Description: + 0 0 @@ -1075,29 +812,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1162,33 +876,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1224,6 +911,7 @@ 0 wxID_ANY Keywords: + 0 0 @@ -1249,29 +937,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1336,33 +1001,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1399,7 +1037,6 @@ wxVERTICAL 1 none - 5 wxRIGHT|wxLEFT @@ -1462,30 +1099,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -1550,30 +1163,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -1618,6 +1207,7 @@ 0 wxID_ANY Number of Units: + 0 0 @@ -1643,29 +1233,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -1728,32 +1295,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1820,30 +1361,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -1871,7 +1388,6 @@ wxVERTICAL 1 none - 5 wxRIGHT|wxLEFT @@ -1934,30 +1450,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -2022,30 +1514,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -2120,30 +1588,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -2188,6 +1632,7 @@ 0 wxID_ANY Position offset: + 0 0 @@ -2213,29 +1658,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2300,33 +1722,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2362,6 +1757,7 @@ 0 wxID_ANY units + 0 0 @@ -2387,29 +1783,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2488,29 +1861,6 @@ wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - bSizerMainPanelAlias @@ -2558,6 +1908,7 @@ 0 wxID_ANY Aliases: + 0 0 @@ -2583,29 +1934,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -2669,31 +1997,7 @@ - - - - - - - - - - OnSelectAlias - - - - - - - - - - - - - - @@ -2727,6 +2031,7 @@ 1 1 + 0 0 @@ -2740,9 +2045,10 @@ 0 0 - wxID_ANY Add Alias + + 0 0 @@ -2757,8 +2063,9 @@ protected 1 + + Resizable - 1 @@ -2773,29 +2080,6 @@ OnAddAlias - - - - - - - - - - - - - - - - - - - - - - - @@ -2830,6 +2114,7 @@ 1 1 + 0 0 @@ -2843,9 +2128,10 @@ 0 0 - wxID_ANY Delete Alias + + 0 0 @@ -2860,8 +2146,9 @@ protected 1 + + Resizable - 1 @@ -2876,29 +2163,6 @@ OnDeleteAlias - - - - - - - - - - - - - - - - - - - - - - - @@ -2947,6 +2211,7 @@ 0 wxID_ANY Alias field substitutions: + 0 0 @@ -2972,29 +2237,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -3023,10 +2265,10 @@ wxALIGN_TOP 0 1 - wxALIGN_CENTRE + wxALIGN_CENTER 22 "Name" "Value" "Show" "H Align" "V Align" "Italic" "Bold" "Text Size" "Orientation" "X Position" "Y Position" - wxALIGN_CENTRE + wxALIGN_CENTER 2 72,420 @@ -3069,10 +2311,10 @@ 1 Resizable - wxALIGN_CENTRE + wxALIGN_CENTER 0 - wxALIGN_CENTRE + wxALIGN_CENTER 4 1 @@ -3083,61 +2325,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnSizeAliasGrid - @@ -3199,6 +2387,7 @@ 0 wxID_ANY Alias name: + 0 0 @@ -3224,29 +2413,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -3311,33 +2477,8 @@ - - - - - OnAliasNameKillFocus - - - - - - - - - - - - - - - - OnAliasNameText - - - - @@ -3373,6 +2514,7 @@ 0 wxID_ANY Alias description: + 0 0 @@ -3398,29 +2540,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -3485,33 +2604,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -3547,6 +2639,7 @@ 0 wxID_ANY Alias keywords: + 0 0 @@ -3572,29 +2665,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -3659,33 +2729,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -3750,29 +2793,6 @@ wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - bPanelFpFilterBoxSizer @@ -3820,6 +2840,7 @@ 0 wxID_ANY Footprint filters: + 0 0 @@ -3845,29 +2866,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -3931,31 +2929,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -3989,6 +2962,7 @@ 1 1 + 0 0 @@ -4002,9 +2976,10 @@ 0 0 - wxID_ANY Add Filter + + 0 0 @@ -4019,8 +2994,9 @@ protected 1 + + Resizable - 1 30,30 @@ -4035,29 +3011,6 @@ OnAddFootprintFilter - - - - - - - - - - - - - - - - - - - - - - - @@ -4082,6 +3035,7 @@ 1 1 + 0 0 @@ -4095,9 +3049,10 @@ 0 0 - wxID_ANY Edit Filter + + 0 0 @@ -4112,8 +3067,9 @@ protected 1 + + Resizable - 1 30,30 @@ -4128,29 +3084,6 @@ OnEditFootprintFilter - - - - - - - - - - - - - - - - - - - - - - - @@ -4185,6 +3118,7 @@ 1 1 + 0 0 @@ -4198,9 +3132,10 @@ 0 0 - wxID_ANY Delete Filter + + 0 0 @@ -4215,8 +3150,9 @@ protected 1 + + Resizable - 1 30,30 @@ -4231,29 +3167,6 @@ OnDeleteFootprintFilter - - - - - - - - - - - - - - - - - - - - - - - @@ -4269,28 +3182,124 @@ 5 - wxEXPAND|wxALL + wxEXPAND 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 + - m_stdSizerButton - protected - - - - - - - - + bSizer101 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Edit Spice Model... + + 0 + + 0 + + + 0 + + 1 + m_spiceFieldsButton + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnEditSpiceModel + + + + 15 + wxEXPAND|wxRIGHT|wxLEFT + 0 + + 0 + protected + 0 + + + + 5 + wxEXPAND|wxALL + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_stdSizerButton + protected + + diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.h b/eeschema/dialogs/dialog_edit_component_in_lib_base.h index 6b3c4d4707..8898da6fe4 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.h +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Nov 23 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __DIALOG_EDIT_COMPONENT_IN_LIB_BASE_H__ -#define __DIALOG_EDIT_COMPONENT_IN_LIB_BASE_H__ +#pragma once #include #include @@ -20,10 +19,10 @@ class WX_GRID; #include #include #include +#include #include #include #include -#include #include #include #include @@ -46,7 +45,7 @@ class WX_GRID; class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public DIALOG_SHIM { private: - + protected: wxNotebook* m_NoteBook; wxPanel* m_PanelBasic; @@ -86,10 +85,11 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public DIALOG_SHIM wxBitmapButton* m_addFilterButton; wxBitmapButton* m_editFilterButton; wxBitmapButton* m_deleteFilterButton; + wxButton* m_spiceFieldsButton; wxStdDialogButtonSizer* m_stdSizerButton; wxButton* m_stdSizerButtonOK; wxButton* m_stdSizerButtonCancel; - + // Virtual event handlers, overide them in your derived class virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnSizeGrid( wxSizeEvent& event ) { event.Skip(); } @@ -108,13 +108,13 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public DIALOG_SHIM virtual void OnAddFootprintFilter( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditFootprintFilter( wxCommandEvent& event ) { event.Skip(); } virtual void OnDeleteFootprintFilter( wxCommandEvent& event ) { event.Skip(); } - - + virtual void OnEditSpiceModel( wxCommandEvent& event ) { event.Skip(); } + + public: - - DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id = ID_LIBEDIT_NOTEBOOK, const wxString& title = _("Library Symbol Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wxWindow* parent, wxWindowID id = ID_LIBEDIT_NOTEBOOK, const wxString& title = _("Library Symbol Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE(); - + }; -#endif //__DIALOG_EDIT_COMPONENT_IN_LIB_BASE_H__ diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 6c21b9b1d6..9e73e7044b 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -323,7 +323,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnEditSpiceModel( wxCommandEvent& event #ifdef KICAD_SPICE int diff = m_fields->size(); - DIALOG_SPICE_MODEL dialog( this, *m_cmp, *m_fields ); + DIALOG_SPICE_MODEL dialog( this, *m_cmp, m_fields ); if( dialog.ShowModal() != wxID_OK ) return; diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp index ff8b0d6ab6..80e47529b5 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp @@ -1,6 +1,6 @@ - + ; C++ @@ -16,9 +16,9 @@ none 1 dialog_edit_component_in_schematic_base - + . - + 1 1 1 @@ -29,67 +29,67 @@ 0 wxAUI_MGR_DEFAULT - - - + + + 1 1 impl_virtual - - - + + + 0 wxID_ANY - - + + DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE - + -1,-1 wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU DIALOG_SHIM; dialog_shim.h Symbol Properties - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + OnInitDlg - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + OnUpdateUI - + mainSizer wxVERTICAL none @@ -100,12 +100,12 @@ wxID_ANY Fields - + sbFields wxVERTICAL 1 none - + 5 wxEXPAND|wxBOTTOM @@ -115,30 +115,30 @@ 1 1 1 - - - - + + + + 0 0 - - - + + + 1 - - + + wxALIGN_LEFT - + wxALIGN_TOP 0 1 - wxALIGN_CENTRE + wxALIGN_CENTER 22 "Name" "Value" "Show" "H Align" "V Align" "Italic" "Bold" "Text Size" "Orientation" "X Position" "Y Position" - wxALIGN_CENTRE + wxALIGN_CENTER 11 72,120,48,72,72,48,48,84,84,84,84 - + 1 0 Dock @@ -150,103 +150,103 @@ 1 1 1 - + 1 - - + + 1 0 0 wxID_ANY - - - + + + 0 0 - + 0 - - + + 0 -1,180 1 m_grid 1 - - + + protected 1 - + Resizable - wxALIGN_CENTRE + wxALIGN_CENTER 0 - - wxALIGN_CENTRE - + + wxALIGN_CENTER + 4 1 - + WX_GRID; widgets/wx_grid.h; forward_declare 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnSizeGrid - + @@ -254,7 +254,7 @@ wxEXPAND 0 - + bButtonSize wxHORIZONTAL none @@ -267,88 +267,88 @@ 1 1 1 - - - - - - - - + + + + + + + + 1 0 1 - + 1 0 0 - + Dock 0 Left 1 - + 1 - - + + 0 0 - + wxID_ANY Add Field - + 0 - - + + 0 30,30 1 m_bpAdd 1 - - + + protected 1 - + Resizable - + 1 - - + + ; forward_declare 0 Add field - + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnAddField - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -360,88 +360,88 @@ 1 1 1 - - - - - - - - + + + + + + + + 1 0 1 - + 1 0 0 - + Dock 0 Left 1 - + 1 - - + + 0 0 - + wxID_ANY Move Up - + 0 - - + + 0 30,30 1 m_bpMoveUp 1 - - + + protected 1 - + Resizable - + 1 - - + + ; forward_declare 0 Move up - + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnMoveUp - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -453,88 +453,88 @@ 1 1 1 - - - - - - - - + + + + + + + + 1 0 1 - + 1 0 0 - + Dock 0 Left 1 - + 1 - - + + 0 0 - + wxID_ANY Move Down - + 0 - - + + 0 30,30 1 m_bpMoveDown 1 - - + + protected 1 - + Resizable - + 1 - - + + ; forward_declare 0 Move down - + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnMoveDown - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -556,88 +556,88 @@ 1 1 1 - - - - - - - - + + + + + + + + 1 0 1 - + 1 0 0 - + Dock 0 Left 1 - + 1 - - + + 0 0 - + wxID_ANY Delete Field - + 0 - - + + 0 30,30 1 m_bpDelete 1 - - + + protected 1 - + Resizable - + 1 - - + + ; forward_declare 0 Delete field - + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnDeleteField - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -659,17 +659,17 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 0 @@ -677,65 +677,65 @@ 0 Left 1 - + 1 - + 0 0 wxID_ANY Update Fields from Library... - + 0 - - + + 0 - + 1 m_updateFieldValues 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 Sets fields to the original library values - + wxFILTER_NONE wxDefaultValidator - - - - + + + + UpdateFieldsFromLibrary - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -747,7 +747,7 @@ wxEXPAND|wxTOP|wxRIGHT 0 - + lowerSizer wxHORIZONTAL none @@ -758,12 +758,12 @@ wxID_ANY Symbol - + sbSizerLibraryReference wxVERTICAL 1 none - + 5 wxEXPAND @@ -772,9 +772,9 @@ 2 wxBOTH 1 - + 0 - + fgSizer1 wxFLEX_GROWMODE_SPECIFIED none @@ -789,78 +789,78 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Library Reference: - + 0 - - + + 0 - + 1 m_staticText3 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -868,7 +868,7 @@ wxEXPAND|wxRIGHT 1 - + bLibraryReferenceSizer wxHORIZONTAL none @@ -881,86 +881,86 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - + 0 - + 0 - + 1 m_libraryNameTextCtrl 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 Name of the symbol in the library to which this symbol is linked - + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -972,88 +972,88 @@ 1 1 1 - - - - - - - - + + + + + + + + 1 0 1 - + 1 0 0 - + Dock 0 Left 1 - + 1 - - + + 0 0 - + wxID_ANY Browse Library - + 0 - - + + 0 30,29 1 m_buttonBrowseLibrary 1 - - + + protected 1 - + Resizable - + 1 - - + + ; forward_declare 0 Browse library - + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnBrowseLibrary - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1067,78 +1067,78 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Unit: - + 0 - - + + 0 - + 1 m_unitLabel 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1150,83 +1150,83 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 - + 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - + + 0 100,-1 1 m_unitChoice 1 - - + + protected 1 - + Resizable 0 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1248,83 +1248,83 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Alternate symbol (DeMorgan) - + 0 - - + + 0 - + 1 m_cbAlternateSymbol 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 Use the alternate shape of this symbol. For gates, this is the "De Morgan" conversion - + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1340,85 +1340,85 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 "0" "+90" "+180" "-90" 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Orientation 1 - + 0 - - + + 0 - + 1 m_rbOrientation 1 - - + + protected 1 - + Resizable 0 1 - + wxRA_SPECIFY_COLS - + 0 Select if the symbol is to be rotated when drawn - + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1430,85 +1430,85 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 "Default" "Mirror around X axis" "Mirror around Y axis" 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Aspect 1 - + 0 - - + + 0 - + 1 m_rbMirror 1 - - + + protected 1 - + Resizable 1 1 - + wxRA_SPECIFY_COLS - + 0 Pick the graphical transformation to be used when displaying the symbol - + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1522,76 +1522,76 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - + + 0 - + 1 m_staticline1 1 - - + + protected 1 - + Resizable 1 - + wxLI_HORIZONTAL ; forward_declare 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1599,7 +1599,7 @@ wxEXPAND 0 - + bSizer101 wxHORIZONTAL none @@ -1608,7 +1608,7 @@ wxEXPAND|wxRIGHT|wxLEFT 0 - + bSizer11 wxHORIZONTAL none @@ -1621,78 +1621,78 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Unique ID: - + 0 - - + + 0 - + 1 timeStampLabel 1 - - + + none 1 - + Resizable 1 - - - + + + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1704,86 +1704,86 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - + 0 - + 0 - + 1 m_textCtrlTimeStamp 1 - - + + protected 1 - + Resizable 1 - + wxTE_READONLY - + 0 Unique ID that identifies the symbol - + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1807,17 +1807,17 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 0 @@ -1825,65 +1825,65 @@ 0 Left 1 - + 1 - + 0 0 wxID_ANY Edit Spice Model... - + 0 - - + + 0 - + 1 m_spiceFieldsButton 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnEditSpiceModel - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1909,17 +1909,17 @@ 1 0 0 - + m_stdDialogButtonSizer protected - - - - - - - - + + + + + + + + diff --git a/eeschema/dialogs/dialog_spice_model.cpp b/eeschema/dialogs/dialog_spice_model.cpp index 5a6cd6b20f..029a56e777 100644 --- a/eeschema/dialogs/dialog_spice_model.cpp +++ b/eeschema/dialogs/dialog_spice_model.cpp @@ -92,9 +92,25 @@ static int getModelTypeIdx( char aPrimitive ) } -DIALOG_SPICE_MODEL::DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent, SCH_FIELDS& aFields ) - : DIALOG_SPICE_MODEL_BASE( aParent ), m_component( aComponent ), m_fields( aFields ), - m_spiceEmptyValidator( true ), m_notEmptyValidator( wxFILTER_EMPTY ) +DIALOG_SPICE_MODEL::DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent, SCH_FIELDS* aFields ) + : DIALOG_SPICE_MODEL_BASE( aParent ), m_component( aComponent ), m_schfields( aFields ), + m_useSchFields( true ), + m_spiceEmptyValidator( true ), m_notEmptyValidator( wxFILTER_EMPTY ) +{ + Init(); +} + + +DIALOG_SPICE_MODEL::DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent, LIB_FIELDS* aFields ) + : DIALOG_SPICE_MODEL_BASE( aParent ), m_component( aComponent ), + m_libfields( aFields ), m_useSchFields( false ), + m_spiceEmptyValidator( true ), m_notEmptyValidator( wxFILTER_EMPTY ) +{ + Init(); +} + + +void DIALOG_SPICE_MODEL::Init() { m_pasValue->SetValidator( m_spiceValidator ); @@ -136,7 +152,6 @@ DIALOG_SPICE_MODEL::DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aCompo m_pwlValueCol = m_pwlValList->AppendColumn( "Value [V/A]", wxLIST_FORMAT_LEFT, 100 ); m_sdbSizerOK->SetDefault(); - } @@ -213,19 +228,22 @@ bool DIALOG_SPICE_MODEL::TransferDataFromWindow() { if( m_fieldsTmp.count( (SPICE_FIELD) i ) > 0 && !m_fieldsTmp.at( i ).IsEmpty() ) { - getField( i ).SetText( m_fieldsTmp[i] ); + if( m_useSchFields ) + getSchField( i ).SetText( m_fieldsTmp[i] ); + else + getLibField( i ).SetText( m_fieldsTmp[i] ); } else { // Erase empty fields (having empty fields causes a warning in the properties dialog) const wxString& spiceField = NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD) i ); - auto fieldIt = std::find_if( m_fields.begin(), m_fields.end(), [&]( const SCH_FIELD& f ) { - return f.GetName() == spiceField; - } ); - - if( fieldIt != m_fields.end() ) - m_fields.erase( fieldIt ); + if( m_useSchFields ) + m_schfields->erase( std::remove_if( m_schfields->begin(), m_schfields->end(), + [&]( const SCH_FIELD& f ) { return f.GetName() == spiceField; } ), m_schfields->end() ); + else + m_libfields->erase( std::remove_if( m_libfields->begin(), m_libfields->end(), + [&]( const LIB_FIELD& f ) { return f.GetName() == spiceField; } ), m_libfields->end() ); } } @@ -242,16 +260,33 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow() { const wxString& spiceField = spiceFields[idx]; - auto fieldIt = std::find_if( m_fields.begin(), m_fields.end(), [&]( const SCH_FIELD& f ) { - return f.GetName() == spiceField; - } ); + m_fieldsTmp[idx] = NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( (SPICE_FIELD) idx, &m_component, + NET_ADJUST_INCLUDE_PATHS | NET_ADJUST_PASSIVE_VALS ); // Do not modify the existing value, just add missing fields with default values - if( fieldIt != m_fields.end() && !fieldIt->GetText().IsEmpty() ) - m_fieldsTmp[idx] = fieldIt->GetText(); - else - m_fieldsTmp[idx] = NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( (SPICE_FIELD) idx, &m_component, - NET_ADJUST_INCLUDE_PATHS | NET_ADJUST_PASSIVE_VALS ); + if( m_schfields ) + { + for( auto field : *m_schfields ) + { + if( field.GetName() == spiceField && !field.GetText().IsEmpty() ) + { + m_fieldsTmp[idx] = field.GetText(); + break; + } + } + } + else if( m_libfields) + { + // TODO: There must be a good way to template out these repetitive calls + for( auto field : *m_libfields ) + { + if( field.GetName() == spiceField && !field.GetText().IsEmpty() ) + { + m_fieldsTmp[idx] = field.GetText(); + break; + } + } + } } // Analyze the component fields to fill out the dialog @@ -714,21 +749,43 @@ void DIALOG_SPICE_MODEL::loadLibrary( const wxString& aFilePath ) } -SCH_FIELD& DIALOG_SPICE_MODEL::getField( int aFieldType ) +SCH_FIELD& DIALOG_SPICE_MODEL::getSchField( int aFieldType ) { const wxString& spiceField = NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD) aFieldType ); - auto fieldIt = std::find_if( m_fields.begin(), m_fields.end(), [&]( const SCH_FIELD& f ) { + auto fieldIt = std::find_if( m_schfields->begin(), m_schfields->end(), [&]( const SCH_FIELD& f ) { return f.GetName() == spiceField; } ); // Found one, so return it - if( fieldIt != m_fields.end() ) + if( fieldIt != m_schfields->end() ) return *fieldIt; // Create a new field with requested name - m_fields.emplace_back( wxPoint(), m_fields.size(), &m_component, spiceField ); - return m_fields.back(); + m_schfields->emplace_back( wxPoint(), m_schfields->size(), &m_component, spiceField ); + return m_schfields->back(); +} + + +LIB_FIELD& DIALOG_SPICE_MODEL::getLibField( int aFieldType ) +{ + const wxString& spiceField = NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD) aFieldType ); + + auto fieldIt = std::find_if( m_libfields->begin(), m_libfields->end(), [&]( const LIB_FIELD& f ) { + return f.GetName() == spiceField; + } ); + + // Found one, so return it + if( fieldIt != m_libfields->end() ) + return *fieldIt; + + // Create a new field with requested name + LIB_FIELD new_field( m_libfields->size() ); + m_libfields->front().Copy( &new_field ); + new_field.SetName( spiceField ); + + m_libfields->push_back( new_field ); + return m_libfields->back(); } diff --git a/eeschema/dialogs/dialog_spice_model.h b/eeschema/dialogs/dialog_spice_model.h index 7a4acfba8e..d5fea82865 100644 --- a/eeschema/dialogs/dialog_spice_model.h +++ b/eeschema/dialogs/dialog_spice_model.h @@ -30,13 +30,16 @@ #include #include +#include +#include #include class DIALOG_SPICE_MODEL : public DIALOG_SPICE_MODEL_BASE { public: - DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent, SCH_FIELDS& aSchFields ); + DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent, SCH_FIELDS* aSchFields ); + DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent, LIB_FIELDS* aLibFields ); private: /** @@ -67,7 +70,8 @@ private: * @param aFieldType is an SPICE_FIELD enum value. * @return Requested field. */ - SCH_FIELD& getField( int aFieldType ); + SCH_FIELD& getSchField( int aFieldType ); + LIB_FIELD& getLibField( int aFieldType ); /** * Adds a value to the PWL values list. @@ -98,6 +102,11 @@ private: FinishDialogSettings(); } + /** + * Initializes the internal settings + */ + void Init(); + // Event handlers void onSelectLibrary( wxCommandEvent& event ) override; void onModelSelected( wxCommandEvent& event ) override; @@ -108,7 +117,9 @@ private: SCH_COMPONENT& m_component; ///> Fields from the component properties dialog - SCH_FIELDS& m_fields; + SCH_FIELDS* m_schfields; + LIB_FIELDS* m_libfields; + bool m_useSchFields; ///> Temporary field values std::map m_fieldsTmp; diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index e0d3f43966..d26bb84cea 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -61,6 +61,14 @@ LIB_FIELD::LIB_FIELD( int idfield ) : } +LIB_FIELD::LIB_FIELD( int aID, wxString& aName ) : + LIB_ITEM( LIB_FIELD_T, NULL ) +{ + Init( aID ); + m_name = aName; +} + + LIB_FIELD::~LIB_FIELD() { } diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 6fef8b8cbe..077cedb829 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -89,6 +89,8 @@ public: LIB_FIELD( int idfield = 2 ); + LIB_FIELD( int aID, wxString& aName ); + LIB_FIELD( LIB_PART * aParent, int idfield = 2 ); // Do not create a copy constructor. The one generated by the compiler is adequate. diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 200785c27a..c016fe0418 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -153,7 +153,10 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, LIB_ID aLibId, SCH_SHEET_PATH* sh UpdatePinCache(); // Update the reference -- just the prefix for now. - SetRef( sheet, aPart.GetReferenceField().GetText() + wxT( "?" ) ); + if( sheet ) + SetRef( sheet, aPart.GetReferenceField().GetText() + wxT( "?" ) ); + else + m_prefix = aPart.GetReferenceField().GetText() + wxT( "?" ); }