EDA_ANGLE: use constexpr for constant angles
Remove all statics in the class and instead use constexpr to ensure correct ordering
This commit is contained in:
parent
6ff3b0eb95
commit
079478f989
|
@ -2113,7 +2113,7 @@ void SCH_IO_ALTIUM::ParseEllipticalArc( const std::map<wxString, wxString>& aPro
|
|||
wxCHECK( currentScreen, /* void */ );
|
||||
|
||||
ELLIPSE<int> ellipse( elem.m_Center + m_sheetOffset, elem.m_Radius,
|
||||
KiROUND( elem.m_SecondaryRadius ), EDA_ANGLE::m_Angle0,
|
||||
KiROUND( elem.m_SecondaryRadius ), ANGLE_0,
|
||||
EDA_ANGLE( elem.m_StartAngle, DEGREES_T ),
|
||||
EDA_ANGLE( elem.m_EndAngle, DEGREES_T ) );
|
||||
std::vector<BEZIER<int>> beziers;
|
||||
|
@ -2164,7 +2164,7 @@ void SCH_IO_ALTIUM::ParseEllipticalArc( const std::map<wxString, wxString>& aPro
|
|||
}
|
||||
|
||||
ELLIPSE<int> ellipse( elem.m_Center, elem.m_Radius,
|
||||
KiROUND( elem.m_SecondaryRadius ), EDA_ANGLE::m_Angle0,
|
||||
KiROUND( elem.m_SecondaryRadius ), ANGLE_0,
|
||||
EDA_ANGLE( elem.m_StartAngle, DEGREES_T ),
|
||||
EDA_ANGLE( elem.m_EndAngle, DEGREES_T ) );
|
||||
std::vector<BEZIER<int>> beziers;
|
||||
|
@ -2224,7 +2224,7 @@ void SCH_IO_ALTIUM::ParseEllipse( const std::map<wxString, wxString>& aPropertie
|
|||
FILL_T fillMode = elem.IsSolid ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL;
|
||||
|
||||
ELLIPSE<int> ellipse( elem.Center + m_sheetOffset, elem.Radius,
|
||||
KiROUND( elem.SecondaryRadius ), EDA_ANGLE::m_Angle0 );
|
||||
KiROUND( elem.SecondaryRadius ), ANGLE_0 );
|
||||
|
||||
std::vector<BEZIER<int>> beziers;
|
||||
std::vector<VECTOR2I> polyPoints;
|
||||
|
@ -2288,7 +2288,7 @@ void SCH_IO_ALTIUM::ParseEllipse( const std::map<wxString, wxString>& aPropertie
|
|||
}
|
||||
|
||||
ELLIPSE<int> ellipse( elem.Center, elem.Radius, KiROUND( elem.SecondaryRadius ),
|
||||
EDA_ANGLE::m_Angle0 );
|
||||
ANGLE_0 );
|
||||
|
||||
std::vector<BEZIER<int>> beziers;
|
||||
std::vector<VECTOR2I> polyPoints;
|
||||
|
|
|
@ -60,6 +60,12 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an EDA_ANGLE in degrees
|
||||
* @param aAngleInDegrees
|
||||
*/
|
||||
constexpr EDA_ANGLE( double aAngleInDegrees ) : m_value(aAngleInDegrees) {}
|
||||
|
||||
explicit EDA_ANGLE( const VECTOR2D& aVector )
|
||||
{
|
||||
if( aVector.x == 0.0 && aVector.y == 0.0 )
|
||||
|
@ -332,14 +338,6 @@ public:
|
|||
private:
|
||||
double m_value; ///< value in degrees
|
||||
|
||||
public:
|
||||
static EDA_ANGLE m_Angle0;
|
||||
static EDA_ANGLE m_Angle45;
|
||||
static EDA_ANGLE m_Angle90;
|
||||
static EDA_ANGLE m_Angle135;
|
||||
static EDA_ANGLE m_Angle180;
|
||||
static EDA_ANGLE m_Angle270;
|
||||
static EDA_ANGLE m_Angle360;
|
||||
};
|
||||
|
||||
|
||||
|
@ -430,17 +428,17 @@ inline EDA_ANGLE abs( const EDA_ANGLE& aAngle )
|
|||
}
|
||||
|
||||
|
||||
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_HORIZONTAL{ 0 };
|
||||
static constexpr EDA_ANGLE ANGLE_VERTICAL{ 90 };
|
||||
static constexpr EDA_ANGLE FULL_CIRCLE{ 360 };
|
||||
|
||||
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_135 = EDA_ANGLE::m_Angle135;
|
||||
static constexpr EDA_ANGLE& ANGLE_180 = EDA_ANGLE::m_Angle180;
|
||||
static constexpr EDA_ANGLE& ANGLE_270 = EDA_ANGLE::m_Angle270;
|
||||
static constexpr EDA_ANGLE& ANGLE_360 = EDA_ANGLE::m_Angle360;
|
||||
static constexpr EDA_ANGLE ANGLE_0{ 0 };
|
||||
static constexpr EDA_ANGLE ANGLE_45{ 45 };
|
||||
static constexpr EDA_ANGLE ANGLE_90{ 90 };
|
||||
static constexpr EDA_ANGLE ANGLE_135{ 135 };
|
||||
static constexpr EDA_ANGLE ANGLE_180{ 180 };
|
||||
static constexpr EDA_ANGLE ANGLE_270{ 270 };
|
||||
static constexpr EDA_ANGLE ANGLE_360{ 360 };
|
||||
|
||||
|
||||
#endif // EDA_ANGLE_H
|
||||
|
|
|
@ -20,15 +20,6 @@
|
|||
#include <geometry/eda_angle.h>
|
||||
|
||||
|
||||
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_Angle135 = EDA_ANGLE( 135, 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
|
||||
{
|
||||
EDA_ANGLE inAngle( *this );
|
||||
|
|
|
@ -1195,7 +1195,7 @@ wxXmlNode* PCB_IO_IPC2581::generateBOMSection( wxXmlNode* aEcadNode )
|
|||
if( fp->GetLayer() != F_Cu )
|
||||
fp->Flip( fp->GetPosition(), false );
|
||||
|
||||
fp->SetOrientation( EDA_ANGLE::m_Angle0 );
|
||||
fp->SetOrientation( ANGLE_0 );
|
||||
|
||||
size_t hash = hash_fp_item( fp.get(), HASH_POS | REL_COORD );
|
||||
auto iter = m_footprint_dict.find( hash );
|
||||
|
@ -1579,7 +1579,7 @@ void PCB_IO_IPC2581::addPad( wxXmlNode* aContentNode, const PAD* aPad, PCB_LAYER
|
|||
|
||||
addPadStack( padNode, aPad );
|
||||
|
||||
if( aPad->GetOrientation() != EDA_ANGLE::m_Angle0 )
|
||||
if( aPad->GetOrientation() != ANGLE_0 )
|
||||
{
|
||||
wxXmlNode* xformNode = appendNode( padNode, "Xform" );
|
||||
xformNode->AddAttribute( "rotation",
|
||||
|
@ -1888,7 +1888,7 @@ wxXmlNode* PCB_IO_IPC2581::addPackage( wxXmlNode* aContentNode, FOOTPRINT* aFp )
|
|||
if( fp->GetLayer() != F_Cu )
|
||||
fp->Flip( fp->GetPosition(), false );
|
||||
|
||||
fp->SetOrientation( EDA_ANGLE::m_Angle0 );
|
||||
fp->SetOrientation( ANGLE_0 );
|
||||
|
||||
|
||||
size_t hash = hash_fp_item( fp.get(), HASH_POS | REL_COORD );
|
||||
|
@ -2146,7 +2146,7 @@ wxXmlNode* PCB_IO_IPC2581::addPackage( wxXmlNode* aContentNode, FOOTPRINT* aFp )
|
|||
else
|
||||
addAttribute( pinNode, "type", "SURFACE" );
|
||||
|
||||
if( pad->GetFPRelativeOrientation() != EDA_ANGLE::m_Angle0 )
|
||||
if( pad->GetFPRelativeOrientation() != ANGLE_0 )
|
||||
{
|
||||
wxXmlNode* xformNode = appendNode( pinNode, "Xform" );
|
||||
xformNode->AddAttribute(
|
||||
|
@ -2215,11 +2215,11 @@ void PCB_IO_IPC2581::generateComponents( wxXmlNode* aStepNode )
|
|||
else
|
||||
addAttribute( componentNode, "mountType", "OTHER" );
|
||||
|
||||
if( fp->GetOrientation() != EDA_ANGLE::m_Angle0 || fp->GetLayer() != F_Cu )
|
||||
if( fp->GetOrientation() != ANGLE_0 || fp->GetLayer() != F_Cu )
|
||||
{
|
||||
wxXmlNode* xformNode = appendNode( componentNode, "Xform" );
|
||||
|
||||
if( fp->GetOrientation() != EDA_ANGLE::m_Angle0 )
|
||||
if( fp->GetOrientation() != ANGLE_0 )
|
||||
addAttribute( xformNode, "rotation", floatVal( fp->GetOrientation().Normalize().AsDegrees() ) );
|
||||
|
||||
if( fp->GetLayer() != F_Cu )
|
||||
|
|
|
@ -68,10 +68,10 @@ BOOST_AUTO_TEST_CASE( TabCheck )
|
|||
wxString text2 = wxString::Format( c.second );
|
||||
|
||||
VECTOR2I output1 = font->GetTextAsGlyphs( &bbox, &glyphs, text1,
|
||||
VECTOR2I( 1000, 1000 ), VECTOR2I( 0, 0 ), EDA_ANGLE::m_Angle0, false,
|
||||
VECTOR2I( 1000, 1000 ), VECTOR2I( 0, 0 ), ANGLE_0, false,
|
||||
VECTOR2I( 0, 0 ), 0 );
|
||||
VECTOR2I output2 = font->GetTextAsGlyphs( &bbox, &glyphs, text2,
|
||||
VECTOR2I( 1000, 1000 ), VECTOR2I( 0, 0 ), EDA_ANGLE::m_Angle0, false,
|
||||
VECTOR2I( 1000, 1000 ), VECTOR2I( 0, 0 ), ANGLE_0, false,
|
||||
VECTOR2I( 0, 0 ), 0 );
|
||||
|
||||
BOOST_CHECK_MESSAGE( output1.x == output2.x, "Incorrect tab size for \n\t'" <<
|
||||
|
|
|
@ -94,4 +94,20 @@ BOOST_AUTO_TEST_CASE( Normalize )
|
|||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( ConstantAngles )
|
||||
{
|
||||
BOOST_CHECK_EQUAL( ANGLE_0.AsDegrees(), 0.0 );
|
||||
BOOST_CHECK_EQUAL( ANGLE_45.AsDegrees(), 45.0 );
|
||||
BOOST_CHECK_EQUAL( ANGLE_90.AsDegrees(), 90.0 );
|
||||
BOOST_CHECK_EQUAL( ANGLE_135.AsDegrees(), 135.0 );
|
||||
BOOST_CHECK_EQUAL( ANGLE_180.AsDegrees(), 180.0 );
|
||||
BOOST_CHECK_EQUAL( ANGLE_270.AsDegrees(), 270.0 );
|
||||
BOOST_CHECK_EQUAL( ANGLE_360.AsDegrees(), 360.0 );
|
||||
|
||||
BOOST_CHECK_EQUAL( ANGLE_HORIZONTAL.AsDegrees(), 0.0 );
|
||||
BOOST_CHECK_EQUAL( ANGLE_VERTICAL.AsDegrees(), 90.0 );
|
||||
BOOST_CHECK_EQUAL( FULL_CIRCLE.AsDegrees(), 360.0 );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
Loading…
Reference in New Issue