diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index 0d7fa9f433..bce0485452 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -137,15 +137,7 @@ template bool DIALOG_SIM_MODEL::TransferDataToWindow() { wxCommandEvent dummyEvent; - - int pinCount = m_sortedSymbolPins.size(); - std::string ref = SIM_MODEL::GetFieldValue( &m_fields, SIM_MODEL::REFERENCE_FIELD ); - std::string libraryFilename = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::LIBRARY_FIELD ); - - SIM_MODEL::DEVICE_TYPE_ inferredDevice = SIM_MODEL::InferDeviceTypeFromRef( ref ); - - if( inferredDevice == SIM_MODEL::DEVICE_TYPE_::NONE ) - m_inferInstanceModelRadioButton->Enable( false ); + wxString libraryFilename = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::LIBRARY_FIELD ); if( libraryFilename != "" ) { @@ -207,33 +199,23 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() else { // The model is sourced from the instance. - std::string device = SIM_MODEL::GetFieldValue( &m_fields, SIM_MODEL::DEVICE_TYPE_FIELD ); - SIM_MODEL::TYPE type = SIM_MODEL::ReadTypeFromFields( m_fields, pinCount ); - bool inferred = m_inferInstanceModelRadioButton->IsEnabled() && device.empty(); - - if( inferred ) - m_inferInstanceModelRadioButton->SetValue( true ); - else - m_useInstanceModelRadioButton->SetValue( true ); + m_useInstanceModelRadioButton->SetValue( true ); + SIM_MODEL::TYPE type = SIM_MODEL::ReadTypeFromFields( m_fields, m_sortedSymbolPins.size() ); try { - m_models.at( static_cast( type ) ) = SIM_MODEL::Create( pinCount, m_fields ); + m_models.at( static_cast( SIM_MODEL::ReadTypeFromFields( m_fields, + m_sortedSymbolPins.size() ) ) ) = + SIM_MODEL::Create( m_sortedSymbolPins.size(), m_fields ); } catch( const IO_ERROR& e ) { - if( !inferred ) - { - DisplayErrorMessage( this, _( "Failed to read simulation model from fields." ) - + wxT( "\n\n" ) - + e.What() ); - } - } + DisplayErrorMessage( this, _( "Failed to read simulation model from fields." ) + + wxT( "\n\n" ) + + e.What() ); - if( m_inferInstanceModelRadioButton->IsEnabled() ) - { - m_inferredDevice->SetValue( SIM_MODEL::DeviceTypeInfo( inferredDevice ).description ); - m_inferredType->SetValue( SIM_MODEL::TypeInfo( type ).description ); + onRadioButton( dummyEvent ); + return DIALOG_SIM_MODEL_BASE::TransferDataToWindow(); } m_curModelType = type; @@ -241,9 +223,13 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() m_overrideCheckbox->SetValue( curModel().HasNonInstanceOverrides() ); m_excludeCheckbox->SetValue( !curModel().IsEnabled() ); + 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 ); onRadioButton( dummyEvent ); - return DIALOG_SIM_MODEL_BASE::TransferDataToWindow(); } @@ -294,7 +280,6 @@ bool DIALOG_SIM_MODEL::TransferDataFromWindow() } } - curModel().SetIsInferred( m_inferInstanceModelRadioButton->GetValue() ); curModel().WriteFields( m_fields ); return true; @@ -307,13 +292,16 @@ void DIALOG_SIM_MODEL::updateWidgets() m_overrideCheckbox->SetValue( curModel().HasNonInstanceOverrides() ); updateIbisWidgets(); - updateInstanceWidgets(); updateModelParamsTab(); updateModelCodeTab(); updatePinAssignments(); m_excludeCheckbox->SetValue( !curModel().IsEnabled() ); + std::string ref = SIM_MODEL::GetFieldValue( &m_fields, SIM_MODEL::REFERENCE_FIELD ); + m_inferCheckbox->Enable( SIM_MODEL::InferDeviceTypeFromRef( ref ) == curModel().GetDeviceType() ); + m_inferCheckbox->SetValue( curModel().IsInferred() ); + m_modelPanel->Layout(); m_pinAssignmentsPanel->Layout(); m_parametersPanel->Layout(); @@ -328,8 +316,32 @@ void DIALOG_SIM_MODEL::updateWidgets() template void DIALOG_SIM_MODEL::updateIbisWidgets() { - SIM_MODEL_KIBIS* modelkibis = isIbisLoaded() ? dynamic_cast( &curModel() ) - : nullptr; + SIM_MODEL_KIBIS* modelkibis = nullptr; + + if( isIbisLoaded() ) + { + modelkibis = dynamic_cast( &curModel() ); + + for ( wxSizerItem* item : m_sourceSizer->GetChildren() ) + { + if ( item->GetWindow() == m_differentialCheckbox ) + item->SetFlag( item->GetFlag() | wxRESERVE_SPACE_EVEN_IF_HIDDEN ); + + if ( item->GetWindow() == m_overrideCheckbox ) + item->SetFlag( item->GetFlag() & ~wxRESERVE_SPACE_EVEN_IF_HIDDEN ); + } + } + else + { + for ( wxSizerItem* item : m_sourceSizer->GetChildren() ) + { + if ( item->GetWindow() == m_differentialCheckbox ) + item->SetFlag( item->GetFlag() | wxRESERVE_SPACE_EVEN_IF_HIDDEN ); + + if ( item->GetWindow() == m_overrideCheckbox ) + item->SetFlag( item->GetFlag() & ~wxRESERVE_SPACE_EVEN_IF_HIDDEN ); + } + } m_ibisModelCombobox->Show( isIbisLoaded() ); m_ibisPinCombobox->Show( isIbisLoaded() ); @@ -343,44 +355,35 @@ void DIALOG_SIM_MODEL::updateIbisWidgets() } -template -void DIALOG_SIM_MODEL::updateInstanceWidgets() -{ - SIM_MODEL::DEVICE_TYPE_ deviceType = SIM_MODEL::TypeInfo( curModel().GetType() ).deviceType; - - // Change the Type choice to match the current device type. - if( !m_prevModel || deviceType != m_prevModel->GetDeviceType() ) - { - m_deviceTypeChoice->SetSelection( static_cast( deviceType ) ); - m_inferredDevice->SetValue( m_deviceTypeChoice->GetString( static_cast( deviceType ) ) ); - - m_typeChoice->Clear(); - - for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() ) - { - if( SIM_MODEL::TypeInfo( type ).deviceType == deviceType ) - { - wxString description = SIM_MODEL::TypeInfo( type ).description; - - if( !description.IsEmpty() ) - m_typeChoice->Append( description ); - - if( type == curModel().GetType() ) - { - m_typeChoice->SetSelection( m_typeChoice->GetCount() - 1 ); - m_inferredType->SetValue( description ); - } - } - } - } -} - - template void DIALOG_SIM_MODEL::updateModelParamsTab() { if( &curModel() != m_prevModel ) { + SIM_MODEL::DEVICE_TYPE_ deviceType = SIM_MODEL::TypeInfo( curModel().GetType() ).deviceType; + + // Change the Type choice to match the current device type. + if( !m_prevModel || deviceType != m_prevModel->GetDeviceType() ) + { + m_deviceTypeChoice->SetSelection( static_cast( deviceType ) ); + + m_typeChoice->Clear(); + + for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() ) + { + if( SIM_MODEL::TypeInfo( type ).deviceType == deviceType ) + { + wxString description = SIM_MODEL::TypeInfo( type ).description; + + if( !description.IsEmpty() ) + m_typeChoice->Append( description ); + + if( type == curModel().GetType() ) + m_typeChoice->SetSelection( m_typeChoice->GetCount() - 1 ); + } + } + } + // This wxPropertyGridManager column and header stuff has to be here because it segfaults in // the constructor. @@ -957,8 +960,6 @@ template void DIALOG_SIM_MODEL::onRadioButton( wxCommandEvent& aEvent ) { bool fromLibrary = m_useLibraryModelRadioButton->GetValue(); - bool inferred = m_inferInstanceModelRadioButton->GetValue(); - bool fromInstance = m_useInstanceModelRadioButton->GetValue(); m_pathLabel->Enable( fromLibrary ); m_tclibraryPathName->Enable( fromLibrary ); @@ -972,15 +973,10 @@ void DIALOG_SIM_MODEL::onRadioButton( wxCommandEvent& aEvent ) m_ibisModelLabel->Enable( fromLibrary ); m_ibisModelCombobox->Enable( fromLibrary ); - m_staticTextDevType->Enable( fromInstance ); - m_deviceTypeChoice->Enable( fromInstance ); - m_staticTextSpiceType->Enable( fromInstance ); - m_typeChoice->Enable( fromInstance ); - - m_inferredDeviceLabel->Enable( inferred ); - m_inferredDevice->Enable( inferred ); - m_inferredTypeLabel->Enable( inferred ); - m_inferredType->Enable( inferred ); + m_staticTextDevType->Enable( !fromLibrary ); + m_deviceTypeChoice->Enable( !fromLibrary ); + m_staticTextSpiceType->Enable( !fromLibrary ); + m_typeChoice->Enable( !fromLibrary ); updateWidgets(); } @@ -1241,6 +1237,13 @@ void DIALOG_SIM_MODEL::onExcludeCheckbox( wxCommandEvent& aEvent ) } +template +void DIALOG_SIM_MODEL::onInferCheckbox( wxCommandEvent& aEvent ) +{ + curModel().SetIsInferred( m_inferCheckbox->GetValue() ); +} + + template void DIALOG_SIM_MODEL::onParamGridSetFocus( wxFocusEvent& aEvent ) { diff --git a/eeschema/dialogs/dialog_sim_model.h b/eeschema/dialogs/dialog_sim_model.h index fcb8fb5fbc..c851edf599 100644 --- a/eeschema/dialogs/dialog_sim_model.h +++ b/eeschema/dialogs/dialog_sim_model.h @@ -92,7 +92,6 @@ private: void updateWidgets(); void updateIbisWidgets(); - void updateInstanceWidgets(); void updateModelParamsTab(); void updateModelCodeTab(); void updatePinAssignments(); @@ -130,6 +129,7 @@ private: void onPinAssignmentsGridCellChange( wxGridEvent& aEvent ) override; void onPinAssignmentsGridSize( wxSizeEvent& aEvent ) override; void onExcludeCheckbox( wxCommandEvent& aEvent ) override; + void onInferCheckbox( wxCommandEvent& aEvent ) override; void onDifferentialCheckbox( wxCommandEvent& event ) override; void onParamGridSetFocus( wxFocusEvent& aEvent ); diff --git a/eeschema/dialogs/dialog_sim_model_base.cpp b/eeschema/dialogs/dialog_sim_model_base.cpp index bd719aa04d..fdd1c2abc4 100644 --- a/eeschema/dialogs/dialog_sim_model_base.cpp +++ b/eeschema/dialogs/dialog_sim_model_base.cpp @@ -29,74 +29,64 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c m_useLibraryModelRadioButton = new wxRadioButton( m_modelPanel, wxID_ANY, _("From library:"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); bSizerMargins->Add( m_useLibraryModelRadioButton, 0, wxLEFT, 5 ); - wxGridBagSizer* gbSizer1; - gbSizer1 = new wxGridBagSizer( 3, 5 ); - gbSizer1->SetFlexibleDirection( wxBOTH ); - gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + 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_pathLabel = new wxStaticText( m_modelPanel, wxID_ANY, _("Library path:"), wxDefaultPosition, wxDefaultSize, 0 ); m_pathLabel->Wrap( -1 ); - gbSizer1->Add( m_pathLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - - wxBoxSizer* bSizer7; - bSizer7 = new wxBoxSizer( wxHORIZONTAL ); + m_sourceSizer->Add( m_pathLabel, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_tclibraryPathName = new wxTextCtrl( m_modelPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - bSizer7->Add( m_tclibraryPathName, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 3 ); + m_sourceSizer->Add( m_tclibraryPathName, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_browseButton = new wxBitmapButton( m_modelPanel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); - bSizer7->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - - gbSizer1->Add( bSizer7, wxGBPosition( 0, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + m_sourceSizer->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_modelNameLabel = new wxStaticText( m_modelPanel, wxID_ANY, _("Model:"), wxDefaultPosition, wxDefaultSize, 0 ); m_modelNameLabel->Wrap( -1 ); - gbSizer1->Add( m_modelNameLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + m_sourceSizer->Add( m_modelNameLabel, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT, 5 ); m_modelNameCombobox = new wxComboBox( m_modelPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); - gbSizer1->Add( m_modelNameCombobox, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + m_sourceSizer->Add( m_modelNameCombobox, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - m_overrideCheckbox = new wxCheckBox( m_modelPanel, wxID_ANY, _("Allow overrides"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_overrideCheckbox, wxGBPosition( 1, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 40 ); + 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_ibisPinLabel = new wxStaticText( m_modelPanel, wxID_ANY, _("Pin:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ibisPinLabel->Wrap( -1 ); - gbSizer1->Add( m_ibisPinLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + m_sourceSizer->Add( m_ibisPinLabel, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT, 5 ); m_ibisPinCombobox = new wxComboBox( m_modelPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); - gbSizer1->Add( m_ibisPinCombobox, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), 0, 5 ); + m_sourceSizer->Add( m_ibisPinCombobox, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_differentialCheckbox = new wxCheckBox( m_modelPanel, wxID_ANY, _("Differential"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_differentialCheckbox, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 40 ); + m_sourceSizer->Add( m_differentialCheckbox, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 7 ); m_ibisModelLabel = new wxStaticText( m_modelPanel, wxID_ANY, _("Model:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ibisModelLabel->Wrap( -1 ); - gbSizer1->Add( m_ibisModelLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + m_sourceSizer->Add( m_ibisModelLabel, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT, 5 ); m_ibisModelCombobox = new wxComboBox( m_modelPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); - gbSizer1->Add( m_ibisModelCombobox, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), 0, 5 ); + m_sourceSizer->Add( m_ibisModelCombobox, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - gbSizer1->AddGrowableCol( 1 ); - - bSizerMargins->Add( gbSizer1, 0, wxLEFT|wxEXPAND, 28 ); - - - bSizerMargins->Add( 0, 18, 0, 0, 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, 6, 5 ); + 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, 5 ); + 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 ); @@ -105,7 +95,7 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c m_staticTextSpiceType = new wxStaticText( m_modelPanel, wxID_ANY, _("Type:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextSpiceType->Wrap( -1 ); - fgSizer16->Add( m_staticTextSpiceType, 0, wxALIGN_CENTER_VERTICAL, 5 ); + 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 ); @@ -113,39 +103,10 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c fgSizer16->Add( m_typeChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT, 10 ); - bSizerMargins->Add( fgSizer16, 0, wxEXPAND|wxLEFT, 28 ); + bSizerMargins->Add( fgSizer16, 0, wxEXPAND|wxLEFT, 24 ); - bSizerMargins->Add( 0, 22, 0, 0, 5 ); - - m_inferInstanceModelRadioButton = new wxRadioButton( m_modelPanel, wxID_ANY, _("From symbol's reference designator and value:"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerMargins->Add( m_inferInstanceModelRadioButton, 0, wxBOTTOM|wxLEFT, 5 ); - - wxFlexGridSizer* fgSizer3; - fgSizer3 = new wxFlexGridSizer( 0, 2, 5, 5 ); - fgSizer3->AddGrowableCol( 1 ); - fgSizer3->SetFlexibleDirection( wxBOTH ); - fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_inferredDeviceLabel = new wxStaticText( m_modelPanel, wxID_ANY, _("Device:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_inferredDeviceLabel->Wrap( -1 ); - fgSizer3->Add( m_inferredDeviceLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_inferredDevice = new wxTextCtrl( m_modelPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - fgSizer3->Add( m_inferredDevice, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT, 10 ); - - m_inferredTypeLabel = new wxStaticText( m_modelPanel, wxID_ANY, _("Type:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_inferredTypeLabel->Wrap( -1 ); - fgSizer3->Add( m_inferredTypeLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_inferredType = new wxTextCtrl( m_modelPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - fgSizer3->Add( m_inferredType, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT, 10 ); - - - bSizerMargins->Add( fgSizer3, 0, wxEXPAND|wxLEFT, 28 ); - - - bSizerMargins->Add( 0, 5, 0, 0, 5 ); + 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 ); @@ -268,14 +229,20 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c bSizer8->Add( m_notebook, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - wxBoxSizer* bSizerBottom; - bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); + wxGridSizer* gSizer1; + gSizer1 = new wxGridSizer( 0, 2, 0, 0 ); m_excludeCheckbox = new wxCheckBox( this, wxID_ANY, _("Exclude from simulation"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerBottom->Add( m_excludeCheckbox, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 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|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bSizerBottom->Add( 30, 0, 1, wxEXPAND, 5 ); + 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 ); m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); @@ -284,10 +251,7 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_sdbSizer1->Realize(); - bSizerBottom->Add( m_sdbSizer1, 0, wxEXPAND|wxALL, 5 ); - - - bSizer8->Add( bSizerBottom, 0, wxEXPAND|wxLEFT, 5 ); + bSizer8->Add( m_sdbSizer1, 0, wxEXPAND|wxALL, 5 ); this->SetSizer( bSizer8 ); @@ -326,12 +290,12 @@ DIALOG_SIM_MODEL_BASE::DIALOG_SIM_MODEL_BASE( wxWindow* parent, wxWindowID id, c 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_inferInstanceModelRadioButton->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onRadioButton ), 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 ); m_pinAssignmentsGrid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SIM_MODEL_BASE::onPinAssignmentsGridSize ), NULL, this ); m_excludeCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onExcludeCheckbox ), NULL, this ); + m_inferCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onInferCheckbox ), NULL, this ); } DIALOG_SIM_MODEL_BASE::~DIALOG_SIM_MODEL_BASE() @@ -366,11 +330,11 @@ DIALOG_SIM_MODEL_BASE::~DIALOG_SIM_MODEL_BASE() 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_inferInstanceModelRadioButton->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onRadioButton ), 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 ); m_pinAssignmentsGrid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SIM_MODEL_BASE::onPinAssignmentsGridSize ), NULL, this ); m_excludeCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onExcludeCheckbox ), NULL, this ); + m_inferCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SIM_MODEL_BASE::onInferCheckbox ), NULL, this ); } diff --git a/eeschema/dialogs/dialog_sim_model_base.fbp b/eeschema/dialogs/dialog_sim_model_base.fbp index 7d262eca6d..6ccbb4dc2b 100644 --- a/eeschema/dialogs/dialog_sim_model_base.fbp +++ b/eeschema/dialogs/dialog_sim_model_base.fbp @@ -252,29 +252,27 @@ onRadioButton - - 28 - wxLEFT|wxEXPAND + + 24 + wxEXPAND|wxBOTTOM|wxLEFT 0 - - + + 3 wxBOTH 1 - - 5 + 0 + 0 - gbSizer1 + m_sourceSizer wxFLEX_GROWMODE_SPECIFIED - none - 3 - + protected + 0 + 2 + 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL - 0 - 1 - + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + 1 1 1 @@ -332,167 +330,150 @@ onLibraryPathLabelUpdate - + 5 - 2 - 1 - wxEXPAND - 0 - 1 - + wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 - bSizer7 - wxHORIZONTAL - none - - 3 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - -1,-1 - 1 - m_tclibraryPathName - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - onLibraryPathUpdate - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - MyButton - - 0 - - 0 - - - 0 - - 1 - m_browseButton - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onBrowseButtonClick - onBrowseButtonUpdate - - + 1 + m_tclibraryPathName + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + onLibraryPathUpdate - + 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL - 1 - 1 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + MyButton + + 0 + + 0 + + + 0 + + 1 + m_browseButton + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onBrowseButtonClick + onBrowseButtonUpdate + + + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT + 0 1 1 @@ -551,13 +532,10 @@ onModelNameLabelUpdate - + 5 - 1 - 1 - wxALIGN_CENTER_VERTICAL - 1 - 1 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 1 1 @@ -623,13 +601,10 @@ onModelNameComboboxUpdate - - 40 - 1 - 2 + + 7 wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 1 - 1 + 0 1 1 @@ -659,7 +634,7 @@ 0 0 wxID_ANY - Allow overrides + Override 0 @@ -691,13 +666,10 @@ onOverrideCheckbox - + 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL - 2 - 1 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT + 0 1 1 @@ -756,13 +728,10 @@ onIbisPinLabelUpdate - + 5 - 1 - 1 - - 2 - 1 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 1 1 @@ -828,13 +797,10 @@ onModelNameComboboxUpdate - - 40 - 1 - 2 + + 7 wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 2 - 1 + 0 1 1 @@ -897,13 +863,10 @@ onOverrideCheckboxUpdate - + 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL - 3 - 1 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT + 0 1 1 @@ -962,13 +925,10 @@ onIbisModelLabelUpdate - + 5 - 1 - 1 - - 3 - 1 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 1 1 @@ -1036,16 +996,6 @@ - - 5 - - 0 - - 18 - protected - 0 - - 5 wxBOTTOM|wxLEFT @@ -1112,7 +1062,7 @@ - 28 + 24 wxEXPAND|wxLEFT 0 @@ -1120,16 +1070,16 @@ wxBOTH 1 - 5 + 0 fgSizer16 wxFLEX_GROWMODE_SPECIFIED none 0 - 6 + 8 5 - wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -1257,7 +1207,7 @@ 5 - wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -1384,355 +1334,12 @@ - + 5 0 - - 22 - protected - 0 - - - - 5 - wxBOTTOM|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - From symbol's reference designator and value: - - 0 - - - 0 - - 1 - m_inferInstanceModelRadioButton - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - onRadioButton - - - - 28 - wxEXPAND|wxLEFT - 0 - - 2 - wxBOTH - 1 - - 5 - - fgSizer3 - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 5 - - 5 - wxALIGN_CENTER_VERTICAL - 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_inferredDeviceLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 10 - wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_inferredDevice - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 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_inferredTypeLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 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_inferredType - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - 5 - - 0 - - 5 + + 10 protected 0 @@ -1794,11 +1401,11 @@ - + Parameters 1 - + 1 1 1 @@ -1849,7 +1456,7 @@ wxTAB_TRAVERSAL - + bSizer12 wxVERTICAL @@ -2228,17 +1835,20 @@ - 5 - wxEXPAND|wxLEFT + 10 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 - + + 2 + 0 - bSizerBottom - wxHORIZONTAL + gSizer1 none + 0 + 0 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -2303,34 +1913,147 @@ 5 - wxEXPAND - 1 - - 0 - protected - 30 - - - - 5 - wxEXPAND|wxALL + wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Store in Reference and Value + + 0 + + + 0 - m_sdbSizer1 + 1 + m_inferCheckbox + 1 + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onInferCheckbox + + 5 + wxEXPAND | wxALL + 0 + + 1 + 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 + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + + diff --git a/eeschema/dialogs/dialog_sim_model_base.h b/eeschema/dialogs/dialog_sim_model_base.h index 607c591396..1374727d96 100644 --- a/eeschema/dialogs/dialog_sim_model_base.h +++ b/eeschema/dialogs/dialog_sim_model_base.h @@ -26,10 +26,9 @@ class WX_GRID; #include #include #include -#include #include #include -#include +#include #include #include #include @@ -38,6 +37,7 @@ class WX_GRID; #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -54,6 +54,7 @@ class DIALOG_SIM_MODEL_BASE : public DIALOG_SHIM wxNotebook* m_notebook; wxPanel* m_modelPanel; wxRadioButton* m_useLibraryModelRadioButton; + wxFlexGridSizer* m_sourceSizer; wxStaticText* m_pathLabel; wxTextCtrl* m_tclibraryPathName; wxBitmapButton* m_browseButton; @@ -70,11 +71,6 @@ class DIALOG_SIM_MODEL_BASE : public DIALOG_SHIM wxChoice* m_deviceTypeChoice; wxStaticText* m_staticTextSpiceType; wxChoice* m_typeChoice; - wxRadioButton* m_inferInstanceModelRadioButton; - wxStaticText* m_inferredDeviceLabel; - wxTextCtrl* m_inferredDevice; - wxStaticText* m_inferredTypeLabel; - wxTextCtrl* m_inferredType; wxNotebook* m_notebook4; wxPanel* m_parametersPanel; wxPropertyGridManager* m_paramGridMgr; @@ -84,6 +80,8 @@ class DIALOG_SIM_MODEL_BASE : public DIALOG_SHIM wxPanel* m_pinAssignmentsPanel; WX_GRID* m_pinAssignmentsGrid; wxCheckBox* m_excludeCheckbox; + wxCheckBox* m_inferCheckbox; + wxStaticLine* m_staticline1; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; @@ -118,6 +116,7 @@ class DIALOG_SIM_MODEL_BASE : public DIALOG_SHIM virtual void onPinAssignmentsGridCellChange( wxGridEvent& event ) { event.Skip(); } virtual void onPinAssignmentsGridSize( wxSizeEvent& event ) { event.Skip(); } virtual void onExcludeCheckbox( wxCommandEvent& event ) { event.Skip(); } + virtual void onInferCheckbox( wxCommandEvent& event ) { event.Skip(); } public: