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

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

parent bb8741c7
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -153,6 +153,7 @@ void STROKE_FONT::Draw( const wxString& aText, const VECTOR2D& aPosition, double
    m_gal->Save();
    m_gal->Save();


    m_gal->Translate( aPosition );
    m_gal->Translate( aPosition );
    m_gal->Rotate( -aRotationAngle );


    // Single line height
    // Single line height
    int lineHeight = getInterline();
    int lineHeight = getInterline();
@@ -177,8 +178,6 @@ void STROKE_FONT::Draw( const wxString& aText, const VECTOR2D& aPosition, double
        break;
        break;
    }
    }


    m_gal->Rotate( -aRotationAngle );

    m_gal->SetIsStroke( true );
    m_gal->SetIsStroke( true );
    m_gal->SetIsFill( false );
    m_gal->SetIsFill( false );


+0 −37
Original line number Original line Diff line number Diff line
@@ -205,40 +205,3 @@ EDA_ITEM* TEXTE_PCB::Clone() const
{
{
    return new TEXTE_PCB( *this );
    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() );
    }
}
+0 −3
Original line number Original line Diff line number Diff line
@@ -135,9 +135,6 @@ public:


    EDA_ITEM* Clone() const;
    EDA_ITEM* Clone() const;


    /// @copydoc VIEW_ITEM::ViewBBox()
    virtual const BOX2I ViewBBox() const;

#if defined(DEBUG)
#if defined(DEBUG)
    virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); }    // override
    virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); }    // override
#endif
#endif