diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index e650b5649d..5235caccc4 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -296,6 +296,9 @@ set( PLUGINS_EAGLE_SRCS
plugins/eagle/eagle_parser.cpp
)
+set( FONT_SRCS
+ )
+
set( COMMON_SRCS
${LIB_KICAD_SRCS}
${COMMON_ABOUT_DLG_SRCS}
@@ -307,6 +310,7 @@ set( COMMON_SRCS
${PLUGINS_ALTIUM_SRCS}
${PLUGINS_CADSTAR_SRCS}
${PLUGINS_EAGLE_SRCS}
+ ${FONT_SRCS}
advanced_config.cpp
array_axis.cpp
array_options.cpp
@@ -325,6 +329,7 @@ set( COMMON_SRCS
dialog_shim.cpp
gr_text.cpp
dsnlexer.cpp
+ eda_angle.cpp
eda_base_frame.cpp
eda_dde.cpp
eda_doc.cpp
diff --git a/common/drawing_sheet/drawing_sheet_parser.cpp b/common/drawing_sheet/drawing_sheet_parser.cpp
index d848b5d5ab..059b8fe41d 100644
--- a/common/drawing_sheet/drawing_sheet_parser.cpp
+++ b/common/drawing_sheet/drawing_sheet_parser.cpp
@@ -729,24 +729,24 @@ void DRAWING_SHEET_PARSER::parseText( DS_DATA_ITEM_TEXT* aItem )
switch( token )
{
case T_center:
- aItem->m_Hjustify = GR_TEXT_HJUSTIFY_CENTER;
- aItem->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER;
+ aItem->m_Hjustify = GR_TEXT_H_ALIGN_CENTER;
+ aItem->m_Vjustify = GR_TEXT_V_ALIGN_CENTER;
break;
case T_left:
- aItem->m_Hjustify = GR_TEXT_HJUSTIFY_LEFT;
+ aItem->m_Hjustify = GR_TEXT_H_ALIGN_LEFT;
break;
case T_right:
- aItem->m_Hjustify = GR_TEXT_HJUSTIFY_RIGHT;
+ aItem->m_Hjustify = GR_TEXT_H_ALIGN_RIGHT;
break;
case T_top:
- aItem->m_Vjustify = GR_TEXT_VJUSTIFY_TOP;
+ aItem->m_Vjustify = GR_TEXT_V_ALIGN_TOP;
break;
case T_bottom:
- aItem->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
+ aItem->m_Vjustify = GR_TEXT_V_ALIGN_BOTTOM;
break;
default:
diff --git a/common/drawing_sheet/ds_data_item.cpp b/common/drawing_sheet/ds_data_item.cpp
index 226508bfb5..ca356a4c02 100644
--- a/common/drawing_sheet/ds_data_item.cpp
+++ b/common/drawing_sheet/ds_data_item.cpp
@@ -523,8 +523,8 @@ DS_DATA_ITEM_TEXT::DS_DATA_ITEM_TEXT( const wxString& aTextBase ) :
{
m_TextBase = aTextBase;
m_IncrementLabel = 1;
- m_Hjustify = GR_TEXT_HJUSTIFY_LEFT;
- m_Vjustify = GR_TEXT_VJUSTIFY_CENTER;
+ m_Hjustify = GR_TEXT_H_ALIGN_LEFT;
+ m_Vjustify = GR_TEXT_V_ALIGN_CENTER;
m_Italic = false;
m_Bold = false;
m_Orient = 0.0;
diff --git a/common/drawing_sheet/ds_data_model_io.cpp b/common/drawing_sheet/ds_data_model_io.cpp
index 6879176abc..3532741674 100644
--- a/common/drawing_sheet/ds_data_model_io.cpp
+++ b/common/drawing_sheet/ds_data_model_io.cpp
@@ -272,20 +272,20 @@ void DS_DATA_MODEL_IO::format( DS_DATA_ITEM_TEXT* aItem, int aNestLevel ) const
}
// Write text justification
- if( aItem->m_Hjustify != GR_TEXT_HJUSTIFY_LEFT || aItem->m_Vjustify != GR_TEXT_VJUSTIFY_CENTER )
+ if( aItem->m_Hjustify != GR_TEXT_H_ALIGN_LEFT || aItem->m_Vjustify != GR_TEXT_V_ALIGN_CENTER )
{
m_out->Print( 0, " (justify" );
// Write T_center opt first, because it is
// also a center for both m_Hjustify and m_Vjustify
- if( aItem->m_Hjustify == GR_TEXT_HJUSTIFY_CENTER )
+ if( aItem->m_Hjustify == GR_TEXT_H_ALIGN_CENTER )
m_out->Print( 0, " center" );
- else if( aItem->m_Hjustify == GR_TEXT_HJUSTIFY_RIGHT )
+ else if( aItem->m_Hjustify == GR_TEXT_H_ALIGN_RIGHT )
m_out->Print( 0, " right" );
- if( aItem->m_Vjustify == GR_TEXT_VJUSTIFY_TOP )
+ if( aItem->m_Vjustify == GR_TEXT_V_ALIGN_TOP )
m_out->Print( 0, " top" );
- else if( aItem->m_Vjustify == GR_TEXT_VJUSTIFY_BOTTOM )
+ else if( aItem->m_Vjustify == GR_TEXT_V_ALIGN_BOTTOM )
m_out->Print( 0, " bottom" );
m_out->Print( 0, ")" );
diff --git a/common/drawing_sheet/ds_painter.cpp b/common/drawing_sheet/ds_painter.cpp
index ad4ad58f4d..b15c471e77 100644
--- a/common/drawing_sheet/ds_painter.cpp
+++ b/common/drawing_sheet/ds_painter.cpp
@@ -236,7 +236,7 @@ void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
m_gal->Save();
m_gal->Translate( position );
- m_gal->Rotate( -aItem->GetTextAngle() * M_PI / 1800.0 );
+ m_gal->Rotate( -aItem->GetTextAngle().AsRadians() );
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
m_gal->SetLineWidth( penWidth );
m_gal->SetTextAttributes( aItem );
diff --git a/common/eda_angle.cpp b/common/eda_angle.cpp
new file mode 100644
index 0000000000..44c8b4df58
--- /dev/null
+++ b/common/eda_angle.cpp
@@ -0,0 +1,114 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2021 Ola Rinta-Koski
+ * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#include
+
+EDA_ANGLE EDA_ANGLE::m_angle0 = EDA_ANGLE( 0, EDA_ANGLE::DEGREES );
+EDA_ANGLE EDA_ANGLE::m_angle90 = EDA_ANGLE( 90, EDA_ANGLE::DEGREES );
+EDA_ANGLE EDA_ANGLE::m_angle180 = EDA_ANGLE( 180, EDA_ANGLE::DEGREES );
+EDA_ANGLE EDA_ANGLE::m_angle270 = EDA_ANGLE( 270, EDA_ANGLE::DEGREES );
+EDA_ANGLE EDA_ANGLE::m_angle360 = EDA_ANGLE( 360, EDA_ANGLE::DEGREES );
+
+EDA_ANGLE EDA_ANGLE::KeepUpright() const
+{
+ EDA_ANGLE inAngle( *this );
+ inAngle.Normalize();
+
+ int inDegrees = inAngle.AsDegrees();
+ int outDegrees;
+
+ if( inDegrees <= 45 || inDegrees >= 315 || ( inDegrees > 135 && inDegrees <= 225 ) )
+ outDegrees = 0;
+ else
+ outDegrees = 90;
+
+ return EDA_ANGLE( outDegrees, EDA_ANGLE::DEGREES );
+}
+
+
+void EDA_ANGLE::normalize( bool n720 )
+{
+ if( GetInitialAngleType() == EDA_ANGLE::RADIANS )
+ {
+ m_radians = normalize( m_radians, EDA_ANGLE::RADIANS, n720 );
+ m_value = int( m_radians / TENTHS_OF_A_DEGREE_TO_RADIANS );
+ }
+ else
+ {
+ m_value = normalize( m_value, EDA_ANGLE::TENTHS_OF_A_DEGREE, n720 );
+ }
+}
+
+
+int EDA_ANGLE::normalize( int aValue, ANGLE_TYPE aAngleType, bool n720 ) const
+{
+ int full_circle_upper;
+
+ switch( aAngleType )
+ {
+ case DEGREES:
+ full_circle_upper = DEGREES_FULL_CIRCLE;
+ break;
+
+ case TENTHS_OF_A_DEGREE:
+ full_circle_upper = TENTHS_OF_A_DEGREE_FULL_CIRCLE;
+ break;
+
+ case RADIANS:
+ /* ?? should not get here */
+ assert( 1 == 0 );
+ }
+
+ /* if n720 == false, clamp between 0..full_circle_upper
+ * if n720 == true, clamp between +/- full_circle_upper
+ */
+ int full_circle_lower = n720 ? 0 : -full_circle_upper;
+
+ while( aValue < full_circle_lower )
+ aValue += full_circle_upper;
+
+ while( aValue > full_circle_upper )
+ aValue -= full_circle_upper;
+
+ return aValue;
+}
+
+
+double EDA_ANGLE::normalize( double aValue, ANGLE_TYPE aAngleType, bool n720 ) const
+{
+ double full_circle_upper;
+
+ switch( aAngleType )
+ {
+ case DEGREES: full_circle_upper = DEGREES_FULL_CIRCLE; break;
+ case TENTHS_OF_A_DEGREE: full_circle_upper = TENTHS_OF_A_DEGREE_FULL_CIRCLE; break;
+ case RADIANS: full_circle_upper = RADIANS_FULL_CIRCLE; break;
+ }
+
+ double full_circle_lower = n720 ? 0 : -full_circle_upper;
+
+ while( aValue < full_circle_lower )
+ aValue += full_circle_upper;
+
+ while( aValue > full_circle_upper )
+ aValue -= full_circle_upper;
+
+ return aValue;
+}
diff --git a/common/eda_text.cpp b/common/eda_text.cpp
index 51aa0dbbd0..3544d5a44b 100644
--- a/common/eda_text.cpp
+++ b/common/eda_text.cpp
@@ -70,37 +70,36 @@ void addTextSegmToPoly( int x0, int y0, int xf, int yf, void* aData )
}
-EDA_TEXT_HJUSTIFY_T EDA_TEXT::MapHorizJustify( int aHorizJustify )
+GR_TEXT_H_ALIGN_T EDA_TEXT::MapHorizJustify( int aHorizJustify )
{
- wxASSERT( aHorizJustify >= GR_TEXT_HJUSTIFY_LEFT && aHorizJustify <= GR_TEXT_HJUSTIFY_RIGHT );
+ wxASSERT( aHorizJustify >= GR_TEXT_H_ALIGN_LEFT && aHorizJustify <= GR_TEXT_H_ALIGN_RIGHT );
- if( aHorizJustify > GR_TEXT_HJUSTIFY_RIGHT )
- return GR_TEXT_HJUSTIFY_RIGHT;
+ if( aHorizJustify > GR_TEXT_H_ALIGN_RIGHT )
+ return GR_TEXT_H_ALIGN_RIGHT;
- if( aHorizJustify < GR_TEXT_HJUSTIFY_LEFT )
- return GR_TEXT_HJUSTIFY_LEFT;
+ if( aHorizJustify < GR_TEXT_H_ALIGN_LEFT )
+ return GR_TEXT_H_ALIGN_LEFT;
- return static_cast( aHorizJustify );
+ return static_cast( aHorizJustify );
}
-EDA_TEXT_VJUSTIFY_T EDA_TEXT::MapVertJustify( int aVertJustify )
+GR_TEXT_V_ALIGN_T EDA_TEXT::MapVertJustify( int aVertJustify )
{
- wxASSERT( aVertJustify >= GR_TEXT_VJUSTIFY_TOP && aVertJustify <= GR_TEXT_VJUSTIFY_BOTTOM );
+ wxASSERT( aVertJustify >= GR_TEXT_V_ALIGN_TOP && aVertJustify <= GR_TEXT_V_ALIGN_BOTTOM );
- if( aVertJustify > GR_TEXT_VJUSTIFY_BOTTOM )
- return GR_TEXT_VJUSTIFY_BOTTOM;
+ if( aVertJustify > GR_TEXT_V_ALIGN_BOTTOM )
+ return GR_TEXT_V_ALIGN_BOTTOM;
- if( aVertJustify < GR_TEXT_VJUSTIFY_TOP )
- return GR_TEXT_VJUSTIFY_TOP;
+ if( aVertJustify < GR_TEXT_V_ALIGN_TOP )
+ return GR_TEXT_V_ALIGN_TOP;
- return static_cast( aVertJustify );
+ return static_cast( aVertJustify );
}
EDA_TEXT::EDA_TEXT( const wxString& text ) :
- m_text( text ),
- m_e( 1 << TE_VISIBLE )
+ m_text( text )
{
int sz = Mils2iu( DEFAULT_SIZE_TEXT );
SetTextSize( wxSize( sz, sz ) );
@@ -110,7 +109,7 @@ EDA_TEXT::EDA_TEXT( const wxString& text ) :
EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) :
m_text( aText.m_text ),
- m_e( aText.m_e )
+ m_attributes( aText.m_attributes )
{
cacheShownText();
}
@@ -136,9 +135,10 @@ void EDA_TEXT::CopyText( const EDA_TEXT& aSrc )
}
-void EDA_TEXT::SetEffects( const EDA_TEXT& aSrc )
+void EDA_TEXT::SetAttributes( const EDA_TEXT& aSrc )
{
- m_e = aSrc.m_e;
+ m_attributes = aSrc.m_attributes;
+ m_pos = aSrc.m_pos;
}
@@ -150,9 +150,10 @@ void EDA_TEXT::SwapText( EDA_TEXT& aTradingPartner )
}
-void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner )
+void EDA_TEXT::SwapAttributes( EDA_TEXT& aTradingPartner )
{
- std::swap( m_e, aTradingPartner.m_e );
+ std::swap( m_attributes, aTradingPartner.m_attributes );
+ std::swap( m_pos, aTradingPartner.m_pos );
}
@@ -328,16 +329,16 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
*/
switch( GetHorizJustify() )
{
- case GR_TEXT_HJUSTIFY_LEFT:
+ case GR_TEXT_H_ALIGN_LEFT:
if( IsMirrored() )
rect.SetX( rect.GetX() - rect.GetWidth() );
break;
- case GR_TEXT_HJUSTIFY_CENTER:
+ case GR_TEXT_H_ALIGN_CENTER:
rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
break;
- case GR_TEXT_HJUSTIFY_RIGHT:
+ case GR_TEXT_H_ALIGN_RIGHT:
if( !IsMirrored() )
rect.SetX( rect.GetX() - rect.GetWidth() );
break;
@@ -345,14 +346,14 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
switch( GetVertJustify() )
{
- case GR_TEXT_VJUSTIFY_TOP:
+ case GR_TEXT_V_ALIGN_TOP:
break;
- case GR_TEXT_VJUSTIFY_CENTER:
+ case GR_TEXT_V_ALIGN_CENTER:
rect.SetY( rect.GetY() - ( dy / 2) );
break;
- case GR_TEXT_VJUSTIFY_BOTTOM:
+ case GR_TEXT_V_ALIGN_BOTTOM:
rect.SetY( rect.GetY() - dy );
break;
}
@@ -364,15 +365,15 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
switch( GetVertJustify() )
{
- case GR_TEXT_VJUSTIFY_TOP:
+ case GR_TEXT_V_ALIGN_TOP:
break;
- case GR_TEXT_VJUSTIFY_CENTER:
+ case GR_TEXT_V_ALIGN_CENTER:
yoffset = linecount * GetInterline() / 2;
rect.SetY( rect.GetY() - yoffset );
break;
- case GR_TEXT_VJUSTIFY_BOTTOM:
+ case GR_TEXT_V_ALIGN_BOTTOM:
yoffset = linecount * GetInterline();
rect.SetY( rect.GetY() - yoffset );
break;
@@ -395,7 +396,7 @@ bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
wxPoint location = aPoint;
rect.Inflate( aAccuracy );
- RotatePoint( &location, GetTextPos(), -GetTextAngle() );
+ RotatePoint( &location, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
return rect.Contains( location );
}
@@ -410,7 +411,7 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
if( aContains )
return rect.Contains( GetTextBox() );
- return rect.Intersects( GetTextBox(), GetTextAngle() );
+ return rect.Intersects( GetTextBox(), GetTextAngle().AsTenthsOfADegree() );
}
@@ -451,14 +452,14 @@ void EDA_TEXT::GetLinePositions( std::vector& aPositions, int aLineCoun
{
switch( GetVertJustify() )
{
- case GR_TEXT_VJUSTIFY_TOP:
+ case GR_TEXT_V_ALIGN_TOP:
break;
- case GR_TEXT_VJUSTIFY_CENTER:
+ case GR_TEXT_V_ALIGN_CENTER:
pos.y -= ( aLineCount - 1 ) * offset.y / 2;
break;
- case GR_TEXT_VJUSTIFY_BOTTOM:
+ case GR_TEXT_V_ALIGN_BOTTOM:
pos.y -= ( aLineCount - 1 ) * offset.y;
break;
}
@@ -466,10 +467,10 @@ void EDA_TEXT::GetLinePositions( std::vector& aPositions, int aLineCoun
// Rotate the position of the first line
// around the center of the multiline text block
- RotatePoint( &pos, GetTextPos(), GetTextAngle() );
+ RotatePoint( &pos, GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
// Rotate the offset lines to increase happened in the right direction
- RotatePoint( &offset, GetTextAngle() );
+ RotatePoint( &offset, GetTextAngle().AsTenthsOfADegree() );
for( int ii = 0; ii < aLineCount; ii++ )
{
@@ -523,8 +524,8 @@ bool EDA_TEXT::IsDefaultFormatting() const
{
return ( IsVisible()
&& !IsMirrored()
- && GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER
- && GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER
+ && GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER
+ && GetVertJustify() == GR_TEXT_V_ALIGN_CENTER
&& GetTextThickness() == 0
&& !IsItalic()
&& !IsBold()
@@ -541,9 +542,9 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
aFormatter->Print( aNestLevel + 1, "(effects" );
- // Text size
aFormatter->Print( 0, " (font" );
+ // Text size
aFormatter->Print( 0, " (size %s %s)",
FormatInternalUnits( GetTextHeight() ).c_str(),
FormatInternalUnits( GetTextWidth() ).c_str() );
@@ -562,16 +563,16 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
aFormatter->Print( 0, ")"); // (font
- if( IsMirrored() || GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER
- || GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
+ if( IsMirrored() || GetHorizJustify() != GR_TEXT_H_ALIGN_CENTER
+ || GetVertJustify() != GR_TEXT_V_ALIGN_CENTER )
{
aFormatter->Print( 0, " (justify");
- if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER )
- aFormatter->Print( 0, GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ? " left" : " right" );
+ if( GetHorizJustify() != GR_TEXT_H_ALIGN_CENTER )
+ aFormatter->Print( 0, GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ? " left" : " right" );
- if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
- aFormatter->Print( 0, GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ? " top" : " bottom" );
+ if( GetVertJustify() != GR_TEXT_V_ALIGN_CENTER )
+ aFormatter->Print( 0, GetVertJustify() == GR_TEXT_V_ALIGN_TOP ? " top" : " bottom" );
if( IsMirrored() )
aFormatter->Print( 0, " mirror" );
@@ -661,15 +662,22 @@ int EDA_TEXT::Compare( const EDA_TEXT* aOther ) const
#define TEST_E( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; }
#define TEST_PT( a, b ) { TEST_E( a.x, b.x ); TEST_E( a.y, b.y ); }
- TEST_PT( m_e.pos, aOther->m_e.pos );
+ TEST_PT( m_pos, aOther->m_pos );
- TEST_PT( m_e.size, aOther->m_e.size );
- TEST_E( m_e.penwidth, aOther->m_e.penwidth );
- TEST( m_e.angle, aOther->m_e.angle );
+ TEST_PT( m_attributes.m_Size, aOther->m_attributes.m_Size );
+ TEST_E( m_attributes.m_StrokeWidth, aOther->m_attributes.m_StrokeWidth );
+ TEST( m_attributes.m_Angle.AsTenthsOfADegree(), aOther->m_attributes.m_Angle.AsTenthsOfADegree() );
+ TEST( m_attributes.m_LineSpacing, aOther->m_attributes.m_LineSpacing );
- TEST( m_e.hjustify, aOther->m_e.hjustify );
- TEST( m_e.vjustify, aOther->m_e.vjustify );
- TEST( m_e.bits, aOther->m_e.bits );
+ TEST( m_attributes.m_Halign, aOther->m_attributes.m_Halign );
+ TEST( m_attributes.m_Valign, aOther->m_attributes.m_Valign );
+ TEST( m_attributes.m_Italic, aOther->m_attributes.m_Italic );
+ TEST( m_attributes.m_Bold, aOther->m_attributes.m_Bold );
+ TEST( m_attributes.m_Underlined, aOther->m_attributes.m_Underlined );
+ TEST( m_attributes.m_Visible, aOther->m_attributes.m_Visible );
+ TEST( m_attributes.m_Mirrored, aOther->m_attributes.m_Mirrored );
+ TEST( m_attributes.m_Multiline, aOther->m_attributes.m_Multiline );
+ TEST( m_attributes.m_KeepUpright, aOther->m_attributes.m_KeepUpright );
return m_text.Cmp( aOther->m_text );
}
@@ -715,7 +723,7 @@ void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCorn
for( wxPoint& corner : corners )
{
// Rotate polygon
- RotatePoint( &corner.x, &corner.y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
+ RotatePoint( &corner, GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
aCornerBuffer->Append( corner.x, corner.y );
}
}
@@ -725,14 +733,14 @@ static struct EDA_TEXT_DESC
{
EDA_TEXT_DESC()
{
- ENUM_MAP::Instance()
- .Map( GR_TEXT_HJUSTIFY_LEFT, _HKI( "Left" ) )
- .Map( GR_TEXT_HJUSTIFY_CENTER, _HKI( "Center" ) )
- .Map( GR_TEXT_HJUSTIFY_RIGHT, _HKI( "Right" ) );
- ENUM_MAP::Instance()
- .Map( GR_TEXT_VJUSTIFY_TOP, _HKI( "Top" ) )
- .Map( GR_TEXT_VJUSTIFY_CENTER, _HKI( "Center" ) )
- .Map( GR_TEXT_VJUSTIFY_BOTTOM, _HKI( "Bottom" ) );
+ ENUM_MAP::Instance()
+ .Map( GR_TEXT_H_ALIGN_LEFT, _HKI( "Left" ) )
+ .Map( GR_TEXT_H_ALIGN_CENTER, _HKI( "Center" ) )
+ .Map( GR_TEXT_H_ALIGN_RIGHT, _HKI( "Right" ) );
+ ENUM_MAP::Instance()
+ .Map( GR_TEXT_V_ALIGN_TOP, _HKI( "Top" ) )
+ .Map( GR_TEXT_V_ALIGN_CENTER, _HKI( "Center" ) )
+ .Map( GR_TEXT_V_ALIGN_BOTTOM, _HKI( "Bottom" ) );
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( EDA_TEXT );
@@ -762,15 +770,15 @@ static struct EDA_TEXT_DESC
&EDA_TEXT::GetTextHeight,
PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Horizontal Justification" ),
- &EDA_TEXT::SetHorizJustify,
- &EDA_TEXT::GetHorizJustify ) );
+ GR_TEXT_H_ALIGN_T>( _HKI( "Horizontal Justification" ),
+ &EDA_TEXT::SetHorizJustify,
+ &EDA_TEXT::GetHorizJustify ) );
propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Vertical Justification" ),
- &EDA_TEXT::SetVertJustify,
- &EDA_TEXT::GetVertJustify ) );
+ GR_TEXT_V_ALIGN_T>( _HKI( "Vertical Justification" ),
+ &EDA_TEXT::SetVertJustify,
+ &EDA_TEXT::GetVertJustify ) );
}
} _EDA_TEXT_DESC;
-ENUM_TO_WXANY( EDA_TEXT_HJUSTIFY_T )
-ENUM_TO_WXANY( EDA_TEXT_VJUSTIFY_T )
+ENUM_TO_WXANY( GR_TEXT_H_ALIGN_T )
+ENUM_TO_WXANY( GR_TEXT_V_ALIGN_T )
diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp
index 38497bb1a7..18a6b457fd 100644
--- a/common/gal/graphics_abstraction_layer.cpp
+++ b/common/gal/graphics_abstraction_layer.cpp
@@ -170,8 +170,8 @@ void GAL::ResetTextAttributes()
// there is no built-in default
SetGlyphSize( { 1.0, 1.0 } );
- SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
- SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
+ SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
+ SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
SetFontBold( false );
SetFontItalic( false );
diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp
index 55208d6bab..44c0c8e280 100644
--- a/common/gal/opengl/opengl_gal.cpp
+++ b/common/gal/opengl/opengl_gal.cpp
@@ -1299,16 +1299,16 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
switch( GetHorizontalJustify() )
{
- case GR_TEXT_HJUSTIFY_CENTER:
+ case GR_TEXT_H_ALIGN_CENTER:
Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
break;
- case GR_TEXT_HJUSTIFY_RIGHT:
+ case GR_TEXT_H_ALIGN_RIGHT:
//if( !IsTextMirrored() )
Translate( VECTOR2D( -textSize.x, 0 ) );
break;
- case GR_TEXT_HJUSTIFY_LEFT:
+ case GR_TEXT_H_ALIGN_LEFT:
//if( IsTextMirrored() )
//Translate( VECTOR2D( -textSize.x, 0 ) );
break;
@@ -1316,17 +1316,17 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
switch( GetVerticalJustify() )
{
- case GR_TEXT_VJUSTIFY_TOP:
+ case GR_TEXT_V_ALIGN_TOP:
Translate( VECTOR2D( 0, -textSize.y ) );
overbarHeight = -textSize.y / 2.0;
break;
- case GR_TEXT_VJUSTIFY_CENTER:
+ case GR_TEXT_V_ALIGN_CENTER:
Translate( VECTOR2D( 0, -textSize.y / 2.0 ) );
overbarHeight = 0;
break;
- case GR_TEXT_VJUSTIFY_BOTTOM:
+ case GR_TEXT_V_ALIGN_BOTTOM:
break;
}
diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp
index d268b15742..1ae7e66810 100644
--- a/common/gal/stroke_font.cpp
+++ b/common/gal/stroke_font.cpp
@@ -207,15 +207,15 @@ void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRo
// align the 1st line of text
switch( m_gal->GetVerticalJustify() )
{
- case GR_TEXT_VJUSTIFY_TOP:
+ case GR_TEXT_V_ALIGN_TOP:
m_gal->Translate( VECTOR2D( 0, glyphSize.y ) );
break;
- case GR_TEXT_VJUSTIFY_CENTER:
+ case GR_TEXT_V_ALIGN_CENTER:
m_gal->Translate( VECTOR2D( 0, glyphSize.y / 2.0 ) );
break;
- case GR_TEXT_VJUSTIFY_BOTTOM:
+ case GR_TEXT_V_ALIGN_BOTTOM:
break;
default:
@@ -226,14 +226,14 @@ void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRo
{
switch( m_gal->GetVerticalJustify() )
{
- case GR_TEXT_VJUSTIFY_TOP:
+ case GR_TEXT_V_ALIGN_TOP:
break;
- case GR_TEXT_VJUSTIFY_CENTER:
+ case GR_TEXT_V_ALIGN_CENTER:
m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight / 2) );
break;
- case GR_TEXT_VJUSTIFY_BOTTOM:
+ case GR_TEXT_V_ALIGN_BOTTOM:
m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight ) );
break;
}
@@ -295,16 +295,16 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText )
// Adjust the text position to the given horizontal justification
switch( m_gal->GetHorizontalJustify() )
{
- case GR_TEXT_HJUSTIFY_CENTER:
+ case GR_TEXT_H_ALIGN_CENTER:
m_gal->Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
break;
- case GR_TEXT_HJUSTIFY_RIGHT:
+ case GR_TEXT_H_ALIGN_RIGHT:
if( !m_gal->IsTextMirrored() )
m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
break;
- case GR_TEXT_HJUSTIFY_LEFT:
+ case GR_TEXT_H_ALIGN_LEFT:
if( m_gal->IsTextMirrored() )
m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
break;
diff --git a/common/gr_text.cpp b/common/gr_text.cpp
index 0f36751423..c5ec292693 100644
--- a/common/gr_text.cpp
+++ b/common/gr_text.cpp
@@ -31,7 +31,6 @@
#include
#include
-#include // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T
#include
#include
#include