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

Moved STROKE_FONT from PAINTER to GAL.

parent fe6c901a
......@@ -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() );
}
......@@ -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;
......
......@@ -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 );
}
......@@ -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()
{
......
......@@ -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.
*
......
......@@ -40,7 +40,6 @@ class COLORS_DESIGN_SETTINGS;
namespace KiGfx
{
class GAL;
class STROKE_FONT;
class VIEW_ITEM;
/**
......@@ -231,10 +230,6 @@ protected:
/// commands used to draw (eg. DrawLine, DrawCircle, etc.)
GAL* m_gal;
/// Instance of object that stores information about how to draw texts (including different
/// font display modes [bold/italic/mirror]).
STROKE_FONT* m_stroke_font;
/// Colors and display modes settings that are going to be used when drawing items.
RENDER_SETTINGS* m_settings;
};
......
......@@ -38,8 +38,6 @@
#include <view/view.h>
#include <pcb_painter.h>
#include <gal/graphics_abstraction_layer.h>
#include <gal/stroke_font.h>
#include <newstroke_font.h>
using namespace KiGfx;
......@@ -482,8 +480,8 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText )
m_gal->SetStrokeColor( strokeColor );
m_gal->SetLineWidth( aText->GetThickness() );
m_stroke_font->LoadAttributes( aText );
m_stroke_font->Draw( std::string( aText->GetText().mb_str() ), position, orientation );
m_gal->SetTextAttributes( aText );
m_gal->StrokeText( std::string( aText->GetText().mb_str() ), position, orientation );
}
......@@ -495,8 +493,8 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
m_gal->SetStrokeColor( strokeColor );
m_gal->SetLineWidth( aText->GetThickness() );
m_stroke_font->LoadAttributes( aText );
m_stroke_font->Draw( std::string( aText->GetText().mb_str() ), position, orientation );
m_gal->SetTextAttributes( aText );
m_gal->StrokeText( std::string( aText->GetText().mb_str() ), position, orientation );
}
......
......@@ -52,7 +52,6 @@ class PCB_TARGET;
namespace KiGfx
{
class GAL;
class STROKE_FONT;
/**
* Class PCB_RENDER_SETTINGS
......
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