mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Update properties to show units
The function duplicated our built-in funcitonality and did not properly handly outputs Fixes https://gitlab.com/kicad/code/kicad/issues/21685
This commit is contained in:
parent
0acc659676
commit
3f8abe3744
@ -165,28 +165,6 @@ SCH_ITEM* SCH_ITEM::Duplicate( bool addToParentGroup, SCH_COMMIT* aCommit, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_ITEM::SetUnitProp( const wxString& aUnit )
|
|
||||||
{
|
|
||||||
if( aUnit == _HKI( "All units" ) )
|
|
||||||
{
|
|
||||||
m_unit = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( SYMBOL* symbol = GetParentSymbol() )
|
|
||||||
{
|
|
||||||
for( int unit = 1; unit <= symbol->GetUnitCount(); unit++ )
|
|
||||||
{
|
|
||||||
if( symbol->GetUnitDisplayName( unit, false ) == aUnit )
|
|
||||||
{
|
|
||||||
m_unit = unit;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxString SCH_ITEM::GetUnitDisplayName( int aUnit, bool aLabel ) const
|
wxString SCH_ITEM::GetUnitDisplayName( int aUnit, bool aLabel ) const
|
||||||
{
|
{
|
||||||
if( aUnit == 0 )
|
if( aUnit == 0 )
|
||||||
@ -208,13 +186,6 @@ wxString SCH_ITEM::GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const
|
|||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString SCH_ITEM::GetUnitProp() const
|
|
||||||
{
|
|
||||||
return GetUnitDisplayName( m_unit, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SCH_ITEM::SetBodyStyleProp( const wxString& aBodyStyle )
|
void SCH_ITEM::SetBodyStyleProp( const wxString& aBodyStyle )
|
||||||
{
|
{
|
||||||
if( aBodyStyle == _HKI( "All body styles" ) )
|
if( aBodyStyle == _HKI( "All body styles" ) )
|
||||||
@ -734,21 +705,21 @@ static struct SCH_ITEM_DESC
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
propMgr.AddProperty( new PROPERTY<SCH_ITEM, wxString>( _HKI( "Unit" ),
|
propMgr.AddProperty( new PROPERTY<SCH_ITEM, int>( _HKI( "Unit" ),
|
||||||
&SCH_ITEM::SetUnitProp, &SCH_ITEM::GetUnitProp ) )
|
&SCH_ITEM::SetUnit, &SCH_ITEM::GetUnit ) )
|
||||||
.SetAvailableFunc( multiUnit )
|
.SetAvailableFunc( multiUnit )
|
||||||
.SetIsHiddenFromDesignEditors()
|
.SetIsHiddenFromDesignEditors()
|
||||||
.SetChoicesFunc( []( INSPECTABLE* aItem )
|
.SetChoicesFunc( []( INSPECTABLE* aItem )
|
||||||
{
|
{
|
||||||
wxPGChoices choices;
|
wxPGChoices choices;
|
||||||
choices.Add( _HKI( "All units" ) );
|
choices.Add( _HKI( "All units" ), 0 );
|
||||||
|
|
||||||
if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
|
if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
|
||||||
{
|
{
|
||||||
if( SYMBOL* symbol = item->GetParentSymbol() )
|
if( SYMBOL* symbol = item->GetParentSymbol() )
|
||||||
{
|
{
|
||||||
for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
|
for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
|
||||||
choices.Add( symbol->GetUnitDisplayName( ii, false ) );
|
choices.Add( symbol->GetUnitDisplayName( ii, false ), ii );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,9 +240,6 @@ public:
|
|||||||
virtual wxString GetUnitDisplayName( int aUnit, bool aLabel ) const;
|
virtual wxString GetUnitDisplayName( int aUnit, bool aLabel ) const;
|
||||||
virtual wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const;
|
virtual wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const;
|
||||||
|
|
||||||
virtual void SetUnitProp( const wxString& aUnit );
|
|
||||||
virtual wxString GetUnitProp() const;
|
|
||||||
|
|
||||||
virtual void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; }
|
virtual void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; }
|
||||||
int GetBodyStyle() const { return m_bodyStyle; }
|
int GetBodyStyle() const { return m_bodyStyle; }
|
||||||
|
|
||||||
|
@ -2986,7 +2986,7 @@ static struct SCH_SYMBOL_DESC
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, wxString>( _HKI( "Unit" ),
|
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, int>( _HKI( "Unit" ),
|
||||||
&SCH_SYMBOL::SetUnitProp, &SCH_SYMBOL::GetUnitProp ) )
|
&SCH_SYMBOL::SetUnitProp, &SCH_SYMBOL::GetUnitProp ) )
|
||||||
.SetAvailableFunc( multiUnit )
|
.SetAvailableFunc( multiUnit )
|
||||||
.SetChoicesFunc( []( INSPECTABLE* aItem )
|
.SetChoicesFunc( []( INSPECTABLE* aItem )
|
||||||
@ -2996,7 +2996,7 @@ static struct SCH_SYMBOL_DESC
|
|||||||
if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( aItem ) )
|
if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( aItem ) )
|
||||||
{
|
{
|
||||||
for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
|
for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
|
||||||
choices.Add( symbol->GetUnitDisplayName( ii, false ) );
|
choices.Add( symbol->GetUnitDisplayName( ii, false ), ii );
|
||||||
}
|
}
|
||||||
|
|
||||||
return choices;
|
return choices;
|
||||||
|
@ -497,24 +497,15 @@ public:
|
|||||||
SetValueFieldText( aRef );
|
SetValueFieldText( aRef );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString GetUnitProp() const override
|
int GetUnitProp() const
|
||||||
{
|
{
|
||||||
int unit = GetUnitSelection( &Schematic()->CurrentSheet() );
|
return GetUnitSelection( &Schematic()->CurrentSheet() );
|
||||||
|
|
||||||
return GetUnitDisplayName( unit, false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUnitProp( const wxString& aUnit ) override
|
void SetUnitProp( int aUnit )
|
||||||
{
|
{
|
||||||
for( int unit = 1; unit <= GetUnitCount(); unit++ )
|
SetUnitSelection( &Schematic()->CurrentSheet(), aUnit );
|
||||||
{
|
SetUnit( aUnit );
|
||||||
if( GetUnitDisplayName( unit, false ) == aUnit )
|
|
||||||
{
|
|
||||||
SetUnitSelection( &Schematic()->CurrentSheet(), unit );
|
|
||||||
SetUnit( unit );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString GetBodyStyleProp() const override
|
wxString GetBodyStyleProp() const override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user