diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index a8f0b1a53b..e11680da94 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -422,9 +422,10 @@ void SCH_SYMBOL::UpdatePins() void SCH_SYMBOL::SetBodyStyle( int aBodyStyle ) { - if( m_bodyStyle != aBodyStyle ) + if( HasAlternateBodyStyle() && m_bodyStyle != aBodyStyle ) { - m_bodyStyle = aBodyStyle; + m_bodyStyle = ( m_bodyStyle == BODY_STYLE::BASE ) ? BODY_STYLE::DEMORGAN + : BODY_STYLE::BASE; // The body style may have a different pin layout so the update the pin map. UpdatePins(); @@ -2800,6 +2801,32 @@ static struct SCH_SYMBOL_DESC NO_SETTER( SCH_SYMBOL, wxString ), &SCH_SYMBOL::GetKeyWords ), groupFields ); + auto multiUnit = + [=]( INSPECTABLE* aItem ) -> bool + { + if( SCH_SYMBOL* symbol = dynamic_cast( aItem ) ) + return symbol->IsMulti(); + + return false; + }; + + auto multiBodyStyle = + [=]( INSPECTABLE* aItem ) -> bool + { + if( SCH_SYMBOL* symbol = dynamic_cast( aItem ) ) + return symbol->HasAlternateBodyStyle(); + + return false; + }; + + propMgr.AddProperty( new PROPERTY( _HKI( "Unit" ), + &SCH_SYMBOL::SetUnitProp, &SCH_SYMBOL::GetUnitProp ) ) + .SetAvailableFunc( multiUnit ); + + propMgr.AddProperty( new PROPERTY( _HKI( "Body Style" ), + &SCH_SYMBOL::SetBodyStyleProp, &SCH_SYMBOL::GetBodyStyleProp ) ) + .SetAvailableFunc( multiBodyStyle ); + const wxString groupAttributes = _HKI( "Attributes" ); propMgr.AddProperty( new PROPERTY( _HKI( "Exclude From Board" ), diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index b6e4381b6d..b12eef7b51 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -548,6 +548,29 @@ public: { SetValueFieldText( aRef ); } + int GetUnitProp() const + { + return GetUnitSelection( &Schematic()->CurrentSheet() ); + } + void SetUnitProp( int aUnit ) + { + if( aUnit < 1 ) + return; + + if( aUnit > GetUnitCount() ) + aUnit = GetUnitCount(); + + SetUnitSelection( &Schematic()->CurrentSheet(), aUnit ); + SetUnit( aUnit ); + } + int GetBodyStyleProp() const + { + return GetBodyStyle(); + } + void SetBodyStyleProp( int aBodyStyle ) + { + SetBodyStyle( aBodyStyle ); + } /** * Restore fields to the original library values.