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 plugins/eagle/eagle_parser.cpp
) )
set( FONT_SRCS
)
set( COMMON_SRCS set( COMMON_SRCS
${LIB_KICAD_SRCS} ${LIB_KICAD_SRCS}
${COMMON_ABOUT_DLG_SRCS} ${COMMON_ABOUT_DLG_SRCS}
@ -307,6 +310,7 @@ set( COMMON_SRCS
${PLUGINS_ALTIUM_SRCS} ${PLUGINS_ALTIUM_SRCS}
${PLUGINS_CADSTAR_SRCS} ${PLUGINS_CADSTAR_SRCS}
${PLUGINS_EAGLE_SRCS} ${PLUGINS_EAGLE_SRCS}
${FONT_SRCS}
advanced_config.cpp advanced_config.cpp
array_axis.cpp array_axis.cpp
array_options.cpp array_options.cpp
@ -325,6 +329,7 @@ set( COMMON_SRCS
dialog_shim.cpp dialog_shim.cpp
gr_text.cpp gr_text.cpp
dsnlexer.cpp dsnlexer.cpp
eda_angle.cpp
eda_base_frame.cpp eda_base_frame.cpp
eda_dde.cpp eda_dde.cpp
eda_doc.cpp eda_doc.cpp

View File

@ -729,24 +729,24 @@ void DRAWING_SHEET_PARSER::parseText( DS_DATA_ITEM_TEXT* aItem )
switch( token ) switch( token )
{ {
case T_center: case T_center:
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_CENTER; aItem->m_Hjustify = GR_TEXT_H_ALIGN_CENTER;
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER; aItem->m_Vjustify = GR_TEXT_V_ALIGN_CENTER;
break; break;
case T_left: case T_left:
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_LEFT; aItem->m_Hjustify = GR_TEXT_H_ALIGN_LEFT;
break; break;
case T_right: case T_right:
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_RIGHT; aItem->m_Hjustify = GR_TEXT_H_ALIGN_RIGHT;
break; break;
case T_top: case T_top:
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_TOP; aItem->m_Vjustify = GR_TEXT_V_ALIGN_TOP;
break; break;
case T_bottom: case T_bottom:
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; aItem->m_Vjustify = GR_TEXT_V_ALIGN_BOTTOM;
break; break;
default: default:

View File

@ -523,8 +523,8 @@ DS_DATA_ITEM_TEXT::DS_DATA_ITEM_TEXT( const wxString& aTextBase ) :
{ {
m_TextBase = aTextBase; m_TextBase = aTextBase;
m_IncrementLabel = 1; m_IncrementLabel = 1;
m_Hjustify = GR_TEXT_HJUSTIFY_LEFT; m_Hjustify = GR_TEXT_H_ALIGN_LEFT;
m_Vjustify = GR_TEXT_VJUSTIFY_CENTER; m_Vjustify = GR_TEXT_V_ALIGN_CENTER;
m_Italic = false; m_Italic = false;
m_Bold = false; m_Bold = false;
m_Orient = 0.0; 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 // 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" ); m_out->Print( 0, " (justify" );
// Write T_center opt first, because it is // Write T_center opt first, because it is
// also a center for both m_Hjustify and m_Vjustify // 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" ); 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" ); 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" ); 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, " bottom" );
m_out->Print( 0, ")" ); 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->Save();
m_gal->Translate( position ); 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->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
m_gal->SetLineWidth( penWidth ); m_gal->SetLineWidth( penWidth );
m_gal->SetTextAttributes( aItem ); 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 ) if( aHorizJustify > GR_TEXT_H_ALIGN_RIGHT )
return GR_TEXT_HJUSTIFY_RIGHT; return GR_TEXT_H_ALIGN_RIGHT;
if( aHorizJustify < GR_TEXT_HJUSTIFY_LEFT ) if( aHorizJustify < GR_TEXT_H_ALIGN_LEFT )
return GR_TEXT_HJUSTIFY_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 ) if( aVertJustify > GR_TEXT_V_ALIGN_BOTTOM )
return GR_TEXT_VJUSTIFY_BOTTOM; return GR_TEXT_V_ALIGN_BOTTOM;
if( aVertJustify < GR_TEXT_VJUSTIFY_TOP ) if( aVertJustify < GR_TEXT_V_ALIGN_TOP )
return GR_TEXT_VJUSTIFY_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 ) : EDA_TEXT::EDA_TEXT( const wxString& text ) :
m_text( text ), m_text( text )
m_e( 1 << TE_VISIBLE )
{ {
int sz = Mils2iu( DEFAULT_SIZE_TEXT ); int sz = Mils2iu( DEFAULT_SIZE_TEXT );
SetTextSize( wxSize( sz, sz ) ); SetTextSize( wxSize( sz, sz ) );
@ -110,7 +109,7 @@ EDA_TEXT::EDA_TEXT( const wxString& text ) :
EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) : EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) :
m_text( aText.m_text ), m_text( aText.m_text ),
m_e( aText.m_e ) m_attributes( aText.m_attributes )
{ {
cacheShownText(); 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() ) switch( GetHorizJustify() )
{ {
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_H_ALIGN_LEFT:
if( IsMirrored() ) if( IsMirrored() )
rect.SetX( rect.GetX() - rect.GetWidth() ); rect.SetX( rect.GetX() - rect.GetWidth() );
break; break;
case GR_TEXT_HJUSTIFY_CENTER: case GR_TEXT_H_ALIGN_CENTER:
rect.SetX( rect.GetX() - (rect.GetWidth() / 2) ); rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
break; break;
case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_H_ALIGN_RIGHT:
if( !IsMirrored() ) if( !IsMirrored() )
rect.SetX( rect.GetX() - rect.GetWidth() ); rect.SetX( rect.GetX() - rect.GetWidth() );
break; break;
@ -345,14 +346,14 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
switch( GetVertJustify() ) switch( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_V_ALIGN_TOP:
break; break;
case GR_TEXT_VJUSTIFY_CENTER: case GR_TEXT_V_ALIGN_CENTER:
rect.SetY( rect.GetY() - ( dy / 2) ); rect.SetY( rect.GetY() - ( dy / 2) );
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_V_ALIGN_BOTTOM:
rect.SetY( rect.GetY() - dy ); rect.SetY( rect.GetY() - dy );
break; break;
} }
@ -364,15 +365,15 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
switch( GetVertJustify() ) switch( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_V_ALIGN_TOP:
break; break;
case GR_TEXT_VJUSTIFY_CENTER: case GR_TEXT_V_ALIGN_CENTER:
yoffset = linecount * GetInterline() / 2; yoffset = linecount * GetInterline() / 2;
rect.SetY( rect.GetY() - yoffset ); rect.SetY( rect.GetY() - yoffset );
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_V_ALIGN_BOTTOM:
yoffset = linecount * GetInterline(); yoffset = linecount * GetInterline();
rect.SetY( rect.GetY() - yoffset ); rect.SetY( rect.GetY() - yoffset );
break; break;
@ -395,7 +396,7 @@ bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
wxPoint location = aPoint; wxPoint location = aPoint;
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
RotatePoint( &location, GetTextPos(), -GetTextAngle() ); RotatePoint( &location, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
return rect.Contains( location ); return rect.Contains( location );
} }
@ -410,7 +411,7 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
if( aContains ) if( aContains )
return rect.Contains( GetTextBox() ); 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() ) switch( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_V_ALIGN_TOP:
break; break;
case GR_TEXT_VJUSTIFY_CENTER: case GR_TEXT_V_ALIGN_CENTER:
pos.y -= ( aLineCount - 1 ) * offset.y / 2; pos.y -= ( aLineCount - 1 ) * offset.y / 2;
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_V_ALIGN_BOTTOM:
pos.y -= ( aLineCount - 1 ) * offset.y; pos.y -= ( aLineCount - 1 ) * offset.y;
break; break;
} }
@ -466,10 +467,10 @@ void EDA_TEXT::GetLinePositions( std::vector<wxPoint>& aPositions, int aLineCoun
// Rotate the position of the first line // Rotate the position of the first line
// around the center of the multiline text block // 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 // 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++ ) for( int ii = 0; ii < aLineCount; ii++ )
{ {
@ -523,8 +524,8 @@ bool EDA_TEXT::IsDefaultFormatting() const
{ {
return ( IsVisible() return ( IsVisible()
&& !IsMirrored() && !IsMirrored()
&& GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER && GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER
&& GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER && GetVertJustify() == GR_TEXT_V_ALIGN_CENTER
&& GetTextThickness() == 0 && GetTextThickness() == 0
&& !IsItalic() && !IsItalic()
&& !IsBold() && !IsBold()
@ -541,9 +542,9 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
aFormatter->Print( aNestLevel + 1, "(effects" ); aFormatter->Print( aNestLevel + 1, "(effects" );
// Text size
aFormatter->Print( 0, " (font" ); aFormatter->Print( 0, " (font" );
// Text size
aFormatter->Print( 0, " (size %s %s)", aFormatter->Print( 0, " (size %s %s)",
FormatInternalUnits( GetTextHeight() ).c_str(), FormatInternalUnits( GetTextHeight() ).c_str(),
FormatInternalUnits( GetTextWidth() ).c_str() ); FormatInternalUnits( GetTextWidth() ).c_str() );
@ -562,16 +563,16 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
aFormatter->Print( 0, ")"); // (font aFormatter->Print( 0, ")"); // (font
if( IsMirrored() || GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER if( IsMirrored() || GetHorizJustify() != GR_TEXT_H_ALIGN_CENTER
|| GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER ) || GetVertJustify() != GR_TEXT_V_ALIGN_CENTER )
{ {
aFormatter->Print( 0, " (justify"); aFormatter->Print( 0, " (justify");
if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER ) if( GetHorizJustify() != GR_TEXT_H_ALIGN_CENTER )
aFormatter->Print( 0, GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ? " left" : " right" ); aFormatter->Print( 0, GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ? " left" : " right" );
if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER ) if( GetVertJustify() != GR_TEXT_V_ALIGN_CENTER )
aFormatter->Print( 0, GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ? " top" : " bottom" ); aFormatter->Print( 0, GetVertJustify() == GR_TEXT_V_ALIGN_TOP ? " top" : " bottom" );
if( IsMirrored() ) if( IsMirrored() )
aFormatter->Print( 0, " mirror" ); 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_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 ); } #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_PT( m_attributes.m_Size, aOther->m_attributes.m_Size );
TEST_E( m_e.penwidth, aOther->m_e.penwidth ); TEST_E( m_attributes.m_StrokeWidth, aOther->m_attributes.m_StrokeWidth );
TEST( m_e.angle, aOther->m_e.angle ); 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_attributes.m_Halign, aOther->m_attributes.m_Halign );
TEST( m_e.vjustify, aOther->m_e.vjustify ); TEST( m_attributes.m_Valign, aOther->m_attributes.m_Valign );
TEST( m_e.bits, aOther->m_e.bits ); 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 ); return m_text.Cmp( aOther->m_text );
} }
@ -715,7 +723,7 @@ void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCorn
for( wxPoint& corner : corners ) for( wxPoint& corner : corners )
{ {
// Rotate polygon // Rotate polygon
RotatePoint( &corner.x, &corner.y, GetTextPos().x, GetTextPos().y, GetTextAngle() ); RotatePoint( &corner, GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
aCornerBuffer->Append( corner.x, corner.y ); aCornerBuffer->Append( corner.x, corner.y );
} }
} }
@ -725,14 +733,14 @@ static struct EDA_TEXT_DESC
{ {
EDA_TEXT_DESC() EDA_TEXT_DESC()
{ {
ENUM_MAP<EDA_TEXT_HJUSTIFY_T>::Instance() ENUM_MAP<GR_TEXT_H_ALIGN_T>::Instance()
.Map( GR_TEXT_HJUSTIFY_LEFT, _HKI( "Left" ) ) .Map( GR_TEXT_H_ALIGN_LEFT, _HKI( "Left" ) )
.Map( GR_TEXT_HJUSTIFY_CENTER, _HKI( "Center" ) ) .Map( GR_TEXT_H_ALIGN_CENTER, _HKI( "Center" ) )
.Map( GR_TEXT_HJUSTIFY_RIGHT, _HKI( "Right" ) ); .Map( GR_TEXT_H_ALIGN_RIGHT, _HKI( "Right" ) );
ENUM_MAP<EDA_TEXT_VJUSTIFY_T>::Instance() ENUM_MAP<GR_TEXT_V_ALIGN_T>::Instance()
.Map( GR_TEXT_VJUSTIFY_TOP, _HKI( "Top" ) ) .Map( GR_TEXT_V_ALIGN_TOP, _HKI( "Top" ) )
.Map( GR_TEXT_VJUSTIFY_CENTER, _HKI( "Center" ) ) .Map( GR_TEXT_V_ALIGN_CENTER, _HKI( "Center" ) )
.Map( GR_TEXT_VJUSTIFY_BOTTOM, _HKI( "Bottom" ) ); .Map( GR_TEXT_V_ALIGN_BOTTOM, _HKI( "Bottom" ) );
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( EDA_TEXT ); REGISTER_TYPE( EDA_TEXT );
@ -762,15 +770,15 @@ static struct EDA_TEXT_DESC
&EDA_TEXT::GetTextHeight, &EDA_TEXT::GetTextHeight,
PROPERTY_DISPLAY::DISTANCE ) ); PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT, 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::SetHorizJustify,
&EDA_TEXT::GetHorizJustify ) ); &EDA_TEXT::GetHorizJustify ) );
propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT, 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::SetVertJustify,
&EDA_TEXT::GetVertJustify ) ); &EDA_TEXT::GetVertJustify ) );
} }
} _EDA_TEXT_DESC; } _EDA_TEXT_DESC;
ENUM_TO_WXANY( EDA_TEXT_HJUSTIFY_T ) ENUM_TO_WXANY( GR_TEXT_H_ALIGN_T )
ENUM_TO_WXANY( EDA_TEXT_VJUSTIFY_T ) ENUM_TO_WXANY( GR_TEXT_V_ALIGN_T )

View File

@ -170,8 +170,8 @@ void GAL::ResetTextAttributes()
// there is no built-in default // there is no built-in default
SetGlyphSize( { 1.0, 1.0 } ); SetGlyphSize( { 1.0, 1.0 } );
SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
SetFontBold( false ); SetFontBold( false );
SetFontItalic( false ); SetFontItalic( false );

View File

@ -1299,16 +1299,16 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
switch( GetHorizontalJustify() ) switch( GetHorizontalJustify() )
{ {
case GR_TEXT_HJUSTIFY_CENTER: case GR_TEXT_H_ALIGN_CENTER:
Translate( VECTOR2D( -textSize.x / 2.0, 0 ) ); Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
break; break;
case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_H_ALIGN_RIGHT:
//if( !IsTextMirrored() ) //if( !IsTextMirrored() )
Translate( VECTOR2D( -textSize.x, 0 ) ); Translate( VECTOR2D( -textSize.x, 0 ) );
break; break;
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_H_ALIGN_LEFT:
//if( IsTextMirrored() ) //if( IsTextMirrored() )
//Translate( VECTOR2D( -textSize.x, 0 ) ); //Translate( VECTOR2D( -textSize.x, 0 ) );
break; break;
@ -1316,17 +1316,17 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
switch( GetVerticalJustify() ) switch( GetVerticalJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_V_ALIGN_TOP:
Translate( VECTOR2D( 0, -textSize.y ) ); Translate( VECTOR2D( 0, -textSize.y ) );
overbarHeight = -textSize.y / 2.0; overbarHeight = -textSize.y / 2.0;
break; break;
case GR_TEXT_VJUSTIFY_CENTER: case GR_TEXT_V_ALIGN_CENTER:
Translate( VECTOR2D( 0, -textSize.y / 2.0 ) ); Translate( VECTOR2D( 0, -textSize.y / 2.0 ) );
overbarHeight = 0; overbarHeight = 0;
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_V_ALIGN_BOTTOM:
break; 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 // align the 1st line of text
switch( m_gal->GetVerticalJustify() ) switch( m_gal->GetVerticalJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_V_ALIGN_TOP:
m_gal->Translate( VECTOR2D( 0, glyphSize.y ) ); m_gal->Translate( VECTOR2D( 0, glyphSize.y ) );
break; break;
case GR_TEXT_VJUSTIFY_CENTER: case GR_TEXT_V_ALIGN_CENTER:
m_gal->Translate( VECTOR2D( 0, glyphSize.y / 2.0 ) ); m_gal->Translate( VECTOR2D( 0, glyphSize.y / 2.0 ) );
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_V_ALIGN_BOTTOM:
break; break;
default: default:
@ -226,14 +226,14 @@ void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRo
{ {
switch( m_gal->GetVerticalJustify() ) switch( m_gal->GetVerticalJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_V_ALIGN_TOP:
break; break;
case GR_TEXT_VJUSTIFY_CENTER: case GR_TEXT_V_ALIGN_CENTER:
m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight / 2) ); m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight / 2) );
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_V_ALIGN_BOTTOM:
m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight ) ); m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight ) );
break; break;
} }
@ -295,16 +295,16 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText )
// Adjust the text position to the given horizontal justification // Adjust the text position to the given horizontal justification
switch( m_gal->GetHorizontalJustify() ) switch( m_gal->GetHorizontalJustify() )
{ {
case GR_TEXT_HJUSTIFY_CENTER: case GR_TEXT_H_ALIGN_CENTER:
m_gal->Translate( VECTOR2D( -textSize.x / 2.0, 0 ) ); m_gal->Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
break; break;
case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_H_ALIGN_RIGHT:
if( !m_gal->IsTextMirrored() ) if( !m_gal->IsTextMirrored() )
m_gal->Translate( VECTOR2D( -textSize.x, 0 ) ); m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
break; break;
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_H_ALIGN_LEFT:
if( m_gal->IsTextMirrored() ) if( m_gal->IsTextMirrored() )
m_gal->Translate( VECTOR2D( -textSize.x, 0 ) ); m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
break; break;

View File

@ -31,7 +31,6 @@
#include <gr_basic.h> #include <gr_basic.h>
#include <plotters/plotter.h> #include <plotters/plotter.h>
#include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T
#include <trigo.h> #include <trigo.h>
#include <base_screen.h> #include <base_screen.h>
#include <math/util.h> // for KiROUND #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 aPos is the text position (according to h_justify, v_justify).
* @param aColor is the text color. * @param aColor is the text color.
* @param aText is the text to draw. * @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 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 aH_justify is the horizontal justification (Left, center, right).
* @param aV_justify is the vertical justification (bottom, center, top). * @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. * the text. NULL to draw this text.
*/ */
void GRText( wxDC* aDC, const wxPoint& aPos, const COLOR4D& aColor, const wxString& aText, 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, const EDA_ANGLE& aOrient, const wxSize& aSize, enum GR_TEXT_H_ALIGN_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, 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 (* aCallback)( int x0, int y0, int xf, int yf, void* aData ),
void* aCallbackData, PLOTTER* aPlotter ) 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_DC = aDC;
basic_gal.m_Color = aColor; basic_gal.m_Color = aColor;
basic_gal.SetClipBox( nullptr ); 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 ) if( aFlags & HASH_ROT )
hash_combine( ret, text->GetTextAngle() ); hash_combine( ret, text->GetTextAngle().AsTenthsOfADegree() );
} }
break; break;

View File

@ -831,10 +831,10 @@ bool containsNonAsciiChars( const wxString& string )
void DXF_PLOTTER::Text( const wxPoint& aPos, void DXF_PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor, const COLOR4D& aColor,
const wxString& aText, const wxString& aText,
double aOrient, const EDA_ANGLE& aOrient,
const wxSize& aSize, const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum GR_TEXT_H_ALIGN_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth, int aWidth,
bool aItalic, bool aItalic,
bool aBold, bool aBold,
@ -852,8 +852,8 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
// output text as graphics. // output text as graphics.
// Perhaps multiline texts could be handled as DXF text entity // Perhaps multiline texts could be handled as DXF text entity
// but I do not want spend time about this (JPC) // but I do not want spend time about this (JPC)
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth,
aWidth, aItalic, aBold, aMultilineAllowed ); aItalic, aBold, aMultilineAllowed, aData );
} }
else else
{ {
@ -867,72 +867,59 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
switch( aH_justify ) switch( aH_justify )
{ {
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_H_ALIGN_LEFT: h_code = 0; break;
h_code = 0; case GR_TEXT_H_ALIGN_CENTER: h_code = 1; break;
break; case GR_TEXT_H_ALIGN_RIGHT: h_code = 2; break;
case GR_TEXT_HJUSTIFY_CENTER:
h_code = 1;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
h_code = 2;
break;
} }
switch( aV_justify ) switch( aV_justify )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_V_ALIGN_TOP: v_code = 3; break;
v_code = 3; case GR_TEXT_V_ALIGN_CENTER: v_code = 2; break;
break; case GR_TEXT_V_ALIGN_BOTTOM: v_code = 1; break;
case GR_TEXT_VJUSTIFY_CENTER:
v_code = 2;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
v_code = 1;
break;
} }
// Position, size, rotation and alignment // Position, size, rotation and alignment
// The two alignment point usages is somewhat idiot (see the DXF ref) // The two alignment point usages is somewhat idiot (see the DXF ref)
// Anyway since we don't use the fit/aligned options, they're the same // Anyway since we don't use the fit/aligned options, they're the same
fprintf( m_outputFile, fprintf( m_outputFile,
" 0\n" " 0\n"
"TEXT\n" "TEXT\n"
" 7\n" " 7\n"
"%s\n" // Text style "%s\n" // Text style
" 8\n" " 8\n"
"%s\n" // Layer name "%s\n" // Layer name
" 10\n" " 10\n"
"%g\n" // First point X "%g\n" // First point X
" 11\n" " 11\n"
"%g\n" // Second point X "%g\n" // Second point X
" 20\n" " 20\n"
"%g\n" // First point Y "%g\n" // First point Y
" 21\n" " 21\n"
"%g\n" // Second point Y "%g\n" // Second point Y
" 40\n" " 40\n"
"%g\n" // Text height "%g\n" // Text height
" 41\n" " 41\n"
"%g\n" // Width factor "%g\n" // Width factor
" 50\n" " 50\n"
"%g\n" // Rotation "%g\n" // Rotation
" 51\n" " 51\n"
"%g\n" // Oblique angle "%g\n" // Oblique angle
" 71\n" " 71\n"
"%d\n" // Mirror flags "%d\n" // Mirror flags
" 72\n" " 72\n"
"%d\n" // H alignment "%d\n" // H alignment
" 73\n" " 73\n"
"%d\n", // V alignment "%d\n", // V alignment
aBold ? (aItalic ? "KICADBI" : "KICADB") aBold ? (aItalic ? "KICADBI" : "KICADB") : (aItalic ? "KICADI" : "KICAD"),
: (aItalic ? "KICADI" : "KICAD"),
TO_UTF8( cname ), TO_UTF8( cname ),
origin_dev.x, origin_dev.x, origin_dev.x, origin_dev.x,
origin_dev.y, origin_dev.y, origin_dev.y, origin_dev.y,
size_dev.y, fabs( size_dev.x / size_dev.y ), size_dev.y, fabs( size_dev.x / size_dev.y ),
aOrient / 10.0, aOrient.AsDegrees(),
aItalic ? DXF_OBLIQUE_ANGLE : 0, aItalic ? DXF_OBLIQUE_ANGLE : 0,
size_dev.x < 0 ? 2 : 0, // X mirror flag size_dev.x < 0 ? 2 : 0, // X mirror flag
h_code, v_code ); h_code, v_code );
/* There are two issue in emitting the text: /* There are two issue in emitting the text:
- Our overline character (~) must be converted to the appropriate - Our overline character (~) must be converted to the appropriate

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, void GERBER_PLOTTER::Text( const wxPoint& aPos,
const wxString& aText, double aOrient, const wxSize& aSize, const COLOR4D& aColor,
enum EDA_TEXT_HJUSTIFY_T aH_justify, const wxString& aText,
enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, const EDA_ANGLE& aOrient,
bool aBold, bool aMultilineAllowed, void* aData ) 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 ); 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, void PDF_PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor, const COLOR4D& aColor,
const wxString& aText, const wxString& aText,
double aOrient, const EDA_ANGLE& aOrient,
const wxSize& aSize, const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum GR_TEXT_H_ALIGN_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth, int aWidth,
bool aItalic, bool aItalic,
bool aBold, bool aBold,
@ -851,9 +851,8 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
double wideningFactor, heightFactor; double wideningFactor, heightFactor;
computeTextParameters( aPos, aText, aOrient, aSize, m_plotMirror, aH_justify, computeTextParameters( aPos, aText, aOrient, aSize, m_plotMirror, aH_justify,
aV_justify, aWidth, aItalic, aBold, aV_justify, aWidth, aItalic, aBold, &wideningFactor, &ctm_a,
&wideningFactor, &ctm_a, &ctm_b, &ctm_c, &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor );
&ctm_d, &ctm_e, &ctm_f, &heightFactor );
SetColor( aColor ); SetColor( aColor );
SetCurrentLineWidth( aWidth, aData ); 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, void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
const wxString& aText, const wxString& aText,
int aOrient, const EDA_ANGLE& aOrient,
const wxSize& aSize, const wxSize& aSize,
bool aMirror, bool aMirror,
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum GR_TEXT_H_ALIGN_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth, int aWidth,
bool aItalic, bool aItalic,
bool aBold, bool aBold,
@ -463,36 +463,20 @@ void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
switch( aH_justify ) switch( aH_justify )
{ {
case GR_TEXT_HJUSTIFY_CENTER: case GR_TEXT_H_ALIGN_CENTER: dx = -tw / 2; break;
dx = -tw / 2; case GR_TEXT_H_ALIGN_RIGHT: dx = -tw; break;
break; case GR_TEXT_H_ALIGN_LEFT: dx = 0; break;
case GR_TEXT_HJUSTIFY_RIGHT:
dx = -tw;
break;
case GR_TEXT_HJUSTIFY_LEFT:
dx = 0;
break;
} }
switch( aV_justify ) switch( aV_justify )
{ {
case GR_TEXT_VJUSTIFY_CENTER: case GR_TEXT_V_ALIGN_CENTER: dy = th / 2; break;
dy = th / 2; case GR_TEXT_V_ALIGN_TOP: dy = th; break;
break; case GR_TEXT_V_ALIGN_BOTTOM: dy = 0; break;
case GR_TEXT_VJUSTIFY_TOP:
dy = th;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
dy = 0;
break;
} }
RotatePoint( &dx, &dy, aOrient ); RotatePoint( &dx, &dy, aOrient.AsTenthsOfADegree() );
RotatePoint( &tw, &th, aOrient ); RotatePoint( &tw, &th, aOrient.AsTenthsOfADegree() );
start_pos.x += dx; start_pos.x += dx;
start_pos.y += dy; start_pos.y += dy;
DPOINT pos_dev = userToDeviceCoordinates( start_pos ); DPOINT pos_dev = userToDeviceCoordinates( start_pos );
@ -503,13 +487,10 @@ void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
// Mirrored texts must be plotted as mirrored! // Mirrored texts must be plotted as mirrored!
if( m_plotMirror ) if( m_plotMirror )
{
*wideningFactor = -*wideningFactor; *wideningFactor = -*wideningFactor;
aOrient = -aOrient;
}
// The CTM transformation matrix // The CTM transformation matrix
double alpha = DECIDEG2RAD( aOrient ); double alpha = m_plotMirror ? aOrient.Invert().AsRadians() : aOrient.AsRadians();
double sinalpha = sin( alpha ); double sinalpha = sin( alpha );
double cosalpha = cos( alpha ); double cosalpha = cos( alpha );
@ -978,17 +959,17 @@ bool PS_PLOTTER::EndPlot()
void PS_PLOTTER::Text( const wxPoint& aPos, void PS_PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor, const COLOR4D& aColor,
const wxString& aText, const wxString& aText,
double aOrient, const EDA_ANGLE& aOrient,
const wxSize& aSize, const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum GR_TEXT_H_ALIGN_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth, int aWidth,
bool aItalic, bool aItalic,
bool aBold, bool aBold,
bool aMultilineAllowed, bool aMultilineAllowed,
void* aData ) void* aData )
{ {
SetCurrentLineWidth( aWidth ); SetCurrentLineWidth( aWidth );
SetColor( aColor ); SetColor( aColor );

View File

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

View File

@ -140,9 +140,9 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
if( aTextQuadrant.x < 0 ) if( aTextQuadrant.x < 0 )
{ {
if( viewFlipped ) if( viewFlipped )
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
else else
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
textPos.x += 15.0 / gal->GetWorldScale(); textPos.x += 15.0 / gal->GetWorldScale();
@ -152,9 +152,9 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
else else
{ {
if( viewFlipped ) if( viewFlipped )
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
else else
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
textPos.x -= 15.0 / gal->GetWorldScale(); 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 ) if( aLine.Angle() > 0 )
{ {
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
} }
else else
{ {
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
labelAngle += M_PI; 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 class AUTOPLACER
{ {
public: public:
@ -204,9 +195,9 @@ protected:
for( SCH_FIELD* field : m_fields ) for( SCH_FIELD* field : m_fields )
{ {
if( m_symbol->GetTransform().y1 ) if( m_symbol->GetTransform().y1 )
field->SetTextAngle( TEXT_ANGLE_VERT ); field->SetTextAngle( EDA_ANGLE::VERTICAL );
else else
field->SetTextAngle( TEXT_ANGLE_HORIZ ); field->SetTextAngle( EDA_ANGLE::HORIZONTAL );
EDA_RECT bbox = field->GetBoundingBox(); EDA_RECT bbox = field->GetBoundingBox();
int field_width = bbox.GetWidth(); int field_width = bbox.GetWidth();
@ -528,7 +519,7 @@ protected:
aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) ); aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x ) );
aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x aField->SetHorizJustify( TO_HJUSTIFY( -aFieldSide.x
* ( aField->IsHorizJustifyFlipped() ? -1 : 1 ) ) ); * ( 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 ) switch( field_hjust )
{ {
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_H_ALIGN_LEFT:
field_xcoord = aFieldBox.GetLeft(); field_xcoord = aFieldBox.GetLeft();
break; break;
case GR_TEXT_HJUSTIFY_CENTER: case GR_TEXT_H_ALIGN_CENTER:
field_xcoord = aFieldBox.Centre().x; field_xcoord = aFieldBox.Centre().x;
break; break;
case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_H_ALIGN_RIGHT:
field_xcoord = aFieldBox.GetRight(); field_xcoord = aFieldBox.GetRight();
break; break;
default: default:

View File

@ -636,11 +636,11 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_
if( resetEffects ) 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(); bool visible = field.IsVisible();
wxPoint pos = field.GetPosition(); wxPoint pos = field.GetPosition();
field.SetEffects( *libField ); field.SetAttributes( *libField );
field.SetVisible( visible ); field.SetVisible( visible );
field.SetPosition( pos ); 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 newField( wxPoint( 0, 0), aSymbol->GetFieldCount(), aSymbol, fieldName );
SCH_FIELD* schField = aSymbol->AddField( newField ); 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->SetText( libField.GetText() );
schField->SetTextPos( aSymbol->GetPosition() + libField.GetTextPos() ); 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_isBold = aTextItem->IsBold();
m_position = aTextItem->GetTextPos(); m_position = aTextItem->GetTextPos();
m_size = aTextItem->GetTextWidth(); m_size = aTextItem->GetTextWidth();
m_isVertical = ( aTextItem->GetTextAngle() == TEXT_ANGLE_VERT ); m_isVertical = aTextItem->GetTextAngle().IsVertical();
m_verticalJustification = aTextItem->GetVertJustify() + 1; m_verticalJustification = aTextItem->GetVertJustify() + 1;
m_horizontalJustification = aTextItem->GetHorizJustify() + 1; m_horizontalJustification = aTextItem->GetHorizJustify() + 1;
m_isVisible = aTextItem->IsVisible(); m_isVisible = aTextItem->IsVisible();
@ -305,16 +305,16 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataToWindow()
switch ( m_horizontalJustification ) switch ( m_horizontalJustification )
{ {
case GR_TEXT_HJUSTIFY_LEFT: m_hAlignLeft->Check( true ); break; case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
case GR_TEXT_HJUSTIFY_CENTER: m_hAlignCenter->Check( true ); break; case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
case GR_TEXT_HJUSTIFY_RIGHT: m_hAlignRight->Check( true ); break; case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
} }
switch ( m_verticalJustification ) switch ( m_verticalJustification )
{ {
case GR_TEXT_VJUSTIFY_TOP: m_vAlignTop->Check( true ); break; case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
case GR_TEXT_VJUSTIFY_CENTER: m_vAlignCenter->Check( true ); break; case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: m_vAlignBottom->Check( true ); break; case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
} }
m_visible->SetValue( m_isVisible ); m_visible->SetValue( m_isVisible );
@ -369,18 +369,18 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataFromWindow()
m_isItalic = m_italic->IsChecked(); m_isItalic = m_italic->IsChecked();
if( m_hAlignLeft->IsChecked() ) if( m_hAlignLeft->IsChecked() )
m_horizontalJustification = GR_TEXT_HJUSTIFY_LEFT; m_horizontalJustification = GR_TEXT_H_ALIGN_LEFT;
else if( m_hAlignCenter->IsChecked() ) else if( m_hAlignCenter->IsChecked() )
m_horizontalJustification = GR_TEXT_HJUSTIFY_CENTER; m_horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
else else
m_horizontalJustification = GR_TEXT_HJUSTIFY_RIGHT; m_horizontalJustification = GR_TEXT_H_ALIGN_RIGHT;
if( m_vAlignTop->IsChecked() ) if( m_vAlignTop->IsChecked() )
m_verticalJustification = GR_TEXT_VJUSTIFY_TOP; m_verticalJustification = GR_TEXT_V_ALIGN_TOP;
else if( m_vAlignCenter->IsChecked() ) else if( m_vAlignCenter->IsChecked() )
m_verticalJustification = GR_TEXT_VJUSTIFY_CENTER; m_verticalJustification = GR_TEXT_V_ALIGN_CENTER;
else else
m_verticalJustification = GR_TEXT_VJUSTIFY_BOTTOM; m_verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
m_isVisible = m_visible->GetValue(); 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->SetTextSize( wxSize( m_size, m_size ) );
aText->SetVisible( m_isVisible ); 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->SetItalic( m_isItalic );
aText->SetBold( m_isBold ); aText->SetBold( m_isBold );
} }
@ -596,14 +596,14 @@ void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH
symbol->SetFootprint( m_text ); symbol->SetFootprint( m_text );
} }
EDA_TEXT_HJUSTIFY_T hJustify = EDA_TEXT::MapHorizJustify( m_horizontalJustification - 1 ); GR_TEXT_H_ALIGN_T hJustify = EDA_TEXT::MapHorizJustify( m_horizontalJustification - 1 );
EDA_TEXT_VJUSTIFY_T vJustify = EDA_TEXT::MapVertJustify( m_verticalJustification - 1 ); GR_TEXT_V_ALIGN_T vJustify = EDA_TEXT::MapVertJustify( m_verticalJustification - 1 );
bool positioningModified = false; bool positioningModified = false;
if( aField->GetPosition() != m_position ) if( aField->GetPosition() != m_position )
positioningModified = true; positioningModified = true;
if( ( aField->GetTextAngle() == TEXT_ANGLE_VERT ) != m_isVertical ) if( aField->GetTextAngle().IsVertical() != m_isVertical )
positioningModified = true; positioningModified = true;
if( aField->GetEffectiveHorizJustify() != hJustify ) if( aField->GetEffectiveHorizJustify() != hJustify )

View File

@ -137,23 +137,23 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow()
m_CommonUnit->SetValue( m_graphicText->GetUnit() == 0 ); m_CommonUnit->SetValue( m_graphicText->GetUnit() == 0 );
m_CommonConvert->SetValue( m_graphicText->GetConvert() == 0 ); m_CommonConvert->SetValue( m_graphicText->GetConvert() == 0 );
if( m_graphicText->GetTextAngle() == TEXT_ANGLE_HORIZ ) if( m_graphicText->GetTextAngle().IsHorizontal() )
m_horizontal->Check(); m_horizontal->Check();
else else
m_vertical->Check(); m_vertical->Check();
switch ( m_graphicText->GetHorizJustify() ) switch ( m_graphicText->GetHorizJustify() )
{ {
case GR_TEXT_HJUSTIFY_LEFT: m_hAlignLeft->Check( true ); break; case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
case GR_TEXT_HJUSTIFY_CENTER: m_hAlignCenter->Check( true ); break; case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
case GR_TEXT_HJUSTIFY_RIGHT: m_hAlignRight->Check( true ); break; case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
} }
switch ( m_graphicText->GetVertJustify() ) switch ( m_graphicText->GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: m_vAlignTop->Check( true ); break; case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
case GR_TEXT_VJUSTIFY_CENTER: m_vAlignCenter->Check( true ); break; case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: m_vAlignBottom->Check( true ); break; case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
} }
} }
else else
@ -166,7 +166,7 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow()
m_CommonUnit->SetValue( !tools->GetDrawSpecificUnit() ); m_CommonUnit->SetValue( !tools->GetDrawSpecificUnit() );
m_CommonConvert->SetValue( !tools->GetDrawSpecificConvert() ); m_CommonConvert->SetValue( !tools->GetDrawSpecificConvert() );
if( tools->GetLastTextAngle() == TEXT_ANGLE_HORIZ ) if( tools->GetLastTextAngle().IsHorizontal() )
m_horizontal->Check(); m_horizontal->Check();
else else
m_vertical->Check(); m_vertical->Check();
@ -221,9 +221,9 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow()
m_graphicText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); m_graphicText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) );
if( m_horizontal->IsChecked() ) if( m_horizontal->IsChecked() )
m_graphicText->SetTextAngle( TEXT_ANGLE_HORIZ ); m_graphicText->SetTextAngle( EDA_ANGLE::HORIZONTAL );
else else
m_graphicText->SetTextAngle( TEXT_ANGLE_VERT ); m_graphicText->SetTextAngle( EDA_ANGLE::VERTICAL );
if( !m_CommonUnit->GetValue() ) if( !m_CommonUnit->GetValue() )
m_graphicText->SetUnit( m_parent->GetUnit() ); m_graphicText->SetUnit( m_parent->GetUnit() );
@ -239,18 +239,18 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow()
m_graphicText->SetBold( m_bold->IsChecked() ); m_graphicText->SetBold( m_bold->IsChecked() );
if( m_hAlignLeft->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() ) else if( m_hAlignCenter->IsChecked() )
m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
else else
m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
if( m_vAlignTop->IsChecked() ) if( m_vAlignTop->IsChecked() )
m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
else if( m_vAlignCenter->IsChecked() ) else if( m_vAlignCenter->IsChecked() )
m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
else else
m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
// Record settings used for next time: // Record settings used for next time:
auto* tools = m_parent->GetToolManager()->GetTool<SYMBOL_EDITOR_DRAWING_TOOLS>(); 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 ) 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(); bool visible = field.IsVisible();
wxPoint pos = field.GetPosition(); wxPoint pos = field.GetPosition();
field.SetEffects( *parentField ); field.SetAttributes( *parentField );
field.SetVisible( visible ); field.SetVisible( visible );
field.SetPosition( pos ); field.SetPosition( pos );
@ -207,7 +207,7 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent )
newField->SetName( parentField->GetCanonicalName() ); newField->SetName( parentField->GetCanonicalName() );
newField->SetText( parentField->GetText() ); 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.SetText( wxT( "U1" ) );
ref.SetPosition( MILS_POINT( p.x + 30, p.y + 260 ) ); 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(); LIB_FIELD& value = symbol->GetValueField();
value.SetText( wxT( "OPA604" ) ); value.SetText( wxT( "OPA604" ) );
value.SetPosition( MILS_POINT( p.x + 30, p.y + 180 ) ); 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->SetShowPinNames( true );
symbol->SetShowPinNumbers( true ); symbol->SetShowPinNumbers( true );

View File

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

View File

@ -73,7 +73,7 @@ LIB_FIELD& LIB_FIELD::operator=( const LIB_FIELD& field )
m_parent = field.m_parent; m_parent = field.m_parent;
SetText( field.GetText() ); SetText( field.GetText() );
SetEffects( field ); SetAttributes( field );
return *this; return *this;
} }
@ -85,7 +85,7 @@ void LIB_FIELD::Init( int aId )
m_id = 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 // 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. // 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 // 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) // 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 ); return tmp_text.TextHitTest( aPosition, aAccuracy );
} }
@ -174,7 +174,7 @@ void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
aTarget->m_name = m_name; aTarget->m_name = m_name;
aTarget->CopyText( *this ); aTarget->CopyText( *this );
aTarget->SetEffects( *this ); aTarget->SetAttributes( *this );
aTarget->SetParent( m_parent ); aTarget->SetParent( m_parent );
} }
@ -280,7 +280,8 @@ void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW )
RotatePoint( &pt, center, rot_angle ); RotatePoint( &pt, center, rot_angle );
SetTextPos( pt ); 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; return;
// Calculate the text orientation, according to the symbol orientation/mirror. // 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( aTransform.y1 ) // Rotate symbol 90 deg.
{ {
if( orient == TEXT_ANGLE_HORIZ ) if( orient.IsHorizontal() )
orient = TEXT_ANGLE_VERT; orient = EDA_ANGLE::VERTICAL;
else else
orient = TEXT_ANGLE_HORIZ; orient = EDA_ANGLE::HORIZONTAL;
} }
EDA_RECT bbox = GetBoundingBox(); EDA_RECT bbox = GetBoundingBox();
bbox.RevertYAxis(); bbox.RevertYAxis();
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER; GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_CENTER;
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; GR_TEXT_V_ALIGN_T vjustify = GR_TEXT_V_ALIGN_CENTER;
wxPoint textpos = aTransform.TransformCoordinate( bbox.Centre() ) + aOffset; wxPoint textpos = aTransform.TransformCoordinate( bbox.Centre() ) + aOffset;
COLOR4D color; COLOR4D color;
@ -351,8 +352,8 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const
wxPoint orig = rect.GetOrigin(); wxPoint orig = rect.GetOrigin();
wxPoint end = rect.GetEnd(); wxPoint end = rect.GetEnd();
RotatePoint( &orig, GetTextPos(), -GetTextAngle() ); RotatePoint( &orig, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
RotatePoint( &end, GetTextPos(), -GetTextAngle() ); RotatePoint( &end, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
rect.SetOrigin( orig ); rect.SetOrigin( orig );
rect.SetEnd( end ); rect.SetEnd( end );
@ -468,18 +469,18 @@ void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
switch ( GetHorizJustify() ) switch ( GetHorizJustify() )
{ {
case GR_TEXT_HJUSTIFY_LEFT: msg = _( "Left" ); break; case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
case GR_TEXT_HJUSTIFY_CENTER: msg = _( "Center" ); break; case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_HJUSTIFY_RIGHT: msg = _( "Right" ); break; case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
} }
aList.emplace_back( _( "H Justification" ), msg ); aList.emplace_back( _( "H Justification" ), msg );
switch ( GetVertJustify() ) switch ( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: msg = _( "Top" ); break; case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
case GR_TEXT_VJUSTIFY_CENTER: msg = _( "Center" ); break; case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: msg = _( "Bottom" ); break; case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
} }
aList.emplace_back( _( "V Justification" ), msg ); 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 ) if( aPinOrient == PIN_RIGHT )
{ {
x = x1 + aTextInside; x = x1 + aTextInside;
GRText( DC, wxPoint( x, y1 ), NameColor, name, TEXT_ANGLE_HORIZ, PinNameSize, GRText( DC, wxPoint( x, y1 ), NameColor, name, EDA_ANGLE::HORIZONTAL,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, false, PinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth,
false ); false, false );
} }
else // Orient == PIN_LEFT else // Orient == PIN_LEFT
{ {
x = x1 - aTextInside; x = x1 - aTextInside;
GRText( DC, wxPoint( x, y1 ), NameColor, name, TEXT_ANGLE_HORIZ, PinNameSize, GRText( DC, wxPoint( x, y1 ), NameColor, name, EDA_ANGLE::HORIZONTAL,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, false, PinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth,
false ); false, false );
} }
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
GRText( DC, wxPoint(( x1 + aPinPos.x) / 2, y1 - num_offset ), NumColor, number, GRText( DC, wxPoint(( x1 + aPinPos.x) / 2, y1 - num_offset ), NumColor, number,
TEXT_ANGLE_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, EDA_ANGLE::HORIZONTAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
} }
} }
else /* Its a vertical line. */ else /* Its a vertical line. */
@ -423,16 +423,16 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos,
if( aDrawPinName ) if( aDrawPinName )
{ {
GRText( DC, wxPoint( x1, y ), NameColor, name, TEXT_ANGLE_VERT, PinNameSize, GRText( DC, wxPoint( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, false, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false,
false ); false );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
GRText( DC, wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor, GRText( DC, wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
number, TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, number, EDA_ANGLE::VERTICAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
} }
} }
else /* PIN_UP */ else /* PIN_UP */
@ -441,16 +441,16 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos,
if( aDrawPinName ) if( aDrawPinName )
{ {
GRText( DC, wxPoint( x1, y ), NameColor, name, TEXT_ANGLE_VERT, PinNameSize, GRText( DC, wxPoint( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, false, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false,
false ); false );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
GRText( DC, wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor, GRText( DC, wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
number, TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, number, EDA_ANGLE::VERTICAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
} }
} }
} }
@ -463,15 +463,15 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos,
if( aDrawPinName ) if( aDrawPinName )
{ {
x = ( x1 + aPinPos.x) / 2; x = ( x1 + aPinPos.x) / 2;
GRText( DC, wxPoint( x, y1 - name_offset ), NameColor, name, TEXT_ANGLE_HORIZ, GRText( DC, wxPoint( x, y1 - name_offset ), NameColor, name, EDA_ANGLE::HORIZONTAL,
PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, PinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
namePenWidth, false, false ); namePenWidth, false, false );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
x = ( x1 + aPinPos.x) / 2; x = ( x1 + aPinPos.x) / 2;
GRText( DC, wxPoint( x, y1 + num_offset ), NumColor, number, TEXT_ANGLE_HORIZ, GRText( DC, wxPoint( x, y1 + num_offset ), NumColor, number, EDA_ANGLE::HORIZONTAL,
PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, numPenWidth, PinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, numPenWidth,
false, false ); false, false );
} }
} }
@ -480,15 +480,15 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos,
if( aDrawPinName ) if( aDrawPinName )
{ {
y = ( y1 + aPinPos.y) / 2; y = ( y1 + aPinPos.y) / 2;
GRText( DC, wxPoint( x1 - name_offset, y ), NameColor, name, TEXT_ANGLE_VERT, GRText( DC, wxPoint( x1 - name_offset, y ), NameColor, name, EDA_ANGLE::VERTICAL,
PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, PinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
namePenWidth, false, false ); namePenWidth, false, false );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
GRText( DC, wxPoint( x1 + num_offset, ( y1 + aPinPos.y) / 2 ), NumColor, number, 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 ); numPenWidth, false, false );
} }
} }
@ -519,20 +519,20 @@ void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, wxPo
wxPoint txtpos = aPosition; wxPoint txtpos = aPosition;
int offset = Millimeter2iu( 0.4 ); int offset = Millimeter2iu( 0.4 );
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_LEFT; GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_LEFT;
int orient = TEXT_ANGLE_HORIZ; EDA_ANGLE orient = EDA_ANGLE::HORIZONTAL;
switch( aOrientation ) switch( aOrientation )
{ {
case PIN_UP: case PIN_UP:
txtpos.y += offset; txtpos.y += offset;
orient = TEXT_ANGLE_VERT; orient = EDA_ANGLE::VERTICAL;
hjustify = GR_TEXT_HJUSTIFY_RIGHT; hjustify = GR_TEXT_H_ALIGN_RIGHT;
break; break;
case PIN_DOWN: case PIN_DOWN:
txtpos.y -= offset; txtpos.y -= offset;
orient = TEXT_ANGLE_VERT; orient = EDA_ANGLE::VERTICAL;
break; break;
case PIN_LEFT: case PIN_LEFT:
@ -541,12 +541,12 @@ void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, wxPo
case PIN_RIGHT: case PIN_RIGHT:
txtpos.x -= offset; txtpos.x -= offset;
hjustify = GR_TEXT_HJUSTIFY_RIGHT; hjustify = GR_TEXT_H_ALIGN_RIGHT;
break; break;
} }
GRText( DC, txtpos, color, typeName, orient, wxSize( textSize, textSize ), hjustify, 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, void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinOrient,
bool aDrawPinNum, bool aDrawPinName ) const int aTextInside, bool aDrawPinNum, bool aDrawPinName ) const
{ {
wxString name = GetShownName(); wxString name = GetShownName();
wxString number = GetShownNumber(); wxString number = GetShownNumber();
@ -728,27 +728,27 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO
{ {
if( aDrawPinName ) if( aDrawPinName )
{ {
EDA_TEXT_HJUSTIFY_T hjustify; GR_TEXT_H_ALIGN_T hjustify;
if( aPinOrient == PIN_RIGHT ) if( aPinOrient == PIN_RIGHT )
{ {
x = x1 + aTextInside; x = x1 + aTextInside;
hjustify = GR_TEXT_HJUSTIFY_LEFT; hjustify = GR_TEXT_H_ALIGN_LEFT;
} }
else // orient == PIN_LEFT else // orient == PIN_LEFT
{ {
x = x1 - aTextInside; 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, aPlotter->Text( wxPoint( x, y1 ), nameColor, name, EDA_ANGLE::HORIZONTAL,
hjustify, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, pinNameSize, hjustify, GR_TEXT_V_ALIGN_CENTER, namePenWidth,
false, false ); false, false );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
aPlotter->Text( wxPoint( ( x1 + aPinPos.x) / 2, y1 - num_offset ), numColor, aPlotter->Text( wxPoint( ( x1 + aPinPos.x) / 2, y1 - num_offset ), numColor,
number, TEXT_ANGLE_HORIZ, pinNumSize, GR_TEXT_HJUSTIFY_CENTER, number, EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
} }
} }
else /* Its a vertical line. */ else /* Its a vertical line. */
@ -758,15 +758,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO
y = y1 + aTextInside; y = y1 + aTextInside;
if( aDrawPinName ) if( aDrawPinName )
aPlotter->Text( wxPoint( x1, y ), nameColor, name, TEXT_ANGLE_VERT, aPlotter->Text( wxPoint( x1, y ), nameColor, name, EDA_ANGLE::VERTICAL,
pinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER,
namePenWidth, false, false ); namePenWidth, false, false );
if( aDrawPinNum ) if( aDrawPinNum )
{ {
aPlotter->Text( wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor, aPlotter->Text( wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor,
number, TEXT_ANGLE_VERT, pinNumSize, GR_TEXT_HJUSTIFY_CENTER, number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
} }
} }
else /* PIN_UP */ else /* PIN_UP */
@ -775,16 +775,16 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const wxPoint& aPinPos, int aPinO
if( aDrawPinName ) if( aDrawPinName )
{ {
aPlotter->Text( wxPoint( x1, y ), nameColor, name, TEXT_ANGLE_VERT, aPlotter->Text( wxPoint( x1, y ), nameColor, name, EDA_ANGLE::VERTICAL,
pinNameSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER,
namePenWidth, false, false ); namePenWidth, false, false );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
aPlotter->Text( wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor, aPlotter->Text( wxPoint( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor,
number, TEXT_ANGLE_VERT, pinNumSize, GR_TEXT_HJUSTIFY_CENTER, number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false ); 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; x = ( x1 + aPinPos.x) / 2;
aPlotter->Text( wxPoint( x, y1 - name_offset ), nameColor, name, aPlotter->Text( wxPoint( x, y1 - name_offset ), nameColor, name,
TEXT_ANGLE_HORIZ, pinNameSize, GR_TEXT_HJUSTIFY_CENTER, EDA_ANGLE::HORIZONTAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, namePenWidth, false, false ); GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
x = ( x1 + aPinPos.x ) / 2; x = ( x1 + aPinPos.x ) / 2;
aPlotter->Text( wxPoint( x, y1 + num_offset ), numColor, number, aPlotter->Text( wxPoint( x, y1 + num_offset ), numColor, number,
TEXT_ANGLE_HORIZ, pinNumSize, GR_TEXT_HJUSTIFY_CENTER, EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_TOP, numPenWidth, false, false ); GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false );
} }
} }
else /* Its a vertical line. */ 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; y = ( y1 + aPinPos.y ) / 2;
aPlotter->Text( wxPoint( x1 - name_offset, y ), nameColor, name, aPlotter->Text( wxPoint( x1 - name_offset, y ), nameColor, name,
TEXT_ANGLE_VERT, pinNameSize, GR_TEXT_HJUSTIFY_CENTER, EDA_ANGLE::VERTICAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, namePenWidth, false, false ); GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
aPlotter->Text( wxPoint( x1 + num_offset, ( y1 + aPinPos.y ) / 2 ), numColor, aPlotter->Text( wxPoint( x1 + num_offset, ( y1 + aPinPos.y ) / 2 ), numColor,
number, TEXT_ANGLE_VERT, pinNumSize, GR_TEXT_HJUSTIFY_CENTER, number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_TOP, numPenWidth, false, false ); 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. * transformation matrix causes xy axes to be flipped.
* this simple algo works only for schematic matrix (rot 90 or/and mirror) * 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 ); return tmp_text.TextHitTest( aPosition, aAccuracy );
} }
@ -78,7 +78,7 @@ EDA_ITEM* LIB_TEXT::Clone() const
newitem->m_flags = m_flags; newitem->m_flags = m_flags;
newitem->SetText( GetText() ); newitem->SetText( GetText() );
newitem->SetEffects( *this ); newitem->SetAttributes( *this );
return newitem; return newitem;
} }
@ -133,28 +133,28 @@ void LIB_TEXT::NormalizeJustification( bool inverse )
wxPoint delta( 0, 0 ); wxPoint delta( 0, 0 );
EDA_RECT bbox = GetTextBox(); 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; 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; delta.x = - bbox.GetWidth() / 2;
if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
delta.y = - bbox.GetHeight() / 2; 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; delta.y = bbox.GetHeight() / 2;
} }
else else
{ {
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
delta.y = bbox.GetWidth() / 2; 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; delta.y = - bbox.GetWidth() / 2;
if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
delta.x = + bbox.GetHeight() / 2; 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; delta.x = - bbox.GetHeight() / 2;
} }
@ -174,19 +174,19 @@ void LIB_TEXT::MirrorHorizontal( const wxPoint& center )
x *= -1; x *= -1;
x += center.x; x += center.x;
if( GetTextAngle() == 0.0 ) if( GetTextAngle().IsHorizontal() )
{ {
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
} }
else else
{ {
if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); SetVertJustify( GR_TEXT_V_ALIGN_TOP );
} }
SetTextX( x ); SetTextX( x );
@ -203,19 +203,19 @@ void LIB_TEXT::MirrorVertical( const wxPoint& center )
y *= -1; y *= -1;
y += center.y; y += center.y;
if( GetTextAngle() == 0.0 ) if( GetTextAngle().IsHorizontal() )
{ {
if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); SetVertJustify( GR_TEXT_V_ALIGN_TOP );
} }
else else
{ {
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
} }
SetTextY( y ); SetTextY( y );
@ -232,23 +232,23 @@ void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW )
RotatePoint( &pt, center, rot_angle ); RotatePoint( &pt, center, rot_angle );
SetTextPos( pt ); SetTextPos( pt );
if( GetTextAngle() == 0.0 ) if( GetTextAngle().IsHorizontal() )
{ {
SetTextAngle( 900 ); SetTextAngle( EDA_ANGLE::VERTICAL );
} }
else else
{ {
// 180º of rotation is a mirror // 180º of rotation is a mirror
if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); SetVertJustify( GR_TEXT_V_ALIGN_TOP );
SetTextAngle( 0 ); 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 // The text orientation may need to be flipped if the transformation matrix causes xy
// axes to be flipped. // 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; wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset;
// Get color // Get color
@ -284,9 +284,9 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
int penWidth = std::max( GetEffectiveTextPenWidth(), settings->GetMinPenWidth() ); int penWidth = std::max( GetEffectiveTextPenWidth(), settings->GetMinPenWidth() );
plotter->Text( pos, color, GetText(), t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT, GetTextSize(), plotter->Text( pos, color, GetText(), t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), GetTextSize(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth,
IsBold() ); 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 // Calculate the text orientation, according to the symbol orientation/mirror (needed when
// draw text in schematic) // draw text in schematic)
int orient = (int) GetTextAngle(); EDA_ANGLE orient = GetTextAngle();
if( aTransform.y1 ) // Rotate symbol 90 degrees. if( aTransform.y1 ) // Rotate symbol 90 degrees.
{ {
if( orient == TEXT_ANGLE_HORIZ ) if( orient == EDA_ANGLE::HORIZONTAL )
orient = TEXT_ANGLE_VERT; orient = EDA_ANGLE::VERTICAL;
else 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. // Calculate pos according to mirror/rotation.
txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset;
GRText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GRText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), IsBold() ); 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() ) switch ( GetHorizJustify() )
{ {
case GR_TEXT_HJUSTIFY_LEFT: msg = _( "Left" ); break; case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
case GR_TEXT_HJUSTIFY_CENTER: msg = _( "Center" ); break; case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_HJUSTIFY_RIGHT: msg = _( "Right" ); break; case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
} }
aList.emplace_back( _( "H Justification" ), msg ); aList.emplace_back( _( "H Justification" ), msg );
switch ( GetVertJustify() ) switch ( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: msg = _( "Top" ); break; case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
case GR_TEXT_VJUSTIFY_CENTER: msg = _( "Center" ); break; case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: msg = _( "Bottom" ); break; case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
} }
aList.emplace_back( _( "V Justification" ), msg ); aList.emplace_back( _( "V Justification" ), msg );
@ -385,8 +385,8 @@ const EDA_RECT LIB_TEXT::GetBoundingBox() const
wxPoint orig = rect.GetOrigin(); wxPoint orig = rect.GetOrigin();
wxPoint end = rect.GetEnd(); wxPoint end = rect.GetEnd();
RotatePoint( &orig, GetTextPos(), -GetTextAngle() ); RotatePoint( &orig, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
RotatePoint( &end, GetTextPos(), -GetTextAngle() ); RotatePoint( &end, GetTextPos(), -GetTextAngle().AsTenthsOfADegree() );
rect.SetOrigin( orig ); rect.SetOrigin( orig );
rect.SetEnd( end ); rect.SetEnd( end );

View File

@ -74,7 +74,7 @@ public:
if( aContained ) if( aContained )
return rect.Contains( textBox ); return rect.Contains( textBox );
return rect.Intersects( textBox, GetTextAngle() ); return rect.Intersects( textBox, GetTextAngle().AsTenthsOfADegree() );
} }
int GetPenWidth() const override; 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(); wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = aSettings->GetLayerColor( IsForceVisible() ? LAYER_HIDDEN : m_layer ); COLOR4D color = aSettings->GetLayerColor( IsForceVisible() ? LAYER_HIDDEN : m_layer );
int orient;
wxPoint textpos; wxPoint textpos;
int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() ); int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
@ -225,7 +224,7 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset
return; return;
// Calculate the text orientation according to the symbol orientation. // Calculate the text orientation according to the symbol orientation.
orient = GetTextAngle(); EDA_ANGLE orient = GetTextAngle();
if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) 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( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
{ {
if( orient == TEXT_ANGLE_HORIZ ) if( orient == EDA_ANGLE::HORIZONTAL )
orient = TEXT_ANGLE_VERT; orient = EDA_ANGLE::VERTICAL;
else 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; textpos = GetBoundingBox().Centre() + aOffset;
GRText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GRText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), IsBold() ); GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold() );
} }
void SCH_FIELD::ImportValues( const LIB_FIELD& aSource ) 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 ); std::swap( m_layer, item->m_layer );
SwapText( *item ); 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. // 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 ) 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( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
{ {
if( orient == TEXT_ANGLE_HORIZ ) if( orient.IsHorizontal() )
orient = TEXT_ANGLE_VERT; orient = EDA_ANGLE::VERTICAL;
else 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 pos = GetTextPos() - origin;
wxPoint begin = rect.GetOrigin() - origin; wxPoint begin = rect.GetOrigin() - origin;
wxPoint end = rect.GetEnd() - origin; wxPoint end = rect.GetEnd() - origin;
RotatePoint( &begin, pos, GetTextAngle() ); RotatePoint( &begin, pos, GetTextAngle().AsTenthsOfADegree() );
RotatePoint( &end, pos, GetTextAngle() ); RotatePoint( &end, pos, GetTextAngle().AsTenthsOfADegree() );
// Now, apply the symbol transform (mirror/rot) // Now, apply the symbol transform (mirror/rot)
TRANSFORM transform; TRANSFORM transform;
@ -365,13 +364,13 @@ bool SCH_FIELD::IsHorizJustifyFlipped() const
switch( GetHorizJustify() ) switch( GetHorizJustify() )
{ {
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_H_ALIGN_LEFT:
if( GetDrawRotation() == TEXT_ANGLE_VERT ) if( GetDrawRotation().IsVertical() )
return render_center.y > pos.y; return render_center.y > pos.y;
else else
return render_center.x < pos.x; return render_center.x < pos.x;
case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_H_ALIGN_RIGHT:
if( GetDrawRotation() == TEXT_ANGLE_VERT ) if( GetDrawRotation().IsVertical() )
return render_center.y < pos.y; return render_center.y < pos.y;
else else
return render_center.x > pos.x; 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() ) switch( GetHorizJustify() )
{ {
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_H_ALIGN_LEFT:
return IsHorizJustifyFlipped() ? GR_TEXT_HJUSTIFY_RIGHT : GR_TEXT_HJUSTIFY_LEFT; return IsHorizJustifyFlipped() ? GR_TEXT_H_ALIGN_RIGHT : GR_TEXT_H_ALIGN_LEFT;
case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_H_ALIGN_RIGHT:
return IsHorizJustifyFlipped() ? GR_TEXT_HJUSTIFY_LEFT : GR_TEXT_HJUSTIFY_RIGHT; return IsHorizJustifyFlipped() ? GR_TEXT_H_ALIGN_LEFT : GR_TEXT_H_ALIGN_RIGHT;
default: default:
return GR_TEXT_HJUSTIFY_CENTER; return GR_TEXT_H_ALIGN_CENTER;
} }
} }
@ -402,13 +401,13 @@ bool SCH_FIELD::IsVertJustifyFlipped() const
switch( GetVertJustify() ) switch( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_V_ALIGN_TOP:
if( GetDrawRotation() == TEXT_ANGLE_VERT ) if( GetDrawRotation().IsVertical() )
return render_center.x < pos.x; return render_center.x < pos.x;
else else
return render_center.y < pos.y; return render_center.y < pos.y;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_V_ALIGN_BOTTOM:
if( GetDrawRotation() == TEXT_ANGLE_VERT ) if( GetDrawRotation().IsVertical() )
return render_center.x > pos.x; return render_center.x > pos.x;
else else
return render_center.y > pos.y; 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() ) switch( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_V_ALIGN_TOP:
return IsVertJustifyFlipped() ? GR_TEXT_VJUSTIFY_BOTTOM : GR_TEXT_VJUSTIFY_TOP; return IsVertJustifyFlipped() ? GR_TEXT_V_ALIGN_BOTTOM : GR_TEXT_V_ALIGN_TOP;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_V_ALIGN_BOTTOM:
return IsVertJustifyFlipped() ? GR_TEXT_VJUSTIFY_TOP : GR_TEXT_VJUSTIFY_BOTTOM; return IsVertJustifyFlipped() ? GR_TEXT_V_ALIGN_TOP : GR_TEXT_V_ALIGN_BOTTOM;
default: 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() ) switch ( GetHorizJustify() )
{ {
case GR_TEXT_HJUSTIFY_LEFT: msg = _( "Left" ); break; case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
case GR_TEXT_HJUSTIFY_CENTER: msg = _( "Center" ); break; case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_HJUSTIFY_RIGHT: msg = _( "Right" ); break; case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
} }
aList.emplace_back( _( "H Justification" ), msg ); aList.emplace_back( _( "H Justification" ), msg );
switch ( GetVertJustify() ) switch ( GetVertJustify() )
{ {
case GR_TEXT_VJUSTIFY_TOP: msg = _( "Top" ); break; case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
case GR_TEXT_VJUSTIFY_CENTER: msg = _( "Center" ); break; case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
case GR_TEXT_VJUSTIFY_BOTTOM: msg = _( "Bottom" ); break; case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
} }
aList.emplace_back( _( "V Justification" ), msg ); aList.emplace_back( _( "V Justification" ), msg );
@ -833,7 +832,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) const
return; return;
// Calculate the text orientation, according to the symbol orientation/mirror // 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 ) 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( parentSymbol->GetTransform().y1 ) // Rotate symbol 90 deg.
{ {
if( orient == TEXT_ANGLE_HORIZ ) if( orient.IsHorizontal() )
orient = TEXT_ANGLE_VERT; orient = EDA_ANGLE::VERTICAL;
else else
orient = TEXT_ANGLE_HORIZ; orient = EDA_ANGLE::HORIZONTAL;
} }
} }
@ -858,9 +857,9 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) const
* to calculate so the easier way is to use no justifications (centered text) and use * to calculate so the easier way is to use no justifications (centered text) and use
* GetBoundingBox to know the text coordinate considered as centered * GetBoundingBox to know the text coordinate considered as centered
*/ */
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER; GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_CENTER;
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; GR_TEXT_V_ALIGN_T vjustify = GR_TEXT_V_ALIGN_CENTER;
wxPoint textpos = GetBoundingBox().Centre(); wxPoint textpos = GetBoundingBox().Centre();
aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify, aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify,
penWidth, IsItalic(), IsBold() ); penWidth, IsItalic(), IsBold() );

View File

@ -119,10 +119,10 @@ public:
/** /**
* Adjusters to allow EDA_TEXT to draw/print/etc. text in absolute coords. * 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; wxPoint GetDrawPos() const override;
EDA_TEXT_HJUSTIFY_T GetDrawHorizJustify() const override; GR_TEXT_H_ALIGN_T GetDrawHorizJustify() const override;
EDA_TEXT_VJUSTIFY_T GetDrawVertJustify() const override; GR_TEXT_V_ALIGN_T GetDrawVertJustify() const override;
const EDA_RECT GetBoundingBox() const override; const EDA_RECT GetBoundingBox() const override;
@ -133,8 +133,8 @@ public:
bool IsHorizJustifyFlipped() const; bool IsHorizJustifyFlipped() const;
bool IsVertJustifyFlipped() const; bool IsVertJustifyFlipped() const;
EDA_TEXT_HJUSTIFY_T GetEffectiveHorizJustify() const; GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const;
EDA_TEXT_VJUSTIFY_T GetEffectiveVertJustify() const; GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const;
/** /**
* @return true if the field is either empty or holds "~". * @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 pos = item->GetBoundingBox().Centre();
auto label = conn->Name( true ); auto label = conn->Name( true );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetStrokeColor( COLOR4D( LIGHTRED ) ); m_gal->SetStrokeColor( COLOR4D( LIGHTRED ) );
m_gal->SetLineWidth( Mils2ui( 2 ) ); m_gal->SetLineWidth( Mils2ui( 2 ) );
m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) ); 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() ); m_gal->GetLineWidth() );
EDA_RECT box( (wxPoint) aPosition, wxSize( extents.x, extents.y ) ); 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) ); 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() ); 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) ); 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.SetY( box.GetY() - box.GetHeight() );
box.Normalize(); // Make h and v sizes always >= 0 box.Normalize(); // Make h and v sizes always >= 0
@ -695,12 +695,13 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer )
} }
else else
{ {
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) ); m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
m_gal->SetFontItalic( aField->IsItalic() ); 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 // 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(); EDA_RECT bBox = aText->GetBoundingBox();
bBox.RevertYAxis(); bBox.RevertYAxis();
VECTOR2D pos = mapCoords( bBox.Centre() ); VECTOR2D pos = mapCoords( bBox.Centre() );
double orient = aText->GetTextAngleRadians(); double orient = aText->GetTextAngle().AsRadians();
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) ); m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
@ -1105,29 +1106,29 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] ) if( size[INSIDE] )
{ {
setupDC( INSIDE ); setupDC( INSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 ); drawText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
} }
if( size[OUTSIDE] ) if( size[OUTSIDE] )
{ {
setupDC( OUTSIDE ); setupDC( OUTSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 ); drawText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
} }
if( size[ABOVE] ) if( size[ABOVE] )
{ {
setupDC( ABOVE ); setupDC( ABOVE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM );
drawText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 ); drawText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
} }
if( size[BELOW] ) if( size[BELOW] )
{ {
setupDC( BELOW ); setupDC( BELOW );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP );
drawText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 ); drawText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
} }
break; break;
@ -1136,30 +1137,30 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] ) if( size[INSIDE] )
{ {
setupDC( INSIDE ); setupDC( INSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
drawText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 ); drawText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
} }
if( size[OUTSIDE] ) if( size[OUTSIDE] )
{ {
setupDC( OUTSIDE ); setupDC( OUTSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 ); drawText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
} }
if( size[ABOVE] ) if( size[ABOVE] )
{ {
setupDC( ABOVE ); setupDC( ABOVE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM );
drawText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 ); drawText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
} }
if( size[BELOW] ) if( size[BELOW] )
{ {
setupDC( BELOW ); setupDC( BELOW );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP );
drawText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 ); drawText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
} }
break; break;
@ -1168,29 +1169,29 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] ) if( size[INSIDE] )
{ {
setupDC( INSIDE ); setupDC( INSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 ); drawText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 );
} }
if( size[OUTSIDE] ) if( size[OUTSIDE] )
{ {
setupDC( OUTSIDE ); setupDC( OUTSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 ); drawText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 );
} }
if( size[ABOVE] ) if( size[ABOVE] )
{ {
setupDC( ABOVE ); setupDC( ABOVE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM );
drawText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 ); drawText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
} }
if( size[BELOW] ) if( size[BELOW] )
{ {
setupDC( BELOW ); setupDC( BELOW );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP );
drawText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 ); drawText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
} }
break; break;
@ -1199,29 +1200,29 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] ) if( size[INSIDE] )
{ {
setupDC( INSIDE ); setupDC( INSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 ); drawText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 );
} }
if( size[OUTSIDE] ) if( size[OUTSIDE] )
{ {
setupDC( OUTSIDE ); setupDC( OUTSIDE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_RIGHT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
drawText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 ); drawText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 );
} }
if( size[ABOVE] ) if( size[ABOVE] )
{ {
setupDC( ABOVE ); setupDC( ABOVE );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM );
drawText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 ); drawText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
} }
if( size[BELOW] ) if( size[BELOW] )
{ {
setupDC( BELOW ); setupDC( BELOW );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_TOP );
drawText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 ); drawText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
} }
break; break;
@ -1518,7 +1519,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer )
m_gal->SetTextAttributes( aText ); m_gal->SetTextAttributes( aText );
m_gal->SetFontUnderlined( false ); 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. // 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( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
{ {
if( static_cast<SCH_SYMBOL*>( aField->GetParent() )->GetTransform().y1 ) if( static_cast<SCH_SYMBOL*>( aField->GetParent() )->GetTransform().y1 )
{ {
// Rotate symbol 90 degrees. // Rotate symbol 90 degrees.
if( orient == TEXT_ANGLE_HORIZ ) if( orient.IsHorizontal() )
orient = TEXT_ANGLE_VERT; orient = EDA_ANGLE::VERTICAL;
else else
orient = TEXT_ANGLE_HORIZ; orient = EDA_ANGLE::HORIZONTAL;
} }
} }
@ -1720,8 +1721,8 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer )
} }
else else
{ {
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) ); m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
m_gal->SetFontBold( aField->IsBold() ); 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->SetFontUnderlined( underline );
m_gal->SetTextMirrored( aField->IsMirrored() ); 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 // Draw the umbilical line

View File

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

View File

@ -218,12 +218,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSh
// the margin to the nearest grid, ensuring all items remain on the grid. // the margin to the nearest grid, ensuring all items remain on the grid.
wxSize targetSheetSize = sheetBoundingBox.GetSize(); wxSize targetSheetSize = sheetBoundingBox.GetSize();
int longestSide = std::max( targetSheetSize.x, targetSheetSize.y ); int longestSide = std::max( targetSheetSize.x, targetSheetSize.y );
int margin = ( (double) longestSide * 0.03); int margin = ( (double) longestSide * 0.03 );
margin = roundToNearestGrid( margin ); margin = roundToNearestGrid( margin );
targetSheetSize.IncBy( margin * 2, margin * 2 ); targetSheetSize.IncBy( margin * 2, margin * 2 );
// Update page size always // Update page size always
PAGE_INFO pageInfo = sheet->GetScreen()->GetPageSettings(); PAGE_INFO pageInfo = sheet->GetScreen()->GetPageSettings();
pageInfo.SetWidthMils( Iu2Mils( targetSheetSize.x ) ); pageInfo.SetWidthMils( Iu2Mils( targetSheetSize.x ) );
pageInfo.SetHeightMils( Iu2Mils( targetSheetSize.y ) ); pageInfo.SetHeightMils( Iu2Mils( targetSheetSize.y ) );
@ -243,7 +243,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSh
std::vector<SCH_ITEM*> allItems; std::vector<SCH_ITEM*> allItems;
std::copy( sheet->GetScreen()->Items().begin(), sheet->GetScreen()->Items().end(), std::copy( sheet->GetScreen()->Items().begin(), sheet->GetScreen()->Items().end(),
std::back_inserter( allItems ) ); std::back_inserter( allItems ) );
for( SCH_ITEM* item : allItems ) for( SCH_ITEM* item : allItems )
{ {
@ -295,9 +295,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheets()
wxFileName loadedFilePath = wxFileName( Filename ); wxFileName loadedFilePath = wxFileName( Filename );
std::string filename = wxString::Format( std::string filename = wxString::Format( "%s_%02d",
"%s_%02d", loadedFilePath.GetName(), getSheetNumber( rootSheetID ) ) loadedFilePath.GetName(),
.ToStdString(); getSheetNumber( rootSheetID ) ).ToStdString();
ReplaceIllegalFileNameChars( &filename ); ReplaceIllegalFileNameChars( &filename );
filename += wxT( "." ) + KiCadSchematicFileExtension; filename += wxT( "." ) + KiCadSchematicFileExtension;
@ -366,7 +366,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary()
{ {
for( std::pair<PART_ID, PART> partPair : Parts.PartDefinitions ) for( std::pair<PART_ID, PART> partPair : Parts.PartDefinitions )
{ {
PART_ID partID = partPair.first; PART_ID partID = partPair.first;
PART part = partPair.second; PART part = partPair.second;
if( part.Definition.GateSymbols.size() == 0 ) if( part.Definition.GateSymbols.size() == 0 )
@ -442,7 +442,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
"symbol was not loaded" ), "symbol was not loaded" ),
sym.ComponentRef.Designator, sym.ComponentRef.Designator,
sym.PartRef.RefID ), sym.PartRef.RefID ),
RPT_SEVERITY_ERROR); RPT_SEVERITY_ERROR );
continue; continue;
} }
@ -484,8 +484,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
sym.ComponentRef.Designator.Replace( wxT( " " ), wxT( "_" ) ); sym.ComponentRef.Designator.Replace( wxT( " " ), wxT( "_" ) );
refField->SetText( sym.ComponentRef.Designator ); refField->SetText( sym.ComponentRef.Designator );
loadSymbolFieldAttribute( sym.ComponentRef.AttrLoc, symOrientDeciDeg, loadSymbolFieldAttribute( sym.ComponentRef.AttrLoc, symOrientDeciDeg, sym.Mirror,
sym.Mirror, refField ); refField );
if( sym.HasPartRef ) if( sym.HasPartRef )
{ {
@ -506,8 +506,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
partname.Replace( wxT( "\t" ), wxT( "\\t" ) ); partname.Replace( wxT( "\t" ), wxT( "\\t" ) );
partField->SetText( partname ); partField->SetText( partname );
loadSymbolFieldAttribute( sym.PartRef.AttrLoc, symOrientDeciDeg, loadSymbolFieldAttribute( sym.PartRef.AttrLoc, symOrientDeciDeg, sym.Mirror,
sym.Mirror, partField ); partField );
partField->SetVisible( SymbolPartNameColor.IsVisible ); 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) // (the position of the wire will determine how best to place the bus label)
} }
} }
} }
} }
@ -874,23 +873,20 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets()
} }
auto getHierarchicalLabel = auto getHierarchicalLabel =
[&]( NETELEMENT_ID aNode ) -> SCH_HIERLABEL* [&]( NETELEMENT_ID aNode ) -> SCH_HIERLABEL*
{
if( aNode.Contains( "BLKT" ) )
{ {
NET_SCH::BLOCK_TERM blockTerm = net.BlockTerminals.at( aNode ); if( aNode.Contains( "BLKT" ) )
BLOCK_PIN_ID blockPinID = std::make_pair( blockTerm.BlockID,
blockTerm.TerminalID );
if( m_sheetPinMap.find( blockPinID )
!= m_sheetPinMap.end() )
{ {
return m_sheetPinMap.at( blockPinID ); NET_SCH::BLOCK_TERM blockTerm = net.BlockTerminals.at( aNode );
} BLOCK_PIN_ID blockPinID = std::make_pair( blockTerm.BlockID,
} blockTerm.TerminalID );
return nullptr; if( m_sheetPinMap.find( blockPinID ) != m_sheetPinMap.end() )
}; return m_sheetPinMap.at( blockPinID );
}
return nullptr;
};
//Add net name to all hierarchical pins (block terminals in CADSTAR) //Add net name to all hierarchical pins (block terminals in CADSTAR)
for( std::pair<NETELEMENT_ID, NET_SCH::BLOCK_TERM> blockPair : net.BlockTerminals ) for( std::pair<NETELEMENT_ID, NET_SCH::BLOCK_TERM> blockPair : net.BlockTerminals )
@ -1067,18 +1063,18 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets()
} }
auto fixNetLabelsAndSheetPins = auto fixNetLabelsAndSheetPins =
[&]( double aWireAngleDeciDeg, NETELEMENT_ID& aNetEleID ) [&]( double aWireAngleDeciDeg, NETELEMENT_ID& aNetEleID )
{ {
LABEL_SPIN_STYLE spin = getSpinStyleDeciDeg( aWireAngleDeciDeg ); LABEL_SPIN_STYLE spin = getSpinStyleDeciDeg( aWireAngleDeciDeg );
if( netlabels.find( aNetEleID ) != netlabels.end() ) if( netlabels.find( aNetEleID ) != netlabels.end() )
netlabels.at( aNetEleID )->SetLabelSpinStyle( spin.MirrorY() ); netlabels.at( aNetEleID )->SetLabelSpinStyle( spin.MirrorY() );
SCH_HIERLABEL* sheetPin = getHierarchicalLabel( aNetEleID ); SCH_HIERLABEL* sheetPin = getHierarchicalLabel( aNetEleID );
if( sheetPin ) if( sheetPin )
sheetPin->SetLabelSpinStyle( spin.MirrorX() ); sheetPin->SetLabelSpinStyle( spin.MirrorX() );
}; };
// Now we can load the wires and fix the label orientations // Now we can load the wires and fix the label orientations
for( const VECTOR2I& pt : wireChain.CPoints() ) for( const VECTOR2I& pt : wireChain.CPoints() )
@ -1181,7 +1177,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadTexts()
void CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols() void CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols()
{ {
for( std::pair<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> docSymPair : for( std::pair<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> docSymPair :
Schematic.DocumentationSymbols ) Schematic.DocumentationSymbols )
{ {
DOCUMENTATION_SYMBOL docSym = docSymPair.second; DOCUMENTATION_SYMBOL docSym = docSymPair.second;
@ -1241,23 +1237,25 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols()
void CADSTAR_SCH_ARCHIVE_LOADER::loadTextVariables() void CADSTAR_SCH_ARCHIVE_LOADER::loadTextVariables()
{ {
auto findAndReplaceTextField = [&]( TEXT_FIELD_NAME aField, wxString aValue ) { auto findAndReplaceTextField =
if( m_context.TextFieldToValuesMap.find( aField ) != m_context.TextFieldToValuesMap.end() ) [&]( TEXT_FIELD_NAME aField, wxString aValue )
{
if( m_context.TextFieldToValuesMap.at( aField ) != aValue )
{ {
m_context.TextFieldToValuesMap.at( aField ) = aValue; if( m_context.TextFieldToValuesMap.find( aField ) != m_context.TextFieldToValuesMap.end() )
m_context.InconsistentTextFields.insert( aField ); {
return false; if( m_context.TextFieldToValuesMap.at( aField ) != aValue )
} {
} m_context.TextFieldToValuesMap.at( aField ) = aValue;
else m_context.InconsistentTextFields.insert( aField );
{ return false;
m_context.TextFieldToValuesMap.insert( { aField, aValue } ); }
} }
else
{
m_context.TextFieldToValuesMap.insert( { aField, aValue } );
}
return true; return true;
}; };
PROJECT* pj = &m_schematic->Prj(); PROJECT* pj = &m_schematic->Prj();
@ -1314,7 +1312,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
int lineThickness = getLineThickness( fig.LineCodeID ); int lineThickness = getLineThickness( fig.LineCodeID );
loadLibrarySymbolShapeVertices( fig.Shape.Vertices, symbol.Origin, aSymbol, gateNumber, loadLibrarySymbolShapeVertices( fig.Shape.Vertices, symbol.Origin, aSymbol, gateNumber,
lineThickness ); lineThickness );
for( CUTOUT c : fig.Shape.Cutouts ) for( CUTOUT c : fig.Shape.Cutouts )
{ {
@ -1428,12 +1426,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
EDA_RECT bbox = libtext->GetTextBox( ii, true ); EDA_RECT bbox = libtext->GetTextBox( ii, true );
wxPoint linePos = { bbox.GetLeft(), -bbox.GetBottom() }; 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() ); LIB_TEXT* line = static_cast<LIB_TEXT*>( libtext->Clone() );
line->SetText( strings[ii] ); line->SetText( strings[ii] );
line->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); line->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
line->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); line->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
line->SetTextPos( linePos ); line->SetTextPos( linePos );
// Multiline text not allowed in LIB_TEXT // Multiline text not allowed in LIB_TEXT
@ -1498,87 +1496,87 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
wxString footprintAlternateName = wxEmptyString; wxString footprintAlternateName = wxEmptyString;
auto loadLibraryField = auto loadLibraryField =
[&]( ATTRIBUTE_VALUE& aAttributeVal ) [&]( ATTRIBUTE_VALUE& aAttributeVal )
{ {
wxString attrName = getAttributeName( aAttributeVal.AttributeID ); wxString attrName = getAttributeName( aAttributeVal.AttributeID );
// Remove invalid field characters // Remove invalid field characters
aAttributeVal.Value.Replace( wxT( "\n" ), wxT( "\\n" ) ); aAttributeVal.Value.Replace( wxT( "\n" ), wxT( "\\n" ) );
aAttributeVal.Value.Replace( wxT( "\r" ), wxT( "\\r" ) ); aAttributeVal.Value.Replace( wxT( "\r" ), wxT( "\\r" ) );
aAttributeVal.Value.Replace( wxT( "\t" ), wxT( "\\t" ) ); aAttributeVal.Value.Replace( wxT( "\t" ), wxT( "\\t" ) );
//TODO: Handle "links": In cadstar a field can be a "link" if its name starts //TODO: Handle "links": In cadstar a field can be a "link" if its name starts
// with the characters "Link ". Need to figure out how to convert them to // with the characters "Link ". Need to figure out how to convert them to
// equivalent in KiCad. // equivalent in KiCad.
if( attrName == wxT( "(PartDefinitionNameStem)" ) ) if( attrName == wxT( "(PartDefinitionNameStem)" ) )
{ {
//Space not allowed in Reference field //Space not allowed in Reference field
aAttributeVal.Value.Replace( wxT( " " ), "_" ); aAttributeVal.Value.Replace( wxT( " " ), "_" );
aSymbol->GetReferenceField().SetText( aAttributeVal.Value ); aSymbol->GetReferenceField().SetText( aAttributeVal.Value );
return; return;
} }
else if( attrName == wxT( "(PartDescription)" ) ) else if( attrName == wxT( "(PartDescription)" ) )
{ {
aSymbol->SetDescription( aAttributeVal.Value ); aSymbol->SetDescription( aAttributeVal.Value );
return; return;
} }
else if( attrName == wxT( "(PartDefinitionReferenceName)" ) ) else if( attrName == wxT( "(PartDefinitionReferenceName)" ) )
{ {
footprintRefName = aAttributeVal.Value; footprintRefName = aAttributeVal.Value;
return; return;
} }
else if( attrName == wxT( "(PartDefinitionAlternateName)" ) ) else if( attrName == wxT( "(PartDefinitionAlternateName)" ) )
{ {
footprintAlternateName = aAttributeVal.Value; footprintAlternateName = aAttributeVal.Value;
return; return;
} }
LIB_FIELD* attrField = aSymbol->FindField( attrName ); LIB_FIELD* attrField = aSymbol->FindField( attrName );
if( !attrField ) if( !attrField )
{ {
int fieldID = aSymbol->GetFieldCount(); int fieldID = aSymbol->GetFieldCount();
attrField = new LIB_FIELD( aSymbol, fieldID ); attrField = new LIB_FIELD( aSymbol, fieldID );
attrField->SetName( attrName ); attrField->SetName( attrName );
aSymbol->AddField( attrField ); aSymbol->AddField( attrField );
} }
wxASSERT( attrField->GetName() == attrName ); wxASSERT( attrField->GetName() == attrName );
attrField->SetText( aAttributeVal.Value ); attrField->SetText( aAttributeVal.Value );
attrField->SetUnit( gateNumber ); attrField->SetUnit( gateNumber );
ATTRIBUTE_ID& attrid = aAttributeVal.AttributeID; ATTRIBUTE_ID& attrid = aAttributeVal.AttributeID;
attrField->SetVisible( isAttributeVisible( attrid ) ); attrField->SetVisible( isAttributeVisible( attrid ) );
if( aAttributeVal.HasLocation ) if( aAttributeVal.HasLocation )
{ {
// #1 Check if the part itself defined a location for the field // #1 Check if the part itself defined a location for the field
applyToLibraryFieldAttribute( aAttributeVal.AttributeLocation, symbol.Origin, applyToLibraryFieldAttribute( aAttributeVal.AttributeLocation, symbol.Origin,
attrField ); attrField );
} }
else if( symbol.TextLocations.find( aAttributeVal.AttributeID ) else if( symbol.TextLocations.find( aAttributeVal.AttributeID )
!= symbol.TextLocations.end() ) != symbol.TextLocations.end() )
{ {
// #2 Look in the symbol definition: Text locations // #2 Look in the symbol definition: Text locations
TEXT_LOCATION symTxtLoc = symbol.TextLocations.at( aAttributeVal.AttributeID ); TEXT_LOCATION symTxtLoc = symbol.TextLocations.at( aAttributeVal.AttributeID );
applyToLibraryFieldAttribute( symTxtLoc, symbol.Origin, attrField ); applyToLibraryFieldAttribute( symTxtLoc, symbol.Origin, attrField );
} }
else if( symbol.AttributeValues.find( attrid ) != symbol.AttributeValues.end() else if( symbol.AttributeValues.find( attrid ) != symbol.AttributeValues.end()
&& symbol.AttributeValues.at( attrid ).HasLocation ) && symbol.AttributeValues.at( attrid ).HasLocation )
{ {
// #3 Look in the symbol definition: Attribute values // #3 Look in the symbol definition: Attribute values
ATTRIBUTE_VALUE symAttrVal = symbol.AttributeValues.at( attrid ); ATTRIBUTE_VALUE symAttrVal = symbol.AttributeValues.at( attrid );
applyToLibraryFieldAttribute( symAttrVal.AttributeLocation, symbol.Origin, applyToLibraryFieldAttribute( symAttrVal.AttributeLocation, symbol.Origin,
attrField ); attrField );
} }
else else
{ {
attrField->SetVisible( false ); attrField->SetVisible( false );
applyTextSettings( attrField, wxT( "TC1" ), ALIGNMENT::NO_ALIGNMENT, applyTextSettings( attrField, wxT( "TC1" ), ALIGNMENT::NO_ALIGNMENT,
JUSTIFICATION::LEFT ); JUSTIFICATION::LEFT );
} }
}; };
// Load all attributes in the Part Definition // Load all attributes in the Part Definition
for( std::pair<ATTRIBUTE_ID, for( std::pair<ATTRIBUTE_ID,
@ -1725,7 +1723,7 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads
symbol->SetPosition( getKiCadPoint( aCadstarSymbol.Origin ) ); symbol->SetPosition( getKiCadPoint( aCadstarSymbol.Origin ) );
double compAngleDeciDeg = getAngleTenthDegree( aCadstarSymbol.OrientAngle ); double compAngleDeciDeg = getAngleTenthDegree( aCadstarSymbol.OrientAngle );
int compOrientation = 0; int compOrientation = 0;
if( aCadstarSymbol.Mirror ) if( aCadstarSymbol.Mirror )
{ {
@ -1744,7 +1742,7 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads
"manual fixing." ), "manual fixing." ),
aCadstarSymbol.ComponentRef.Designator, aCadstarSymbol.ComponentRef.Designator,
compAngleDeciDeg / 10.0 ), compAngleDeciDeg / 10.0 ),
RPT_SEVERITY_ERROR); RPT_SEVERITY_ERROR );
} }
symbol->SetOrientation( compOrientation ); symbol->SetOrientation( compOrientation );
@ -1779,14 +1777,15 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads
symbol->GetLibSymbolRef()->GetPin( term.second ) } ); symbol->GetLibSymbolRef()->GetPin( term.second ) } );
} }
auto replacePinNumber = [&]( wxString aOldPinNum, wxString aNewPinNum ) auto replacePinNumber =
{ [&]( wxString aOldPinNum, wxString aNewPinNum )
if( aOldPinNum == aNewPinNum ) {
return; if( aOldPinNum == aNewPinNum )
return;
LIB_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum ); LIB_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum );
libpin->SetNumber( HandleTextOverbar( aNewPinNum ) ); libpin->SetNumber( HandleTextOverbar( aNewPinNum ) );
}; };
//Older versions of Cadstar used pin numbers //Older versions of Cadstar used pin numbers
for( auto& pinPair : aCadstarSymbol.PinNumbers ) for( auto& pinPair : aCadstarSymbol.PinNumbers )
@ -1847,8 +1846,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolFieldAttribute(
} }
int CADSTAR_SCH_ARCHIVE_LOADER::getComponentOrientation( int CADSTAR_SCH_ARCHIVE_LOADER::getComponentOrientation( double aOrientAngleDeciDeg,
double aOrientAngleDeciDeg, double& aReturnedOrientationDeciDeg ) double& aReturnedOrientationDeciDeg )
{ {
int compOrientation = SYMBOL_ORIENTATION_T::SYM_ORIENT_0; 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( CADSTAR_SCH_ARCHIVE_LOADER::POINT
const NET_SCH& aNet, const NETELEMENT_ID& aNetElementID ) CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetElement( const NET_SCH& aNet,
const NETELEMENT_ID& aNetElementID )
{ {
// clang-format off // clang-format off
auto logUnknownNetElementError = 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* prev = &aCadstarVertices.at( 0 );
const VERTEX* cur; const VERTEX* cur;
wxASSERT_MSG( wxASSERT_MSG( prev->Type == VERTEX_TYPE::POINT,
prev->Type == VERTEX_TYPE::POINT, "First vertex should always be a point vertex" ); "First vertex should always be a point vertex" );
for( size_t ii = 1; ii < aCadstarVertices.size(); ii++ ) for( size_t ii = 1; ii < aCadstarVertices.size(); ii++ )
{ {
@ -2124,8 +2124,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(
wxCHECK_MSG( m_sheetMap.find( aCadstarSheetID ) == m_sheetMap.end(), , wxCHECK_MSG( m_sheetMap.find( aCadstarSheetID ) == m_sheetMap.end(), ,
"Sheet already loaded!" ); "Sheet already loaded!" );
SCH_SHEET* sheet = new SCH_SHEET( aParentSheet.Last(), aPosition ); SCH_SHEET* sheet = new SCH_SHEET( aParentSheet.Last(), aPosition );
SCH_SCREEN* screen = new SCH_SCREEN( m_schematic ); SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
SCH_SHEET_PATH instance( aParentSheet ); SCH_SHEET_PATH instance( aParentSheet );
sheet->SetSize( aSheetSize ); sheet->SetSize( aSheetSize );
@ -2138,8 +2138,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(
sheetNameField.SetText( name ); sheetNameField.SetText( name );
int sheetNum = getSheetNumber( aCadstarSheetID ); int sheetNum = getSheetNumber( aCadstarSheetID );
wxString loadedFilename = wxFileName( Filename ).GetName(); wxString loadedFilename = wxFileName( Filename ).GetName();
std::string filename = wxString::Format( "%s_%02d", loadedFilename, sheetNum ).ToStdString(); std::string filename = wxString::Format( "%s_%02d", loadedFilename, sheetNum ).ToStdString();
ReplaceIllegalFileNameChars( &filename ); ReplaceIllegalFileNameChars( &filename );
@ -2168,7 +2168,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets( LAYER_ID aCadstarSheetID,
const SCH_SHEET_PATH& aSheet ) const SCH_SHEET_PATH& aSheet )
{ {
wxCHECK_MSG( m_sheetMap.find( aCadstarSheetID ) != m_sheetMap.end(), , wxCHECK_MSG( m_sheetMap.find( aCadstarSheetID ) != m_sheetMap.end(), ,
"FIXME! Parent sheet should be loaded before attempting to load subsheets" ); "FIXME! Parent sheet should be loaded before attempting to load subsheets" );
for( std::pair<BLOCK_ID, BLOCK> blockPair : Schematic.Blocks ) for( std::pair<BLOCK_ID, BLOCK> blockPair : Schematic.Blocks )
{ {
@ -2327,8 +2327,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadItemOntoKiCadSheet( LAYER_ID aCadstarSheetI
} }
else if( aCadstarSheetID == "NO_SHEET" ) else if( aCadstarSheetID == "NO_SHEET" )
{ {
wxASSERT_MSG( wxASSERT_MSG( false,
false, "Trying to add an item to NO_SHEET? This might be a documentation symbol." ); "Trying to add an item to NO_SHEET? This might be a documentation symbol." );
} }
else 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( CADSTAR_SCH_ARCHIVE_LOADER::SYMDEF_ID
const wxString& aSymdefName, const wxString& aSymDefAlternate ) CADSTAR_SCH_ARCHIVE_LOADER::getSymDefFromName( const wxString& aSymdefName,
const wxString& aSymDefAlternate )
{ {
// Do a case-insensitive comparison // Do a case-insensitive comparison
for( std::pair<SYMDEF_ID, SYMDEF_SCM> symPair : Library.SymbolDefinitions ) 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( CADSTAR_SCH_ARCHIVE_LOADER::TEXTCODE
const TEXTCODE_ID& aCadstarTextCodeID ) CADSTAR_SCH_ARCHIVE_LOADER::getTextCode( const TEXTCODE_ID& aCadstarTextCodeID )
{ {
wxCHECK( Assignments.Codedefs.TextCodes.find( aCadstarTextCodeID ) wxCHECK( Assignments.Codedefs.TextCodes.find( aCadstarTextCodeID )
!= Assignments.Codedefs.TextCodes.end(), != 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( CADSTAR_SCH_ARCHIVE_LOADER::PART
const PART_ID& aCadstarPartID ) CADSTAR_SCH_ARCHIVE_LOADER::getPart( const PART_ID& aCadstarPartID )
{ {
wxCHECK( Parts.PartDefinitions.find( aCadstarPartID ) != Parts.PartDefinitions.end(), PART() ); 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( CADSTAR_SCH_ARCHIVE_LOADER::ROUTECODE
const ROUTECODE_ID& aCadstarRouteCodeID ) CADSTAR_SCH_ARCHIVE_LOADER::getRouteCode( const ROUTECODE_ID& aCadstarRouteCodeID )
{ {
wxCHECK( Assignments.Codedefs.RouteCodes.find( aCadstarRouteCodeID ) wxCHECK( Assignments.Codedefs.RouteCodes.find( aCadstarRouteCodeID )
!= Assignments.Codedefs.RouteCodes.end(), != Assignments.Codedefs.RouteCodes.end(),
@ -2458,11 +2459,12 @@ CADSTAR_SCH_ARCHIVE_LOADER::ROUTECODE CADSTAR_SCH_ARCHIVE_LOADER::getRouteCode(
} }
CADSTAR_SCH_ARCHIVE_LOADER::PART::DEFINITION::PIN CADSTAR_SCH_ARCHIVE_LOADER::getPartDefinitionPin( CADSTAR_SCH_ARCHIVE_LOADER::PART::DEFINITION::PIN
const PART& aCadstarPart, const GATE_ID& aGateID, const TERMINAL_ID& aTerminalID ) 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 : for( std::pair<PART_DEFINITION_PIN_ID, PART::DEFINITION::PIN> pinPair :
aCadstarPart.Definition.Pins ) aCadstarPart.Definition.Pins )
{ {
PART::DEFINITION::PIN partPin = pinPair.second; PART::DEFINITION::PIN partPin = pinPair.second;
@ -2635,48 +2637,48 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT
FixTextPositionNoAlignment( aText ); FixTextPositionNoAlignment( aText );
KI_FALLTHROUGH; KI_FALLTHROUGH;
case ALIGNMENT::BOTTOMLEFT: case ALIGNMENT::BOTTOMLEFT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case ALIGNMENT::BOTTOMCENTER: case ALIGNMENT::BOTTOMCENTER:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
case ALIGNMENT::BOTTOMRIGHT: case ALIGNMENT::BOTTOMRIGHT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
case ALIGNMENT::CENTERLEFT: case ALIGNMENT::CENTERLEFT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case ALIGNMENT::CENTERCENTER: case ALIGNMENT::CENTERCENTER:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
case ALIGNMENT::CENTERRIGHT: case ALIGNMENT::CENTERRIGHT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); aText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
case ALIGNMENT::TOPLEFT: case ALIGNMENT::TOPLEFT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case ALIGNMENT::TOPCENTER: case ALIGNMENT::TOPCENTER:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
case ALIGNMENT::TOPRIGHT: case ALIGNMENT::TOPRIGHT:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; 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 // Spin style not used. All text justifications are permitted. However, only orientations
// of 0 deg or 90 deg are supported // 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 ); int quadrant = KiROUND( angleDeciDeg / 900.0 );
quadrant %= 4; quadrant %= 4;
@ -2725,7 +2727,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT
case SCH_TEXT_T: 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 // so need to adjust the location of the text element based on Cadstar's original text
// alignment (anchor position). // alignment (anchor position).
setAlignment( aKiCadTextItem, textAlignment ); 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 ) double CADSTAR_SCH_ARCHIVE_LOADER::getPolarRadius( const wxPoint& aPoint )
{ {
return sqrt( return sqrt( ( (double) aPoint.x * (double) aPoint.x )
( (double) aPoint.x * (double) aPoint.x ) + ( (double) aPoint.y * (double) aPoint.y ) ); + ( (double) aPoint.y * (double) aPoint.y ) );
} }

View File

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

View File

@ -130,7 +130,7 @@ void SCH_SEXPR_PARSER::ParseLib( LIB_SYMBOL_MAP& aSymbolLibMap )
NextTok(); NextTok();
parseHeader( T_kicad_symbol_lib, SEXPR_SYMBOL_LIB_FILE_VERSION ); parseHeader( T_kicad_symbol_lib, SEXPR_SYMBOL_LIB_FILE_VERSION );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -193,7 +193,7 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF
symbol->SetName( m_symbolName ); symbol->SetName( m_symbolName );
symbol->SetLibId( id ); symbol->SetLibId( id );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -331,7 +331,7 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF
if( m_unit > symbol->GetUnitCount() ) if( m_unit > symbol->GetUnitCount() )
symbol->SetUnitCount( m_unit, false ); symbol->SetUnitCount( m_unit, false );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -506,7 +506,7 @@ void SCH_SEXPR_PARSER::parseFill( FILL_PARAMS& aFill )
T token; T token;
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -564,7 +564,7 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta
T token; T token;
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token == T_LEFT ) if( token == T_LEFT )
token = NextTok(); token = NextTok();
@ -572,7 +572,7 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta
switch( token ) switch( token )
{ {
case T_font: case T_font:
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token == T_LEFT ) if( token == T_LEFT )
token = NextTok(); token = NextTok();
@ -614,11 +614,11 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta
{ {
switch( token ) switch( token )
{ {
case T_left: aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break; case T_left: aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break;
case T_right: aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break; case T_right: aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break;
case T_top: aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break; case T_top: aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break;
case T_bottom: aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; case T_bottom: aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break;
case T_mirror: aText->SetMirrored( true ); break; case T_mirror: aText->SetMirrored( true ); break;
default: Expecting( "left, right, top, bottom, or mirror" ); default: Expecting( "left, right, top, bottom, or mirror" );
} }
} }
@ -752,7 +752,7 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol
field->SetText( value ); field->SetText( value );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -838,7 +838,7 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol
wxString base_name = field->GetCanonicalName(); wxString base_name = field->GetCanonicalName();
// Arbitrary limit 10 attempts to find a new name // Arbitrary limit 10 attempts to find a new name
for( int ii = 1; ii < 10 && existingField ; ii++ ) for( int ii = 1; ii < 10 && existingField; ii++ )
{ {
wxString newname = base_name; wxString newname = base_name;
newname << '_' << ii; newname << '_' << ii;
@ -914,7 +914,7 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseArc()
break; break;
case T_radius: case T_radius:
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1014,7 +1014,7 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseBezier()
bezier->SetUnit( m_unit ); bezier->SetUnit( m_unit );
bezier->SetConvert( m_convert ); bezier->SetConvert( m_convert );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1089,7 +1089,7 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseCircle()
circle->SetUnit( m_unit ); circle->SetUnit( m_unit );
circle->SetConvert( m_convert ); circle->SetConvert( m_convert );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1183,9 +1183,9 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
wxCHECK_MSG( CurTok() == T_pin, nullptr, wxCHECK_MSG( CurTok() == T_pin, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a pin token." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a pin token." ) );
T token; T token;
wxString tmp; wxString tmp;
wxString error; wxString error;
std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( nullptr ); std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( nullptr );
pin->SetUnit( m_unit ); pin->SetUnit( m_unit );
@ -1199,7 +1199,7 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
token = NextTok(); token = NextTok();
pin->SetShape( parseShape( token ) ); pin->SetShape( parseShape( token ) );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token == T_hide ) if( token == T_hide )
{ {
@ -1329,8 +1329,8 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
pin->GetAlternates()[ alt.m_Name ] = alt; pin->GetAlternates()[ alt.m_Name ] = alt;
NeedRIGHT(); NeedRIGHT();
}
break; break;
}
default: default:
Expecting( "at, name, number, length, or alternate" ); Expecting( "at, name, number, length, or alternate" );
@ -1364,7 +1364,7 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parsePolyLine()
switch( token ) switch( token )
{ {
case T_pts: case T_pts:
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1414,7 +1414,7 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseRectangle()
rectangle->SetUnit( m_unit ); rectangle->SetUnit( m_unit );
rectangle->SetConvert( m_convert ); rectangle->SetConvert( m_convert );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1474,7 +1474,7 @@ LIB_TEXT* SCH_SEXPR_PARSER::parseText()
text->SetText( FromUTF8() ); text->SetText( FromUTF8() );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1561,7 +1561,7 @@ void SCH_SEXPR_PARSER::parseTITLE_BLOCK( TITLE_BLOCK& aTitleBlock )
T token; T token;
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1696,7 +1696,7 @@ SCH_FIELD* SCH_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent )
field->SetText( value ); field->SetText( value );
field->SetVisible( true ); field->SetVisible( true );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1766,7 +1766,7 @@ SCH_SHEET_PIN* SCH_SEXPR_PARSER::parseSchSheetPin( SCH_SHEET* aSheet )
Expecting( "input, output, bidirectional, tri_state, or passive" ); Expecting( "input, output, bidirectional, tri_state, or passive" );
} }
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1823,7 +1823,7 @@ void SCH_SEXPR_PARSER::parseSchSheetInstances( SCH_SHEET* aRootSheet, SCH_SCREEN
T token; T token;
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1840,7 +1840,7 @@ void SCH_SEXPR_PARSER::parseSchSheetInstances( SCH_SHEET* aRootSheet, SCH_SCREEN
instance.m_Path = KIID_PATH( FromUTF8() ); instance.m_Path = KIID_PATH( FromUTF8() );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1902,7 +1902,7 @@ void SCH_SEXPR_PARSER::parseSchSymbolInstances( SCH_SCREEN* aScreen )
T token; T token;
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1919,7 +1919,7 @@ void SCH_SEXPR_PARSER::parseSchSymbolInstances( SCH_SCREEN* aScreen )
instance.m_Path = KIID_PATH( FromUTF8() ); instance.m_Path = KIID_PATH( FromUTF8() );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -1993,7 +1993,7 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly,
screen->SetFileFormatVersionAtLoad( m_requiredVersion ); screen->SetFileFormatVersionAtLoad( m_requiredVersion );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( aIsCopyableOnly && token == T_EOF ) if( aIsCopyableOnly && token == T_EOF )
break; break;
@ -2057,7 +2057,7 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly,
LIB_SYMBOL_MAP symbolLibMap; LIB_SYMBOL_MAP symbolLibMap;
LIB_SYMBOL* symbol; LIB_SYMBOL* symbol;
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2188,7 +2188,7 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol()
m_fieldId = MANDATORY_FIELDS; m_fieldId = MANDATORY_FIELDS;
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2322,7 +2322,7 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol()
while( prefix.Length() ) while( prefix.Length() )
{ {
if( ( prefix.Last() < '0' || prefix.Last() > '9') && prefix.Last() != '?' ) if( ( prefix.Last() < '0' || prefix.Last() > '9' ) && prefix.Last() != '?' )
break; break;
prefix.RemoveLast(); prefix.RemoveLast();
@ -2356,7 +2356,7 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol()
NeedSYMBOL(); NeedSYMBOL();
number = FromUTF8(); number = FromUTF8();
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2414,10 +2414,10 @@ SCH_BITMAP* SCH_SEXPR_PARSER::parseImage()
wxCHECK_MSG( CurTok() == T_image, nullptr, wxCHECK_MSG( CurTok() == T_image, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as an image." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as an image." ) );
T token; T token;
std::unique_ptr<SCH_BITMAP> bitmap = std::make_unique<SCH_BITMAP>(); std::unique_ptr<SCH_BITMAP> bitmap = std::make_unique<SCH_BITMAP>();
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2465,10 +2465,10 @@ SCH_BITMAP* SCH_SEXPR_PARSER::parseImage()
token = NextTok(); token = NextTok();
} }
wxMemoryBuffer buffer = wxBase64Decode( data ); wxMemoryBuffer buffer = wxBase64Decode( data );
wxMemoryOutputStream stream( buffer.GetData(), buffer.GetBufSize() ); wxMemoryOutputStream stream( buffer.GetData(), buffer.GetBufSize() );
wxImage* image = new wxImage(); wxImage* image = new wxImage();
wxMemoryInputStream istream( stream ); wxMemoryInputStream istream( stream );
image->LoadFile( istream, wxBITMAP_TYPE_PNG ); image->LoadFile( istream, wxBITMAP_TYPE_PNG );
bitmap->GetImage()->SetImage( image ); bitmap->GetImage()->SetImage( image );
bitmap->GetImage()->SetBitmap( new wxBitmap( *image ) ); bitmap->GetImage()->SetBitmap( new wxBitmap( *image ) );
@ -2500,7 +2500,7 @@ SCH_SHEET* SCH_SEXPR_PARSER::parseSheet()
// We'll reset this if we find a fields_autoplaced token // We'll reset this if we find a fields_autoplaced token
sheet->ClearFieldsAutoplaced(); sheet->ClearFieldsAutoplaced();
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2596,10 +2596,10 @@ SCH_JUNCTION* SCH_SEXPR_PARSER::parseJunction()
wxCHECK_MSG( CurTok() == T_junction, nullptr, wxCHECK_MSG( CurTok() == T_junction, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a junction." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a junction." ) );
T token; T token;
std::unique_ptr<SCH_JUNCTION> junction = std::make_unique<SCH_JUNCTION>(); std::unique_ptr<SCH_JUNCTION> junction = std::make_unique<SCH_JUNCTION>();
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2652,10 +2652,10 @@ SCH_NO_CONNECT* SCH_SEXPR_PARSER::parseNoConnect()
wxCHECK_MSG( CurTok() == T_no_connect, nullptr, wxCHECK_MSG( CurTok() == T_no_connect, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a no connect." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a no connect." ) );
T token; T token;
std::unique_ptr<SCH_NO_CONNECT> no_connect = std::make_unique<SCH_NO_CONNECT>(); std::unique_ptr<SCH_NO_CONNECT> no_connect = std::make_unique<SCH_NO_CONNECT>();
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2693,7 +2693,7 @@ SCH_BUS_WIRE_ENTRY* SCH_SEXPR_PARSER::parseBusEntry()
STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT );
std::unique_ptr<SCH_BUS_WIRE_ENTRY> busEntry = std::make_unique<SCH_BUS_WIRE_ENTRY>(); std::unique_ptr<SCH_BUS_WIRE_ENTRY> busEntry = std::make_unique<SCH_BUS_WIRE_ENTRY>();
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2755,7 +2755,7 @@ SCH_LINE* SCH_SEXPR_PARSER::parseLine()
std::unique_ptr<SCH_LINE> line = std::make_unique<SCH_LINE>( wxPoint(), layer ); std::unique_ptr<SCH_LINE> line = std::make_unique<SCH_LINE>( wxPoint(), layer );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2809,20 +2809,20 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchArc()
wxCHECK_MSG( CurTok() == T_arc, nullptr, wxCHECK_MSG( CurTok() == T_arc, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as an arc." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as an arc." ) );
T token; T token;
wxPoint startPoint; wxPoint startPoint;
wxPoint midPoint; wxPoint midPoint;
wxPoint endPoint; wxPoint endPoint;
wxPoint pos; wxPoint pos;
int startAngle; int startAngle;
int endAngle; int endAngle;
STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT );
FILL_PARAMS fill; FILL_PARAMS fill;
bool hasMidPoint = false; bool hasMidPoint = false;
bool hasAngles = false; bool hasAngles = false;
std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>( SHAPE_T::ARC ); std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>( SHAPE_T::ARC );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2848,7 +2848,7 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchArc()
break; break;
case T_radius: case T_radius:
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -2945,14 +2945,14 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchCircle()
wxCHECK_MSG( CurTok() == T_circle, nullptr, wxCHECK_MSG( CurTok() == T_circle, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a circle." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a circle." ) );
T token; T token;
wxPoint center; wxPoint center;
int radius; int radius;
STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT );
FILL_PARAMS fill; FILL_PARAMS fill;
std::unique_ptr<SCH_SHAPE> circle = std::make_unique<SCH_SHAPE>( SHAPE_T::CIRCLE ); std::unique_ptr<SCH_SHAPE> circle = std::make_unique<SCH_SHAPE>( SHAPE_T::CIRCLE );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -3005,12 +3005,12 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchRectangle()
wxCHECK_MSG( CurTok() == T_rectangle, nullptr, wxCHECK_MSG( CurTok() == T_rectangle, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a rectangle." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a rectangle." ) );
T token; T token;
STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT );
FILL_PARAMS fill; FILL_PARAMS fill;
std::unique_ptr<SCH_SHAPE> rectangle = std::make_unique<SCH_SHAPE>( SHAPE_T::RECT ); std::unique_ptr<SCH_SHAPE> rectangle = std::make_unique<SCH_SHAPE>( SHAPE_T::RECT );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -3060,12 +3060,12 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchBezier()
wxCHECK_MSG( CurTok() == T_bezier, nullptr, wxCHECK_MSG( CurTok() == T_bezier, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a bezier." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a bezier." ) );
T token; T token;
STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT );
FILL_PARAMS fill; FILL_PARAMS fill;
std::unique_ptr<SCH_SHAPE> bezier = std::make_unique<SCH_SHAPE>( SHAPE_T::BEZIER ); std::unique_ptr<SCH_SHAPE> bezier = std::make_unique<SCH_SHAPE>( SHAPE_T::BEZIER );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -3120,7 +3120,7 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchBezier()
SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
{ {
T token; T token;
std::unique_ptr<SCH_TEXT> text; std::unique_ptr<SCH_TEXT> text;
switch( CurTok() ) switch( CurTok() )
@ -3145,7 +3145,7 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
text->SetText( FromUTF8() ); text->SetText( FromUTF8() );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
if( token != T_LEFT ) if( token != T_LEFT )
Expecting( T_LEFT ); Expecting( T_LEFT );
@ -3220,15 +3220,15 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
// Spin style is defined differently for graphical text (#SCH_TEXT) objects. // Spin style is defined differently for graphical text (#SCH_TEXT) objects.
if( text->Type() == SCH_TEXT_T ) if( text->Type() == SCH_TEXT_T )
{ {
if( text->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT if( text->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT
&& text->GetTextAngle() == TEXT_ANGLE_VERT ) && text->GetTextAngle().IsVertical() )
{ {
// The vertically aligned text angle is always 90 (labels use 270 for the // The vertically aligned text angle is always 90 (labels use 270 for the
// down direction) combined with the text justification flags. // down direction) combined with the text justification flags.
text->SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM ); text->SetLabelSpinStyle( LABEL_SPIN_STYLE::BOTTOM );
} }
else if( text->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT else if( text->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT
&& text->GetTextAngle() == TEXT_ANGLE_HORIZ ) && text->GetTextAngle().IsHorizontal() )
{ {
// The horizontally aligned text angle is always 0 (labels use 180 for the // The horizontally aligned text angle is always 0 (labels use 180 for the
// left direction) combined with the text justification flags. // 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(), aField->GetId(),
FormatInternalUnits( aField->GetPosition().x ).c_str(), FormatInternalUnits( aField->GetPosition().x ).c_str(),
FormatInternalUnits( aField->GetPosition().y ).c_str(), FormatInternalUnits( aField->GetPosition().y ).c_str(),
FormatAngle( aField->GetTextAngleDegrees() * 10.0 ).c_str() ); FormatAngle( aField->GetTextAngle().AsTenthsOfADegree() ).c_str() );
if( !aField->IsDefaultFormatting() if( !aField->IsDefaultFormatting()
|| ( aField->GetTextHeight() != Mils2iu( DEFAULT_SIZE_TEXT ) ) ) || ( 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)", m_out->Print( aNestLevel + 1, "(at %s %s %s)",
FormatInternalUnits( aText->GetPosition().x ).c_str(), FormatInternalUnits( aText->GetPosition().x ).c_str(),
FormatInternalUnits( aText->GetPosition().y ).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 ) if( aText->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
@ -2042,7 +2042,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFor
aField->GetId(), aField->GetId(),
FormatInternalUnits( aField->GetPosition().x ).c_str(), FormatInternalUnits( aField->GetPosition().x ).c_str(),
FormatInternalUnits( aField->GetPosition().y ).c_str(), FormatInternalUnits( aField->GetPosition().y ).c_str(),
static_cast<double>( aField->GetTextAngle() ) / 10.0 ); aField->GetTextAngle().AsDegrees() );
aField->Format( &aFormatter, aNestLevel, 0 ); aField->Format( &aFormatter, aNestLevel, 0 );
aFormatter.Print( aNestLevel, ")\n" ); 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(), aFormatter.Quotew( aText->GetText() ).c_str(),
FormatInternalUnits( aText->GetPosition().x ).c_str(), FormatInternalUnits( aText->GetPosition().x ).c_str(),
FormatInternalUnits( aText->GetPosition().y ).c_str(), FormatInternalUnits( aText->GetPosition().y ).c_str(),
aText->GetTextAngle() ); (double) aText->GetTextAngle().AsTenthsOfADegree() );
aText->Format( &aFormatter, aNestLevel, 0 ); aText->Format( &aFormatter, aNestLevel, 0 );
aFormatter.Print( aNestLevel, ")\n" ); 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 ); parseQuotedString( name, aReader, line, &line, true );
if( hjustify == 'L' ) if( hjustify == 'L' )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
else if( hjustify == 'R' ) else if( hjustify == 'R' )
field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( hjustify != 'C' ) else if( hjustify != 'C' )
SCH_PARSE_ERROR( "symbol field text horizontal justification must be " SCH_PARSE_ERROR( "symbol field text horizontal justification must be "
"L, R, or C", aReader, line ); "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 // We are guaranteed to have a least one character here for older file formats
// otherwise an exception would have been raised.. // otherwise an exception would have been raised..
if( textAttrs[0] == 'T' ) if( textAttrs[0] == 'T' )
field.SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); field.SetVertJustify( GR_TEXT_V_ALIGN_TOP );
else if( textAttrs[0] == 'B' ) else if( textAttrs[0] == 'B' )
field.SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); field.SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else if( textAttrs[0] != 'C' ) else if( textAttrs[0] != 'C' )
SCH_PARSE_ERROR( "symbol field text vertical justification must be " SCH_PARSE_ERROR( "symbol field text vertical justification must be "
"B, T, or C", aReader, line ); "B, T, or C", aReader, line );
@ -1784,9 +1784,9 @@ SCH_SYMBOL* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader )
field.SetTextSize( wxSize( size, size ) ); field.SetTextSize( wxSize( size, size ) );
if( orientation == 'H' ) if( orientation == 'H' )
field.SetTextAngle( TEXT_ANGLE_HORIZ ); field.SetTextAngle( EDA_ANGLE::HORIZONTAL );
else if( orientation == 'V' ) else if( orientation == 'V' )
field.SetTextAngle( TEXT_ANGLE_VERT ); field.SetTextAngle( EDA_ANGLE::VERTICAL );
else else
SCH_PARSE_ERROR( "symbol field orientation must be H or V", aReader, line ); 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'; char hjustify = 'C';
if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
hjustify = 'L'; hjustify = 'L';
else if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) else if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
hjustify = 'R'; hjustify = 'R';
char vjustify = 'C'; char vjustify = 'C';
if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
vjustify = 'B'; vjustify = 'B';
else if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) else if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
vjustify = 'T'; vjustify = 'T';
m_out->Print( 0, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", m_out->Print( 0, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
aField->GetId(), aField->GetId(),
EscapedUTF8( aField->GetText() ).c_str(), // wraps in quotes too 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().x ),
Iu2Mils( aField->GetLibPosition().y ), Iu2Mils( aField->GetLibPosition().y ),
Iu2Mils( aField->GetTextWidth() ), 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 ); char textOrient = parseChar( aReader, line, &line );
if( textOrient == 'H' ) if( textOrient == 'H' )
field->SetTextAngle( TEXT_ANGLE_HORIZ ); field->SetTextAngle( EDA_ANGLE::HORIZONTAL );
else if( textOrient == 'V' ) else if( textOrient == 'V' )
field->SetTextAngle( TEXT_ANGLE_VERT ); field->SetTextAngle( EDA_ANGLE::VERTICAL );
else else
SCH_PARSE_ERROR( "invalid field text orientation parameter", aReader, line ); 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 ); char textHJustify = parseChar( aReader, line, &line );
if( textHJustify == 'C' ) if( textHJustify == 'C' )
field->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); field->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
else if( textHJustify == 'L' ) else if( textHJustify == 'L' )
field->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); field->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
else if( textHJustify == 'R' ) else if( textHJustify == 'R' )
field->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); field->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else else
SCH_PARSE_ERROR( "invalid field text horizontal justification", aReader, line ); 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] ) switch( (wxChar) attributes[0] )
{ {
case 'C': field->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; case 'C': field->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break;
case 'B': field->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; case 'B': field->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break;
case 'T': field->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break; case 'T': field->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break;
default: SCH_PARSE_ERROR( "invalid field text vertical justification", aReader, line ); 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 ) ) switch( parseChar( aReader, line, &line ) )
{ {
case 'L': text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break; case 'L': text->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break;
case 'C': text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); break; case 'C': text->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break;
case 'R': text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break; case 'R': text->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break;
default: SCH_PARSE_ERROR( "invalid horizontal text justication; expected L, C, or R", default: SCH_PARSE_ERROR( "invalid horizontal text justication; expected L, C, or R",
aReader, line ); aReader, line );
} }
switch( parseChar( aReader, line, &line ) ) switch( parseChar( aReader, line, &line ) )
{ {
case 'T': text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break; case 'T': text->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); break;
case 'C': text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; case 'C': text->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); break;
case 'B': text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; case 'B': text->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); break;
default: SCH_PARSE_ERROR( "invalid vertical text justication; expected T, C, or B", default: SCH_PARSE_ERROR( "invalid vertical text justication; expected T, C, or B",
aReader, line ); aReader, line );
} }
@ -4058,16 +4058,16 @@ void SCH_LEGACY_PLUGIN_CACHE::saveField( const LIB_FIELD* aField, OUTPUTFORMATTE
hjustify = 'C'; hjustify = 'C';
if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
hjustify = 'L'; hjustify = 'L';
else if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) else if( aField->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
hjustify = 'R'; hjustify = 'R';
vjustify = 'C'; vjustify = 'C';
if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
vjustify = 'B'; vjustify = 'B';
else if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) else if( aField->GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
vjustify = 'T'; vjustify = 'T';
aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c", 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().x ),
Iu2Mils( aField->GetTextPos().y ), Iu2Mils( aField->GetTextPos().y ),
Iu2Mils( aField->GetTextWidth() ), Iu2Mils( aField->GetTextWidth() ),
aField->GetTextAngle() == 0 ? 'H' : 'V', aField->GetTextAngle().IsHorizontal() ? 'H' : 'V',
aField->IsVisible() ? 'V' : 'I', aField->IsVisible() ? 'V' : 'I',
hjustify, vjustify, hjustify, vjustify,
aField->IsItalic() ? 'I' : 'N', aField->IsItalic() ? 'I' : 'N',
@ -4207,25 +4207,30 @@ void SCH_LEGACY_PLUGIN_CACHE::saveText( const LIB_TEXT* aText, OUTPUTFORMATTER&
text = wxT( "\"" ) + text + wxT( "\"" ); text = wxT( "\"" ) + text + wxT( "\"" );
} }
aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", aText->GetTextAngle(), aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s",
Iu2Mils( aText->GetTextPos().x ), Iu2Mils( aText->GetTextPos().y ), (double) aText->GetTextAngle().AsTenthsOfADegree(),
Iu2Mils( aText->GetTextWidth() ), !aText->IsVisible(), Iu2Mils( aText->GetTextPos().x ),
aText->GetUnit(), aText->GetConvert(), TO_UTF8( text ) ); 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() ); aFormatter.Print( 0, " %s %d", aText->IsItalic() ? "Italic" : "Normal", aText->IsBold() );
char hjustify = 'C'; char hjustify = 'C';
if( aText->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
hjustify = 'L'; hjustify = 'L';
else if( aText->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) else if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
hjustify = 'R'; hjustify = 'R';
char vjustify = 'C'; char vjustify = 'C';
if( aText->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) if( aText->GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM )
vjustify = 'B'; vjustify = 'B';
else if( aText->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) else if( aText->GetVertJustify() == GR_TEXT_V_ALIGN_TOP )
vjustify = 'T'; vjustify = 'T';
aFormatter.Print( 0, " %c %c\n", hjustify, vjustify ); 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() ) if( IsVerticalOrientation() )
{ {
m_fields[ SHEETNAME ].SetTextPos( m_pos + wxPoint( -margin, m_size.y ) ); m_fields[ SHEETNAME ].SetTextPos( m_pos + wxPoint( -margin, m_size.y ) );
m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETNAME ].SetVertJustify(GR_TEXT_VJUSTIFY_BOTTOM ); m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
m_fields[ SHEETNAME ].SetTextAngle( TEXT_ANGLE_VERT ); m_fields[ SHEETNAME ].SetTextAngle( EDA_ANGLE::VERTICAL );
} }
else else
{ {
m_fields[ SHEETNAME ].SetTextPos( m_pos + wxPoint( 0, -margin ) ); m_fields[ SHEETNAME ].SetTextPos( m_pos + wxPoint( 0, -margin ) );
m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETNAME ].SetVertJustify(GR_TEXT_VJUSTIFY_BOTTOM ); m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
m_fields[ SHEETNAME ].SetTextAngle( TEXT_ANGLE_HORIZ ); m_fields[ SHEETNAME ].SetTextAngle( EDA_ANGLE::HORIZONTAL );
} }
textSize = m_fields[ SHEETFILENAME ].GetTextSize(); textSize = m_fields[ SHEETFILENAME ].GetTextSize();
@ -576,16 +576,16 @@ void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
if( IsVerticalOrientation() ) if( IsVerticalOrientation() )
{ {
m_fields[ SHEETFILENAME ].SetTextPos( m_pos + wxPoint( m_size.x + margin, m_size.y ) ); 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 ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETFILENAME ].SetVertJustify(GR_TEXT_VJUSTIFY_TOP ); m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP );
m_fields[ SHEETFILENAME ].SetTextAngle( TEXT_ANGLE_VERT ); m_fields[ SHEETFILENAME ].SetTextAngle( EDA_ANGLE::VERTICAL );
} }
else else
{ {
m_fields[ SHEETFILENAME ].SetTextPos( m_pos + wxPoint( 0, m_size.y + margin ) ); m_fields[ SHEETFILENAME ].SetTextPos( m_pos + wxPoint( 0, m_size.y + margin ) );
m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETFILENAME ].SetVertJustify(GR_TEXT_VJUSTIFY_TOP ); m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP );
m_fields[ SHEETFILENAME ].SetTextAngle( TEXT_ANGLE_HORIZ ); m_fields[ SHEETFILENAME ].SetTextAngle( EDA_ANGLE::HORIZONTAL );
} }
m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO; m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO;

View File

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

View File

@ -485,9 +485,9 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::deleteTool, EDIT_TOOL( ACTIONS::deleteTool ) ); mgr->SetConditions( ACTIONS::deleteTool, EDIT_TOOL( ACTIONS::deleteTool ) );
mgr->SetConditions( EE_ACTIONS::placeSymbolPin, EDIT_TOOL( EE_ACTIONS::placeSymbolPin ) ); mgr->SetConditions( EE_ACTIONS::placeSymbolPin, EDIT_TOOL( EE_ACTIONS::placeSymbolPin ) );
mgr->SetConditions( EE_ACTIONS::placeSymbolText, EDIT_TOOL( EE_ACTIONS::placeSymbolText ) ); mgr->SetConditions( EE_ACTIONS::placeSymbolText, EDIT_TOOL( EE_ACTIONS::placeSymbolText ) );
mgr->SetConditions( EE_ACTIONS::drawRectangle, EDIT_TOOL( EE_ACTIONS::drawRectangle ) ); mgr->SetConditions( EE_ACTIONS::drawRectangle, EDIT_TOOL( EE_ACTIONS::drawRectangle ) );
mgr->SetConditions( EE_ACTIONS::drawCircle, EDIT_TOOL( EE_ACTIONS::drawCircle ) ); mgr->SetConditions( EE_ACTIONS::drawCircle, EDIT_TOOL( EE_ACTIONS::drawCircle ) );
mgr->SetConditions( EE_ACTIONS::drawArc, EDIT_TOOL( EE_ACTIONS::drawArc ) ); mgr->SetConditions( EE_ACTIONS::drawArc, EDIT_TOOL( EE_ACTIONS::drawArc ) );
mgr->SetConditions( EE_ACTIONS::drawSymbolLines, EDIT_TOOL( EE_ACTIONS::drawSymbolLines ) ); mgr->SetConditions( EE_ACTIONS::drawSymbolLines, EDIT_TOOL( EE_ACTIONS::drawSymbolLines ) );
mgr->SetConditions( EE_ACTIONS::placeSymbolAnchor, EDIT_TOOL( EE_ACTIONS::placeSymbolAnchor ) ); mgr->SetConditions( EE_ACTIONS::placeSymbolAnchor, EDIT_TOOL( EE_ACTIONS::placeSymbolAnchor ) );
@ -1320,7 +1320,7 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol )
libField.SetName( field.GetName( false ) ); libField.SetName( field.GetName( false ) );
libField.SetText( field.GetText() ); libField.SetText( field.GetText() );
libField.SetEffects( field ); libField.SetAttributes( field );
libField.SetPosition( wxPoint( pos.x, -pos.y ) ); libField.SetPosition( wxPoint( pos.x, -pos.y ) );
fullSetOfFields.emplace_back( std::move( libField ) ); 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 ); SCH_FIELD* field = static_cast<SCH_FIELD*>( head );
if( field->GetTextAngle() == TEXT_ANGLE_HORIZ ) if( field->GetTextAngle().IsHorizontal() )
field->SetTextAngle( TEXT_ANGLE_VERT ); field->SetTextAngle( EDA_ANGLE::VERTICAL );
else else
field->SetTextAngle( TEXT_ANGLE_HORIZ ); field->SetTextAngle( EDA_ANGLE::HORIZONTAL );
// Now that we're moving a field, they're no longer autoplaced. // Now that we're moving a field, they're no longer autoplaced.
static_cast<SCH_ITEM*>( head->GetParent() )->ClearFieldsAutoplaced(); static_cast<SCH_ITEM*>( head->GetParent() )->ClearFieldsAutoplaced();
@ -643,10 +643,10 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
field->Rotate( rotPoint ); field->Rotate( rotPoint );
if( field->GetTextAngle() == TEXT_ANGLE_HORIZ ) if( field->GetTextAngle().IsHorizontal() )
field->SetTextAngle( TEXT_ANGLE_VERT ); field->SetTextAngle( EDA_ANGLE::VERTICAL );
else else
field->SetTextAngle( TEXT_ANGLE_HORIZ ); field->SetTextAngle( EDA_ANGLE::HORIZONTAL );
// Now that we're moving a field, they're no longer autoplaced. // Now that we're moving a field, they're no longer autoplaced.
static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced(); 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 ); SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
if( vertical ) if( vertical )
field->SetVertJustify( (EDA_TEXT_VJUSTIFY_T)-field->GetVertJustify() ); field->SetVertJustify( TO_VJUSTIFY( -field->GetVertJustify() ) );
else 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. // 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; break;
} }

View File

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

View File

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

View File

@ -105,7 +105,7 @@ bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, wxPoint& aPos, double& aOr
else else
size = std::min( m_Size.x, m_Size.y ); size = std::min( m_Size.x, m_Size.y );
aOrientation = TEXT_ANGLE_HORIZ; aOrientation = 0;
if( m_Flashed ) 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->SetFontUnderlined( false );
m_gal->SetTextMirrored( false ); m_gal->SetTextMirrored( false );
m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) ); m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->BitmapText( codeText, textPosition, orient ); m_gal->BitmapText( codeText, textPosition, orient );
return; return;

View File

@ -335,8 +335,8 @@ public:
wxString m_TextBase; // The basic text, with format symbols wxString m_TextBase; // The basic text, with format symbols
wxString m_FullText; // The expanded text, shown on screen wxString m_FullText; // The expanded text, shown on screen
double m_Orient; // Orientation in degrees double m_Orient; // Orientation in degrees
EDA_TEXT_HJUSTIFY_T m_Hjustify; GR_TEXT_H_ALIGN_T m_Hjustify;
EDA_TEXT_VJUSTIFY_T m_Vjustify; GR_TEXT_V_ALIGN_T m_Vjustify;
bool m_Italic; bool m_Italic;
bool m_Bold; bool m_Bold;
DSIZE m_TextSize; 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 <outline_mode.h>
#include <eda_rect.h> #include <eda_rect.h>
#include <font/text_attributes.h>
class OUTPUTFORMATTER; class OUTPUTFORMATTER;
class SHAPE_COMPOUND; class SHAPE_COMPOUND;
@ -66,33 +67,12 @@ namespace KIGFX
using KIGFX::RENDER_SETTINGS; using KIGFX::RENDER_SETTINGS;
using KIGFX::COLOR4D; 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. // part of the kicad_plugin.h family of defines.
// See kicad_plugin.h for the choice of the value // 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 // When set when calling EDA_TEXT::Format, disable writing the "hide" keyword in save file
#define CTL_OMIT_HIDE (1 << 6) #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 * This is the "default-of-the-default" hardcoded text size; individual
* application define their own default policy starting with this * 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 #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, * 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 * 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 * The TextThickness is that set by the user. The EffectiveTextPenWidth also factors
* in bold text and thickness clamping. * in bold text and thickness clamping.
*/ */
void SetTextThickness( int aWidth ) { m_e.penwidth = aWidth; }; void SetTextThickness( int aWidth ) { m_attributes.m_StrokeWidth = aWidth; };
int GetTextThickness() const { return m_e.penwidth; }; int GetTextThickness() const { return m_attributes.m_StrokeWidth; };
/** /**
* The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth. * The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
*/ */
int GetEffectiveTextPenWidth( int aDefaultWidth = 0 ) const; 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 // Higher level classes may be more restrictive than this by overloading
// SetTextAngle() or merely calling EDA_TEXT::SetTextAngle() after clamping // SetTextAngle() or merely calling EDA_TEXT::SetTextAngle() after clamping
// aAngle before calling this lowest inline accessor. // 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; } void SetTextAngle( const EDA_ANGLE& aAngle )
double GetTextAngleRadians() const { return GetTextAngle() * M_PI/1800; } {
m_attributes.m_Angle = aAngle;
}
void SetItalic( bool isItalic ) { m_e.Bit( TE_ITALIC, isItalic ); } const EDA_ANGLE& GetTextAngle() const { return m_attributes.m_Angle; }
bool IsItalic() const { return m_e.Bit( TE_ITALIC ); }
void SetBold( bool aBold ) { m_e.Bit( TE_BOLD, aBold); } void SetItalic( bool aItalic ) { m_attributes.m_Italic = aItalic; }
bool IsBold() const { return m_e.Bit( TE_BOLD ); } bool IsItalic() const { return m_attributes.m_Italic; }
virtual void SetVisible( bool aVisible ) { m_e.Bit( TE_VISIBLE, aVisible ); } void SetBold( bool aBold ) { m_attributes.m_Bold = aBold; }
virtual bool IsVisible() const { return m_e.Bit( TE_VISIBLE ); } bool IsBold() const { return m_attributes.m_Bold; }
void SetMirrored( bool isMirrored ) { m_e.Bit( TE_MIRROR, isMirrored ); } virtual void SetVisible( bool aVisible ) { m_attributes.m_Visible = aVisible; }
bool IsMirrored() const { return m_e.Bit( TE_MIRROR ); } 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 * @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.) * text. (Single line is faster in calculations than multiline.)
*/ */
void SetMultilineAllowed( bool aAllow ) { m_e.Bit( TE_MULTILINE, aAllow ); } void SetMultilineAllowed( bool aAllow ) { m_attributes.m_Multiline = aAllow; }
bool IsMultilineAllowed() const { return m_e.Bit( TE_MULTILINE ); } bool IsMultilineAllowed() const { return m_attributes.m_Multiline; }
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const { return EDA_TEXT_HJUSTIFY_T( m_e.hjustify ); }; GR_TEXT_H_ALIGN_T GetHorizJustify() const { return m_attributes.m_Halign; };
EDA_TEXT_VJUSTIFY_T GetVertJustify() const { return EDA_TEXT_VJUSTIFY_T( m_e.vjustify ); }; GR_TEXT_V_ALIGN_T GetVertJustify() const { return m_attributes.m_Valign; };
void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_e.hjustify = aType; }; void SetHorizJustify( GR_TEXT_H_ALIGN_T aType ) { m_attributes.m_Halign = aType; };
void SetVertJustify( EDA_TEXT_VJUSTIFY_T aType ) { m_e.vjustify = aType; }; void SetVertJustify( GR_TEXT_V_ALIGN_T aType ) { m_attributes.m_Valign = aType; };
/** /**
* Set the text effects from another instance. * Set the text attributes from another instance.
*
* #TEXT_EFFECTS is not exposed in the public API, but includes everything except the actual
* text string itself.
*/ */
void SetEffects( const EDA_TEXT& aSrc ); void SetAttributes( const EDA_TEXT& aSrc );
/** /**
* Swap the text effects of the two involved instances. * Swap the text attributes of the two involved instances.
*
* #TEXT_EFFECTS is not exposed in the public API, but includes everything except the actual
* text string itself.
*/ */
void SwapEffects( EDA_TEXT& aTradingPartner ); void SwapAttributes( EDA_TEXT& aTradingPartner );
void SwapText( EDA_TEXT& aTradingPartner ); void SwapText( EDA_TEXT& aTradingPartner );
@ -255,28 +203,29 @@ public:
bool IsDefaultFormatting() const; bool IsDefaultFormatting() const;
void SetTextSize( const wxSize& aNewSize ) { m_e.size = aNewSize; } void SetTextSize( const wxSize& aNewSize ) { m_attributes.m_Size = aNewSize; }
const wxSize& GetTextSize() const { return m_e.size; } wxSize GetTextSize() const { return wxSize( m_attributes.m_Size.x,
m_attributes.m_Size.y ); }
void SetTextWidth( int aWidth ) { m_e.size.x = aWidth; } void SetTextWidth( int aWidth ) { m_attributes.m_Size.x = aWidth; }
int GetTextWidth() const { return m_e.size.x; } int GetTextWidth() const { return m_attributes.m_Size.x; }
void SetTextHeight( int aHeight ) { m_e.size.y = aHeight; } void SetTextHeight( int aHeight ) { m_attributes.m_Size.y = aHeight; }
int GetTextHeight() const { return m_e.size.y; } int GetTextHeight() const { return m_attributes.m_Size.y; }
void SetTextPos( const wxPoint& aPoint ) { m_e.pos = aPoint; } void SetTextPos( const wxPoint& aPoint ) { m_pos = aPoint; }
const wxPoint& GetTextPos() const { return m_e.pos; } const wxPoint& GetTextPos() const { return m_pos; }
void SetTextX( int aX ) { m_e.pos.x = aX; } void SetTextX( int aX ) { m_pos.x = aX; }
void SetTextY( int aY ) { m_e.pos.y = aY; } 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(); } 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. * 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 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 wxPoint GetDrawPos() const { return GetTextPos(); }
virtual EDA_TEXT_HJUSTIFY_T GetDrawHorizJustify() const { return GetHorizJustify(); }; virtual GR_TEXT_H_ALIGN_T GetDrawHorizJustify() const { return GetHorizJustify(); };
virtual EDA_TEXT_VJUSTIFY_T GetDrawVertJustify() const { return GetVertJustify(); }; virtual GR_TEXT_V_ALIGN_T GetDrawVertJustify() const { return GetVertJustify(); };
int Compare( const EDA_TEXT* aOther ) const; int Compare( const EDA_TEXT* aOther ) const;
@ -396,7 +345,7 @@ private:
void cacheShownText(); void cacheShownText();
/** /**
* Print each line of this EDA_TEXT.. * Print each line of this EDA_TEXT.
* *
* @param aOffset draw offset (usually (0,0)). * @param aOffset draw offset (usually (0,0)).
* @param aColor text color. * @param aColor text color.
@ -408,19 +357,12 @@ private:
const COLOR4D& aColor, OUTLINE_MODE aFillMode, const wxString& aText, const COLOR4D& aColor, OUTLINE_MODE aFillMode, const wxString& aText,
const wxPoint& aPos ); const wxPoint& aPos );
wxString m_text; wxString m_text;
wxString m_shown_text; // Cache of unescaped text for efficient access wxString m_shown_text; // Cache of unescaped text for efficient access
bool m_shown_text_has_text_var_refs; bool m_shown_text_has_text_var_refs;
TEXT_EFFECTS m_e; // Private bitflags for text styling. API above TEXT_ATTRIBUTES m_attributes;
// provides accessor funcs. wxPoint m_pos;
enum TE_FLAGS {
TE_MIRROR,
TE_ITALIC,
TE_BOLD,
TE_MULTILINE,
TE_VISIBLE,
};
}; };

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. * @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; textProperties.m_horizontalJustify = aHorizontalJustify;
} }
@ -455,7 +455,7 @@ public:
/** /**
* Return current text horizontal justification setting. * 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; return textProperties.m_horizontalJustify;
} }
@ -465,7 +465,7 @@ public:
* *
* @param aVerticalJustify is the vertical justify value. * @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; textProperties.m_verticalJustify = aVerticalJustify;
} }
@ -473,7 +473,7 @@ public:
/** /**
* Returns current text vertical justification setting. * 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; return textProperties.m_verticalJustify;
} }
@ -1218,13 +1218,13 @@ protected:
private: private:
struct TEXT_PROPERTIES struct TEXT_PROPERTIES
{ {
VECTOR2D m_glyphSize; ///< Size of the glyphs VECTOR2D m_glyphSize; ///< Size of the glyphs
EDA_TEXT_HJUSTIFY_T m_horizontalJustify; ///< Horizontal justification GR_TEXT_H_ALIGN_T m_horizontalJustify; ///< Horizontal justification
EDA_TEXT_VJUSTIFY_T m_verticalJustify; ///< Vertical justification GR_TEXT_V_ALIGN_T m_verticalJustify; ///< Vertical justification
bool m_bold; bool m_bold;
bool m_italic; bool m_italic;
bool m_underlined; bool m_underlined;
bool m_mirrored; bool m_mirrored;
} textProperties; } textProperties;
}; };

View File

@ -22,17 +22,16 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/** #ifndef GR_TEXT_H
* This file is part of the common library #define GR_TEXT_H
* @file drawtxt.h
* @see common.h
*/
#ifndef __INCLUDE__DRAWTXT_H__
#define __INCLUDE__DRAWTXT_H__ 1
#include <eda_item.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 * 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 aPos text position (according to h_justify, v_justify).
* @param aColor (COLOR4D) = text color. * @param aColor (COLOR4D) = text color.
* @param aText text to draw. * @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 aSize text size (size.x or size.y can be < 0 for mirrored texts).
* @param aH_justify horizontal justification (Left, center, right). * @param aH_justify horizontal justification (Left, center, right).
* @param aV_justify vertical justification (bottom, center, top). * @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 * @param aPlotter = a pointer to a PLOTTER instance, when this function is used to plot
* the text. NULL to draw this text. * the text. NULL to draw this text.
*/ */
void GRText( wxDC* aDC, const wxPoint& aPos, const COLOR4D& aColor, const wxString& aText, void GRText( wxDC* aDC, const wxPoint& aPos, const KIGFX::COLOR4D& aColor, const wxString& aText,
double aOrient, const wxSize& aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, const EDA_ANGLE& aOrient, const wxSize& aSize, enum GR_TEXT_H_ALIGN_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, 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 (*aCallback)( int x0, int y0, int xf, int yf, void* aData ) = nullptr,
void* aCallbackData = nullptr, PLOTTER* aPlotter = nullptr ); void* aCallbackData = nullptr, PLOTTER* aPlotter = nullptr );
/** #endif /* GR_TEXT_H */
* 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__ */

View File

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

View File

@ -152,15 +152,15 @@ public:
virtual void Text( const wxPoint& aPos, virtual void Text( const wxPoint& aPos,
const COLOR4D& aColor, const COLOR4D& aColor,
const wxString& aText, const wxString& aText,
double aOrient, const EDA_ANGLE& aOrient,
const wxSize& aSize, const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum GR_TEXT_H_ALIGN_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth, int aWidth,
bool aItalic, bool aItalic,
bool aBold, bool aBold,
bool aMultilineAllowed = false, bool aMultilineAllowed = false,
void* aData = nullptr ) override; void* aData = nullptr ) override;
/** /**

View File

@ -102,15 +102,15 @@ public:
virtual void Text( const wxPoint& aPos, virtual void Text( const wxPoint& aPos,
const COLOR4D& aColor, const COLOR4D& aColor,
const wxString& aText, const wxString& aText,
double aOrient, const EDA_ANGLE& aOrient,
const wxSize& aSize, const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum GR_TEXT_H_ALIGN_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify, enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth, int aWidth,
bool aItalic, bool aItalic,
bool aBold, bool aBold,
bool aMultilineAllowed = false, bool aMultilineAllowed = false,
void* aData = nullptr ) override; void* aData = nullptr ) override;
/** /**
* Filled circular flashes are stored as apertures * Filled circular flashes are stored as apertures

View File

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

View File

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

View File

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

View File

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

View File

@ -273,14 +273,14 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
switch ( m_edaText->GetHorizJustify() ) switch ( m_edaText->GetHorizJustify() )
{ {
case GR_TEXT_HJUSTIFY_LEFT: m_alignLeft->Check( true ); break; case GR_TEXT_H_ALIGN_LEFT: m_alignLeft->Check( true ); break;
case GR_TEXT_HJUSTIFY_CENTER: m_alignCenter->Check( true ); break; case GR_TEXT_H_ALIGN_CENTER: m_alignCenter->Check( true ); break;
case GR_TEXT_HJUSTIFY_RIGHT: m_alignRight->Check( true ); break; case GR_TEXT_H_ALIGN_RIGHT: m_alignRight->Check( true ); break;
} }
m_mirrored->Check( m_edaText->IsMirrored() ); m_mirrored->Check( m_edaText->IsMirrored() );
m_OrientValue = m_edaText->GetTextAngle(); m_OrientValue = m_edaText->GetTextAngle().AsTenthsOfADegree();
m_orientation.SetDoubleValue( m_OrientValue ); m_orientation.SetDoubleValue( m_OrientValue );
return DIALOG_TEXT_PROPERTIES_BASE::TransferDataToWindow(); return DIALOG_TEXT_PROPERTIES_BASE::TransferDataToWindow();
@ -377,11 +377,11 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
m_edaText->SetItalic( m_italic->IsChecked() ); m_edaText->SetItalic( m_italic->IsChecked() );
if( m_alignLeft->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() ) else if( m_alignCenter->IsChecked() )
m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); m_edaText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
else else
m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); m_edaText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
m_edaText->SetMirrored( m_mirrored->IsChecked() ); 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?) // Text on silk layer: RefDes and value (are they actually useful?)
for( FP_TEXT* textItem : { &footprint->Reference(), &footprint->Value() } ) for( FP_TEXT* textItem : { &footprint->Reference(), &footprint->Value() } )
{ {
double txt_orient = textItem->GetTextAngle();
std::string layer = GenCADLayerName( cu_count, std::string layer = GenCADLayerName( cu_count,
footprint->GetFlag() ? B_SilkS : F_SilkS ); footprint->GetFlag() ? B_SilkS : F_SilkS );
@ -901,7 +900,7 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
textItem->GetPos0().x / SCALE_FACTOR, textItem->GetPos0().x / SCALE_FACTOR,
-textItem->GetPos0().y / SCALE_FACTOR, -textItem->GetPos0().y / SCALE_FACTOR,
textItem->GetTextWidth() / SCALE_FACTOR, textItem->GetTextWidth() / SCALE_FACTOR,
txt_orient / 10.0, textItem->GetTextAngle().AsDegrees(),
mirror, mirror,
layer.c_str(), layer.c_str(),
TO_UTF8( escapeString( textItem->GetText() ) ) ); TO_UTF8( escapeString( textItem->GetText() ) ) );

View File

@ -252,9 +252,9 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
// Plot title "Info" // Plot title "Info"
wxString Text = wxT( "Drill Map:" ); 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 ) ), 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 // 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 // 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 ) if( tool.m_Hole_NotPlated )
msg += wxT( " (not plated)" ); 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 ) ), 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 ); 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 bool FP_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
{ {
EDA_RECT rect = GetTextBox(); EDA_RECT rect = GetTextBox();
@ -83,7 +89,7 @@ bool FP_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
RotatePoint( &location, GetTextPos(), -GetDrawRotation() ); RotatePoint( &location, GetTextPos(), -GetDrawRotation().AsTenthsOfADegree() );
return rect.Contains( location ); return rect.Contains( location );
} }
@ -98,7 +104,7 @@ bool FP_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
if( aContains ) if( aContains )
return rect.Contains( GetBoundingBox() ); return rect.Contains( GetBoundingBox() );
else 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() ) if( !IsKeepUpright() )
return; return;
double newAngle = GetTextAngle() + aNewOrientation; double newAngle = GetTextAngle().AsTenthsOfADegree() + aNewOrientation;
NORMALIZE_ANGLE_POS( newAngle ); NORMALIZE_ANGLE_POS( newAngle );
bool needsFlipped = newAngle >= 1800.0; bool needsFlipped = newAngle >= 1800.0;
if( needsFlipped ) if( needsFlipped )
{ {
SetHorizJustify( static_cast<EDA_TEXT_HJUSTIFY_T>( -GetHorizJustify() ) ); SetHorizJustify( static_cast<GR_TEXT_H_ALIGN_T>( -GetHorizJustify() ) );
SetTextAngle( GetTextAngle() + 1800.0 ); SetTextAngle( GetTextAngle().AsTenthsOfADegree() + 1800.0 );
SetDrawCoord(); SetDrawCoord();
} }
} }
@ -129,7 +135,7 @@ void FP_TEXT::Rotate( const wxPoint& aRotCentre, double aAngle )
RotatePoint( &pt, aRotCentre, aAngle ); RotatePoint( &pt, aRotCentre, aAngle );
SetTextPos( pt ); SetTextPos( pt );
SetTextAngle( GetTextAngle() + aAngle ); SetTextAngle( GetTextAngle().AsTenthsOfADegree() + aAngle );
SetLocalCoord(); SetLocalCoord();
} }
@ -145,7 +151,7 @@ void FP_TEXT::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
else else
{ {
SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) ); SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
SetTextAngle( 1800 - GetTextAngle() ); SetTextAngle( 1800 - GetTextAngle().AsTenthsOfADegree() );
} }
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
@ -226,7 +232,7 @@ void FP_TEXT::SetLocalCoord()
const EDA_RECT FP_TEXT::GetBoundingBox() const const EDA_RECT FP_TEXT::GetBoundingBox() const
{ {
double angle = GetDrawRotation(); double angle = GetDrawRotation().AsTenthsOfADegree();
EDA_RECT text_area = GetTextBox(); EDA_RECT text_area = GetTextBox();
if( angle ) 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 ); FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
double rotation = GetTextAngle(); double rotation = GetTextAngle().AsTenthsOfADegree();
if( parentFootprint ) if( parentFootprint )
rotation += parentFootprint->GetOrientation(); rotation += parentFootprint->GetOrientation();
@ -258,7 +264,7 @@ double FP_TEXT::GetDrawRotation() const
NORMALIZE_ANGLE_POS( rotation ); 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" ) ); aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
msg.Printf( wxT( "%g" ), GetTextAngleDegrees() ); msg.Printf( wxT( "%g" ), GetTextAngle().AsDegrees() );
aList.emplace_back( _( "Angle" ), msg ); aList.emplace_back( _( "Angle" ), msg );
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextThickness() ); msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextThickness() );
@ -344,10 +350,10 @@ EDA_ITEM* FP_TEXT::Clone() const
const BOX2I FP_TEXT::ViewBBox() const const BOX2I FP_TEXT::ViewBBox() const
{ {
double angle = GetDrawRotation(); double angle = GetDrawRotation().AsTenthsOfADegree();
EDA_RECT text_area = GetTextBox(); EDA_RECT text_area = GetTextBox();
if( angle != 0.0 ) if( angle )
text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle ); text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
return BOX2I( text_area.GetPosition(), text_area.GetSize() ); 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 ); const FOOTPRINT* parentFootprint = static_cast<const FOOTPRINT*>( m_parent );
if( parentFootprint ) if( parentFootprint )
buffer.Rotate( DECIDEG2RAD( GetDrawRotation() ), GetTextPos() ); buffer.Rotate( GetDrawRotation().AsRadians(), GetTextPos() );
aCornerBuffer.Append( buffer ); aCornerBuffer.Append( buffer );
} }

View File

@ -97,6 +97,7 @@ public:
} }
void SetTextAngle( double aAngle ) override; void SetTextAngle( double aAngle ) override;
void SetTextAngle( const EDA_ANGLE& aAngle );
/** /**
* Called when rotating the parent footprint. * Called when rotating the parent footprint.
@ -133,27 +134,6 @@ public:
void SetType( TEXT_TYPE aType ) { m_Type = aType; } void SetType( TEXT_TYPE aType ) { m_Type = aType; }
TEXT_TYPE GetType() const { return m_Type; } 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. // The Pos0 accessors are for footprint-relative coordinates.
void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); } void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
const wxPoint& GetPos0() const { return m_Pos0; } 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 * @return the text rotation for drawings and plotting the footprint rotation is taken
* in account. * in account.
*/ */
virtual double GetDrawRotation() const override; virtual EDA_ANGLE GetDrawRotation() const override;
double GetDrawRotationRadians() const { return GetDrawRotation() * M_PI/1800; }
// Virtual function // Virtual function
const EDA_RECT GetBoundingBox() const override; 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(); return text.GetLayerName();
case FPT_ORIENTATION: case FPT_ORIENTATION:
return StringFromValue( EDA_UNITS::DEGREES, (int) NormalizeAnglePos( text.GetTextAngle() ), return StringFromValue( EDA_UNITS::DEGREES,
NormalizeAnglePos( text.GetTextAngle().AsTenthsOfADegree() ),
true ); true );
case FPT_XOFFSET: 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 topLeft(0.0, 0.0);
VECTOR2D topRight(0.0, 0.0); VECTOR2D topRight(0.0, 0.0);
EDA_TEXT_HJUSTIFY_T hJustify = GR_TEXT_HJUSTIFY_LEFT; GR_TEXT_H_ALIGN_T hJustify = GR_TEXT_H_ALIGN_LEFT;
EDA_TEXT_VJUSTIFY_T vJustify = GR_TEXT_VJUSTIFY_BOTTOM; GR_TEXT_V_ALIGN_T vJustify = GR_TEXT_V_ALIGN_BOTTOM;
switch( aData.vJustification ) switch( aData.vJustification )
{ {
case 0: //DRW_Text::VBaseLine: case 0: //DRW_Text::VBaseLine:
case 1: //DRW_Text::VBottom: case 1: //DRW_Text::VBottom:
vJustify = GR_TEXT_VJUSTIFY_BOTTOM; vJustify = GR_TEXT_V_ALIGN_BOTTOM;
topLeft.y = textHeight; topLeft.y = textHeight;
topRight.y = textHeight; topRight.y = textHeight;
break; break;
case 2: //DRW_Text::VMiddle: case 2: //DRW_Text::VMiddle:
vJustify = GR_TEXT_VJUSTIFY_CENTER; vJustify = GR_TEXT_V_ALIGN_CENTER;
bottomRight.y = -textHeight / 2.0; bottomRight.y = -textHeight / 2.0;
bottomLeft.y = -textHeight / 2.0; bottomLeft.y = -textHeight / 2.0;
@ -611,7 +611,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
break; break;
case 3: //DRW_Text::VTop: case 3: //DRW_Text::VTop:
vJustify = GR_TEXT_VJUSTIFY_TOP; vJustify = GR_TEXT_V_ALIGN_TOP;
bottomLeft.y = -textHeight; bottomLeft.y = -textHeight;
bottomRight.y = -textHeight; bottomRight.y = -textHeight;
@ -623,7 +623,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
case 0: //DRW_Text::HLeft: case 0: //DRW_Text::HLeft:
case 3: //DRW_Text::HAligned: // no equivalent options in text pcb. case 3: //DRW_Text::HAligned: // no equivalent options in text pcb.
case 5: //DRW_Text::HFit: // 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; bottomRight.x = textWidth;
topRight.x = textWidth; topRight.x = textWidth;
@ -631,7 +631,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
case 1: //DRW_Text::HCenter: case 1: //DRW_Text::HCenter:
case 4: //DRW_Text::HMiddle: // no equivalent options in text pcb. 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; bottomLeft.x = -textWidth / 2.0;
topLeft.x = -textWidth / 2.0; topLeft.x = -textWidth / 2.0;
@ -640,7 +640,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
break; break;
case 2: //DRW_Text::HRight: case 2: //DRW_Text::HRight:
hJustify = GR_TEXT_HJUSTIFY_RIGHT; hJustify = GR_TEXT_H_ALIGN_RIGHT;
bottomLeft.x = -textWidth; bottomLeft.x = -textWidth;
topLeft.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 ) ); VECTOR2D textpos( mapX( textposCoords.x ), mapY( textposCoords.y ) );
// Initialize text justifications: // Initialize text justifications:
EDA_TEXT_HJUSTIFY_T hJustify = GR_TEXT_HJUSTIFY_LEFT; GR_TEXT_H_ALIGN_T hJustify = GR_TEXT_H_ALIGN_LEFT;
EDA_TEXT_VJUSTIFY_T vJustify = GR_TEXT_VJUSTIFY_BOTTOM; GR_TEXT_V_ALIGN_T vJustify = GR_TEXT_V_ALIGN_BOTTOM;
if( aData.attachmentPoint <= 3 ) if( aData.attachmentPoint <= 3 )
{ {
vJustify = GR_TEXT_VJUSTIFY_TOP; vJustify = GR_TEXT_V_ALIGN_TOP;
bottomLeft.y = -textHeight; bottomLeft.y = -textHeight;
bottomRight.y = -textHeight; bottomRight.y = -textHeight;
} }
else if( aData.attachmentPoint <= 6 ) else if( aData.attachmentPoint <= 6 )
{ {
vJustify = GR_TEXT_VJUSTIFY_CENTER; vJustify = GR_TEXT_V_ALIGN_CENTER;
bottomRight.y = -textHeight / 2.0; bottomRight.y = -textHeight / 2.0;
bottomLeft.y = -textHeight / 2.0; bottomLeft.y = -textHeight / 2.0;
@ -776,7 +776,7 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
} }
else else
{ {
vJustify = GR_TEXT_VJUSTIFY_BOTTOM; vJustify = GR_TEXT_V_ALIGN_BOTTOM;
topLeft.y = textHeight; topLeft.y = textHeight;
topRight.y = textHeight; topRight.y = textHeight;
@ -784,14 +784,14 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
if( aData.attachmentPoint % 3 == 1 ) if( aData.attachmentPoint % 3 == 1 )
{ {
hJustify = GR_TEXT_HJUSTIFY_LEFT; hJustify = GR_TEXT_H_ALIGN_LEFT;
bottomRight.x = textWidth; bottomRight.x = textWidth;
topRight.x = textWidth; topRight.x = textWidth;
} }
else if( aData.attachmentPoint % 3 == 2 ) else if( aData.attachmentPoint % 3 == 2 )
{ {
hJustify = GR_TEXT_HJUSTIFY_CENTER; hJustify = GR_TEXT_H_ALIGN_CENTER;
bottomLeft.x = -textWidth / 2.0; bottomLeft.x = -textWidth / 2.0;
topLeft.x = -textWidth / 2.0; topLeft.x = -textWidth / 2.0;
@ -800,7 +800,7 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
} }
else else
{ {
hJustify = GR_TEXT_HJUSTIFY_RIGHT; hJustify = GR_TEXT_H_ALIGN_RIGHT;
bottomLeft.x = -textWidth; bottomLeft.x = -textWidth;
topLeft.x = -textWidth; topLeft.x = -textWidth;

View File

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

View File

@ -48,29 +48,30 @@ void GRAPHICS_IMPORTER_BUFFER::AddCircle( const VECTOR2D& aCenter, double aRadiu
void GRAPHICS_IMPORTER_BUFFER::AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, void GRAPHICS_IMPORTER_BUFFER::AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart,
double aAngle, double aWidth ) double aAngle, double aWidth )
{ {
m_shapes.push_back( make_shape< IMPORTED_ARC >( aCenter, aStart, aAngle, aWidth ) ); m_shapes.push_back( make_shape<IMPORTED_ARC>( aCenter, aStart, aAngle, aWidth ) );
} }
void GRAPHICS_IMPORTER_BUFFER::AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) void GRAPHICS_IMPORTER_BUFFER::AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth )
{ {
m_shapes.push_back( make_shape< IMPORTED_POLYGON >( aVertices, aWidth ) ); m_shapes.push_back( make_shape<IMPORTED_POLYGON>( aVertices, aWidth ) );
} }
void GRAPHICS_IMPORTER_BUFFER::AddText( const VECTOR2D& aOrigin, const wxString& aText, void GRAPHICS_IMPORTER_BUFFER::AddText( const VECTOR2D& aOrigin, const wxString& aText,
double aHeight, double aWidth, double aThickness, double aOrientation, double aHeight, double aWidth, double aThickness,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) 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, m_shapes.push_back( make_shape< IMPORTED_TEXT >( aOrigin, aText, aHeight, aWidth,
aThickness, aOrientation, aHJustify, aVJustify ) ); aThickness, aOrientation, aHJustify, aVJustify ) );
} }
void GRAPHICS_IMPORTER_BUFFER::AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1, void GRAPHICS_IMPORTER_BUFFER::AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd , double aWidth ) const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd , double aWidth )
{ {
m_shapes.push_back( make_shape< IMPORTED_SPLINE >( aStart, aBezierControl1, aBezierControl2, aEnd, aWidth ) ); m_shapes.push_back( make_shape<IMPORTED_SPLINE>( aStart, aBezierControl1, aBezierControl2, aEnd, aWidth ) );
} }
@ -82,6 +83,6 @@ void GRAPHICS_IMPORTER_BUFFER::AddShape( std::unique_ptr<IMPORTED_SHAPE>& aShape
void GRAPHICS_IMPORTER_BUFFER::ImportTo( GRAPHICS_IMPORTER& aImporter ) 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 ); shape->ImportTo( aImporter );
} }

View File

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

View File

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

View File

@ -210,7 +210,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
else else
pcb_text->CopyText( *fp_text ); pcb_text->CopyText( *fp_text );
pcb_text->SetEffects( *fp_text ); pcb_text->SetAttributes( *fp_text );
pcb_text->SetLayer( fp_text->GetLayer() ); pcb_text->SetLayer( fp_text->GetLayer() );
copy = pcb_text; 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 ) 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 ) if( newAngle >= 3600 )
newAngle -= 3600; newAngle -= 3600;
@ -613,7 +613,7 @@ void PCB_DIM_ALIGNED::updateGeometry()
polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y ); polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y );
polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd() );
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); 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 // The ideal crossbar, if the text doesn't collide
SEG crossbar( m_crossBarStart, m_crossBarEnd ); 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.GetOrigin().x, textBox.GetEnd().y );
polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd() );
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); 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 // The ideal crossbar, if the text doesn't collide
SEG crossbar( m_crossBarStart, m_crossBarEnd ); 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.GetOrigin().x, textBox.GetEnd().y );
polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd() );
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); 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 firstLine( m_end - m_start );
VECTOR2I start( 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.GetOrigin().x, textBox.GetEnd().y );
polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd() );
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); 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 ); VECTOR2I radial( m_end - m_start );
radial = radial.Resize( m_leaderLength ); 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->SetFontUnderlined( false );
m_gal->SetTextMirrored( false ); m_gal->SetTextMirrored( false );
m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) ); m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->BitmapText( netName, textPosition, textOrientation ); m_gal->BitmapText( netName, textPosition, textOrientation );
return; return;
@ -912,8 +912,8 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
size = maxSize; size = maxSize;
// Default font settings // Default font settings
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
m_gal->SetFontBold( false ); m_gal->SetFontBold( false );
m_gal->SetFontItalic( false ); m_gal->SetFontItalic( false );
m_gal->SetFontUnderlined( 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->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetTextAttributes( aText ); 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->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetTextAttributes( aText ); m_gal->SetTextAttributes( aText );
m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() ); m_gal->StrokeText( shownText, position, aText->GetDrawRotation().AsRadians() );
// Draw the umbilical line // Draw the umbilical line
if( aText->IsSelected() ) if( aText->IsSelected() )
@ -1686,8 +1686,8 @@ void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
m_gal->SetFontItalic( true ); m_gal->SetFontItalic( true );
m_gal->SetFontUnderlined( false ); m_gal->SetFontUnderlined( false );
m_gal->SetTextMirrored( m_gal->IsFlippedX() ); m_gal->SetTextMirrored( m_gal->IsFlippedX() );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_BOTTOM );
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetGlyphSize( VECTOR2D( textSize, textSize ) ); m_gal->SetGlyphSize( VECTOR2D( textSize, textSize ) );
m_gal->SetLineWidth( penWidth ); 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->SetLineWidth( getLineThickness( text.GetEffectiveTextPenWidth() ) );
m_gal->SetTextAttributes( &text ); 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 ) void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{ {
EDA_UNITS units = aFrame->GetUserUnits(); 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( _( "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( _( "Thickness" ), MessageTextFromValue( units, GetTextThickness() ) );
aList.emplace_back( _( "Width" ), MessageTextFromValue( units, GetTextWidth() ) ); aList.emplace_back( _( "Width" ), MessageTextFromValue( units, GetTextWidth() ) );
@ -133,8 +139,8 @@ const EDA_RECT PCB_TEXT::GetBoundingBox() const
{ {
EDA_RECT rect = GetTextBox(); EDA_RECT rect = GetTextBox();
if( GetTextAngle() != 0 ) if( GetTextAngle() != EDA_ANGLE::ANGLE_0 )
rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle() ); rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
return rect; return rect;
} }
@ -165,7 +171,7 @@ void PCB_TEXT::Rotate( const wxPoint& aRotCentre, double aAngle )
RotatePoint( &pt, aRotCentre, aAngle ); RotatePoint( &pt, aRotCentre, aAngle );
SetTextPos( pt ); SetTextPos( pt );
SetTextAngle( GetTextAngle() + aAngle ); SetTextAngle( GetTextAngle().AsTenthsOfADegree() + aAngle );
} }
@ -179,7 +185,7 @@ void PCB_TEXT::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
else else
{ {
SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) ); SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
SetTextAngle( 1800 - GetTextAngle() ); SetTextAngle( 1800 - GetTextAngle().AsTenthsOfADegree() );
} }
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );

View File

@ -89,6 +89,7 @@ public:
} }
void SetTextAngle( double aAngle ) override; void SetTextAngle( double aAngle ) override;
void SetTextAngle( const EDA_ANGLE& aAngle );
void Rotate( const wxPoint& aRotCentre, double aAngle ) override; 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 : // calculate some text parameters :
wxSize size = aTextMod->GetTextSize(); wxSize size = aTextMod->GetTextSize();
wxPoint pos = aTextMod->GetTextPos(); wxPoint pos = aTextMod->GetTextPos();
double orient = aTextMod->GetDrawRotation();
int thickness = aTextMod->GetEffectiveTextPenWidth(); int thickness = aTextMod->GetEffectiveTextPenWidth();
if( aTextMod->IsMirrored() ) if( aTextMod->IsMirrored() )
@ -412,7 +411,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aTextMod, const COL
m_plotter->SetCurrentLineWidth( thickness ); 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->GetHorizJustify(), aTextMod->GetVertJustify(), thickness,
aTextMod->IsItalic(), allow_bold, false, &gbr_metadata ); aTextMod->IsItalic(), allow_bold, false, &gbr_metadata );
} }
@ -757,7 +756,6 @@ void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText )
wxSize size = aText->GetTextSize(); wxSize size = aText->GetTextSize();
wxPoint pos = aText->GetTextPos(); wxPoint pos = aText->GetTextPos();
double orient = aText->GetTextAngle();
int thickness = aText->GetEffectiveTextPenWidth(); int thickness = aText->GetEffectiveTextPenWidth();
if( aText->IsMirrored() ) if( aText->IsMirrored() )
@ -783,16 +781,16 @@ void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText )
for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
{ {
wxString& txt = strings_list.Item( ii ); wxString& txt = strings_list.Item( ii );
m_plotter->Text( positions[ii], color, txt, orient, size, aText->GetHorizJustify(), m_plotter->Text( positions[ii], color, txt, aText->GetTextAngle(), size,
aText->GetVertJustify(), thickness, aText->IsItalic(), aText->GetHorizJustify(), aText->GetVertJustify(), thickness,
allow_bold, false, &gbr_metadata ); aText->IsItalic(), allow_bold, false, &gbr_metadata );
} }
} }
else else
{ {
m_plotter->Text( pos, color, shownText, orient, size, aText->GetHorizJustify(), m_plotter->Text( pos, color, shownText, aText->GetTextAngle(), size,
aText->GetVertJustify(), thickness, aText->IsItalic(), allow_bold, aText->GetHorizJustify(), aText->GetVertJustify(), thickness,
false, &gbr_metadata ); 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 // It's unclear exactly how Altium figures it's text positioning, but this gets us reasonably
// close. // close.
dimension->Text().SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM ); dimension->Text().SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
dimension->Text().SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT ); dimension->Text().SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
int yAdjust = dimension->Text().GetCenter().y - dimension->Text().GetPosition().y; int yAdjust = dimension->Text().GetCenter().y - dimension->Text().GetPosition().y;
dimension->Text().Move( wxPoint( 0, yAdjust + aElem.textgap ) ); 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->SetLayer( klayer );
text->SetTextSize( wxSize( aElem.textheight, aElem.textheight ) ); // TODO: parse text width text->SetTextSize( wxSize( aElem.textheight, aElem.textheight ) ); // TODO: parse text width
text->SetTextThickness( aElem.textlinewidth ); text->SetTextThickness( aElem.textlinewidth );
text->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT ); text->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
text->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM ); 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() ); FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( fpText->GetParent() );
double orientation = parentFootprint->GetOrientation(); double orientation = parentFootprint->GetOrientation();
fpText->SetTextAngle( fpText->GetTextAngle() - orientation ); fpText->SetTextAngle( fpText->GetTextAngle().AsTenthsOfADegree() - orientation );
fpText->SetLocalCoord(); 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 if( elem.isDesignator || elem.isComment ) // That's just a bold assumption
{ {
tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT ); tx->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
tx->SetVertJustify( EDA_TEXT_VJUSTIFY_T::GR_TEXT_VJUSTIFY_BOTTOM ); tx->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
} }
else else
{ {
@ -2795,17 +2795,17 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader,
case ALTIUM_TEXT_POSITION::LEFT_TOP: case ALTIUM_TEXT_POSITION::LEFT_TOP:
case ALTIUM_TEXT_POSITION::LEFT_CENTER: case ALTIUM_TEXT_POSITION::LEFT_CENTER:
case ALTIUM_TEXT_POSITION::LEFT_BOTTOM: case ALTIUM_TEXT_POSITION::LEFT_BOTTOM:
tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_LEFT ); tx->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case ALTIUM_TEXT_POSITION::CENTER_TOP: case ALTIUM_TEXT_POSITION::CENTER_TOP:
case ALTIUM_TEXT_POSITION::CENTER_CENTER: case ALTIUM_TEXT_POSITION::CENTER_CENTER:
case ALTIUM_TEXT_POSITION::CENTER_BOTTOM: case ALTIUM_TEXT_POSITION::CENTER_BOTTOM:
tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_CENTER ); tx->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
case ALTIUM_TEXT_POSITION::RIGHT_TOP: case ALTIUM_TEXT_POSITION::RIGHT_TOP:
case ALTIUM_TEXT_POSITION::RIGHT_CENTER: case ALTIUM_TEXT_POSITION::RIGHT_CENTER:
case ALTIUM_TEXT_POSITION::RIGHT_BOTTOM: case ALTIUM_TEXT_POSITION::RIGHT_BOTTOM:
tx->SetHorizJustify( EDA_TEXT_HJUSTIFY_T::GR_TEXT_HJUSTIFY_RIGHT ); tx->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
default: default:
wxLogError( "Unexpected horizontal Text Position. This should never happen." ); 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::LEFT_TOP:
case ALTIUM_TEXT_POSITION::CENTER_TOP: case ALTIUM_TEXT_POSITION::CENTER_TOP:
case ALTIUM_TEXT_POSITION::RIGHT_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; break;
case ALTIUM_TEXT_POSITION::LEFT_CENTER: case ALTIUM_TEXT_POSITION::LEFT_CENTER:
case ALTIUM_TEXT_POSITION::CENTER_CENTER: case ALTIUM_TEXT_POSITION::CENTER_CENTER:
case ALTIUM_TEXT_POSITION::RIGHT_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; break;
case ALTIUM_TEXT_POSITION::LEFT_BOTTOM: case ALTIUM_TEXT_POSITION::LEFT_BOTTOM:
case ALTIUM_TEXT_POSITION::CENTER_BOTTOM: case ALTIUM_TEXT_POSITION::CENTER_BOTTOM:
case ALTIUM_TEXT_POSITION::RIGHT_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; break;
default: default:
wxLogError( "Unexpected vertical text position. This should never happen." ); 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 ); leaderDim->SetUnitsFormat( DIM_UNITS_FORMAT::NO_SUFFIX );
if( orientX == 1 ) if( orientX == 1 )
leaderDim->Text().SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); leaderDim->Text().SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else else
leaderDim->Text().SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); leaderDim->Text().SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
leaderDim->SetExtensionOffset( 0 ); 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::NO_ALIGNMENT: // Default for Single line text is Bottom Left
case ALIGNMENT::BOTTOMLEFT: case ALIGNMENT::BOTTOMLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case ALIGNMENT::BOTTOMCENTER: case ALIGNMENT::BOTTOMCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
case ALIGNMENT::BOTTOMRIGHT: case ALIGNMENT::BOTTOMRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
case ALIGNMENT::CENTERLEFT: case ALIGNMENT::CENTERLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case ALIGNMENT::CENTERCENTER: case ALIGNMENT::CENTERCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
case ALIGNMENT::CENTERRIGHT: case ALIGNMENT::CENTERRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
case ALIGNMENT::TOPLEFT: case ALIGNMENT::TOPLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case ALIGNMENT::TOPCENTER: case ALIGNMENT::TOPCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
case ALIGNMENT::TOPRIGHT: case ALIGNMENT::TOPRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
default: default:
@ -3270,48 +3270,48 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
FixTextPositionNoAlignment( txt ); FixTextPositionNoAlignment( txt );
KI_FALLTHROUGH; KI_FALLTHROUGH;
case ALIGNMENT::BOTTOMLEFT: case ALIGNMENT::BOTTOMLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case ALIGNMENT::BOTTOMCENTER: case ALIGNMENT::BOTTOMCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
case ALIGNMENT::BOTTOMRIGHT: case ALIGNMENT::BOTTOMRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); txt->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
case ALIGNMENT::CENTERLEFT: case ALIGNMENT::CENTERLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case ALIGNMENT::CENTERCENTER: case ALIGNMENT::CENTERCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
case ALIGNMENT::CENTERRIGHT: case ALIGNMENT::CENTERRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); txt->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
case ALIGNMENT::TOPLEFT: case ALIGNMENT::TOPLEFT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case ALIGNMENT::TOPCENTER: case ALIGNMENT::TOPCENTER:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
case ALIGNMENT::TOPRIGHT: case ALIGNMENT::TOPRIGHT:
txt->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); txt->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
txt->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); txt->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
default: default:

View File

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

View File

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

View File

@ -266,7 +266,7 @@ private:
{ {
double rotation; ///<! GRAPHIC_DATA_3 double rotation; ///<! GRAPHIC_DATA_3
bool mirror; ///<! GRAPHIC_DATA_4 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 // GRAPHIC_DATA_6 is
// SIZE FONT HEIGHT WIDTH ITAL LINESPACE THICKNESS // SIZE FONT HEIGHT WIDTH ITAL LINESPACE THICKNESS
int height; ///<! GRAPHIC_DATA_6[2] int height; ///<! GRAPHIC_DATA_6[2]

View File

@ -470,19 +470,19 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText )
switch( token ) switch( token )
{ {
case T_left: case T_left:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break; break;
case T_right: case T_right:
aText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); aText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
case T_top: case T_top:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
break; break;
case T_bottom: case T_bottom:
aText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); aText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
break; break;
case T_mirror: case T_mirror:
@ -3492,7 +3492,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
{ {
FP_TEXT* text = parseFP_TEXT(); FP_TEXT* text = parseFP_TEXT();
text->SetParent( footprint.get() ); text->SetParent( footprint.get() );
double orientation = text->GetTextAngle(); double orientation = text->GetTextAngle().AsTenthsOfADegree();
orientation -= footprint->GetOrientation(); orientation -= footprint->GetOrientation();
text->SetTextAngle( orientation ); text->SetTextAngle( orientation );
text->SetDrawCoord(); 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(), m_out->Quotew( aText->GetText() ).c_str(),
FormatInternalUnits( aText->GetTextPos() ).c_str() ); FormatInternalUnits( aText->GetTextPos() ).c_str() );
if( aText->GetTextAngle() != 0.0 ) if( aText->GetTextAngle() != EDA_ANGLE::ANGLE_0 )
m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle() ).c_str() ); m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle().AsTenthsOfADegree() ).c_str() );
m_out->Print( 0, ")" ); 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, // 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 // but internally the angle is held relative to its parent footprint. parent
// may be NULL when saving a footprint outside a BOARD. // may be NULL when saving a footprint outside a BOARD.
double orient = aText->GetTextAngle(); double orient = aText->GetTextAngle().AsTenthsOfADegree();
FOOTPRINT* parent = (FOOTPRINT*) aText->GetParent(); FOOTPRINT* parent = static_cast<FOOTPRINT*>( aText->GetParent() );
if( parent ) if( parent )
{ {

View File

@ -254,26 +254,26 @@ static inline char* ReadLine( LINE_READER* rdr, const char* caller )
#endif #endif
static EDA_TEXT_HJUSTIFY_T horizJustify( const char* horizontal ) static GR_TEXT_H_ALIGN_T horizJustify( const char* horizontal )
{ {
if( !strcmp( "L", horizontal ) ) if( !strcmp( "L", horizontal ) )
return GR_TEXT_HJUSTIFY_LEFT; return GR_TEXT_H_ALIGN_LEFT;
if( !strcmp( "R", horizontal ) ) 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 ) ) if( !strcmp( "T", vertical ) )
return GR_TEXT_VJUSTIFY_TOP; return GR_TEXT_V_ALIGN_TOP;
if( !strcmp( "B", vertical ) ) 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 else
{ {
// boom, somebody changed a constructor, I was relying on this: // 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 ) if( vJustify )

View File

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

View File

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

View File

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