Commit 84392f17 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Moved STROKE_FONT from PAINTER to GAL.

parent fe6c901a
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -28,12 +28,12 @@

#include <gal/graphics_abstraction_layer.h>
#include <gal/definitions.h>
#include <gal/color4d.h>


using namespace KiGfx;

GAL::GAL()
GAL::GAL() :
        strokeFont( this )
{
    // Set the default values for the internal variables
    SetIsFill( false );
@@ -47,6 +47,8 @@ GAL::GAL()
    SetCoarseGrid( 5 );
    SetLineWidth( 1.0 );
    SetDepthRange( VECTOR2D( -2048, 2047 ) );

    strokeFont.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize );
}


@@ -156,3 +158,13 @@ void GAL::DrawGrid()
    SetStrokeColor( savedColor );
}


void GAL::SetTextAttributes( const EDA_TEXT* aText )
{
    strokeFont.SetGlyphSize( VECTOR2D( aText->GetSize() ) );
    strokeFont.SetHorizontalJustify( aText->GetHorizJustify() );
    strokeFont.SetVerticalJustify( aText->GetVertJustify() );
    strokeFont.SetBold( aText->IsBold() );
    strokeFont.SetItalic( aText->IsItalic() );
    strokeFont.SetMirrored( aText->IsMirrored() );
}
+0 −11
Original line number Diff line number Diff line
@@ -114,17 +114,6 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe
}


void STROKE_FONT::LoadAttributes( const EDA_TEXT* aText )
{
    SetGlyphSize( VECTOR2D( aText->GetSize() ) );
    SetHorizontalJustify( aText->GetHorizJustify() );
    SetVerticalJustify( aText->GetVertJustify() );
    SetBold( aText->IsBold() );
    SetItalic( aText->IsItalic() );
    SetMirrored( aText->IsMirrored() );
}


BOX2D STROKE_FONT::computeBoundingBox( const Glyph& aGlyph, const VECTOR2D& aGlyphBoundingX ) const
{
    BOX2D boundingBox;
+0 −6
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@
 */

#include <painter.h>
#include <gal/stroke_font.h>
#include <newstroke_font.h>

using namespace KiGfx;

@@ -70,14 +68,11 @@ void RENDER_SETTINGS::Update()
PAINTER::PAINTER( GAL* aGal ) :
    m_gal( aGal ), m_settings( NULL )
{
    m_stroke_font = new STROKE_FONT( aGal );
    m_stroke_font->LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize );
}


PAINTER::~PAINTER()
{
    delete m_stroke_font;
    delete m_settings;
}

@@ -85,5 +80,4 @@ PAINTER::~PAINTER()
void PAINTER::SetGAL( GAL* aGal )
{
    m_gal = aGal;
    m_stroke_font->SetGAL( aGal );
}
+29 −1
Original line number Diff line number Diff line
@@ -33,8 +33,10 @@
#include <wx/event.h>

#include <math/matrix3x3.h>
#include <gal/color4d.h>

#include <gal/color4d.h>
#include <gal/stroke_font.h>
#include <newstroke_font.h>

namespace KiGfx
{
@@ -260,6 +262,29 @@ public:
        layerDepth = aLayerDepth;
    }

    // ----
    // Text
    // ----
    /**
     * @brief Draws a vector type text using preloaded Newstroke font.
     *
     * @param aText is the text to be drawn.
     * @param aPosition is the text position in world coordinates.
     * @param aRotationAngle is the text rotation angle.
     */
    inline virtual void StrokeText( const std::string& aText, const VECTOR2D& aPosition,
                                    double aRotationAngle )
    {
        strokeFont.Draw( aText, aPosition, aRotationAngle );
    }

    /**
     * @brief Loads attributes of the given text (bold/italic/underline/mirrored and so on).
     *
     * @param aText is the text item.
     */
    virtual void SetTextAttributes( const EDA_TEXT* aText );

    // --------------
    // Transformation
    // --------------
@@ -696,6 +721,9 @@ protected:
    VECTOR2D           cursorPosition;         ///< The cursor position
    COLOR4D            cursorColor;            ///< Cursor color

    /// Instance of object that stores information about how to draw texts
    STROKE_FONT        strokeFont;

    /// Compute the scaling factor for the world->screen matrix
    inline void ComputeWorldScale()
    {
+0 −7
Original line number Diff line number Diff line
@@ -66,13 +66,6 @@ public:
     */
    bool LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNewStrokeFontSize );

    /**
     * @brief Load attributes of a given text, in order to be used during drawing.
     *
     * @param aText is the text string.
     */
    void LoadAttributes( const EDA_TEXT* aText );

    /**
     * @brief Draw a string.
     *
Loading