Switch to using unit names in property inspector.

This commit is contained in:
Jeff Young 2025-02-14 23:02:27 +00:00
parent 56b8fec74b
commit d921a4e916
3 changed files with 29 additions and 12 deletions

View File

@ -3032,7 +3032,7 @@ static struct SCH_SYMBOL_DESC
return false; return false;
}; };
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, int>( _HKI( "Unit" ), propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, wxString>( _HKI( "Unit" ),
&SCH_SYMBOL::SetUnitProp, &SCH_SYMBOL::GetUnitProp ) ) &SCH_SYMBOL::SetUnitProp, &SCH_SYMBOL::GetUnitProp ) )
.SetAvailableFunc( multiUnit ); .SetAvailableFunc( multiUnit );

View File

@ -522,21 +522,37 @@ public:
SetValueFieldText( aRef ); SetValueFieldText( aRef );
} }
int GetUnitProp() const wxString GetUnitProp() const
{ {
return GetUnitSelection( &Schematic()->CurrentSheet() ); int unit = GetUnitSelection( &Schematic()->CurrentSheet() );
if( HasUnitDisplayName( unit ) )
return GetUnitDisplayName( unit );
else
return SubReference( unit, false );
} }
void SetUnitProp( int aUnit ) void SetUnitProp( const wxString& aUnit )
{ {
if( aUnit < 1 ) for( int unit = 1; unit <= GetUnitCount(); unit++ )
return; {
if( HasUnitDisplayName( unit ) && GetUnitDisplayName( unit ) == aUnit )
{
SetUnitSelection( &Schematic()->CurrentSheet(), unit );
SetUnit( unit );
return;
}
}
if( aUnit > GetUnitCount() ) for( int unit = 1; unit <= GetUnitCount(); unit++ )
aUnit = GetUnitCount(); {
if( SubReference( unit, false ) == aUnit )
SetUnitSelection( &Schematic()->CurrentSheet(), aUnit ); {
SetUnit( aUnit ); SetUnitSelection( &Schematic()->CurrentSheet(), unit );
SetUnit( unit );
return;
}
}
} }
int GetBodyStyleProp() const int GetBodyStyleProp() const

View File

@ -602,7 +602,8 @@ int SCH_DRAWING_TOOLS::PlaceNextSymbolUnit( const TOOL_EVENT& aEvent )
std::unique_ptr<SCH_SYMBOL> newSymbol = std::make_unique<SCH_SYMBOL>( *symbol ); std::unique_ptr<SCH_SYMBOL> newSymbol = std::make_unique<SCH_SYMBOL>( *symbol );
const SCH_SHEET_PATH& sheetPath = m_frame->GetCurrentSheet(); const SCH_SHEET_PATH& sheetPath = m_frame->GetCurrentSheet();
newSymbol->SetUnitProp( nextMissing ); newSymbol->SetUnitSelection( &sheetPath, nextMissing );
newSymbol->SetUnit( nextMissing );
newSymbol->SetRefProp( symbol->GetRef( &sheetPath, false ) ); newSymbol->SetRefProp( symbol->GetRef( &sheetPath, false ) );
// Post the new symbol - don't reannotate it - we set the reference ourselves // Post the new symbol - don't reannotate it - we set the reference ourselves