Separate symbol angle and mirroring in prop manager.

This commit is contained in:
Jeff Young 2024-01-19 13:29:08 +00:00
parent f80094e7c5
commit 4d80da8238
2 changed files with 84 additions and 5 deletions

View File

@ -1604,6 +1604,12 @@ void SCH_SYMBOL::SetOrientation( int aOrientation )
SetOrientation( SYM_MIRROR_Y );
break;
case ( SYM_ORIENT_0 + SYM_MIRROR_X + SYM_MIRROR_Y ):
SetOrientation( SYM_ORIENT_0 );
SetOrientation( SYM_MIRROR_X );
SetOrientation( SYM_MIRROR_Y );
break;
case ( SYM_ORIENT_90 + SYM_MIRROR_X ):
SetOrientation( SYM_ORIENT_90 );
SetOrientation( SYM_MIRROR_X );
@ -1614,6 +1620,12 @@ void SCH_SYMBOL::SetOrientation( int aOrientation )
SetOrientation( SYM_MIRROR_Y );
break;
case ( SYM_ORIENT_90 + SYM_MIRROR_X + SYM_MIRROR_Y ):
SetOrientation( SYM_ORIENT_90 );
SetOrientation( SYM_MIRROR_X );
SetOrientation( SYM_MIRROR_Y );
break;
case ( SYM_ORIENT_180 + SYM_MIRROR_X ):
SetOrientation( SYM_ORIENT_180 );
SetOrientation( SYM_MIRROR_X );
@ -1624,6 +1636,12 @@ void SCH_SYMBOL::SetOrientation( int aOrientation )
SetOrientation( SYM_MIRROR_Y );
break;
case ( SYM_ORIENT_180 + SYM_MIRROR_X + SYM_MIRROR_Y ):
SetOrientation( SYM_ORIENT_180 );
SetOrientation( SYM_MIRROR_X );
SetOrientation( SYM_MIRROR_Y );
break;
case ( SYM_ORIENT_270 + SYM_MIRROR_X ):
SetOrientation( SYM_ORIENT_270 );
SetOrientation( SYM_MIRROR_X );
@ -1634,6 +1652,12 @@ void SCH_SYMBOL::SetOrientation( int aOrientation )
SetOrientation( SYM_MIRROR_Y );
break;
case ( SYM_ORIENT_270 + SYM_MIRROR_X + SYM_MIRROR_Y ):
SetOrientation( SYM_ORIENT_270 );
SetOrientation( SYM_MIRROR_X );
SetOrientation( SYM_MIRROR_Y );
break;
default:
transform = false;
wxFAIL_MSG( "Invalid schematic symbol orientation type." );
@ -2619,8 +2643,12 @@ static struct SCH_SYMBOL_DESC
ORIGIN_TRANSFORMS::ABS_Y_COORD ) );
propMgr.AddProperty( new PROPERTY_ENUM<SCH_SYMBOL, SYMBOL_ORIENTATION_PROP>(
_HKI( "Orientation" ), &SCH_SYMBOL::SetOrientationProp,
&SCH_SYMBOL::GetOrientationProp ) );
_HKI( "Orientation" ),
&SCH_SYMBOL::SetOrientationProp, &SCH_SYMBOL::GetOrientationProp ) );
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, bool>( _HKI( "Mirror X" ),
&SCH_SYMBOL::SetMirrorX, &SCH_SYMBOL::GetMirrorX ) );
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, bool>( _HKI( "Mirror Y" ),
&SCH_SYMBOL::SetMirrorY, &SCH_SYMBOL::GetMirrorY ) );
auto isMultiUnitSymbol =
[]( INSPECTABLE* aItem ) -> bool

View File

@ -350,15 +350,66 @@ public:
int GetOrientation() const;
/**
* Access for property manager.
* Orientation/mirroring access for property manager.
*/
void SetOrientationProp( SYMBOL_ORIENTATION_PROP aAngle )
{
SetOrientation( aAngle );
int mirroring = GetOrientation();
mirroring &= ( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
SetOrientation( aAngle | mirroring );
}
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
{
return (SYMBOL_ORIENTATION_PROP) GetOrientation();
int orientation = GetOrientation();
orientation &= ~( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
switch( orientation )
{
default:
case SYM_NORMAL:
case SYM_ORIENT_0: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0;
case SYM_ORIENT_90: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_90;
case SYM_ORIENT_180: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_180;
case SYM_ORIENT_270: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_270;
}
}
void SetMirrorX( bool aMirror )
{
int orientation = GetOrientation();
if( aMirror )
orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
else
orientation &= ~SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
SetOrientation( orientation );
}
bool GetMirrorX() const
{
return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
}
void SetMirrorY( bool aMirror )
{
int orientation = GetOrientation();
if( aMirror )
orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
else
orientation &= ~SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
SetOrientation( orientation );
}
bool GetMirrorY() const
{
return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
}
/**