Properties: specialize layer setting for footprints
Fixes https://gitlab.com/kicad/code/kicad/-/issues/12480
This commit is contained in:
parent
88495e5be1
commit
11e784cf10
|
@ -111,7 +111,7 @@ void PROPERTY_MANAGER::AddProperty( PROPERTY_BASE* aProperty )
|
||||||
|
|
||||||
void PROPERTY_MANAGER::ReplaceProperty( size_t aBase, const wxString& aName, PROPERTY_BASE* aNew )
|
void PROPERTY_MANAGER::ReplaceProperty( size_t aBase, const wxString& aName, PROPERTY_BASE* aNew )
|
||||||
{
|
{
|
||||||
wxASSERT( aBase == aNew->BaseHash() );
|
wxASSERT( aBase == aNew->BaseHash() || IsOfType( aNew->OwnerHash(), aBase ) );
|
||||||
CLASS_DESC& classDesc = getClass( aNew->OwnerHash() );
|
CLASS_DESC& classDesc = getClass( aNew->OwnerHash() );
|
||||||
classDesc.m_replaced.insert( std::make_pair( aBase, aName ) );
|
classDesc.m_replaced.insert( std::make_pair( aBase, aName ) );
|
||||||
AddProperty( aNew );
|
AddProperty( aNew );
|
||||||
|
|
|
@ -1559,6 +1559,15 @@ void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT::SetLayerAndFlip( PCB_LAYER_ID aLayer )
|
||||||
|
{
|
||||||
|
wxASSERT( aLayer == F_Cu || aLayer == B_Cu );
|
||||||
|
|
||||||
|
if( aLayer != GetLayer() )
|
||||||
|
Flip( GetPosition(), true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
|
void FOOTPRINT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
|
||||||
{
|
{
|
||||||
// Move footprint to its final position:
|
// Move footprint to its final position:
|
||||||
|
@ -1578,7 +1587,7 @@ void FOOTPRINT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
|
||||||
SetPosition( finalPos );
|
SetPosition( finalPos );
|
||||||
|
|
||||||
// Flip layer
|
// Flip layer
|
||||||
SetLayer( FlipLayer( GetLayer() ) );
|
BOARD_ITEM::SetLayer( FlipLayer( GetLayer() ) );
|
||||||
|
|
||||||
// Reverse mirror orientation.
|
// Reverse mirror orientation.
|
||||||
m_orient = -m_orient;
|
m_orient = -m_orient;
|
||||||
|
@ -2829,10 +2838,11 @@ static struct FOOTPRINT_DESC
|
||||||
propMgr.InheritsAfter( TYPE_HASH( FOOTPRINT ), TYPE_HASH( BOARD_ITEM ) );
|
propMgr.InheritsAfter( TYPE_HASH( FOOTPRINT ), TYPE_HASH( BOARD_ITEM ) );
|
||||||
propMgr.InheritsAfter( TYPE_HASH( FOOTPRINT ), TYPE_HASH( BOARD_ITEM_CONTAINER ) );
|
propMgr.InheritsAfter( TYPE_HASH( FOOTPRINT ), TYPE_HASH( BOARD_ITEM_CONTAINER ) );
|
||||||
|
|
||||||
auto layer = new PROPERTY_ENUM<FOOTPRINT, PCB_LAYER_ID, BOARD_ITEM>( _HKI( "Layer" ),
|
auto layer = new PROPERTY_ENUM<FOOTPRINT, PCB_LAYER_ID>( _HKI( "Layer" ),
|
||||||
&FOOTPRINT::SetLayer, &FOOTPRINT::GetLayer );
|
&FOOTPRINT::SetLayerAndFlip, &FOOTPRINT::GetLayer );
|
||||||
layer->SetChoices( fpLayers );
|
layer->SetChoices( fpLayers );
|
||||||
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ), layer );
|
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ), layer );
|
||||||
|
|
||||||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Reference" ),
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Reference" ),
|
||||||
&FOOTPRINT::SetReference, &FOOTPRINT::GetReferenceAsString ) );
|
&FOOTPRINT::SetReference, &FOOTPRINT::GetReferenceAsString ) );
|
||||||
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Value" ),
|
propMgr.AddProperty( new PROPERTY<FOOTPRINT, wxString>( _HKI( "Value" ),
|
||||||
|
|
|
@ -190,6 +190,15 @@ public:
|
||||||
void SetOrientation( const EDA_ANGLE& aNewAngle );
|
void SetOrientation( const EDA_ANGLE& aNewAngle );
|
||||||
EDA_ANGLE GetOrientation() const { return m_orient; }
|
EDA_ANGLE GetOrientation() const { return m_orient; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used as Layer property setter -- performs a flip if necessary to set the footprint layer
|
||||||
|
* @param aLayer is the target layer (F_Cu or B_Cu)
|
||||||
|
*/
|
||||||
|
void SetLayerAndFlip( PCB_LAYER_ID aLayer );
|
||||||
|
|
||||||
|
// to make property magic work
|
||||||
|
PCB_LAYER_ID GetLayer() const override { return BOARD_ITEM::GetLayer(); }
|
||||||
|
|
||||||
// For property system:
|
// For property system:
|
||||||
void SetOrientationDegrees( double aOrientation )
|
void SetOrientationDegrees( double aOrientation )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue