Cherry-pick TEXT_ATTRIBUTES and EDA_ANGLE from rockola/kicad-strokefont

This commit is contained in:
Jeff Young 2021-12-28 22:13:54 +00:00
parent a0c4f05c17
commit 86cb57f4a7
91 changed files with 1896 additions and 1576 deletions

View File

@ -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

View File

@ -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:

View File

@ -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;

View File

@ -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, ")" );

View File

@ -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 );

114
common/eda_angle.cpp Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <eda_angle.h>
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;
}

View File

@ -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<EDA_TEXT_HJUSTIFY_T>( aHorizJustify );
return static_cast<GR_TEXT_H_ALIGN_T>( 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<EDA_TEXT_VJUSTIFY_T>( aVertJustify );
return static_cast<GR_TEXT_V_ALIGN_T>( 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<wxPoint>& 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<wxPoint>& 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<EDA_TEXT_HJUSTIFY_T>::Instance()
.Map( GR_TEXT_HJUSTIFY_LEFT, _HKI( "Left" ) )
.Map( GR_TEXT_HJUSTIFY_CENTER, _HKI( "Center" ) )
.Map( GR_TEXT_HJUSTIFY_RIGHT, _HKI( "Right" ) );
ENUM_MAP<EDA_TEXT_VJUSTIFY_T>::Instance()
.Map( GR_TEXT_VJUSTIFY_TOP, _HKI( "Top" ) )
.Map( GR_TEXT_VJUSTIFY_CENTER, _HKI( "Center" ) )
.Map( GR_TEXT_VJUSTIFY_BOTTOM, _HKI( "Bottom" ) );
ENUM_MAP<GR_TEXT_H_ALIGN_T>::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<GR_TEXT_V_ALIGN_T>::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<EDA_TEXT,
EDA_TEXT_HJUSTIFY_T>( _HKI( "Horizontal Justification" ),
GR_TEXT_H_ALIGN_T>( _HKI( "Horizontal Justification" ),
&EDA_TEXT::SetHorizJustify,
&EDA_TEXT::GetHorizJustify ) );
propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT,
EDA_TEXT_VJUSTIFY_T>( _HKI( "Vertical Justification" ),
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 )

View File

@ -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 );

View File

@ -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;
}

View File

@ -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;

View File

@ -31,7 +31,6 @@
#include <gr_basic.h>
#include <plotters/plotter.h>
#include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T
#include <trigo.h>
#include <base_screen.h>
#include <math/util.h> // for KiROUND
@ -109,7 +108,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
* @param aPos is the text position (according to h_justify, v_justify).
* @param aColor is the text color.
* @param aText is the text to draw.
* @param aOrient is the angle in 0.1 degree.
* @param aOrient is the angle.
* @param aSize is the text size (size.x or size.y can be < 0 for mirrored texts).
* @param aH_justify is the horizontal justification (Left, center, right).
* @param aV_justify is the vertical justification (bottom, center, top).
@ -127,8 +126,8 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
* the text. NULL to draw this text.
*/
void GRText( wxDC* aDC, const wxPoint& aPos, const COLOR4D& aColor, const wxString& aText,
double aOrient, const wxSize& aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold,
const EDA_ANGLE& aOrient, const wxSize& aSize, enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold,
void (* aCallback)( int x0, int y0, int xf, int yf, void* aData ),
void* aCallbackData, PLOTTER* aPlotter )
{
@ -166,72 +165,7 @@ void GRText( wxDC* aDC, const wxPoint& aPos, const COLOR4D& aColor, const wxStri
basic_gal.m_DC = aDC;
basic_gal.m_Color = aColor;
basic_gal.SetClipBox( nullptr );
basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800 );
basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient.AsRadians() );
}
void GRHaloText( wxDC* aDC, const wxPoint &aPos, const COLOR4D& aBgColor, const COLOR4D& aColor1,
const COLOR4D& aColor2, const wxString &aText, double aOrient, const wxSize &aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify,
int aWidth, bool aItalic, bool aBold,
void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ),
void* aCallbackData, PLOTTER * aPlotter )
{
COLOR4D color1 = aColor1;
COLOR4D color2 = aColor2;
// Swap color if contrast would be better
// TODO: Maybe calculate contrast some way other than brightness
if( aBgColor.GetBrightness() > 0.5 )
{
COLOR4D c = color1;
color1 = color2;
color2 = c;
}
// Draw the background
GRText( aDC, aPos, color1, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
aBold, aCallback, aCallbackData, aPlotter );
// Draw the text
GRText( aDC, aPos, color2, aText, aOrient, aSize, aH_justify, aV_justify, aWidth / 4, aItalic,
aBold, aCallback, aCallbackData, aPlotter );
}
/**
* Same as GRText, but plot graphic text instead of draw it.
*
* @param aPos is the text position (according to aH_justify, aV_justify).
* @param aColor is the text color.
* @param aText is the text to draw.
* @param aOrient is the angle in 0.1 degree.
* @param aSize is the text size (size.x or size.y can be < 0 for mirrored texts).
* @param aH_justify is the horizontal justification (Left, center, right).
* @param aV_justify is the vertical justification (bottom, center, top).
* @param aPenWidth is the line width (if = 0, use plot default line width).
* @param aItalic is the true to simulate an italic font.
* @param aBold use true to use a bold font Useful only with default width value (aWidth = 0).
* @param aMultilineAllowed use true to plot text as multiline, otherwise single line.
* @param aData is a parameter used by some plotters in SetCurrentLineWidth(),
* not directly used here.
*/
void PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
int aPenWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
void* aData )
{
SetColor( aColor );
SetCurrentLineWidth( aPenWidth, aData );
GRText( nullptr, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aPenWidth,
aItalic, aBold, nullptr, nullptr, this );
}

View File

@ -132,7 +132,7 @@ size_t hash_fp_item( const EDA_ITEM* aItem, int aFlags )
}
if( aFlags & HASH_ROT )
hash_combine( ret, text->GetTextAngle() );
hash_combine( ret, text->GetTextAngle().AsTenthsOfADegree() );
}
break;

View File

@ -831,10 +831,10 @@ bool containsNonAsciiChars( const wxString& string )
void DXF_PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
@ -852,8 +852,8 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
// output text as graphics.
// Perhaps multiline texts could be handled as DXF text entity
// but I do not want spend time about this (JPC)
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
aWidth, aItalic, aBold, aMultilineAllowed );
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth,
aItalic, aBold, aMultilineAllowed, aData );
}
else
{
@ -867,28 +867,16 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
switch( aH_justify )
{
case GR_TEXT_HJUSTIFY_LEFT:
h_code = 0;
break;
case GR_TEXT_HJUSTIFY_CENTER:
h_code = 1;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
h_code = 2;
break;
case GR_TEXT_H_ALIGN_LEFT: h_code = 0; break;
case GR_TEXT_H_ALIGN_CENTER: h_code = 1; break;
case GR_TEXT_H_ALIGN_RIGHT: h_code = 2; break;
}
switch( aV_justify )
{
case GR_TEXT_VJUSTIFY_TOP:
v_code = 3;
break;
case GR_TEXT_VJUSTIFY_CENTER:
v_code = 2;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
v_code = 1;
break;
case GR_TEXT_V_ALIGN_TOP: v_code = 3; break;
case GR_TEXT_V_ALIGN_CENTER: v_code = 2; break;
case GR_TEXT_V_ALIGN_BOTTOM: v_code = 1; break;
}
// Position, size, rotation and alignment
@ -923,13 +911,12 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
"%d\n" // H alignment
" 73\n"
"%d\n", // V alignment
aBold ? (aItalic ? "KICADBI" : "KICADB")
: (aItalic ? "KICADI" : "KICAD"),
aBold ? (aItalic ? "KICADBI" : "KICADB") : (aItalic ? "KICADI" : "KICAD"),
TO_UTF8( cname ),
origin_dev.x, origin_dev.x,
origin_dev.y, origin_dev.y,
size_dev.y, fabs( size_dev.x / size_dev.y ),
aOrient / 10.0,
aOrient.AsDegrees(),
aItalic ? DXF_OBLIQUE_ANGLE : 0,
size_dev.x < 0 ? 2 : 0, // X mirror flag
h_code, v_code );

View File

@ -1923,11 +1923,18 @@ void GERBER_PLOTTER::FlashRegularPolygon( const wxPoint& aShapePos, int aDiamete
}
void GERBER_PLOTTER::Text( const wxPoint& aPos, const COLOR4D& aColor,
const wxString& aText, double aOrient, const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic,
bool aBold, bool aMultilineAllowed, void* aData )
void GERBER_PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
void* aData )
{
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );

View File

@ -825,10 +825,10 @@ bool PDF_PLOTTER::EndPlot()
void PDF_PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
@ -851,9 +851,8 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
double wideningFactor, heightFactor;
computeTextParameters( aPos, aText, aOrient, aSize, m_plotMirror, aH_justify,
aV_justify, aWidth, aItalic, aBold,
&wideningFactor, &ctm_a, &ctm_b, &ctm_c,
&ctm_d, &ctm_e, &ctm_f, &heightFactor );
aV_justify, aWidth, aItalic, aBold, &wideningFactor, &ctm_a,
&ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor );
SetColor( aColor );
SetCurrentLineWidth( aWidth, aData );

View File

@ -436,11 +436,11 @@ void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
const wxString& aText,
int aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
bool aMirror,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
@ -463,36 +463,20 @@ void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
switch( aH_justify )
{
case GR_TEXT_HJUSTIFY_CENTER:
dx = -tw / 2;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
dx = -tw;
break;
case GR_TEXT_HJUSTIFY_LEFT:
dx = 0;
break;
case GR_TEXT_H_ALIGN_CENTER: dx = -tw / 2; break;
case GR_TEXT_H_ALIGN_RIGHT: dx = -tw; break;
case GR_TEXT_H_ALIGN_LEFT: dx = 0; break;
}
switch( aV_justify )
{
case GR_TEXT_VJUSTIFY_CENTER:
dy = th / 2;
break;
case GR_TEXT_VJUSTIFY_TOP:
dy = th;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
dy = 0;
break;
case GR_TEXT_V_ALIGN_CENTER: dy = th / 2; break;
case GR_TEXT_V_ALIGN_TOP: dy = th; break;
case GR_TEXT_V_ALIGN_BOTTOM: dy = 0; break;
}
RotatePoint( &dx, &dy, aOrient );
RotatePoint( &tw, &th, aOrient );
RotatePoint( &dx, &dy, aOrient.AsTenthsOfADegree() );
RotatePoint( &tw, &th, aOrient.AsTenthsOfADegree() );
start_pos.x += dx;
start_pos.y += dy;
DPOINT pos_dev = userToDeviceCoordinates( start_pos );
@ -503,13 +487,10 @@ void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
// Mirrored texts must be plotted as mirrored!
if( m_plotMirror )
{
*wideningFactor = -*wideningFactor;
aOrient = -aOrient;
}
// The CTM transformation matrix
double alpha = DECIDEG2RAD( aOrient );
double alpha = m_plotMirror ? aOrient.Invert().AsRadians() : aOrient.AsRadians();
double sinalpha = sin( alpha );
double cosalpha = cos( alpha );
@ -980,10 +961,10 @@ bool PS_PLOTTER::EndPlot()
void PS_PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,

View File

@ -758,10 +758,10 @@ bool SVG_PLOTTER::EndPlot()
void SVG_PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
@ -777,31 +777,16 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
switch( aH_justify )
{
case GR_TEXT_HJUSTIFY_CENTER:
hjust = "middle";
break;
case GR_TEXT_HJUSTIFY_RIGHT:
hjust = "end";
break;
case GR_TEXT_HJUSTIFY_LEFT:
hjust = "start";
break;
case GR_TEXT_H_ALIGN_CENTER: hjust = "middle"; break;
case GR_TEXT_H_ALIGN_RIGHT: hjust = "end"; break;
case GR_TEXT_H_ALIGN_LEFT: hjust = "start"; break;
}
switch( aV_justify )
{
case GR_TEXT_VJUSTIFY_CENTER:
text_pos.y += aSize.y / 2;
break;
case GR_TEXT_VJUSTIFY_TOP:
text_pos.y += aSize.y;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
break;
case GR_TEXT_V_ALIGN_CENTER: text_pos.y += aSize.y / 2; break;
case GR_TEXT_V_ALIGN_TOP: text_pos.y += aSize.y; break;
case GR_TEXT_V_ALIGN_BOTTOM: break;
}
wxSize text_size;
@ -814,14 +799,14 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
DPOINT text_pos_dev = userToDeviceCoordinates( text_pos );
DPOINT sz_dev = userToDeviceSize( text_size );
if( aOrient != 0 ) {
if( aOrient != EDA_ANGLE::ANGLE_0 )
{
fprintf( m_outputFile,
"<g transform=\"rotate(%f %f %f)\">\n",
- aOrient * 0.1, anchor_pos_dev.x, anchor_pos_dev.y );
- aOrient.AsDegrees(), anchor_pos_dev.x, anchor_pos_dev.y );
}
fprintf( m_outputFile,
"<text x=\"%f\" y=\"%f\"\n", text_pos_dev.x, text_pos_dev.y );
fprintf( m_outputFile, "<text x=\"%f\" y=\"%f\"\n", text_pos_dev.x, text_pos_dev.y );
/// If the text is mirrored, we should also mirror the hidden text to match
if( aSize.x < 0 )
@ -830,16 +815,16 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
fprintf( m_outputFile,
"textLength=\"%f\" font-size=\"%f\" lengthAdjust=\"spacingAndGlyphs\"\n"
"text-anchor=\"%s\" opacity=\"0\">%s</text>\n",
sz_dev.x, sz_dev.y,
hjust, TO_UTF8( XmlEsc( aText ) ) );
sz_dev.x, sz_dev.y, hjust, TO_UTF8( XmlEsc( aText ) ) );
if( aOrient != 0 )
if( aOrient != EDA_ANGLE::ANGLE_0 )
fputs( "</g>\n", m_outputFile );
fprintf( m_outputFile,
"<g class=\"stroked-text\"><desc>%s</desc>\n",
fprintf( m_outputFile, "<g class=\"stroked-text\"><desc>%s</desc>\n",
TO_UTF8( XmlEsc( aText ) ) );
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
aWidth, aItalic, aBold, aMultilineAllowed );
fputs( "</g>", m_outputFile );
}

View File

@ -630,3 +630,41 @@ void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, int a
PlotPoly( cornerList, aFill, aWidth, aData );
}
/**
* Same as GRText, but plot graphic text instead of draw it.
*
* @param aPos is the text position (according to aH_justify, aV_justify).
* @param aColor is the text color.
* @param aText is the text to draw.
* @param aOrient is the angle.
* @param aSize is the text size (size.x or size.y can be < 0 for mirrored texts).
* @param aH_justify is the horizontal justification (Left, center, right).
* @param aV_justify is the vertical justification (bottom, center, top).
* @param aPenWidth is the line width (if = 0, use plot default line width).
* @param aItalic is the true to simulate an italic font.
* @param aBold use true to use a bold font Useful only with default width value (aWidth = 0).
* @param aMultilineAllowed use true to plot text as multiline, otherwise single line.
* @param aData is a parameter used by some plotters in SetCurrentLineWidth(),
* not directly used here.
*/
void PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aPenWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
void* aData )
{
SetColor( aColor );
SetCurrentLineWidth( aPenWidth, aData );
GRText( nullptr, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aPenWidth,
aItalic, aBold, nullptr, nullptr, this );
}

View File

@ -2618,7 +2618,7 @@ void CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextIte
{
if( !aKiCadTextItem->GetText().IsEmpty() )
{
int txtAngleDecideg = aKiCadTextItem->GetTextAngleDegrees() * 10.0;
int txtAngleDecideg = aKiCadTextItem->GetTextAngle().AsTenthsOfADegree();
wxPoint positionOffset( 0, aKiCadTextItem->GetInterline() );
RotatePoint( &positionOffset, txtAngleDecideg );

View File

@ -140,9 +140,9 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
if( aTextQuadrant.x < 0 )
{
if( viewFlipped )
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
else
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
textPos.x += 15.0 / gal->GetWorldScale();
@ -152,9 +152,9 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
else
{
if( viewFlipped )
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
else
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
textPos.x -= 15.0 / gal->GetWorldScale();

View File

@ -181,11 +181,11 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT
if( aLine.Angle() > 0 )
{
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
}
else
{
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
labelAngle += M_PI;
}

View File

@ -82,15 +82,6 @@ template<typename T> T round_n( const T& value, const T& n, bool aRoundUp )
}
/**
* Convert an integer to a horizontal justification; neg=L zero=C pos=R
*/
EDA_TEXT_HJUSTIFY_T TO_HJUSTIFY( int x )
{
return static_cast<EDA_TEXT_HJUSTIFY_T>( x );
}
class AUTOPLACER
{
public:
@ -204,9 +195,9 @@ protected:
for( SCH_FIELD* field : m_fields )
{
if( m_symbol->GetTransform().y1 )
field->SetTextAngle( TEXT_ANGLE_VERT );
field->SetTextAngle( EDA_ANGLE::VERTICAL );
else
field->SetTextAngle( TEXT_ANGLE_HORIZ );
field->SetTextAngle( EDA_ANGLE::HORIZONTAL );
EDA_RECT bbox = field->GetBoundingBox();
int field_width = bbox.GetWidth();
@ -528,7 +519,7 @@ protected:
aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x
* ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) );
aField->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aField->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
}
/**
@ -654,13 +645,13 @@ protected:
switch( field_hjust )
{
case GR_TEXT_HJUSTIFY_LEFT:
case GR_TEXT_H_ALIGN_LEFT:
field_xcoord = aFieldBox.GetLeft();
break;
case GR_TEXT_HJUSTIFY_CENTER:
case GR_TEXT_H_ALIGN_CENTER:
field_xcoord = aFieldBox.Centre().x;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
case GR_TEXT_H_ALIGN_RIGHT:
field_xcoord = aFieldBox.GetRight();
break;
default:

View File

@ -636,11 +636,11 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_
if( resetEffects )
{
// Careful: the visible bit and position are also in Effects
// Careful: the visible bit and position are also set by SetAttributes()
bool visible = field.IsVisible();
wxPoint pos = field.GetPosition();
field.SetEffects( *libField );
field.SetAttributes( *libField );
field.SetVisible( visible );
field.SetPosition( pos );
@ -672,7 +672,8 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_
SCH_FIELD newField( wxPoint( 0, 0), aSymbol->GetFieldCount(), aSymbol, fieldName );
SCH_FIELD* schField = aSymbol->AddField( newField );
schField->SetEffects( libField );
// Careful: the visible bit and position are also set by SetAttributes()
schField->SetAttributes( libField );
schField->SetText( libField.GetText() );
schField->SetTextPos( aSymbol->GetPosition() + libField.GetTextPos() );
}

View File

@ -120,7 +120,7 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const
m_isBold = aTextItem->IsBold();
m_position = aTextItem->GetTextPos();
m_size = aTextItem->GetTextWidth();
m_isVertical = ( aTextItem->GetTextAngle() == TEXT_ANGLE_VERT );
m_isVertical = aTextItem->GetTextAngle().IsVertical();
m_verticalJustification = aTextItem->GetVertJustify() + 1;
m_horizontalJustification = aTextItem->GetHorizJustify() + 1;
m_isVisible = aTextItem->IsVisible();
@ -305,16 +305,16 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataToWindow()
switch ( m_horizontalJustification )
{
case GR_TEXT_HJUSTIFY_LEFT: m_hAlignLeft->Check( true ); break;
case GR_TEXT_HJUSTIFY_CENTER: m_hAlignCenter->Check( true ); break;
case GR_TEXT_HJUSTIFY_RIGHT: m_hAlignRight->Check( true ); break;
case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
}
switch ( m_verticalJustification )
{
case GR_TEXT_VJUSTIFY_TOP: m_vAlignTop->Check( true ); break;
case GR_TEXT_VJUSTIFY_CENTER: m_vAlignCenter->Check( true ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: m_vAlignBottom->Check( true ); break;
case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
}
m_visible->SetValue( m_isVisible );
@ -369,18 +369,18 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataFromWindow()
m_isItalic = m_italic->IsChecked();
if( m_hAlignLeft->IsChecked() )
m_horizontalJustification = GR_TEXT_HJUSTIFY_LEFT;
m_horizontalJustification = GR_TEXT_H_ALIGN_LEFT;
else if( m_hAlignCenter->IsChecked() )
m_horizontalJustification = GR_TEXT_HJUSTIFY_CENTER;
m_horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
else
m_horizontalJustification = GR_TEXT_HJUSTIFY_RIGHT;
m_horizontalJustification = GR_TEXT_H_ALIGN_RIGHT;
if( m_vAlignTop->IsChecked() )
m_verticalJustification = GR_TEXT_VJUSTIFY_TOP;
m_verticalJustification = GR_TEXT_V_ALIGN_TOP;
else if( m_vAlignCenter->IsChecked() )
m_verticalJustification = GR_TEXT_VJUSTIFY_CENTER;
m_verticalJustification = GR_TEXT_V_ALIGN_CENTER;
else
m_verticalJustification = GR_TEXT_VJUSTIFY_BOTTOM;
m_verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
m_isVisible = m_visible->GetValue();
@ -394,7 +394,7 @@ void DIALOG_FIELD_PROPERTIES::updateText( EDA_TEXT* aText )
aText->SetTextSize( wxSize( m_size, m_size ) );
aText->SetVisible( m_isVisible );
aText->SetTextAngle( m_isVertical ? TEXT_ANGLE_VERT : TEXT_ANGLE_HORIZ );
aText->SetTextAngle( m_isVertical ? EDA_ANGLE::VERTICAL : EDA_ANGLE::HORIZONTAL );
aText->SetItalic( m_isItalic );
aText->SetBold( m_isBold );
}
@ -596,14 +596,14 @@ void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH
symbol->SetFootprint( m_text );
}
EDA_TEXT_HJUSTIFY_T hJustify = EDA_TEXT::MapHorizJustify( m_horizontalJustification - 1 );
EDA_TEXT_VJUSTIFY_T vJustify = EDA_TEXT::MapVertJustify( m_verticalJustification - 1 );
GR_TEXT_H_ALIGN_T hJustify = EDA_TEXT::MapHorizJustify( m_horizontalJustification - 1 );
GR_TEXT_V_ALIGN_T vJustify = EDA_TEXT::MapVertJustify( m_verticalJustification - 1 );
bool positioningModified = false;
if( aField->GetPosition() != m_position )
positioningModified = true;
if( ( aField->GetTextAngle() == TEXT_ANGLE_VERT ) != m_isVertical )
if( aField->GetTextAngle().IsVertical() != m_isVertical )
positioningModified = true;
if( aField->GetEffectiveHorizJustify() != hJustify )

View File

@ -137,23 +137,23 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow()
m_CommonUnit->SetValue( m_graphicText->GetUnit() == 0 );
m_CommonConvert->SetValue( m_graphicText->GetConvert() == 0 );
if( m_graphicText->GetTextAngle() == TEXT_ANGLE_HORIZ )
if( m_graphicText->GetTextAngle().IsHorizontal() )
m_horizontal->Check();
else
m_vertical->Check();
switch ( m_graphicText->GetHorizJustify() )
{
case GR_TEXT_HJUSTIFY_LEFT: m_hAlignLeft->Check( true ); break;
case GR_TEXT_HJUSTIFY_CENTER: m_hAlignCenter->Check( true ); break;
case GR_TEXT_HJUSTIFY_RIGHT: m_hAlignRight->Check( true ); break;
case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
}
switch ( m_graphicText->GetVertJustify() )
{
case GR_TEXT_VJUSTIFY_TOP: m_vAlignTop->Check( true ); break;
case GR_TEXT_VJUSTIFY_CENTER: m_vAlignCenter->Check( true ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: m_vAlignBottom->Check( true ); break;
case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
}
}
else
@ -166,7 +166,7 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow()
m_CommonUnit->SetValue( !tools->GetDrawSpecificUnit() );
m_CommonConvert->SetValue( !tools->GetDrawSpecificConvert() );
if( tools->GetLastTextAngle() == TEXT_ANGLE_HORIZ )
if( tools->GetLastTextAngle().IsHorizontal() )
m_horizontal->Check();
else
m_vertical->Check();
@ -221,9 +221,9 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow()
m_graphicText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) );
if( m_horizontal->IsChecked() )
m_graphicText->SetTextAngle( TEXT_ANGLE_HORIZ );
m_graphicText->SetTextAngle( EDA_ANGLE::HORIZONTAL );
else
m_graphicText->SetTextAngle( TEXT_ANGLE_VERT );
m_graphicText->SetTextAngle( EDA_ANGLE::VERTICAL );
if( !m_CommonUnit->GetValue() )
m_graphicText->SetUnit( m_parent->GetUnit() );
@ -239,18 +239,18 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow()
m_graphicText->SetBold( m_bold->IsChecked() );
if( m_hAlignLeft->IsChecked() )
m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
else if( m_hAlignCenter->IsChecked() )
m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
else
m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
if( m_vAlignTop->IsChecked() )
m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
else if( m_vAlignCenter->IsChecked() )
m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
else
m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
// Record settings used for next time:
auto* tools = m_parent->GetToolManager()->GetTool<SYMBOL_EDITOR_DRAWING_TOOLS>();

View File

@ -167,11 +167,11 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent )
if( resetEffects )
{
// Careful: the visible bit and position are also in Effects
// Careful: the visible bit and position are also set by SetAttributes()
bool visible = field.IsVisible();
wxPoint pos = field.GetPosition();
field.SetEffects( *parentField );
field.SetAttributes( *parentField );
field.SetVisible( visible );
field.SetPosition( pos );
@ -207,7 +207,7 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent )
newField->SetName( parentField->GetCanonicalName() );
newField->SetText( parentField->GetText() );
newField->SetEffects( *parentField ); // Includes visible bit and position
newField->SetAttributes( *parentField ); // Includes visible bit and position
}
}

View File

@ -359,13 +359,13 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
ref.SetText( wxT( "U1" ) );
ref.SetPosition( MILS_POINT( p.x + 30, p.y + 260 ) );
ref.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
ref.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
LIB_FIELD& value = symbol->GetValueField();
value.SetText( wxT( "OPA604" ) );
value.SetPosition( MILS_POINT( p.x + 30, p.y + 180 ) );
value.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
value.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
symbol->SetShowPinNames( true );
symbol->SetShowPinNumbers( true );

View File

@ -466,9 +466,9 @@ wxString FIELDS_GRID_TABLE<T>::GetValue( int aRow, int aCol )
case FDC_H_ALIGN:
switch ( field.GetHorizJustify() )
{
case GR_TEXT_HJUSTIFY_LEFT: return _( "Left" );
case GR_TEXT_HJUSTIFY_CENTER: return _( "Center" );
case GR_TEXT_HJUSTIFY_RIGHT: return _( "Right" );
case GR_TEXT_H_ALIGN_LEFT: return _( "Left" );
case GR_TEXT_H_ALIGN_CENTER: return _( "Center" );
case GR_TEXT_H_ALIGN_RIGHT: return _( "Right" );
}
break;
@ -476,9 +476,9 @@ wxString FIELDS_GRID_TABLE<T>::GetValue( int aRow, int aCol )
case FDC_V_ALIGN:
switch ( field.GetVertJustify() )
{
case GR_TEXT_VJUSTIFY_TOP: return _( "Top" );
case GR_TEXT_VJUSTIFY_CENTER: return _( "Center" );
case GR_TEXT_VJUSTIFY_BOTTOM: return _( "Bottom" );
case GR_TEXT_V_ALIGN_TOP: return _( "Top" );
case GR_TEXT_V_ALIGN_CENTER: return _( "Center" );
case GR_TEXT_V_ALIGN_BOTTOM: return _( "Bottom" );
}
break;
@ -493,13 +493,10 @@ wxString FIELDS_GRID_TABLE<T>::GetValue( int aRow, int aCol )
return StringFromValue( m_frame->GetUserUnits(), field.GetTextSize().GetHeight(), true );
case FDC_ORIENTATION:
switch ( (int) field.GetTextAngle() )
{
case TEXT_ANGLE_HORIZ: return _( "Horizontal" );
case TEXT_ANGLE_VERT: return _( "Vertical" );
}
break;
if( field.GetTextAngle().IsHorizontal() )
return _( "Horizontal" );
else
return _( "Vertical" );
case FDC_POSX:
return StringFromValue( m_frame->GetUserUnits(), field.GetTextPos().x, true );
@ -579,22 +576,22 @@ void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue
case FDC_H_ALIGN:
if( aValue == _( "Left" ) )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
else if( aValue == _( "Center" ) )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
field.SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
else if( aValue == _( "Right" ) )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else
wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
break;
case FDC_V_ALIGN:
if( aValue == _( "Top" ) )
field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
field.SetVertJustify( GR_TEXT_V_ALIGN_TOP );
else if( aValue == _( "Center" ) )
field.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
field.SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
else if( aValue == _( "Bottom" ) )
field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
field.SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else
wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
break;
@ -614,9 +611,9 @@ void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue
case FDC_ORIENTATION:
if( aValue == _( "Horizontal" ) )
field.SetTextAngle( TEXT_ANGLE_HORIZ );
field.SetTextAngle( EDA_ANGLE::HORIZONTAL );
else if( aValue == _( "Vertical" ) )
field.SetTextAngle( TEXT_ANGLE_VERT );
field.SetTextAngle( EDA_ANGLE::VERTICAL );
else
wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
break;

View File

@ -73,7 +73,7 @@ LIB_FIELD& LIB_FIELD::operator=( const LIB_FIELD& field )
m_parent = field.m_parent;
SetText( field.GetText() );
SetEffects( field );
SetAttributes( field );
return *this;
}
@ -85,7 +85,7 @@ void LIB_FIELD::Init( int aId )
m_id = aId;
SetTextAngle( TEXT_ANGLE_HORIZ ); // constructor already did this.
SetTextAngle( EDA_ANGLE::HORIZONTAL ); // constructor already did this.
// Fields in RAM must always have names, because we are trying to get less dependent on
// field ids and more dependent on names. Plus assumptions are made in the field editors.
@ -152,8 +152,8 @@ bool LIB_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
// The text orientation may need to be flipped if the transformation matrix causes xy axes
// to be flipped. This simple algo works only for schematic matrix (rot 90 or/and mirror)
bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != EDA_ANGLE::HORIZONTAL );
tmp_text.SetTextAngle( t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL );
return tmp_text.TextHitTest( aPosition, aAccuracy );
}
@ -174,7 +174,7 @@ void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
aTarget->m_name = m_name;
aTarget->CopyText( *this );
aTarget->SetEffects( *this );
aTarget->SetAttributes( *this );
aTarget->SetParent( m_parent );
}
@ -280,7 +280,8 @@ void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW )
RotatePoint( &pt, center, rot_angle );
SetTextPos( pt );
SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 );
SetTextAngle( GetTextAngle() != EDA_ANGLE::HORIZONTAL ? EDA_ANGLE::HORIZONTAL
: EDA_ANGLE::VERTICAL );
}
@ -291,21 +292,21 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
return;
// Calculate the text orientation, according to the symbol orientation/mirror.
int orient = (int) GetTextAngle();
EDA_ANGLE orient = GetTextAngle();
if( aTransform.y1 ) // Rotate symbol 90 deg.
{
if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ANGLE_VERT;
if( orient.IsHorizontal() )
orient = EDA_ANGLE::VERTICAL;
else
orient = TEXT_ANGLE_HORIZ;
orient = EDA_ANGLE::HORIZONTAL;
}
EDA_RECT bbox = GetBoundingBox();
bbox.RevertYAxis();
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_CENTER;
GR_TEXT_V_ALIGN_T vjustify = GR_TEXT_V_ALIGN_CENTER;
wxPoint textpos = aTransform.TransformCoordinate( bbox.Centre() ) + aOffset;
COLOR4D color;
@ -351,8 +352,8 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const
wxPoint orig = rect.GetOrigin();
wxPoint end = rect.GetEnd();
RotatePoint( &orig, GetTextPos(), -GetTextAngle() );
RotatePoint( &end, GetTextPos(), -GetTextAngle() );
RotatePoint( &orig, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
RotatePoint( &end, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
rect.SetOrigin( orig );
rect.SetEnd( end );
@ -468,18 +469,18 @@ void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
switch ( GetHorizJustify() )
{
case GR_TEXT_HJUSTIFY_LEFT: msg = _( "Left" ); break;
case GR_TEXT_HJUSTIFY_CENTER: msg = _( "Center" ); break;
case GR_TEXT_HJUSTIFY_RIGHT: msg = _( "Right" ); break;
case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
}
aList.emplace_back( _( "H Justification" ), msg );
switch ( GetVertJustify() )
{
case GR_TEXT_VJUSTIFY_TOP: msg = _( "Top" ); break;
case GR_TEXT_VJUSTIFY_CENTER: msg = _( "Center" ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: msg = _( "Bottom" ); break;
case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
}
aList.emplace_back( _( "V Justification" ), msg );

View File

@ -394,24 +394,24 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos,
if( aPinOrient == PIN_RIGHT )
{
x = x1 + aTextInside;
GRText( DC, wxPoint( x, y1 ), NameColor, name, TEXT_ANGLE_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, false,
false );
GRText( DC, wxPoint( x, y1 ), NameColor, name, EDA_ANGLE::HORIZONTAL,
PinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth,
false, false );
}
else // Orient == PIN_LEFT
{
x = x1 - aTextInside;
GRText( DC, wxPoint( x, y1 ), NameColor, name, TEXT_ANGLE_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, false,
false );
GRText( DC, wxPoint( x, y1 ), NameColor, name, EDA_ANGLE::HORIZONTAL,
PinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth,
false, false );
}
}
if( aDrawPinNum )
{
GRText( DC, wxPoint(( x1 + aPinPos.x) / 2, y1 - num_offset ), NumColor, number,
TEXT_ANGLE_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false );
EDA_ANGLE::HORIZONTAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
}
}
else /* Its a vertical line. */
@ -423,16 +423,16 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos,
if( aDrawPinName )
{
GRText( DC, wxPoint( x1, y ), NameColor, name, TEXT_ANGLE_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, false,
GRText( DC, wxPoint( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, PinNameSize,
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false,
false );
}
if( aDrawPinNum )
{
GRText( DC, wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
number, TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false );
number, EDA_ANGLE::VERTICAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
}
}
else /* PIN_UP */
@ -441,16 +441,16 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos,
if( aDrawPinName )
{
GRText( DC, wxPoint( x1, y ), NameColor, name, TEXT_ANGLE_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, false,
GRText( DC, wxPoint( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, PinNameSize,
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false,
false );
}
if( aDrawPinNum )
{
GRText( DC, wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
number, TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false );
number, EDA_ANGLE::VERTICAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
}
}
}
@ -463,15 +463,15 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos,
if( aDrawPinName )
{
x = ( x1 + aPinPos.x) / 2;
GRText( DC, wxPoint( x, y1 - name_offset ), NameColor, name, TEXT_ANGLE_HORIZ,
PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
GRText( DC, wxPoint( x, y1 - name_offset ), NameColor, name, EDA_ANGLE::HORIZONTAL,
PinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
namePenWidth, false, false );
}
if( aDrawPinNum )
{
x = ( x1 + aPinPos.x) / 2;
GRText( DC, wxPoint( x, y1 + num_offset ), NumColor, number, TEXT_ANGLE_HORIZ,
PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, numPenWidth,
GRText( DC, wxPoint( x, y1 + num_offset ), NumColor, number, EDA_ANGLE::HORIZONTAL,
PinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, numPenWidth,
false, false );
}
}
@ -480,15 +480,15 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos,
if( aDrawPinName )
{
y = ( y1 + aPinPos.y) / 2;
GRText( DC, wxPoint( x1 - name_offset, y ), NameColor, name, TEXT_ANGLE_VERT,
PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
GRText( DC, wxPoint( x1 - name_offset, y ), NameColor, name, EDA_ANGLE::VERTICAL,
PinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
namePenWidth, false, false );
}
if( aDrawPinNum )
{
GRText( DC, wxPoint( x1 + num_offset, ( y1 + aPinPos.y) / 2 ), NumColor, number,
TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP,
EDA_ANGLE::VERTICAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP,
numPenWidth, false, false );
}
}
@ -519,20 +519,20 @@ void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, wxPo
wxPoint txtpos = aPosition;
int offset = Millimeter2iu( 0.4 );
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_LEFT;
int orient = TEXT_ANGLE_HORIZ;
GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_LEFT;
EDA_ANGLE orient = EDA_ANGLE::HORIZONTAL;
switch( aOrientation )
{
case PIN_UP:
txtpos.y += offset;
orient = TEXT_ANGLE_VERT;
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
orient = EDA_ANGLE::VERTICAL;
hjustify = GR_TEXT_H_ALIGN_RIGHT;
break;
case PIN_DOWN:
txtpos.y -= offset;
orient = TEXT_ANGLE_VERT;
orient = EDA_ANGLE::VERTICAL;
break;
case PIN_LEFT:
@ -541,12 +541,12 @@ void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, wxPo
case PIN_RIGHT:
txtpos.x -= offset;
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
hjustify = GR_TEXT_H_ALIGN_RIGHT;
break;
}
GRText( DC, txtpos, color, typeName, orient, wxSize( textSize, textSize ), hjustify,
GR_TEXT_VJUSTIFY_CENTER, pensize, false, false, nullptr );
GR_TEXT_V_ALIGN_CENTER, pensize, false, false, nullptr );
}
@ -679,8 +679,8 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie
}
void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinOrient, int aTextInside,
bool aDrawPinNum, bool aDrawPinName ) const
void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinOrient,
int aTextInside, bool aDrawPinNum, bool aDrawPinName ) const
{
wxString name = GetShownName();
wxString number = GetShownNumber();
@ -728,27 +728,27 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO
{
if( aDrawPinName )
{
EDA_TEXT_HJUSTIFY_T hjustify;
GR_TEXT_H_ALIGN_T hjustify;
if( aPinOrient == PIN_RIGHT )
{
x = x1 + aTextInside;
hjustify = GR_TEXT_HJUSTIFY_LEFT;
hjustify = GR_TEXT_H_ALIGN_LEFT;
}
else // orient == PIN_LEFT
{
x = x1 - aTextInside;
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
hjustify = GR_TEXT_H_ALIGN_RIGHT;
}
aPlotter->Text( wxPoint( x, y1 ), nameColor, name, TEXT_ANGLE_HORIZ, pinNameSize,
hjustify, GR_TEXT_VJUSTIFY_CENTER, namePenWidth,
aPlotter->Text( wxPoint( x, y1 ), nameColor, name, EDA_ANGLE::HORIZONTAL,
pinNameSize, hjustify, GR_TEXT_V_ALIGN_CENTER, namePenWidth,
false, false );
}
if( aDrawPinNum )
{
aPlotter->Text( wxPoint( ( x1 + aPinPos.x) / 2, y1 - num_offset ), numColor,
number, TEXT_ANGLE_HORIZ, pinNumSize, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false );
number, EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
}
}
else /* Its a vertical line. */
@ -758,15 +758,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO
y = y1 + aTextInside;
if( aDrawPinName )
aPlotter->Text( wxPoint( x1, y ), nameColor, name, TEXT_ANGLE_VERT,
pinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER,
aPlotter->Text( wxPoint( x1, y ), nameColor, name, EDA_ANGLE::VERTICAL,
pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER,
namePenWidth, false, false );
if( aDrawPinNum )
{
aPlotter->Text( wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor,
number, TEXT_ANGLE_VERT, pinNumSize, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false );
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
}
}
else /* PIN_UP */
@ -775,16 +775,16 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO
if( aDrawPinName )
{
aPlotter->Text( wxPoint( x1, y ), nameColor, name, TEXT_ANGLE_VERT,
pinNameSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
aPlotter->Text( wxPoint( x1, y ), nameColor, name, EDA_ANGLE::VERTICAL,
pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER,
namePenWidth, false, false );
}
if( aDrawPinNum )
{
aPlotter->Text( wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor,
number, TEXT_ANGLE_VERT, pinNumSize, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false );
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
}
}
}
@ -798,16 +798,16 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO
{
x = ( x1 + aPinPos.x) / 2;
aPlotter->Text( wxPoint( x, y1 - name_offset ), nameColor, name,
TEXT_ANGLE_HORIZ, pinNameSize, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, namePenWidth, false, false );
EDA_ANGLE::HORIZONTAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false );
}
if( aDrawPinNum )
{
x = ( x1 + aPinPos.x ) / 2;
aPlotter->Text( wxPoint( x, y1 + num_offset ), numColor, number,
TEXT_ANGLE_HORIZ, pinNumSize, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, numPenWidth, false, false );
EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false );
}
}
else /* Its a vertical line. */
@ -816,15 +816,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO
{
y = ( y1 + aPinPos.y ) / 2;
aPlotter->Text( wxPoint( x1 - name_offset, y ), nameColor, name,
TEXT_ANGLE_VERT, pinNameSize, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, namePenWidth, false, false );
EDA_ANGLE::VERTICAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false );
}
if( aDrawPinNum )
{
aPlotter->Text( wxPoint( x1 + num_offset, ( y1 + aPinPos.y ) / 2 ), numColor,
number, TEXT_ANGLE_VERT, pinNumSize, GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, numPenWidth, false, false );
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false );
}
}
}

View File

@ -62,9 +62,9 @@ bool LIB_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
* transformation matrix causes xy axes to be flipped.
* this simple algo works only for schematic matrix (rot 90 or/and mirror)
*/
bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != EDA_ANGLE::HORIZONTAL );
tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
tmp_text.SetTextAngle( t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL );
return tmp_text.TextHitTest( aPosition, aAccuracy );
}
@ -78,7 +78,7 @@ EDA_ITEM* LIB_TEXT::Clone() const
newitem->m_flags = m_flags;
newitem->SetText( GetText() );
newitem->SetEffects( *this );
newitem->SetAttributes( *this );
return newitem;
}
@ -133,28 +133,28 @@ void LIB_TEXT::NormalizeJustification( bool inverse )
wxPoint delta( 0, 0 );
EDA_RECT bbox = GetTextBox();
if( GetTextAngle() == 0.0 )
if( GetTextAngle().IsHorizontal() )
{
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
delta.x = bbox.GetWidth() / 2;
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
delta.x = - bbox.GetWidth() / 2;
if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
delta.y = - bbox.GetHeight() / 2;
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
delta.y = bbox.GetHeight() / 2;
}
else
{
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
delta.y = bbox.GetWidth() / 2;
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
delta.y = - bbox.GetWidth() / 2;
if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
delta.x = + bbox.GetHeight() / 2;
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
delta.x = - bbox.GetHeight() / 2;
}
@ -174,19 +174,19 @@ void LIB_TEXT::MirrorHorizontal( const wxPoint& center )
x *= -1;
x += center.x;
if( GetTextAngle() == 0.0 )
if( GetTextAngle().IsHorizontal() )
{
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
}
else
{
if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
SetVertJustify( GR_TEXT_V_ALIGN_TOP );
}
SetTextX( x );
@ -203,19 +203,19 @@ void LIB_TEXT::MirrorVertical( const wxPoint& center )
y *= -1;
y += center.y;
if( GetTextAngle() == 0.0 )
if( GetTextAngle().IsHorizontal() )
{
if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
SetVertJustify( GR_TEXT_V_ALIGN_TOP );
}
else
{
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
}
SetTextY( y );
@ -232,23 +232,23 @@ void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW )
RotatePoint( &pt, center, rot_angle );
SetTextPos( pt );
if( GetTextAngle() == 0.0 )
if( GetTextAngle().IsHorizontal() )
{
SetTextAngle( 900 );
SetTextAngle( EDA_ANGLE::VERTICAL );
}
else
{
// 180º of rotation is a mirror
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
SetVertJustify( GR_TEXT_V_ALIGN_TOP );
SetTextAngle( 0 );
}
@ -269,7 +269,7 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
// The text orientation may need to be flipped if the transformation matrix causes xy
// axes to be flipped.
int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != EDA_ANGLE::HORIZONTAL );
wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset;
// Get color
@ -284,9 +284,9 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
int penWidth = std::max( GetEffectiveTextPenWidth(), settings->GetMinPenWidth() );
plotter->Text( pos, color, GetText(), t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT, GetTextSize(),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(),
IsBold() );
plotter->Text( pos, color, GetText(), t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL,
GetTextSize(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth,
IsItalic(), IsBold() );
}
@ -305,14 +305,14 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
// Calculate the text orientation, according to the symbol orientation/mirror (needed when
// draw text in schematic)
int orient = (int) GetTextAngle();
EDA_ANGLE orient = GetTextAngle();
if( aTransform.y1 ) // Rotate symbol 90 degrees.
{
if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ANGLE_VERT;
if( orient == EDA_ANGLE::HORIZONTAL )
orient = EDA_ANGLE::VERTICAL;
else
orient = TEXT_ANGLE_HORIZ;
orient = EDA_ANGLE::HORIZONTAL;
}
/*
@ -334,8 +334,8 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
// Calculate pos according to mirror/rotation.
txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset;
GRText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), IsBold() );
GRText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold() );
}
@ -355,18 +355,18 @@ void LIB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
switch ( GetHorizJustify() )
{
case GR_TEXT_HJUSTIFY_LEFT: msg = _( "Left" ); break;
case GR_TEXT_HJUSTIFY_CENTER: msg = _( "Center" ); break;
case GR_TEXT_HJUSTIFY_RIGHT: msg = _( "Right" ); break;
case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
}
aList.emplace_back( _( "H Justification" ), msg );
switch ( GetVertJustify() )
{
case GR_TEXT_VJUSTIFY_TOP: msg = _( "Top" ); break;
case GR_TEXT_VJUSTIFY_CENTER: msg = _( "Center" ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: msg = _( "Bottom" ); break;
case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
}
aList.emplace_back( _( "V Justification" ), msg );
@ -385,8 +385,8 @@ const EDA_RECT LIB_TEXT::GetBoundingBox() const
wxPoint orig = rect.GetOrigin();
wxPoint end = rect.GetEnd();
RotatePoint( &orig, GetTextPos(), -GetTextAngle() );
RotatePoint( &end, GetTextPos(), -GetTextAngle() );
RotatePoint( &orig, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
RotatePoint( &end, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
rect.SetOrigin( orig );
rect.SetEnd( end );

View File

@ -74,7 +74,7 @@ public:
if( aContained )
return rect.Contains( textBox );
return rect.Intersects( textBox, GetTextAngle() );
return rect.Intersects( textBox, GetTextAngle().AsTenthsOfADegree() );
}
int GetPenWidth() const override;

View File

@ -217,7 +217,6 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset
{
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = aSettings->GetLayerColor( IsForceVisible() ? LAYER_HIDDEN : m_layer );
int orient;
wxPoint textpos;
int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
@ -225,7 +224,7 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset
return;
// Calculate the text orientation according to the symbol orientation.
orient = GetTextAngle();
EDA_ANGLE orient = GetTextAngle();
if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
{
@ -233,10 +232,10 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset
if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
{
if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ANGLE_VERT;
if( orient == EDA_ANGLE::HORIZONTAL )
orient = EDA_ANGLE::VERTICAL;
else
orient = TEXT_ANGLE_HORIZ;
orient = EDA_ANGLE::HORIZONTAL;
}
}
@ -252,14 +251,14 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset
*/
textpos = GetBoundingBox().Centre() + aOffset;
GRText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), IsBold() );
GRText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold() );
}
void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
{
SetEffects( aSource );
SetAttributes( aSource );
}
@ -272,14 +271,14 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem )
std::swap( m_layer, item->m_layer );
SwapText( *item );
SwapEffects( *item );
SwapAttributes( *item );
}
double SCH_FIELD::GetDrawRotation() const
EDA_ANGLE SCH_FIELD::GetDrawRotation() const
{
// Calculate the text orientation according to the symbol orientation.
int orient = GetTextAngle();
EDA_ANGLE orient = GetTextAngle();
if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
{
@ -287,10 +286,10 @@ double SCH_FIELD::GetDrawRotation() const
if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
{
if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ANGLE_VERT;
if( orient.IsHorizontal() )
orient = EDA_ANGLE::VERTICAL;
else
orient = TEXT_ANGLE_HORIZ;
orient = EDA_ANGLE::HORIZONTAL;
}
}
@ -304,15 +303,15 @@ wxPoint SCH_FIELD::GetDrawPos() const
}
EDA_TEXT_HJUSTIFY_T SCH_FIELD::GetDrawHorizJustify() const
GR_TEXT_H_ALIGN_T SCH_FIELD::GetDrawHorizJustify() const
{
return GR_TEXT_HJUSTIFY_CENTER;
return GR_TEXT_H_ALIGN_CENTER;
}
EDA_TEXT_VJUSTIFY_T SCH_FIELD::GetDrawVertJustify() const
GR_TEXT_V_ALIGN_T SCH_FIELD::GetDrawVertJustify() const
{
return GR_TEXT_VJUSTIFY_CENTER;
return GR_TEXT_V_ALIGN_CENTER;
}
@ -326,8 +325,8 @@ const EDA_RECT SCH_FIELD::GetBoundingBox() const
wxPoint pos = GetTextPos() - origin;
wxPoint begin = rect.GetOrigin() - origin;
wxPoint end = rect.GetEnd() - origin;
RotatePoint( &begin, pos, GetTextAngle() );
RotatePoint( &end, pos, GetTextAngle() );
RotatePoint( &begin, pos, GetTextAngle().AsTenthsOfADegree() );
RotatePoint( &end, pos, GetTextAngle().AsTenthsOfADegree() );
// Now, apply the symbol transform (mirror/rot)
TRANSFORM transform;
@ -365,13 +364,13 @@ bool SCH_FIELD::IsHorizJustifyFlipped() const
switch( GetHorizJustify() )
{
case GR_TEXT_HJUSTIFY_LEFT:
if( GetDrawRotation() == TEXT_ANGLE_VERT )
case GR_TEXT_H_ALIGN_LEFT:
if( GetDrawRotation().IsVertical() )
return render_center.y > pos.y;
else
return render_center.x < pos.x;
case GR_TEXT_HJUSTIFY_RIGHT:
if( GetDrawRotation() == TEXT_ANGLE_VERT )
case GR_TEXT_H_ALIGN_RIGHT:
if( GetDrawRotation().IsVertical() )
return render_center.y < pos.y;
else
return render_center.x > pos.x;
@ -381,16 +380,16 @@ bool SCH_FIELD::IsHorizJustifyFlipped() const
}
EDA_TEXT_HJUSTIFY_T SCH_FIELD::GetEffectiveHorizJustify() const
GR_TEXT_H_ALIGN_T SCH_FIELD::GetEffectiveHorizJustify() const
{
switch( GetHorizJustify() )
{
case GR_TEXT_HJUSTIFY_LEFT:
return IsHorizJustifyFlipped() ? GR_TEXT_HJUSTIFY_RIGHT : GR_TEXT_HJUSTIFY_LEFT;
case GR_TEXT_HJUSTIFY_RIGHT:
return IsHorizJustifyFlipped() ? GR_TEXT_HJUSTIFY_LEFT : GR_TEXT_HJUSTIFY_RIGHT;
case GR_TEXT_H_ALIGN_LEFT:
return IsHorizJustifyFlipped() ? GR_TEXT_H_ALIGN_RIGHT : GR_TEXT_H_ALIGN_LEFT;
case GR_TEXT_H_ALIGN_RIGHT:
return IsHorizJustifyFlipped() ? GR_TEXT_H_ALIGN_LEFT : GR_TEXT_H_ALIGN_RIGHT;
default:
return GR_TEXT_HJUSTIFY_CENTER;
return GR_TEXT_H_ALIGN_CENTER;
}
}
@ -402,13 +401,13 @@ bool SCH_FIELD::IsVertJustifyFlipped() const
switch( GetVertJustify() )
{
case GR_TEXT_VJUSTIFY_TOP:
if( GetDrawRotation() == TEXT_ANGLE_VERT )
case GR_TEXT_V_ALIGN_TOP:
if( GetDrawRotation().IsVertical() )
return render_center.x < pos.x;
else
return render_center.y < pos.y;
case GR_TEXT_VJUSTIFY_BOTTOM:
if( GetDrawRotation() == TEXT_ANGLE_VERT )
case GR_TEXT_V_ALIGN_BOTTOM:
if( GetDrawRotation().IsVertical() )
return render_center.x > pos.x;
else
return render_center.y > pos.y;
@ -418,16 +417,16 @@ bool SCH_FIELD::IsVertJustifyFlipped() const
}
EDA_TEXT_VJUSTIFY_T SCH_FIELD::GetEffectiveVertJustify() const
GR_TEXT_V_ALIGN_T SCH_FIELD::GetEffectiveVertJustify() const
{
switch( GetVertJustify() )
{
case GR_TEXT_VJUSTIFY_TOP:
return IsVertJustifyFlipped() ? GR_TEXT_VJUSTIFY_BOTTOM : GR_TEXT_VJUSTIFY_TOP;
case GR_TEXT_VJUSTIFY_BOTTOM:
return IsVertJustifyFlipped() ? GR_TEXT_VJUSTIFY_TOP : GR_TEXT_VJUSTIFY_BOTTOM;
case GR_TEXT_V_ALIGN_TOP:
return IsVertJustifyFlipped() ? GR_TEXT_V_ALIGN_BOTTOM : GR_TEXT_V_ALIGN_TOP;
case GR_TEXT_V_ALIGN_BOTTOM:
return IsVertJustifyFlipped() ? GR_TEXT_V_ALIGN_TOP : GR_TEXT_V_ALIGN_BOTTOM;
default:
return GR_TEXT_VJUSTIFY_CENTER;
return GR_TEXT_V_ALIGN_CENTER;
}
}
@ -610,18 +609,18 @@ void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
switch ( GetHorizJustify() )
{
case GR_TEXT_HJUSTIFY_LEFT: msg = _( "Left" ); break;
case GR_TEXT_HJUSTIFY_CENTER: msg = _( "Center" ); break;
case GR_TEXT_HJUSTIFY_RIGHT: msg = _( "Right" ); break;
case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
}
aList.emplace_back( _( "H Justification" ), msg );
switch ( GetVertJustify() )
{
case GR_TEXT_VJUSTIFY_TOP: msg = _( "Top" ); break;
case GR_TEXT_VJUSTIFY_CENTER: msg = _( "Center" ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: msg = _( "Bottom" ); break;
case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
}
aList.emplace_back( _( "V Justification" ), msg );
@ -833,7 +832,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) const
return;
// Calculate the text orientation, according to the symbol orientation/mirror
int orient = GetTextAngle();
EDA_ANGLE orient = GetTextAngle();
if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
{
@ -841,10 +840,10 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) const
if( parentSymbol->GetTransform().y1 ) // Rotate symbol 90 deg.
{
if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ANGLE_VERT;
if( orient.IsHorizontal() )
orient = EDA_ANGLE::VERTICAL;
else
orient = TEXT_ANGLE_HORIZ;
orient = EDA_ANGLE::HORIZONTAL;
}
}
@ -858,8 +857,8 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) const
* to calculate so the easier way is to use no justifications (centered text) and use
* GetBoundingBox to know the text coordinate considered as centered
*/
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_CENTER;
GR_TEXT_V_ALIGN_T vjustify = GR_TEXT_V_ALIGN_CENTER;
wxPoint textpos = GetBoundingBox().Centre();
aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify,

View File

@ -119,10 +119,10 @@ public:
/**
* Adjusters to allow EDA_TEXT to draw/print/etc. text in absolute coords.
*/
double GetDrawRotation() const override;
EDA_ANGLE GetDrawRotation() const override;
wxPoint GetDrawPos() const override;
EDA_TEXT_HJUSTIFY_T GetDrawHorizJustify() const override;
EDA_TEXT_VJUSTIFY_T GetDrawVertJustify() const override;
GR_TEXT_H_ALIGN_T GetDrawHorizJustify() const override;
GR_TEXT_V_ALIGN_T GetDrawVertJustify() const override;
const EDA_RECT GetBoundingBox() const override;
@ -133,8 +133,8 @@ public:
bool IsHorizJustifyFlipped() const;
bool IsVertJustifyFlipped() const;
EDA_TEXT_HJUSTIFY_T GetEffectiveHorizJustify() const;
EDA_TEXT_VJUSTIFY_T GetEffectiveVertJustify() const;
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const;
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const;
/**
* @return true if the field is either empty or holds "~".

View File

@ -187,8 +187,8 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
auto pos = item->GetBoundingBox().Centre();
auto label = conn->Name( true );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetStrokeColor( COLOR4D( LIGHTRED ) );
m_gal->SetLineWidth( Mils2ui( 2 ) );
m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) );
@ -448,14 +448,14 @@ void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition, dou
m_gal->GetLineWidth() );
EDA_RECT box( (wxPoint) aPosition, wxSize( extents.x, extents.y ) );
if( m_gal->GetHorizontalJustify() == GR_TEXT_HJUSTIFY_CENTER )
if( m_gal->GetHorizontalJustify() == GR_TEXT_H_ALIGN_CENTER )
box.SetX( box.GetX() - ( box.GetWidth() / 2) );
else if( m_gal->GetHorizontalJustify() == GR_TEXT_HJUSTIFY_RIGHT )
else if( m_gal->GetHorizontalJustify() == GR_TEXT_H_ALIGN_RIGHT )
box.SetX( box.GetX() - box.GetWidth() );
if( m_gal->GetVerticalJustify() == GR_TEXT_VJUSTIFY_CENTER )
if( m_gal->GetVerticalJustify() == GR_TEXT_V_ALIGN_CENTER )
box.SetY( box.GetY() - ( box.GetHeight() / 2) );
else if( m_gal->GetVerticalJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
else if( m_gal->GetVerticalJustify() == GR_TEXT_V_ALIGN_BOTTOM )
box.SetY( box.GetY() - box.GetHeight() );
box.Normalize(); // Make h and v sizes always >= 0
@ -695,12 +695,13 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer )
}
else
{
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
m_gal->SetFontItalic( aField->IsItalic() );
strokeText( UnescapeString( aField->GetText() ), textpos, aField->GetTextAngleRadians() );
strokeText( UnescapeString( aField->GetText() ), textpos,
aField->GetTextAngle().AsRadians() );
}
// Draw the umbilical line when in the schematic editor
@ -736,10 +737,10 @@ void SCH_PAINTER::draw( const LIB_TEXT *aText, int aLayer )
EDA_RECT bBox = aText->GetBoundingBox();
bBox.RevertYAxis();
VECTOR2D pos = mapCoords( bBox.Centre() );
double orient = aText->GetTextAngleRadians();
double orient = aText->GetTextAngle().AsRadians();
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
@ -1105,29 +1106,29 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] )
{
setupDC( INSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
}
if( size[OUTSIDE] )
{
setupDC( OUTSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
}
if( size[ABOVE] )
{
setupDC( ABOVE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM );
drawText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
}
if( size[BELOW] )
{
setupDC( BELOW );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP );
drawText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
}
break;
@ -1136,30 +1137,30 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] )
{
setupDC( INSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
drawText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
}
if( size[OUTSIDE] )
{
setupDC( OUTSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
}
if( size[ABOVE] )
{
setupDC( ABOVE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM );
drawText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
}
if( size[BELOW] )
{
setupDC( BELOW );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP );
drawText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
}
break;
@ -1168,29 +1169,29 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] )
{
setupDC( INSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 );
}
if( size[OUTSIDE] )
{
setupDC( OUTSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 );
}
if( size[ABOVE] )
{
setupDC( ABOVE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM );
drawText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
}
if( size[BELOW] )
{
setupDC( BELOW );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP );
drawText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
}
break;
@ -1199,29 +1200,29 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] )
{
setupDC( INSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 );
}
if( size[OUTSIDE] )
{
setupDC( OUTSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 );
}
if( size[ABOVE] )
{
setupDC( ABOVE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM );
drawText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
}
if( size[BELOW] )
{
setupDC( BELOW );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP );
drawText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
}
break;
@ -1518,7 +1519,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer )
m_gal->SetTextAttributes( aText );
m_gal->SetFontUnderlined( false );
strokeText( shownText, text_offset, aText->GetTextAngleRadians() );
strokeText( shownText, text_offset, aText->GetTextAngle().AsRadians() );
}
}
@ -1672,17 +1673,17 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer )
}
// Calculate the text orientation according to the parent orientation.
int orient = (int) aField->GetTextAngle();
EDA_ANGLE orient = aField->GetTextAngle();
if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
{
if( static_cast<SCH_SYMBOL*>( aField->GetParent() )->GetTransform().y1 )
{
// Rotate symbol 90 degrees.
if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ANGLE_VERT;
if( orient.IsHorizontal() )
orient = EDA_ANGLE::VERTICAL;
else
orient = TEXT_ANGLE_HORIZ;
orient = EDA_ANGLE::HORIZONTAL;
}
}
@ -1720,8 +1721,8 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer )
}
else
{
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetIsFill( false );
m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
m_gal->SetFontBold( aField->IsBold() );
@ -1729,7 +1730,7 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer )
m_gal->SetFontUnderlined( underline );
m_gal->SetTextMirrored( aField->IsMirrored() );
strokeText( aField->GetShownText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 );
strokeText( aField->GetShownText(), textpos, orient.AsRadians() );
}
// Draw the umbilical line

View File

@ -792,7 +792,7 @@ void SetTextPositioning( EDA_TEXT* text, ASCH_LABEL_JUSTIFICATION justification,
ASCH_RECORD_ORIENTATION orientation )
{
int vjustify, hjustify;
double angle = TEXT_ANGLE_HORIZ;
EDA_ANGLE angle = EDA_ANGLE::HORIZONTAL;
switch( justification )
{
@ -801,17 +801,17 @@ void SetTextPositioning( EDA_TEXT* text, ASCH_LABEL_JUSTIFICATION justification,
case ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT:
case ASCH_LABEL_JUSTIFICATION::BOTTOM_CENTER:
case ASCH_LABEL_JUSTIFICATION::BOTTOM_RIGHT:
vjustify = EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM;
vjustify = GR_TEXT_V_ALIGN_BOTTOM;
break;
case ASCH_LABEL_JUSTIFICATION::CENTER_LEFT:
case ASCH_LABEL_JUSTIFICATION::CENTER_CENTER:
case ASCH_LABEL_JUSTIFICATION::CENTER_RIGHT:
vjustify = EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_CENTER;
vjustify = GR_TEXT_V_ALIGN_CENTER;
break;
case ASCH_LABEL_JUSTIFICATION::TOP_LEFT:
case ASCH_LABEL_JUSTIFICATION::TOP_CENTER:
case ASCH_LABEL_JUSTIFICATION::TOP_RIGHT:
vjustify = EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_TOP;
vjustify = GR_TEXT_V_ALIGN_TOP;
break;
}
@ -822,42 +822,42 @@ void SetTextPositioning( EDA_TEXT* text, ASCH_LABEL_JUSTIFICATION justification,
case ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT:
case ASCH_LABEL_JUSTIFICATION::CENTER_LEFT:
case ASCH_LABEL_JUSTIFICATION::TOP_LEFT:
hjustify = EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT;
hjustify = GR_TEXT_H_ALIGN_LEFT;
break;
case ASCH_LABEL_JUSTIFICATION::BOTTOM_CENTER:
case ASCH_LABEL_JUSTIFICATION::CENTER_CENTER:
case ASCH_LABEL_JUSTIFICATION::TOP_CENTER:
hjustify = EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_CENTER;
hjustify = GR_TEXT_H_ALIGN_CENTER;
break;
case ASCH_LABEL_JUSTIFICATION::BOTTOM_RIGHT:
case ASCH_LABEL_JUSTIFICATION::CENTER_RIGHT:
case ASCH_LABEL_JUSTIFICATION::TOP_RIGHT:
hjustify = EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_RIGHT;
hjustify = GR_TEXT_H_ALIGN_RIGHT;
break;
}
switch( orientation )
{
case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
angle = TEXT_ANGLE_HORIZ;
angle = EDA_ANGLE::HORIZONTAL;
break;
case ASCH_RECORD_ORIENTATION::LEFTWARDS:
vjustify *= -1;
hjustify *= -1;
angle = TEXT_ANGLE_HORIZ;
angle = EDA_ANGLE::HORIZONTAL;
break;
case ASCH_RECORD_ORIENTATION::UPWARDS:
angle = TEXT_ANGLE_VERT;
angle = EDA_ANGLE::VERTICAL;
break;
case ASCH_RECORD_ORIENTATION::DOWNWARDS:
vjustify *= -1;
hjustify *= -1;
angle = TEXT_ANGLE_VERT;
angle = EDA_ANGLE::VERTICAL;
break;
}
text->SetVertJustify( static_cast<EDA_TEXT_VJUSTIFY_T>( vjustify ) );
text->SetHorizJustify( static_cast<EDA_TEXT_HJUSTIFY_T>( hjustify ) );
text->SetVertJustify( static_cast<GR_TEXT_V_ALIGN_T>( vjustify ) );
text->SetHorizJustify( static_cast<GR_TEXT_H_ALIGN_T>( hjustify ) );
text->SetTextAngle( angle );
}
@ -1858,23 +1858,23 @@ void SCH_ALTIUM_PLUGIN::ParsePowerPort( const std::map<wxString, wxString>& aPro
{
case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_90 );
valueField->SetTextAngle( TEXT_ANGLE_VERT );
valueField->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_RIGHT );
valueField->SetTextAngle( EDA_ANGLE::VERTICAL );
valueField->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case ASCH_RECORD_ORIENTATION::UPWARDS:
symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_180 );
valueField->SetTextAngle( TEXT_ANGLE_HORIZ );
valueField->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_CENTER );
valueField->SetTextAngle( EDA_ANGLE::HORIZONTAL );
valueField->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ASCH_RECORD_ORIENTATION::LEFTWARDS:
symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_270 );
valueField->SetTextAngle( TEXT_ANGLE_VERT );
valueField->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_RIGHT );
valueField->SetTextAngle( EDA_ANGLE::VERTICAL );
valueField->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case ASCH_RECORD_ORIENTATION::DOWNWARDS:
symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_0 );
valueField->SetTextAngle( TEXT_ANGLE_HORIZ );
valueField->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_CENTER );
valueField->SetTextAngle( EDA_ANGLE::HORIZONTAL );
valueField->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
default:
m_reporter->Report( _( "Pin has unexpected orientation." ), RPT_SEVERITY_WARNING );

View File

@ -295,9 +295,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheets()
wxFileName loadedFilePath = wxFileName( Filename );
std::string filename = wxString::Format(
"%s_%02d", loadedFilePath.GetName(), getSheetNumber( rootSheetID ) )
.ToStdString();
std::string filename = wxString::Format( "%s_%02d",
loadedFilePath.GetName(),
getSheetNumber( rootSheetID ) ).ToStdString();
ReplaceIllegalFileNameChars( &filename );
filename += wxT( "." ) + KiCadSchematicFileExtension;
@ -484,8 +484,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
sym.ComponentRef.Designator.Replace( wxT( " " ), wxT( "_" ) );
refField->SetText( sym.ComponentRef.Designator );
loadSymbolFieldAttribute( sym.ComponentRef.AttrLoc, symOrientDeciDeg,
sym.Mirror, refField );
loadSymbolFieldAttribute( sym.ComponentRef.AttrLoc, symOrientDeciDeg, sym.Mirror,
refField );
if( sym.HasPartRef )
{
@ -506,8 +506,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
partname.Replace( wxT( "\t" ), wxT( "\\t" ) );
partField->SetText( partname );
loadSymbolFieldAttribute( sym.PartRef.AttrLoc, symOrientDeciDeg,
sym.Mirror, partField );
loadSymbolFieldAttribute( sym.PartRef.AttrLoc, symOrientDeciDeg, sym.Mirror,
partField );
partField->SetVisible( SymbolPartNameColor.IsVisible );
}
@ -796,7 +796,6 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadBusses()
// (the position of the wire will determine how best to place the bus label)
}
}
}
}
@ -882,12 +881,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets()
BLOCK_PIN_ID blockPinID = std::make_pair( blockTerm.BlockID,
blockTerm.TerminalID );
if( m_sheetPinMap.find( blockPinID )
!= m_sheetPinMap.end() )
{
if( m_sheetPinMap.find( blockPinID ) != m_sheetPinMap.end() )
return m_sheetPinMap.at( blockPinID );
}
}
return nullptr;
};
@ -1241,7 +1237,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols()
void CADSTAR_SCH_ARCHIVE_LOADER::loadTextVariables()
{
auto findAndReplaceTextField = [&]( TEXT_FIELD_NAME aField, wxString aValue ) {
auto findAndReplaceTextField =
[&]( TEXT_FIELD_NAME aField, wxString aValue )
{
if( m_context.TextFieldToValuesMap.find( aField ) != m_context.TextFieldToValuesMap.end() )
{
if( m_context.TextFieldToValuesMap.at( aField ) != aValue )
@ -1428,12 +1426,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
EDA_RECT bbox = libtext->GetTextBox( ii, true );
wxPoint linePos = { bbox.GetLeft(), -bbox.GetBottom() };
RotatePoint( &linePos, libtext->GetTextPos(), -libtext->GetTextAngle() );
RotatePoint( &linePos, libtext->GetTextPos(), -libtext->GetTextAngle().AsTenthsOfADegree() );
LIB_TEXT* line = static_cast<LIB_TEXT*>( libtext->Clone() );
line->SetText( strings[ii] );
line->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
line->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
line->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
line->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
line->SetTextPos( linePos );
// Multiline text not allowed in LIB_TEXT
@ -1779,7 +1777,8 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads
symbol->GetLibSymbolRef()->GetPin( term.second ) } );
}
auto replacePinNumber = [&]( wxString aOldPinNum, wxString aNewPinNum )
auto replacePinNumber =
[&]( wxString aOldPinNum, wxString aNewPinNum )
{
if( aOldPinNum == aNewPinNum )
return;
@ -1847,8 +1846,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolFieldAttribute(
}
int CADSTAR_SCH_ARCHIVE_LOADER::getComponentOrientation(
double aOrientAngleDeciDeg, double& aReturnedOrientationDeciDeg )
int CADSTAR_SCH_ARCHIVE_LOADER::getComponentOrientation( double aOrientAngleDeciDeg,
double& aReturnedOrientationDeciDeg )
{
int compOrientation = SYMBOL_ORIENTATION_T::SYM_ORIENT_0;
@ -1879,8 +1878,9 @@ int CADSTAR_SCH_ARCHIVE_LOADER::getComponentOrientation(
}
CADSTAR_SCH_ARCHIVE_LOADER::POINT CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetElement(
const NET_SCH& aNet, const NETELEMENT_ID& aNetElementID )
CADSTAR_SCH_ARCHIVE_LOADER::POINT
CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetElement( const NET_SCH& aNet,
const NETELEMENT_ID& aNetElementID )
{
// clang-format off
auto logUnknownNetElementError =
@ -2028,8 +2028,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadShapeVertices( const std::vector<VERTEX>& a
const VERTEX* prev = &aCadstarVertices.at( 0 );
const VERTEX* cur;
wxASSERT_MSG(
prev->Type == VERTEX_TYPE::POINT, "First vertex should always be a point vertex" );
wxASSERT_MSG( prev->Type == VERTEX_TYPE::POINT,
"First vertex should always be a point vertex" );
for( size_t ii = 1; ii < aCadstarVertices.size(); ii++ )
{
@ -2327,8 +2327,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadItemOntoKiCadSheet( LAYER_ID aCadstarSheetI
}
else if( aCadstarSheetID == "NO_SHEET" )
{
wxASSERT_MSG(
false, "Trying to add an item to NO_SHEET? This might be a documentation symbol." );
wxASSERT_MSG( false,
"Trying to add an item to NO_SHEET? This might be a documentation symbol." );
}
else
{
@ -2345,8 +2345,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadItemOntoKiCadSheet( LAYER_ID aCadstarSheetI
}
CADSTAR_SCH_ARCHIVE_LOADER::SYMDEF_ID CADSTAR_SCH_ARCHIVE_LOADER::getSymDefFromName(
const wxString& aSymdefName, const wxString& aSymDefAlternate )
CADSTAR_SCH_ARCHIVE_LOADER::SYMDEF_ID
CADSTAR_SCH_ARCHIVE_LOADER::getSymDefFromName( const wxString& aSymdefName,
const wxString& aSymDefAlternate )
{
// Do a case-insensitive comparison
for( std::pair<SYMDEF_ID, SYMDEF_SCM> symPair : Library.SymbolDefinitions )
@ -2409,8 +2410,8 @@ PLOT_DASH_TYPE CADSTAR_SCH_ARCHIVE_LOADER::getLineStyle( const LINECODE_ID& aCad
}
CADSTAR_SCH_ARCHIVE_LOADER::TEXTCODE CADSTAR_SCH_ARCHIVE_LOADER::getTextCode(
const TEXTCODE_ID& aCadstarTextCodeID )
CADSTAR_SCH_ARCHIVE_LOADER::TEXTCODE
CADSTAR_SCH_ARCHIVE_LOADER::getTextCode( const TEXTCODE_ID& aCadstarTextCodeID )
{
wxCHECK( Assignments.Codedefs.TextCodes.find( aCadstarTextCodeID )
!= Assignments.Codedefs.TextCodes.end(),
@ -2438,8 +2439,8 @@ wxString CADSTAR_SCH_ARCHIVE_LOADER::getAttributeName( const ATTRIBUTE_ID& aCads
}
CADSTAR_SCH_ARCHIVE_LOADER::PART CADSTAR_SCH_ARCHIVE_LOADER::getPart(
const PART_ID& aCadstarPartID )
CADSTAR_SCH_ARCHIVE_LOADER::PART
CADSTAR_SCH_ARCHIVE_LOADER::getPart( const PART_ID& aCadstarPartID )
{
wxCHECK( Parts.PartDefinitions.find( aCadstarPartID ) != Parts.PartDefinitions.end(), PART() );
@ -2447,8 +2448,8 @@ CADSTAR_SCH_ARCHIVE_LOADER::PART CADSTAR_SCH_ARCHIVE_LOADER::getPart(
}
CADSTAR_SCH_ARCHIVE_LOADER::ROUTECODE CADSTAR_SCH_ARCHIVE_LOADER::getRouteCode(
const ROUTECODE_ID& aCadstarRouteCodeID )
CADSTAR_SCH_ARCHIVE_LOADER::ROUTECODE
CADSTAR_SCH_ARCHIVE_LOADER::getRouteCode( const ROUTECODE_ID& aCadstarRouteCodeID )
{
wxCHECK( Assignments.Codedefs.RouteCodes.find( aCadstarRouteCodeID )
!= Assignments.Codedefs.RouteCodes.end(),
@ -2458,8 +2459,9 @@ CADSTAR_SCH_ARCHIVE_LOADER::ROUTECODE CADSTAR_SCH_ARCHIVE_LOADER::getRouteCode(
}
CADSTAR_SCH_ARCHIVE_LOADER::PART::DEFINITION::PIN CADSTAR_SCH_ARCHIVE_LOADER::getPartDefinitionPin(
const PART& aCadstarPart, const GATE_ID& aGateID, const TERMINAL_ID& aTerminalID )
CADSTAR_SCH_ARCHIVE_LOADER::PART::DEFINITION::PIN
CADSTAR_SCH_ARCHIVE_LOADER::getPartDefinitionPin( const PART& aCadstarPart, const GATE_ID& aGateID,
const TERMINAL_ID& aTerminalID )
{
for( std::pair<PART_DEFINITION_PIN_ID, PART::DEFINITION::PIN> pinPair :
aCadstarPart.Definition.Pins )
@ -2635,48 +2637,48 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT
FixTextPositionNoAlignment( aText );
KI_FALLTHROUGH;
case ALIGNMENT::BOTTOMLEFT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case ALIGNMENT::BOTTOMCENTER:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ALIGNMENT::BOTTOMRIGHT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case ALIGNMENT::CENTERLEFT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case ALIGNMENT::CENTERCENTER:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ALIGNMENT::CENTERRIGHT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case ALIGNMENT::TOPLEFT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case ALIGNMENT::TOPCENTER:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ALIGNMENT::TOPRIGHT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
}
};
@ -2695,7 +2697,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT
{
// Spin style not used. All text justifications are permitted. However, only orientations
// of 0 deg or 90 deg are supported
double angleDeciDeg = NormalizeAnglePos( aKiCadTextItem->GetTextAngle() );
double angleDeciDeg = NormalizeAnglePos( aKiCadTextItem->GetTextAngle().AsTenthsOfADegree() );
int quadrant = KiROUND( angleDeciDeg / 900.0 );
quadrant %= 4;
@ -2725,7 +2727,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT
case SCH_TEXT_T:
{
// Note spin style in a SCH_TEXT results in a vertical alignment GR_TEXT_VJUSTIFY_BOTTOM
// Note spin style in a SCH_TEXT results in a vertical alignment GR_TEXT_V_ALIGN_BOTTOM
// so need to adjust the location of the text element based on Cadstar's original text
// alignment (anchor position).
setAlignment( aKiCadTextItem, textAlignment );
@ -3055,6 +3057,6 @@ double CADSTAR_SCH_ARCHIVE_LOADER::getPolarAngle( const wxPoint& aPoint )
double CADSTAR_SCH_ARCHIVE_LOADER::getPolarRadius( const wxPoint& aPoint )
{
return sqrt(
( (double) aPoint.x * (double) aPoint.x ) + ( (double) aPoint.y * (double) aPoint.y ) );
return sqrt( ( (double) aPoint.x * (double) aPoint.x )
+ ( (double) aPoint.y * (double) aPoint.y ) );
}

View File

@ -298,53 +298,53 @@ static void eagleToKicadAlignment( EDA_TEXT* aText, int aEagleAlignment, int aRe
switch( align )
{
case ETEXT::CENTER:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::CENTER_LEFT:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::CENTER_RIGHT:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::TOP_CENTER:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::TOP_LEFT:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::TOP_RIGHT:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::BOTTOM_CENTER:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
case ETEXT::BOTTOM_LEFT:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
case ETEXT::BOTTOM_RIGHT:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
default:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
}
}

View File

@ -614,10 +614,10 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta
{
switch( token )
{
case T_left: aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break;
case T_right: aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break;
case T_top: aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break;
case T_bottom: aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break;
case T_left: aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break;
case T_right: aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break;
case T_top: aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break;
case T_bottom: aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break;
case T_mirror: aText->SetMirrored( true ); break;
default: Expecting( "left, right, top, bottom, or mirror" );
}
@ -1329,8 +1329,8 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
pin->GetAlternates()[ alt.m_Name ] = alt;
NeedRIGHT();
}
break;
}
default:
Expecting( "at, name, number, length, or alternate" );
@ -3220,15 +3220,15 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
// Spin style is defined differently for graphical text (#SCH_TEXT) objects.
if( text->Type() == SCH_TEXT_T )
{
if( text->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT
&& text->GetTextAngle() == TEXT_ANGLE_VERT )
if( text->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT
&& text->GetTextAngle().IsVertical() )
{
// The vertically aligned text angle is always 90 (labels use 270 for the
// down direction) combined with the text justification flags.
text->SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM );
}
else if( text->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT
&& text->GetTextAngle() == TEXT_ANGLE_HORIZ )
else if( text->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT
&& text->GetTextAngle().IsHorizontal() )
{
// The horizontally aligned text angle is always 0 (labels use 180 for the
// left direction) combined with the text justification flags.

View File

@ -1148,7 +1148,7 @@ void SCH_SEXPR_PLUGIN::saveField( SCH_FIELD* aField, int aNestLevel )
aField->GetId(),
FormatInternalUnits( aField->GetPosition().x ).c_str(),
FormatInternalUnits( aField->GetPosition().y ).c_str(),
FormatAngle( aField->GetTextAngleDegrees() * 10.0 ).c_str() );
FormatAngle( aField->GetTextAngle().AsTenthsOfADegree() ).c_str() );
if( !aField->IsDefaultFormatting()
|| ( aField->GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) ) )
@ -1455,7 +1455,7 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel )
m_out->Print( aNestLevel + 1, "(at %s %s %s)",
FormatInternalUnits( aText->GetPosition().x ).c_str(),
FormatInternalUnits( aText->GetPosition().y ).c_str(),
FormatAngle( aText->GetTextAngle() ).c_str() );
FormatAngle( aText->GetTextAngle().AsTenthsOfADegree() ).c_str() );
}
if( aText->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
@ -2042,7 +2042,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFor
aField->GetId(),
FormatInternalUnits( aField->GetPosition().x ).c_str(),
FormatInternalUnits( aField->GetPosition().y ).c_str(),
static_cast<double>( aField->GetTextAngle() ) / 10.0 );
aField->GetTextAngle().AsDegrees() );
aField->Format( &aFormatter, aNestLevel, 0 );
aFormatter.Print( aNestLevel, ")\n" );
@ -2101,7 +2101,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveText( LIB_TEXT* aText, OUTPUTFORMATTER& aFormat
aFormatter.Quotew( aText->GetText() ).c_str(),
FormatInternalUnits( aText->GetPosition().x ).c_str(),
FormatInternalUnits( aText->GetPosition().y ).c_str(),
aText->GetTextAngle() );
(double) aText->GetTextAngle().AsTenthsOfADegree() );
aText->Format( &aFormatter, aNestLevel, 0 );
aFormatter.Print( aNestLevel, ")\n" );
}

View File

@ -1740,9 +1740,9 @@ SCH_SYMBOL* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader )
parseQuotedString( name, aReader, line, &line, true );
if( hjustify == 'L' )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
else if( hjustify == 'R' )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( hjustify != 'C' )
SCH_PARSE_ERROR( "symbol field text horizontal justification must be "
"L, R, or C", aReader, line );
@ -1750,9 +1750,9 @@ SCH_SYMBOL* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader )
// We are guaranteed to have a least one character here for older file formats
// otherwise an exception would have been raised..
if( textAttrs[0] == 'T' )
field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
field.SetVertJustify( GR_TEXT_V_ALIGN_TOP );
else if( textAttrs[0] == 'B' )
field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
field.SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else if( textAttrs[0] != 'C' )
SCH_PARSE_ERROR( "symbol field text vertical justification must be "
"B, T, or C", aReader, line );
@ -1784,9 +1784,9 @@ SCH_SYMBOL* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader )
field.SetTextSize( wxSize( size, size ) );
if( orientation == 'H' )
field.SetTextAngle( TEXT_ANGLE_HORIZ );
field.SetTextAngle( EDA_ANGLE::HORIZONTAL );
else if( orientation == 'V' )
field.SetTextAngle( TEXT_ANGLE_VERT );
field.SetTextAngle( EDA_ANGLE::VERTICAL );
else
SCH_PARSE_ERROR( "symbol field orientation must be H or V", aReader, line );
@ -2155,22 +2155,22 @@ void SCH_LEGACY_PLUGIN::saveField( SCH_FIELD* aField )
{
char hjustify = 'C';
if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
hjustify = 'L';
else if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
else if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
hjustify = 'R';
char vjustify = 'C';
if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
vjustify = 'B';
else if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
else if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
vjustify = 'T';
m_out->Print( 0, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
aField->GetId(),
EscapedUTF8( aField->GetText() ).c_str(), // wraps in quotes too
aField->GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V',
aField->GetTextAngle().IsHorizontal() ? 'H' : 'V',
Iu2Mils( aField->GetLibPosition().x ),
Iu2Mils( aField->GetLibPosition().y ),
Iu2Mils( aField->GetTextWidth() ),
@ -3093,9 +3093,9 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSymbol,
char textOrient = parseChar( aReader, line, &line );
if( textOrient == 'H' )
field->SetTextAngle( TEXT_ANGLE_HORIZ );
field->SetTextAngle( EDA_ANGLE::HORIZONTAL );
else if( textOrient == 'V' )
field->SetTextAngle( TEXT_ANGLE_VERT );
field->SetTextAngle( EDA_ANGLE::VERTICAL );
else
SCH_PARSE_ERROR( "invalid field text orientation parameter", aReader, line );
@ -3117,11 +3117,11 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSymbol,
char textHJustify = parseChar( aReader, line, &line );
if( textHJustify == 'C' )
field->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
field->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
else if( textHJustify == 'L' )
field->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
else if( textHJustify == 'R' )
field->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
field->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else
SCH_PARSE_ERROR( "invalid field text horizontal justification", aReader, line );
@ -3136,9 +3136,9 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSymbol,
switch( (wxChar) attributes[0] )
{
case 'C': field->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break;
case 'B': field->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break;
case 'T': field->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break;
case 'C': field->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break;
case 'B': field->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break;
case 'T': field->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break;
default: SCH_PARSE_ERROR( "invalid field text vertical justification", aReader, line );
}
@ -3446,18 +3446,18 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr<LIB_SYMBOL>& aSymbo
{
switch( parseChar( aReader, line, &line ) )
{
case 'L': text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break;
case 'C': text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); break;
case 'R': text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break;
case 'L': text->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break;
case 'C': text->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break;
case 'R': text->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break;
default: SCH_PARSE_ERROR( "invalid horizontal text justication; expected L, C, or R",
aReader, line );
}
switch( parseChar( aReader, line, &line ) )
{
case 'T': text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break;
case 'C': text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break;
case 'B': text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break;
case 'T': text->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break;
case 'C': text->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break;
case 'B': text->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break;
default: SCH_PARSE_ERROR( "invalid vertical text justication; expected T, C, or B",
aReader, line );
}
@ -4058,16 +4058,16 @@ void SCH_LEGACY_PLUGIN_CACHE::saveField( const LIB_FIELD* aField, OUTPUTFORMATTE
hjustify = 'C';
if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
hjustify = 'L';
else if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
else if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
hjustify = 'R';
vjustify = 'C';
if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
vjustify = 'B';
else if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
else if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
vjustify = 'T';
aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c",
@ -4076,7 +4076,7 @@ void SCH_LEGACY_PLUGIN_CACHE::saveField( const LIB_FIELD* aField, OUTPUTFORMATTE
Iu2Mils( aField->GetTextPos().x ),
Iu2Mils( aField->GetTextPos().y ),
Iu2Mils( aField->GetTextWidth() ),
aField->GetTextAngle() == 0 ? 'H' : 'V',
aField->GetTextAngle().IsHorizontal() ? 'H' : 'V',
aField->IsVisible() ? 'V' : 'I',
hjustify, vjustify,
aField->IsItalic() ? 'I' : 'N',
@ -4207,25 +4207,30 @@ void SCH_LEGACY_PLUGIN_CACHE::saveText( const LIB_TEXT* aText, OUTPUTFORMATTER&
text = wxT( "\"" ) + text + wxT( "\"" );
}
aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", aText->GetTextAngle(),
Iu2Mils( aText->GetTextPos().x ), Iu2Mils( aText->GetTextPos().y ),
Iu2Mils( aText->GetTextWidth() ), !aText->IsVisible(),
aText->GetUnit(), aText->GetConvert(), TO_UTF8( text ) );
aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s",
(double) aText->GetTextAngle().AsTenthsOfADegree(),
Iu2Mils( aText->GetTextPos().x ),
Iu2Mils( aText->GetTextPos().y ),
Iu2Mils( aText->GetTextWidth() ),
!aText->IsVisible(),
aText->GetUnit(),
aText->GetConvert(),
TO_UTF8( text ) );
aFormatter.Print( 0, " %s %d", aText->IsItalic() ? "Italic" : "Normal", aText->IsBold() );
char hjustify = 'C';
if( aText->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
hjustify = 'L';
else if( aText->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
else if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
hjustify = 'R';
char vjustify = 'C';
if( aText->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
if( aText->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
vjustify = 'B';
else if( aText->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
else if( aText->GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
vjustify = 'T';
aFormatter.Print( 0, " %c %c\n", hjustify, vjustify );

View File

@ -558,16 +558,16 @@ void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
if( IsVerticalOrientation() )
{
m_fields[ SHEETNAME ].SetTextPos( m_pos + wxPoint( -margin, m_size.y ) );
m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
m_fields[ SHEETNAME ].SetVertJustify(GR_TEXT_VJUSTIFY_BOTTOM );
m_fields[ SHEETNAME ].SetTextAngle( TEXT_ANGLE_VERT );
m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
m_fields[ SHEETNAME ].SetTextAngle( EDA_ANGLE::VERTICAL );
}
else
{
m_fields[ SHEETNAME ].SetTextPos( m_pos + wxPoint( 0, -margin ) );
m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
m_fields[ SHEETNAME ].SetVertJustify(GR_TEXT_VJUSTIFY_BOTTOM );
m_fields[ SHEETNAME ].SetTextAngle( TEXT_ANGLE_HORIZ );
m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
m_fields[ SHEETNAME ].SetTextAngle( EDA_ANGLE::HORIZONTAL );
}
textSize = m_fields[ SHEETFILENAME ].GetTextSize();
@ -576,16 +576,16 @@ void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
if( IsVerticalOrientation() )
{
m_fields[ SHEETFILENAME ].SetTextPos( m_pos + wxPoint( m_size.x + margin, m_size.y ) );
m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
m_fields[ SHEETFILENAME ].SetVertJustify(GR_TEXT_VJUSTIFY_TOP );
m_fields[ SHEETFILENAME ].SetTextAngle( TEXT_ANGLE_VERT );
m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP );
m_fields[ SHEETFILENAME ].SetTextAngle( EDA_ANGLE::VERTICAL );
}
else
{
m_fields[ SHEETFILENAME ].SetTextPos( m_pos + wxPoint( 0, m_size.y + margin ) );
m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
m_fields[ SHEETFILENAME ].SetVertJustify(GR_TEXT_VJUSTIFY_TOP );
m_fields[ SHEETFILENAME ].SetTextAngle( TEXT_ANGLE_HORIZ );
m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP );
m_fields[ SHEETFILENAME ].SetTextAngle( EDA_ANGLE::HORIZONTAL );
}
m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO;

View File

@ -325,27 +325,27 @@ void SCH_TEXT::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle )
KI_FALLTHROUGH;
case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
SetTextAngle( TEXT_ANGLE_HORIZ );
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
SetTextAngle( EDA_ANGLE::HORIZONTAL );
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case LABEL_SPIN_STYLE::UP: // Vert Orientation UP
SetTextAngle( TEXT_ANGLE_VERT );
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
SetTextAngle( EDA_ANGLE::VERTICAL );
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation - Right justified
SetTextAngle( TEXT_ANGLE_HORIZ );
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
SetTextAngle( EDA_ANGLE::HORIZONTAL );
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
SetTextAngle( TEXT_ANGLE_VERT );
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
SetTextAngle( EDA_ANGLE::VERTICAL );
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
}
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
}
@ -357,7 +357,7 @@ void SCH_TEXT::SwapData( SCH_ITEM* aItem )
std::swap( m_spin_style, item->m_spin_style );
SwapText( *item );
SwapEffects( *item );
SwapAttributes( *item );
}
@ -417,13 +417,13 @@ const EDA_RECT SCH_TEXT::GetBoundingBox() const
{
EDA_RECT rect = GetTextBox();
if( GetTextAngle() != 0 ) // Rotate rect.
if( GetTextAngle() != EDA_ANGLE::ANGLE_0 ) // Rotate rect.
{
wxPoint pos = rect.GetOrigin();
wxPoint end = rect.GetEnd();
RotatePoint( &pos, GetTextPos(), GetTextAngle() );
RotatePoint( &end, GetTextPos(), GetTextAngle() );
RotatePoint( &pos, GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
RotatePoint( &end, GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
rect.SetOrigin( pos );
rect.SetEnd( end );
@ -750,37 +750,37 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise )
{
for( SCH_FIELD& field : m_fields )
{
if( field.GetTextAngle() == TEXT_ANGLE_VERT
&& field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
if( field.GetTextAngle().IsVertical()
&& field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
{
if( !aClockwise )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
field.SetTextAngle( TEXT_ANGLE_HORIZ );
field.SetTextAngle( EDA_ANGLE::HORIZONTAL );
}
else if( field.GetTextAngle() == TEXT_ANGLE_VERT
&& field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
else if( field.GetTextAngle().IsVertical()
&& field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
{
if( !aClockwise )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
field.SetTextAngle( TEXT_ANGLE_HORIZ );
field.SetTextAngle( EDA_ANGLE::HORIZONTAL );
}
else if( field.GetTextAngle() == TEXT_ANGLE_HORIZ
&& field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
else if( field.GetTextAngle().IsHorizontal()
&& field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
{
if( aClockwise )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
field.SetTextAngle( TEXT_ANGLE_VERT );
field.SetTextAngle( EDA_ANGLE::VERTICAL );
}
else if( field.GetTextAngle() == TEXT_ANGLE_HORIZ
&& field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
else if( field.GetTextAngle().IsHorizontal()
&& field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
{
if( aClockwise )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
field.SetTextAngle( TEXT_ANGLE_VERT );
field.SetTextAngle( EDA_ANGLE::VERTICAL );
}
wxPoint pos = field.GetTextPos();
@ -808,8 +808,8 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
{
default:
case LABEL_SPIN_STYLE::LEFT:
field.SetTextAngle( TEXT_ANGLE_HORIZ );
field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
field.SetTextAngle( EDA_ANGLE::HORIZONTAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 )
offset.x = - ( labelLen + margin );
@ -819,8 +819,8 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
break;
case LABEL_SPIN_STYLE::UP:
field.SetTextAngle( TEXT_ANGLE_VERT );
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field.SetTextAngle( EDA_ANGLE::VERTICAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 )
offset.y = - ( labelLen + margin );
@ -830,8 +830,8 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
break;
case LABEL_SPIN_STYLE::RIGHT:
field.SetTextAngle( TEXT_ANGLE_HORIZ );
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field.SetTextAngle( EDA_ANGLE::HORIZONTAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 )
offset.x = labelLen + margin;
@ -841,8 +841,8 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
break;
case LABEL_SPIN_STYLE::BOTTOM:
field.SetTextAngle( TEXT_ANGLE_VERT );
field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
field.SetTextAngle( EDA_ANGLE::VERTICAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 )
offset.y = labelLen + margin;
@ -1288,14 +1288,14 @@ const EDA_RECT SCH_LABEL::GetBodyBoundingBox() const
rect.Offset( 0, -GetTextOffset() );
if( GetTextAngle() != 0.0 )
if( GetTextAngle() != EDA_ANGLE::ANGLE_0 )
{
// Rotate rect
wxPoint pos = rect.GetOrigin();
wxPoint end = rect.GetEnd();
RotatePoint( &pos, GetTextPos(), GetTextAngle() );
RotatePoint( &end, GetTextPos(), GetTextAngle() );
RotatePoint( &pos, GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
RotatePoint( &end, GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
rect.SetOrigin( pos );
rect.SetEnd( end );
@ -1335,7 +1335,7 @@ SCH_NETCLASS_FLAG::SCH_NETCLASS_FLAG( const wxPoint& pos ) :
m_fields[0].SetLayer( LAYER_NETCLASS_REFS );
m_fields[0].SetVisible( true );
m_fields[0].SetItalic( true );
m_fields[0].SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
m_fields[0].SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
}
@ -1436,27 +1436,27 @@ void SCH_NETCLASS_FLAG::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
{
default:
case LABEL_SPIN_STYLE::LEFT:
field.SetTextAngle( TEXT_ANGLE_HORIZ );
field.SetTextAngle( EDA_ANGLE::HORIZONTAL );
offset = { symbolWidth + margin, origin };
break;
case LABEL_SPIN_STYLE::UP:
field.SetTextAngle( TEXT_ANGLE_VERT );
field.SetTextAngle( EDA_ANGLE::VERTICAL );
offset = { -origin, -( symbolWidth + margin ) };
break;
case LABEL_SPIN_STYLE::RIGHT:
field.SetTextAngle( TEXT_ANGLE_HORIZ );
field.SetTextAngle( EDA_ANGLE::HORIZONTAL );
offset = { symbolWidth + margin, -origin };
break;
case LABEL_SPIN_STYLE::BOTTOM:
field.SetTextAngle( TEXT_ANGLE_VERT );
field.SetTextAngle( EDA_ANGLE::VERTICAL );
offset = { origin, -( symbolWidth + margin ) };
break;
}
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
field.SetTextPos( GetPosition() + offset );
origin -= field.GetTextHeight() + margin;
@ -1479,13 +1479,13 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
m_shape = LABEL_FLAG_SHAPE::L_BIDI;
m_isDangling = true;
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
m_fields.emplace_back( SCH_FIELD( { 0, 0 }, 0, this, _( "Sheet References" ) ) );
m_fields[0].SetText( wxT( "${INTERSHEET_REFS}" ) );
m_fields[0].SetVisible( true );
m_fields[0].SetLayer( LAYER_INTERSHEET_REFS );
m_fields[0].SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
m_fields[0].SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
}
@ -1530,7 +1530,7 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSetting
void SCH_GLOBALLABEL::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle )
{
SCH_TEXT::SetLabelSpinStyle( aSpinStyle );
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
}
@ -1540,13 +1540,13 @@ void SCH_GLOBALLABEL::MirrorSpinStyle( bool aLeftRight )
for( SCH_FIELD& field : m_fields )
{
if( ( aLeftRight && field.GetTextAngle() == TEXT_ANGLE_HORIZ )
|| ( !aLeftRight && field.GetTextAngle() == TEXT_ANGLE_VERT ) )
if( ( aLeftRight && field.GetTextAngle().IsHorizontal() )
|| ( !aLeftRight && field.GetTextAngle().IsVertical() ) )
{
if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
if( field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
}
wxPoint pos = field.GetTextPos();
@ -1569,10 +1569,10 @@ void SCH_GLOBALLABEL::MirrorHorizontally( int aCenter )
for( SCH_FIELD& field : m_fields )
{
if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
if( field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
wxPoint pos = field.GetTextPos();
wxPoint delta = old_pos - pos;
@ -1755,7 +1755,7 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T
void SCH_HIERLABEL::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle )
{
SCH_TEXT::SetLabelSpinStyle( aSpinStyle );
SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
}

View File

@ -1320,7 +1320,7 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol )
libField.SetName( field.GetName( false ) );
libField.SetText( field.GetText() );
libField.SetEffects( field );
libField.SetAttributes( field );
libField.SetPosition( wxPoint( pos.x, -pos.y ) );
fullSetOfFields.emplace_back( std::move( libField ) );

View File

@ -537,10 +537,10 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
{
SCH_FIELD* field = static_cast<SCH_FIELD*>( head );
if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
field->SetTextAngle( TEXT_ANGLE_VERT );
if( field->GetTextAngle().IsHorizontal() )
field->SetTextAngle( EDA_ANGLE::VERTICAL );
else
field->SetTextAngle( TEXT_ANGLE_HORIZ );
field->SetTextAngle( EDA_ANGLE::HORIZONTAL );
// Now that we're moving a field, they're no longer autoplaced.
static_cast<SCH_ITEM*>( head->GetParent() )->ClearFieldsAutoplaced();
@ -643,10 +643,10 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
field->Rotate( rotPoint );
if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
field->SetTextAngle( TEXT_ANGLE_VERT );
if( field->GetTextAngle().IsHorizontal() )
field->SetTextAngle( EDA_ANGLE::VERTICAL );
else
field->SetTextAngle( TEXT_ANGLE_HORIZ );
field->SetTextAngle( EDA_ANGLE::HORIZONTAL );
// Now that we're moving a field, they're no longer autoplaced.
static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
@ -757,12 +757,12 @@ int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
if( vertical )
field->SetVertJustify( (EDA_TEXT_VJUSTIFY_T)-field->GetVertJustify() );
field->SetVertJustify( TO_VJUSTIFY( -field->GetVertJustify() ) );
else
field->SetHorizJustify( (EDA_TEXT_HJUSTIFY_T)-field->GetHorizJustify() );
field->SetHorizJustify( TO_HJUSTIFY( -field->GetHorizJustify() ) );
// Now that we're re-justifying a field, they're no longer autoplaced.
static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
break;
}

View File

@ -26,7 +26,6 @@
#include <symbol_edit_frame.h>
#include <tools/symbol_editor_drawing_tools.h>
#include <tools/symbol_editor_pin_tool.h>
#include <bitmaps.h>
#include <lib_text.h>
#include <dialogs/dialog_lib_text_properties.h>
#include <lib_shape.h>
@ -40,7 +39,7 @@ static void* g_lastPinWeakPtr;
SYMBOL_EDITOR_DRAWING_TOOLS::SYMBOL_EDITOR_DRAWING_TOOLS() :
EE_TOOL_BASE<SYMBOL_EDIT_FRAME>( "eeschema.SymbolDrawing" ),
m_lastTextAngle( 0.0 ),
m_lastTextAngle( EDA_ANGLE::HORIZONTAL ),
m_lastFillStyle( FILL_T::NO_FILL ),
m_drawSpecificConvert( true ),
m_drawSpecificUnit( false )

View File

@ -52,8 +52,8 @@ public:
int RepeatDrawItem( const TOOL_EVENT& aEvent );
void SetLastTextAngle( double aAngle ) { m_lastTextAngle = aAngle; }
double GetLastTextAngle() const { return m_lastTextAngle; }
void SetLastTextAngle( const EDA_ANGLE& aAngle ) { m_lastTextAngle = aAngle; }
EDA_ANGLE GetLastTextAngle() const { return m_lastTextAngle; }
void SetDrawSpecificConvert( bool aSpecific ) { m_drawSpecificConvert = aSpecific; }
bool GetDrawSpecificConvert() const { return m_drawSpecificConvert; }
@ -65,7 +65,7 @@ private:
void setTransitions() override;
private:
double m_lastTextAngle;
EDA_ANGLE m_lastTextAngle;
FILL_T m_lastFillStyle;
bool m_drawSpecificConvert;
bool m_drawSpecificUnit;

View File

@ -105,7 +105,7 @@ bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, wxPoint& aPos, double& aOr
else
size = std::min( m_Size.x, m_Size.y );
aOrientation = TEXT_ANGLE_HORIZ;
aOrientation = 0;
if( m_Flashed )
{

View File

@ -225,8 +225,8 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
m_gal->SetFontUnderlined( false );
m_gal->SetTextMirrored( false );
m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->BitmapText( codeText, textPosition, orient );
return;

View File

@ -335,8 +335,8 @@ public:
wxString m_TextBase; // The basic text, with format symbols
wxString m_FullText; // The expanded text, shown on screen
double m_Orient; // Orientation in degrees
EDA_TEXT_HJUSTIFY_T m_Hjustify;
EDA_TEXT_VJUSTIFY_T m_Vjustify;
GR_TEXT_H_ALIGN_T m_Hjustify;
GR_TEXT_V_ALIGN_T m_Vjustify;
bool m_Italic;
bool m_Bold;
DSIZE m_TextSize;

264
include/eda_angle.h Normal file
View File

@ -0,0 +1,264 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef EDA_ANGLE_H
#define EDA_ANGLE_H
#include <cassert>
#include <cmath>
class EDA_ANGLE
{
public:
enum ANGLE_TYPE
{
TENTHS_OF_A_DEGREE = 1,
DEGREES = 10,
RADIANS ///< enum value does not matter
};
// Angles can be created in degrees, 1/10ths of a degree, and radians,
// and read as any of the angle types
//
// Angle type must be explicitly specified at creation, because
// there is no other way of knowing what an int or a double represents
EDA_ANGLE( int aValue, ANGLE_TYPE aAngleType ) :
m_initial_type( aAngleType )
{
switch( aAngleType )
{
case RADIANS:
m_radians = aValue;
m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS );
break;
default:
m_value = aValue * aAngleType;
}
}
EDA_ANGLE( double aValue, ANGLE_TYPE aAngleType ) :
m_initial_type( aAngleType )
{
switch( aAngleType )
{
case RADIANS:
m_radians = aValue;
m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS );
break;
default:
m_value = int( aValue * aAngleType );
}
}
EDA_ANGLE() :
m_value( 0 ),
m_radians( 0.0 ),
m_initial_type( EDA_ANGLE::RADIANS )
{}
inline double AsDegrees() const { return m_value / (double) EDA_ANGLE::DEGREES; }
inline int AsTenthsOfADegree() const { return m_value; }
inline double AsRadians() const
{
if( m_initial_type == EDA_ANGLE::RADIANS )
{
// if this was initialized with radians, return exact initial value
return m_radians;
}
else
{
// otherwise compute from value stored as 1/10ths of a degree
return m_value * TENTHS_OF_A_DEGREE_TO_RADIANS;
}
}
inline double AsAngleType( ANGLE_TYPE aAngleType ) const
{
switch( aAngleType )
{
case TENTHS_OF_A_DEGREE: return AsTenthsOfADegree();
case DEGREES: return AsDegrees();
case RADIANS: return AsRadians();
default: assert( 1 == 0 );
}
}
static constexpr double TENTHS_OF_A_DEGREE_TO_RADIANS = M_PI / 1800;
/**
* @return true if angle is one of the four cardinal directions (0/90/180/270 degrees),
* otherwise false
*/
bool IsCardinal() const
{
return AsTenthsOfADegree() % 900 == 0;
}
bool IsZero() const
{
return AsTenthsOfADegree() == 0;
}
bool IsHorizontal() const
{
return AsTenthsOfADegree() == 0 || AsTenthsOfADegree() == 1800;
}
bool IsVertical() const
{
return AsTenthsOfADegree() == 900 || AsTenthsOfADegree() == 2700;
}
EDA_ANGLE Add( const EDA_ANGLE& aAngle ) const
{
ANGLE_TYPE initialType = GetInitialAngleType();
// if both were given in radians, addition is exact
if( initialType == EDA_ANGLE::RADIANS
&& aAngle.GetInitialAngleType() == EDA_ANGLE::RADIANS )
{
//double newAngle = normalize( AsRadians() + aAngle.AsRadians(), EDA_ANGLE::RADIANS );
double newAngle = AsRadians() + aAngle.AsRadians();
return EDA_ANGLE( newAngle, EDA_ANGLE::RADIANS );
}
// if both were not given in radians, addition is done using
// 1/10ths of a degree, then converted to original angle type
// of this angle
//int newAngle = normalize( AsTenthsOfADegree() + aAngle.AsTenthsOfADegree(),
//EDA_ANGLE::TENTHS_OF_A_DEGREE );
int newAngle = AsTenthsOfADegree() + aAngle.AsTenthsOfADegree();
switch( initialType )
{
case DEGREES:
return EDA_ANGLE( newAngle / EDA_ANGLE::DEGREES, EDA_ANGLE::DEGREES );
case RADIANS:
return EDA_ANGLE( newAngle / TENTHS_OF_A_DEGREE_TO_RADIANS, EDA_ANGLE::RADIANS );
default:
case TENTHS_OF_A_DEGREE:
return EDA_ANGLE( newAngle, EDA_ANGLE::TENTHS_OF_A_DEGREE );
}
}
EDA_ANGLE Invert() const
{
switch( GetInitialAngleType() )
{
case RADIANS:
return EDA_ANGLE( -m_radians, EDA_ANGLE::RADIANS );
default:
return EDA_ANGLE( -m_value / GetInitialAngleType(), GetInitialAngleType() );
}
}
EDA_ANGLE Subtract( const EDA_ANGLE& aAngle ) const { return Add( aAngle.Invert() ); }
inline ANGLE_TYPE GetInitialAngleType() const { return m_initial_type; }
double Sin() const { return sin( AsRadians() ); }
double Cos() const { return cos( AsRadians() ); }
double Tan() const { return tan( AsRadians() ); }
static EDA_ANGLE Arccos( double x ) { return EDA_ANGLE( acos( x ), EDA_ANGLE::RADIANS ); }
static EDA_ANGLE Arcsin( double x ) { return EDA_ANGLE( asin( x ), EDA_ANGLE::RADIANS ); }
static EDA_ANGLE Arctan( double x ) { return EDA_ANGLE( atan( x ), EDA_ANGLE::RADIANS ); }
static EDA_ANGLE Arctan2( double y, double x )
{
return EDA_ANGLE( atan2( y, x ), EDA_ANGLE::RADIANS );
}
inline EDA_ANGLE Normalize()
{
normalize( false );
return *this;
}
inline EDA_ANGLE Normalize720()
{
normalize( true );
return *this;
}
EDA_ANGLE KeepUpright() const;
private:
// value is always stored in 1/10ths of a degree
int m_value;
double m_radians; //< only used with as-radians constructor
ANGLE_TYPE m_initial_type;
void normalize( bool n720 = false );
int normalize( int aValue, ANGLE_TYPE aAngleType, bool n720 = false ) const;
double normalize( double aValue, ANGLE_TYPE aAngleType, bool n720 = false ) const;
static constexpr int TENTHS_OF_A_DEGREE_FULL_CIRCLE = 3600;
static constexpr int DEGREES_FULL_CIRCLE = 360;
static constexpr double RADIANS_FULL_CIRCLE = 2 * M_PI;
static EDA_ANGLE m_angle0;
static EDA_ANGLE m_angle90;
static EDA_ANGLE m_angle180;
static EDA_ANGLE m_angle270;
static EDA_ANGLE m_angle360;
public:
static constexpr EDA_ANGLE& HORIZONTAL = m_angle0;
static constexpr EDA_ANGLE& VERTICAL = m_angle90;
static constexpr EDA_ANGLE& FULL_CIRCLE = m_angle360;
static constexpr EDA_ANGLE& ANGLE_0 = m_angle0;
static constexpr EDA_ANGLE& ANGLE_90 = m_angle90;
static constexpr EDA_ANGLE& ANGLE_180 = m_angle180;
static constexpr EDA_ANGLE& ANGLE_270 = m_angle270;
};
inline EDA_ANGLE operator-( const EDA_ANGLE& aAngle )
{
return aAngle.Invert();
}
inline bool operator==( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB )
{
return aAngleA.AsTenthsOfADegree() == aAngleB.AsTenthsOfADegree();
}
inline bool operator!=( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB )
{
return aAngleA.AsTenthsOfADegree() != aAngleB.AsTenthsOfADegree();
}
#endif // EDA_ANGLE_H

View File

@ -30,6 +30,7 @@
#include <outline_mode.h>
#include <eda_rect.h>
#include <font/text_attributes.h>
class OUTPUTFORMATTER;
class SHAPE_COMPOUND;
@ -66,33 +67,12 @@ namespace KIGFX
using KIGFX::RENDER_SETTINGS;
using KIGFX::COLOR4D;
/// Frequent text rotations, used with {Set,Get}TextAngle(),
/// in 0.1 degrees for now, hoping to migrate to degrees eventually.
#define TEXT_ANGLE_HORIZ 0
#define TEXT_ANGLE_VERT 900
// part of the kicad_plugin.h family of defines.
// See kicad_plugin.h for the choice of the value
// When set when calling EDA_TEXT::Format, disable writing the "hide" keyword in save file
#define CTL_OMIT_HIDE (1 << 6)
// Graphic Text justify:
// Values -1,0,1 are used in computations, do not change them
enum EDA_TEXT_HJUSTIFY_T {
GR_TEXT_HJUSTIFY_LEFT = -1,
GR_TEXT_HJUSTIFY_CENTER = 0,
GR_TEXT_HJUSTIFY_RIGHT = 1
};
enum EDA_TEXT_VJUSTIFY_T {
GR_TEXT_VJUSTIFY_TOP = -1,
GR_TEXT_VJUSTIFY_CENTER = 0,
GR_TEXT_VJUSTIFY_BOTTOM = 1
};
/**
* This is the "default-of-the-default" hardcoded text size; individual
* application define their own default policy starting with this
@ -102,35 +82,6 @@ enum EDA_TEXT_VJUSTIFY_T {
#define DIM_ANCRE_TEXTE 2 // Anchor size for text
/**
* A container for text effects.
*
* These fields are bundled so they can be easily copied together as a lot. The privacy
* policy is established by client (incorporating) code.
*/
struct TEXT_EFFECTS
{
TEXT_EFFECTS( int aSetOfBits = 0 ) :
bits( aSetOfBits ),
hjustify( GR_TEXT_HJUSTIFY_CENTER ),
vjustify( GR_TEXT_VJUSTIFY_CENTER ),
penwidth( 0 ),
angle( 0.0 )
{}
int bits; ///< any set of booleans a client uses.
signed char hjustify; ///< horizontal justification
signed char vjustify; ///< vertical justification
wxSize size;
int penwidth;
double angle; ///< now: 0.1 degrees; future: degrees
wxPoint pos;
void Bit( int aBit, bool aValue ) { aValue ? bits |= (1<<aBit) : bits &= ~(1<<aBit); }
bool Bit( int aBit ) const { return bits & (1<<aBit); }
};
/**
* A mix-in class (via multiple inheritance) that handles texts such as labels, parts,
* components, or footprints. Because it's a mix-in class, care is used to provide
@ -177,66 +128,63 @@ public:
* The TextThickness is that set by the user. The EffectiveTextPenWidth also factors
* in bold text and thickness clamping.
*/
void SetTextThickness( int aWidth ) { m_e.penwidth = aWidth; };
int GetTextThickness() const { return m_e.penwidth; };
void SetTextThickness( int aWidth ) { m_attributes.m_StrokeWidth = aWidth; };
int GetTextThickness() const { return m_attributes.m_StrokeWidth; };
/**
* The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
*/
int GetEffectiveTextPenWidth( int aDefaultWidth = 0 ) const;
virtual void SetTextAngle( double aAngle )
virtual void SetTextAngle( double aAngleInTenthsOfADegree )
{
// Higher level classes may be more restrictive than this by overloading
// SetTextAngle() or merely calling EDA_TEXT::SetTextAngle() after clamping
// aAngle before calling this lowest inline accessor.
m_e.angle = aAngle;
m_attributes.m_Angle = EDA_ANGLE( aAngleInTenthsOfADegree, EDA_ANGLE::TENTHS_OF_A_DEGREE );
}
double GetTextAngle() const { return m_e.angle; }
double GetTextAngleDegrees() const { return GetTextAngle() / 10.0; }
double GetTextAngleRadians() const { return GetTextAngle() * M_PI/1800; }
void SetTextAngle( const EDA_ANGLE& aAngle )
{
m_attributes.m_Angle = aAngle;
}
void SetItalic( bool isItalic ) { m_e.Bit( TE_ITALIC, isItalic ); }
bool IsItalic() const { return m_e.Bit( TE_ITALIC ); }
const EDA_ANGLE& GetTextAngle() const { return m_attributes.m_Angle; }
void SetBold( bool aBold ) { m_e.Bit( TE_BOLD, aBold); }
bool IsBold() const { return m_e.Bit( TE_BOLD ); }
void SetItalic( bool aItalic ) { m_attributes.m_Italic = aItalic; }
bool IsItalic() const { return m_attributes.m_Italic; }
virtual void SetVisible( bool aVisible ) { m_e.Bit( TE_VISIBLE, aVisible ); }
virtual bool IsVisible() const { return m_e.Bit( TE_VISIBLE ); }
void SetBold( bool aBold ) { m_attributes.m_Bold = aBold; }
bool IsBold() const { return m_attributes.m_Bold; }
void SetMirrored( bool isMirrored ) { m_e.Bit( TE_MIRROR, isMirrored ); }
bool IsMirrored() const { return m_e.Bit( TE_MIRROR ); }
virtual void SetVisible( bool aVisible ) { m_attributes.m_Visible = aVisible; }
virtual bool IsVisible() const { return m_attributes.m_Visible; }
void SetMirrored( bool isMirrored ) { m_attributes.m_Mirrored = isMirrored; }
bool IsMirrored() const { return m_attributes.m_Mirrored; }
/**
* @param aAllow true if ok to use multiline option, false if ok to use only single line
* text. (Single line is faster in calculations than multiline.)
*/
void SetMultilineAllowed( bool aAllow ) { m_e.Bit( TE_MULTILINE, aAllow ); }
bool IsMultilineAllowed() const { return m_e.Bit( TE_MULTILINE ); }
void SetMultilineAllowed( bool aAllow ) { m_attributes.m_Multiline = aAllow; }
bool IsMultilineAllowed() const { return m_attributes.m_Multiline; }
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const { return EDA_TEXT_HJUSTIFY_T( m_e.hjustify ); };
EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return EDA_TEXT_VJUSTIFY_T( m_e.vjustify ); };
GR_TEXT_H_ALIGN_T GetHorizJustify() const { return m_attributes.m_Halign; };
GR_TEXT_V_ALIGN_T GetVertJustify() const { return m_attributes.m_Valign; };
void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_e.hjustify = aType; };
void SetVertJustify( EDA_TEXT_VJUSTIFY_T aType ) { m_e.vjustify = aType; };
void SetHorizJustify( GR_TEXT_H_ALIGN_T aType ) { m_attributes.m_Halign = aType; };
void SetVertJustify( GR_TEXT_V_ALIGN_T aType ) { m_attributes.m_Valign = aType; };
/**
* Set the text effects from another instance.
*
* #TEXT_EFFECTS is not exposed in the public API, but includes everything except the actual
* text string itself.
* Set the text attributes from another instance.
*/
void SetEffects( const EDA_TEXT& aSrc );
void SetAttributes( const EDA_TEXT& aSrc );
/**
* Swap the text effects of the two involved instances.
*
* #TEXT_EFFECTS is not exposed in the public API, but includes everything except the actual
* text string itself.
* Swap the text attributes of the two involved instances.
*/
void SwapEffects( EDA_TEXT& aTradingPartner );
void SwapAttributes( EDA_TEXT& aTradingPartner );
void SwapText( EDA_TEXT& aTradingPartner );
@ -255,28 +203,29 @@ public:
bool IsDefaultFormatting() const;
void SetTextSize( const wxSize& aNewSize ) { m_e.size = aNewSize; }
const wxSize& GetTextSize() const { return m_e.size; }
void SetTextSize( const wxSize& aNewSize ) { m_attributes.m_Size = aNewSize; }
wxSize GetTextSize() const { return wxSize( m_attributes.m_Size.x,
m_attributes.m_Size.y ); }
void SetTextWidth( int aWidth ) { m_e.size.x = aWidth; }
int GetTextWidth() const { return m_e.size.x; }
void SetTextWidth( int aWidth ) { m_attributes.m_Size.x = aWidth; }
int GetTextWidth() const { return m_attributes.m_Size.x; }
void SetTextHeight( int aHeight ) { m_e.size.y = aHeight; }
int GetTextHeight() const { return m_e.size.y; }
void SetTextHeight( int aHeight ) { m_attributes.m_Size.y = aHeight; }
int GetTextHeight() const { return m_attributes.m_Size.y; }
void SetTextPos( const wxPoint& aPoint ) { m_e.pos = aPoint; }
const wxPoint& GetTextPos() const { return m_e.pos; }
void SetTextPos( const wxPoint& aPoint ) { m_pos = aPoint; }
const wxPoint& GetTextPos() const { return m_pos; }
void SetTextX( int aX ) { m_e.pos.x = aX; }
void SetTextY( int aY ) { m_e.pos.y = aY; }
void SetTextX( int aX ) { m_pos.x = aX; }
void SetTextY( int aY ) { m_pos.y = aY; }
void Offset( const wxPoint& aOffset ) { m_e.pos += aOffset; }
void Offset( const wxPoint& aOffset ) { m_pos += aOffset; }
void Empty() { m_text.Empty(); }
static EDA_TEXT_HJUSTIFY_T MapHorizJustify( int aHorizJustify );
static GR_TEXT_H_ALIGN_T MapHorizJustify( int aHorizJustify );
static EDA_TEXT_VJUSTIFY_T MapVertJustify( int aVertJustify );
static GR_TEXT_V_ALIGN_T MapVertJustify( int aVertJustify );
/**
* Print this text object to the device context \a aDC.
@ -385,10 +334,10 @@ public:
*/
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
virtual double GetDrawRotation() const { return GetTextAngle(); }
virtual EDA_ANGLE GetDrawRotation() const { return GetTextAngle(); }
virtual wxPoint GetDrawPos() const { return GetTextPos(); }
virtual EDA_TEXT_HJUSTIFY_T GetDrawHorizJustify() const { return GetHorizJustify(); };
virtual EDA_TEXT_VJUSTIFY_T GetDrawVertJustify() const { return GetVertJustify(); };
virtual GR_TEXT_H_ALIGN_T GetDrawHorizJustify() const { return GetHorizJustify(); };
virtual GR_TEXT_V_ALIGN_T GetDrawVertJustify() const { return GetVertJustify(); };
int Compare( const EDA_TEXT* aOther ) const;
@ -396,7 +345,7 @@ private:
void cacheShownText();
/**
* Print each line of this EDA_TEXT..
* Print each line of this EDA_TEXT.
*
* @param aOffset draw offset (usually (0,0)).
* @param aColor text color.
@ -412,15 +361,8 @@ private:
wxString m_shown_text; // Cache of unescaped text for efficient access
bool m_shown_text_has_text_var_refs;
TEXT_EFFECTS m_e; // Private bitflags for text styling. API above
// provides accessor funcs.
enum TE_FLAGS {
TE_MIRROR,
TE_ITALIC,
TE_BOLD,
TE_MULTILINE,
TE_VISIBLE,
};
TEXT_ATTRIBUTES m_attributes;
wxPoint m_pos;
};

View File

@ -0,0 +1,86 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef TEXT_ATTRIBUTES_H
#define TEXT_ATTRIBUTES_H
#include <iostream>
#include <wx/log.h>
#include <cmath>
#include <math/vector2d.h>
#include <eda_angle.h>
class EDA_TEXT;
namespace KIFONT
{
class FONT;
};
// Graphic Text alignments:
//
// NB: values -1,0,1 are used in computations, do not change them
//
enum GR_TEXT_H_ALIGN_T
{
GR_TEXT_H_ALIGN_LEFT = -1,
GR_TEXT_H_ALIGN_CENTER = 0,
GR_TEXT_H_ALIGN_RIGHT = 1
};
enum GR_TEXT_V_ALIGN_T
{
GR_TEXT_V_ALIGN_TOP = -1,
GR_TEXT_V_ALIGN_CENTER = 0,
GR_TEXT_V_ALIGN_BOTTOM = 1
};
#define TO_HJUSTIFY( x ) static_cast<GR_TEXT_H_ALIGN_T>( x )
#define TO_VJUSTIFY( x ) static_cast<GR_TEXT_V_ALIGN_T>( x )
class TEXT_ATTRIBUTES
{
public:
KIFONT::FONT* m_Font = nullptr;
GR_TEXT_H_ALIGN_T m_Halign = GR_TEXT_H_ALIGN_CENTER;
GR_TEXT_V_ALIGN_T m_Valign = GR_TEXT_V_ALIGN_CENTER;
EDA_ANGLE m_Angle;
double m_LineSpacing = 1.0;
int m_StrokeWidth = 0;
bool m_Italic = false;
bool m_Bold = false;
bool m_Underlined = false;
bool m_Visible = true;
bool m_Mirrored = false;
bool m_Multiline = true;
VECTOR2D m_Size;
/**
* If true, keep rotation angle between -90...90 degrees for readability
*/
bool m_KeepUpright = false;
};
#endif //TEXT_ATTRIBUTES_H

View File

@ -447,7 +447,7 @@ public:
*
* @param aHorizontalJustify is the horizontal justify value.
*/
inline void SetHorizontalJustify( const EDA_TEXT_HJUSTIFY_T aHorizontalJustify )
inline void SetHorizontalJustify( const GR_TEXT_H_ALIGN_T aHorizontalJustify )
{
textProperties.m_horizontalJustify = aHorizontalJustify;
}
@ -455,7 +455,7 @@ public:
/**
* Return current text horizontal justification setting.
*/
inline EDA_TEXT_HJUSTIFY_T GetHorizontalJustify() const
inline GR_TEXT_H_ALIGN_T GetHorizontalJustify() const
{
return textProperties.m_horizontalJustify;
}
@ -465,7 +465,7 @@ public:
*
* @param aVerticalJustify is the vertical justify value.
*/
inline void SetVerticalJustify( const EDA_TEXT_VJUSTIFY_T aVerticalJustify )
inline void SetVerticalJustify( const GR_TEXT_V_ALIGN_T aVerticalJustify )
{
textProperties.m_verticalJustify = aVerticalJustify;
}
@ -473,7 +473,7 @@ public:
/**
* Returns current text vertical justification setting.
*/
inline EDA_TEXT_VJUSTIFY_T GetVerticalJustify() const
inline GR_TEXT_V_ALIGN_T GetVerticalJustify() const
{
return textProperties.m_verticalJustify;
}
@ -1219,8 +1219,8 @@ private:
struct TEXT_PROPERTIES
{
VECTOR2D m_glyphSize; ///< Size of the glyphs
EDA_TEXT_HJUSTIFY_T m_horizontalJustify; ///< Horizontal justification
EDA_TEXT_VJUSTIFY_T m_verticalJustify; ///< Vertical justification
GR_TEXT_H_ALIGN_T m_horizontalJustify; ///< Horizontal justification
GR_TEXT_V_ALIGN_T m_verticalJustify; ///< Vertical justification
bool m_bold;
bool m_italic;
bool m_underlined;

View File

@ -22,17 +22,16 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* This file is part of the common library
* @file drawtxt.h
* @see common.h
*/
#ifndef __INCLUDE__DRAWTXT_H__
#define __INCLUDE__DRAWTXT_H__ 1
#ifndef GR_TEXT_H
#define GR_TEXT_H
#include <eda_item.h>
#include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T
#include <font/text_attributes.h>
namespace KIGFX
{
class COLOR4D;
}
/**
* Minimum dimension in pixel for drawing/no drawing a text used in Pcbnew to decide to
@ -93,7 +92,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, b
* @param aPos text position (according to h_justify, v_justify).
* @param aColor (COLOR4D) = text color.
* @param aText text to draw.
* @param aOrient angle in 0.1 degree.
* @param aOrient angle.
* @param aSize text size (size.x or size.y can be < 0 for mirrored texts).
* @param aH_justify horizontal justification (Left, center, right).
* @param aV_justify vertical justification (bottom, center, top).
@ -110,24 +109,11 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, b
* @param aPlotter = a pointer to a PLOTTER instance, when this function is used to plot
* the text. NULL to draw this text.
*/
void GRText( wxDC* aDC, const wxPoint& aPos, const COLOR4D& aColor, const wxString& aText,
double aOrient, const wxSize& aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold,
void GRText( wxDC* aDC, const wxPoint& aPos, const KIGFX::COLOR4D& aColor, const wxString& aText,
const EDA_ANGLE& aOrient, const wxSize& aSize, enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold,
void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ) = nullptr,
void* aCallbackData = nullptr, PLOTTER* aPlotter = nullptr );
/**
* Draw graphic text with a border so that it can be read on different backgrounds.
*
* See GRText for most of the parameters. If \a aBgColor is a dark color text is drawn
* in \a aColor2 with \a aColor1 border. Otherwise colors are swapped.
*/
void GRHaloText( wxDC* aDC, const wxPoint& aPos, const COLOR4D& aBgColor, const COLOR4D& aColor1,
const COLOR4D& aColor2, const wxString& aText, double aOrient, const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify,
int aWidth, bool aItalic, bool aBold,
void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ) = nullptr,
void* aCallbackData = nullptr, PLOTTER* aPlotter = nullptr );
#endif /* __INCLUDE__DRAWTXT_H__ */
#endif /* GR_TEXT_H */

View File

@ -126,10 +126,7 @@ public:
virtual bool StartPlot() = 0;
virtual bool EndPlot() = 0;
virtual void SetNegative( bool aNegative )
{
m_negativeMode = aNegative;
}
virtual void SetNegative( bool aNegative ) { m_negativeMode = aNegative; }
/**
* Plot in B/W or color.
@ -306,14 +303,14 @@ public:
// Higher level primitives -- can be drawn as line, sketch or 'filled'
virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
OUTLINE_MODE tracemode, void* aData );
virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
int rayon, int width, OUTLINE_MODE tracemode, void* aData );
virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
OUTLINE_MODE tracemode, void* aData );
virtual void ThickCircle( const wxPoint& pos, int diametre, int width,
OUTLINE_MODE tracemode, void* aData );
virtual void FilledCircle( const wxPoint& pos, int diametre,
OUTLINE_MODE tracemode, void* aData );
virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle, int rayon,
int width, OUTLINE_MODE tracemode, void* aData );
virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width, OUTLINE_MODE tracemode,
void* aData );
virtual void ThickCircle( const wxPoint& pos, int diametre, int width, OUTLINE_MODE tracemode,
void* aData );
virtual void FilledCircle( const wxPoint& pos, int diametre, OUTLINE_MODE tracemode,
void* aData );
// Flash primitives
@ -324,8 +321,8 @@ public:
* @param aTraceMode is the drawing mode, FILLED or SKETCH.
* @param aData is an auxiliary info (mainly for gerber format attributes).
*/
virtual void FlashPadCircle( const wxPoint& aPadPos, int aDiameter,
OUTLINE_MODE aTraceMode, void* aData ) = 0;
virtual void FlashPadCircle( const wxPoint& aPadPos, int aDiameter, OUTLINE_MODE aTraceMode,
void* aData ) = 0;
/**
* @param aPadPos Position of the shape (center of the rectangle.
@ -344,8 +341,8 @@ public:
* @param aTraceMode is the drawing mode, FILLED or SKETCH.
* @param aData an auxiliary info (mainly for gerber format attributes).
*/
virtual void FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize,
double aPadOrient, OUTLINE_MODE aTraceMode, void* aData ) = 0;
virtual void FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize, double aPadOrient,
OUTLINE_MODE aTraceMode, void* aData ) = 0;
/**
* @param aPadPos Position of the shape (center of the rectangle.
@ -355,9 +352,8 @@ public:
* @param aTraceMode is the drawing mode, FILLED or SKETCH.
* @param aData an auxiliary info (mainly for gerber format attributes).
*/
virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
int aCornerRadius, double aOrient,
OUTLINE_MODE aTraceMode, void* aData ) = 0;
virtual void FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize, int aCornerRadius,
double aOrient, OUTLINE_MODE aTraceMode, void* aData ) = 0;
/**
* @param aPadPos Position of the shape.
@ -367,9 +363,9 @@ public:
* @param aTraceMode is the drawing mode, FILLED or SKETCH.
* @param aData an auxiliary info (mainly for gerber format attributes).
*/
virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
double aPadOrient, SHAPE_POLY_SET* aPolygons,
OUTLINE_MODE aTraceMode, void* aData ) = 0;
virtual void FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize, double aPadOrient,
SHAPE_POLY_SET* aPolygons, OUTLINE_MODE aTraceMode,
void* aData ) = 0;
/**
* Flash a trapezoidal pad.
@ -381,9 +377,8 @@ public:
* @param aTraceMode is the drawing mode, FILLED or SKETCH.
* @param aData an auxiliary info (mainly for gerber format attributes).
*/
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
double aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) = 0;
virtual void FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCorners, double aPadOrient,
OUTLINE_MODE aTraceMode, void* aData ) = 0;
/**
* Flash a regular polygon. Useful only in Gerber files to flash a regular polygon.
@ -407,10 +402,10 @@ public:
virtual void Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,

View File

@ -152,10 +152,10 @@ public:
virtual void Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,

View File

@ -102,10 +102,10 @@ public:
virtual void Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,

View File

@ -97,11 +97,11 @@ protected:
*/
void computeTextParameters( const wxPoint& aPos,
const wxString& aText,
int aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
bool aMirror,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
@ -217,15 +217,16 @@ public:
virtual void Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed = false,
void* aData = nullptr ) override;
protected:
virtual void emitSetRGBColor( double r, double g, double b ) override;
};
@ -333,15 +334,16 @@ public:
virtual void Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed = false,
void* aData = nullptr ) override;
/**
* PDF images are handles as inline, not XObject streams...
*/
@ -495,10 +497,10 @@ public:
virtual void Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,

View File

@ -263,16 +263,16 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
switch( item->m_Hjustify )
{
case GR_TEXT_HJUSTIFY_LEFT: m_choiceHjustify->SetSelection( 0 ); break;
case GR_TEXT_HJUSTIFY_CENTER: m_choiceHjustify->SetSelection( 1 ); break;
case GR_TEXT_HJUSTIFY_RIGHT: m_choiceHjustify->SetSelection( 2 ); break;
case GR_TEXT_H_ALIGN_LEFT: m_choiceHjustify->SetSelection( 0 ); break;
case GR_TEXT_H_ALIGN_CENTER: m_choiceHjustify->SetSelection( 1 ); break;
case GR_TEXT_H_ALIGN_RIGHT: m_choiceHjustify->SetSelection( 2 ); break;
}
switch( item->m_Vjustify )
{
case GR_TEXT_VJUSTIFY_TOP: m_choiceVjustify->SetSelection( 0 ); break;
case GR_TEXT_VJUSTIFY_CENTER: m_choiceVjustify->SetSelection( 1 ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: m_choiceVjustify->SetSelection( 2 ); break;
case GR_TEXT_V_ALIGN_TOP: m_choiceVjustify->SetSelection( 0 ); break;
case GR_TEXT_V_ALIGN_CENTER: m_choiceVjustify->SetSelection( 1 ); break;
case GR_TEXT_V_ALIGN_BOTTOM: m_choiceVjustify->SetSelection( 2 ); break;
}
// Text size
@ -474,16 +474,16 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
switch( m_choiceHjustify->GetSelection() )
{
case 0: item->m_Hjustify = GR_TEXT_HJUSTIFY_LEFT; break;
case 1: item->m_Hjustify = GR_TEXT_HJUSTIFY_CENTER; break;
case 2: item->m_Hjustify = GR_TEXT_HJUSTIFY_RIGHT; break;
case 0: item->m_Hjustify = GR_TEXT_H_ALIGN_LEFT; break;
case 1: item->m_Hjustify = GR_TEXT_H_ALIGN_CENTER; break;
case 2: item->m_Hjustify = GR_TEXT_H_ALIGN_RIGHT; break;
}
switch( m_choiceVjustify->GetSelection() )
{
case 0: item->m_Vjustify = GR_TEXT_VJUSTIFY_TOP; break;
case 1: item->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER; break;
case 2: item->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break;
case 0: item->m_Vjustify = GR_TEXT_V_ALIGN_TOP; break;
case 1: item->m_Vjustify = GR_TEXT_V_ALIGN_CENTER; break;
case 2: item->m_Vjustify = GR_TEXT_V_ALIGN_BOTTOM; break;
}
msg = m_textCtrlRotation->GetValue();

View File

@ -221,7 +221,7 @@ bool DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow()
m_txtTextPosY->Disable();
}
m_orientValue = text.GetTextAngleDegrees();
m_orientValue = text.GetTextAngle().AsDegrees();
m_cbKeepAligned->SetValue( m_dimension->GetKeepTextAligned() );
m_cbTextOrientation->Enable( !m_dimension->GetKeepTextAligned() );
@ -229,7 +229,7 @@ bool DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow()
m_cbItalic->SetValue( text.IsItalic() );
m_cbMirrored->SetValue( text.IsMirrored() );
EDA_TEXT_HJUSTIFY_T hJustify = text.GetHorizJustify();
GR_TEXT_H_ALIGN_T hJustify = text.GetHorizJustify();
m_cbJustification->SetSelection( (int) hJustify + 1 );
m_lineThickness.SetValue( m_dimension->GetLineThickness() );
@ -346,8 +346,7 @@ void DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog( PCB_DIMENSION_BASE*
text.SetTextThickness( m_textThickness.GetValue() );
text.SetItalic( m_cbItalic->GetValue() );
text.SetMirrored( m_cbMirrored->GetValue() );
int justification = m_cbJustification->GetSelection() - 1;
text.SetHorizJustify( static_cast<EDA_TEXT_HJUSTIFY_T>( justification ) );
text.SetHorizJustify( TO_HJUSTIFY( m_cbJustification->GetSelection() - 1 ) );
aTarget->SetLineThickness( m_lineThickness.GetValue() );
aTarget->SetArrowLength( m_arrowLength.GetValue() );

View File

@ -436,9 +436,9 @@ void processTextItem( const FP_TEXT& aSrc, FP_TEXT& aDest,
}
else
{
// Careful: the visible bit is also in Effects
// Careful: the visible bit and position are also set by SetAttributes()
bool visible = aDest.IsVisible();
aDest.SetEffects( aSrc );
aDest.SetAttributes( aSrc );
aDest.SetVisible( visible );
}

View File

@ -273,14 +273,14 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
switch ( m_edaText->GetHorizJustify() )
{
case GR_TEXT_HJUSTIFY_LEFT: m_alignLeft->Check( true ); break;
case GR_TEXT_HJUSTIFY_CENTER: m_alignCenter->Check( true ); break;
case GR_TEXT_HJUSTIFY_RIGHT: m_alignRight->Check( true ); break;
case GR_TEXT_H_ALIGN_LEFT: m_alignLeft->Check( true ); break;
case GR_TEXT_H_ALIGN_CENTER: m_alignCenter->Check( true ); break;
case GR_TEXT_H_ALIGN_RIGHT: m_alignRight->Check( true ); break;
}
m_mirrored->Check( m_edaText->IsMirrored() );
m_OrientValue = m_edaText->GetTextAngle();
m_OrientValue = m_edaText->GetTextAngle().AsTenthsOfADegree();
m_orientation.SetDoubleValue( m_OrientValue );
return DIALOG_TEXT_PROPERTIES_BASE::TransferDataToWindow();
@ -377,11 +377,11 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
m_edaText->SetItalic( m_italic->IsChecked() );
if( m_alignLeft->IsChecked() )
m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
m_edaText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
else if( m_alignCenter->IsChecked() )
m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
m_edaText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
else
m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
m_edaText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
m_edaText->SetMirrored( m_mirrored->IsChecked() );

View File

@ -893,7 +893,6 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
// Text on silk layer: RefDes and value (are they actually useful?)
for( FP_TEXT* textItem : { &footprint->Reference(), &footprint->Value() } )
{
double txt_orient = textItem->GetTextAngle();
std::string layer = GenCADLayerName( cu_count,
footprint->GetFlag() ? B_SilkS : F_SilkS );
@ -901,7 +900,7 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
textItem->GetPos0().x / SCALE_FACTOR,
-textItem->GetPos0().y / SCALE_FACTOR,
textItem->GetTextWidth() / SCALE_FACTOR,
txt_orient / 10.0,
textItem->GetTextAngle().AsDegrees(),
mirror,
layer.c_str(),
TO_UTF8( escapeString( textItem->GetText() ) ) );

View File

@ -252,9 +252,9 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
// Plot title "Info"
wxString Text = wxT( "Drill Map:" );
plotter->Text( wxPoint( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, 0,
plotter->Text( wxPoint( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, EDA_ANGLE::HORIZONTAL,
wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, TextWidth, false, false );
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false );
// For some formats (PS, PDF SVG) we plot the drill size list on more than one column
// because the list must be contained inside the printed page
@ -313,9 +313,9 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
if( tool.m_Hole_NotPlated )
msg += wxT( " (not plated)" );
plotter->Text( wxPoint( plotX, y ), COLOR4D::UNSPECIFIED, msg, 0,
plotter->Text( wxPoint( plotX, y ), COLOR4D::UNSPECIFIED, msg, EDA_ANGLE::HORIZONTAL,
wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, TextWidth, false, false );
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false );
intervalle = KiROUND( ( ( charSize * charScale ) + TextWidth ) * 1.2 );

View File

@ -76,6 +76,12 @@ void FP_TEXT::SetTextAngle( double aAngle )
}
void FP_TEXT::SetTextAngle( const EDA_ANGLE& aAngle )
{
EDA_TEXT::SetTextAngle( aAngle );
}
bool FP_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
EDA_RECT rect = GetTextBox();
@ -83,7 +89,7 @@ bool FP_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
rect.Inflate( aAccuracy );
RotatePoint( &location, GetTextPos(), -GetDrawRotation() );
RotatePoint( &location, GetTextPos(), -GetDrawRotation().AsTenthsOfADegree() );
return rect.Contains( location );
}
@ -98,7 +104,7 @@ bool FP_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
if( aContains )
return rect.Contains( GetBoundingBox() );
else
return rect.Intersects( GetTextBox(), GetDrawRotation() );
return rect.Intersects( GetTextBox(), GetDrawRotation().AsTenthsOfADegree() );
}
@ -107,14 +113,14 @@ void FP_TEXT::KeepUpright( double aOldOrientation, double aNewOrientation )
if( !IsKeepUpright() )
return;
double newAngle = GetTextAngle() + aNewOrientation;
double newAngle = GetTextAngle().AsTenthsOfADegree() + aNewOrientation;
NORMALIZE_ANGLE_POS( newAngle );
bool needsFlipped = newAngle >= 1800.0;
if( needsFlipped )
{
SetHorizJustify( static_cast<EDA_TEXT_HJUSTIFY_T>( -GetHorizJustify() ) );
SetTextAngle( GetTextAngle() + 1800.0 );
SetHorizJustify( static_cast<GR_TEXT_H_ALIGN_T>( -GetHorizJustify() ) );
SetTextAngle( GetTextAngle().AsTenthsOfADegree() + 1800.0 );
SetDrawCoord();
}
}
@ -129,7 +135,7 @@ void FP_TEXT::Rotate( const wxPoint& aRotCentre, double aAngle )
RotatePoint( &pt, aRotCentre, aAngle );
SetTextPos( pt );
SetTextAngle( GetTextAngle() + aAngle );
SetTextAngle( GetTextAngle().AsTenthsOfADegree() + aAngle );
SetLocalCoord();
}
@ -145,7 +151,7 @@ void FP_TEXT::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
else
{
SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
SetTextAngle( 1800 - GetTextAngle() );
SetTextAngle( 1800 - GetTextAngle().AsTenthsOfADegree() );
}
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
@ -226,7 +232,7 @@ void FP_TEXT::SetLocalCoord()
const EDA_RECT FP_TEXT::GetBoundingBox() const
{
double angle = GetDrawRotation();
double angle = GetDrawRotation().AsTenthsOfADegree();
EDA_RECT text_area = GetTextBox();
if( angle )
@ -236,10 +242,10 @@ const EDA_RECT FP_TEXT::GetBoundingBox() const
}
double FP_TEXT::GetDrawRotation() const
EDA_ANGLE FP_TEXT::GetDrawRotation() const
{
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
double rotation = GetTextAngle();
double rotation = GetTextAngle().AsTenthsOfADegree();
if( parentFootprint )
rotation += parentFootprint->GetOrientation();
@ -258,7 +264,7 @@ double FP_TEXT::GetDrawRotation() const
NORMALIZE_ANGLE_POS( rotation );
}
return rotation;
return EDA_ANGLE( rotation, EDA_ANGLE::TENTHS_OF_A_DEGREE );
}
@ -295,7 +301,7 @@ void FP_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
msg.Printf( wxT( "%g" ), GetTextAngleDegrees() );
msg.Printf( wxT( "%g" ), GetTextAngle().AsDegrees() );
aList.emplace_back( _( "Angle" ), msg );
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextThickness() );
@ -344,10 +350,10 @@ EDA_ITEM* FP_TEXT::Clone() const
const BOX2I FP_TEXT::ViewBBox() const
{
double angle = GetDrawRotation();
double angle = GetDrawRotation().AsTenthsOfADegree();
EDA_RECT text_area = GetTextBox();
if( angle != 0.0 )
if( angle )
text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
return BOX2I( text_area.GetPosition(), text_area.GetSize() );
@ -486,7 +492,7 @@ void FP_TEXT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffe
const FOOTPRINT* parentFootprint = static_cast<const FOOTPRINT*>( m_parent );
if( parentFootprint )
buffer.Rotate( DECIDEG2RAD( GetDrawRotation() ), GetTextPos() );
buffer.Rotate( GetDrawRotation().AsRadians(), GetTextPos() );
aCornerBuffer.Append( buffer );
}

View File

@ -97,6 +97,7 @@ public:
}
void SetTextAngle( double aAngle ) override;
void SetTextAngle( const EDA_ANGLE& aAngle );
/**
* Called when rotating the parent footprint.
@ -133,27 +134,6 @@ public:
void SetType( TEXT_TYPE aType ) { m_Type = aType; }
TEXT_TYPE GetType() const { return m_Type; }
/**
* Set the text effects from another instance.
*/
void SetEffects( const FP_TEXT& aSrc )
{
EDA_TEXT::SetEffects( aSrc );
SetLocalCoord();
// SetType( aSrc.GetType() );
}
/**
* Swap the text effects of the two involved instances.
*/
void SwapEffects( FP_TEXT& aTradingPartner )
{
EDA_TEXT::SwapEffects( aTradingPartner );
SetLocalCoord();
aTradingPartner.SetLocalCoord();
// std::swap( m_Type, aTradingPartner.m_Type );
}
// The Pos0 accessors are for footprint-relative coordinates.
void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
const wxPoint& GetPos0() const { return m_Pos0; }
@ -164,8 +144,7 @@ public:
* @return the text rotation for drawings and plotting the footprint rotation is taken
* in account.
*/
virtual double GetDrawRotation() const override;
double GetDrawRotationRadians() const { return GetDrawRotation() * M_PI/1800; }
virtual EDA_ANGLE GetDrawRotation() const override;
// Virtual function
const EDA_RECT GetBoundingBox() const override;

View File

@ -211,7 +211,8 @@ wxString FP_TEXT_GRID_TABLE::GetValue( int aRow, int aCol )
return text.GetLayerName();
case FPT_ORIENTATION:
return StringFromValue( EDA_UNITS::DEGREES, (int) NormalizeAnglePos( text.GetTextAngle() ),
return StringFromValue( EDA_UNITS::DEGREES,
NormalizeAnglePos( text.GetTextAngle().AsTenthsOfADegree() ),
true );
case FPT_XOFFSET:

View File

@ -588,21 +588,21 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
VECTOR2D topLeft(0.0, 0.0);
VECTOR2D topRight(0.0, 0.0);
EDA_TEXT_HJUSTIFY_T hJustify = GR_TEXT_HJUSTIFY_LEFT;
EDA_TEXT_VJUSTIFY_T vJustify = GR_TEXT_VJUSTIFY_BOTTOM;
GR_TEXT_H_ALIGN_T hJustify = GR_TEXT_H_ALIGN_LEFT;
GR_TEXT_V_ALIGN_T vJustify = GR_TEXT_V_ALIGN_BOTTOM;
switch( aData.vJustification )
{
case 0: //DRW_Text::VBaseLine:
case 1: //DRW_Text::VBottom:
vJustify = GR_TEXT_VJUSTIFY_BOTTOM;
vJustify = GR_TEXT_V_ALIGN_BOTTOM;
topLeft.y = textHeight;
topRight.y = textHeight;
break;
case 2: //DRW_Text::VMiddle:
vJustify = GR_TEXT_VJUSTIFY_CENTER;
vJustify = GR_TEXT_V_ALIGN_CENTER;
bottomRight.y = -textHeight / 2.0;
bottomLeft.y = -textHeight / 2.0;
@ -611,7 +611,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
break;
case 3: //DRW_Text::VTop:
vJustify = GR_TEXT_VJUSTIFY_TOP;
vJustify = GR_TEXT_V_ALIGN_TOP;
bottomLeft.y = -textHeight;
bottomRight.y = -textHeight;
@ -623,7 +623,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
case 0: //DRW_Text::HLeft:
case 3: //DRW_Text::HAligned: // no equivalent options in text pcb.
case 5: //DRW_Text::HFit: // no equivalent options in text pcb.
hJustify = GR_TEXT_HJUSTIFY_LEFT;
hJustify = GR_TEXT_H_ALIGN_LEFT;
bottomRight.x = textWidth;
topRight.x = textWidth;
@ -631,7 +631,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
case 1: //DRW_Text::HCenter:
case 4: //DRW_Text::HMiddle: // no equivalent options in text pcb.
hJustify = GR_TEXT_HJUSTIFY_CENTER;
hJustify = GR_TEXT_H_ALIGN_CENTER;
bottomLeft.x = -textWidth / 2.0;
topLeft.x = -textWidth / 2.0;
@ -640,7 +640,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
break;
case 2: //DRW_Text::HRight:
hJustify = GR_TEXT_HJUSTIFY_RIGHT;
hJustify = GR_TEXT_H_ALIGN_RIGHT;
bottomLeft.x = -textWidth;
topLeft.x = -textWidth;
@ -755,19 +755,19 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
VECTOR2D textpos( mapX( textposCoords.x ), mapY( textposCoords.y ) );
// Initialize text justifications:
EDA_TEXT_HJUSTIFY_T hJustify = GR_TEXT_HJUSTIFY_LEFT;
EDA_TEXT_VJUSTIFY_T vJustify = GR_TEXT_VJUSTIFY_BOTTOM;
GR_TEXT_H_ALIGN_T hJustify = GR_TEXT_H_ALIGN_LEFT;
GR_TEXT_V_ALIGN_T vJustify = GR_TEXT_V_ALIGN_BOTTOM;
if( aData.attachmentPoint <= 3 )
{
vJustify = GR_TEXT_VJUSTIFY_TOP;
vJustify = GR_TEXT_V_ALIGN_TOP;
bottomLeft.y = -textHeight;
bottomRight.y = -textHeight;
}
else if( aData.attachmentPoint <= 6 )
{
vJustify = GR_TEXT_VJUSTIFY_CENTER;
vJustify = GR_TEXT_V_ALIGN_CENTER;
bottomRight.y = -textHeight / 2.0;
bottomLeft.y = -textHeight / 2.0;
@ -776,7 +776,7 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
}
else
{
vJustify = GR_TEXT_VJUSTIFY_BOTTOM;
vJustify = GR_TEXT_V_ALIGN_BOTTOM;
topLeft.y = textHeight;
topRight.y = textHeight;
@ -784,14 +784,14 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
if( aData.attachmentPoint % 3 == 1 )
{
hJustify = GR_TEXT_HJUSTIFY_LEFT;
hJustify = GR_TEXT_H_ALIGN_LEFT;
bottomRight.x = textWidth;
topRight.x = textWidth;
}
else if( aData.attachmentPoint % 3 == 2 )
{
hJustify = GR_TEXT_HJUSTIFY_CENTER;
hJustify = GR_TEXT_H_ALIGN_CENTER;
bottomLeft.x = -textWidth / 2.0;
topLeft.x = -textWidth / 2.0;
@ -800,7 +800,7 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
}
else
{
hJustify = GR_TEXT_HJUSTIFY_RIGHT;
hJustify = GR_TEXT_H_ALIGN_RIGHT;
bottomLeft.x = -textWidth;
topLeft.x = -textWidth;

View File

@ -231,9 +231,9 @@ public:
* @param aVJustify is the text vertical justification.
* @param aWidth is the segment thickness in mm. Use -1 for default line thickness
*/
virtual void AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aThickness, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) = 0;
virtual void AddText( const VECTOR2D& aOrigin, const wxString& aText, double aHeight,
double aWidth, double aThickness, double aOrientation,
GR_TEXT_H_ALIGN_T aHJustify, GR_TEXT_V_ALIGN_T aVJustify ) = 0;
/**
* Create an object representing an arc.

View File

@ -59,8 +59,9 @@ void GRAPHICS_IMPORTER_BUFFER::AddPolygon( const std::vector< VECTOR2D >& aVerti
void GRAPHICS_IMPORTER_BUFFER::AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aThickness, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify )
double aHeight, double aWidth, double aThickness,
double aOrientation, GR_TEXT_H_ALIGN_T aHJustify,
GR_TEXT_V_ALIGN_T aVJustify )
{
m_shapes.push_back( make_shape< IMPORTED_TEXT >( aOrigin, aText, aHeight, aWidth,
aThickness, aOrientation, aHJustify, aVJustify ) );
@ -82,6 +83,6 @@ void GRAPHICS_IMPORTER_BUFFER::AddShape( std::unique_ptr<IMPORTED_SHAPE>& aShape
void GRAPHICS_IMPORTER_BUFFER::ImportTo( GRAPHICS_IMPORTER& aImporter )
{
for( auto& shape : m_shapes )
for( std::unique_ptr<IMPORTED_SHAPE>& shape : m_shapes )
shape->ImportTo( aImporter );
}

View File

@ -218,8 +218,8 @@ class IMPORTED_TEXT : public IMPORTED_SHAPE
{
public:
IMPORTED_TEXT( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, double aWidth,
double aThickness, double aOrientation, EDA_TEXT_HJUSTIFY_T aHJustify,
EDA_TEXT_VJUSTIFY_T aVJustify ) :
double aThickness, double aOrientation, GR_TEXT_H_ALIGN_T aHJustify,
GR_TEXT_V_ALIGN_T aVJustify ) :
m_origin( aOrigin ),
m_text( aText ),
m_height( aHeight ),
@ -260,8 +260,8 @@ private:
double m_width;
double m_thickness;
double m_orientation;
EDA_TEXT_HJUSTIFY_T m_hJustify;
EDA_TEXT_VJUSTIFY_T m_vJustify;
GR_TEXT_H_ALIGN_T m_hJustify;
GR_TEXT_V_ALIGN_T m_vJustify;
};
@ -329,9 +329,9 @@ public:
void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override;
void AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aThickness, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override;
void AddText( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, double aWidth,
double aThickness, double aOrientation, GR_TEXT_H_ALIGN_T aHJustify,
GR_TEXT_V_ALIGN_T aVJustify ) override;
void AddSpline( const VECTOR2D& aStart, const VECTOR2D& BezierControl1,
const VECTOR2D& BezierControl2, const VECTOR2D& aEnd , double aWidth ) override;

View File

@ -146,8 +146,8 @@ void GRAPHICS_IMPORTER_PCBNEW::AddPolygon( const std::vector< VECTOR2D >& aVerti
void GRAPHICS_IMPORTER_PCBNEW::AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aThickness,
double aOrientation, EDA_TEXT_HJUSTIFY_T aHJustify,
EDA_TEXT_VJUSTIFY_T aVJustify )
double aOrientation, GR_TEXT_H_ALIGN_T aHJustify,
GR_TEXT_V_ALIGN_T aVJustify )
{
std::unique_ptr<BOARD_ITEM> boardItem;
EDA_TEXT* textItem;

View File

@ -69,9 +69,9 @@ public:
void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override;
void AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aThickness, double aOrientation,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override;
void AddText( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, double aWidth,
double aThickness, double aOrientation, GR_TEXT_H_ALIGN_T aHJustify,
GR_TEXT_V_ALIGN_T aVJustify ) override;
void AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd,

View File

@ -210,7 +210,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
else
pcb_text->CopyText( *fp_text );
pcb_text->SetEffects( *fp_text );
pcb_text->SetAttributes( *fp_text );
pcb_text->SetLayer( fp_text->GetLayer() );
copy = pcb_text;
}

View File

@ -213,7 +213,7 @@ void PCB_DIMENSION_BASE::Move( const wxPoint& offset )
void PCB_DIMENSION_BASE::Rotate( const wxPoint& aRotCentre, double aAngle )
{
double newAngle = m_text.GetTextAngle() + aAngle;
double newAngle = m_text.GetTextAngle().AsTenthsOfADegree() + aAngle;
if( newAngle >= 3600 )
newAngle -= 3600;
@ -613,7 +613,7 @@ void PCB_DIM_ALIGNED::updateGeometry()
polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y );
polyBox.Append( textBox.GetEnd() );
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y );
polyBox.Rotate( -m_text.GetTextAngleRadians(), textBox.GetCenter() );
polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() );
// The ideal crossbar, if the text doesn't collide
SEG crossbar( m_crossBarStart, m_crossBarEnd );
@ -796,7 +796,7 @@ void PCB_DIM_ORTHOGONAL::updateGeometry()
polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y );
polyBox.Append( textBox.GetEnd() );
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y );
polyBox.Rotate( -m_text.GetTextAngleRadians(), textBox.GetCenter() );
polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() );
// The ideal crossbar, if the text doesn't collide
SEG crossbar( m_crossBarStart, m_crossBarEnd );
@ -986,7 +986,7 @@ void PCB_DIM_LEADER::updateGeometry()
polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y );
polyBox.Append( textBox.GetEnd() );
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y );
polyBox.Rotate( -m_text.GetTextAngleRadians(), textBox.GetCenter() );
polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() );
VECTOR2I firstLine( m_end - m_start );
VECTOR2I start( m_start );
@ -1178,7 +1178,7 @@ void PCB_DIM_RADIAL::updateGeometry()
polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y );
polyBox.Append( textBox.GetEnd() );
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y );
polyBox.Rotate( -m_text.GetTextAngleRadians(), textBox.GetCenter() );
polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() );
VECTOR2I radial( m_end - m_start );
radial = radial.Resize( m_leaderLength );

View File

@ -611,8 +611,8 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
m_gal->SetFontUnderlined( false );
m_gal->SetTextMirrored( false );
m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->BitmapText( netName, textPosition, textOrientation );
return;
@ -912,8 +912,8 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
size = maxSize;
// Default font settings
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetFontBold( false );
m_gal->SetFontItalic( false );
m_gal->SetFontUnderlined( false );
@ -1568,7 +1568,7 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetTextAttributes( aText );
m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
m_gal->StrokeText( shownText, position, aText->GetTextAngle().AsRadians() );
}
@ -1592,7 +1592,7 @@ void PCB_PAINTER::draw( const FP_TEXT* aText, int aLayer )
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetTextAttributes( aText );
m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
m_gal->StrokeText( shownText, position, aText->GetDrawRotation().AsRadians() );
// Draw the umbilical line
if( aText->IsSelected() )
@ -1686,8 +1686,8 @@ void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
m_gal->SetFontItalic( true );
m_gal->SetFontUnderlined( false );
m_gal->SetTextMirrored( m_gal->IsFlippedX() );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM );
m_gal->SetIsFill( false );
m_gal->SetGlyphSize( VECTOR2D( textSize, textSize ) );
m_gal->SetLineWidth( penWidth );
@ -1833,7 +1833,7 @@ void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer )
m_gal->SetLineWidth( getLineThickness( text.GetEffectiveTextPenWidth() ) );
m_gal->SetTextAttributes( &text );
m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngle().AsRadians() );
}

View File

@ -107,6 +107,12 @@ void PCB_TEXT::SetTextAngle( double aAngle )
}
void PCB_TEXT::SetTextAngle( const EDA_ANGLE& aAngle )
{
EDA_TEXT::SetTextAngle( aAngle );
}
void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{
EDA_UNITS units = aFrame->GetUserUnits();
@ -121,7 +127,7 @@ void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngleDegrees() ) );
aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngle().AsDegrees() ) );
aList.emplace_back( _( "Thickness" ), MessageTextFromValue( units, GetTextThickness() ) );
aList.emplace_back( _( "Width" ), MessageTextFromValue( units, GetTextWidth() ) );
@ -133,8 +139,8 @@ const EDA_RECT PCB_TEXT::GetBoundingBox() const
{
EDA_RECT rect = GetTextBox();
if( GetTextAngle() != 0 )
rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle() );
if( GetTextAngle() != EDA_ANGLE::ANGLE_0 )
rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
return rect;
}
@ -165,7 +171,7 @@ void PCB_TEXT::Rotate( const wxPoint& aRotCentre, double aAngle )
RotatePoint( &pt, aRotCentre, aAngle );
SetTextPos( pt );
SetTextAngle( GetTextAngle() + aAngle );
SetTextAngle( GetTextAngle().AsTenthsOfADegree() + aAngle );
}
@ -179,7 +185,7 @@ void PCB_TEXT::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
else
{
SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
SetTextAngle( 1800 - GetTextAngle() );
SetTextAngle( 1800 - GetTextAngle().AsTenthsOfADegree() );
}
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );

View File

@ -89,6 +89,7 @@ public:
}
void SetTextAngle( double aAngle ) override;
void SetTextAngle( const EDA_ANGLE& aAngle );
void Rotate( const wxPoint& aRotCentre, double aAngle ) override;

View File

@ -389,7 +389,6 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aTextMod, const COL
// calculate some text parameters :
wxSize size = aTextMod->GetTextSize();
wxPoint pos = aTextMod->GetTextPos();
double orient = aTextMod->GetDrawRotation();
int thickness = aTextMod->GetEffectiveTextPenWidth();
if( aTextMod->IsMirrored() )
@ -412,7 +411,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aTextMod, const COL
m_plotter->SetCurrentLineWidth( thickness );
m_plotter->Text( pos, aColor, aTextMod->GetShownText(), orient, size,
m_plotter->Text( pos, aColor, aTextMod->GetShownText(), aTextMod->GetDrawRotation(), size,
aTextMod->GetHorizJustify(), aTextMod->GetVertJustify(), thickness,
aTextMod->IsItalic(), allow_bold, false, &gbr_metadata );
}
@ -757,7 +756,6 @@ void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText )
wxSize size = aText->GetTextSize();
wxPoint pos = aText->GetTextPos();
double orient = aText->GetTextAngle();
int thickness = aText->GetEffectiveTextPenWidth();
if( aText->IsMirrored() )
@ -783,16 +781,16 @@ void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText )
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
{
wxString& txt = strings_list.Item( ii );
m_plotter->Text( positions[ii], color, txt, orient, size, aText->GetHorizJustify(),
aText->GetVertJustify(), thickness, aText->IsItalic(),
allow_bold, false, &gbr_metadata );
m_plotter->Text( positions[ii], color, txt, aText->GetTextAngle(), size,
aText->GetHorizJustify(), aText->GetVertJustify(), thickness,
aText->IsItalic(), allow_bold, false, &gbr_metadata );
}
}
else
{
m_plotter->Text( pos, color, shownText, orient, size, aText->GetHorizJustify(),
aText->GetVertJustify(), thickness, aText->IsItalic(), allow_bold,
false, &gbr_metadata );
m_plotter->Text( pos, color, shownText, aText->GetTextAngle(), size,
aText->GetHorizJustify(), aText->GetVertJustify(), thickness,
aText->IsItalic(), allow_bold, false, &gbr_metadata );
}
}

View File

@ -1228,12 +1228,12 @@ void ALTIUM_PCB::HelperParseDimensions6Radial(const ADIMENSION6 &aElem)
// It's unclear exactly how Altium figures it's text positioning, but this gets us reasonably
// close.
dimension->Text().SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM );
dimension->Text().SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT );
dimension->Text().SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
dimension->Text().SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
int yAdjust = dimension->Text().GetCenter().y - dimension->Text().GetPosition().y;
dimension->Text().Move( wxPoint( 0, yAdjust + aElem.textgap ) );
dimension->Text().SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_CENTER );
dimension->Text().SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
}
@ -1309,8 +1309,8 @@ void ALTIUM_PCB::HelperParseDimensions6Leader( const ADIMENSION6& aElem )
text->SetLayer( klayer );
text->SetTextSize( wxSize( aElem.textheight, aElem.textheight ) ); // TODO: parse text width
text->SetTextThickness( aElem.textlinewidth );
text->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT );
text->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM );
text->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
text->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
}
@ -2751,7 +2751,7 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader,
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( fpText->GetParent() );
double orientation = parentFootprint->GetOrientation();
fpText->SetTextAngle( fpText->GetTextAngle() - orientation );
fpText->SetTextAngle( fpText->GetTextAngle().AsTenthsOfADegree() - orientation );
fpText->SetLocalCoord();
}
}
@ -2785,8 +2785,8 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader,
if( elem.isDesignator || elem.isComment ) // That's just a bold assumption
{
tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT );
tx->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM );
tx->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
tx->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
}
else
{
@ -2795,17 +2795,17 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader,
case ALTIUM_TEXT_POSITION::LEFT_TOP:
case ALTIUM_TEXT_POSITION::LEFT_CENTER:
case ALTIUM_TEXT_POSITION::LEFT_BOTTOM:
tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT );
tx->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case ALTIUM_TEXT_POSITION::CENTER_TOP:
case ALTIUM_TEXT_POSITION::CENTER_CENTER:
case ALTIUM_TEXT_POSITION::CENTER_BOTTOM:
tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_CENTER );
tx->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ALTIUM_TEXT_POSITION::RIGHT_TOP:
case ALTIUM_TEXT_POSITION::RIGHT_CENTER:
case ALTIUM_TEXT_POSITION::RIGHT_BOTTOM:
tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_RIGHT );
tx->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
default:
wxLogError( "Unexpected horizontal Text Position. This should never happen." );
@ -2817,17 +2817,17 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader,
case ALTIUM_TEXT_POSITION::LEFT_TOP:
case ALTIUM_TEXT_POSITION::CENTER_TOP:
case ALTIUM_TEXT_POSITION::RIGHT_TOP:
tx->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_TOP );
tx->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ALTIUM_TEXT_POSITION::LEFT_CENTER:
case ALTIUM_TEXT_POSITION::CENTER_CENTER:
case ALTIUM_TEXT_POSITION::RIGHT_CENTER:
tx->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_CENTER );
tx->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ALTIUM_TEXT_POSITION::LEFT_BOTTOM:
case ALTIUM_TEXT_POSITION::CENTER_BOTTOM:
case ALTIUM_TEXT_POSITION::RIGHT_BOTTOM:
tx->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM );
tx->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
default:
wxLogError( "Unexpected vertical text position. This should never happen." );

View File

@ -1552,9 +1552,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions()
leaderDim->SetUnitsFormat( DIM_UNITS_FORMAT::NO_SUFFIX );
if( orientX == 1 )
leaderDim->Text().SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
leaderDim->Text().SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else
leaderDim->Text().SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
leaderDim->Text().SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
leaderDim->SetExtensionOffset( 0 );
}
@ -2547,48 +2547,48 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( const TEXT& aCadstarText,
{
case ALIGNMENT::NO_ALIGNMENT: // Default for Single line text is Bottom Left
case ALIGNMENT::BOTTOMLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case ALIGNMENT::BOTTOMCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ALIGNMENT::BOTTOMRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case ALIGNMENT::CENTERLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case ALIGNMENT::CENTERCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ALIGNMENT::CENTERRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case ALIGNMENT::TOPLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case ALIGNMENT::TOPCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ALIGNMENT::TOPRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
default:
@ -3270,48 +3270,48 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
FixTextPositionNoAlignment( txt );
KI_FALLTHROUGH;
case ALIGNMENT::BOTTOMLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case ALIGNMENT::BOTTOMCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ALIGNMENT::BOTTOMRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case ALIGNMENT::CENTERLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case ALIGNMENT::CENTERCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ALIGNMENT::CENTERRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case ALIGNMENT::TOPLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case ALIGNMENT::TOPCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case ALIGNMENT::TOPRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
default:

View File

@ -808,48 +808,48 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
switch( align )
{
case ETEXT::CENTER:
pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::CENTER_LEFT:
pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::CENTER_RIGHT:
pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::TOP_CENTER:
pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::TOP_LEFT:
pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::TOP_RIGHT:
pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::BOTTOM_CENTER:
pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
case ETEXT::BOTTOM_LEFT:
pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
case ETEXT::BOTTOM_RIGHT:
pcbtxt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
pcbtxt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
pcbtxt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
}
}
@ -1631,48 +1631,48 @@ void EAGLE_PLUGIN::orientFPText( FOOTPRINT* aFootprint, const EELEMENT& e, FP_TE
switch( align )
{
case ETEXT::TOP_RIGHT:
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
aFPText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::BOTTOM_LEFT:
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
aFPText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
case ETEXT::TOP_LEFT:
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
aFPText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::BOTTOM_RIGHT:
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
aFPText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
case ETEXT::TOP_CENTER:
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
aFPText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::BOTTOM_CENTER:
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
aFPText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
case ETEXT::CENTER:
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
aFPText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::CENTER_LEFT:
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
aFPText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::CENTER_RIGHT:
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
aFPText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
default:
@ -1683,15 +1683,15 @@ void EAGLE_PLUGIN::orientFPText( FOOTPRINT* aFootprint, const EELEMENT& e, FP_TE
{
// Part is not smash so use Lib default for NAME/VALUE // the text is per the original
// package, sans <attribute>.
double degrees = ( aFPText->GetTextAngle() + aFootprint->GetOrientation() ) / 10;
double degrees = aFPText->GetTextAngle().AsDegrees() + aFootprint->GetOrientation() / 10.0;
// @todo there are a few more cases than these to contend with:
if( ( !aFPText->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ) )
|| ( aFPText->IsMirrored() && ( degrees == 360 ) ) )
{
// ETEXT::TOP_RIGHT:
aFPText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aFPText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aFPText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
aFPText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
}
}
}
@ -1984,48 +1984,48 @@ void EAGLE_PLUGIN::packageText( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const
switch( align )
{
case ETEXT::CENTER:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::CENTER_LEFT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::CENTER_RIGHT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
break;
case ETEXT::TOP_CENTER:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::TOP_LEFT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::TOP_RIGHT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case ETEXT::BOTTOM_CENTER:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
case ETEXT::BOTTOM_LEFT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
case ETEXT::BOTTOM_RIGHT:
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
}
}

View File

@ -1110,11 +1110,11 @@ FABMASTER::GRAPHIC_TEXT* FABMASTER::processText( const FABMASTER::GRAPHIC_DATA&
new_text->mirror = ( aData.graphic_data4 == "YES" );
if( aData.graphic_data5 == "RIGHT" )
new_text->orient = GR_TEXT_HJUSTIFY_RIGHT;
new_text->orient = GR_TEXT_H_ALIGN_RIGHT;
else if( aData.graphic_data5 == "CENTER" )
new_text->orient = GR_TEXT_HJUSTIFY_CENTER;
new_text->orient = GR_TEXT_H_ALIGN_CENTER;
else
new_text->orient = GR_TEXT_HJUSTIFY_LEFT;
new_text->orient = GR_TEXT_H_ALIGN_LEFT;
std::vector<std::string> toks = split( aData.graphic_data6, " \t" );

View File

@ -266,7 +266,7 @@ private:
{
double rotation; ///<! GRAPHIC_DATA_3
bool mirror; ///<! GRAPHIC_DATA_4
EDA_TEXT_HJUSTIFY_T orient; ///<! GRAPHIC_DATA_5
GR_TEXT_H_ALIGN_T orient; ///<! GRAPHIC_DATA_5
// GRAPHIC_DATA_6 is
// SIZE FONT HEIGHT WIDTH ITAL LINESPACE THICKNESS
int height; ///<! GRAPHIC_DATA_6[2]

View File

@ -470,19 +470,19 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText )
switch( token )
{
case T_left:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case T_right:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case T_top:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break;
case T_bottom:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break;
case T_mirror:
@ -3492,7 +3492,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
{
FP_TEXT* text = parseFP_TEXT();
text->SetParent( footprint.get() );
double orientation = text->GetTextAngle();
double orientation = text->GetTextAngle().AsTenthsOfADegree();
orientation -= footprint->GetOrientation();
text->SetTextAngle( orientation );
text->SetDrawCoord();

View File

@ -1770,8 +1770,8 @@ void PCB_PLUGIN::format( const PCB_TEXT* aText, int aNestLevel ) const
m_out->Quotew( aText->GetText() ).c_str(),
FormatInternalUnits( aText->GetTextPos() ).c_str() );
if( aText->GetTextAngle() != 0.0 )
m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle() ).c_str() );
if( aText->GetTextAngle() != EDA_ANGLE::ANGLE_0 )
m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle().AsTenthsOfADegree() ).c_str() );
m_out->Print( 0, ")" );
@ -1838,8 +1838,8 @@ void PCB_PLUGIN::format( const FP_TEXT* aText, int aNestLevel ) const
// Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle,
// but internally the angle is held relative to its parent footprint. parent
// may be NULL when saving a footprint outside a BOARD.
double orient = aText->GetTextAngle();
FOOTPRINT* parent = (FOOTPRINT*) aText->GetParent();
double orient = aText->GetTextAngle().AsTenthsOfADegree();
FOOTPRINT* parent = static_cast<FOOTPRINT*>( aText->GetParent() );
if( parent )
{

View File

@ -254,26 +254,26 @@ static inline char* ReadLine( LINE_READER* rdr, const char* caller )
#endif
static EDA_TEXT_HJUSTIFY_T horizJustify( const char* horizontal )
static GR_TEXT_H_ALIGN_T horizJustify( const char* horizontal )
{
if( !strcmp( "L", horizontal ) )
return GR_TEXT_HJUSTIFY_LEFT;
return GR_TEXT_H_ALIGN_LEFT;
if( !strcmp( "R", horizontal ) )
return GR_TEXT_HJUSTIFY_RIGHT;
return GR_TEXT_H_ALIGN_RIGHT;
return GR_TEXT_HJUSTIFY_CENTER;
return GR_TEXT_H_ALIGN_CENTER;
}
static EDA_TEXT_VJUSTIFY_T vertJustify( const char* vertical )
static GR_TEXT_V_ALIGN_T vertJustify( const char* vertical )
{
if( !strcmp( "T", vertical ) )
return GR_TEXT_VJUSTIFY_TOP;
return GR_TEXT_V_ALIGN_TOP;
if( !strcmp( "B", vertical ) )
return GR_TEXT_VJUSTIFY_BOTTOM;
return GR_TEXT_V_ALIGN_BOTTOM;
return GR_TEXT_VJUSTIFY_CENTER;
return GR_TEXT_V_ALIGN_CENTER;
}
@ -2047,7 +2047,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT()
else
{
// boom, somebody changed a constructor, I was relying on this:
wxASSERT( pcbtxt->GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER );
wxASSERT( pcbtxt->GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER );
}
if( vJustify )

View File

@ -468,40 +468,40 @@ void SetTextJustify( EDA_TEXT* aText, TTEXT_JUSTIFY aJustify )
switch( aJustify )
{
case LowerLeft:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case LowerCenter:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case LowerRight:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case UpperLeft:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case UpperCenter:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case UpperRight:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case Left:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case Center:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break;
case Right:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
}
}

View File

@ -224,8 +224,8 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const wxPoint&
headStyle->SetItalic( false );
headStyle->SetTextPos( wxPoint( 0, 0 ) );
headStyle->SetText( "Layer" );
headStyle->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
headStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
headStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
headStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
// Style : data
PCB_TEXT* dataStyle = new PCB_TEXT( static_cast<FOOTPRINT*>( m_frame->GetModel() ) );
@ -235,8 +235,8 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const wxPoint&
dataStyle->SetItalic( false );
dataStyle->SetTextPos( wxPoint( 0, 0 ) );
dataStyle->SetText( "Layer" );
dataStyle->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
dataStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
dataStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
dataStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
//Get Layer names
BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
@ -388,8 +388,8 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint&
headStyle->SetTextThickness( Millimeter2iu( 0.4 ) );
headStyle->SetItalic( false );
headStyle->SetTextPos( wxPoint( 0, 0 ) );
headStyle->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
headStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
headStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
headStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
// Style : Data
PCB_TEXT* dataStyle = new PCB_TEXT( static_cast<FOOTPRINT*>( m_frame->GetModel() ) );
@ -398,8 +398,8 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint&
dataStyle->SetTextThickness( Millimeter2iu( 0.2 ) );
dataStyle->SetItalic( false );
dataStyle->SetTextPos( wxPoint( 0, 0 ) );
dataStyle->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
dataStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
dataStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
dataStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
PCB_TEXT* t;

View File

@ -675,7 +675,8 @@ static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOA
if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
continue;
text->SetTextAngle( text->GetTextAngle() + aClipFootprint->GetOrientation() );
text->SetTextAngle( text->GetTextAngle().AsTenthsOfADegree()
+ aClipFootprint->GetOrientation() );
text->SetParent( nullptr );
text->SetLocalCoord();
@ -785,7 +786,7 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
// Convert to PCB_FP_TEXT_T
FP_TEXT* pastedTextItem = new FP_TEXT( editorFootprint );
static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
static_cast<EDA_TEXT*>( pastedTextItem )->SwapAttributes( *clipTextItem );
pastedTextItem->SetParent( editorFootprint );
pastedItems.push_back( pastedTextItem );