Commit 60e3b01a authored by Maciej Suminski's avatar Maciej Suminski

Fixed drawing of rotated texts that are not horizontally center aligned.

parent bb8741c7
......@@ -153,6 +153,7 @@ void STROKE_FONT::Draw( const wxString& aText, const VECTOR2D& aPosition, double
m_gal->Save();
m_gal->Translate( aPosition );
m_gal->Rotate( -aRotationAngle );
// Single line height
int lineHeight = getInterline();
......@@ -177,8 +178,6 @@ void STROKE_FONT::Draw( const wxString& aText, const VECTOR2D& aPosition, double
break;
}
m_gal->Rotate( -aRotationAngle );
m_gal->SetIsStroke( true );
m_gal->SetIsFill( false );
......
......@@ -205,40 +205,3 @@ EDA_ITEM* TEXTE_PCB::Clone() const
{
return new TEXTE_PCB( *this );
}
const BOX2I TEXTE_PCB::ViewBBox() const
{
EDA_RECT rect = GetTextBox();
if( m_Orient != 0.0 )
{
// If the text is rotated, we need to take it into account
wxPoint p1 = rect.GetOrigin();
wxPoint p2 = wxPoint( p1.x + rect.GetWidth(), p1.y );
wxPoint p3 = rect.GetEnd();
wxPoint p4 = wxPoint( p1.x, p1.y + rect.GetHeight() );
// Transform all the corners of the bounding box according to the rotation angle
RotatePoint( &p1, m_Pos, -m_Orient );
RotatePoint( &p2, m_Pos, -m_Orient );
RotatePoint( &p3, m_Pos, -m_Orient );
RotatePoint( &p4, m_Pos, -m_Orient );
// Find the new bounding box origin and dimensions
int minX = std::min( std::min( p1.x, p2.x ), std::min( p3.x, p4.x ) );
int minY = std::min( std::min( p1.y, p2.y ), std::min( p3.y, p4.y ) );
int maxX = std::max( std::max( p1.x, p2.x ), std::max( p3.x, p4.x ) );
int maxY = std::max( std::max( p1.y, p2.y ), std::max( p3.y, p4.y ) );
int width = maxX - minX;
int height = maxY - minY;
return BOX2I( VECTOR2I( minX, minY ), VECTOR2I( width, height ) );
}
else
{
return BOX2I( rect.GetOrigin(), rect.GetSize() );
}
}
......@@ -135,9 +135,6 @@ public:
EDA_ITEM* Clone() const;
/// @copydoc VIEW_ITEM::ViewBBox()
virtual const BOX2I ViewBBox() const;
#if defined(DEBUG)
virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment