diff --git a/common/eda_angle.cpp b/common/eda_angle.cpp index 2ab1217b50..9dbbb138a8 100644 --- a/common/eda_angle.cpp +++ b/common/eda_angle.cpp @@ -2,7 +2,7 @@ * 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. + * Copyright (C) 2021-2022 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 @@ -20,11 +20,14 @@ #include -EDA_ANGLE EDA_ANGLE::m_angle0 = EDA_ANGLE( 0, EDA_ANGLE::DEGREES ); -EDA_ANGLE EDA_ANGLE::m_angle90 = EDA_ANGLE( 90, EDA_ANGLE::DEGREES ); -EDA_ANGLE EDA_ANGLE::m_angle180 = EDA_ANGLE( 180, EDA_ANGLE::DEGREES ); -EDA_ANGLE EDA_ANGLE::m_angle270 = EDA_ANGLE( 270, EDA_ANGLE::DEGREES ); -EDA_ANGLE EDA_ANGLE::m_angle360 = EDA_ANGLE( 360, EDA_ANGLE::DEGREES ); + +EDA_ANGLE EDA_ANGLE::m_Angle0 = EDA_ANGLE( 0, DEGREES_T ); +EDA_ANGLE EDA_ANGLE::m_Angle45 = EDA_ANGLE( 45, DEGREES_T ); +EDA_ANGLE EDA_ANGLE::m_Angle90 = EDA_ANGLE( 90, DEGREES_T ); +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 { @@ -39,39 +42,39 @@ EDA_ANGLE EDA_ANGLE::KeepUpright() const else outDegrees = 90; - return EDA_ANGLE( outDegrees, EDA_ANGLE::DEGREES ); + return EDA_ANGLE( outDegrees, DEGREES_T ); } 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 ); } 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; switch( aAngleType ) { - case DEGREES: + case DEGREES_T: full_circle_upper = DEGREES_FULL_CIRCLE; break; - case TENTHS_OF_A_DEGREE: + case TENTHS_OF_A_DEGREE_T: full_circle_upper = TENTHS_OF_A_DEGREE_FULL_CIRCLE; break; - case RADIANS: + case RADIANS_T: /* ?? should not get here */ 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; 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; + case DEGREES_T: full_circle_upper = DEGREES_FULL_CIRCLE; break; + case TENTHS_OF_A_DEGREE_T: full_circle_upper = TENTHS_OF_A_DEGREE_FULL_CIRCLE; break; + case RADIANS_T: full_circle_upper = RADIANS_FULL_CIRCLE; break; } double full_circle_lower = n720 ? 0 : -full_circle_upper; diff --git a/common/font/font.cpp b/common/font/font.cpp index 35404547ed..9bca6ace54 100644 --- a/common/font/font.cpp +++ b/common/font/font.cpp @@ -280,7 +280,7 @@ VECTOR2I FONT::StringBoundaryLimits( const UTF8& aText, const VECTOR2I& aSize, i if( aItalic ) 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 ); if( IsStroke() ) @@ -305,8 +305,8 @@ VECTOR2I FONT::boundingBoxSingleLine( BOX2I* aBBox, const UTF8& aText, const VEC if( aItalic ) textStyle |= TEXT_STYLE::ITALIC; - VECTOR2I extents = drawMarkup( aBBox, nullptr, aText, aPosition, aSize, EDA_ANGLE::ANGLE_0, - false, VECTOR2I(), textStyle ); + VECTOR2I extents = drawMarkup( aBBox, nullptr, aText, aPosition, aSize, ANGLE_0, false, + VECTOR2I(), textStyle ); return extents; } diff --git a/common/plotters/SVG_plotter.cpp b/common/plotters/SVG_plotter.cpp index 2d85b2a9b0..b4a0650ca0 100644 --- a/common/plotters/SVG_plotter.cpp +++ b/common/plotters/SVG_plotter.cpp @@ -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. * * 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 * 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 sz_dev = userToDeviceSize( text_size ); - if( aOrient != EDA_ANGLE::ANGLE_0 ) + if( !aOrient.IsZero() ) { fprintf( m_outputFile, "\n", @@ -819,7 +814,7 @@ void SVG_PLOTTER::Text( const VECTOR2I& aPos, "text-anchor=\"%s\" opacity=\"0\">%s\n", sz_dev.x, sz_dev.y, hjust, TO_UTF8( XmlEsc( aText ) ) ); - if( aOrient != EDA_ANGLE::ANGLE_0 ) + if( !aOrient.IsZero() ) fputs( "\n", m_outputFile ); fprintf( m_outputFile, "%s\n", diff --git a/common/preview_items/ruler_item.cpp b/common/preview_items/ruler_item.cpp index a5e4a5fe1c..1c35b7db13 100644 --- a/common/preview_items/ruler_item.cpp +++ b/common/preview_items/ruler_item.cpp @@ -1,7 +1,7 @@ /* * 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 * 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 ) { 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 { 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(); diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index ccc4a73406..ddfcce9188 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Chris Pavlina - * 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 * modify it under the terms of the GNU General Public License @@ -196,9 +196,9 @@ protected: for( SCH_FIELD* field : m_fields ) { if( m_symbol->GetTransform().y1 ) - field->SetTextAngle( EDA_ANGLE::VERTICAL ); + field->SetTextAngle( ANGLE_VERTICAL ); else - field->SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field->SetTextAngle( ANGLE_HORIZONTAL ); EDA_RECT bbox = field->GetBoundingBox(); int field_width = bbox.GetWidth(); diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp index b445a3e8fb..6a7621f42c 100644 --- a/eeschema/dialogs/dialog_field_properties.cpp +++ b/eeschema/dialogs/dialog_field_properties.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.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 * 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->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->SetBold( m_isBold ); } diff --git a/eeschema/dialogs/dialog_lib_text_properties.cpp b/eeschema/dialogs/dialog_lib_text_properties.cpp index 56244f6267..f25d76748c 100644 --- a/eeschema/dialogs/dialog_lib_text_properties.cpp +++ b/eeschema/dialogs/dialog_lib_text_properties.cpp @@ -2,7 +2,7 @@ * 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) 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 * 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() ) ); if( m_horizontal->IsChecked() ) - m_graphicText->SetTextAngle( EDA_ANGLE::HORIZONTAL ); + m_graphicText->SetTextAngle( ANGLE_HORIZONTAL ); else - m_graphicText->SetTextAngle( EDA_ANGLE::VERTICAL ); + m_graphicText->SetTextAngle( ANGLE_VERTICAL ); if( !m_CommonUnit->GetValue() ) m_graphicText->SetUnit( m_parent->GetUnit() ); diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index 373ad4973e..d4c10047ee 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -1,7 +1,7 @@ /* * 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 * modify it under the terms of the GNU General Public License @@ -611,9 +611,9 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue case FDC_ORIENTATION: if( aValue == _( "Horizontal" ) ) - field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field.SetTextAngle( ANGLE_HORIZONTAL ); else if( aValue == _( "Vertical" ) ) - field.SetTextAngle( EDA_ANGLE::VERTICAL ); + field.SetTextAngle( ANGLE_VERTICAL ); else wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue ); break; diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index ca1acfff61..ef650796bc 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -2,7 +2,7 @@ * 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) 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 * modify it under the terms of the GNU General Public License @@ -85,7 +85,7 @@ void LIB_FIELD::Init( int 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 // 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 // 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 ); - tmp_text.SetTextAngle( t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL ); + bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL ); + tmp_text.SetTextAngle( t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL ); return tmp_text.TextHitTest( aPosition, aAccuracy ); } @@ -291,8 +291,7 @@ void LIB_FIELD::Rotate( const VECTOR2I& center, bool aRotateCCW ) RotatePoint( pt, center, rot_angle ); SetTextPos( pt ); - SetTextAngle( GetTextAngle() != EDA_ANGLE::HORIZONTAL ? EDA_ANGLE::HORIZONTAL - : EDA_ANGLE::VERTICAL ); + SetTextAngle( GetTextAngle() != ANGLE_HORIZONTAL ? ANGLE_HORIZONTAL : 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( orient.IsHorizontal() ) - orient = EDA_ANGLE::VERTICAL; + orient = ANGLE_VERTICAL; else - orient = EDA_ANGLE::HORIZONTAL; + orient = ANGLE_HORIZONTAL; } EDA_RECT bbox = GetBoundingBox(); diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index a2d3349160..a6f32687c6 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -402,14 +402,14 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos if( aPinOrient == PIN_RIGHT ) { 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, namePenWidth, false, false, font ); } else // Orient == PIN_LEFT { 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, namePenWidth, false, false, font ); } @@ -418,7 +418,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos if( aDrawPinNum ) { 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 ); } } @@ -431,7 +431,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos 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, namePenWidth, false, false, font ); } @@ -439,7 +439,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos if( aDrawPinNum ) { 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 ); } } @@ -449,7 +449,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos 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, namePenWidth, false, false, font ); } @@ -457,7 +457,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos if( aDrawPinNum ) { 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 ); } } @@ -471,16 +471,16 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos if( aDrawPinName ) { x = ( x1 + aPinPos.x) / 2; - GRPrintText( DC, VECTOR2I( x, y1 - name_offset ), NameColor, name, - EDA_ANGLE::HORIZONTAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false, font ); + GRPrintText( DC, VECTOR2I( x, y1 - name_offset ), NameColor, name, ANGLE_HORIZONTAL, + pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, + namePenWidth, false, false, font ); } if( aDrawPinNum ) { x = ( x1 + aPinPos.x) / 2; - GRPrintText( DC, VECTOR2I( x, y1 + num_offset ), NumColor, number, - EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false, font ); + GRPrintText( DC, VECTOR2I( x, y1 + num_offset ), NumColor, number, ANGLE_HORIZONTAL, + pinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, + numPenWidth, false, false, font ); } } else /* Its a vertical line. */ @@ -488,15 +488,15 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos if( aDrawPinName ) { y = ( y1 + aPinPos.y) / 2; - GRPrintText( DC, VECTOR2I( x1 - name_offset, y ), NameColor, name, - EDA_ANGLE::VERTICAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false, font ); + GRPrintText( DC, VECTOR2I( x1 - name_offset, y ), NameColor, name, ANGLE_VERTICAL, + pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, + namePenWidth, false, false, font ); } if( aDrawPinNum ) { 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 ); } } @@ -528,19 +528,19 @@ void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECT VECTOR2I txtpos = aPosition; int offset = Millimeter2iu( 0.4 ); GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_LEFT; - EDA_ANGLE orient = EDA_ANGLE::HORIZONTAL; + EDA_ANGLE orient = ANGLE_HORIZONTAL; switch( aOrientation ) { case PIN_UP: txtpos.y += offset; - orient = EDA_ANGLE::VERTICAL; + orient = ANGLE_VERTICAL; hjustify = GR_TEXT_H_ALIGN_RIGHT; break; case PIN_DOWN: txtpos.y -= offset; - orient = EDA_ANGLE::VERTICAL; + orient = ANGLE_VERTICAL; break; case PIN_LEFT: @@ -752,14 +752,13 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin hjustify = GR_TEXT_H_ALIGN_RIGHT; } - aPlotter->Text( VECTOR2I( x, y1 ), nameColor, name, EDA_ANGLE::HORIZONTAL, - pinNameSize, hjustify, GR_TEXT_V_ALIGN_CENTER, namePenWidth, - false, false ); + aPlotter->Text( VECTOR2I( x, y1 ), nameColor, name, ANGLE_HORIZONTAL, pinNameSize, + hjustify, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false, false ); } if( aDrawPinNum ) { 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 ); } } @@ -770,14 +769,14 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin y = y1 + aTextInside; 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, namePenWidth, false, false ); if( aDrawPinNum ) { 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 ); } } @@ -787,7 +786,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin 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, namePenWidth, false, false ); } @@ -795,7 +794,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin if( aDrawPinNum ) { 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 ); } } @@ -809,17 +808,17 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin if( aDrawPinName ) { x = ( x1 + aPinPos.x) / 2; - aPlotter->Text( VECTOR2I( x, y1 - name_offset ), nameColor, name, - EDA_ANGLE::HORIZONTAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false ); + aPlotter->Text( VECTOR2I( x, y1 - name_offset ), nameColor, name, ANGLE_HORIZONTAL, + pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, + namePenWidth, false, false ); } if( aDrawPinNum ) { x = ( x1 + aPinPos.x ) / 2; - aPlotter->Text( VECTOR2I( x, y1 + num_offset ), numColor, number, - EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_TOP, numPenWidth, false, false ); + aPlotter->Text( VECTOR2I( x, y1 + num_offset ), numColor, number, ANGLE_HORIZONTAL, + pinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, + numPenWidth, false, false ); } } else /* Its a vertical line. */ @@ -827,15 +826,15 @@ void LIB_PIN::PlotPinTexts( PLOTTER* aPlotter, const VECTOR2I& aPinPos, int aPin if( aDrawPinName ) { y = ( y1 + aPinPos.y ) / 2; - aPlotter->Text( VECTOR2I( x1 - name_offset, y ), nameColor, name, - EDA_ANGLE::VERTICAL, pinNameSize, GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_BOTTOM, namePenWidth, false, false ); + aPlotter->Text( VECTOR2I( x1 - name_offset, y ), nameColor, name, ANGLE_VERTICAL, + pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, + namePenWidth, false, false ); } if( aDrawPinNum ) { 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 ); } } diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 9be2496807..2c949518e1 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -1,7 +1,7 @@ /* * 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 * 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. * 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 ); } @@ -234,7 +234,7 @@ void LIB_TEXT::Rotate( const VECTOR2I& center, bool aRotateCCW ) if( GetTextAngle().IsHorizontal() ) { - SetTextAngle( EDA_ANGLE::VERTICAL ); + SetTextAngle( ANGLE_VERTICAL ); } 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 // 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; // Get color @@ -284,9 +284,8 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const VECTOR2I& offset, bool fill, int penWidth = std::max( GetEffectiveTextPenWidth(), settings->GetMinPenWidth() ); - plotter->Text( pos, color, GetText(), t1 ? EDA_ANGLE::HORIZONTAL : EDA_ANGLE::VERTICAL, - GetTextSize(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, - IsItalic(), IsBold() ); + plotter->Text( pos, color, GetText(), t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL, GetTextSize(), + GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, 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( orient == EDA_ANGLE::HORIZONTAL ) - orient = EDA_ANGLE::VERTICAL; + if( orient == ANGLE_HORIZONTAL ) + orient = ANGLE_VERTICAL; else - orient = EDA_ANGLE::HORIZONTAL; + orient = ANGLE_HORIZONTAL; } /* diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index cb5778447b..cf08ee1b3d 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -2,7 +2,7 @@ * 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) 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 * 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( orient == EDA_ANGLE::HORIZONTAL ) - orient = EDA_ANGLE::VERTICAL; + if( orient == ANGLE_HORIZONTAL ) + orient = ANGLE_VERTICAL; 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( orient.IsHorizontal() ) - orient = EDA_ANGLE::VERTICAL; + orient = ANGLE_VERTICAL; 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( orient.IsHorizontal() ) - orient = EDA_ANGLE::VERTICAL; + orient = ANGLE_VERTICAL; else - orient = EDA_ANGLE::HORIZONTAL; + orient = ANGLE_HORIZONTAL; } } diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index bc5fab1867..50d9d8e24b 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * 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 * @@ -1144,22 +1144,22 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) if( size[INSIDE] ) { 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] ) { 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] ) { 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] ) { 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; @@ -1167,22 +1167,22 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) if( size[INSIDE] ) { 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] ) { 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] ) { 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] ) { 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; @@ -1190,22 +1190,22 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) if( size[INSIDE] ) { 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] ) { 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] ) { 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] ) { 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; @@ -1213,22 +1213,22 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) if( size[INSIDE] ) { 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] ) { 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] ) { 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] ) { 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; @@ -1694,9 +1694,9 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) { // Rotate symbol 90 degrees. if( orient.IsHorizontal() ) - orient = EDA_ANGLE::VERTICAL; + orient = ANGLE_VERTICAL; else - orient = EDA_ANGLE::HORIZONTAL; + orient = ANGLE_HORIZONTAL; } } diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 5264a93c11..bddde83b34 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Thomas Pointhuber - * 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 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 ) { int vjustify, hjustify; - EDA_ANGLE angle = EDA_ANGLE::HORIZONTAL; + EDA_ANGLE angle = ANGLE_HORIZONTAL; switch( justification ) { @@ -839,20 +839,20 @@ void SetTextPositioning( EDA_TEXT* text, ASCH_LABEL_JUSTIFICATION justification, switch( orientation ) { case ASCH_RECORD_ORIENTATION::RIGHTWARDS: - angle = EDA_ANGLE::HORIZONTAL; + angle = ANGLE_HORIZONTAL; break; case ASCH_RECORD_ORIENTATION::LEFTWARDS: vjustify *= -1; hjustify *= -1; - angle = EDA_ANGLE::HORIZONTAL; + angle = ANGLE_HORIZONTAL; break; case ASCH_RECORD_ORIENTATION::UPWARDS: - angle = EDA_ANGLE::VERTICAL; + angle = ANGLE_VERTICAL; break; case ASCH_RECORD_ORIENTATION::DOWNWARDS: vjustify *= -1; hjustify *= -1; - angle = EDA_ANGLE::VERTICAL; + angle = ANGLE_VERTICAL; break; } @@ -1854,22 +1854,22 @@ void SCH_ALTIUM_PLUGIN::ParsePowerPort( const std::map& aPro { case ASCH_RECORD_ORIENTATION::RIGHTWARDS: symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_90 ); - valueField->SetTextAngle( EDA_ANGLE::VERTICAL ); + valueField->SetTextAngle( ANGLE_VERTICAL ); valueField->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case ASCH_RECORD_ORIENTATION::UPWARDS: symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_180 ); - valueField->SetTextAngle( EDA_ANGLE::HORIZONTAL ); + valueField->SetTextAngle( ANGLE_HORIZONTAL ); valueField->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; case ASCH_RECORD_ORIENTATION::LEFTWARDS: symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_270 ); - valueField->SetTextAngle( EDA_ANGLE::VERTICAL ); + valueField->SetTextAngle( ANGLE_VERTICAL ); valueField->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case ASCH_RECORD_ORIENTATION::DOWNWARDS: symbol->SetOrientation( SYMBOL_ORIENTATION_T::SYM_ORIENT_0 ); - valueField->SetTextAngle( EDA_ANGLE::HORIZONTAL ); + valueField->SetTextAngle( ANGLE_HORIZONTAL ); valueField->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); break; default: diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index fa033a8986..ae5f83ffb1 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * 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 * @@ -1784,9 +1784,9 @@ SCH_SYMBOL* SCH_LEGACY_PLUGIN::loadSymbol( LINE_READER& aReader ) field.SetTextSize( wxSize( size, size ) ); if( orientation == 'H' ) - field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field.SetTextAngle( ANGLE_HORIZONTAL ); else if( orientation == 'V' ) - field.SetTextAngle( EDA_ANGLE::VERTICAL ); + field.SetTextAngle( ANGLE_VERTICAL ); else 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& aSymbol, char textOrient = parseChar( aReader, line, &line ); if( textOrient == 'H' ) - field->SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field->SetTextAngle( ANGLE_HORIZONTAL ); else if( textOrient == 'V' ) - field->SetTextAngle( EDA_ANGLE::VERTICAL ); + field->SetTextAngle( ANGLE_VERTICAL ); else SCH_PARSE_ERROR( "invalid field text orientation parameter", aReader, line ); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 9691bc667d..c037a84759 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -2,7 +2,7 @@ * 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) 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 * 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 ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - m_fields[ SHEETNAME ].SetTextAngle( EDA_ANGLE::VERTICAL ); + m_fields[ SHEETNAME ].SetTextAngle( ANGLE_VERTICAL ); } else { m_fields[SHEETNAME].SetTextPos( m_pos + VECTOR2I( 0, -margin ) ); m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - m_fields[ SHEETNAME ].SetTextAngle( EDA_ANGLE::HORIZONTAL ); + m_fields[ SHEETNAME ].SetTextAngle( ANGLE_HORIZONTAL ); } 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 ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - m_fields[ SHEETFILENAME ].SetTextAngle( EDA_ANGLE::VERTICAL ); + m_fields[ SHEETFILENAME ].SetTextAngle( ANGLE_VERTICAL ); } else { m_fields[SHEETFILENAME].SetTextPos( m_pos + VECTOR2I( 0, m_size.y + margin ) ); m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - m_fields[ SHEETFILENAME ].SetTextAngle( EDA_ANGLE::HORIZONTAL ); + m_fields[ SHEETFILENAME ].SetTextAngle( ANGLE_HORIZONTAL ); } m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index eae1d9ce4f..aa7b51961c 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -310,22 +310,22 @@ void SCH_TEXT::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) KI_FALLTHROUGH; case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation - SetTextAngle( EDA_ANGLE::HORIZONTAL ); + SetTextAngle( ANGLE_HORIZONTAL ); SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case LABEL_SPIN_STYLE::UP: // Vert Orientation UP - SetTextAngle( EDA_ANGLE::VERTICAL ); + SetTextAngle( ANGLE_VERTICAL ); SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break; case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation - Right justified - SetTextAngle( EDA_ANGLE::HORIZONTAL ); + SetTextAngle( ANGLE_HORIZONTAL ); SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM - SetTextAngle( EDA_ANGLE::VERTICAL ); + SetTextAngle( ANGLE_VERTICAL ); SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; } @@ -413,7 +413,7 @@ const EDA_RECT SCH_TEXT::GetBoundingBox() const { EDA_RECT rect = GetTextBox(); - if( GetTextAngle() != EDA_ANGLE::ANGLE_0 ) // Rotate rect. + if( !GetTextAngle().IsZero() ) // Rotate rect. { VECTOR2I pos = rect.GetOrigin(); VECTOR2I end = rect.GetEnd(); @@ -776,7 +776,7 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise ) if( !aClockwise ) field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field.SetTextAngle( ANGLE_HORIZONTAL ); } else if( field.GetTextAngle().IsVertical() && field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) @@ -784,7 +784,7 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise ) if( !aClockwise ) field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field.SetTextAngle( ANGLE_HORIZONTAL ); } else if( field.GetTextAngle().IsHorizontal() && field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) @@ -792,7 +792,7 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise ) if( aClockwise ) field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - field.SetTextAngle( EDA_ANGLE::VERTICAL ); + field.SetTextAngle( ANGLE_VERTICAL ); } else if( field.GetTextAngle().IsHorizontal() && field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) @@ -800,7 +800,7 @@ void SCH_LABEL_BASE::Rotate90( bool aClockwise ) if( aClockwise ) field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - field.SetTextAngle( EDA_ANGLE::VERTICAL ); + field.SetTextAngle( ANGLE_VERTICAL ); } VECTOR2I pos = field.GetTextPos(); @@ -828,7 +828,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) { default: case LABEL_SPIN_STYLE::LEFT: - field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field.SetTextAngle( ANGLE_HORIZONTAL ); field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) @@ -839,7 +839,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) break; case LABEL_SPIN_STYLE::UP: - field.SetTextAngle( EDA_ANGLE::VERTICAL ); + field.SetTextAngle( ANGLE_VERTICAL ); field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) @@ -850,7 +850,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) break; case LABEL_SPIN_STYLE::RIGHT: - field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field.SetTextAngle( ANGLE_HORIZONTAL ); field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) @@ -861,7 +861,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) break; case LABEL_SPIN_STYLE::BOTTOM: - field.SetTextAngle( EDA_ANGLE::VERTICAL ); + field.SetTextAngle( ANGLE_VERTICAL ); field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) @@ -1314,7 +1314,7 @@ const EDA_RECT SCH_LABEL::GetBodyBoundingBox() const rect.Offset( 0, -GetTextOffset() ); - if( GetTextAngle() != EDA_ANGLE::ANGLE_0 ) + if( !GetTextAngle().IsZero() ) { // Rotate rect VECTOR2I pos = rect.GetOrigin(); @@ -1462,22 +1462,22 @@ void SCH_NETCLASS_FLAG::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) { default: case LABEL_SPIN_STYLE::LEFT: - field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field.SetTextAngle( ANGLE_HORIZONTAL ); offset = { symbolWidth + margin, origin }; break; case LABEL_SPIN_STYLE::UP: - field.SetTextAngle( EDA_ANGLE::VERTICAL ); + field.SetTextAngle( ANGLE_VERTICAL ); offset = { -origin, -( symbolWidth + margin ) }; break; case LABEL_SPIN_STYLE::RIGHT: - field.SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field.SetTextAngle( ANGLE_HORIZONTAL ); offset = { symbolWidth + margin, -origin }; break; case LABEL_SPIN_STYLE::BOTTOM: - field.SetTextAngle( EDA_ANGLE::VERTICAL ); + field.SetTextAngle( ANGLE_VERTICAL ); offset = { origin, -( symbolWidth + margin ) }; break; } diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 96d29cb60f..030580ed9d 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * 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 * 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( head ); if( field->GetTextAngle().IsHorizontal() ) - field->SetTextAngle( EDA_ANGLE::VERTICAL ); + field->SetTextAngle( ANGLE_VERTICAL ); else - field->SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field->SetTextAngle( ANGLE_HORIZONTAL ); // Now that we're moving a field, they're no longer autoplaced. static_cast( head->GetParent() )->ClearFieldsAutoplaced(); @@ -645,9 +645,9 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) field->Rotate( rotPoint ); if( field->GetTextAngle().IsHorizontal() ) - field->SetTextAngle( EDA_ANGLE::VERTICAL ); + field->SetTextAngle( ANGLE_VERTICAL ); else - field->SetTextAngle( EDA_ANGLE::HORIZONTAL ); + field->SetTextAngle( ANGLE_HORIZONTAL ); // Now that we're moving a field, they're no longer autoplaced. static_cast( field->GetParent() )->ClearFieldsAutoplaced(); diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index f6b1e1fba0..9d0fdcbe6c 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * 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 * 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() : EE_TOOL_BASE( "eeschema.SymbolDrawing" ), - m_lastTextAngle( EDA_ANGLE::HORIZONTAL ), + m_lastTextAngle( ANGLE_HORIZONTAL ), m_lastFillStyle( FILL_T::NO_FILL ), m_drawSpecificConvert( true ), m_drawSpecificUnit( false ) diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index 64a10d8017..90a6ef1af3 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2017 - * 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 * 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 size = std::min( m_Size.x, m_Size.y ); - aOrientation = EDA_ANGLE::HORIZONTAL; + aOrientation = ANGLE_HORIZONTAL; 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 ) ); 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 margin = size/4 seems good, expecting the line len is large enough to show 3 chars, diff --git a/include/eda_angle.h b/include/eda_angle.h index 979b0db47e..df18dcd197 100644 --- a/include/eda_angle.h +++ b/include/eda_angle.h @@ -2,7 +2,7 @@ * 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. + * Copyright (C) 2021-2022 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 @@ -24,29 +24,31 @@ #include #include + +enum EDA_ANGLE_T +{ + TENTHS_OF_A_DEGREE_T = 1, + DEGREES_T = 10, + RADIANS_T ///< enum value does not matter +}; + + 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 ) : + EDA_ANGLE( int aValue, EDA_ANGLE_T aAngleType ) : m_value( 0 ), m_radians( 0.0 ), m_initial_type( aAngleType ) { switch( aAngleType ) { - case RADIANS: + case RADIANS_T: m_radians = aValue; m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS ); 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_radians( 0.0 ), m_initial_type( aAngleType ) { switch( aAngleType ) { - case RADIANS: + case RADIANS_T: m_radians = aValue; m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS ); break; @@ -76,16 +78,16 @@ public: EDA_ANGLE() : m_value( 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 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 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 ) { - case TENTHS_OF_A_DEGREE: return AsTenthsOfADegree(); - case DEGREES: return AsDegrees(); - case RADIANS: return AsRadians(); + case TENTHS_OF_A_DEGREE_T: return AsTenthsOfADegree(); + case DEGREES_T: return AsDegrees(); + case RADIANS_T: return AsRadians(); default: assert( 1 == 0 ); } } @@ -136,35 +138,35 @@ public: 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( initialType == EDA_ANGLE::RADIANS - && aAngle.GetInitialAngleType() == EDA_ANGLE::RADIANS ) + if( initialType == RADIANS_T + && 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(); - return EDA_ANGLE( newAngle, EDA_ANGLE::RADIANS ); + return EDA_ANGLE( newAngle, RADIANS_T ); } // 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 ); + //TENTHS_OF_A_DEGREE_T ); int newAngle = AsTenthsOfADegree() + aAngle.AsTenthsOfADegree(); switch( initialType ) { - case DEGREES: - return EDA_ANGLE( newAngle / EDA_ANGLE::DEGREES, EDA_ANGLE::DEGREES ); + case DEGREES_T: + return EDA_ANGLE( newAngle / DEGREES_T, DEGREES_T ); - case RADIANS: - return EDA_ANGLE( newAngle / TENTHS_OF_A_DEGREE_TO_RADIANS, EDA_ANGLE::RADIANS ); + case RADIANS_T: + return EDA_ANGLE( newAngle / TENTHS_OF_A_DEGREE_TO_RADIANS, RADIANS_T ); default: - case TENTHS_OF_A_DEGREE: - return EDA_ANGLE( newAngle, EDA_ANGLE::TENTHS_OF_A_DEGREE ); + case TENTHS_OF_A_DEGREE_T: + return EDA_ANGLE( newAngle, TENTHS_OF_A_DEGREE_T ); } } @@ -172,8 +174,8 @@ public: { switch( GetInitialAngleType() ) { - case RADIANS: - return EDA_ANGLE( -m_radians, EDA_ANGLE::RADIANS ); + case RADIANS_T: + return EDA_ANGLE( -m_radians, RADIANS_T ); default: return EDA_ANGLE( -m_value / GetInitialAngleType(), GetInitialAngleType() ); } @@ -181,7 +183,7 @@ public: 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() ); } @@ -189,15 +191,15 @@ public: 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 ) { - return EDA_ANGLE( atan2( y, x ), EDA_ANGLE::RADIANS ); + return EDA_ANGLE( atan2( y, x ), RADIANS_T ); } inline EDA_ANGLE Normalize() @@ -206,6 +208,21 @@ public: 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() { normalize( true ); @@ -214,35 +231,41 @@ public: 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: 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; + int normalize( int aValue, EDA_ANGLE_T aAngleType, bool n720 = false ) const; + double normalize( double aValue, EDA_ANGLE_T aAngleType, bool n720 = false ) const; private: int m_value; ///< value is always stored in 1/10ths of a degree 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 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; + static EDA_ANGLE m_Angle0; + static EDA_ANGLE m_Angle45; + static EDA_ANGLE m_Angle90; + static EDA_ANGLE m_Angle180; + static EDA_ANGLE m_Angle270; + static EDA_ANGLE m_Angle360; }; @@ -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 ) { 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 diff --git a/include/eda_text.h b/include/eda_text.h index 7a340a7b4b..32e1dc105d 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -124,7 +124,7 @@ public: // Higher level classes may be more restrictive than this by overloading // SetTextAngle() or merely calling EDA_TEXT::SetTextAngle() after clamping // aAngle before calling this lowest inline accessor. - 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 ); diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index e2ebb8613b..689ea801b6 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -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. * * 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 * 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" 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 ) ), 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 ) 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 ) ), GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, TextWidth, false, false ); diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index cce36dcf0f..90f3417e03 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -266,7 +266,7 @@ EDA_ANGLE FP_TEXT::GetDrawRotation() const NORMALIZE_ANGLE_POS( rotation ); } - return EDA_ANGLE( rotation, EDA_ANGLE::TENTHS_OF_A_DEGREE ); + return EDA_ANGLE( rotation, TENTHS_OF_A_DEGREE_T ); } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 2e032df55e..d47340ad2b 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * 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 * @author Maciej Suminski @@ -587,17 +587,17 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer ) if( end.y == start.y ) // horizontal { - textOrientation = EDA_ANGLE::HORIZONTAL; + textOrientation = ANGLE_HORIZONTAL; textPosition.y += penWidth; } else if( end.x == start.x ) // vertical { - textOrientation = EDA_ANGLE::VERTICAL; + textOrientation = ANGLE_VERTICAL; textPosition.x += penWidth; } 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.y += penWidth / 1.4; } @@ -773,7 +773,7 @@ void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer ) m_gal->SetGlyphSize( namesize ); 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(); @@ -967,7 +967,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) m_gal->SetGlyphSize( namesize ); m_gal->SetLineWidth( namesize.x / 12.0 ); - m_gal->BitmapText( netname, textpos, EDA_ANGLE::HORIZONTAL ); + m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL ); } if( displayPadNumber ) @@ -986,7 +986,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) m_gal->SetGlyphSize( numsize ); 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(); diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index f99992f90e..03b3bebd4c 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -141,7 +141,7 @@ const EDA_RECT PCB_TEXT::GetBoundingBox() const { EDA_RECT rect = GetTextBox(); - if( GetTextAngle() != EDA_ANGLE::ANGLE_0 ) + if( !GetTextAngle().IsZero() ) rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle().AsTenthsOfADegree() ); return rect; diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 50525c1a46..5d9208bb87 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * 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 * 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() ); double cacheAngle = parseAngle( "render cache angle" ); - text->SetupRenderCache( cacheText, - EDA_ANGLE( cacheAngle, EDA_ANGLE::TENTHS_OF_A_DEGREE ) ); + text->SetupRenderCache( cacheText, EDA_ANGLE( cacheAngle, TENTHS_OF_A_DEGREE_T ) ); for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index a1e61718ce..f00cde807f 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * 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 * 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(), 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, ")" ); diff --git a/qa/pns/playground.cpp b/qa/pns/playground.cpp index 53c52510ec..eca1ff19d0 100644 --- a/qa/pns/playground.cpp +++ b/qa/pns/playground.cpp @@ -201,7 +201,7 @@ int playground_main_func( int argc, char* argv[] ) overlay->SetGlyphSize( { 100000, 100000 } ); overlay->BitmapText( wxString::Format( "dist=%d, l=%d", closestDist.Length() ), closestDist.A + VECTOR2I( 0, -arcs[i].GetWidth() ), - EDA_ANGLE::HORIZONTAL ); + ANGLE_HORIZONTAL ); } overlay->SetLineWidth( 10000 ); @@ -264,9 +264,11 @@ int drawShapes( int argc, char* argv[] ) int mult = ( i % 2 ) ? 1 : -1; overlay->AnnotatedPoint( lc.GetPoint( i ), arc.GetWidth() * 2 ); overlay->SetGlyphSize( { 800000, 800000 } ); - overlay->BitmapText( wxString::Format( "x=%d, y=%d", lc.GetPoint( i ).x, lc.GetPoint( i ).y ), - lc.GetPoint( i ) + VECTOR2I( 0, mult*arc.GetWidth() * 4 ), - EDA_ANGLE::HORIZONTAL ); + overlay->BitmapText( wxString::Format( "x=%d, y=%d", + lc.GetPoint( i ).x, + lc.GetPoint( i ).y ), + lc.GetPoint( i ) + VECTOR2I( 0, mult*arc.GetWidth() * 4 ), + ANGLE_HORIZONTAL ); } arc.Collide( &lc, 100000 ); diff --git a/qa/pns/pns_log_viewer.cpp b/qa/pns/pns_log_viewer.cpp index 6eee692357..6cbfd8dda4 100644 --- a/qa/pns/pns_log_viewer.cpp +++ b/qa/pns/pns_log_viewer.cpp @@ -99,7 +99,7 @@ void LABEL_MANAGER::Redraw( KIGFX::VIEW_OVERLAY* aOvl ) aOvl->SetLineWidth( 10000 ); aOvl->SetStrokeColor( lbl.m_color.Brighten( 0.7 ) ); 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 ); aOvl->Line( lbl.m_target, nearest ); }