diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index b9808adfdc..93ada009b0 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -78,8 +78,6 @@ DIALOG_SIM_MODEL::DIALOG_SIM_MODEL( wxWindow* aParent, SCH_SYMBOL& aSymbol, for( SIM_MODEL::DEVICE_TYPE_ deviceType : SIM_MODEL::DEVICE_TYPE__ITERATOR() ) m_deviceTypeChoice->Append( SIM_MODEL::DeviceTypeInfo( deviceType ).description ); - m_scintillaTricks = std::make_unique( m_codePreview, wxT( "{}" ), false ); - m_paramGridMgr->Bind( wxEVT_PG_SELECTED, &DIALOG_SIM_MODEL::onParamGridSelectionChange, this ); m_paramGrid->SetValidationFailureBehavior( wxPG_VFB_STAY_IN_PROPERTY @@ -110,7 +108,9 @@ DIALOG_SIM_MODEL::DIALOG_SIM_MODEL( wxWindow* aParent, SCH_SYMBOL& aSymbol, grid->DedicateKey( WXK_DOWN ); } else + { wxFAIL; + } // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); @@ -120,11 +120,13 @@ DIALOG_SIM_MODEL::DIALOG_SIM_MODEL( wxWindow* aParent, SCH_SYMBOL& aSymbol, template bool DIALOG_SIM_MODEL::TransferDataToWindow() { + wxCommandEvent dummyEvent; wxString libraryFilename = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::LIBRARY_FIELD ); if( libraryFilename != "" ) { // The model is sourced from a library, optionally with instance overrides. + m_useLibraryModelRadioButton->SetValue( true ); loadLibrary( libraryFilename ); // Must be set before curModel() is used since the latter checks the combobox value. @@ -139,7 +141,6 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() if( kibismodel ) { - wxCommandEvent dummyEvent; onModelNameCombobox( dummyEvent ); // refresh list of pins int i = 0; @@ -182,6 +183,7 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() else { // The model is sourced from the instance. + m_useInstanceModelRadioButton->SetValue( true ); SIM_MODEL::TYPE type = SIM_MODEL::ReadTypeFromFields( m_fields, m_sortedSymbolPins.size() ); try @@ -192,7 +194,11 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() } catch( const IO_ERROR& e ) { - DisplayErrorMessage( this, e.What() ); + DisplayErrorMessage( this, _( "Failed to read simulation model from fields." ) + + wxT( "\n\n" ) + + e.What() ); + + onRadioButton( dummyEvent ); return DIALOG_SIM_MODEL_BASE::TransferDataToWindow(); } @@ -204,11 +210,10 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() m_inferCheckbox->SetValue( curModel().IsInferred() ); std::string ref = SIM_MODEL::GetFieldValue( &m_fields, SIM_MODEL::REFERENCE_FIELD ); - m_inferCheckbox->Show( - SIM_MODEL::InferDeviceTypeFromRef( ref ) != SIM_MODEL::DEVICE_TYPE_::NONE ); - - updateWidgets(); + m_inferCheckbox->Show( SIM_MODEL::InferDeviceTypeFromRef( ref ) + != SIM_MODEL::DEVICE_TYPE_::NONE ); + onRadioButton( dummyEvent ); return DIALOG_SIM_MODEL_BASE::TransferDataToWindow(); } @@ -291,6 +296,7 @@ void DIALOG_SIM_MODEL::updateWidgets() m_prevModel = &curModel(); } + template void DIALOG_SIM_MODEL::updateIbisWidgets() { @@ -300,30 +306,24 @@ void DIALOG_SIM_MODEL::updateIbisWidgets() { modelkibis = dynamic_cast( &curModel() ); - for ( auto& item : m_sourceSizer->GetChildren() ) + for ( wxSizerItem* item : m_sourceSizer->GetChildren() ) { if ( item->GetWindow() == m_differentialCheckbox ) - { - item->SetFlag( wxALIGN_CENTER_VERTICAL|wxALL|wxRESERVE_SPACE_EVEN_IF_HIDDEN ); - } + item->SetFlag( item->GetFlag() | wxRESERVE_SPACE_EVEN_IF_HIDDEN ); + if ( item->GetWindow() == m_overrideCheckbox ) - { - item->SetFlag( wxALIGN_CENTER_VERTICAL|wxALL ); - } + item->SetFlag( item->GetFlag() & ~wxRESERVE_SPACE_EVEN_IF_HIDDEN ); } } else { - for ( auto& item : m_sourceSizer->GetChildren() ) + for ( wxSizerItem* item : m_sourceSizer->GetChildren() ) { if ( item->GetWindow() == m_differentialCheckbox ) - { - item->SetFlag( wxALIGN_CENTER_VERTICAL|wxALL ); - } + item->SetFlag( item->GetFlag() | wxRESERVE_SPACE_EVEN_IF_HIDDEN ); + if ( item->GetWindow() == m_overrideCheckbox ) - { - item->SetFlag( wxALIGN_CENTER_VERTICAL|wxALL|wxRESERVE_SPACE_EVEN_IF_HIDDEN ); - } + item->SetFlag( item->GetFlag() & ~wxRESERVE_SPACE_EVEN_IF_HIDDEN ); } } @@ -443,18 +443,20 @@ void DIALOG_SIM_MODEL::updateModelParamsTab() ( *it )->GetCell( col ).SetFgCol( fgCol ); } + const SIM_MODEL::PARAM& param = prop->GetParam(); + // Model values other than the currently edited value may have changed. Update them. // This feature is called "autofill" and present only in certain models. Don't do it for // models that don't have it for performance reasons. if( curModel().HasAutofill() ) - ( *it )->SetValueFromString( prop->GetParam().value->ToString() ); + ( *it )->SetValueFromString( param.value->ToString() ); // Most of the values are disabled when the override checkbox is unchecked. - ( *it )->Enable( - ( isIbisLoaded() ) || m_useInstanceModelRadioButton->GetValue() - || ( prop->GetParam().info.isInstanceParam - && prop->GetParam().info.category == SIM_MODEL::PARAM::CATEGORY::PRINCIPAL ) - || m_overrideCheckbox->GetValue() ); + ( *it )->Enable( isIbisLoaded() + || m_useInstanceModelRadioButton->GetValue() + || ( param.info.isInstanceParam + && param.info.category == SIM_MODEL::PARAM::CATEGORY::PRINCIPAL ) + || m_overrideCheckbox->GetValue() ); } } @@ -474,10 +476,10 @@ void DIALOG_SIM_MODEL::updateModelCodeTab() { // For raw Spice models display the whole file instead. - wxString path = curModel().FindParam( "lib" )->value->ToString(); - wxString absolutePath = Prj().AbsolutePath( path ); + wxString path = curModel().FindParam( "lib" )->value->ToString(); + wxString absolutePath = Prj().AbsolutePath( path ); wxTextFile file; - wxString text; + wxString text; text << curModel().SpiceGenerator().Preview( item ); text << "\n"; @@ -497,7 +499,9 @@ void DIALOG_SIM_MODEL::updateModelCodeTab() } } else + { m_codePreview->SetText( curModel().SpiceGenerator().Preview( item ) ); + } m_codePreview->SetEditable( false ); // ??? m_wasCodePreviewUpdated = true; @@ -603,7 +607,6 @@ void DIALOG_SIM_MODEL::loadLibrary( const wxString& aFilePath ) { wxString ibisTypeString = SIM_MODEL::GetFieldValue( &m_fields, SIM_MODEL::TYPE_FIELD ); - SIM_MODEL::TYPE ibisType = SIM_MODEL::TYPE::KIBIS_DEVICE; if( ibisTypeString == "IBISDRIVERDC" ) @@ -637,8 +640,7 @@ void DIALOG_SIM_MODEL::loadLibrary( const wxString& aFilePath ) { for( auto& [baseModelName, baseModel] : m_library->GetModels() ) { - wxString expectedModelName; - expectedModelName = + wxString expectedModelName = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY_KIBIS::NAME_FIELD ); // Only the current model is initialized from fields. Others have default @@ -662,6 +664,7 @@ void DIALOG_SIM_MODEL::loadLibrary( const wxString& aFilePath ) } wxArrayString modelNames; + for( auto& [modelName, model] : m_library->GetModels() ) modelNames.Add( modelName ); @@ -748,6 +751,7 @@ void DIALOG_SIM_MODEL::addParamPropertyIfRelevant( int aParamIndex ) } } + template wxPGProperty* DIALOG_SIM_MODEL::newParamProperty( int aParamIndex ) const { @@ -787,12 +791,14 @@ wxPGProperty* DIALOG_SIM_MODEL::newParamProperty( int aParamIndex ) const if( param.info.enumValues.empty() ) { prop = new SIM_STRING_PROPERTY( paramDescription, param.info.name, m_library, - curModelSharedPtr(), aParamIndex, SIM_VALUE::TYPE_STRING ); + curModelSharedPtr(), aParamIndex, + SIM_VALUE::TYPE_STRING ); } else { prop = new SIM_ENUM_PROPERTY( paramDescription, param.info.name, m_library, - curModelSharedPtr(), aParamIndex, SIM_VALUE::TYPE_STRING ); + curModelSharedPtr(), aParamIndex, + SIM_VALUE::TYPE_STRING ); } break; @@ -864,9 +870,13 @@ std::shared_ptr DIALOG_SIM_MODEL::curModelSharedPtr() const { if( m_useLibraryModelRadioButton->GetValue() && m_modelNameCombobox->GetSelection() != wxNOT_FOUND ) + { return m_libraryModels.at( m_modelNameCombobox->GetSelection() ); + } else + { return m_models.at( static_cast( m_curModelType ) ); + } } @@ -947,6 +957,25 @@ wxArrayString DIALOG_SIM_MODEL::getModelPinChoices() const template void DIALOG_SIM_MODEL::onRadioButton( wxCommandEvent& aEvent ) { + bool fromLibrary = m_useLibraryModelRadioButton->GetValue(); + + m_pathLabel->Enable( fromLibrary ); + m_tclibraryPathName->Enable( fromLibrary ); + m_browseButton->Enable( fromLibrary ); + m_modelNameLabel->Enable( fromLibrary ); + m_modelNameCombobox->Enable( fromLibrary ); + m_overrideCheckbox->Enable( fromLibrary ); + m_ibisPinLabel->Enable( fromLibrary ); + m_ibisPinCombobox->Enable( fromLibrary ); + m_differentialCheckbox->Enable( fromLibrary ); + m_ibisModelLabel->Enable( fromLibrary ); + m_ibisModelCombobox->Enable( fromLibrary ); + + m_staticTextDevType->Enable( !fromLibrary ); + m_deviceTypeChoice->Enable( !fromLibrary ); + m_staticTextSpiceType->Enable( !fromLibrary ); + m_typeChoice->Enable( !fromLibrary ); + updateWidgets(); } @@ -985,15 +1014,14 @@ void DIALOG_SIM_MODEL::onModelNameCombobox( wxCommandEvent& aEvent ) } for( std::pair strs : modelkibis->GetIbisPins() ) - { - pinLabels.Add( strs.first + " - " + strs.second ); - } + pinLabels.Add( strs.first + wxT( " - " ) + strs.second ); m_ibisPinCombobox->Set( pinLabels ); wxArrayString emptyArray; m_ibisModelCombobox->Set( emptyArray ); } + updateWidgets(); } @@ -1045,6 +1073,7 @@ void DIALOG_SIM_MODEL::onIbisPinCombobox( wxCommandEvent& aEvent ) m_ibisModelCombobox->Set( modelLabels ); } + updateWidgets(); } @@ -1211,48 +1240,6 @@ void DIALOG_SIM_MODEL::onInferCheckbox( wxCommandEvent& aEvent ) } -template -void DIALOG_SIM_MODEL::onLibraryPathUpdate( wxUpdateUIEvent& aEvent ) -{ - aEvent.Enable( m_useLibraryModelRadioButton->GetValue() ); -} - - -template -void DIALOG_SIM_MODEL::onBrowseButtonUpdate( wxUpdateUIEvent& aEvent ) -{ - aEvent.Enable( m_useLibraryModelRadioButton->GetValue() ); -} - - -template -void DIALOG_SIM_MODEL::onModelNameComboboxUpdate( wxUpdateUIEvent& aEvent ) -{ - aEvent.Enable( m_useLibraryModelRadioButton->GetValue() ); -} - - -template -void DIALOG_SIM_MODEL::onOverrideCheckboxUpdate( wxUpdateUIEvent& aEvent ) -{ - aEvent.Enable( m_useLibraryModelRadioButton->GetValue() ); -} - - -template -void DIALOG_SIM_MODEL::onDeviceTypeChoiceUpdate( wxUpdateUIEvent& aEvent ) -{ - aEvent.Enable( m_useInstanceModelRadioButton->GetValue() ); -} - - -template -void DIALOG_SIM_MODEL::onTypeChoiceUpdate( wxUpdateUIEvent& aEvent ) -{ - aEvent.Enable( m_useInstanceModelRadioButton->GetValue() || ( isIbisLoaded() ) ); -} - - template void DIALOG_SIM_MODEL::onParamGridSetFocus( wxFocusEvent& aEvent ) { @@ -1260,6 +1247,7 @@ void DIALOG_SIM_MODEL::onParamGridSetFocus( wxFocusEvent& aEvent ) // Tab key is pressed. This is inconvenient, so we fix that here. wxPropertyGrid* grid = m_paramGrid->GetGrid(); + if( !grid ) { wxFAIL; @@ -1282,6 +1270,7 @@ template void DIALOG_SIM_MODEL::onParamGridSelectionChange( wxPropertyGridEvent& aEvent ) { wxPropertyGrid* grid = m_paramGrid->GetGrid(); + if( !grid ) { wxFAIL; diff --git a/eeschema/dialogs/dialog_sim_model.h b/eeschema/dialogs/dialog_sim_model.h index 638424ed15..42386c295f 100644 --- a/eeschema/dialogs/dialog_sim_model.h +++ b/eeschema/dialogs/dialog_sim_model.h @@ -116,13 +116,6 @@ private: void onPinAssignmentsGridSize( wxSizeEvent& aEvent ) override; void onExcludeCheckbox( wxCommandEvent& aEvent ) override; void onInferCheckbox( wxCommandEvent& aEvent ) override; - - void onLibraryPathUpdate( wxUpdateUIEvent& aEvent ) override; - void onBrowseButtonUpdate( wxUpdateUIEvent& aEvent ) override; - void onModelNameComboboxUpdate( wxUpdateUIEvent& aEvent ) override; - void onOverrideCheckboxUpdate( wxUpdateUIEvent& aEvent ) override; - void onDeviceTypeChoiceUpdate( wxUpdateUIEvent& aEvent ) override; - void onTypeChoiceUpdate( wxUpdateUIEvent& aEvent ) override; void onDifferentialCheckbox( wxCommandEvent& event ) override; void onParamGridSetFocus( wxFocusEvent& aEvent ); @@ -143,7 +136,6 @@ private: MODEL_NAME_VALIDATOR m_modelNameValidator; wxPGProperty* m_firstCategory; // Used to add principal parameters to root. - std::unique_ptr m_scintillaTricks; wxPGProperty* m_prevParamGridSelection; bool m_wasCodePreviewUpdated; diff --git a/eeschema/dialogs/dialog_sim_model_base.cpp b/eeschema/dialogs/dialog_sim_model_base.cpp index 52c6f34a78..fdd1c2abc4 100644 --- a/eeschema/dialogs/dialog_sim_model_base.cpp +++ b/eeschema/dialogs/dialog_sim_model_base.cpp @@ -20,107 +20,101 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_modelPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer9; - bSizer9 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerPanel; + bSizerPanel = new wxBoxSizer( wxVERTICAL ); - m_sourceStaticSizer = new wxStaticBoxSizer( new wxStaticBox( m_modelPanel, wxID_ANY, _("Source") ), wxVERTICAL ); + wxBoxSizer* bSizerMargins; + bSizerMargins = new wxBoxSizer( wxVERTICAL ); - m_sourceSizer = new wxFlexGridSizer( 0, 4, 0, 0 ); - m_sourceSizer->AddGrowableCol( 2 ); + m_useLibraryModelRadioButton = new wxRadioButton( m_modelPanel, wxID_ANY, _("From library:"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); + bSizerMargins->Add( m_useLibraryModelRadioButton, 0, wxLEFT, 5 ); + + m_sourceSizer = new wxFlexGridSizer( 0, 3, 2, 0 ); + m_sourceSizer->AddGrowableCol( 1 ); + m_sourceSizer->AddGrowableRow( 0 ); m_sourceSizer->SetFlexibleDirection( wxBOTH ); m_sourceSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_useInstanceModelRadioButton = new wxRadioButton( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, _("Instance"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); - m_sourceSizer->Add( m_useInstanceModelRadioButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + m_pathLabel = new wxStaticText( m_modelPanel, wxID_ANY, _("Library path:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_pathLabel->Wrap( -1 ); + m_sourceSizer->Add( m_pathLabel, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - m_useLibraryModelRadioButton = new wxRadioButton( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, _("Library:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_sourceSizer->Add( m_useLibraryModelRadioButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + m_tclibraryPathName = new wxTextCtrl( m_modelPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); + m_sourceSizer->Add( m_tclibraryPathName, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - m_tclibraryPathName = new wxTextCtrl( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - m_sourceSizer->Add( m_tclibraryPathName, 0, wxEXPAND|wxALL, 5 ); - - m_browseButton = new wxBitmapButton( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_browseButton = new wxBitmapButton( m_modelPanel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_sourceSizer->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_sourceSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_modelNameLabel = new wxStaticText( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, _("Model:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); + m_modelNameLabel = new wxStaticText( m_modelPanel, wxID_ANY, _("Model:"), wxDefaultPosition, wxDefaultSize, 0 ); m_modelNameLabel->Wrap( -1 ); - m_sourceSizer->Add( m_modelNameLabel, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + m_sourceSizer->Add( m_modelNameLabel, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT, 5 ); - m_modelNameCombobox = new wxComboBox( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); - m_sourceSizer->Add( m_modelNameCombobox, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); + m_modelNameCombobox = new wxComboBox( m_modelPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); + m_sourceSizer->Add( m_modelNameCombobox, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - m_overrideCheckbox = new wxCheckBox( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, _("Override"), wxDefaultPosition, wxDefaultSize, 0 ); - m_sourceSizer->Add( m_overrideCheckbox, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + m_overrideCheckbox = new wxCheckBox( m_modelPanel, wxID_ANY, _("Override"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sourceSizer->Add( m_overrideCheckbox, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 7 ); - - m_sourceSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_ibisPinLabel = new wxStaticText( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, _("Pin:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); + m_ibisPinLabel = new wxStaticText( m_modelPanel, wxID_ANY, _("Pin:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ibisPinLabel->Wrap( -1 ); - m_sourceSizer->Add( m_ibisPinLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); + m_sourceSizer->Add( m_ibisPinLabel, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT, 5 ); - m_ibisPinCombobox = new wxComboBox( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); - m_sourceSizer->Add( m_ibisPinCombobox, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); + m_ibisPinCombobox = new wxComboBox( m_modelPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); + m_sourceSizer->Add( m_ibisPinCombobox, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - m_differentialCheckbox = new wxCheckBox( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, _("Differential"), wxDefaultPosition, wxDefaultSize, 0 ); - m_sourceSizer->Add( m_differentialCheckbox, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); + m_differentialCheckbox = new wxCheckBox( m_modelPanel, wxID_ANY, _("Differential"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sourceSizer->Add( m_differentialCheckbox, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 7 ); - - m_sourceSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_ibisModelLabel = new wxStaticText( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, _("Model:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); + m_ibisModelLabel = new wxStaticText( m_modelPanel, wxID_ANY, _("Model:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ibisModelLabel->Wrap( -1 ); - m_sourceSizer->Add( m_ibisModelLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); + m_sourceSizer->Add( m_ibisModelLabel, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT, 5 ); - m_ibisModelCombobox = new wxComboBox( m_sourceStaticSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); - m_sourceSizer->Add( m_ibisModelCombobox, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); + m_ibisModelCombobox = new wxComboBox( m_modelPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); + m_sourceSizer->Add( m_ibisModelCombobox, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - m_sourceStaticSizer->Add( m_sourceSizer, 0, wxEXPAND, 5 ); + bSizerMargins->Add( m_sourceSizer, 0, wxEXPAND|wxBOTTOM|wxLEFT, 24 ); + + m_useInstanceModelRadioButton = new wxRadioButton( m_modelPanel, wxID_ANY, _("From symbol instance:"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerMargins->Add( m_useInstanceModelRadioButton, 0, wxBOTTOM|wxLEFT, 5 ); + + wxFlexGridSizer* fgSizer16; + fgSizer16 = new wxFlexGridSizer( 0, 2, 8, 0 ); + fgSizer16->AddGrowableCol( 1 ); + fgSizer16->SetFlexibleDirection( wxBOTH ); + fgSizer16->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticTextDevType = new wxStaticText( m_modelPanel, wxID_ANY, _("Device:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextDevType->Wrap( -1 ); + fgSizer16->Add( m_staticTextDevType, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + wxArrayString m_deviceTypeChoiceChoices; + m_deviceTypeChoice = new wxChoice( m_modelPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_deviceTypeChoiceChoices, 0 ); + m_deviceTypeChoice->SetSelection( 0 ); + fgSizer16->Add( m_deviceTypeChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT, 10 ); + + m_staticTextSpiceType = new wxStaticText( m_modelPanel, wxID_ANY, _("Type:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextSpiceType->Wrap( -1 ); + fgSizer16->Add( m_staticTextSpiceType, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + wxArrayString m_typeChoiceChoices; + m_typeChoice = new wxChoice( m_modelPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_typeChoiceChoices, 0 ); + m_typeChoice->SetSelection( 0 ); + fgSizer16->Add( m_typeChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT, 10 ); - bSizer9->Add( m_sourceStaticSizer, 0, wxEXPAND|wxALL, 5 ); + bSizerMargins->Add( fgSizer16, 0, wxEXPAND|wxLEFT, 24 ); - wxStaticBoxSizer* sbSizer5; - sbSizer5 = new wxStaticBoxSizer( new wxStaticBox( m_modelPanel, wxID_ANY, _("Model") ), wxVERTICAL ); - m_notebook4 = new wxNotebook( sbSizer5->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + bSizerMargins->Add( 0, 10, 0, 0, 5 ); + + m_notebook4 = new wxNotebook( m_modelPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_parametersPanel = new wxPanel( m_notebook4, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_parametersPanel->SetMinSize( wxSize( 500,-1 ) ); wxBoxSizer* bSizer12; bSizer12 = new wxBoxSizer( wxVERTICAL ); - wxFlexGridSizer* fgSizer16; - fgSizer16 = new wxFlexGridSizer( 0, 2, 0, 0 ); - fgSizer16->AddGrowableCol( 1 ); - fgSizer16->SetFlexibleDirection( wxBOTH ); - fgSizer16->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_staticTextDevType = new wxStaticText( m_parametersPanel, wxID_ANY, _("Device:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextDevType->Wrap( -1 ); - fgSizer16->Add( m_staticTextDevType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - wxArrayString m_deviceTypeChoiceChoices; - m_deviceTypeChoice = new wxChoice( m_parametersPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_deviceTypeChoiceChoices, 0 ); - m_deviceTypeChoice->SetSelection( 0 ); - fgSizer16->Add( m_deviceTypeChoice, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); - - m_staticTextSpiceType = new wxStaticText( m_parametersPanel, wxID_ANY, _("Type:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextSpiceType->Wrap( -1 ); - fgSizer16->Add( m_staticTextSpiceType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - wxArrayString m_typeChoiceChoices; - m_typeChoice = new wxChoice( m_parametersPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_typeChoiceChoices, 0 ); - m_typeChoice->SetSelection( 0 ); - fgSizer16->Add( m_typeChoice, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); - - - bSizer12->Add( fgSizer16, 0, wxEXPAND, 5 ); - m_paramGridMgr = new wxPropertyGridManager(m_parametersPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxPGMAN_DEFAULT_STYLE|wxPG_SPLITTER_AUTO_CENTER); m_paramGridMgr->SetExtraStyle( wxPG_EX_MODE_BUTTONS|wxPG_EX_NATIVE_DOUBLE_BUFFERING ); @@ -180,15 +174,18 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c bSizer5->Fit( m_codePanel ); m_notebook4->AddPage( m_codePanel, _("Code"), false ); - sbSizer5->Add( m_notebook4, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + bSizerMargins->Add( m_notebook4, 1, wxEXPAND|wxTOP, 10 ); - bSizer9->Add( sbSizer5, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + bSizerMargins->Add( 0, 5, 0, wxEXPAND, 5 ); - m_modelPanel->SetSizer( bSizer9 ); + bSizerPanel->Add( bSizerMargins, 1, wxEXPAND, 5 ); + + + m_modelPanel->SetSizer( bSizerPanel ); m_modelPanel->Layout(); - bSizer9->Fit( m_modelPanel ); + bSizerPanel->Fit( m_modelPanel ); m_notebook->AddPage( m_modelPanel, _("Model"), true ); m_pinAssignmentsPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer10; @@ -210,6 +207,7 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c m_pinAssignmentsGrid->EnableDragColSize( true ); m_pinAssignmentsGrid->SetColLabelValue( 0, _("Symbol Pin") ); m_pinAssignmentsGrid->SetColLabelValue( 1, _("Model Pin") ); + m_pinAssignmentsGrid->SetColLabelSize( 22 ); m_pinAssignmentsGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); // Rows @@ -235,13 +233,13 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c gSizer1 = new wxGridSizer( 0, 2, 0, 0 ); m_excludeCheckbox = new wxCheckBox( this, wxID_ANY, _("Exclude from simulation"), wxDefaultPosition, wxDefaultSize, 0 ); - gSizer1->Add( m_excludeCheckbox, 0, wxALL, 5 ); + gSizer1->Add( m_excludeCheckbox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_inferCheckbox = new wxCheckBox( this, wxID_ANY, _("Store in Reference and Value"), wxDefaultPosition, wxDefaultSize, 0 ); - gSizer1->Add( m_inferCheckbox, 0, wxALIGN_RIGHT|wxALL, 5 ); + gSizer1->Add( m_inferCheckbox, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bSizer8->Add( gSizer1, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + bSizer8->Add( gSizer1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bSizer8->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); @@ -263,31 +261,35 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c this->Centre( wxBOTH ); // Connect Events - m_useInstanceModelRadioButton->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onRadioButton ), NULL, this ); m_useLibraryModelRadioButton->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onRadioButton ), NULL, this ); + m_pathLabel->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onLibraryPathLabelUpdate ), NULL, this ); m_tclibraryPathName->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onLibraryPathUpdate ), NULL, this ); m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onBrowseButtonClick ), NULL, this ); m_browseButton->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onBrowseButtonUpdate ), NULL, this ); + m_modelNameLabel->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameLabelUpdate ), NULL, this ); m_modelNameCombobox->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameCombobox ), NULL, this ); m_modelNameCombobox->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxKillFocus ), NULL, this ); m_modelNameCombobox->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxTextEnter ), NULL, this ); m_modelNameCombobox->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxUpdate ), NULL, this ); m_overrideCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onOverrideCheckbox ), NULL, this ); - m_overrideCheckbox->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onOverrideCheckboxUpdate ), NULL, this ); + m_ibisPinLabel->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onIbisPinLabelUpdate ), NULL, this ); m_ibisPinCombobox->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onIbisPinCombobox ), NULL, this ); m_ibisPinCombobox->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxKillFocus ), NULL, this ); m_ibisPinCombobox->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onIbisPinComboboxTextEnter ), NULL, this ); m_ibisPinCombobox->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxUpdate ), NULL, this ); m_differentialCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onDifferentialCheckbox ), NULL, this ); m_differentialCheckbox->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onOverrideCheckboxUpdate ), NULL, this ); + m_ibisModelLabel->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onIbisModelLabelUpdate ), NULL, this ); m_ibisModelCombobox->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onIbisModelCombobox ), NULL, this ); m_ibisModelCombobox->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxKillFocus ), NULL, this ); m_ibisModelCombobox->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onIbisModelComboboxTextEnter ), NULL, this ); m_ibisModelCombobox->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxUpdate ), NULL, this ); + m_useInstanceModelRadioButton->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onRadioButton ), NULL, this ); + m_staticTextDevType->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onDeviceTypeLabelUpdate ), NULL, this ); m_deviceTypeChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onDeviceTypeChoice ), NULL, this ); m_deviceTypeChoice->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onDeviceTypeChoiceUpdate ), NULL, this ); + m_staticTextSpiceType->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onTypeLabelUpdate ), NULL, this ); m_typeChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onTypeChoice ), NULL, this ); - m_typeChoice->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onTypeChoiceUpdate ), NULL, this ); m_paramGridMgr->Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( DIALOG_SIM_MODEL_BASE::onParamGridChanged ), NULL, this ); m_codePreview->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_SIM_MODEL_BASE::onCodePreviewSetFocus ), NULL, this ); m_pinAssignmentsGrid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SIM_MODEL_BASE::onPinAssignmentsGridCellChange ), NULL, this ); @@ -299,31 +301,35 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c DIALOG_SIM_MODEL_BASE::~DIALOG_SIM_MODEL_BASE() { // Disconnect Events - m_useInstanceModelRadioButton->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onRadioButton ), NULL, this ); m_useLibraryModelRadioButton->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onRadioButton ), NULL, this ); + m_pathLabel->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onLibraryPathLabelUpdate ), NULL, this ); m_tclibraryPathName->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onLibraryPathUpdate ), NULL, this ); m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onBrowseButtonClick ), NULL, this ); m_browseButton->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onBrowseButtonUpdate ), NULL, this ); + m_modelNameLabel->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameLabelUpdate ), NULL, this ); m_modelNameCombobox->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameCombobox ), NULL, this ); m_modelNameCombobox->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxKillFocus ), NULL, this ); m_modelNameCombobox->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxTextEnter ), NULL, this ); m_modelNameCombobox->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxUpdate ), NULL, this ); m_overrideCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onOverrideCheckbox ), NULL, this ); - m_overrideCheckbox->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onOverrideCheckboxUpdate ), NULL, this ); + m_ibisPinLabel->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onIbisPinLabelUpdate ), NULL, this ); m_ibisPinCombobox->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onIbisPinCombobox ), NULL, this ); m_ibisPinCombobox->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxKillFocus ), NULL, this ); m_ibisPinCombobox->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onIbisPinComboboxTextEnter ), NULL, this ); m_ibisPinCombobox->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxUpdate ), NULL, this ); m_differentialCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onDifferentialCheckbox ), NULL, this ); m_differentialCheckbox->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onOverrideCheckboxUpdate ), NULL, this ); + m_ibisModelLabel->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onIbisModelLabelUpdate ), NULL, this ); m_ibisModelCombobox->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onIbisModelCombobox ), NULL, this ); m_ibisModelCombobox->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxKillFocus ), NULL, this ); m_ibisModelCombobox->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onIbisModelComboboxTextEnter ), NULL, this ); m_ibisModelCombobox->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onModelNameComboboxUpdate ), NULL, this ); + m_useInstanceModelRadioButton->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onRadioButton ), NULL, this ); + m_staticTextDevType->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onDeviceTypeLabelUpdate ), NULL, this ); m_deviceTypeChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onDeviceTypeChoice ), NULL, this ); m_deviceTypeChoice->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onDeviceTypeChoiceUpdate ), NULL, this ); + m_staticTextSpiceType->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onTypeLabelUpdate ), NULL, this ); m_typeChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onTypeChoice ), NULL, this ); - m_typeChoice->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SIM_MODEL_BASE::onTypeChoiceUpdate ), NULL, this ); m_paramGridMgr->Disconnect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( DIALOG_SIM_MODEL_BASE::onParamGridChanged ), NULL, this ); m_codePreview->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_SIM_MODEL_BASE::onCodePreviewSetFocus ), NULL, this ); m_pinAssignmentsGrid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SIM_MODEL_BASE::onPinAssignmentsGridCellChange ), NULL, this ); diff --git a/eeschema/dialogs/dialog_sim_model_base.fbp b/eeschema/dialogs/dialog_sim_model_base.fbp index 2f2b2e02f6..6ccbb4dc2b 100644 --- a/eeschema/dialogs/dialog_sim_model_base.fbp +++ b/eeschema/dialogs/dialog_sim_model_base.fbp @@ -65,7 +65,7 @@ 5 wxEXPAND|wxTOP|wxRIGHT|wxLEFT 1 - + 1 1 1 @@ -118,11 +118,11 @@ - + Model 1 - + 1 1 1 @@ -173,44 +173,106 @@ wxTAB_TRAVERSAL - + - bSizer9 + bSizerPanel wxVERTICAL none - + 5 - wxEXPAND|wxALL - 0 - - wxID_ANY - Source + wxEXPAND + 1 + - m_sourceStaticSizer + bSizerMargins wxVERTICAL - 1 - protected + none 5 - wxEXPAND + wxLEFT 0 - - 4 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + From library: + + 0 + + + 0 + + 1 + m_useLibraryModelRadioButton + 1 + + + protected + 1 + + Resizable + 1 + + wxRB_GROUP + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + onRadioButton + + + + 24 + wxEXPAND|wxBOTTOM|wxLEFT + 0 + + 3 wxBOTH - 2 - + 1 + 0 0 m_sourceSizer wxFLEX_GROWMODE_SPECIFIED protected 0 - 0 - + 2 + 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -238,7 +300,8 @@ 0 0 wxID_ANY - Instance + Library path: + 0 0 @@ -246,72 +309,7 @@ 0 1 - m_useInstanceModelRadioButton - 1 - - - protected - 1 - - Resizable - 1 - - wxRB_GROUP - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - onRadioButton - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Library: - - 0 - - - 0 - - 1 - m_useLibraryModelRadioButton + m_pathLabel 1 @@ -325,20 +323,16 @@ ; ; forward_declare 0 - - wxFILTER_NONE - wxDefaultValidator - - 0 - onRadioButton + -1 + onLibraryPathLabelUpdate 5 - wxEXPAND|wxALL + wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -478,17 +472,7 @@ 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT 0 1 @@ -537,7 +521,7 @@ Resizable 1 - wxALIGN_RIGHT + ; ; forward_declare 0 @@ -545,11 +529,12 @@ -1 + onModelNameLabelUpdate 5 - wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxEXPAND 0 1 @@ -617,8 +602,8 @@ - 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + 7 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -679,22 +664,11 @@ onOverrideCheckbox - onOverrideCheckboxUpdate 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT 0 1 @@ -743,7 +717,7 @@ Resizable 1 - wxALIGN_RIGHT + ; ; forward_declare 0 @@ -751,11 +725,12 @@ -1 + onIbisPinLabelUpdate 5 - wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxEXPAND 0 1 @@ -823,8 +798,8 @@ - 5 - wxTOP|wxBOTTOM|wxRIGHT + 7 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -890,17 +865,7 @@ 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxTOP + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT 0 1 @@ -949,7 +914,7 @@ Resizable 1 - wxALIGN_RIGHT + ; ; forward_declare 0 @@ -957,11 +922,12 @@ -1 + onIbisModelLabelUpdate 5 - wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxEXPAND 0 1 @@ -1030,25 +996,359 @@ - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 1 - - wxID_ANY - Model - - sbSizer5 - wxVERTICAL - 1 - none 5 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + From symbol instance: + + 0 + + + 0 + + 1 + m_useInstanceModelRadioButton + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + onRadioButton + + + + 24 + wxEXPAND|wxLEFT + 0 + + 2 + wxBOTH + 1 + + 0 + + fgSizer16 + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 8 + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Device: + 0 + + 0 + + + 0 + + 1 + m_staticTextDevType + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + onDeviceTypeLabelUpdate + + + + 10 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_deviceTypeChoice + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onDeviceTypeChoice + onDeviceTypeChoiceUpdate + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Type: + 0 + + 0 + + + 0 + + 1 + m_staticTextSpiceType + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + onTypeLabelUpdate + + + + 10 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_typeChoice + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onTypeChoice + + + + + + 5 + + 0 + + 10 + protected + 0 + + + + 10 + wxEXPAND|wxTOP 1 - + 1 1 1 @@ -1101,11 +1401,11 @@ - + Parameters 1 - + 1 1 1 @@ -1156,283 +1456,11 @@ wxTAB_TRAVERSAL - + bSizer12 wxVERTICAL none - - 5 - wxEXPAND - 0 - - 2 - wxBOTH - 1 - - 0 - - fgSizer16 - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 0 - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Device: - 0 - - 0 - - - 0 - - 1 - m_staticTextDevType - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_deviceTypeChoice - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onDeviceTypeChoice - onDeviceTypeChoiceUpdate - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Type: - 0 - - 0 - - - 0 - - 1 - m_staticTextSpiceType - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_typeChoice - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onTypeChoice - onTypeChoiceUpdate - - - - 5 wxALL|wxEXPAND @@ -1636,16 +1664,26 @@ + + 5 + wxEXPAND + 0 + + 5 + protected + 0 + + - + Pin Assignments 0 - + 1 1 1 @@ -1696,7 +1734,7 @@ wxTAB_TRAVERSAL - + bSizer10 wxVERTICAL @@ -1728,7 +1766,7 @@ 0 1 wxALIGN_CENTER - + 22 "Symbol Pin" "Model Pin" wxALIGN_CENTER 2 @@ -1798,7 +1836,7 @@ 10 - wxEXPAND|wxRIGHT|wxLEFT + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 2 @@ -1810,7 +1848,7 @@ 0 5 - wxALL + wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -1875,7 +1913,7 @@ 5 - wxALIGN_RIGHT|wxALL + wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT 0 1 diff --git a/eeschema/dialogs/dialog_sim_model_base.h b/eeschema/dialogs/dialog_sim_model_base.h index 45d60f950f..1374727d96 100644 --- a/eeschema/dialogs/dialog_sim_model_base.h +++ b/eeschema/dialogs/dialog_sim_model_base.h @@ -19,17 +19,16 @@ class WX_GRID; #include #include #include +#include #include #include #include #include #include #include -#include #include #include #include -#include #include #include #include @@ -54,10 +53,9 @@ class DIALOG_SIM_MODEL_BASE : public DIALOG_SHIM protected: wxNotebook* m_notebook; wxPanel* m_modelPanel; - wxStaticBoxSizer* m_sourceStaticSizer; - wxFlexGridSizer* m_sourceSizer; - wxRadioButton* m_useInstanceModelRadioButton; wxRadioButton* m_useLibraryModelRadioButton; + wxFlexGridSizer* m_sourceSizer; + wxStaticText* m_pathLabel; wxTextCtrl* m_tclibraryPathName; wxBitmapButton* m_browseButton; wxStaticText* m_modelNameLabel; @@ -68,12 +66,13 @@ class DIALOG_SIM_MODEL_BASE : public DIALOG_SHIM wxCheckBox* m_differentialCheckbox; wxStaticText* m_ibisModelLabel; wxComboBox* m_ibisModelCombobox; - wxNotebook* m_notebook4; - wxPanel* m_parametersPanel; + wxRadioButton* m_useInstanceModelRadioButton; wxStaticText* m_staticTextDevType; wxChoice* m_deviceTypeChoice; wxStaticText* m_staticTextSpiceType; wxChoice* m_typeChoice; + wxNotebook* m_notebook4; + wxPanel* m_parametersPanel; wxPropertyGridManager* m_paramGridMgr; wxPropertyGridPage* m_paramGrid; wxPanel* m_codePanel; @@ -89,24 +88,29 @@ class DIALOG_SIM_MODEL_BASE : public DIALOG_SHIM // Virtual event handlers, override them in your derived class virtual void onRadioButton( wxCommandEvent& event ) { event.Skip(); } + virtual void onLibraryPathLabelUpdate( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onLibraryPathUpdate( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onBrowseButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void onBrowseButtonUpdate( wxUpdateUIEvent& event ) { event.Skip(); } + virtual void onModelNameLabelUpdate( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onModelNameCombobox( wxCommandEvent& event ) { event.Skip(); } virtual void onModelNameComboboxKillFocus( wxFocusEvent& event ) { event.Skip(); } virtual void onModelNameComboboxTextEnter( wxCommandEvent& event ) { event.Skip(); } virtual void onModelNameComboboxUpdate( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onOverrideCheckbox( wxCommandEvent& event ) { event.Skip(); } - virtual void onOverrideCheckboxUpdate( wxUpdateUIEvent& event ) { event.Skip(); } + virtual void onIbisPinLabelUpdate( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onIbisPinCombobox( wxCommandEvent& event ) { event.Skip(); } virtual void onIbisPinComboboxTextEnter( wxCommandEvent& event ) { event.Skip(); } virtual void onDifferentialCheckbox( wxCommandEvent& event ) { event.Skip(); } + virtual void onOverrideCheckboxUpdate( wxUpdateUIEvent& event ) { event.Skip(); } + virtual void onIbisModelLabelUpdate( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onIbisModelCombobox( wxCommandEvent& event ) { event.Skip(); } virtual void onIbisModelComboboxTextEnter( wxCommandEvent& event ) { event.Skip(); } + virtual void onDeviceTypeLabelUpdate( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onDeviceTypeChoice( wxCommandEvent& event ) { event.Skip(); } virtual void onDeviceTypeChoiceUpdate( wxUpdateUIEvent& event ) { event.Skip(); } + virtual void onTypeLabelUpdate( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onTypeChoice( wxCommandEvent& event ) { event.Skip(); } - virtual void onTypeChoiceUpdate( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onParamGridChanged( wxPropertyGridEvent& event ) { event.Skip(); } virtual void onCodePreviewSetFocus( wxFocusEvent& event ) { event.Skip(); } virtual void onPinAssignmentsGridCellChange( wxGridEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index 6270221b81..3305eede75 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -551,6 +551,9 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow() void DIALOG_SYMBOL_PROPERTIES::OnEditSpiceModel( wxCommandEvent& event ) { #ifdef KICAD_SPICE + if( !m_fieldsGrid->CommitPendingChanges() ) + return; + int diff = m_fields->size(); DIALOG_SIM_MODEL dialog( this, *m_symbol, *m_fields ); diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index 49e08d7807..a8083e0039 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -419,6 +419,7 @@ TYPE SIM_MODEL::ReadTypeFromFields( const std::vector& aFields, int aSymbolPi // No type information. Look for legacy (pre-V7) fields. TYPE typeFromLegacyFields = InferTypeFromLegacyFields( aFields ); + if( typeFromLegacyFields != TYPE::NONE ) return typeFromLegacyFields; @@ -500,7 +501,9 @@ TYPE SIM_MODEL::InferTypeFromLegacyFields( const std::vector& aFields ) return TYPE::RAWSPICE; } else + { return TYPE::NONE; + } } @@ -617,7 +620,7 @@ std::unique_ptr SIM_MODEL::Create( unsigned aSymbolPinCount, TYPE type = ReadTypeFromFields( aFields, aSymbolPinCount ); if( type == TYPE::NONE ) - THROW_IO_ERROR( wxString::Format( _( "Failed to read simulation model from fields" ) ) ); + THROW_IO_ERROR( wxString::Format( _( "Failed to read simulation model from fields." ) ) ); std::unique_ptr model = SIM_MODEL::Create( type );