Improve SNR of EDA_ANGLE stuff.

This commit is contained in:
Jeff Young 2022-01-13 12:29:46 +00:00
parent 431560a46b
commit e048e51f5d
30 changed files with 310 additions and 257 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2021 Ola Rinta-Koski * Copyright (C) 2021 Ola Rinta-Koski
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -20,11 +20,14 @@
#include <eda_angle.h> #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_Angle0 = EDA_ANGLE( 0, DEGREES_T );
EDA_ANGLE EDA_ANGLE::m_angle180 = EDA_ANGLE( 180, EDA_ANGLE::DEGREES ); EDA_ANGLE EDA_ANGLE::m_Angle45 = EDA_ANGLE( 45, DEGREES_T );
EDA_ANGLE EDA_ANGLE::m_angle270 = EDA_ANGLE( 270, EDA_ANGLE::DEGREES ); EDA_ANGLE EDA_ANGLE::m_Angle90 = EDA_ANGLE( 90, DEGREES_T );
EDA_ANGLE EDA_ANGLE::m_angle360 = EDA_ANGLE( 360, EDA_ANGLE::DEGREES ); EDA_ANGLE EDA_ANGLE::m_Angle180 = EDA_ANGLE( 180, DEGREES_T );
EDA_ANGLE EDA_ANGLE::m_Angle270 = EDA_ANGLE( 270, DEGREES_T );
EDA_ANGLE EDA_ANGLE::m_Angle360 = EDA_ANGLE( 360, DEGREES_T );
EDA_ANGLE EDA_ANGLE::KeepUpright() const EDA_ANGLE EDA_ANGLE::KeepUpright() const
{ {
@ -39,39 +42,39 @@ EDA_ANGLE EDA_ANGLE::KeepUpright() const
else else
outDegrees = 90; outDegrees = 90;
return EDA_ANGLE( outDegrees, EDA_ANGLE::DEGREES ); return EDA_ANGLE( outDegrees, DEGREES_T );
} }
void EDA_ANGLE::normalize( bool n720 ) void EDA_ANGLE::normalize( bool n720 )
{ {
if( GetInitialAngleType() == EDA_ANGLE::RADIANS ) if( GetInitialAngleType() == RADIANS_T )
{ {
m_radians = normalize( m_radians, EDA_ANGLE::RADIANS, n720 ); m_radians = normalize( m_radians, RADIANS_T, n720 );
m_value = int( m_radians / TENTHS_OF_A_DEGREE_TO_RADIANS ); m_value = int( m_radians / TENTHS_OF_A_DEGREE_TO_RADIANS );
} }
else else
{ {
m_value = normalize( m_value, EDA_ANGLE::TENTHS_OF_A_DEGREE, n720 ); m_value = normalize( m_value, TENTHS_OF_A_DEGREE_T, n720 );
} }
} }
int EDA_ANGLE::normalize( int aValue, ANGLE_TYPE aAngleType, bool n720 ) const int EDA_ANGLE::normalize( int aValue, EDA_ANGLE_T aAngleType, bool n720 ) const
{ {
int full_circle_upper = DEGREES_FULL_CIRCLE; int full_circle_upper = DEGREES_FULL_CIRCLE;
switch( aAngleType ) switch( aAngleType )
{ {
case DEGREES: case DEGREES_T:
full_circle_upper = DEGREES_FULL_CIRCLE; full_circle_upper = DEGREES_FULL_CIRCLE;
break; break;
case TENTHS_OF_A_DEGREE: case TENTHS_OF_A_DEGREE_T:
full_circle_upper = TENTHS_OF_A_DEGREE_FULL_CIRCLE; full_circle_upper = TENTHS_OF_A_DEGREE_FULL_CIRCLE;
break; break;
case RADIANS: case RADIANS_T:
/* ?? should not get here */ /* ?? should not get here */
assert( 1 == 0 ); assert( 1 == 0 );
} }
@ -91,15 +94,15 @@ int EDA_ANGLE::normalize( int aValue, ANGLE_TYPE aAngleType, bool n720 ) const
} }
double EDA_ANGLE::normalize( double aValue, ANGLE_TYPE aAngleType, bool n720 ) const double EDA_ANGLE::normalize( double aValue, EDA_ANGLE_T aAngleType, bool n720 ) const
{ {
double full_circle_upper = DEGREES_FULL_CIRCLE; double full_circle_upper = DEGREES_FULL_CIRCLE;
switch( aAngleType ) switch( aAngleType )
{ {
case DEGREES: full_circle_upper = DEGREES_FULL_CIRCLE; break; case DEGREES_T: full_circle_upper = DEGREES_FULL_CIRCLE; break;
case TENTHS_OF_A_DEGREE: full_circle_upper = TENTHS_OF_A_DEGREE_FULL_CIRCLE; break; case TENTHS_OF_A_DEGREE_T: full_circle_upper = TENTHS_OF_A_DEGREE_FULL_CIRCLE; break;
case RADIANS: full_circle_upper = RADIANS_FULL_CIRCLE; break; case RADIANS_T: full_circle_upper = RADIANS_FULL_CIRCLE; break;
} }
double full_circle_lower = n720 ? 0 : -full_circle_upper; double full_circle_lower = n720 ? 0 : -full_circle_upper;

View File

@ -280,7 +280,7 @@ VECTOR2I FONT::StringBoundaryLimits( const UTF8& aText, const VECTOR2I& aSize, i
if( aItalic ) if( aItalic )
textStyle |= TEXT_STYLE::ITALIC; textStyle |= TEXT_STYLE::ITALIC;
(void) drawMarkup( &boundingBox, nullptr, aText, VECTOR2I(), aSize, EDA_ANGLE::ANGLE_0, false, (void) drawMarkup( &boundingBox, nullptr, aText, VECTOR2I(), aSize, ANGLE_0, false,
VECTOR2I(), textStyle ); VECTOR2I(), textStyle );
if( IsStroke() ) if( IsStroke() )
@ -305,8 +305,8 @@ VECTOR2I FONT::boundingBoxSingleLine( BOX2I* aBBox, const UTF8& aText, const VEC
if( aItalic ) if( aItalic )
textStyle |= TEXT_STYLE::ITALIC; textStyle |= TEXT_STYLE::ITALIC;
VECTOR2I extents = drawMarkup( aBBox, nullptr, aText, aPosition, aSize, EDA_ANGLE::ANGLE_0, VECTOR2I extents = drawMarkup( aBBox, nullptr, aText, aPosition, aSize, ANGLE_0, false,
false, VECTOR2I(), textStyle ); VECTOR2I(), textStyle );
return extents; return extents;
} }

View File

@ -1,13 +1,8 @@
/**
* @file SVG_plotter.cpp
* @brief KiCad: specialized plotter for SVG files format
*/
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2020 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2020 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -801,7 +796,7 @@ void SVG_PLOTTER::Text( const VECTOR2I& 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 != EDA_ANGLE::ANGLE_0 ) if( !aOrient.IsZero() )
{ {
fprintf( m_outputFile, fprintf( m_outputFile,
"<g transform=\"rotate(%f %f %f)\">\n", "<g transform=\"rotate(%f %f %f)\">\n",
@ -819,7 +814,7 @@ void SVG_PLOTTER::Text( const VECTOR2I& aPos,
"text-anchor=\"%s\" opacity=\"0\">%s</text>\n", "text-anchor=\"%s\" opacity=\"0\">%s</text>\n",
sz_dev.x, sz_dev.y, hjust, TO_UTF8( XmlEsc( aText ) ) ); sz_dev.x, sz_dev.y, hjust, TO_UTF8( XmlEsc( aText ) ) );
if( aOrient != EDA_ANGLE::ANGLE_0 ) if( !aOrient.IsZero() )
fputs( "</g>\n", m_outputFile ); fputs( "</g>\n", m_outputFile );
fprintf( m_outputFile, "<g class=\"stroked-text\"><desc>%s</desc>\n", fprintf( m_outputFile, "<g class=\"stroked-text\"><desc>%s</desc>\n",

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2017-2021 Kicad Developers, see change_log.txt for contributors. * Copyright (C) 2017-2022 Kicad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -181,12 +181,12 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT
if( aLine.Angle() > 0 ) if( aLine.Angle() > 0 )
{ {
labelAttrs.m_Halign = GR_TEXT_H_ALIGN_LEFT; labelAttrs.m_Halign = GR_TEXT_H_ALIGN_LEFT;
labelAttrs.m_Angle = EDA_ANGLE( labelAngle, EDA_ANGLE::RADIANS ); labelAttrs.m_Angle = EDA_ANGLE( labelAngle, RADIANS_T );
} }
else else
{ {
labelAttrs.m_Halign = GR_TEXT_H_ALIGN_RIGHT; labelAttrs.m_Halign = GR_TEXT_H_ALIGN_RIGHT;
labelAttrs.m_Angle = EDA_ANGLE( labelAngle + M_PI, EDA_ANGLE::RADIANS ); labelAttrs.m_Angle = EDA_ANGLE( labelAngle + M_PI, RADIANS_T );
} }
BOX2D viewportD = aView->GetViewport(); BOX2D viewportD = aView->GetViewport();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2015 Chris Pavlina <pavlina.chris@gmail.com> * Copyright (C) 2015 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2015, 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2015, 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -196,9 +196,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( EDA_ANGLE::VERTICAL ); field->SetTextAngle( ANGLE_VERTICAL );
else else
field->SetTextAngle( EDA_ANGLE::HORIZONTAL ); field->SetTextAngle( ANGLE_HORIZONTAL );
EDA_RECT bbox = field->GetBoundingBox(); EDA_RECT bbox = field->GetBoundingBox();
int field_width = bbox.GetWidth(); int field_width = bbox.GetWidth();

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2016 Wayne Stambaugh, stambaughw@gmail.com * Copyright (C) 2016 Wayne Stambaugh, stambaughw@gmail.com
* Copyright (C) 2004-2021 KiCad Developers, see AITHORS.txt for contributors. * Copyright (C) 2004-2022 KiCad Developers, see AITHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -400,7 +400,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 ? EDA_ANGLE::VERTICAL : EDA_ANGLE::HORIZONTAL ); aText->SetTextAngle( m_isVertical ? ANGLE_VERTICAL : ANGLE_HORIZONTAL );
aText->SetItalic( m_isItalic ); aText->SetItalic( m_isItalic );
aText->SetBold( m_isBold ); aText->SetBold( m_isBold );
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2001 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2001 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2022 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -230,9 +230,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( EDA_ANGLE::HORIZONTAL ); m_graphicText->SetTextAngle( ANGLE_HORIZONTAL );
else else
m_graphicText->SetTextAngle( EDA_ANGLE::VERTICAL ); m_graphicText->SetTextAngle( ANGLE_VERTICAL );
if( !m_CommonUnit->GetValue() ) if( !m_CommonUnit->GetValue() )
m_graphicText->SetUnit( m_parent->GetUnit() ); m_graphicText->SetUnit( m_parent->GetUnit() );

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -611,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( EDA_ANGLE::HORIZONTAL ); field.SetTextAngle( ANGLE_HORIZONTAL );
else if( aValue == _( "Vertical" ) ) else if( aValue == _( "Vertical" ) )
field.SetTextAngle( EDA_ANGLE::VERTICAL ); field.SetTextAngle( ANGLE_VERTICAL );
else else
wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue ); wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
break; break;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -85,7 +85,7 @@ void LIB_FIELD::Init( int aId )
m_id = aId; m_id = aId;
SetTextAngle( EDA_ANGLE::HORIZONTAL ); // constructor already did this. SetTextAngle( 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.
@ -163,8 +163,8 @@ bool LIB_FIELD::HitTest( const VECTOR2I& 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() != EDA_ANGLE::HORIZONTAL ); bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL );
tmp_text.SetTextAngle( t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL ); tmp_text.SetTextAngle( t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL );
return tmp_text.TextHitTest( aPosition, aAccuracy ); return tmp_text.TextHitTest( aPosition, aAccuracy );
} }
@ -291,8 +291,7 @@ void LIB_FIELD::Rotate( const VECTOR2I& center, bool aRotateCCW )
RotatePoint( pt, center, rot_angle ); RotatePoint( pt, center, rot_angle );
SetTextPos( pt ); SetTextPos( pt );
SetTextAngle( GetTextAngle() != EDA_ANGLE::HORIZONTAL ? EDA_ANGLE::HORIZONTAL SetTextAngle( GetTextAngle() != ANGLE_HORIZONTAL ? ANGLE_HORIZONTAL : ANGLE_VERTICAL );
: EDA_ANGLE::VERTICAL );
} }
@ -308,9 +307,9 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill,
if( aTransform.y1 ) // Rotate symbol 90 deg. if( aTransform.y1 ) // Rotate symbol 90 deg.
{ {
if( orient.IsHorizontal() ) if( orient.IsHorizontal() )
orient = EDA_ANGLE::VERTICAL; orient = ANGLE_VERTICAL;
else else
orient = EDA_ANGLE::HORIZONTAL; orient = ANGLE_HORIZONTAL;
} }
EDA_RECT bbox = GetBoundingBox(); EDA_RECT bbox = GetBoundingBox();

View File

@ -402,14 +402,14 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( aPinOrient == PIN_RIGHT ) if( aPinOrient == PIN_RIGHT )
{ {
x = x1 + aTextInside; x = x1 + aTextInside;
GRPrintText( DC, VECTOR2I( x, y1 ), NameColor, name, EDA_ANGLE::HORIZONTAL, GRPrintText( DC, VECTOR2I( x, y1 ), NameColor, name, ANGLE_HORIZONTAL,
pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER,
namePenWidth, false, false, font ); namePenWidth, false, false, font );
} }
else // Orient == PIN_LEFT else // Orient == PIN_LEFT
{ {
x = x1 - aTextInside; x = x1 - aTextInside;
GRPrintText( DC, VECTOR2I( x, y1 ), NameColor, name, EDA_ANGLE::HORIZONTAL, GRPrintText( DC, VECTOR2I( x, y1 ), NameColor, name, ANGLE_HORIZONTAL,
pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER,
namePenWidth, false, false, font ); namePenWidth, false, false, font );
} }
@ -418,7 +418,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( aDrawPinNum ) if( aDrawPinNum )
{ {
GRPrintText( DC, VECTOR2I(( x1 + aPinPos.x) / 2, y1 - num_offset ), NumColor, GRPrintText( DC, VECTOR2I(( x1 + aPinPos.x) / 2, y1 - num_offset ), NumColor,
number, EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, number, ANGLE_HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, font ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, font );
} }
} }
@ -431,7 +431,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( aDrawPinName ) if( aDrawPinName )
{ {
GRPrintText( DC, VECTOR2I( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, GRPrintText( DC, VECTOR2I( x1, y ), NameColor, name, ANGLE_VERTICAL,
pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER,
namePenWidth, false, false, font ); namePenWidth, false, false, font );
} }
@ -439,7 +439,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( aDrawPinNum ) if( aDrawPinNum )
{ {
GRPrintText( DC, VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor, GRPrintText( DC, VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, number, ANGLE_VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, font ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, font );
} }
} }
@ -449,7 +449,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( aDrawPinName ) if( aDrawPinName )
{ {
GRPrintText( DC, VECTOR2I( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, GRPrintText( DC, VECTOR2I( x1, y ), NameColor, name, ANGLE_VERTICAL,
pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER,
namePenWidth, false, false, font ); namePenWidth, false, false, font );
} }
@ -457,7 +457,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( aDrawPinNum ) if( aDrawPinNum )
{ {
GRPrintText( DC, VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor, GRPrintText( DC, VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, number, ANGLE_VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, font ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, font );
} }
} }
@ -471,16 +471,16 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( aDrawPinName ) if( aDrawPinName )
{ {
x = ( x1 + aPinPos.x) / 2; x = ( x1 + aPinPos.x) / 2;
GRPrintText( DC, VECTOR2I( x, y1 - name_offset ), NameColor, name, GRPrintText( DC, VECTOR2I( x, y1 - name_offset ), NameColor, name, ANGLE_HORIZONTAL,
EDA_ANGLE::HORIZONTAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER, pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false, font ); namePenWidth, false, false, font );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
x = ( x1 + aPinPos.x) / 2; x = ( x1 + aPinPos.x) / 2;
GRPrintText( DC, VECTOR2I( x, y1 + num_offset ), NumColor, number, GRPrintText( DC, VECTOR2I( x, y1 + num_offset ), NumColor, number, ANGLE_HORIZONTAL,
EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, pinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP,
GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false, font ); numPenWidth, false, false, font );
} }
} }
else /* Its a vertical line. */ else /* Its a vertical line. */
@ -488,15 +488,15 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( aDrawPinName ) if( aDrawPinName )
{ {
y = ( y1 + aPinPos.y) / 2; y = ( y1 + aPinPos.y) / 2;
GRPrintText( DC, VECTOR2I( x1 - name_offset, y ), NameColor, name, GRPrintText( DC, VECTOR2I( x1 - name_offset, y ), NameColor, name, ANGLE_VERTICAL,
EDA_ANGLE::VERTICAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER, pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false, font ); namePenWidth, false, false, font );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
GRPrintText( DC, VECTOR2I( x1 + num_offset, ( y1 + aPinPos.y) / 2 ), NumColor, GRPrintText( DC, VECTOR2I( x1 + num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, number, ANGLE_VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false, font ); GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false, font );
} }
} }
@ -528,19 +528,19 @@ void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECT
VECTOR2I txtpos = aPosition; VECTOR2I txtpos = aPosition;
int offset = Millimeter2iu( 0.4 ); int offset = Millimeter2iu( 0.4 );
GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_LEFT; GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_LEFT;
EDA_ANGLE orient = EDA_ANGLE::HORIZONTAL; EDA_ANGLE orient = ANGLE_HORIZONTAL;
switch( aOrientation ) switch( aOrientation )
{ {
case PIN_UP: case PIN_UP:
txtpos.y += offset; txtpos.y += offset;
orient = EDA_ANGLE::VERTICAL; orient = ANGLE_VERTICAL;
hjustify = GR_TEXT_H_ALIGN_RIGHT; hjustify = GR_TEXT_H_ALIGN_RIGHT;
break; break;
case PIN_DOWN: case PIN_DOWN:
txtpos.y -= offset; txtpos.y -= offset;
orient = EDA_ANGLE::VERTICAL; orient = ANGLE_VERTICAL;
break; break;
case PIN_LEFT: case PIN_LEFT:
@ -752,14 +752,13 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin
hjustify = GR_TEXT_H_ALIGN_RIGHT; hjustify = GR_TEXT_H_ALIGN_RIGHT;
} }
aPlotter->Text( VECTOR2I( x, y1 ), nameColor, name, EDA_ANGLE::HORIZONTAL, aPlotter->Text( VECTOR2I( x, y1 ), nameColor, name, ANGLE_HORIZONTAL, pinNameSize,
pinNameSize, hjustify, GR_TEXT_V_ALIGN_CENTER, namePenWidth, hjustify, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false, false );
false, false );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
aPlotter->Text( VECTOR2I( ( x1 + aPinPos.x) / 2, y1 - num_offset ), numColor, aPlotter->Text( VECTOR2I( ( x1 + aPinPos.x) / 2, y1 - num_offset ), numColor,
number, EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, number, ANGLE_HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
} }
} }
@ -770,14 +769,14 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin
y = y1 + aTextInside; y = y1 + aTextInside;
if( aDrawPinName ) if( aDrawPinName )
aPlotter->Text( VECTOR2I( x1, y ), nameColor, name, EDA_ANGLE::VERTICAL, aPlotter->Text( VECTOR2I( x1, y ), nameColor, name, ANGLE_VERTICAL,
pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER,
namePenWidth, false, false ); namePenWidth, false, false );
if( aDrawPinNum ) if( aDrawPinNum )
{ {
aPlotter->Text( VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor, aPlotter->Text( VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor,
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, number, ANGLE_VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
} }
} }
@ -787,7 +786,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin
if( aDrawPinName ) if( aDrawPinName )
{ {
aPlotter->Text( VECTOR2I( x1, y ), nameColor, name, EDA_ANGLE::VERTICAL, aPlotter->Text( VECTOR2I( x1, y ), nameColor, name, ANGLE_VERTICAL,
pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER,
namePenWidth, false, false ); namePenWidth, false, false );
} }
@ -795,7 +794,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin
if( aDrawPinNum ) if( aDrawPinNum )
{ {
aPlotter->Text( VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor, aPlotter->Text( VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), numColor,
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, number, ANGLE_VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false ); GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false );
} }
} }
@ -809,17 +808,17 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin
if( aDrawPinName ) if( aDrawPinName )
{ {
x = ( x1 + aPinPos.x) / 2; x = ( x1 + aPinPos.x) / 2;
aPlotter->Text( VECTOR2I( x, y1 - name_offset ), nameColor, name, aPlotter->Text( VECTOR2I( x, y1 - name_offset ), nameColor, name, ANGLE_HORIZONTAL,
EDA_ANGLE::HORIZONTAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER, pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
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;
aPlotter->Text( VECTOR2I( x, y1 + num_offset ), numColor, number, aPlotter->Text( VECTOR2I( x, y1 + num_offset ), numColor, number, ANGLE_HORIZONTAL,
EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, pinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP,
GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false ); numPenWidth, false, false );
} }
} }
else /* Its a vertical line. */ else /* Its a vertical line. */
@ -827,15 +826,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin
if( aDrawPinName ) if( aDrawPinName )
{ {
y = ( y1 + aPinPos.y ) / 2; y = ( y1 + aPinPos.y ) / 2;
aPlotter->Text( VECTOR2I( x1 - name_offset, y ), nameColor, name, aPlotter->Text( VECTOR2I( x1 - name_offset, y ), nameColor, name, ANGLE_VERTICAL,
EDA_ANGLE::VERTICAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER, pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false ); namePenWidth, false, false );
} }
if( aDrawPinNum ) if( aDrawPinNum )
{ {
aPlotter->Text( VECTOR2I( x1 + num_offset, ( y1 + aPinPos.y ) / 2 ), numColor, aPlotter->Text( VECTOR2I( x1 + num_offset, ( y1 + aPinPos.y ) / 2 ), numColor,
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, number, ANGLE_VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false ); GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false );
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -62,9 +62,9 @@ bool LIB_TEXT::HitTest( const VECTOR2I& 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() != EDA_ANGLE::HORIZONTAL ); bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL );
tmp_text.SetTextAngle( t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL ); tmp_text.SetTextAngle( t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL );
return tmp_text.TextHitTest( aPosition, aAccuracy ); return tmp_text.TextHitTest( aPosition, aAccuracy );
} }
@ -234,7 +234,7 @@ void LIB_TEXT::Rotate( const VECTOR2I& center, bool aRotateCCW )
if( GetTextAngle().IsHorizontal() ) if( GetTextAngle().IsHorizontal() )
{ {
SetTextAngle( EDA_ANGLE::VERTICAL ); SetTextAngle( ANGLE_VERTICAL );
} }
else else
{ {
@ -269,7 +269,7 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const VECTOR2I& 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() != EDA_ANGLE::HORIZONTAL ); int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL );
VECTOR2I pos = aTransform.TransformCoordinate( txtpos ) + offset; VECTOR2I pos = aTransform.TransformCoordinate( txtpos ) + offset;
// Get color // Get color
@ -284,9 +284,8 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const VECTOR2I& offset, bool fill,
int penWidth = std::max( GetEffectiveTextPenWidth(), settings->GetMinPenWidth() ); int penWidth = std::max( GetEffectiveTextPenWidth(), settings->GetMinPenWidth() );
plotter->Text( pos, color, GetText(), t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL, plotter->Text( pos, color, GetText(), t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL, GetTextSize(),
GetTextSize(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold() );
IsItalic(), IsBold() );
} }
@ -320,10 +319,10 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
if( aTransform.y1 ) // Rotate symbol 90 degrees. if( aTransform.y1 ) // Rotate symbol 90 degrees.
{ {
if( orient == EDA_ANGLE::HORIZONTAL ) if( orient == ANGLE_HORIZONTAL )
orient = EDA_ANGLE::VERTICAL; orient = ANGLE_VERTICAL;
else else
orient = EDA_ANGLE::HORIZONTAL; orient = ANGLE_HORIZONTAL;
} }
/* /*

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -338,10 +338,10 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees. if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
{ {
if( orient == EDA_ANGLE::HORIZONTAL ) if( orient == ANGLE_HORIZONTAL )
orient = EDA_ANGLE::VERTICAL; orient = ANGLE_VERTICAL;
else else
orient = EDA_ANGLE::HORIZONTAL; orient = ANGLE_HORIZONTAL;
} }
} }
@ -393,9 +393,9 @@ EDA_ANGLE SCH_FIELD::GetDrawRotation() const
if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees. if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
{ {
if( orient.IsHorizontal() ) if( orient.IsHorizontal() )
orient = EDA_ANGLE::VERTICAL; orient = ANGLE_VERTICAL;
else else
orient = EDA_ANGLE::HORIZONTAL; orient = ANGLE_HORIZONTAL;
} }
} }
@ -952,9 +952,9 @@ 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.IsHorizontal() ) if( orient.IsHorizontal() )
orient = EDA_ANGLE::VERTICAL; orient = ANGLE_VERTICAL;
else else
orient = EDA_ANGLE::HORIZONTAL; orient = ANGLE_HORIZONTAL;
} }
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014 CERN * Copyright (C) 2014 CERN
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
@ -1144,22 +1144,22 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] ) if( size[INSIDE] )
{ {
drawText( INSIDE, pos + VECTOR2D( -insideOffset - len, 0 ), drawText( INSIDE, pos + VECTOR2D( -insideOffset - len, 0 ),
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, EDA_ANGLE::HORIZONTAL ); GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, ANGLE_HORIZONTAL );
} }
if( size[OUTSIDE] ) if( size[OUTSIDE] )
{ {
drawText( OUTSIDE, pos + VECTOR2D( outsideOffset, 0 ), drawText( OUTSIDE, pos + VECTOR2D( outsideOffset, 0 ),
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, EDA_ANGLE::HORIZONTAL ); GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, ANGLE_HORIZONTAL );
} }
if( size[ABOVE] ) if( size[ABOVE] )
{ {
drawText( ABOVE, pos + VECTOR2D( -len / 2.0, -aboveOffset ), drawText( ABOVE, pos + VECTOR2D( -len / 2.0, -aboveOffset ),
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, EDA_ANGLE::HORIZONTAL ); GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, ANGLE_HORIZONTAL );
} }
if( size[BELOW] ) if( size[BELOW] )
{ {
drawText( BELOW, pos + VECTOR2D( -len / 2.0, belowOffset ), drawText( BELOW, pos + VECTOR2D( -len / 2.0, belowOffset ),
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, EDA_ANGLE::HORIZONTAL ); GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, ANGLE_HORIZONTAL );
} }
break; break;
@ -1167,22 +1167,22 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] ) if( size[INSIDE] )
{ {
drawText( INSIDE, pos + VECTOR2D( insideOffset + len, 0 ), drawText( INSIDE, pos + VECTOR2D( insideOffset + len, 0 ),
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, EDA_ANGLE::HORIZONTAL ); GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, ANGLE_HORIZONTAL );
} }
if( size[OUTSIDE] ) if( size[OUTSIDE] )
{ {
drawText( OUTSIDE, pos + VECTOR2D( -outsideOffset, 0 ), drawText( OUTSIDE, pos + VECTOR2D( -outsideOffset, 0 ),
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, EDA_ANGLE::HORIZONTAL ); GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, ANGLE_HORIZONTAL );
} }
if( size[ABOVE] ) if( size[ABOVE] )
{ {
drawText( ABOVE, pos + VECTOR2D( len / 2.0, -aboveOffset ), drawText( ABOVE, pos + VECTOR2D( len / 2.0, -aboveOffset ),
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, EDA_ANGLE::HORIZONTAL ); GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, ANGLE_HORIZONTAL );
} }
if( size[BELOW] ) if( size[BELOW] )
{ {
drawText( BELOW, pos + VECTOR2D( len / 2.0, belowOffset ), drawText( BELOW, pos + VECTOR2D( len / 2.0, belowOffset ),
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, EDA_ANGLE::HORIZONTAL ); GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, ANGLE_HORIZONTAL );
} }
break; break;
@ -1190,22 +1190,22 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] ) if( size[INSIDE] )
{ {
drawText( INSIDE, pos + VECTOR2D( 0, insideOffset + len ), drawText( INSIDE, pos + VECTOR2D( 0, insideOffset + len ),
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, EDA_ANGLE::VERTICAL ); GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, ANGLE_VERTICAL );
} }
if( size[OUTSIDE] ) if( size[OUTSIDE] )
{ {
drawText( OUTSIDE, pos + VECTOR2D( 0, -outsideOffset ), drawText( OUTSIDE, pos + VECTOR2D( 0, -outsideOffset ),
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, EDA_ANGLE::VERTICAL ); GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, ANGLE_VERTICAL );
} }
if( size[ABOVE] ) if( size[ABOVE] )
{ {
drawText( ABOVE, pos + VECTOR2D( -aboveOffset, len / 2.0 ), drawText( ABOVE, pos + VECTOR2D( -aboveOffset, len / 2.0 ),
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, EDA_ANGLE::VERTICAL ); GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, ANGLE_VERTICAL );
} }
if( size[BELOW] ) if( size[BELOW] )
{ {
drawText( BELOW, pos + VECTOR2D( belowOffset, len / 2.0 ), drawText( BELOW, pos + VECTOR2D( belowOffset, len / 2.0 ),
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, EDA_ANGLE::VERTICAL ); GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, ANGLE_VERTICAL );
} }
break; break;
@ -1213,22 +1213,22 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( size[INSIDE] ) if( size[INSIDE] )
{ {
drawText( INSIDE, pos + VECTOR2D( 0, -insideOffset - len ), drawText( INSIDE, pos + VECTOR2D( 0, -insideOffset - len ),
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, EDA_ANGLE::VERTICAL ); GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, ANGLE_VERTICAL );
} }
if( size[OUTSIDE] ) if( size[OUTSIDE] )
{ {
drawText( OUTSIDE, pos + VECTOR2D( 0, outsideOffset ), drawText( OUTSIDE, pos + VECTOR2D( 0, outsideOffset ),
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, EDA_ANGLE::VERTICAL ); GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, ANGLE_VERTICAL );
} }
if( size[ABOVE] ) if( size[ABOVE] )
{ {
drawText( ABOVE, pos + VECTOR2D( -aboveOffset, -len / 2.0 ), drawText( ABOVE, pos + VECTOR2D( -aboveOffset, -len / 2.0 ),
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, EDA_ANGLE::VERTICAL ); GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, ANGLE_VERTICAL );
} }
if( size[BELOW] ) if( size[BELOW] )
{ {
drawText( BELOW, pos + VECTOR2D( belowOffset, -len / 2.0 ), drawText( BELOW, pos + VECTOR2D( belowOffset, -len / 2.0 ),
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, EDA_ANGLE::VERTICAL ); GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, ANGLE_VERTICAL );
} }
break; break;
@ -1694,9 +1694,9 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer )
{ {
// Rotate symbol 90 degrees. // Rotate symbol 90 degrees.
if( orient.IsHorizontal() ) if( orient.IsHorizontal() )
orient = EDA_ANGLE::VERTICAL; orient = ANGLE_VERTICAL;
else else
orient = EDA_ANGLE::HORIZONTAL; orient = ANGLE_HORIZONTAL;
} }
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2020 Thomas Pointhuber <thomas.pointhuber@gmx.at> * Copyright (C) 2020 Thomas Pointhuber <thomas.pointhuber@gmx.at>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -792,7 +792,7 @@ void SetTextPositioning( EDA_TEXT* text, ASCH_LABEL_JUSTIFICATION justification,
ASCH_RECORD_ORIENTATION orientation ) ASCH_RECORD_ORIENTATION orientation )
{ {
int vjustify, hjustify; int vjustify, hjustify;
EDA_ANGLE angle = EDA_ANGLE::HORIZONTAL; EDA_ANGLE angle = ANGLE_HORIZONTAL;
switch( justification ) switch( justification )
{ {
@ -839,20 +839,20 @@ void SetTextPositioning( EDA_TEXT* text, ASCH_LABEL_JUSTIFICATION justification,
switch( orientation ) switch( orientation )
{ {
case ASCH_RECORD_ORIENTATION::RIGHTWARDS: case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
angle = EDA_ANGLE::HORIZONTAL; angle = ANGLE_HORIZONTAL;
break; break;
case ASCH_RECORD_ORIENTATION::LEFTWARDS: case ASCH_RECORD_ORIENTATION::LEFTWARDS:
vjustify *= -1; vjustify *= -1;
hjustify *= -1; hjustify *= -1;
angle = EDA_ANGLE::HORIZONTAL; angle = ANGLE_HORIZONTAL;
break; break;
case ASCH_RECORD_ORIENTATION::UPWARDS: case ASCH_RECORD_ORIENTATION::UPWARDS:
angle = EDA_ANGLE::VERTICAL; angle = ANGLE_VERTICAL;
break; break;
case ASCH_RECORD_ORIENTATION::DOWNWARDS: case ASCH_RECORD_ORIENTATION::DOWNWARDS:
vjustify *= -1; vjustify *= -1;
hjustify *= -1; hjustify *= -1;
angle = EDA_ANGLE::VERTICAL; angle = ANGLE_VERTICAL;
break; break;
} }
@ -1854,22 +1854,22 @@ 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( EDA_ANGLE::VERTICAL ); valueField->SetTextAngle( ANGLE_VERTICAL );
valueField->SetHorizJustify( GR_TEXT_H_ALIGN_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( EDA_ANGLE::HORIZONTAL ); valueField->SetTextAngle( ANGLE_HORIZONTAL );
valueField->SetHorizJustify( GR_TEXT_H_ALIGN_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( EDA_ANGLE::VERTICAL ); valueField->SetTextAngle( ANGLE_VERTICAL );
valueField->SetHorizJustify( GR_TEXT_H_ALIGN_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( EDA_ANGLE::HORIZONTAL ); valueField->SetTextAngle( ANGLE_HORIZONTAL );
valueField->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); valueField->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
break; break;
default: default:

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2016 CERN * Copyright (C) 2016 CERN
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* @author Wayne Stambaugh <stambaughw@gmail.com> * @author Wayne Stambaugh <stambaughw@gmail.com>
* *
@ -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( EDA_ANGLE::HORIZONTAL ); field.SetTextAngle( ANGLE_HORIZONTAL );
else if( orientation == 'V' ) else if( orientation == 'V' )
field.SetTextAngle( EDA_ANGLE::VERTICAL ); field.SetTextAngle( 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 );
@ -3098,9 +3098,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( EDA_ANGLE::HORIZONTAL ); field->SetTextAngle( ANGLE_HORIZONTAL );
else if( textOrient == 'V' ) else if( textOrient == 'V' )
field->SetTextAngle( EDA_ANGLE::VERTICAL ); field->SetTextAngle( ANGLE_VERTICAL );
else else
SCH_PARSE_ERROR( "invalid field text orientation parameter", aReader, line ); SCH_PARSE_ERROR( "invalid field text orientation parameter", aReader, line );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2022 Kicad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -560,14 +560,14 @@ void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
m_fields[SHEETNAME].SetTextPos( m_pos + VECTOR2I( -margin, m_size.y ) ); m_fields[SHEETNAME].SetTextPos( m_pos + VECTOR2I( -margin, m_size.y ) );
m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
m_fields[ SHEETNAME ].SetTextAngle( EDA_ANGLE::VERTICAL ); m_fields[ SHEETNAME ].SetTextAngle( ANGLE_VERTICAL );
} }
else else
{ {
m_fields[SHEETNAME].SetTextPos( m_pos + VECTOR2I( 0, -margin ) ); m_fields[SHEETNAME].SetTextPos( m_pos + VECTOR2I( 0, -margin ) );
m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
m_fields[ SHEETNAME ].SetTextAngle( EDA_ANGLE::HORIZONTAL ); m_fields[ SHEETNAME ].SetTextAngle( ANGLE_HORIZONTAL );
} }
textSize = m_fields[ SHEETFILENAME ].GetTextSize(); textSize = m_fields[ SHEETFILENAME ].GetTextSize();
@ -578,14 +578,14 @@ void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
m_fields[SHEETFILENAME].SetTextPos( m_pos + VECTOR2I( m_size.x + margin, m_size.y ) ); m_fields[SHEETFILENAME].SetTextPos( m_pos + VECTOR2I( m_size.x + margin, m_size.y ) );
m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP ); m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP );
m_fields[ SHEETFILENAME ].SetTextAngle( EDA_ANGLE::VERTICAL ); m_fields[ SHEETFILENAME ].SetTextAngle( ANGLE_VERTICAL );
} }
else else
{ {
m_fields[SHEETFILENAME].SetTextPos( m_pos + VECTOR2I( 0, m_size.y + margin ) ); m_fields[SHEETFILENAME].SetTextPos( m_pos + VECTOR2I( 0, m_size.y + margin ) );
m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP ); m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP );
m_fields[ SHEETFILENAME ].SetTextAngle( EDA_ANGLE::HORIZONTAL ); m_fields[ SHEETFILENAME ].SetTextAngle( ANGLE_HORIZONTAL );
} }
m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO; m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO;

View File

@ -310,22 +310,22 @@ 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( EDA_ANGLE::HORIZONTAL ); SetTextAngle( ANGLE_HORIZONTAL );
SetHorizJustify( GR_TEXT_H_ALIGN_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( EDA_ANGLE::VERTICAL ); SetTextAngle( ANGLE_VERTICAL );
SetHorizJustify( GR_TEXT_H_ALIGN_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( EDA_ANGLE::HORIZONTAL ); SetTextAngle( ANGLE_HORIZONTAL );
SetHorizJustify( GR_TEXT_H_ALIGN_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( EDA_ANGLE::VERTICAL ); SetTextAngle( ANGLE_VERTICAL );
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break; break;
} }
@ -413,7 +413,7 @@ const EDA_RECT SCH_TEXT::GetBoundingBox() const
{ {
EDA_RECT rect = GetTextBox(); EDA_RECT rect = GetTextBox();
if( GetTextAngle() != EDA_ANGLE::ANGLE_0 ) // Rotate rect. if( !GetTextAngle().IsZero() ) // Rotate rect.
{ {
VECTOR2I pos = rect.GetOrigin(); VECTOR2I pos = rect.GetOrigin();
VECTOR2I end = rect.GetEnd(); VECTOR2I end = rect.GetEnd();
@ -776,7 +776,7 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise )
if( !aClockwise ) if( !aClockwise )
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); field.SetTextAngle( ANGLE_HORIZONTAL );
} }
else if( field.GetTextAngle().IsVertical() else if( field.GetTextAngle().IsVertical()
&& field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) && field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
@ -784,7 +784,7 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise )
if( !aClockwise ) if( !aClockwise )
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); field.SetTextAngle( ANGLE_HORIZONTAL );
} }
else if( field.GetTextAngle().IsHorizontal() else if( field.GetTextAngle().IsHorizontal()
&& field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) && field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
@ -792,7 +792,7 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise )
if( aClockwise ) if( aClockwise )
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
field.SetTextAngle( EDA_ANGLE::VERTICAL ); field.SetTextAngle( ANGLE_VERTICAL );
} }
else if( field.GetTextAngle().IsHorizontal() else if( field.GetTextAngle().IsHorizontal()
&& field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) && field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
@ -800,7 +800,7 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise )
if( aClockwise ) if( aClockwise )
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
field.SetTextAngle( EDA_ANGLE::VERTICAL ); field.SetTextAngle( ANGLE_VERTICAL );
} }
VECTOR2I pos = field.GetTextPos(); VECTOR2I pos = field.GetTextPos();
@ -828,7 +828,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
{ {
default: default:
case LABEL_SPIN_STYLE::LEFT: case LABEL_SPIN_STYLE::LEFT:
field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); field.SetTextAngle( ANGLE_HORIZONTAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_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 )
@ -839,7 +839,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
break; break;
case LABEL_SPIN_STYLE::UP: case LABEL_SPIN_STYLE::UP:
field.SetTextAngle( EDA_ANGLE::VERTICAL ); field.SetTextAngle( ANGLE_VERTICAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_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 )
@ -850,7 +850,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
break; break;
case LABEL_SPIN_STYLE::RIGHT: case LABEL_SPIN_STYLE::RIGHT:
field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); field.SetTextAngle( ANGLE_HORIZONTAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_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 )
@ -861,7 +861,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
break; break;
case LABEL_SPIN_STYLE::BOTTOM: case LABEL_SPIN_STYLE::BOTTOM:
field.SetTextAngle( EDA_ANGLE::VERTICAL ); field.SetTextAngle( ANGLE_VERTICAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_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 )
@ -1314,7 +1314,7 @@ const EDA_RECT SCH_LABEL::GetBodyBoundingBox() const
rect.Offset( 0, -GetTextOffset() ); rect.Offset( 0, -GetTextOffset() );
if( GetTextAngle() != EDA_ANGLE::ANGLE_0 ) if( !GetTextAngle().IsZero() )
{ {
// Rotate rect // Rotate rect
VECTOR2I pos = rect.GetOrigin(); VECTOR2I pos = rect.GetOrigin();
@ -1462,22 +1462,22 @@ void SCH_NETCLASS_FLAG::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
{ {
default: default:
case LABEL_SPIN_STYLE::LEFT: case LABEL_SPIN_STYLE::LEFT:
field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); field.SetTextAngle( ANGLE_HORIZONTAL );
offset = { symbolWidth + margin, origin }; offset = { symbolWidth + margin, origin };
break; break;
case LABEL_SPIN_STYLE::UP: case LABEL_SPIN_STYLE::UP:
field.SetTextAngle( EDA_ANGLE::VERTICAL ); field.SetTextAngle( ANGLE_VERTICAL );
offset = { -origin, -( symbolWidth + margin ) }; offset = { -origin, -( symbolWidth + margin ) };
break; break;
case LABEL_SPIN_STYLE::RIGHT: case LABEL_SPIN_STYLE::RIGHT:
field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); field.SetTextAngle( ANGLE_HORIZONTAL );
offset = { symbolWidth + margin, -origin }; offset = { symbolWidth + margin, -origin };
break; break;
case LABEL_SPIN_STYLE::BOTTOM: case LABEL_SPIN_STYLE::BOTTOM:
field.SetTextAngle( EDA_ANGLE::VERTICAL ); field.SetTextAngle( ANGLE_VERTICAL );
offset = { origin, -( symbolWidth + margin ) }; offset = { origin, -( symbolWidth + margin ) };
break; break;
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2019 CERN * Copyright (C) 2019 CERN
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -539,9 +539,9 @@ 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().IsHorizontal() ) if( field->GetTextAngle().IsHorizontal() )
field->SetTextAngle( EDA_ANGLE::VERTICAL ); field->SetTextAngle( ANGLE_VERTICAL );
else else
field->SetTextAngle( EDA_ANGLE::HORIZONTAL ); field->SetTextAngle( 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();
@ -645,9 +645,9 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
field->Rotate( rotPoint ); field->Rotate( rotPoint );
if( field->GetTextAngle().IsHorizontal() ) if( field->GetTextAngle().IsHorizontal() )
field->SetTextAngle( EDA_ANGLE::VERTICAL ); field->SetTextAngle( ANGLE_VERTICAL );
else else
field->SetTextAngle( EDA_ANGLE::HORIZONTAL ); field->SetTextAngle( 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();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2019 CERN * Copyright (C) 2019 CERN
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -39,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( EDA_ANGLE::HORIZONTAL ), m_lastTextAngle( 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

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2017 <Jean-Pierre Charras> * Copyright (C) 1992-2017 <Jean-Pierre Charras>
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -105,7 +105,7 @@ bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, EDA_ANGLE&
else else
size = std::min( m_Size.x, m_Size.y ); size = std::min( m_Size.x, m_Size.y );
aOrientation = EDA_ANGLE::HORIZONTAL; aOrientation = ANGLE_HORIZONTAL;
if( m_Flashed ) if( m_Flashed )
{ {
@ -118,7 +118,7 @@ bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, EDA_ANGLE&
double deci = RAD2DECIDEG( atan2( (double)delta.y, (double)delta.x ) ); double deci = RAD2DECIDEG( atan2( (double)delta.y, (double)delta.x ) );
NORMALIZE_ANGLE_90( deci ); NORMALIZE_ANGLE_90( deci );
aOrientation = EDA_ANGLE( deci, EDA_ANGLE::TENTHS_OF_A_DEGREE ); aOrientation = EDA_ANGLE( deci, TENTHS_OF_A_DEGREE_T );
// A reasonable size for text is size/2 because text needs margin below and above it. // A reasonable size for text is size/2 because text needs margin below and above it.
// a margin = size/4 seems good, expecting the line len is large enough to show 3 chars, // a margin = size/4 seems good, expecting the line len is large enough to show 3 chars,

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2021 Ola Rinta-Koski. * Copyright (C) 2021 Ola Rinta-Koski.
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -24,29 +24,31 @@
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
enum EDA_ANGLE_T
{
TENTHS_OF_A_DEGREE_T = 1,
DEGREES_T = 10,
RADIANS_T ///< enum value does not matter
};
class EDA_ANGLE class EDA_ANGLE
{ {
public: 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, // Angles can be created in degrees, 1/10ths of a degree, and radians,
// and read as any of the angle types // and read as any of the angle types
// //
// Angle type must be explicitly specified at creation, because // Angle type must be explicitly specified at creation, because
// there is no other way of knowing what an int or a double represents // there is no other way of knowing what an int or a double represents
EDA_ANGLE( int aValue, ANGLE_TYPE aAngleType ) : EDA_ANGLE( int aValue, EDA_ANGLE_T aAngleType ) :
m_value( 0 ), m_value( 0 ),
m_radians( 0.0 ), m_radians( 0.0 ),
m_initial_type( aAngleType ) m_initial_type( aAngleType )
{ {
switch( aAngleType ) switch( aAngleType )
{ {
case RADIANS: case RADIANS_T:
m_radians = aValue; m_radians = aValue;
m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS ); m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS );
break; break;
@ -56,14 +58,14 @@ public:
} }
} }
EDA_ANGLE( double aValue, ANGLE_TYPE aAngleType ) : EDA_ANGLE( double aValue, EDA_ANGLE_T aAngleType ) :
m_value( 0 ), m_value( 0 ),
m_radians( 0.0 ), m_radians( 0.0 ),
m_initial_type( aAngleType ) m_initial_type( aAngleType )
{ {
switch( aAngleType ) switch( aAngleType )
{ {
case RADIANS: case RADIANS_T:
m_radians = aValue; m_radians = aValue;
m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS ); m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS );
break; break;
@ -76,16 +78,16 @@ public:
EDA_ANGLE() : EDA_ANGLE() :
m_value( 0 ), m_value( 0 ),
m_radians( 0.0 ), m_radians( 0.0 ),
m_initial_type( EDA_ANGLE::RADIANS ) m_initial_type( RADIANS_T )
{} {}
inline double AsDegrees() const { return m_value / (double) EDA_ANGLE::DEGREES; } inline double AsDegrees() const { return m_value / (double) DEGREES_T; }
inline int AsTenthsOfADegree() const { return m_value; } inline int AsTenthsOfADegree() const { return m_value; }
inline double AsRadians() const inline double AsRadians() const
{ {
if( m_initial_type == EDA_ANGLE::RADIANS ) if( m_initial_type == RADIANS_T )
{ {
// if this was initialized with radians, return exact initial value // if this was initialized with radians, return exact initial value
return m_radians; return m_radians;
@ -97,13 +99,13 @@ public:
} }
} }
inline double AsAngleType( ANGLE_TYPE aAngleType ) const inline double AsAngleType( EDA_ANGLE_T aAngleType ) const
{ {
switch( aAngleType ) switch( aAngleType )
{ {
case TENTHS_OF_A_DEGREE: return AsTenthsOfADegree(); case TENTHS_OF_A_DEGREE_T: return AsTenthsOfADegree();
case DEGREES: return AsDegrees(); case DEGREES_T: return AsDegrees();
case RADIANS: return AsRadians(); case RADIANS_T: return AsRadians();
default: assert( 1 == 0 ); default: assert( 1 == 0 );
} }
} }
@ -136,35 +138,35 @@ public:
EDA_ANGLE Add( const EDA_ANGLE& aAngle ) const EDA_ANGLE Add( const EDA_ANGLE& aAngle ) const
{ {
ANGLE_TYPE initialType = GetInitialAngleType(); EDA_ANGLE_T initialType = GetInitialAngleType();
// if both were given in radians, addition is exact // if both were given in radians, addition is exact
if( initialType == EDA_ANGLE::RADIANS if( initialType == RADIANS_T
&& aAngle.GetInitialAngleType() == EDA_ANGLE::RADIANS ) && aAngle.GetInitialAngleType() == RADIANS_T )
{ {
//double newAngle = normalize( AsRadians() + aAngle.AsRadians(), EDA_ANGLE::RADIANS ); //double newAngle = normalize( AsRadians() + aAngle.AsRadians(), RADIANS_T );
double newAngle = AsRadians() + aAngle.AsRadians(); double newAngle = AsRadians() + aAngle.AsRadians();
return EDA_ANGLE( newAngle, EDA_ANGLE::RADIANS ); return EDA_ANGLE( newAngle, RADIANS_T );
} }
// if both were not given in radians, addition is done using // if both were not given in radians, addition is done using
// 1/10ths of a degree, then converted to original angle type // 1/10ths of a degree, then converted to original angle type
// of this angle // of this angle
//int newAngle = normalize( AsTenthsOfADegree() + aAngle.AsTenthsOfADegree(), //int newAngle = normalize( AsTenthsOfADegree() + aAngle.AsTenthsOfADegree(),
//EDA_ANGLE::TENTHS_OF_A_DEGREE ); //TENTHS_OF_A_DEGREE_T );
int newAngle = AsTenthsOfADegree() + aAngle.AsTenthsOfADegree(); int newAngle = AsTenthsOfADegree() + aAngle.AsTenthsOfADegree();
switch( initialType ) switch( initialType )
{ {
case DEGREES: case DEGREES_T:
return EDA_ANGLE( newAngle / EDA_ANGLE::DEGREES, EDA_ANGLE::DEGREES ); return EDA_ANGLE( newAngle / DEGREES_T, DEGREES_T );
case RADIANS: case RADIANS_T:
return EDA_ANGLE( newAngle / TENTHS_OF_A_DEGREE_TO_RADIANS, EDA_ANGLE::RADIANS ); return EDA_ANGLE( newAngle / TENTHS_OF_A_DEGREE_TO_RADIANS, RADIANS_T );
default: default:
case TENTHS_OF_A_DEGREE: case TENTHS_OF_A_DEGREE_T:
return EDA_ANGLE( newAngle, EDA_ANGLE::TENTHS_OF_A_DEGREE ); return EDA_ANGLE( newAngle, TENTHS_OF_A_DEGREE_T );
} }
} }
@ -172,8 +174,8 @@ public:
{ {
switch( GetInitialAngleType() ) switch( GetInitialAngleType() )
{ {
case RADIANS: case RADIANS_T:
return EDA_ANGLE( -m_radians, EDA_ANGLE::RADIANS ); return EDA_ANGLE( -m_radians, RADIANS_T );
default: default:
return EDA_ANGLE( -m_value / GetInitialAngleType(), GetInitialAngleType() ); return EDA_ANGLE( -m_value / GetInitialAngleType(), GetInitialAngleType() );
} }
@ -181,7 +183,7 @@ public:
EDA_ANGLE Subtract( const EDA_ANGLE& aAngle ) const { return Add( aAngle.Invert() ); } EDA_ANGLE Subtract( const EDA_ANGLE& aAngle ) const { return Add( aAngle.Invert() ); }
inline ANGLE_TYPE GetInitialAngleType() const { return m_initial_type; } inline EDA_ANGLE_T GetInitialAngleType() const { return m_initial_type; }
double Sin() const { return sin( AsRadians() ); } double Sin() const { return sin( AsRadians() ); }
@ -189,15 +191,15 @@ public:
double Tan() const { return tan( AsRadians() ); } double Tan() const { return tan( AsRadians() ); }
static EDA_ANGLE Arccos( double x ) { return EDA_ANGLE( acos( x ), EDA_ANGLE::RADIANS ); } static EDA_ANGLE Arccos( double x ) { return EDA_ANGLE( acos( x ), RADIANS_T ); }
static EDA_ANGLE Arcsin( double x ) { return EDA_ANGLE( asin( x ), EDA_ANGLE::RADIANS ); } static EDA_ANGLE Arcsin( double x ) { return EDA_ANGLE( asin( x ), RADIANS_T ); }
static EDA_ANGLE Arctan( double x ) { return EDA_ANGLE( atan( x ), EDA_ANGLE::RADIANS ); } static EDA_ANGLE Arctan( double x ) { return EDA_ANGLE( atan( x ), RADIANS_T ); }
static EDA_ANGLE Arctan2( double y, double x ) static EDA_ANGLE Arctan2( double y, double x )
{ {
return EDA_ANGLE( atan2( y, x ), EDA_ANGLE::RADIANS ); return EDA_ANGLE( atan2( y, x ), RADIANS_T );
} }
inline EDA_ANGLE Normalize() inline EDA_ANGLE Normalize()
@ -206,6 +208,21 @@ public:
return *this; return *this;
} }
inline EDA_ANGLE Normalize180()
{
int angle = AsTenthsOfADegree();
while( angle <= -1800 )
angle += 3600;
while( angle > 1800 )
angle -= 3600;
*this = EDA_ANGLE( angle, TENTHS_OF_A_DEGREE_T );
return *this;
}
inline EDA_ANGLE Normalize720() inline EDA_ANGLE Normalize720()
{ {
normalize( true ); normalize( true );
@ -214,35 +231,41 @@ public:
EDA_ANGLE KeepUpright() const; EDA_ANGLE KeepUpright() const;
EDA_ANGLE& operator+=( const EDA_ANGLE& aAngle )
{
*this = Add( aAngle );
return *this;
}
EDA_ANGLE& operator-=( const EDA_ANGLE& aAngle )
{
EDA_ANGLE angle( aAngle );
*this = Add( angle.Invert() );
return *this;
}
private: private:
void normalize( bool n720 = false ); void normalize( bool n720 = false );
int normalize( int aValue, ANGLE_TYPE aAngleType, bool n720 = false ) const; int normalize( int aValue, EDA_ANGLE_T aAngleType, bool n720 = false ) const;
double normalize( double aValue, ANGLE_TYPE aAngleType, bool n720 = false ) const; double normalize( double aValue, EDA_ANGLE_T aAngleType, bool n720 = false ) const;
private: private:
int m_value; ///< value is always stored in 1/10ths of a degree int m_value; ///< value is always stored in 1/10ths of a degree
double m_radians; ///< only used with as-radians constructor double m_radians; ///< only used with as-radians constructor
ANGLE_TYPE m_initial_type; EDA_ANGLE_T m_initial_type;
static constexpr int TENTHS_OF_A_DEGREE_FULL_CIRCLE = 3600; static constexpr int TENTHS_OF_A_DEGREE_FULL_CIRCLE = 3600;
static constexpr int DEGREES_FULL_CIRCLE = 360; static constexpr int DEGREES_FULL_CIRCLE = 360;
static constexpr double RADIANS_FULL_CIRCLE = 2 * M_PI; 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: public:
static constexpr EDA_ANGLE& HORIZONTAL = m_angle0; static EDA_ANGLE m_Angle0;
static constexpr EDA_ANGLE& VERTICAL = m_angle90; static EDA_ANGLE m_Angle45;
static constexpr EDA_ANGLE& FULL_CIRCLE = m_angle360; static EDA_ANGLE m_Angle90;
static constexpr EDA_ANGLE& ANGLE_0 = m_angle0; static EDA_ANGLE m_Angle180;
static constexpr EDA_ANGLE& ANGLE_90 = m_angle90; static EDA_ANGLE m_Angle270;
static constexpr EDA_ANGLE& ANGLE_180 = m_angle180; static EDA_ANGLE m_Angle360;
static constexpr EDA_ANGLE& ANGLE_270 = m_angle270;
}; };
@ -252,6 +275,18 @@ inline EDA_ANGLE operator-( const EDA_ANGLE& aAngle )
} }
inline EDA_ANGLE operator-( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB )
{
return aAngleA.Add( aAngleB.Invert() );
}
inline EDA_ANGLE operator+( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB )
{
return aAngleA.Add( aAngleB );
}
inline bool operator==( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB ) inline bool operator==( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB )
{ {
return aAngleA.AsTenthsOfADegree() == aAngleB.AsTenthsOfADegree(); return aAngleA.AsTenthsOfADegree() == aAngleB.AsTenthsOfADegree();
@ -264,4 +299,31 @@ inline bool operator!=( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB )
} }
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();
}
inline bool operator<=( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB )
{
return aAngleA.AsTenthsOfADegree() <= aAngleB.AsTenthsOfADegree();
}
static constexpr EDA_ANGLE& ANGLE_HORIZONTAL = EDA_ANGLE::m_Angle0;
static constexpr EDA_ANGLE& ANGLE_VERTICAL = EDA_ANGLE::m_Angle90;
static constexpr EDA_ANGLE& FULL_CIRCLE = EDA_ANGLE::m_Angle360;
static constexpr EDA_ANGLE& ANGLE_0 = EDA_ANGLE::m_Angle0;
static constexpr EDA_ANGLE& ANGLE_45 = EDA_ANGLE::m_Angle45;
static constexpr EDA_ANGLE& ANGLE_90 = EDA_ANGLE::m_Angle90;
static constexpr EDA_ANGLE& ANGLE_180 = EDA_ANGLE::m_Angle180;
static constexpr EDA_ANGLE& ANGLE_270 = EDA_ANGLE::m_Angle270;
#endif // EDA_ANGLE_H #endif // EDA_ANGLE_H

View File

@ -124,7 +124,7 @@ public:
// 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.
SetTextAngle( EDA_ANGLE( aAngleInTenthsOfADegree, EDA_ANGLE::TENTHS_OF_A_DEGREE ) ); SetTextAngle( EDA_ANGLE( aAngleInTenthsOfADegree, TENTHS_OF_A_DEGREE_T ) );
} }
void SetTextAngle( const EDA_ANGLE& aAngle ); void SetTextAngle( const EDA_ANGLE& aAngle );

View File

@ -1,13 +1,8 @@
/**
* @file gen_drill_report_files.cpp
* @brief Functions to create report and map files for EXCELLON drill files.
*/
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2017 Jean_Pierre Charras <jp.charras at wanadoo.fr> * Copyright (C) 1992-2017 Jean_Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -252,7 +247,7 @@ 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( VECTOR2I( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, EDA_ANGLE::HORIZONTAL, plotter->Text( VECTOR2I( plotX, plotY ), COLOR4D::UNSPECIFIED, Text, ANGLE_HORIZONTAL,
wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ), wxSize( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false ); GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false );
@ -313,7 +308,7 @@ 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( VECTOR2I( plotX, y ), COLOR4D::UNSPECIFIED, msg, EDA_ANGLE::HORIZONTAL, plotter->Text( VECTOR2I( plotX, y ), COLOR4D::UNSPECIFIED, msg, ANGLE_HORIZONTAL,
VECTOR2I( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ), VECTOR2I( KiROUND( charSize * charScale ), KiROUND( charSize * charScale ) ),
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false ); GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false );

View File

@ -266,7 +266,7 @@ EDA_ANGLE FP_TEXT::GetDrawRotation() const
NORMALIZE_ANGLE_POS( rotation ); NORMALIZE_ANGLE_POS( rotation );
} }
return EDA_ANGLE( rotation, EDA_ANGLE::TENTHS_OF_A_DEGREE ); return EDA_ANGLE( rotation, TENTHS_OF_A_DEGREE_T );
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013-2019 CERN * Copyright (C) 2013-2019 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
@ -587,17 +587,17 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
if( end.y == start.y ) // horizontal if( end.y == start.y ) // horizontal
{ {
textOrientation = EDA_ANGLE::HORIZONTAL; textOrientation = ANGLE_HORIZONTAL;
textPosition.y += penWidth; textPosition.y += penWidth;
} }
else if( end.x == start.x ) // vertical else if( end.x == start.x ) // vertical
{ {
textOrientation = EDA_ANGLE::VERTICAL; textOrientation = ANGLE_VERTICAL;
textPosition.x += penWidth; textPosition.x += penWidth;
} }
else else
{ {
textOrientation = EDA_ANGLE( -atan( line.y / line.x ), EDA_ANGLE::RADIANS ); textOrientation = EDA_ANGLE( -atan( line.y / line.x ), RADIANS_T );
textPosition.x += penWidth / 1.4; textPosition.x += penWidth / 1.4;
textPosition.y += penWidth / 1.4; textPosition.y += penWidth / 1.4;
} }
@ -773,7 +773,7 @@ void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
m_gal->SetGlyphSize( namesize ); m_gal->SetGlyphSize( namesize );
m_gal->SetLineWidth( namesize.x / 12.0 ); m_gal->SetLineWidth( namesize.x / 12.0 );
m_gal->BitmapText( netname, textpos, EDA_ANGLE::HORIZONTAL ); m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
m_gal->Restore(); m_gal->Restore();
@ -967,7 +967,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
m_gal->SetGlyphSize( namesize ); m_gal->SetGlyphSize( namesize );
m_gal->SetLineWidth( namesize.x / 12.0 ); m_gal->SetLineWidth( namesize.x / 12.0 );
m_gal->BitmapText( netname, textpos, EDA_ANGLE::HORIZONTAL ); m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
} }
if( displayPadNumber ) if( displayPadNumber )
@ -986,7 +986,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
m_gal->SetGlyphSize( numsize ); m_gal->SetGlyphSize( numsize );
m_gal->SetLineWidth( numsize.x / 12.0 ); m_gal->SetLineWidth( numsize.x / 12.0 );
m_gal->BitmapText( padNumber, textpos, EDA_ANGLE::HORIZONTAL ); m_gal->BitmapText( padNumber, textpos, ANGLE_HORIZONTAL );
} }
m_gal->Restore(); m_gal->Restore();

View File

@ -141,7 +141,7 @@ const EDA_RECT PCB_TEXT::GetBoundingBox() const
{ {
EDA_RECT rect = GetTextBox(); EDA_RECT rect = GetTextBox();
if( GetTextAngle() != EDA_ANGLE::ANGLE_0 ) if( !GetTextAngle().IsZero() )
rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle().AsTenthsOfADegree() ); rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle().AsTenthsOfADegree() );
return rect; return rect;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 CERN * Copyright (C) 2012 CERN
* Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2012-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -544,8 +544,7 @@ void PCB_PARSER::parseRenderCache( EDA_TEXT* text )
wxString cacheText = FROM_UTF8( CurText() ); wxString cacheText = FROM_UTF8( CurText() );
double cacheAngle = parseAngle( "render cache angle" ); double cacheAngle = parseAngle( "render cache angle" );
text->SetupRenderCache( cacheText, text->SetupRenderCache( cacheText, EDA_ANGLE( cacheAngle, TENTHS_OF_A_DEGREE_T ) );
EDA_ANGLE( cacheAngle, EDA_ANGLE::TENTHS_OF_A_DEGREE ) );
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 CERN * Copyright (C) 2012 CERN
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -1718,7 +1718,7 @@ 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() != EDA_ANGLE::ANGLE_0 ) if( !aText->GetTextAngle().IsZero() )
m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle().AsTenthsOfADegree() ).c_str() ); m_out->Print( 0, " %s", FormatAngle( aText->GetTextAngle().AsTenthsOfADegree() ).c_str() );
m_out->Print( 0, ")" ); m_out->Print( 0, ")" );

View File

@ -201,7 +201,7 @@ int playground_main_func( int argc, char* argv[] )
overlay->SetGlyphSize( { 100000, 100000 } ); overlay->SetGlyphSize( { 100000, 100000 } );
overlay->BitmapText( wxString::Format( "dist=%d, l=%d", closestDist.Length() ), overlay->BitmapText( wxString::Format( "dist=%d, l=%d", closestDist.Length() ),
closestDist.A + VECTOR2I( 0, -arcs[i].GetWidth() ), closestDist.A + VECTOR2I( 0, -arcs[i].GetWidth() ),
EDA_ANGLE::HORIZONTAL ); ANGLE_HORIZONTAL );
} }
overlay->SetLineWidth( 10000 ); overlay->SetLineWidth( 10000 );
@ -264,9 +264,11 @@ int drawShapes( int argc, char* argv[] )
int mult = ( i % 2 ) ? 1 : -1; int mult = ( i % 2 ) ? 1 : -1;
overlay->AnnotatedPoint( lc.GetPoint( i ), arc.GetWidth() * 2 ); overlay->AnnotatedPoint( lc.GetPoint( i ), arc.GetWidth() * 2 );
overlay->SetGlyphSize( { 800000, 800000 } ); overlay->SetGlyphSize( { 800000, 800000 } );
overlay->BitmapText( wxString::Format( "x=%d, y=%d", lc.GetPoint( i ).x, lc.GetPoint( i ).y ), overlay->BitmapText( wxString::Format( "x=%d, y=%d",
lc.GetPoint( i ) + VECTOR2I( 0, mult*arc.GetWidth() * 4 ), lc.GetPoint( i ).x,
EDA_ANGLE::HORIZONTAL ); lc.GetPoint( i ).y ),
lc.GetPoint( i ) + VECTOR2I( 0, mult*arc.GetWidth() * 4 ),
ANGLE_HORIZONTAL );
} }
arc.Collide( &lc, 100000 ); arc.Collide( &lc, 100000 );

View File

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