Move FP_TEXT::KeepUpright() to EDA_ANGLE.
This commit is contained in:
parent
5176512de3
commit
037dfb6e01
|
@ -127,7 +127,7 @@ public:
|
|||
SetTextAngle( EDA_ANGLE( aAngleInTenthsOfADegree, TENTHS_OF_A_DEGREE_T ) );
|
||||
}
|
||||
|
||||
void SetTextAngle( const EDA_ANGLE& aAngle );
|
||||
virtual void SetTextAngle( const EDA_ANGLE& aAngle );
|
||||
const EDA_ANGLE& GetTextAngle() const { return m_attributes.m_Angle; }
|
||||
|
||||
void SetItalic( bool aItalic );
|
||||
|
|
|
@ -1491,13 +1491,13 @@ void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
|||
SetPosition( newpos );
|
||||
SetOrientation( newOrientation );
|
||||
|
||||
m_reference->KeepUpright( orientation.AsTenthsOfADegree(), newOrientation.AsTenthsOfADegree() );
|
||||
m_value->KeepUpright( orientation.AsTenthsOfADegree(), newOrientation.AsTenthsOfADegree() );
|
||||
m_reference->KeepUpright( orientation, newOrientation );
|
||||
m_value->KeepUpright( orientation, newOrientation );
|
||||
|
||||
for( BOARD_ITEM* item : m_drawings )
|
||||
{
|
||||
if( item->Type() == PCB_FP_TEXT_T )
|
||||
static_cast<FP_TEXT*>( item )->KeepUpright( orientation.AsTenthsOfADegree(), newOrientation.AsTenthsOfADegree() );
|
||||
static_cast<FP_TEXT*>( item )->KeepUpright( orientation, newOrientation );
|
||||
}
|
||||
|
||||
m_boundingBoxCacheTimeStamp = 0;
|
||||
|
|
|
@ -45,7 +45,7 @@ FP_TEXT::FP_TEXT( FOOTPRINT* aParentFootprint, TEXT_TYPE text_type ) :
|
|||
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
|
||||
|
||||
m_Type = text_type;
|
||||
m_keepUpright = true;
|
||||
SetKeepUpright( true );
|
||||
|
||||
// Set text thickness to a default value
|
||||
SetTextThickness( Millimeter2iu( DEFAULT_TEXT_WIDTH ) );
|
||||
|
@ -110,19 +110,20 @@ bool FP_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
|
|||
}
|
||||
|
||||
|
||||
void FP_TEXT::KeepUpright( double aOldOrientation, double aNewOrientation )
|
||||
void FP_TEXT::KeepUpright( const EDA_ANGLE& aOldOrientation, const EDA_ANGLE& aNewOrientation )
|
||||
{
|
||||
if( !IsKeepUpright() )
|
||||
return;
|
||||
|
||||
double newAngle = GetTextAngle().AsTenthsOfADegree() + aNewOrientation;
|
||||
NORMALIZE_ANGLE_POS( newAngle );
|
||||
bool needsFlipped = newAngle >= 1800.0;
|
||||
EDA_ANGLE newAngle = GetTextAngle() + aNewOrientation;
|
||||
newAngle.Normalize();
|
||||
|
||||
bool needsFlipped = newAngle >= ANGLE_180;
|
||||
|
||||
if( needsFlipped )
|
||||
{
|
||||
SetHorizJustify( static_cast<GR_TEXT_H_ALIGN_T>( -GetHorizJustify() ) );
|
||||
SetTextAngle( GetTextAngle().AsTenthsOfADegree() + 1800.0 );
|
||||
SetTextAngle( GetTextAngle() + ANGLE_180 );
|
||||
SetDrawCoord();
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +248,7 @@ EDA_ANGLE FP_TEXT::GetDrawRotation() const
|
|||
if( parentFootprint )
|
||||
rotation += parentFootprint->GetOrientation();
|
||||
|
||||
if( m_keepUpright )
|
||||
if( IsKeepUpright() )
|
||||
{
|
||||
// Keep angle between 0 .. 90 deg. Otherwise the text is not easy to read
|
||||
while( rotation > ANGLE_90 )
|
||||
|
|
|
@ -96,20 +96,10 @@ public:
|
|||
SetLocalCoord();
|
||||
}
|
||||
|
||||
void SetTextAngle( double aAngle ) override;
|
||||
void SetTextAngle( const EDA_ANGLE& aAngle );
|
||||
|
||||
/**
|
||||
* Called when rotating the parent footprint.
|
||||
*/
|
||||
void KeepUpright( double aOldOrientation, double aNewOrientation );
|
||||
|
||||
/**
|
||||
* @return force the text rotation to be always between -90 .. 90 deg. Otherwise the text
|
||||
* is not easy to read if false, the text rotation is free.
|
||||
*/
|
||||
bool IsKeepUpright() const { return m_keepUpright; }
|
||||
void SetKeepUpright( bool aKeepUpright ) { m_keepUpright = aKeepUpright; }
|
||||
void KeepUpright( const EDA_ANGLE& aOldOrientation, const EDA_ANGLE& aNewOrientation );
|
||||
|
||||
/// Rotate text, in footprint editor
|
||||
/// (for instance in footprint rotation transform)
|
||||
|
@ -209,9 +199,6 @@ private:
|
|||
|
||||
VECTOR2I m_Pos0; ///< text coordinates relative to the footprint anchor, orient 0.
|
||||
///< text coordinate ref point is the text center
|
||||
|
||||
bool m_keepUpright; ///< if true, keep rotation angle between -90 .. 90 deg.
|
||||
///< to keep the text more easy to read
|
||||
};
|
||||
|
||||
#endif // FP_TEXT_H
|
||||
|
|
Loading…
Reference in New Issue