diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index 9248248b47..1648272574 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -337,17 +337,19 @@ bool DIALOG_SIM_MODEL::TransferDataFromWindow() if( ibismodel ) { - SIM_MODEL::SetFieldValue( - m_fields, SIM_LIBRARY_KIBIS::PIN_FIELD, - ibismodel->GetIbisPins().at( m_ibisPinCombobox->GetSelection() ).first ); + std::string pins; + std::string modelName = std::string( m_ibisModelCombobox->GetValue().c_str() ); + std::string differential; - SIM_MODEL::SetFieldValue( - m_fields, SIM_LIBRARY_KIBIS::MODEL_FIELD, - std::string( m_ibisModelCombobox->GetValue().c_str() ) ); + if( m_ibisPinCombobox->GetSelection() >= 0 ) + pins = ibismodel->GetIbisPins().at( m_ibisPinCombobox->GetSelection() ).first; - SIM_MODEL::SetFieldValue( - m_fields, SIM_LIBRARY_KIBIS::DIFF_FIELD, - ibismodel->CanDifferential() && m_differentialCheckbox->GetValue() ? "1" : "" ); + if( ibismodel->CanDifferential() && m_differentialCheckbox->GetValue() ) + differential = "1"; + + SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY_KIBIS::PIN_FIELD, pins ); + SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY_KIBIS::MODEL_FIELD, modelName ); + SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY_KIBIS::DIFF_FIELD, differential ); } } @@ -1219,10 +1221,18 @@ void DIALOG_SIM_MODEL::onTypeChoice( wxCommandEvent& aEvent ) { int idx = m_modelNameChoice->GetSelection(); - auto& kibisModel = static_cast( m_libraryModelsMgr.GetModels().at( idx ).get() ); + auto& baseModel = static_cast( m_libraryModelsMgr.GetModels().at( idx ).get() ); - m_libraryModelsMgr.SetModel( idx, std::make_unique( type, kibisModel, - m_fields, sourcePins ) ); + m_libraryModelsMgr.SetModel( idx, std::make_unique( type, baseModel ) ); + + try + { + m_libraryModelsMgr.GetModels().at( idx ).get().ReadDataFields( &m_fields, sourcePins ); + } + catch( IO_ERROR& err ) + { + DisplayErrorMessage( this, err.What() ); + } } m_curModelType = type; diff --git a/eeschema/sim/sim_model_kibis.cpp b/eeschema/sim/sim_model_kibis.cpp index 7ad12d252a..27c836f952 100644 --- a/eeschema/sim/sim_model_kibis.cpp +++ b/eeschema/sim/sim_model_kibis.cpp @@ -278,24 +278,6 @@ SIM_MODEL_KIBIS::SIM_MODEL_KIBIS( TYPE aType, const SIM_MODEL_KIBIS& aSource ) : } -SIM_MODEL_KIBIS::SIM_MODEL_KIBIS( TYPE aType, SIM_MODEL_KIBIS& aSource, - const std::vector& aFields, - const std::vector& aPins ) : - SIM_MODEL_KIBIS( aType, aSource ) -{ - ReadDataFields( &aFields, aPins ); -} - - -SIM_MODEL_KIBIS::SIM_MODEL_KIBIS( TYPE aType, SIM_MODEL_KIBIS& aSource, - const std::vector& aFields, - const std::vector& aPins ) : - SIM_MODEL_KIBIS( aType, aSource ) -{ - ReadDataFields( &aFields, aPins ); -} - - bool SIM_MODEL_KIBIS::ChangePin( const SIM_LIBRARY_KIBIS& aLib, std::string aPinNumber ) { KIBIS_COMPONENT* kcomp = aLib.m_kibis.GetComponent( std::string( GetComponentName() ) ); diff --git a/eeschema/sim/sim_model_kibis.h b/eeschema/sim/sim_model_kibis.h index f322f284ff..613d3374b6 100644 --- a/eeschema/sim/sim_model_kibis.h +++ b/eeschema/sim/sim_model_kibis.h @@ -59,11 +59,6 @@ public: // creates a a model with aType, but tries to match parameters from aSource. SIM_MODEL_KIBIS( TYPE aType, const SIM_MODEL_KIBIS& aSource ); - SIM_MODEL_KIBIS( TYPE aType, SIM_MODEL_KIBIS& aSource, const std::vector& aFields, - const std::vector& aPins ); - SIM_MODEL_KIBIS( TYPE aType, SIM_MODEL_KIBIS& aSource, const std::vector& aFields, - const std::vector& aPins ); - std::vector> GetIbisPins() const { return m_sourceModel ? m_sourceModel->GetIbisPins() : m_ibisPins;