More VECTOR2D -> VECTOR2I and wxPoint cleanup.

This commit is contained in:
Jeff Young 2022-01-11 13:47:21 +00:00
parent acf2e1601c
commit 8f7d2dd06a
22 changed files with 150 additions and 229 deletions

View File

@ -119,7 +119,7 @@ void FONT::getLinePositions( const UTF8& aText, const VECTOR2I& aPosition,
height += interline; height += interline;
} }
wxPoint offset( 0, 0 ); VECTOR2I offset( 0, 0 );
offset.y += aAttrs.m_Size.y; offset.y += aAttrs.m_Size.y;
switch( aAttrs.m_Valign ) switch( aAttrs.m_Valign )
@ -132,7 +132,7 @@ void FONT::getLinePositions( const UTF8& aText, const VECTOR2I& aPosition,
for( int i = 0; i < lineCount; i++ ) for( int i = 0; i < lineCount; i++ )
{ {
VECTOR2I lineSize = aExtents.at( i ); VECTOR2I lineSize = aExtents.at( i );
wxPoint lineOffset( offset ); VECTOR2I lineOffset( offset );
lineOffset.y += i * interline; lineOffset.y += i * interline;
@ -188,7 +188,7 @@ void FONT::Draw( KIGFX::GAL* aGal, const UTF8& aText, const VECTOR2I& aPosition,
*/ */
VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs, VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const std::unique_ptr<MARKUP::NODE>& aNode, const VECTOR2I& aPosition, const std::unique_ptr<MARKUP::NODE>& aNode, const VECTOR2I& aPosition,
const KIFONT::FONT* aFont, const VECTOR2D& aSize, const EDA_ANGLE& aAngle, const KIFONT::FONT* aFont, const VECTOR2I& aSize, const EDA_ANGLE& aAngle,
bool aMirror, const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) bool aMirror, const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle )
{ {
VECTOR2I nextPosition = aPosition; VECTOR2I nextPosition = aPosition;
@ -229,7 +229,7 @@ VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* a
VECTOR2I FONT::drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs, VECTOR2I FONT::drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const UTF8& aText, const VECTOR2I& aPosition, const VECTOR2D& aSize, const UTF8& aText, const VECTOR2I& aPosition, const VECTOR2I& aSize,
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
TEXT_STYLE_FLAGS aTextStyle ) const TEXT_STYLE_FLAGS aTextStyle ) const
{ {
@ -242,7 +242,7 @@ VECTOR2I FONT::drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYP
void FONT::drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const UTF8& aText, void FONT::drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const UTF8& aText,
const VECTOR2I& aPosition, const VECTOR2D& aSize, const VECTOR2I& aPosition, const VECTOR2I& aSize,
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
bool aItalic ) const bool aItalic ) const
{ {
@ -264,7 +264,7 @@ void FONT::drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const UTF8
} }
VECTOR2I FONT::StringBoundaryLimits( const UTF8& aText, const VECTOR2D& aSize, int aThickness, VECTOR2I FONT::StringBoundaryLimits( const UTF8& aText, const VECTOR2I& aSize, int aThickness,
bool aBold, bool aItalic ) const bool aBold, bool aItalic ) const
{ {
// TODO do we need to parse every time - have we already parsed? // TODO do we need to parse every time - have we already parsed?
@ -295,7 +295,7 @@ VECTOR2I FONT::StringBoundaryLimits( const UTF8& aText, const VECTOR2D& aSize, i
VECTOR2I FONT::boundingBoxSingleLine( BOX2I* aBBox, const UTF8& aText, const VECTOR2I& aPosition, VECTOR2I FONT::boundingBoxSingleLine( BOX2I* aBBox, const UTF8& aText, const VECTOR2I& aPosition,
const VECTOR2D& aSize, bool aItalic ) const const VECTOR2I& aSize, bool aItalic ) const
{ {
TEXT_STYLE_FLAGS textStyle = 0; TEXT_STYLE_FLAGS textStyle = 0;

View File

@ -230,7 +230,7 @@ void OUTLINE_FONT::GetLinesAsGlyphs( std::vector<std::unique_ptr<GLYPH>>* aGlyph
VECTOR2I OUTLINE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs, VECTOR2I OUTLINE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const UTF8& aText, const VECTOR2D& aSize, const UTF8& aText, const VECTOR2I& aSize,
const VECTOR2I& aPosition, const EDA_ANGLE& aAngle, const VECTOR2I& aPosition, const EDA_ANGLE& aAngle,
bool aMirror, const VECTOR2I& aOrigin, bool aMirror, const VECTOR2I& aOrigin,
TEXT_STYLE_FLAGS aTextStyle ) const TEXT_STYLE_FLAGS aTextStyle ) const

View File

@ -205,7 +205,7 @@ double STROKE_FONT::ComputeOverbarVerticalPosition( double aGlyphHeight ) const
VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs, VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const UTF8& aText, const VECTOR2D& aSize, const UTF8& aText, const VECTOR2I& aSize,
const VECTOR2I& aPosition, const EDA_ANGLE& aAngle, const VECTOR2I& aPosition, const EDA_ANGLE& aAngle,
bool aMirror, const VECTOR2I& aOrigin, bool aMirror, const VECTOR2I& aOrigin,
TEXT_STYLE_FLAGS aTextStyle ) const TEXT_STYLE_FLAGS aTextStyle ) const

View File

@ -150,17 +150,11 @@ bool GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions )
} }
void GAL::SetTextAttributes( const TEXT_ATTRIBUTES& aAttributes )
{
m_attributes = aAttributes;
}
void GAL::ResetTextAttributes() void GAL::ResetTextAttributes()
{ {
// Tiny but non-zero - this will always need setting // Tiny but non-zero - this will always need setting
// there is no built-in default // there is no built-in default
SetGlyphSize( { 1.0, 1.0 } ); SetGlyphSize( { 1, 1 } );
SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
@ -260,51 +254,26 @@ COLOR4D GAL::getCursorColor() const
} }
void GAL::StrokeText( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle,
KIFONT::FONT* aFont, double aLineSpacing )
{
if( aText.IsEmpty() )
return;
if( !aFont )
aFont = KIFONT::FONT::GetFont( wxEmptyString );
TEXT_ATTRIBUTES attributes;
attributes.m_Angle = EDA_ANGLE( aRotationAngle, EDA_ANGLE::RADIANS );
attributes.m_Halign = GetHorizontalJustify();
attributes.m_Valign = GetVerticalJustify();
attributes.m_LineSpacing = aLineSpacing;
attributes.m_Size = GetGlyphSize();
attributes.m_StrokeWidth = GetLineWidth();
aFont->Draw( this, aText, aPosition, attributes );
}
/* /*
* Fallback for implementations that don't implement bitmap text: use stroke font * Fallback for implementations that don't implement bitmap text: use stroke font
*/ */
void GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle ) void GAL::BitmapText( const wxString& aText, const VECTOR2I& aPosition, const EDA_ANGLE& aAngle )
{ {
// Handle flipped view KIFONT::FONT* font = KIFONT::FONT::GetFont();
if( m_globalFlipX )
m_attributes.m_Mirrored = !m_attributes.m_Mirrored; if( aText.IsEmpty() )
return;
TEXT_ATTRIBUTES attrs = m_attributes;
attrs.m_Angle = aAngle;
attrs.m_Mirrored = m_globalFlipX; // Prevent text flipping when view is flipped
// Bitmap font is slightly smaller and slightly heavier than the stroke font so we // Bitmap font is slightly smaller and slightly heavier than the stroke font so we
// compensate a bit before stroking // compensate a bit before stroking
float saveLineWidth = m_lineWidth; attrs.m_StrokeWidth *= 1.2f;
VECTOR2D saveGlyphSize = m_attributes.m_Size; attrs.m_Size = attrs.m_Size * 0.8;
{
m_lineWidth *= 1.2f;
m_attributes.m_Size = m_attributes.m_Size * 0.8;
StrokeText( aText, aPosition, aRotationAngle ); font->Draw( this, aText, aPosition, attrs );
}
m_lineWidth = saveLineWidth;
m_attributes.m_Size = saveGlyphSize;
if( m_globalFlipX )
m_attributes.m_Mirrored = !m_attributes.m_Mirrored;
} }

View File

@ -1286,12 +1286,12 @@ void OPENGL_GAL::DrawBitmap( const BITMAP_BASE& aBitmap )
} }
void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition, void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2I& aPosition,
double aRotationAngle ) const EDA_ANGLE& aAngle )
{ {
// Fallback to generic impl (which uses the stroke font) on cases we don't handle // Fallback to generic impl (which uses the stroke font) on cases we don't handle
if( IsTextMirrored() || aText.Contains( wxT( "^{" ) ) || aText.Contains( wxT( "_{" ) ) ) if( IsTextMirrored() || aText.Contains( wxT( "^{" ) ) || aText.Contains( wxT( "_{" ) ) )
return GAL::BitmapText( aText, aPosition, aRotationAngle ); return GAL::BitmapText( aText, aPosition, aAngle );
const UTF8 text( aText ); const UTF8 text( aText );
VECTOR2D textSize; VECTOR2D textSize;
@ -1306,7 +1306,7 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a ); m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a );
m_currentManager->Translate( aPosition.x, aPosition.y, m_layerDepth ); m_currentManager->Translate( aPosition.x, aPosition.y, m_layerDepth );
m_currentManager->Rotate( aRotationAngle, 0.0f, 0.0f, -1.0f ); m_currentManager->Rotate( aAngle.AsRadians(), 0.0f, 0.0f, -1.0f );
double sx = SCALE * ( m_globalFlipX ? -1.0 : 1.0 ); double sx = SCALE * ( m_globalFlipX ? -1.0 : 1.0 );
double sy = SCALE * ( m_globalFlipY ? -1.0 : 1.0 ); double sy = SCALE * ( m_globalFlipY ? -1.0 : 1.0 );
@ -1352,8 +1352,7 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
for( UTF8::uni_iter chIt = text.ubegin(), end = text.uend(); chIt < end; ++chIt ) for( UTF8::uni_iter chIt = text.ubegin(), end = text.uend(); chIt < end; ++chIt )
{ {
wxASSERT_MSG( *chIt != '\n' && *chIt != '\r', wxASSERT_MSG( *chIt != '\n' && *chIt != '\r', "No support for multiline bitmap text yet" );
wxT( "No support for multiline bitmap text yet" ) );
if( *chIt == '~' && overbarDepth == -1 ) if( *chIt == '~' && overbarDepth == -1 )
{ {

View File

@ -61,9 +61,10 @@ wxString KIGFX::PREVIEW::DimensionLabel( const wxString& prefix, double aVal, ED
} }
KIGFX::PREVIEW::TEXT_DIMS KIGFX::PREVIEW::SetConstantGlyphHeight( KIGFX::GAL* aGal, KIGFX::PREVIEW::TEXT_DIMS KIGFX::PREVIEW::GetConstantGlyphHeight( KIGFX::GAL* aGal,
int aRelativeSize ) int aRelativeSize )
{ {
constexpr double aspectRatio = 1.0;
constexpr double hdpiSizes[] = { 8, 9, 11, 13, 15 }; constexpr double hdpiSizes[] = { 8, 9, 11, 13, 15 };
constexpr double sizes[] = { 10, 12, 14, 16, 18 }; constexpr double sizes[] = { 10, 12, 14, 16, 18 };
@ -91,15 +92,12 @@ KIGFX::PREVIEW::TEXT_DIMS KIGFX::PREVIEW::SetConstantGlyphHeight( KIGFX::GAL* aG
height /= aGal->GetWorldScale(); height /= aGal->GetWorldScale();
VECTOR2D glyphSize = aGal->GetGlyphSize();
glyphSize = glyphSize * ( height / glyphSize.y );
aGal->SetGlyphSize( glyphSize );
TEXT_DIMS textDims; TEXT_DIMS textDims;
textDims.StrokeWidth = glyphSize.x * thicknessFactor; textDims.GlyphSize = VECTOR2I( height * aspectRatio, height );
textDims.ShadowWidth = glyphSize.x * shadowFactor; textDims.StrokeWidth = height * thicknessFactor;
textDims.LinePitch = glyphSize.y * linePitchFactor; textDims.ShadowWidth = height * shadowFactor;
textDims.LinePitch = height * linePitchFactor;
return textDims; return textDims;
} }
@ -120,10 +118,11 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
bool aDrawingDropShadows ) bool aDrawingDropShadows )
{ {
KIGFX::GAL* gal = aView->GetGAL(); KIGFX::GAL* gal = aView->GetGAL();
RENDER_SETTINGS* rs = aView->GetPainter()->GetSettings(); KIFONT::FONT* font = KIFONT::FONT::GetFont();
// constant text size on screen // constant text size on screen
TEXT_DIMS textDims = SetConstantGlyphHeight( gal ); TEXT_DIMS textDims = GetConstantGlyphHeight( gal );
TEXT_ATTRIBUTES textAttrs;
// radius string goes on the right of the cursor centre line with a small horizontal // radius string goes on the right of the cursor centre line with a small horizontal
// offset (enough to keep clear of a system cursor if present) // offset (enough to keep clear of a system cursor if present)
@ -133,50 +132,42 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
// if the text goes above the cursor, shift it up // if the text goes above the cursor, shift it up
if( aTextQuadrant.y > 0 ) if( aTextQuadrant.y > 0 )
{
textPos.y -= textDims.LinePitch * ( aStrings.size() + 1 ); textPos.y -= textDims.LinePitch * ( aStrings.size() + 1 );
}
if( aTextQuadrant.x < 0 ) if( aTextQuadrant.x < 0 )
{ {
if( viewFlipped ) if( viewFlipped )
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT ); textAttrs.m_Halign = GR_TEXT_H_ALIGN_RIGHT;
else else
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT ); textAttrs.m_Halign = GR_TEXT_H_ALIGN_LEFT;
textPos.x += 15.0 / gal->GetWorldScale(); textPos.x += 15.0 / gal->GetWorldScale();
if( aDrawingDropShadows )
textPos.x -= textDims.ShadowWidth;
} }
else else
{ {
if( viewFlipped ) if( viewFlipped )
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT ); textAttrs.m_Halign = GR_TEXT_H_ALIGN_LEFT;
else else
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT ); textAttrs.m_Halign = GR_TEXT_H_ALIGN_RIGHT;
textPos.x -= 15.0 / gal->GetWorldScale(); textPos.x -= 15.0 / gal->GetWorldScale();
if( aDrawingDropShadows )
textPos.x += textDims.ShadowWidth;
} }
gal->SetIsFill( false ); gal->SetStrokeColor( aView->GetPainter()->GetSettings()->GetLayerColor( LAYER_AUX_ITEMS ) );
gal->SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ) ); textAttrs.m_Mirrored = viewFlipped; // Prevent text flipping when view is flipped
gal->SetLineWidth( textDims.StrokeWidth ); textAttrs.m_Size = textDims.GlyphSize;
gal->SetTextMirrored( viewFlipped ); // Prevent text flipping when view is flipped textAttrs.m_StrokeWidth = textDims.StrokeWidth;
if( aDrawingDropShadows ) if( aDrawingDropShadows )
{ {
textAttrs.m_StrokeWidth = textDims.StrokeWidth + ( 2 * textDims.ShadowWidth );
gal->SetStrokeColor( GetShadowColor( gal->GetStrokeColor() ) ); gal->SetStrokeColor( GetShadowColor( gal->GetStrokeColor() ) );
gal->SetLineWidth( gal->GetLineWidth() + 2 * textDims.ShadowWidth );
} }
// write strings top-to-bottom // write strings top-to-bottom
for( const wxString& str : aStrings ) for( const wxString& str : aStrings )
{ {
textPos.y += textDims.LinePitch; textPos.y += textDims.LinePitch;
gal->StrokeText( str, textPos, 0.0 ); font->Draw( gal, str, textPos, textAttrs );
} }
} }

View File

@ -151,42 +151,42 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT
double aMinorTickLen, EDA_UNITS aUnits, bool aDrawingDropShadows ) double aMinorTickLen, EDA_UNITS aUnits, bool aDrawingDropShadows )
{ {
KIGFX::GAL* gal = aView->GetGAL(); KIGFX::GAL* gal = aView->GetGAL();
KIFONT::FONT* font = KIFONT::FONT::GetFont();
VECTOR2D tickLine = aLine.Rotate( -M_PI_2 ); VECTOR2D tickLine = aLine.Rotate( -M_PI_2 );
double tickSpace; double tickSpace;
TICK_FORMAT tickF = getTickFormatForScale( gal->GetWorldScale(), tickSpace, aUnits ); TICK_FORMAT tickFormat = getTickFormatForScale( gal->GetWorldScale(), tickSpace, aUnits );
double majorTickLen = aMinorTickLen * ( majorTickLengthFactor + 1 );
// number of ticks in whole ruler // number of ticks in whole ruler
int numTicks = (int) std::ceil( aLine.EuclideanNorm() / tickSpace ); int numTicks = (int) std::ceil( aLine.EuclideanNorm() / tickSpace );
// work out which way up the tick labels go // work out which way up the tick labels go
TEXT_DIMS textDims = SetConstantGlyphHeight( gal, -1 ); TEXT_DIMS labelDims = GetConstantGlyphHeight( gal, -1 );
double textThickness = textDims.StrokeWidth;
double labelAngle = -tickLine.Angle(); double labelAngle = -tickLine.Angle();
double textOffset = 0; VECTOR2I labelOffset = tickLine.Resize( majorTickLen );
if( aDrawingDropShadows ) if( aDrawingDropShadows )
{ {
textOffset = textDims.ShadowWidth; labelOffset = { labelDims.ShadowWidth, labelDims.ShadowWidth };
textThickness += 2 * textDims.ShadowWidth; labelDims.StrokeWidth += 2 * labelDims.ShadowWidth;
} }
double majorTickLen = aMinorTickLen * ( majorTickLengthFactor + 1 );
VECTOR2D labelOffset = tickLine.Resize( majorTickLen - textOffset );
if( aView->IsMirroredX() ) if( aView->IsMirroredX() )
{
textOffset = -textOffset;
labelOffset = -labelOffset; labelOffset = -labelOffset;
}
TEXT_ATTRIBUTES labelAttrs;
labelAttrs.m_Size = labelDims.GlyphSize;
labelAttrs.m_StrokeWidth = labelDims.StrokeWidth;
if( aLine.Angle() > 0 ) if( aLine.Angle() > 0 )
{ {
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT ); labelAttrs.m_Halign = GR_TEXT_H_ALIGN_LEFT;
labelAttrs.m_Angle = EDA_ANGLE( labelAngle, EDA_ANGLE::RADIANS );
} }
else else
{ {
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT ); labelAttrs.m_Halign = GR_TEXT_H_ALIGN_RIGHT;
labelAngle += M_PI; labelAttrs.m_Angle = EDA_ANGLE( labelAngle + M_PI, EDA_ANGLE::RADIANS );
} }
BOX2D viewportD = aView->GetViewport(); BOX2D viewportD = aView->GetViewport();
@ -205,25 +205,24 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT
double length = aMinorTickLen; double length = aMinorTickLen;
bool drawLabel = false; bool drawLabel = false;
if( i % tickF.majorStep == 0 ) if( i % tickFormat.majorStep == 0 )
{ {
drawLabel = true; drawLabel = true;
length *= majorTickLengthFactor; length *= majorTickLengthFactor;
} }
else if( tickF.midStep && i % tickF.midStep == 0 ) else if( tickFormat.midStep && i % tickFormat.midStep == 0 )
{ {
drawLabel = true; drawLabel = true;
length *= midTickLengthFactor; length *= midTickLengthFactor;
} }
gal->SetLineWidth( textThickness / 2 ); gal->SetLineWidth( labelAttrs.m_StrokeWidth / 2 );
gal->DrawLine( tickPos, tickPos + tickLine.Resize( length ) ); gal->DrawLine( tickPos, tickPos + tickLine.Resize( length ) );
if( drawLabel ) if( drawLabel )
{ {
wxString label = DimensionLabel( "", tickSpace * i, aUnits, false ); wxString label = DimensionLabel( "", tickSpace * i, aUnits, false );
gal->SetLineWidth( textThickness ); font->Draw( gal, label, tickPos + labelOffset, labelAttrs );
gal->StrokeText( label, tickPos + labelOffset, labelAngle );
} }
} }
} }
@ -245,7 +244,7 @@ void drawBacksideTicks( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECTO
KIGFX::GAL* gal = aView->GetGAL(); KIGFX::GAL* gal = aView->GetGAL();
const double backTickSpace = aLine.EuclideanNorm() / aNumDivisions; const double backTickSpace = aLine.EuclideanNorm() / aNumDivisions;
const VECTOR2D backTickVec = aLine.Rotate( M_PI_2 ).Resize( aTickLen ); const VECTOR2D backTickVec = aLine.Rotate( M_PI_2 ).Resize( aTickLen );
TEXT_DIMS textDims = SetConstantGlyphHeight( gal, -1 ); TEXT_DIMS textDims = GetConstantGlyphHeight( gal, -1 );
BOX2D viewportD = aView->GetViewport(); BOX2D viewportD = aView->GetViewport();
BOX2I viewport( VECTOR2I( viewportD.GetPosition() ), VECTOR2I( viewportD.GetSize() ) ); BOX2I viewport( VECTOR2I( viewportD.GetPosition() ), VECTOR2I( viewportD.GetSize() ) );
@ -321,7 +320,7 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
gal->SetStrokeColor( GetShadowColor( gal->GetStrokeColor() ) ); gal->SetStrokeColor( GetShadowColor( gal->GetStrokeColor() ) );
gal->ResetTextAttributes(); gal->ResetTextAttributes();
TEXT_DIMS textDims = SetConstantGlyphHeight( gal ); TEXT_DIMS textDims = GetConstantGlyphHeight( gal );
// draw the main line from the origin to cursor // draw the main line from the origin to cursor
gal->SetLineWidth( getTickLineWidth( textDims, drawingDropShadows ) ); gal->SetLineWidth( getTickLineWidth( textDims, drawingDropShadows ) );

View File

@ -229,7 +229,7 @@ struct VIEW_OVERLAY::COMMAND_SET_WIDTH : public VIEW_OVERLAY::COMMAND
struct VIEW_OVERLAY::COMMAND_GLYPH_SIZE : public VIEW_OVERLAY::COMMAND struct VIEW_OVERLAY::COMMAND_GLYPH_SIZE : public VIEW_OVERLAY::COMMAND
{ {
COMMAND_GLYPH_SIZE( const VECTOR2D aSize ) : COMMAND_GLYPH_SIZE( const VECTOR2I aSize ) :
m_size( aSize ) m_size( aSize )
{ }; { };
@ -238,16 +238,17 @@ struct VIEW_OVERLAY::COMMAND_GLYPH_SIZE : public VIEW_OVERLAY::COMMAND
aView->GetGAL()->SetGlyphSize( m_size ); aView->GetGAL()->SetGlyphSize( m_size );
} }
VECTOR2D m_size; VECTOR2I m_size;
}; };
struct VIEW_OVERLAY::COMMAND_BITMAP_TEXT : public VIEW_OVERLAY::COMMAND struct VIEW_OVERLAY::COMMAND_BITMAP_TEXT : public VIEW_OVERLAY::COMMAND
{ {
COMMAND_BITMAP_TEXT( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle ) : COMMAND_BITMAP_TEXT( const wxString& aText, const VECTOR2I& aPosition,
const EDA_ANGLE& aAngle ) :
m_text( aText ), m_text( aText ),
m_pos( aPosition ), m_pos( aPosition ),
m_angle (aRotationAngle) m_angle( aAngle )
{ } { }
virtual void Execute( VIEW* aView ) const override virtual void Execute( VIEW* aView ) const override
@ -256,8 +257,8 @@ struct VIEW_OVERLAY::COMMAND_BITMAP_TEXT : public VIEW_OVERLAY::COMMAND
} }
wxString m_text; wxString m_text;
VECTOR2D m_pos; VECTOR2I m_pos;
double m_angle; EDA_ANGLE m_angle;
}; };
VIEW_OVERLAY::VIEW_OVERLAY() VIEW_OVERLAY::VIEW_OVERLAY()
@ -381,16 +382,16 @@ void VIEW_OVERLAY::SetIsFill( bool aIsFillEnabled )
} }
void VIEW_OVERLAY::SetGlyphSize( const VECTOR2D& aSize ) void VIEW_OVERLAY::SetGlyphSize( const VECTOR2I& aSize )
{ {
m_commands.push_back( new COMMAND_GLYPH_SIZE( aSize ) ); m_commands.push_back( new COMMAND_GLYPH_SIZE( aSize ) );
} }
void VIEW_OVERLAY::BitmapText( const wxString& aText, const VECTOR2D& aPosition, void VIEW_OVERLAY::BitmapText( const wxString& aText, const VECTOR2I& aPosition,
double aRotationAngle ) const EDA_ANGLE& aAngle )
{ {
m_commands.push_back( new COMMAND_BITMAP_TEXT( aText, aPosition, aRotationAngle ) ); m_commands.push_back( new COMMAND_BITMAP_TEXT( aText, aPosition, aAngle ) );
} }

View File

@ -1112,7 +1112,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
m_gal->SetFillColor( colour[i] ); m_gal->SetFillColor( colour[i] );
TEXT_ATTRIBUTES attrs; TEXT_ATTRIBUTES attrs;
attrs.m_Size = VECTOR2D( size[i], size[i] ); attrs.m_Size = VECTOR2I( size[i], size[i] );
attrs.m_Halign = hAlign; attrs.m_Halign = hAlign;
attrs.m_Valign = vAlign; attrs.m_Valign = vAlign;
attrs.m_Angle = aAngle; attrs.m_Angle = aAngle;

View File

@ -84,7 +84,7 @@ int GERBER_DRAW_ITEM::GetLayer() const
} }
bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, double& aOrientation ) bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, EDA_ANGLE& aOrientation )
{ {
// calculate the best size and orientation of the D_Code text // calculate the best size and orientation of the D_Code text
@ -105,7 +105,7 @@ bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, double& aO
else else
size = std::min( m_Size.x, m_Size.y ); size = std::min( m_Size.x, m_Size.y );
aOrientation = 0; aOrientation = EDA_ANGLE::HORIZONTAL;
if( m_Flashed ) if( m_Flashed )
{ {
@ -116,8 +116,9 @@ bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, double& aO
{ {
VECTOR2I delta = m_Start - m_End; VECTOR2I delta = m_Start - m_End;
aOrientation = RAD2DECIDEG( atan2( (double)delta.y, (double)delta.x ) ); double deci = RAD2DECIDEG( atan2( (double)delta.y, (double)delta.x ) );
NORMALIZE_ANGLE_90( aOrientation ); NORMALIZE_ANGLE_90( deci );
aOrientation = EDA_ANGLE( deci, EDA_ANGLE::TENTHS_OF_A_DEGREE );
// A reasonable size for text is size/2 because text needs margin below and above it. // A reasonable size for text is size/2 because text needs margin below and above it.
// a margin = size/4 seems good, expecting the line len is large enough to show 3 chars, // a margin = size/4 seems good, expecting the line len is large enough to show 3 chars,
@ -129,23 +130,6 @@ bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, double& aO
} }
bool GERBER_DRAW_ITEM::GetTextD_CodePrms( double& aSize, VECTOR2D& aPos, double& aOrientation )
{
// aOrientation is returned in radians
int size;
VECTOR2I pos;
if( ! GetTextD_CodePrms( size, pos, aOrientation ) )
return false;
aPos = pos;
aSize = (double) size;
aOrientation = DECIDEG2RAD( aOrientation );
return true;
}
VECTOR2I GERBER_DRAW_ITEM::GetABPosition( const VECTOR2I& aXYPosition ) const VECTOR2I GERBER_DRAW_ITEM::GetABPosition( const VECTOR2I& aXYPosition ) const
{ {
/* Note: RS274Xrevd_e is obscure about the order of transforms: /* Note: RS274Xrevd_e is obscure about the order of transforms:

View File

@ -26,6 +26,7 @@
#define GERBER_DRAW_ITEM_H #define GERBER_DRAW_ITEM_H
#include <eda_item.h> #include <eda_item.h>
#include <eda_angle.h>
#include <layer_ids.h> #include <layer_ids.h>
#include <gr_basic.h> #include <gr_basic.h>
#include <gbr_netlist_metadata.h> #include <gbr_netlist_metadata.h>
@ -87,13 +88,7 @@ public:
* @param aOrientation is a reference to return the text orientation * @param aOrientation is a reference to return the text orientation
* @return true if the parameters can be calculated, false for unknown D_Code * @return true if the parameters can be calculated, false for unknown D_Code
*/ */
bool GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, double& aOrientation ); bool GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, EDA_ANGLE& aOrientation );
/**
* Return the best size and orientation to display the D_Code in GAL
* aOrientation is returned in radians.
*/
bool GetTextD_CodePrms( double& aSize, VECTOR2D& aPos, double& aOrientation );
/** /**
* Optimize screen refresh (when no items are in background color refresh can be faster). * Optimize screen refresh (when no items are in background color refresh can be faster).

View File

@ -205,9 +205,9 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
if( IsDCodeLayer( aLayer ) ) if( IsDCodeLayer( aLayer ) )
{ {
wxString codeText; wxString codeText;
VECTOR2D textPosition; VECTOR2I textPosition;
double textSize; int textSize;
double orient; EDA_ANGLE orient;
if( !aItem->GetTextD_CodePrms( textSize, textPosition, orient ) ) if( !aItem->GetTextD_CodePrms( textSize, textPosition, orient ) )
return; return;

View File

@ -135,9 +135,9 @@ public:
/** /**
* Compute the boundary limits of aText (the bounding box of all shapes). * Compute the boundary limits of aText (the bounding box of all shapes).
* *
* @return a VECTOR2D giving the width and height of text. * @return a VECTOR2I giving the width and height of text.
*/ */
VECTOR2I StringBoundaryLimits( const UTF8& aText, const VECTOR2D& aSize, int aThickness, VECTOR2I StringBoundaryLimits( const UTF8& aText, const VECTOR2I& aSize, int aThickness,
bool aBold, bool aItalic ) const; bool aBold, bool aItalic ) const;
/** /**
@ -167,7 +167,7 @@ public:
* @return text cursor position after this text * @return text cursor position after this text
*/ */
virtual VECTOR2I GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs, virtual VECTOR2I GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const UTF8& aText, const VECTOR2D& aSize, const UTF8& aText, const VECTOR2I& aSize,
const VECTOR2I& aPosition, const EDA_ANGLE& aAngle, const VECTOR2I& aPosition, const EDA_ANGLE& aAngle,
bool aMirror, const VECTOR2I& aOrigin, bool aMirror, const VECTOR2I& aOrigin,
TEXT_STYLE_FLAGS aTextStyle ) const = 0; TEXT_STYLE_FLAGS aTextStyle ) const = 0;
@ -203,7 +203,7 @@ protected:
* @return new cursor position in non-rotated, non-mirrored coordinates * @return new cursor position in non-rotated, non-mirrored coordinates
*/ */
void drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const UTF8& aText, void drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const UTF8& aText,
const VECTOR2I& aPosition, const VECTOR2D& aSize, const VECTOR2I& aPosition, const VECTOR2I& aSize,
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
bool aItalic ) const; bool aItalic ) const;
@ -218,14 +218,14 @@ protected:
* @return new cursor position * @return new cursor position
*/ */
VECTOR2I boundingBoxSingleLine( BOX2I* aBBox, const UTF8& aText, const VECTOR2I& aPosition, VECTOR2I boundingBoxSingleLine( BOX2I* aBBox, const UTF8& aText, const VECTOR2I& aPosition,
const VECTOR2D& aSize, bool aItalic ) const; const VECTOR2I& aSize, bool aItalic ) const;
void getLinePositions( const UTF8& aText, const VECTOR2I& aPosition, void getLinePositions( const UTF8& aText, const VECTOR2I& aPosition,
wxArrayString& aTextLines, std::vector<VECTOR2I>& aPositions, wxArrayString& aTextLines, std::vector<VECTOR2I>& aPositions,
std::vector<VECTOR2I>& aExtents, const TEXT_ATTRIBUTES& aAttrs ) const; std::vector<VECTOR2I>& aExtents, const TEXT_ATTRIBUTES& aAttrs ) const;
VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs, VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const UTF8& aText, const VECTOR2I& aPosition, const VECTOR2D& aSize, const UTF8& aText, const VECTOR2I& aPosition, const VECTOR2I& aSize,
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
TEXT_STYLE_FLAGS aTextStyle ) const; TEXT_STYLE_FLAGS aTextStyle ) const;

View File

@ -98,7 +98,7 @@ public:
double GetInterline( double aGlyphHeight = 0.0, double aLineSpacing = 1.0 ) const override; double GetInterline( double aGlyphHeight = 0.0, double aLineSpacing = 1.0 ) const override;
VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs, VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const UTF8& aText, const VECTOR2D& aSize, const VECTOR2I& aPosition, const UTF8& aText, const VECTOR2I& aSize, const VECTOR2I& aPosition,
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
TEXT_STYLE_FLAGS aTextStyle ) const override; TEXT_STYLE_FLAGS aTextStyle ) const override;

View File

@ -77,7 +77,7 @@ public:
double GetInterline( double aGlyphHeight, double aLineSpacing = 1.0 ) const override; double GetInterline( double aGlyphHeight, double aLineSpacing = 1.0 ) const override;
VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs, VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const UTF8& aText, const VECTOR2D& aSize, const VECTOR2I& aPosition, const UTF8& aText, const VECTOR2I& aSize, const VECTOR2I& aPosition,
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
TEXT_STYLE_FLAGS aTextStyle ) const override; TEXT_STYLE_FLAGS aTextStyle ) const override;

View File

@ -343,44 +343,26 @@ public:
// Text // Text
// ---- // ----
/**
* Draw 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.
* @param aFont is the text font, or nullptr (defaults to newstroke)
* @param aLineSpacing is the line spacing for multiline text (defaults to 1.0)
*/
virtual void StrokeText( const wxString& aText, const VECTOR2D& aPosition,
double aRotationAngle, KIFONT::FONT* aFont = nullptr,
double aLineSpacing = 1.0 );
/** /**
* Draw a text using a bitmap font. It should be faster than StrokeText(), but can be used * Draw a text using a bitmap font. It should be faster than StrokeText(), but can be used
* only for non-Gerber elements. * only for non-Gerber elements.
* *
* @param aText is the text to be drawn. * @param aText is the text to be drawn.
* @param aPosition is the text position in world coordinates. * @param aPosition is the text position in world coordinates.
* @param aRotationAngle is the text rotation angle. * @param aAngle is the text rotation angle.
*/ */
virtual void BitmapText( const wxString& aText, const VECTOR2D& aPosition, virtual void BitmapText( const wxString& aText, const VECTOR2I& aPosition,
double aRotationAngle ); const EDA_ANGLE& aAngle );
/** /**
* Loads attributes of the text (bold/italic/underline/mirrored and so on). * Reset text attributes to default styling. FONT TODO: do we need any of this in GAL anymore?
*/
virtual void SetTextAttributes( const TEXT_ATTRIBUTES& aAttributes );
/**
* Reset text attributes to default styling.
* *
* Normally, custom attributes will be set individually after this, otherwise you can use * Normally, custom attributes will be set individually after this, otherwise you can use
* SetTextAttributes() * SetTextAttributes()
*/ */
void ResetTextAttributes(); void ResetTextAttributes();
void SetGlyphSize( const VECTOR2D aSize ) { m_attributes.m_Size = aSize; } void SetGlyphSize( const VECTOR2I aSize ) { m_attributes.m_Size = aSize; }
const VECTOR2D& GetGlyphSize() const { return m_attributes.m_Size; } const VECTOR2D& GetGlyphSize() const { return m_attributes.m_Size; }
inline void SetFontBold( const bool aBold ) { m_attributes.m_Bold = aBold; } inline void SetFontBold( const bool aBold ) { m_attributes.m_Bold = aBold; }

View File

@ -162,8 +162,8 @@ public:
void DrawBitmap( const BITMAP_BASE& aBitmap ) override; void DrawBitmap( const BITMAP_BASE& aBitmap ) override;
/// @copydoc GAL::BitmapText() /// @copydoc GAL::BitmapText()
void BitmapText( const wxString& aText, const VECTOR2D& aPosition, void BitmapText( const wxString& aText, const VECTOR2I& aPosition,
double aRotationAngle ) override; const EDA_ANGLE& aAngle ) override;
/// @copydoc GAL::DrawGrid() /// @copydoc GAL::DrawGrid()
void DrawGrid() override; void DrawGrid() override;

View File

@ -38,8 +38,9 @@ namespace PREVIEW
struct TEXT_DIMS struct TEXT_DIMS
{ {
double StrokeWidth; VECTOR2I GlyphSize;
double ShadowWidth; int StrokeWidth;
int ShadowWidth;
double LinePitch; double LinePitch;
}; };
@ -64,7 +65,7 @@ wxString DimensionLabel( const wxString& prefix, double aVal, EDA_UNITS aUnits,
* will give larger and -1 etc. will give smaller. * will give larger and -1 etc. will give smaller.
* @returns the text widths for the resulting glyph size. * @returns the text widths for the resulting glyph size.
*/ */
TEXT_DIMS SetConstantGlyphHeight( KIGFX::GAL* aGal, int aRelativeSize = 0 ); TEXT_DIMS GetConstantGlyphHeight( KIGFX::GAL* aGal, int aRelativeSize = 0 );
COLOR4D GetShadowColor( const COLOR4D& aColor ); COLOR4D GetShadowColor( const COLOR4D& aColor );

View File

@ -90,14 +90,14 @@ public:
void Polyline( const SHAPE_LINE_CHAIN& aPolyLine ); void Polyline( const SHAPE_LINE_CHAIN& aPolyLine );
void Polygon( const VECTOR2D aPointList[], int aListSize ); void Polygon( const VECTOR2D aPointList[], int aListSize );
void BitmapText( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle ); void BitmapText( const wxString& aText, const VECTOR2I& aPosition, const EDA_ANGLE& aAngle );
// Draw settings // Draw settings
void SetIsFill( bool aIsFillEnabled ); void SetIsFill( bool aIsFillEnabled );
void SetIsStroke( bool aIsStrokeEnabled ); void SetIsStroke( bool aIsStrokeEnabled );
void SetFillColor( const COLOR4D& aColor ); void SetFillColor( const COLOR4D& aColor );
void SetStrokeColor( const COLOR4D& aColor ); void SetStrokeColor( const COLOR4D& aColor );
void SetGlyphSize( const VECTOR2D& aSize ); void SetGlyphSize( const VECTOR2I& aSize );
void SetLineWidth( double aLineWidth ); void SetLineWidth( double aLineWidth );
const COLOR4D& GetStrokeColor() const { return m_strokeColor; } const COLOR4D& GetStrokeColor() const { return m_strokeColor; }

View File

@ -57,6 +57,7 @@
#include <geometry/shape_circle.h> #include <geometry/shape_circle.h>
#include <bezier_curves.h> #include <bezier_curves.h>
#include <kiface_base.h> #include <kiface_base.h>
#include <gr_text.h>
#include <pgm_base.h> #include <pgm_base.h>
#include "pcbnew_settings.h" #include "pcbnew_settings.h"
@ -582,21 +583,21 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
double textSize = width; double textSize = width;
double penWidth = width / 12.0; double penWidth = width / 12.0;
VECTOR2D textPosition = start + line / 2.0; // center of the track VECTOR2D textPosition = start + line / 2.0; // center of the track
double textOrientation; EDA_ANGLE textOrientation;
if( end.y == start.y ) // horizontal if( end.y == start.y ) // horizontal
{ {
textOrientation = 0; textOrientation = EDA_ANGLE::HORIZONTAL;
textPosition.y += penWidth; textPosition.y += penWidth;
} }
else if( end.x == start.x ) // vertical else if( end.x == start.x ) // vertical
{ {
textOrientation = M_PI / 2; textOrientation = EDA_ANGLE::VERTICAL;
textPosition.x += penWidth; textPosition.x += penWidth;
} }
else else
{ {
textOrientation = -atan( line.y / line.x ); textOrientation = EDA_ANGLE( -atan( line.y / line.x ), EDA_ANGLE::RADIANS );
textPosition.x += penWidth / 1.4; textPosition.x += penWidth / 1.4;
textPosition.y += penWidth / 1.4; textPosition.y += penWidth / 1.4;
} }
@ -772,7 +773,7 @@ void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
m_gal->SetGlyphSize( namesize ); m_gal->SetGlyphSize( namesize );
m_gal->SetLineWidth( namesize.x / 12.0 ); m_gal->SetLineWidth( namesize.x / 12.0 );
m_gal->BitmapText( netname, textpos, 0.0 ); m_gal->BitmapText( netname, textpos, EDA_ANGLE::HORIZONTAL );
m_gal->Restore(); m_gal->Restore();
@ -929,7 +930,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
// We have already translated the GAL to be centered at the center of the pad's // We have already translated the GAL to be centered at the center of the pad's
// bounding box // bounding box
VECTOR2D textpos( 0.0, 0.0 ); VECTOR2I textpos( 0, 0 );
// Divide the space, to display both pad numbers and netnames and set the Y text // Divide the space, to display both pad numbers and netnames and set the Y text
// position to display 2 lines // position to display 2 lines
@ -966,7 +967,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
m_gal->SetGlyphSize( namesize ); m_gal->SetGlyphSize( namesize );
m_gal->SetLineWidth( namesize.x / 12.0 ); m_gal->SetLineWidth( namesize.x / 12.0 );
m_gal->BitmapText( netname, textpos, 0.0 ); m_gal->BitmapText( netname, textpos, EDA_ANGLE::HORIZONTAL );
} }
if( displayPadNumber ) if( displayPadNumber )
@ -985,7 +986,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
m_gal->SetGlyphSize( numsize ); m_gal->SetGlyphSize( numsize );
m_gal->SetLineWidth( numsize.x / 12.0 ); m_gal->SetLineWidth( numsize.x / 12.0 );
m_gal->BitmapText( padNumber, textpos, 0.0 ); m_gal->BitmapText( padNumber, textpos, EDA_ANGLE::HORIZONTAL );
} }
m_gal->Restore(); m_gal->Restore();
@ -1715,7 +1716,6 @@ void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
// Scale by zoom a bit, but not too much // Scale by zoom a bit, but not too much
int textSize = ( scaledSize + ( unscaledSize * 2 ) ) / 3; int textSize = ( scaledSize + ( unscaledSize * 2 ) ) / 3;
int penWidth = textSize / 10;
VECTOR2I textOffset = VECTOR2I( width.x / 2, -KiROUND( textSize * 0.5 ) ); VECTOR2I textOffset = VECTOR2I( width.x / 2, -KiROUND( textSize * 0.5 ) );
VECTOR2I titleHeight = VECTOR2I( 0, KiROUND( textSize * 2.0 ) ); VECTOR2I titleHeight = VECTOR2I( 0, KiROUND( textSize * 2.0 ) );
@ -1725,16 +1725,14 @@ void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
m_gal->DrawLine( topLeft - titleHeight, topLeft + width - titleHeight ); m_gal->DrawLine( topLeft - titleHeight, topLeft + width - titleHeight );
m_gal->DrawLine( topLeft + width - titleHeight, topLeft + width ); m_gal->DrawLine( topLeft + width - titleHeight, topLeft + width );
m_gal->SetFontBold( false ); TEXT_ATTRIBUTES attrs;
m_gal->SetFontItalic( true ); attrs.m_Italic = true;
m_gal->SetFontUnderlined( false ); attrs.m_Halign = GR_TEXT_H_ALIGN_CENTER;
m_gal->SetTextMirrored( m_gal->IsFlippedX() ); attrs.m_Valign = GR_TEXT_V_ALIGN_BOTTOM;
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); attrs.m_Size = VECTOR2I( textSize, textSize );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM ); attrs.m_StrokeWidth = GetPenSizeForNormal( textSize );
m_gal->SetIsFill( false );
m_gal->SetGlyphSize( VECTOR2D( textSize, textSize ) ); KIFONT::FONT::GetFont()->Draw( m_gal, aGroup->GetName(), topLeft + textOffset, attrs );
m_gal->SetLineWidth( penWidth );
m_gal->StrokeText( aGroup->GetName(), topLeft + textOffset, 0.0 );
} }
} }
} }

View File

@ -197,13 +197,14 @@ int playground_main_func( int argc, char* argv[] )
{ {
overlay->SetStrokeColor( YELLOW ); overlay->SetStrokeColor( YELLOW );
overlay->Line( closestDist.A, closestDist.B ); overlay->Line( closestDist.A, closestDist.B );
overlay->SetLineWidth( 10000.0 ); overlay->SetLineWidth( 10000 );
overlay->SetGlyphSize( { 100000.0, 100000.0 } ); overlay->SetGlyphSize( { 100000, 100000 } );
overlay->BitmapText( wxString::Format( "dist=%d, l=%d", closestDist.Length() ), overlay->BitmapText( wxString::Format( "dist=%d, l=%d", closestDist.Length() ),
closestDist.A + VECTOR2I( 0, -arcs[i].GetWidth() ), 0 ); closestDist.A + VECTOR2I( 0, -arcs[i].GetWidth() ),
EDA_ANGLE::HORIZONTAL );
} }
overlay->SetLineWidth( 10000.0 ); overlay->SetLineWidth( 10000 );
overlay->SetStrokeColor( CYAN ); overlay->SetStrokeColor( CYAN );
overlay->AnnotatedPoint( arcs[i].GetP0(), arcs[i].GetWidth() / 2 ); overlay->AnnotatedPoint( arcs[i].GetP0(), arcs[i].GetWidth() / 2 );
overlay->AnnotatedPoint( arcs[i + 1].GetP0(), arcs[i + 1].GetWidth() / 2 ); overlay->AnnotatedPoint( arcs[i + 1].GetP0(), arcs[i + 1].GetWidth() / 2 );
@ -262,9 +263,10 @@ int drawShapes( int argc, char* argv[] )
{ {
int mult = ( i % 2 ) ? 1 : -1; int mult = ( i % 2 ) ? 1 : -1;
overlay->AnnotatedPoint( lc.GetPoint( i ), arc.GetWidth() * 2 ); overlay->AnnotatedPoint( lc.GetPoint( i ), arc.GetWidth() * 2 );
overlay->SetGlyphSize( { 800000.0, 800000.0 } ); overlay->SetGlyphSize( { 800000, 800000 } );
overlay->BitmapText( wxString::Format( "x=%d, y=%d", lc.GetPoint( i ).x, lc.GetPoint( i ).y ), overlay->BitmapText( wxString::Format( "x=%d, y=%d", lc.GetPoint( i ).x, lc.GetPoint( i ).y ),
lc.GetPoint( i ) + VECTOR2I( 0, mult*arc.GetWidth() * 4 ), 0 ); lc.GetPoint( i ) + VECTOR2I( 0, mult*arc.GetWidth() * 4 ),
EDA_ANGLE::HORIZONTAL );
} }
arc.Collide( &lc, 100000 ); arc.Collide( &lc, 100000 );

View File

@ -99,7 +99,7 @@ void LABEL_MANAGER::Redraw( KIGFX::VIEW_OVERLAY* aOvl )
aOvl->SetLineWidth( 10000 ); aOvl->SetLineWidth( 10000 );
aOvl->SetStrokeColor( lbl.m_color.Brighten( 0.7 ) ); aOvl->SetStrokeColor( lbl.m_color.Brighten( 0.7 ) );
aOvl->Rectangle( lbl.m_bbox.GetOrigin(), lbl.m_bbox.GetEnd() ); aOvl->Rectangle( lbl.m_bbox.GetOrigin(), lbl.m_bbox.GetEnd() );
aOvl->BitmapText( lbl.m_msg, lbl.m_bbox.Centre(), 0.0 ); aOvl->BitmapText( lbl.m_msg, lbl.m_bbox.Centre(), EDA_ANGLE::HORIZONTAL );
VECTOR2I nearest = nearestBoxCorner( lbl.m_bbox, lbl.m_target ); VECTOR2I nearest = nearestBoxCorner( lbl.m_bbox, lbl.m_target );
aOvl->Line( lbl.m_target, nearest ); aOvl->Line( lbl.m_target, nearest );
} }