Readjust Edit Symbol Properties when symbol references changes.

The new reference may contain different numbers of units and/or
different deMorgan conversion settings.

Fixes: lp:1822316
* https://bugs.launchpad.net/kicad/+bug/1822316
This commit is contained in:
Jeff Young 2019-04-09 16:58:23 +01:00
parent c85d2fd3bf
commit 15cb032ab7
1 changed files with 44 additions and 12 deletions

View File

@ -235,11 +235,43 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnBrowseLibrary( wxCommandEvent& event
m_libraryNameTextCtrl->SetValue( sel.LibId.Format() );
// Update the value field for Power symbols
LIB_PART* entry = GetParent()->GetLibPart( sel.LibId );
if( entry && entry->IsPower() )
m_grid->SetCellValue( VALUE, FDC_VALUE, sel.LibId.GetLibItemName() );
if( entry )
{
// Update the value field for Power symbols
if( entry->IsPower() )
m_grid->SetCellValue( VALUE, FDC_VALUE, sel.LibId.GetLibItemName() );
// Update the units control
int unit = m_unitChoice->GetSelection();
m_unitChoice->Clear();
if( entry->GetUnitCount() > 1 )
{
for( int ii = 1; ii <= entry->GetUnitCount(); ii++ )
m_unitChoice->Append( LIB_PART::SubReference( ii, false ) );
if( unit < 0 || unit >= m_unitChoice->GetCount() )
unit = 0;
m_unitChoice->SetSelection( unit );
m_unitLabel->Enable( true );
m_unitChoice->Enable( true );
}
else
{
m_unitChoice->SetSelection( -1 );
m_unitLabel->Enable( false );
m_unitChoice->Enable( false );
}
// Update the deMorgan conversion controls
bool conversion = m_cbAlternateSymbol->GetValue();
m_cbAlternateSymbol->SetValue( conversion && entry->HasConversion() );
m_cbAlternateSymbol->Enable( entry->HasConversion() );
}
}
@ -373,17 +405,17 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow()
m_cmp->SetLibId( id, Prj().SchSymbolLibTable(), Prj().SchLibs()->GetCacheLibrary() );
// For symbols with multiple shapes (De Morgan representation) Set the selected shape:
if( m_cbAlternateSymbol->IsEnabled() )
m_cmp->SetConvert( m_cbAlternateSymbol->GetValue() ? 2 : 1 );
int conversion = m_cbAlternateSymbol->IsEnabled()
? m_cbAlternateSymbol->GetValue()
: 0;
m_cmp->SetConvert( conversion );
//Set the part selection in multiple part per package
if( m_cmp->GetUnitCount() > 1 )
{
int unit_selection = m_unitChoice->GetCurrentSelection() + 1;
m_cmp->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
m_cmp->SetUnit( unit_selection );
}
int unit_selection = m_unitChoice->IsEnabled()
? m_unitChoice->GetSelection() + 1
: 0;
m_cmp->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
m_cmp->SetUnit( unit_selection );
switch( m_rbOrientation->GetSelection() )
{