diff --git a/common/array_options.cpp b/common/array_options.cpp index 9898406679..6629409a22 100644 --- a/common/array_options.cpp +++ b/common/array_options.cpp @@ -75,7 +75,7 @@ ARRAY_OPTIONS::TRANSFORM ARRAY_GRID_OPTIONS::GetTransform( int n, const VECTOR2I } // this is already relative to the first array entry - return { point, 0.0 }; + return { point, ANGLE_0 }; } @@ -107,23 +107,23 @@ int ARRAY_CIRCULAR_OPTIONS::GetArraySize() const ARRAY_OPTIONS::TRANSFORM ARRAY_CIRCULAR_OPTIONS::GetTransform( int n, const VECTOR2I& aPos ) const { - double angle; + EDA_ANGLE angle; - if( m_angle == 0 ) + if( m_angle.IsZero() ) // angle is zero, divide evenly into m_nPts - angle = 10 * 360.0 * n / double( m_nPts ); + angle = EDA_ANGLE( 360.0 * n / double( m_nPts ), DEGREES_T ); else // n'th step - angle = m_angle * n; + angle = EDA_ANGLE( m_angle.AsDegrees() * n, DEGREES_T ); VECTOR2I new_pos = aPos; RotatePoint( new_pos, m_centre, angle ); // take off the rotation (but not the translation) if needed if( !m_rotateItems ) - angle = 0; + angle = ANGLE_0; - return { new_pos - aPos, angle / 10.0 }; + return { new_pos - aPos, angle }; } diff --git a/common/drawing_sheet/ds_data_item.cpp b/common/drawing_sheet/ds_data_item.cpp index 9ea0861d63..5cd91b9664 100644 --- a/common/drawing_sheet/ds_data_item.cpp +++ b/common/drawing_sheet/ds_data_item.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2013 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 @@ -596,7 +596,7 @@ void DS_DATA_ITEM_TEXT::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIE text->SetHorizJustify( m_Hjustify ) ; text->SetVertJustify( m_Vjustify ); - text->SetTextAngle( m_Orient * 10 ); // graphic text orient unit = 0.1 degree + text->SetTextAngle( EDA_ANGLE( m_Orient, DEGREES_T ) ); text->SetMultilineAllowed( multilines ); // Increment label for the next text (has no meaning for multiline texts) @@ -697,7 +697,7 @@ void DS_DATA_ITEM_TEXT::SetConstrainedTextSize() dummy.SetMultilineAllowed( true ); dummy.SetHorizJustify( m_Hjustify ) ; dummy.SetVertJustify( m_Vjustify ); - dummy.SetTextAngle( m_Orient * 10 ); + dummy.SetTextAngle( EDA_ANGLE( m_Orient, DEGREES_T ) ); EDA_RECT rect = dummy.GetTextBox(); DSIZE size; diff --git a/common/drawing_sheet/ds_draw_item.cpp b/common/drawing_sheet/ds_draw_item.cpp index 36e602aa2d..2efb2733e9 100644 --- a/common/drawing_sheet/ds_draw_item.cpp +++ b/common/drawing_sheet/ds_draw_item.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2013 Jean-Pierre Charras . - * Copyright (C) 1992-2020 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 @@ -189,11 +189,6 @@ wxString DS_DRAW_ITEM_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const } -void DS_DRAW_ITEM_TEXT::SetTextAngle( double aAngle ) -{ - EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) ); -} - // ============================ POLYGON ================================= void DS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( const RENDER_SETTINGS* aSettings, diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 2c949518e1..a2f7472204 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -250,7 +250,7 @@ void LIB_TEXT::Rotate( const VECTOR2I& center, bool aRotateCCW ) else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - SetTextAngle( 0 ); + SetTextAngle( ANGLE_0 ); } NormalizeJustification( true ); diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index ebca2b747f..eb0e32bed7 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020-2021 Roberto Fernandez Bautista - * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 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 as published by the @@ -2622,7 +2622,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT aKiCadTextItem->SetTextWidth( textWidth ); aKiCadTextItem->SetTextHeight( textHeight ); aKiCadTextItem->SetTextThickness( getKiCadLength( textCode.LineWidth ) ); - aKiCadTextItem->SetTextAngle( getAngleTenthDegree( aCadstarOrientAngle ) ); + aKiCadTextItem->SetTextAngle( EDA_ANGLE( getAngleDegrees( aCadstarOrientAngle ), DEGREES_T ) ); aKiCadTextItem->SetBold( textCode.Font.Modifier1 == FONT_BOLD ); aKiCadTextItem->SetItalic( textCode.Font.Italic ); @@ -2704,30 +2704,32 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT { // Spin style not used. All text justifications are permitted. However, only orientations // of 0 deg or 90 deg are supported - double angleDeciDeg = NormalizeAnglePos( aKiCadTextItem->GetTextAngle().AsTenthsOfADegree() ); - int quadrant = KiROUND( angleDeciDeg / 900.0 ); + EDA_ANGLE angle = aKiCadTextItem->GetTextAngle(); + angle.Normalize(); + + int quadrant = KiROUND( angle.AsDegrees() / 90.0 ); quadrant %= 4; switch( quadrant ) { case 0: - angleDeciDeg = 0; + angle = ANGLE_HORIZONTAL; break; case 1: - angleDeciDeg = 900; + angle = ANGLE_VERTICAL; break; case 2: - angleDeciDeg = 0; + angle = ANGLE_HORIZONTAL; textAlignment = rotate180( textAlignment ); break; case 3: - angleDeciDeg = 900; + angle = ANGLE_VERTICAL; textAlignment = rotate180( textAlignment ); break; default: wxFAIL_MSG( "Unknown Quadrant" ); } - aKiCadTextItem->SetTextAngle( angleDeciDeg ); + aKiCadTextItem->SetTextAngle( angle ); setAlignment( aKiCadTextItem, textAlignment ); return; } diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp index 7998939f41..ae58da78dc 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp @@ -255,13 +255,13 @@ static void eagleToKicadAlignment( EDA_TEXT* aText, int aEagleAlignment, int aRe if( aRelDegress == 90 ) { - aText->SetTextAngle( 900 ); + aText->SetTextAngle( ANGLE_VERTICAL ); } else if( aRelDegress == 180 ) align = -align; else if( aRelDegress == 270 ) { - aText->SetTextAngle( 900 ); + aText->SetTextAngle( ANGLE_VERTICAL ); align = -align; } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index d481991217..47cbd06652 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -764,7 +764,7 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr& aSymbol case T_at: field->SetPosition( parseXY() ); - field->SetTextAngle( static_cast( parseDouble( "text angle" ) * 10.0 ) ); + field->SetTextAngle( EDA_ANGLE( parseDouble( "text angle" ), DEGREES_T ) ); NeedRIGHT(); break; @@ -1496,7 +1496,8 @@ LIB_TEXT* SCH_SEXPR_PARSER::parseText() { case T_at: text->SetPosition( parseXY() ); - text->SetTextAngle( parseDouble( "text angle" ) ); + // Yes, LIB_TEXT is really decidegrees even though all the others are degrees. :( + text->SetTextAngle( EDA_ANGLE( parseDouble( "text angle" ), TENTHS_OF_A_DEGREE_T ) ); NeedRIGHT(); break; @@ -1723,7 +1724,7 @@ SCH_FIELD* SCH_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent ) case T_at: field->SetPosition( parseXY() ); - field->SetTextAngle( static_cast( parseDouble( "text angle" ) * 10.0 ) ); + field->SetTextAngle( EDA_ANGLE( parseDouble( "text angle" ), DEGREES_T ) ); NeedRIGHT(); break; diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 55d8a0c54d..a0e2d5758f 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -1421,17 +1421,6 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) { wxCHECK_RET( aText != nullptr && m_out != nullptr, "" ); - double angle; - - switch( aText->GetLabelSpinStyle() ) - { - case LABEL_SPIN_STYLE::RIGHT: angle = 0.0; break; - case LABEL_SPIN_STYLE::UP: angle = 90.0; break; - case LABEL_SPIN_STYLE::LEFT: angle = 180.0; break; - case LABEL_SPIN_STYLE::BOTTOM: angle = 270.0; break; - default: wxFAIL; angle = 0.0; break; - } - m_out->Print( aNestLevel, "(%s %s", getTextTypeToken( aText->Type() ), m_out->Quotew( aText->GetText() ).c_str() ); @@ -1456,7 +1445,7 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) m_out->Print( 0, " (at %s %s %s)", FormatInternalUnits( aText->GetPosition().x ).c_str(), FormatInternalUnits( aText->GetPosition().y ).c_str(), - FormatAngle( angle * 10.0 ).c_str() ); + FormatAngle( aText->GetTextAngle().AsTenthsOfADegree() ).c_str() ); } else { diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index ae5f83ffb1..d0fe6cf50f 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -3386,8 +3386,9 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr& aSymbo wxCHECK_MSG( strCompare( "T", line, &line ), nullptr, "Invalid LIB_TEXT definition" ); LIB_TEXT* text = new LIB_TEXT( aSymbol.get() ); + double angleInTenths = parseInt( aReader, line, &line ); - text->SetTextAngle( (double) parseInt( aReader, line, &line ) ); + text->SetTextAngle( EDA_ANGLE( angleInTenths, TENTHS_OF_A_DEGREE_T ) ); VECTOR2I center; diff --git a/include/array_options.h b/include/array_options.h index 4d64732dc9..12c3d45c7f 100644 --- a/include/array_options.h +++ b/include/array_options.h @@ -25,7 +25,7 @@ #define PCBNEW_ARRAY_OPTIONS__H #include - +#include #include /** @@ -57,8 +57,8 @@ public: */ struct TRANSFORM { - VECTOR2I m_offset; - double m_rotation; // in degrees + VECTOR2I m_offset; + EDA_ANGLE m_rotation; }; /** @@ -177,7 +177,7 @@ struct ARRAY_CIRCULAR_OPTIONS : public ARRAY_OPTIONS ARRAY_CIRCULAR_OPTIONS() : ARRAY_OPTIONS( ARRAY_CIRCULAR ), m_nPts( 0 ), - m_angle( 0.0f ), + m_angle( ANGLE_0 ), m_rotateItems( false ) { } @@ -185,7 +185,7 @@ struct ARRAY_CIRCULAR_OPTIONS : public ARRAY_OPTIONS /// number of point in the array long m_nPts; /// angle between points, or 0 for each point separated by this value (decideg) - double m_angle; + EDA_ANGLE m_angle; VECTOR2I m_centre; bool m_rotateItems; ARRAY_AXIS m_axis; diff --git a/include/drawing_sheet/ds_draw_item.h b/include/drawing_sheet/ds_draw_item.h index b375e6c764..f8e138f651 100644 --- a/include/drawing_sheet/ds_draw_item.h +++ b/include/drawing_sheet/ds_draw_item.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2014 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 @@ -318,8 +318,6 @@ public: void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override; - void SetTextAngle( double aAngle ) override; - VECTOR2I GetPosition() const override { return GetTextPos(); } void SetPosition( const VECTOR2I& aPos ) override { SetTextPos( aPos ); } diff --git a/include/eda_text.h b/include/eda_text.h index 93a19d1de1..25ea5bacae 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -119,14 +119,6 @@ public: */ int GetEffectiveTextPenWidth( int aDefaultWidth = 0 ) const; - virtual void SetTextAngle( double aAngleInTenthsOfADegree ) - { - // Higher level classes may be more restrictive than this by overloading - // SetTextAngle() or merely calling EDA_TEXT::SetTextAngle() after clamping - // aAngle before calling this lowest inline accessor. - SetTextAngle( EDA_ANGLE( aAngleInTenthsOfADegree, TENTHS_OF_A_DEGREE_T ) ); - } - virtual void SetTextAngle( const EDA_ANGLE& aAngle ); const EDA_ANGLE& GetTextAngle() const { return m_attributes.m_Angle; } diff --git a/pcbnew/array_creator.cpp b/pcbnew/array_creator.cpp index c209319371..ffdaab199d 100644 --- a/pcbnew/array_creator.cpp +++ b/pcbnew/array_creator.cpp @@ -45,7 +45,7 @@ static void TransformItem( const ARRAY_OPTIONS& aArrOpts, int aIndex, BOARD_ITEM const ARRAY_OPTIONS::TRANSFORM transform = aArrOpts.GetTransform( aIndex, aItem.GetPosition() ); aItem.Move( (wxPoint) transform.m_offset ); - aItem.Rotate( aItem.GetPosition(), EDA_ANGLE( transform.m_rotation, DEGREES_T ) ); + aItem.Rotate( aItem.GetPosition(), transform.m_rotation ); } diff --git a/pcbnew/dialogs/dialog_create_array.cpp b/pcbnew/dialogs/dialog_create_array.cpp index 986588ff74..7025c37b20 100644 --- a/pcbnew/dialogs/dialog_create_array.cpp +++ b/pcbnew/dialogs/dialog_create_array.cpp @@ -333,8 +333,8 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() bool ok = true; // ints - ok = ok && validateLongEntry(*m_entryNx, newGrid->m_nx, _("horizontal count"), errors); - ok = ok && validateLongEntry(*m_entryNy, newGrid->m_ny, _("vertical count"), errors); + ok &= validateLongEntry(*m_entryNx, newGrid->m_nx, _("horizontal count"), errors); + ok &= validateLongEntry(*m_entryNy, newGrid->m_ny, _("vertical count"), errors); newGrid->m_delta.x = m_hSpacing.GetValue(); newGrid->m_delta.y = m_vSpacing.GetValue(); @@ -342,7 +342,7 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() newGrid->m_offset.x = m_hOffset.GetValue(); newGrid->m_offset.y = m_vOffset.GetValue(); - ok = ok && validateLongEntry(*m_entryStagger, newGrid->m_stagger, _("stagger"), errors); + ok &= validateLongEntry(*m_entryStagger, newGrid->m_stagger, _("stagger"), errors); newGrid->m_stagger_rows = m_radioBoxGridStaggerType->GetSelection() == 0; @@ -361,18 +361,19 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() // validate from the input fields bool numOk = validateAxisOptions( *m_entryGridPriNumberingOffset, - *m_choicePriAxisNumbering, *m_entryGridPriNumberingStep, - newGrid->m_pri_axis, errors ); + *m_choicePriAxisNumbering, + *m_entryGridPriNumberingStep, + newGrid->m_pri_axis, errors ); if( newGrid->m_2dArrayNumbering ) { - numOk = validateAxisOptions( *m_entryGridSecNumberingOffset, - *m_choiceSecAxisNumbering, *m_entryGridSecNumberingStep, - newGrid->m_sec_axis, errors ) - && numOk; + numOk &= validateAxisOptions( *m_entryGridSecNumberingOffset, + *m_choiceSecAxisNumbering, + *m_entryGridSecNumberingStep, + newGrid->m_sec_axis, errors ); } - ok = ok && numOk; + ok &= numOk; } else { @@ -389,15 +390,15 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() } else if( page == m_circularPanel ) { - auto newCirc = std::make_unique(); - bool ok = true; + auto newCirc = std::make_unique(); + bool ok = true; + double angle = DoubleValueFromString( EDA_UNITS::UNSCALED, m_entryCircAngle->GetValue() ); newCirc->m_centre.x = m_hCentre.GetValue(); newCirc->m_centre.y = m_vCentre.GetValue(); - newCirc->m_angle = DoubleValueFromString( EDA_UNITS::DEGREES, - m_entryCircAngle->GetValue() ); + newCirc->m_angle = EDA_ANGLE( angle, DEGREES_T ); - ok = ok && validateLongEntry(*m_entryCircCount, newCirc->m_nPts, _("point count"), errors); + ok = validateLongEntry(*m_entryCircCount, newCirc->m_nPts, _("point count"), errors); newCirc->m_rotateItems = m_entryRotateItemsCb->GetValue(); newCirc->SetShouldNumber( m_isFootprintEditor ); @@ -408,9 +409,8 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() if( newCirc->GetNumberingStartIsSpecified() ) { - ok = ok - && validateAxisOptions( *m_entryCircNumberingStart, *m_choiceCircNumbering, - *m_entryCircNumberingStep, newCirc->m_axis, errors ); + ok &= validateAxisOptions( *m_entryCircNumberingStart, *m_choiceCircNumbering, + *m_entryCircNumberingStep, newCirc->m_axis, errors ); } else { diff --git a/pcbnew/dialogs/dialog_dimension_properties.cpp b/pcbnew/dialogs/dialog_dimension_properties.cpp index ac0bdf591f..0fdda618ba 100644 --- a/pcbnew/dialogs/dialog_dimension_properties.cpp +++ b/pcbnew/dialogs/dialog_dimension_properties.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Jon Evans - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 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 as published by the @@ -417,7 +417,7 @@ void DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog( PCB_DIMENSION_BASE* aTarget->SetKeepTextAligned( m_cbKeepAligned->GetValue() ); - text.SetTextAngle( m_orientation.GetDoubleValue() ); + text.SetTextAngle( EDA_ANGLE( m_orientation.GetDoubleValue(), TENTHS_OF_A_DEGREE_T ) ); text.SetTextWidth( m_textWidth.GetValue() ); text.SetTextHeight( m_textHeight.GetValue() ); text.SetTextThickness( m_textThickness.GetValue() ); diff --git a/pcbnew/dialogs/dialog_text_properties.cpp b/pcbnew/dialogs/dialog_text_properties.cpp index d1e30b67db..f3b6cd175d 100644 --- a/pcbnew/dialogs/dialog_text_properties.cpp +++ b/pcbnew/dialogs/dialog_text_properties.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004-2018 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 2010-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2010-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 @@ -419,7 +419,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_edaText->SetTextThickness( maxPenWidth ); } - m_edaText->SetTextAngle( m_orientation.GetDoubleValue() ); + m_edaText->SetTextAngle( EDA_ANGLE( m_orientation.GetDoubleValue(), TENTHS_OF_A_DEGREE_T ) ); m_edaText->SetVisible( m_Visible->GetValue() ); diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index 8a6b36bd6a..8ae0f0daf2 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -72,18 +72,6 @@ FP_TEXT::~FP_TEXT() } -void FP_TEXT::SetTextAngle( double aAngle ) -{ - EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) ); -} - - -void FP_TEXT::SetTextAngle( const EDA_ANGLE& aAngle ) -{ - EDA_TEXT::SetTextAngle( aAngle ); -} - - bool FP_TEXT::TextHitTest( const VECTOR2I& aPoint, int aAccuracy ) const { EDA_RECT rect = GetTextBox(); diff --git a/pcbnew/fp_text_grid_table.cpp b/pcbnew/fp_text_grid_table.cpp index 8f8ac76c5f..25229de653 100644 --- a/pcbnew/fp_text_grid_table.cpp +++ b/pcbnew/fp_text_grid_table.cpp @@ -284,7 +284,8 @@ void FP_TEXT_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue ) break; case FPT_ORIENTATION: - text.SetTextAngle( DoubleValueFromString( EDA_UNITS::DEGREES, aValue ) ); + text.SetTextAngle( EDA_ANGLE( DoubleValueFromString( EDA_UNITS::UNSCALED, aValue ), + DEGREES_T ) ); text.SetDrawCoord(); break; diff --git a/pcbnew/import_gfx/graphics_importer_pcbnew.cpp b/pcbnew/import_gfx/graphics_importer_pcbnew.cpp index 7ccf0af4dc..54f2d9fa3d 100644 --- a/pcbnew/import_gfx/graphics_importer_pcbnew.cpp +++ b/pcbnew/import_gfx/graphics_importer_pcbnew.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2016 CERN * @author Maciej Suminski - * Copyright (C) 2018 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 @@ -155,7 +155,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddText( const VECTOR2D& aOrigin, const wxString& boardItem->SetLayer( GetLayer() ); textItem->SetTextThickness( MapLineWidth( aThickness ) ); textItem->SetTextPos( MapCoordinate( aOrigin ) ); - textItem->SetTextAngle( aOrientation * 10.0 ); // Pcbnew uses the decidegree + textItem->SetTextAngle( EDA_ANGLE( aOrientation, DEGREES_T ) ); // Pcbnew uses the decidegree textItem->SetTextWidth( aWidth * ImportScalingFactor() ); textItem->SetTextHeight( aHeight * ImportScalingFactor() ); textItem->SetVertJustify( aVJustify ); diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index 2191c25c3e..7e255d14b6 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -679,12 +679,11 @@ void PCB_DIM_ALIGNED::updateText() if( m_keepTextAligned ) { - double textAngle = 3600 - RAD2DECIDEG( crossbarCenter.Angle() ); + EDA_ANGLE textAngle = FULL_CIRCLE - EDA_ANGLE( crossbarCenter.Angle(), RADIANS_T ); + textAngle.Normalize(); - NORMALIZE_ANGLE_POS( textAngle ); - - if( textAngle > 900 && textAngle <= 2700 ) - textAngle -= 1800; + if( textAngle > ANGLE_90 && textAngle <= ANGLE_270 ) + textAngle -= ANGLE_180; m_text.SetTextAngle( textAngle ); } @@ -859,14 +858,10 @@ void PCB_DIM_ORTHOGONAL::updateText() if( m_keepTextAligned ) { - double textAngle; - if( abs( crossbarCenter.x ) > abs( crossbarCenter.y ) ) - textAngle = 0; + m_text.SetTextAngle( ANGLE_HORIZONTAL ); else - textAngle = 900; - - m_text.SetTextAngle( textAngle ); + m_text.SetTextAngle( ANGLE_VERTICAL ); } PCB_DIMENSION_BASE::updateText(); @@ -1124,16 +1119,18 @@ void PCB_DIM_RADIAL::updateText() { if( m_keepTextAligned ) { - VECTOR2I textLine( Text().GetPosition() - GetKnee() ); - double textAngle = 3600 - RAD2DECIDEG( textLine.Angle() ); + VECTOR2I textLine( Text().GetPosition() - GetKnee() ); + EDA_ANGLE textAngle = FULL_CIRCLE - EDA_ANGLE( textLine.Angle(), RADIANS_T ); - NORMALIZE_ANGLE_POS( textAngle ); + textAngle.Normalize(); - if( textAngle > 900 && textAngle <= 2700 ) - textAngle -= 1800; + if( textAngle > ANGLE_90 && textAngle <= ANGLE_270 ) + textAngle -= ANGLE_180; // Round to nearest degree - m_text.SetTextAngle( KiROUND( textAngle / 10 ) * 10 ); + textAngle = EDA_ANGLE( KiROUND( textAngle.AsDegrees() ), DEGREES_T ); + + m_text.SetTextAngle( textAngle ); } PCB_DIMENSION_BASE::updateText(); diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index 8540fb7ec2..bf1085242d 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -103,18 +103,6 @@ wxString PCB_TEXT::GetShownText( int aDepth ) const } -void PCB_TEXT::SetTextAngle( double aAngle ) -{ - EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) ); -} - - -void PCB_TEXT::SetTextAngle( const EDA_ANGLE& aAngle ) -{ - EDA_TEXT::SetTextAngle( aAngle ); -} - - void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { EDA_UNITS units = aFrame->GetUserUnits(); @@ -187,7 +175,7 @@ void PCB_TEXT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) else { SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) ); - SetTextAngle( 1800 - GetTextAngle().AsTenthsOfADegree() ); + SetTextAngle( ANGLE_180 - GetTextAngle() ); } SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); diff --git a/pcbnew/pcb_text.h b/pcbnew/pcb_text.h index 244d34080e..7670eafc94 100644 --- a/pcbnew/pcb_text.h +++ b/pcbnew/pcb_text.h @@ -88,9 +88,6 @@ public: EDA_TEXT::Offset( aMoveVector ); } - void SetTextAngle( double aAngle ) override; - void SetTextAngle( const EDA_ANGLE& aAngle ); - void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override; void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override; diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index 52a99265f3..c32e72d216 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -2713,7 +2713,7 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader, } itm->SetPosition( elem.position ); - tx->SetTextAngle( elem.rotation * 10. ); + tx->SetTextAngle( EDA_ANGLE( elem.rotation, DEGREES_T ) ); if( elem.component != ALTIUM_COMPONENT_NONE ) { diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp index a682510e2f..43f6247379 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp @@ -2513,8 +2513,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( aContainer->Add( txt ); txt->SetText( aCadstarText.Text ); - VECTOR2I rotatedTextPos = getKiCadPoint( aCadstarText.Position ); - RotatePoint( rotatedTextPos, aTransformCentre, aRotationAngle ); + EDA_ANGLE rotationAngle( aRotationAngle, TENTHS_OF_A_DEGREE_T ); + VECTOR2I rotatedTextPos = getKiCadPoint( aCadstarText.Position ); + RotatePoint( rotatedTextPos, aTransformCentre, rotationAngle ); rotatedTextPos.x = KiROUND( (double) ( rotatedTextPos.x - aTransformCentre.x ) * aScalingFactor ); rotatedTextPos.y = @@ -2523,7 +2524,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( txt->SetTextPos( rotatedTextPos ); txt->SetPosition( rotatedTextPos ); - txt->SetTextAngle( getAngleTenthDegree( aCadstarText.OrientAngle ) + aRotationAngle ); + txt->SetTextAngle( getAngle( aCadstarText.OrientAngle ) + rotationAngle ); txt->SetMirrored( aCadstarText.Mirror ); diff --git a/pcbnew/plugins/eagle/eagle_plugin.cpp b/pcbnew/plugins/eagle/eagle_plugin.cpp index 321899a792..816c671a3e 100644 --- a/pcbnew/plugins/eagle/eagle_plugin.cpp +++ b/pcbnew/plugins/eagle/eagle_plugin.cpp @@ -768,7 +768,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) if( degrees == 90 || t.rot->spin ) { - pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 ); + pcbtxt->SetTextAngle( EDA_ANGLE( sign * t.rot->degrees, DEGREES_T ) ); } else if( degrees == 180 ) { @@ -776,7 +776,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) } else if( degrees == 270 ) { - pcbtxt->SetTextAngle( sign * 90 * 10 ); + pcbtxt->SetTextAngle( EDA_ANGLE( sign * 90, DEGREES_T ) ); align = -align; } else @@ -785,21 +785,21 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) // placement right. if( ( degrees > 0 ) && ( degrees < 90 ) ) { - pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 ); + pcbtxt->SetTextAngle( EDA_ANGLE( sign * t.rot->degrees, DEGREES_T ) ); } else if( ( degrees > 90 ) && ( degrees < 180 ) ) { - pcbtxt->SetTextAngle( sign * ( t.rot->degrees + 180 ) * 10 ); + pcbtxt->SetTextAngle( EDA_ANGLE( sign * ( t.rot->degrees + 180 ), DEGREES_T ) ); align = ETEXT::TOP_RIGHT; } else if( ( degrees > 180 ) && ( degrees < 270 ) ) { - pcbtxt->SetTextAngle( sign * ( t.rot->degrees - 180 ) * 10 ); + pcbtxt->SetTextAngle( EDA_ANGLE( sign * ( t.rot->degrees - 180 ), DEGREES_T ) ); align = ETEXT::TOP_RIGHT; } else if( ( degrees > 270 ) && ( degrees < 360 ) ) { - pcbtxt->SetTextAngle( sign * t.rot->degrees * 10 ); + pcbtxt->SetTextAngle( EDA_ANGLE( sign * t.rot->degrees, DEGREES_T ) ); align = ETEXT::BOTTOM_LEFT; } } @@ -1607,24 +1607,24 @@ void EAGLE_PLUGIN::orientFPText( FOOTPRINT* aFootprint, const EELEMENT& e, FP_TE if( degrees == 90 || degrees == 0 || spin ) { orient = degrees - aFootprint->GetOrientation().AsDegrees(); - aFPText->SetTextAngle( sign * orient * 10 ); + aFPText->SetTextAngle( EDA_ANGLE( sign * orient, DEGREES_T ) ); } else if( degrees == 180 ) { orient = 0 - aFootprint->GetOrientation().AsDegrees(); - aFPText->SetTextAngle( sign * orient * 10 ); + aFPText->SetTextAngle( EDA_ANGLE( sign * orient, DEGREES_T ) ); align = -align; } else if( degrees == 270 ) { orient = 90 - aFootprint->GetOrientation().AsDegrees(); align = -align; - aFPText->SetTextAngle( sign * orient * 10 ); + aFPText->SetTextAngle( EDA_ANGLE( sign * orient, DEGREES_T ) ); } else { orient = 90 - degrees - aFootprint->GetOrientation().AsDegrees(); - aFPText->SetTextAngle( sign * orient * 10 ); + aFPText->SetTextAngle( EDA_ANGLE( sign * orient, DEGREES_T ) ); } switch( align ) @@ -1966,7 +1966,7 @@ void EAGLE_PLUGIN::packageText( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const if( degrees == 90 || t.rot->spin ) { - txt->SetTextAngle( sign * degrees * 10 ); + txt->SetTextAngle( EDA_ANGLE( sign * degrees, DEGREES_T ) ); } else if( degrees == 180 ) { @@ -1975,7 +1975,7 @@ void EAGLE_PLUGIN::packageText( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const else if( degrees == 270 ) { align = ETEXT::TOP_RIGHT; - txt->SetTextAngle( sign * 90 * 10 ); + txt->SetTextAngle( EDA_ANGLE( sign * 90, DEGREES_T ) ); } } diff --git a/pcbnew/plugins/geda/gpcb_plugin.cpp b/pcbnew/plugins/geda/gpcb_plugin.cpp index 7aa8d39c3e..47f8df95fa 100644 --- a/pcbnew/plugins/geda/gpcb_plugin.cpp +++ b/pcbnew/plugins/geda/gpcb_plugin.cpp @@ -393,7 +393,7 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader ) } int orientation = parseInt( parameters[paramCnt-4], 1.0 ); - footprint->Reference().SetTextAngle(( orientation % 2) ? 900 : 0 ); + footprint->Reference().SetTextAngle( ( orientation % 2) ? ANGLE_VERTICAL : ANGLE_HORIZONTAL ); // Calculate size: default height is 40 mils, width 30 mil. // real size is: default * ibuf[idx+3] / 100 (size in gpcb is given in percent of default size diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 292ffdce66..c285f0e517 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -2831,7 +2831,7 @@ PCB_TEXT* PCB_PARSER::parsePCB_TEXT() if( token == T_NUMBER ) { - text->SetTextAngle( parseAngle() ); + text->SetTextAngle( EDA_ANGLE( parseAngle(), TENTHS_OF_A_DEGREE_T ) ); NeedRIGHT(); } else if( token != T_RIGHT ) @@ -3735,7 +3735,7 @@ FP_TEXT* PCB_PARSER::parseFP_TEXT() if( CurTok() == T_NUMBER ) { - text->SetTextAngle( parseAngle() ); + text->SetTextAngle( EDA_ANGLE( parseAngle(), TENTHS_OF_A_DEGREE_T ) ); NextTok(); } diff --git a/pcbnew/plugins/legacy/legacy_plugin.cpp b/pcbnew/plugins/legacy/legacy_plugin.cpp index 5a8589dfe3..5ebc957de2 100644 --- a/pcbnew/plugins/legacy/legacy_plugin.cpp +++ b/pcbnew/plugins/legacy/legacy_plugin.cpp @@ -2007,14 +2007,15 @@ void LEGACY_PLUGIN::loadPCB_TEXT() } else if( TESTLINE( "Po" ) ) { - wxSize size; + wxSize size; + BIU pos_x = biuParse( line + SZ( "Po" ), &data ); + BIU pos_y = biuParse( data, &data ); - BIU pos_x = biuParse( line + SZ( "Po" ), &data ); - BIU pos_y = biuParse( data, &data ); - size.x = biuParse( data, &data ); - size.y = biuParse( data, &data ); - BIU thickn = biuParse( data, &data ); - double angle = degParse( data ); + size.x = biuParse( data, &data ); + size.y = biuParse( data, &data ); + + BIU thickn = biuParse( data, &data ); + EDA_ANGLE angle = EDA_ANGLE( degParse( data ), TENTHS_OF_A_DEGREE_T ); pcbtxt->SetTextSize( size ); pcbtxt->SetTextThickness( thickn ); @@ -2642,13 +2643,13 @@ void LEGACY_PLUGIN::loadDIMENSION() } else if( TESTLINE( "Po" ) ) { - BIU pos_x = biuParse( line + SZ( "Po" ), &data ); - BIU pos_y = biuParse( data, &data ); - BIU width = biuParse( data, &data ); - BIU height = biuParse( data, &data ); - BIU thickn = biuParse( data, &data ); - double orient = degParse( data, &data ); - char* mirror = strtok_r( (char*) data, delims, (char**) &data ); + BIU pos_x = biuParse( line + SZ( "Po" ), &data ); + BIU pos_y = biuParse( data, &data ); + BIU width = biuParse( data, &data ); + BIU height = biuParse( data, &data ); + BIU thickn = biuParse( data, &data ); + EDA_ANGLE orient = EDA_ANGLE( degParse( data, &data ), TENTHS_OF_A_DEGREE_T ); + char* mirror = strtok_r( (char*) data, delims, (char**) &data ); dim->Text().SetTextPos( VECTOR2I( pos_x, pos_y ) ); dim->Text().SetTextSize( wxSize( width, height ) ); diff --git a/pcbnew/plugins/pcad/pcb_footprint.cpp b/pcbnew/plugins/pcad/pcb_footprint.cpp index 4561fb6777..abcbd47d70 100644 --- a/pcbnew/plugins/pcad/pcb_footprint.cpp +++ b/pcbnew/plugins/pcad/pcb_footprint.cpp @@ -530,7 +530,7 @@ void PCB_FOOTPRINT::AddToBoard() SetTextSizeFromStrokeFontHeight( ref_text, m_name.textHeight ); r = m_name.textRotation - m_rotation; - ref_text->SetTextAngle( r ); + ref_text->SetTextAngle( EDA_ANGLE( r, TENTHS_OF_A_DEGREE_T ) ); ref_text->SetKeepUpright( false ); ref_text->SetItalic( m_name.isItalic ); @@ -558,7 +558,7 @@ void PCB_FOOTPRINT::AddToBoard() SetTextSizeFromStrokeFontHeight( val_text, m_Value.textHeight ); r = m_Value.textRotation - m_rotation; - val_text->SetTextAngle( r ); + val_text->SetTextAngle( EDA_ANGLE( r, TENTHS_OF_A_DEGREE_T ) ); val_text->SetKeepUpright( false ); val_text->SetItalic( m_Value.isItalic ); diff --git a/pcbnew/plugins/pcad/pcb_text.cpp b/pcbnew/plugins/pcad/pcb_text.cpp index f195a60e6b..4cb775ec4a 100644 --- a/pcbnew/plugins/pcad/pcb_text.cpp +++ b/pcbnew/plugins/pcad/pcb_text.cpp @@ -122,9 +122,9 @@ void PCB_TEXT::AddToBoard() pcbtxt->SetMirrored( m_name.mirror ); if( pcbtxt->IsMirrored() ) - pcbtxt->SetTextAngle( 3600.0 - m_name.textRotation ); + pcbtxt->SetTextAngle( ANGLE_360 - EDA_ANGLE( m_name.textRotation, TENTHS_OF_A_DEGREE_T ) ); else - pcbtxt->SetTextAngle( m_name.textRotation ); + pcbtxt->SetTextAngle( EDA_ANGLE( m_name.textRotation, TENTHS_OF_A_DEGREE_T ) ); pcbtxt->SetLayer( m_KiCadLayer ); } diff --git a/qa/common/test_array_options.cpp b/qa/common/test_array_options.cpp index fb663c59bc..6b59e01115 100644 --- a/qa/common/test_array_options.cpp +++ b/qa/common/test_array_options.cpp @@ -41,7 +41,7 @@ */ std::ostream& operator<<( std::ostream& os, const ARRAY_OPTIONS::TRANSFORM& aObj ) { - os << "TRANSFORM[ " << aObj.m_offset << " r " << aObj.m_rotation << "deg" + os << "TRANSFORM[ " << aObj.m_offset << " r " << aObj.m_rotation.AsDegrees() << "deg" << " ]"; return os; } @@ -53,7 +53,8 @@ std::ostream& operator<<( std::ostream& os, const ARRAY_OPTIONS::TRANSFORM& aObj bool TransformIsClose( const ARRAY_OPTIONS::TRANSFORM& aL, const ARRAY_OPTIONS::TRANSFORM& aR ) { return KI_TEST::IsVecWithinTol( aL.m_offset, aR.m_offset, 1 ) - && KI_TEST::IsWithin( aL.m_rotation, aR.m_rotation, 0.001 ); + && KI_TEST::IsWithin( aL.m_rotation.AsDegrees(), + aR.m_rotation.AsDegrees(), 0.001 ); } @@ -129,12 +130,12 @@ static const std::vector grid_geom_cases = { }, { 0, 0 }, { - { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 0 ) }, 0 }, - { { Millimeter2iu( 0 ), Millimeter2iu( 2 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 2 ) }, 0 }, - { { Millimeter2iu( 0 ), Millimeter2iu( 4 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 4 ) }, 0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 2 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 2 ) }, ANGLE_0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 4 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 4 ) }, ANGLE_0 }, }, }, { @@ -152,12 +153,12 @@ static const std::vector grid_geom_cases = { { 0, 0 }, { // add the offsets for each positions - { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 0.2 ) }, 0 }, - { { Millimeter2iu( 0.1 ), Millimeter2iu( 2 ) }, 0 }, - { { Millimeter2iu( 2.1 ), Millimeter2iu( 2.2 ) }, 0 }, - { { Millimeter2iu( 0.2 ), Millimeter2iu( 4.0 ) }, 0 }, - { { Millimeter2iu( 2.2 ), Millimeter2iu( 4.2 ) }, 0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 0.2 ) }, ANGLE_0 }, + { { Millimeter2iu( 0.1 ), Millimeter2iu( 2 ) }, ANGLE_0 }, + { { Millimeter2iu( 2.1 ), Millimeter2iu( 2.2 ) }, ANGLE_0 }, + { { Millimeter2iu( 0.2 ), Millimeter2iu( 4.0 ) }, ANGLE_0 }, + { { Millimeter2iu( 2.2 ), Millimeter2iu( 4.2 ) }, ANGLE_0 }, }, }, { @@ -175,12 +176,12 @@ static const std::vector grid_geom_cases = { { 0, 0 }, { // add the offsets for each positions - { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, 0 }, - { { Millimeter2iu( 3 ), Millimeter2iu( 0 ) }, 0 }, - { { Millimeter2iu( 1 ), Millimeter2iu( 2 ) }, 0 }, - { { Millimeter2iu( 4 ), Millimeter2iu( 2 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 4 ) }, 0 }, - { { Millimeter2iu( 5 ), Millimeter2iu( 4 ) }, 0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( 3 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( 1 ), Millimeter2iu( 2 ) }, ANGLE_0 }, + { { Millimeter2iu( 4 ), Millimeter2iu( 2 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 4 ) }, ANGLE_0 }, + { { Millimeter2iu( 5 ), Millimeter2iu( 4 ) }, ANGLE_0 }, }, }, { @@ -198,12 +199,12 @@ static const std::vector grid_geom_cases = { { 0, 0 }, { // add the offsets for each positions - { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, 0 }, - { { Millimeter2iu( 3 ), Millimeter2iu( 1 ) }, 0 }, - { { Millimeter2iu( 0 ), Millimeter2iu( 2 ) }, 0 }, - { { Millimeter2iu( 3 ), Millimeter2iu( 3 ) }, 0 }, - { { Millimeter2iu( 0 ), Millimeter2iu( 4 ) }, 0 }, - { { Millimeter2iu( 3 ), Millimeter2iu( 5 ) }, 0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( 3 ), Millimeter2iu( 1 ) }, ANGLE_0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 2 ) }, ANGLE_0 }, + { { Millimeter2iu( 3 ), Millimeter2iu( 3 ) }, ANGLE_0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 4 ) }, ANGLE_0 }, + { { Millimeter2iu( 3 ), Millimeter2iu( 5 ) }, ANGLE_0 }, }, }, { @@ -220,12 +221,12 @@ static const std::vector grid_geom_cases = { }, { 0, 0 }, { - { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 0 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 2 ) }, 0 }, - { { Millimeter2iu( 0 ), Millimeter2iu( 2 ) }, 0 }, - { { Millimeter2iu( 0 ), Millimeter2iu( 4 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 4 ) }, 0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 2 ) }, ANGLE_0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 2 ) }, ANGLE_0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 4 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 4 ) }, ANGLE_0 }, }, }, { @@ -242,12 +243,12 @@ static const std::vector grid_geom_cases = { }, { 0, 0 }, { - { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, 0 }, - { { Millimeter2iu( 0 ), Millimeter2iu( 2 ) }, 0 }, - { { Millimeter2iu( 0 ), Millimeter2iu( 4 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 0 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 2 ) }, 0 }, - { { Millimeter2iu( 2 ), Millimeter2iu( 4 ) }, 0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 2 ) }, ANGLE_0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 4 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 2 ) }, ANGLE_0 }, + { { Millimeter2iu( 2 ), Millimeter2iu( 4 ) }, ANGLE_0 }, }, }, }; @@ -310,10 +311,10 @@ static const std::vector circ_geom_cases = { { Millimeter2iu( 10 ), 0 }, { // diamond shape - { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) } , 0 }, - { { Millimeter2iu( -10 ), Millimeter2iu( -10 ) } , 0 }, - { { Millimeter2iu( -20 ), Millimeter2iu( 0 ) } , 0 }, - { {Millimeter2iu( -10 ), Millimeter2iu( 10 ) } , 0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( -10 ), Millimeter2iu( -10 ) }, ANGLE_0 }, + { { Millimeter2iu( -20 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { {Millimeter2iu( -10 ), Millimeter2iu( 10 ) }, ANGLE_0 }, }, }, { @@ -326,10 +327,10 @@ static const std::vector circ_geom_cases = { }, { Millimeter2iu( 10 ), 0 }, { - { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) } , 0 }, - { { Millimeter2iu( -10 ), Millimeter2iu( -10 ) } , 90 }, - { { Millimeter2iu( -20 ), Millimeter2iu( 0 ) } , 180 }, - { {Millimeter2iu( -10 ), Millimeter2iu( 10 ) } , 270 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, ANGLE_0 }, + { { Millimeter2iu( -10 ), Millimeter2iu( -10 ) }, ANGLE_90 }, + { { Millimeter2iu( -20 ), Millimeter2iu( 0 ) }, ANGLE_180 }, + { {Millimeter2iu( -10 ), Millimeter2iu( 10 ) }, ANGLE_270 }, }, }, { @@ -342,10 +343,10 @@ static const std::vector circ_geom_cases = { }, { Millimeter2iu( 10 ), 0 }, { - { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) } , 0 }, + { { Millimeter2iu( 0 ), Millimeter2iu( 0 ) }, ANGLE_0 }, // 10 * [ 1-sin(45), sin(45) ] - { { Millimeter2iu( -2.9289321881 ), Millimeter2iu( -7.0710678118 ) } , 45 }, - { { Millimeter2iu( -10 ), Millimeter2iu( -10 ) } , 90 }, + { { Millimeter2iu( -2.9289321881 ), Millimeter2iu( -7.0710678118 ) }, ANGLE_45 }, + { { Millimeter2iu( -10 ), Millimeter2iu( -10 ) }, ANGLE_90 }, }, }, }; @@ -363,7 +364,7 @@ BOOST_AUTO_TEST_CASE( CircularGeometry ) ARRAY_CIRCULAR_OPTIONS grid_opts; grid_opts.m_nPts = c.m_geom.n; - grid_opts.m_angle = 10 * c.m_geom.angle_offset; + grid_opts.m_angle = EDA_ANGLE( c.m_geom.angle_offset, DEGREES_T ); grid_opts.m_centre = c.m_geom.centre; grid_opts.m_rotateItems = c.m_geom.rotate;