Move footprints to EDA_ANGLE.

This commit is contained in:
Jeff Young 2022-01-13 17:27:36 +00:00
parent 70ad554343
commit abd3f5bc2b
38 changed files with 171 additions and 174 deletions

View File

@ -1223,8 +1223,8 @@ void RENDER_3D_OPENGL::renderFootprint( const FOOTPRINT* aFootprint, bool aRende
glTranslatef( pos.x * m_boardAdapter.BiuTo3dUnits(), -pos.y * m_boardAdapter.BiuTo3dUnits(), glTranslatef( pos.x * m_boardAdapter.BiuTo3dUnits(), -pos.y * m_boardAdapter.BiuTo3dUnits(),
zpos ); zpos );
if( aFootprint->GetOrientation() ) if( !aFootprint->GetOrientation().IsZero() )
glRotated( (double) aFootprint->GetOrientation() / 10.0, 0.0, 0.0, 1.0 ); glRotated( aFootprint->GetOrientation().AsDegrees(), 0.0, 0.0, 1.0 );
if( aFootprint->IsFlipped() ) if( aFootprint->IsFlipped() )
{ {

View File

@ -1219,11 +1219,10 @@ void RENDER_3D_RAYTRACE::load3DModels( CONTAINER_3D& aDstContainer, bool aSkipMa
-pos.y * m_boardAdapter.BiuTo3dUnits(), -pos.y * m_boardAdapter.BiuTo3dUnits(),
zpos ) ); zpos ) );
if( fp->GetOrientation() ) if( !fp->GetOrientation().IsZero() )
{ {
fpMatrix = glm::rotate( fpMatrix, fpMatrix = glm::rotate( fpMatrix, (float) fp->GetOrientation().AsRadians(),
( (float) ( fp->GetOrientation() / 10.0f ) / 180.0f ) * glm::pi<float>(), SFVEC3F( 0.0f, 0.0f, 1.0f ) );
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
} }
if( fp->IsFlipped() ) if( fp->IsFlipped() )

View File

@ -62,7 +62,7 @@ size_t hash_fp_item( const EDA_ITEM* aItem, int aFlags )
hash_combine( ret, footprint->GetPosition().x, footprint->GetPosition().y ); hash_combine( ret, footprint->GetPosition().x, footprint->GetPosition().y );
if( aFlags & HASH_ROT ) if( aFlags & HASH_ROT )
hash_combine( ret, footprint->GetOrientation() ); hash_combine( ret, footprint->GetOrientation().AsTenthsOfADegree() );
for( BOARD_ITEM* item : footprint->GraphicalItems() ) for( BOARD_ITEM* item : footprint->GraphicalItems() )
hash_combine( ret, hash_fp_item( item, aFlags ) ); hash_combine( ret, hash_fp_item( item, aFlags ) );

View File

@ -137,7 +137,6 @@ private:
FT_Face m_subscriptFace; FT_Face m_subscriptFace;
int m_faceScaler; int m_faceScaler;
int m_subscriptFaceScaler;
// cache for glyphs converted to straight segments // cache for glyphs converted to straight segments
// key is glyph index (FT_GlyphSlot field glyph_index) // key is glyph index (FT_GlyphSlot field glyph_index)

View File

@ -101,6 +101,11 @@ inline void RotatePoint( VECTOR2I& point, const VECTOR2I& centre, EDA_ANGLE angl
void RotatePoint( double* pX, double* pY, double angle ); void RotatePoint( double* pX, double* pY, double angle );
inline void RotatePoint( double* pX, double* pY, EDA_ANGLE angle )
{
RotatePoint( pX, pY, angle.AsTenthsOfADegree() );
}
inline void RotatePoint( VECTOR2D& point, EDA_ANGLE angle ) inline void RotatePoint( VECTOR2D& point, EDA_ANGLE angle )
{ {
RotatePoint( &point.x, &point.y, angle.AsTenthsOfADegree() ); RotatePoint( &point.x, &point.y, angle.AsTenthsOfADegree() );
@ -108,6 +113,11 @@ inline void RotatePoint( VECTOR2D& point, EDA_ANGLE angle )
void RotatePoint( double* pX, double* pY, double cx, double cy, double angle ); void RotatePoint( double* pX, double* pY, double cx, double cy, double angle );
inline void RotatePoint( double* pX, double* pY, double cx, double cy, EDA_ANGLE angle )
{
RotatePoint( pX, pY, cx, cy, angle.AsTenthsOfADegree() );
}
inline void RotatePoint( VECTOR2D& point, const VECTOR2D& aCenter, EDA_ANGLE angle ) inline void RotatePoint( VECTOR2D& point, const VECTOR2D& aCenter, EDA_ANGLE angle )
{ {
RotatePoint( &point.x, &point.y, aCenter.x, aCenter.y, angle.AsTenthsOfADegree() ); RotatePoint( &point.x, &point.y, aCenter.x, aCenter.y, angle.AsTenthsOfADegree() );

View File

@ -251,11 +251,13 @@ bool AR_AUTOPLACER::fillMatrix()
} }
void AR_AUTOPLACER::rotateFootprint( FOOTPRINT* aFootprint, double angle, bool incremental ) void AR_AUTOPLACER::rotateFootprint( FOOTPRINT* aFootprint, double aAngle, bool incremental )
{ {
if( aFootprint == nullptr ) if( aFootprint == nullptr )
return; return;
EDA_ANGLE angle( aAngle, TENTHS_OF_A_DEGREE_T );
if( incremental ) if( incremental )
aFootprint->SetOrientation( aFootprint->GetOrientation() + angle ); aFootprint->SetOrientation( aFootprint->GetOrientation() + angle );
else else

View File

@ -247,7 +247,7 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
case SHAPE_T::POLY: case SHAPE_T::POLY:
{ {
const SHAPE_POLY_SET poly = graphic->GetPolyShape(); const SHAPE_POLY_SET poly = graphic->GetPolyShape();
double orientation = 0.0; EDA_ANGLE orientation = ANGLE_0;
VECTOR2I offset = VECTOR2I( 0, 0 ); VECTOR2I offset = VECTOR2I( 0, 0 );
if( graphic->GetParentFootprint() ) if( graphic->GetParentFootprint() )
@ -323,8 +323,8 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
} }
else if( graphic->GetShape() == SHAPE_T::POLY ) else if( graphic->GetShape() == SHAPE_T::POLY )
{ {
double orientation = 0.0; EDA_ANGLE orientation = ANGLE_0;
VECTOR2I offset = VECTOR2I( 0, 0 ); VECTOR2I offset = VECTOR2I( 0, 0 );
if( graphic->GetParentFootprint() ) if( graphic->GetParentFootprint() )
{ {
@ -561,8 +561,8 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
// connect to other elements, so we process them independently // connect to other elements, so we process them independently
if( graphic->GetShape() == SHAPE_T::POLY ) if( graphic->GetShape() == SHAPE_T::POLY )
{ {
double orientation = 0.0; EDA_ANGLE orientation = ANGLE_0;
VECTOR2I offset = VECTOR2I( 0, 0 ); VECTOR2I offset = VECTOR2I( 0, 0 );
if( graphic->GetParentFootprint() ) if( graphic->GetParentFootprint() )
{ {
@ -602,7 +602,7 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aSegList, SHAPE_POLY_SET&
{ {
double rotation = ( angle * step ) / steps; double rotation = ( angle * step ) / steps;
nextPt = start; nextPt = start;
RotatePoint( &nextPt.x, &nextPt.y, center.x, center.y, rotation ); RotatePoint( nextPt, center, rotation );
aPolygons.Append( nextPt, -1, hole ); aPolygons.Append( nextPt, -1, hole );
if( firstPt ) if( firstPt )

View File

@ -4,7 +4,7 @@
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt> * Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -246,7 +246,7 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow()
m_BoardSideCtrl->SetSelection( (m_footprint->GetLayer() == B_Cu) ? 1 : 0 ); m_BoardSideCtrl->SetSelection( (m_footprint->GetLayer() == B_Cu) ? 1 : 0 );
m_orientation.SetDoubleValue( m_footprint->GetOrientation() ); m_orientation.SetDoubleValue( m_footprint->GetOrientation().AsTenthsOfADegree() );
m_cbLocked->SetValue( m_footprint->IsLocked() ); m_cbLocked->SetValue( m_footprint->IsLocked() );
m_cbLocked->SetToolTip( _( "Locked footprints cannot be freely moved and oriented on the " m_cbLocked->SetToolTip( _( "Locked footprints cannot be freely moved and oriented on the "
@ -441,10 +441,13 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow()
m_footprint->SetAttributes( attributes ); m_footprint->SetAttributes( attributes );
double orient = m_orientation.GetDoubleValue(); EDA_ANGLE orient( m_orientation.GetDoubleValue(), TENTHS_OF_A_DEGREE_T );
if( m_footprint->GetOrientation() != orient ) if( m_footprint->GetOrientation() != orient )
m_footprint->Rotate( m_footprint->GetPosition(), orient - m_footprint->GetOrientation() ); {
m_footprint->Rotate( m_footprint->GetPosition(),
( orient - m_footprint->GetOrientation() ).AsTenthsOfADegree() );
}
// Set component side, that also have effect on the fields positions on board // Set component side, that also have effect on the fields positions on board
bool change_layer = false; bool change_layer = false;

View File

@ -486,8 +486,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
if( footprint ) if( footprint )
{ {
EDA_ANGLE angle = m_dummyPad->GetOrientation(); EDA_ANGLE angle = m_dummyPad->GetOrientation() - footprint->GetOrientation();
angle -= EDA_ANGLE( footprint->GetOrientation(), TENTHS_OF_A_DEGREE_T );
m_dummyPad->SetOrientation( angle ); m_dummyPad->SetOrientation( angle );
// Display parent footprint info // Display parent footprint info
@ -495,7 +494,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
footprint->Reference().GetShownText(), footprint->Reference().GetShownText(),
footprint->Value().GetShownText(), footprint->Value().GetShownText(),
footprint->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ), footprint->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ),
footprint->GetOrientationDegrees() ); footprint->GetOrientation().AsDegrees() );
} }
m_parentInfo->SetLabel( msg ); m_parentInfo->SetLabel( msg );
@ -1655,8 +1654,7 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
VECTOR2I pt = m_currentPad->GetPosition() - footprint->GetPosition(); VECTOR2I pt = m_currentPad->GetPosition() - footprint->GetPosition();
RotatePoint( pt, -footprint->GetOrientation() ); RotatePoint( pt, -footprint->GetOrientation() );
m_currentPad->SetPos0( pt ); m_currentPad->SetPos0( pt );
m_currentPad->SetOrientation( m_currentPad->GetOrientation() m_currentPad->SetOrientation( m_currentPad->GetOrientation() + footprint->GetOrientation() );
+ EDA_ANGLE( footprint->GetOrientation(), TENTHS_OF_A_DEGREE_T ) );
} }
m_parent->SetMsgPanel( m_currentPad ); m_parent->SetMsgPanel( m_currentPad );

View File

@ -246,7 +246,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
footprint->GetReference(), footprint->GetReference(),
footprint->GetValue(), footprint->GetValue(),
footprint->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ), footprint->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ),
footprint->GetOrientation() / 10.0 ); footprint->GetOrientation().AsDegrees() );
} }
m_statusLine->SetLabel( msg ); m_statusLine->SetLabel( msg );

View File

@ -147,8 +147,8 @@ bool padsNeedUpdate( const PAD* a, const PAD* b )
TEST( a->GetProperty(), b->GetProperty() ); TEST( a->GetProperty(), b->GetProperty() );
// The pad orientation, for historical reasons is the pad rotation + parent rotation. // The pad orientation, for historical reasons is the pad rotation + parent rotation.
TEST( ( a->GetOrientation() - EDA_ANGLE( a->GetParent()->GetOrientation(), TENTHS_OF_A_DEGREE_T ) ).Normalize().AsTenthsOfADegree(), TEST( ( a->GetOrientation() - a->GetParent()->GetOrientation() ).Normalize().AsTenthsOfADegree(),
( b->GetOrientation() - EDA_ANGLE( b->GetParent()->GetOrientation(), TENTHS_OF_A_DEGREE_T ) ).Normalize().AsTenthsOfADegree() ); ( b->GetOrientation() - b->GetParent()->GetOrientation() ).Normalize().AsTenthsOfADegree() );
TEST( a->GetSize(), b->GetSize() ); TEST( a->GetSize(), b->GetSize() );
TEST( a->GetDelta(), b->GetDelta() ); TEST( a->GetDelta(), b->GetDelta() );

View File

@ -191,11 +191,13 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
tmp << "\"" << csv_sep; tmp << "\"" << csv_sep;
tmp << wxString::Format( "%f%c%f%c%f", tmp << wxString::Format( "%f%c%f%c%f",
footprint_pos.x * conv_unit, csv_sep, footprint_pos.x * conv_unit,
// Keep the Y axis oriented from bottom to top, csv_sep,
// ( change y coordinate sign ) // Keep the Y axis oriented from bottom to top,
-footprint_pos.y * conv_unit, csv_sep, // ( change y coordinate sign )
list[ii].m_Footprint->GetOrientation() / 10.0 ); -footprint_pos.y * conv_unit,
csv_sep,
list[ii].m_Footprint->GetOrientation().AsDegrees() );
tmp << csv_sep; tmp << csv_sep;
tmp << ( (layer == F_Cu ) ? PLACE_FILE_EXPORTER::GetFrontSideName() tmp << ( (layer == F_Cu ) ? PLACE_FILE_EXPORTER::GetFrontSideName()
@ -263,7 +265,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
// Keep the coordinates in the first quadrant, // Keep the coordinates in the first quadrant,
// (i.e. change y sign // (i.e. change y sign
-footprint_pos.y * conv_unit, -footprint_pos.y * conv_unit,
list[ii].m_Footprint->GetOrientation() / 10.0, list[ii].m_Footprint->GetOrientation().AsDegrees(),
(layer == F_Cu ) ? GetFrontSideName().c_str() : GetBackSideName().c_str() ); (layer == F_Cu ) ? GetFrontSideName().c_str() : GetBackSideName().c_str() );
buffer += line; buffer += line;
} }
@ -357,7 +359,7 @@ std::string PLACE_FILE_EXPORTER::GenReportData()
sprintf( line, "position %9.6f %9.6f orientation %.2f\n", sprintf( line, "position %9.6f %9.6f orientation %.2f\n",
footprint_pos.x * conv_unit, footprint_pos.x * conv_unit,
footprint_pos.y * conv_unit, footprint_pos.y * conv_unit,
footprint->GetOrientation() / 10.0 ); footprint->GetOrientation().AsDegrees() );
buffer += line; buffer += line;
if( footprint->GetLayer() == F_Cu ) if( footprint->GetLayer() == F_Cu )
@ -402,7 +404,7 @@ std::string PLACE_FILE_EXPORTER::GenReportData()
pad->GetPos0().y * conv_unit, pad->GetPos0().y * conv_unit,
pad->GetSize().x * conv_unit, pad->GetSize().x * conv_unit,
pad->GetSize().y * conv_unit, pad->GetSize().y * conv_unit,
pad->GetOrientation().AsDegrees() - ( footprint->GetOrientation() / 10.0 ) ); ( pad->GetOrientation() - footprint->GetOrientation() ).AsDegrees() );
buffer += line; buffer += line;
sprintf( line, "drill %9.6f\n", pad->GetDrillSize().x * conv_unit ); sprintf( line, "drill %9.6f\n", pad->GetDrillSize().x * conv_unit );

View File

@ -828,8 +828,8 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
pins.insert( pinname ); pins.insert( pinname );
} }
double orient = pad->GetOrientation().AsTenthsOfADegree() - footprint->GetOrientation(); EDA_ANGLE orient = pad->GetOrientation() - footprint->GetOrientation();
NORMALIZE_ANGLE_POS( orient ); orient.Normalize();
// Bottom side footprints use the flipped padstack // Bottom side footprints use the flipped padstack
fprintf( aFile, ( flipBottomPads && footprint->GetFlag() ) ? fprintf( aFile, ( flipBottomPads && footprint->GetFlag() ) ?
@ -838,7 +838,7 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
TO_UTF8( escapeString( pinname ) ), pad->GetSubRatsnest(), TO_UTF8( escapeString( pinname ) ), pad->GetSubRatsnest(),
pad->GetPos0().x / SCALE_FACTOR, pad->GetPos0().x / SCALE_FACTOR,
-pad->GetPos0().y / SCALE_FACTOR, -pad->GetPos0().y / SCALE_FACTOR,
layer, orient / 10.0, mirror ); layer, orient.AsDegrees(), mirror );
} }
} }
@ -861,7 +861,7 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
{ {
const char* mirror; const char* mirror;
const char* flip; const char* flip;
double fp_orient = footprint->GetOrientation(); double fp_orient = footprint->GetOrientation().AsTenthsOfADegree();
if( footprint->GetFlag() ) if( footprint->GetFlag() )
{ {

View File

@ -441,7 +441,7 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
if( !outline ) if( !outline )
throw( std::runtime_error( aIDFBoard.GetError() ) ); throw( std::runtime_error( aIDFBoard.GetError() ) );
double rotz = aFootprint->GetOrientation() / 10.0; double rotz = aFootprint->GetOrientation().AsDegrees();
double locx = sM->m_Offset.x * 25.4; // part offsets are in inches double locx = sM->m_Offset.x * 25.4; // part offsets are in inches
double locy = sM->m_Offset.y * 25.4; double locy = sM->m_Offset.y * 25.4;
double locz = sM->m_Offset.z * 25.4; double locz = sM->m_Offset.z * 25.4;

View File

@ -836,7 +836,7 @@ void EXPORTER_PCB_VRML::ExportVrmlFootprint( FOOTPRINT* aFootprint, std::ostream
// Note here aFootprint->GetOrientation() is in 0.1 degrees, so footprint rotation // Note here aFootprint->GetOrientation() is in 0.1 degrees, so footprint rotation
// has to be converted to radians // has to be converted to radians
build_quat( 0, 0, 1, DECIDEG2RAD( aFootprint->GetOrientation() ), q2 ); build_quat( 0, 0, 1, aFootprint->GetOrientation().AsRadians(), q2 );
compose_quat( q1, q2, q1 ); compose_quat( q1, q2, q1 );
from_quat( q1, rot ); from_quat( q1, rot );

View File

@ -218,7 +218,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
poly.Append( bbox.GetRight(), y_sign*bbox.GetTop() ); poly.Append( bbox.GetRight(), y_sign*bbox.GetTop() );
poly.SetClosed( true ); poly.SetClosed( true );
poly.Rotate( -footprint->GetOrientationRadians(), VECTOR2I( 0, 0 ) ); poly.Rotate( -footprint->GetOrientation().AsRadians(), VECTOR2I( 0, 0 ) );
poly.Move( footprint->GetPosition() ); poly.Move( footprint->GetPosition() );
plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &gbr_metadata ); plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &gbr_metadata );
} }

View File

@ -58,7 +58,7 @@ FOOTPRINT::FOOTPRINT( BOARD* parent ) :
{ {
m_attributes = 0; m_attributes = 0;
m_layer = F_Cu; m_layer = F_Cu;
m_orient = 0; m_orient = ANGLE_0;
m_fpStatus = FP_PADS_are_LOCKED; m_fpStatus = FP_PADS_are_LOCKED;
m_arflag = 0; m_arflag = 0;
m_link = 0; m_link = 0;
@ -714,13 +714,11 @@ EDA_RECT FOOTPRINT::GetFpPadsLocalBbox() const
FOOTPRINT dummy( *this ); FOOTPRINT dummy( *this );
dummy.SetPosition( VECTOR2I( 0, 0 ) ); dummy.SetPosition( VECTOR2I( 0, 0 ) );
dummy.SetOrientation( ANGLE_0 );
if( dummy.IsFlipped() ) if( dummy.IsFlipped() )
dummy.Flip( VECTOR2I( 0, 0 ), false ); dummy.Flip( VECTOR2I( 0, 0 ), false );
if( dummy.GetOrientation() )
dummy.SetOrientation( 0 );
for( PAD* pad : dummy.Pads() ) for( PAD* pad : dummy.Pads() )
area.Merge( pad->GetBoundingBox() ); area.Merge( pad->GetBoundingBox() );
@ -988,7 +986,7 @@ void FOOTPRINT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
aList.emplace_back( _( "Status: " ) + status, _( "Attributes:" ) + wxS( " " ) + attrs ); aList.emplace_back( _( "Status: " ) + status, _( "Attributes:" ) + wxS( " " ) + attrs );
aList.emplace_back( _( "Rotation" ), wxString::Format( "%.4g", GetOrientationDegrees() ) ); aList.emplace_back( _( "Rotation" ), wxString::Format( "%.4g", GetOrientation().AsDegrees() ) );
msg.Printf( _( "Footprint: %s" ), m_fpid.GetUniStringLibId() ); msg.Printf( _( "Footprint: %s" ), m_fpid.GetUniStringLibId() );
msg2.Printf( _( "3D-Shape: %s" ), m_3D_Drawings.empty() ? _( "<none>" ) msg2.Printf( _( "3D-Shape: %s" ), m_3D_Drawings.empty() ? _( "<none>" )
@ -1486,12 +1484,12 @@ void FOOTPRINT::Move( const VECTOR2I& aMoveVector )
void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, double aAngle ) void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, double aAngle )
{ {
double orientation = GetOrientation(); double orientation = GetOrientation().AsTenthsOfADegree();
double newOrientation = orientation + aAngle; double newOrientation = orientation + aAngle;
VECTOR2I newpos = m_pos; VECTOR2I newpos = m_pos;
RotatePoint( newpos, aRotCentre, aAngle ); RotatePoint( newpos, aRotCentre, aAngle );
SetPosition( newpos ); SetPosition( newpos );
SetOrientation( newOrientation ); SetOrientation( EDA_ANGLE( newOrientation, TENTHS_OF_A_DEGREE_T ) );
m_reference->KeepUpright( orientation, newOrientation ); m_reference->KeepUpright( orientation, newOrientation );
m_value->KeepUpright( orientation, newOrientation ); m_value->KeepUpright( orientation, newOrientation );
@ -1532,8 +1530,7 @@ void FOOTPRINT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
// Reverse mirror orientation. // Reverse mirror orientation.
m_orient = -m_orient; m_orient = -m_orient;
m_orient.Normalize180();
NORMALIZE_ANGLE_180( m_orient );
// Mirror pads to other side of board. // Mirror pads to other side of board.
for( PAD* pad : m_pads ) for( PAD* pad : m_pads )
@ -1707,24 +1704,21 @@ void FOOTPRINT::MoveAnchorPosition( const VECTOR2I& aMoveVector )
} }
void FOOTPRINT::SetOrientation( double aNewAngle ) void FOOTPRINT::SetOrientation( const EDA_ANGLE& aNewAngle )
{ {
double angleChange = aNewAngle - m_orient; // change in rotation EDA_ANGLE angleChange = aNewAngle - m_orient; // change in rotation
NORMALIZE_ANGLE_180( aNewAngle );
m_orient = aNewAngle; m_orient = aNewAngle;
m_orient.Normalize180();
for( PAD* pad : m_pads ) for( PAD* pad : m_pads )
{ {
pad->SetOrientation( pad->GetOrientation() + EDA_ANGLE( angleChange, TENTHS_OF_A_DEGREE_T ) ); pad->SetOrientation( pad->GetOrientation() + angleChange );
pad->SetDrawCoord(); pad->SetDrawCoord();
} }
for( ZONE* zone : m_fp_zones ) for( ZONE* zone : m_fp_zones )
{ zone->Rotate( GetPosition(), angleChange.AsTenthsOfADegree() );
zone->Rotate( GetPosition(), angleChange );
}
// Update of the reference and value. // Update of the reference and value.
m_reference->SetDrawCoord(); m_reference->SetDrawCoord();
@ -1734,20 +1728,16 @@ void FOOTPRINT::SetOrientation( double aNewAngle )
for( BOARD_ITEM* item : m_drawings ) for( BOARD_ITEM* item : m_drawings )
{ {
if( item->Type() == PCB_FP_SHAPE_T ) if( item->Type() == PCB_FP_SHAPE_T )
{
static_cast<FP_SHAPE*>( item )->SetDrawCoord(); static_cast<FP_SHAPE*>( item )->SetDrawCoord();
}
else if( item->Type() == PCB_FP_TEXT_T ) else if( item->Type() == PCB_FP_TEXT_T )
{
static_cast<FP_TEXT*>( item )->SetDrawCoord(); static_cast<FP_TEXT*>( item )->SetDrawCoord();
}
} }
m_boundingBoxCacheTimeStamp = 0; m_boundingBoxCacheTimeStamp = 0;
m_visibleBBoxCacheTimeStamp = 0; m_visibleBBoxCacheTimeStamp = 0;
m_textExcludedBBoxCacheTimeStamp = 0; m_textExcludedBBoxCacheTimeStamp = 0;
m_cachedHull.Rotate( -DECIDEG2RAD( angleChange ), GetPosition() ); m_cachedHull.Rotate( - angleChange.AsRadians(), GetPosition() );
} }

View File

@ -191,11 +191,18 @@ public:
void SetPosition( const VECTOR2I& aPos ) override; void SetPosition( const VECTOR2I& aPos ) override;
VECTOR2I GetPosition() const override { return m_pos; } VECTOR2I GetPosition() const override { return m_pos; }
void SetOrientation( double aNewAngle ); void SetOrientation( const EDA_ANGLE& aNewAngle );
void SetOrientationDegrees( double aOrientation ) { SetOrientation( aOrientation * 10.0 ); } EDA_ANGLE GetOrientation() const { return m_orient; }
double GetOrientation() const { return m_orient; }
double GetOrientationDegrees() const { return m_orient / 10.0; } // For property system:
double GetOrientationRadians() const { return m_orient * M_PI / 1800; } void SetOrientationDegrees( double aOrientation )
{
SetOrientation( EDA_ANGLE( aOrientation, DEGREES_T ) );
}
double GetOrientationDegrees() const
{
return m_orient.AsDegrees();
}
const LIB_ID& GetFPID() const { return m_fpid; } const LIB_ID& GetFPID() const { return m_fpid; }
void SetFPID( const LIB_ID& aFPID ) { m_fpid = aFPID; } void SetFPID( const LIB_ID& aFPID ) { m_fpid = aFPID; }
@ -736,12 +743,12 @@ private:
FP_ZONES m_fp_zones; // FP_ZONE items, owned by pointer FP_ZONES m_fp_zones; // FP_ZONE items, owned by pointer
FP_GROUPS m_fp_groups; // PCB_GROUP items, owned by pointer FP_GROUPS m_fp_groups; // PCB_GROUP items, owned by pointer
double m_orient; // Orientation in tenths of a degree, 900=90.0 degrees. EDA_ANGLE m_orient; // Orientation
VECTOR2I m_pos; // Position of footprint on the board in internal units. VECTOR2I m_pos; // Position of footprint on the board in internal units.
FP_TEXT* m_reference; // Component reference designator value (U34, R18..) FP_TEXT* m_reference; // Component reference designator value (U34, R18..)
FP_TEXT* m_value; // Component value (74LS00, 22K..) FP_TEXT* m_value; // Component value (74LS00, 22K..)
LIB_ID m_fpid; // The #LIB_ID of the FOOTPRINT. LIB_ID m_fpid; // The #LIB_ID of the FOOTPRINT.
int m_attributes; // Flag bits ( see FOOTPRINT_ATTR_T ) int m_attributes; // Flag bits (see FOOTPRINT_ATTR_T)
int m_fpStatus; // For autoplace: flags (LOCKED, FIELDS_AUTOPLACED) int m_fpStatus; // For autoplace: flags (LOCKED, FIELDS_AUTOPLACED)
// Bounding box caching strategy: // Bounding box caching strategy:

View File

@ -4,7 +4,7 @@
* Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -69,12 +69,11 @@ void FP_SHAPE::SetLocalCoord()
m_bezierC1_0 = m_bezierC1 - fp->GetPosition(); m_bezierC1_0 = m_bezierC1 - fp->GetPosition();
m_bezierC2_0 = m_bezierC2 - fp->GetPosition(); m_bezierC2_0 = m_bezierC2 - fp->GetPosition();
double angle = fp->GetOrientation(); RotatePoint( &m_start0.x, &m_start0.y, - fp->GetOrientation() );
RotatePoint( &m_start0.x, &m_start0.y, -angle ); RotatePoint( &m_end0.x, &m_end0.y, - fp->GetOrientation() );
RotatePoint( &m_end0.x, &m_end0.y, -angle ); RotatePoint( &m_arcCenter0.x, &m_arcCenter0.y, - fp->GetOrientation() );
RotatePoint( &m_arcCenter0.x, &m_arcCenter0.y, -angle ); RotatePoint( &m_bezierC1_0.x, &m_bezierC1_0.y, - fp->GetOrientation() );
RotatePoint( &m_bezierC1_0.x, &m_bezierC1_0.y, -angle ); RotatePoint( &m_bezierC2_0.x, &m_bezierC2_0.y, - fp->GetOrientation() );
RotatePoint( &m_bezierC2_0.x, &m_bezierC2_0.y, -angle );
} }

View File

@ -203,10 +203,8 @@ void FP_TEXT::SetDrawCoord()
if( parentFootprint ) if( parentFootprint )
{ {
double angle = parentFootprint->GetOrientation();
VECTOR2I pt = GetTextPos(); VECTOR2I pt = GetTextPos();
RotatePoint( pt, angle ); RotatePoint( pt, parentFootprint->GetOrientation() );
SetTextPos( pt ); SetTextPos( pt );
Offset( parentFootprint->GetPosition() ); Offset( parentFootprint->GetPosition() );
@ -221,10 +219,7 @@ void FP_TEXT::SetLocalCoord()
if( parentFootprint ) if( parentFootprint )
{ {
m_Pos0 = GetTextPos() - parentFootprint->GetPosition(); m_Pos0 = GetTextPos() - parentFootprint->GetPosition();
RotatePoint( &m_Pos0.x, &m_Pos0.y, - parentFootprint->GetOrientation() );
double angle = parentFootprint->GetOrientation();
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
} }
else else
{ {
@ -247,7 +242,7 @@ const EDA_RECT FP_TEXT::GetBoundingBox() const
EDA_ANGLE FP_TEXT::GetDrawRotation() const EDA_ANGLE FP_TEXT::GetDrawRotation() const
{ {
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent ); FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
double rotation = GetTextAngle().AsTenthsOfADegree(); EDA_ANGLE rotation = GetTextAngle();
if( parentFootprint ) if( parentFootprint )
rotation += parentFootprint->GetOrientation(); rotation += parentFootprint->GetOrientation();
@ -255,18 +250,18 @@ EDA_ANGLE FP_TEXT::GetDrawRotation() const
if( m_keepUpright ) if( m_keepUpright )
{ {
// Keep angle between 0 .. 90 deg. Otherwise the text is not easy to read // Keep angle between 0 .. 90 deg. Otherwise the text is not easy to read
while( rotation > 900 ) while( rotation > ANGLE_90 )
rotation -= 1800; rotation -= ANGLE_180;
while( rotation < 0 ) while( rotation < ANGLE_0 )
rotation += 1800; rotation += ANGLE_180;
} }
else else
{ {
NORMALIZE_ANGLE_POS( rotation ); rotation.Normalize();
} }
return EDA_ANGLE( rotation, TENTHS_OF_A_DEGREE_T ); return rotation;
} }

View File

@ -151,7 +151,7 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( FOOTPRINT* aFootprint )
// Put it in orientation 0, // Put it in orientation 0,
// because this is the default orientation in Footprint Editor, and in libs // because this is the default orientation in Footprint Editor, and in libs
newFootprint->SetOrientation( 0 ); newFootprint->SetOrientation( ANGLE_0 );
Zoom_Automatique( false ); Zoom_Automatique( false );

View File

@ -59,9 +59,9 @@ using KIGFX::PCB_RENDER_SETTINGS;
PAD::PAD( FOOTPRINT* parent ) : PAD::PAD( FOOTPRINT* parent ) :
BOARD_CONNECTED_ITEM( parent, PCB_PAD_T ) BOARD_CONNECTED_ITEM( parent, PCB_PAD_T )
{ {
m_size.x = m_size.y = Mils2iu( 60 ); // Default pad size 60 mils. m_size.x = m_size.y = Mils2iu( 60 ); // Default pad size 60 mils.
m_drill.x = m_drill.y = Mils2iu( 30 ); // Default drill size 30 mils. m_drill.x = m_drill.y = Mils2iu( 30 ); // Default drill size 30 mils.
m_orient = ANGLE_0; // Pad rotation. m_orient = ANGLE_0;
m_lengthPadToDie = 0; m_lengthPadToDie = 0;
if( m_parent && m_parent->Type() == PCB_FOOTPRINT_T ) if( m_parent && m_parent->Type() == PCB_FOOTPRINT_T )
@ -567,9 +567,7 @@ void PAD::SetDrawCoord()
if( parentFootprint == nullptr ) if( parentFootprint == nullptr )
return; return;
double angle = parentFootprint->GetOrientation(); RotatePoint( &m_pos.x, &m_pos.y, parentFootprint->GetOrientation() );
RotatePoint( &m_pos.x, &m_pos.y, angle );
m_pos += parentFootprint->GetPosition(); m_pos += parentFootprint->GetPosition();
SetDirty(); SetDirty();
@ -1404,10 +1402,10 @@ void PAD::ImportSettingsFrom( const PAD& aMasterPad )
EDA_ANGLE pad_rot = aMasterPad.GetOrientation(); EDA_ANGLE pad_rot = aMasterPad.GetOrientation();
if( aMasterPad.GetParent() ) if( aMasterPad.GetParent() )
pad_rot -= EDA_ANGLE( aMasterPad.GetParent()->GetOrientation(), TENTHS_OF_A_DEGREE_T ); pad_rot -= aMasterPad.GetParent()->GetOrientation();
if( GetParent() ) if( GetParent() )
pad_rot += EDA_ANGLE( GetParent()->GetOrientation(), TENTHS_OF_A_DEGREE_T ); pad_rot += GetParent()->GetOrientation();
SetOrientation( pad_rot ); SetOrientation( pad_rot );

View File

@ -202,7 +202,7 @@ void PCB_BASE_FRAME::AddFootprintToBoard( FOOTPRINT* aFootprint )
// Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
// it might be stored in another orientation if the lib is an archive built from a board) // it might be stored in another orientation if the lib is an archive built from a board)
aFootprint->SetOrientation( 0 ); aFootprint->SetOrientation( ANGLE_0 );
} }
} }

View File

@ -1449,7 +1449,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
{ {
m_gal->Save(); m_gal->Save();
m_gal->Translate( parentFootprint->GetPosition() ); m_gal->Translate( parentFootprint->GetPosition() );
m_gal->Rotate( -parentFootprint->GetOrientationRadians() ); m_gal->Rotate( -parentFootprint->GetOrientation().AsRadians() );
} }
if( outline_mode ) if( outline_mode )

View File

@ -132,7 +132,7 @@ FOOTPRINT* PCB_SHAPE::GetParentFootprint() const
double PCB_SHAPE::getParentOrientation() const double PCB_SHAPE::getParentOrientation() const
{ {
if( GetParentFootprint() ) if( GetParentFootprint() )
return GetParentFootprint()->GetOrientation(); return GetParentFootprint()->GetOrientation().AsTenthsOfADegree();
else else
return 0.0; return 0.0;
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2019-2020 Thomas Pointhuber <thomas.pointhuber@gmx.at> * Copyright (C) 2019-2020 Thomas Pointhuber <thomas.pointhuber@gmx.at>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -162,7 +162,7 @@ void ALTIUM_PCB::HelperShapeSetLocalCoord( PCB_SHAPE* aShape, uint16_t aComponen
FOOTPRINT* fp = m_components.at( aComponent ); FOOTPRINT* fp = m_components.at( aComponent );
polyShape.Move( -fp->GetPosition() ); polyShape.Move( -fp->GetPosition() );
polyShape.Rotate( -fp->GetOrientationRadians() ); polyShape.Rotate( -fp->GetOrientation().AsRadians() );
} }
} }
} }
@ -1012,7 +1012,7 @@ void ALTIUM_PCB::ParseComponentsBodies6Data( const CFB::CompoundFileReader& aRea
modelSettings.m_Offset.y = -Iu2Millimeter((int) elem.modelPosition.y - fpPosition.y ); modelSettings.m_Offset.y = -Iu2Millimeter((int) elem.modelPosition.y - fpPosition.y );
modelSettings.m_Offset.z = Iu2Millimeter( (int) elem.modelPosition.z ); modelSettings.m_Offset.z = Iu2Millimeter( (int) elem.modelPosition.z );
double orientation = footprint->GetOrientation(); EDA_ANGLE orientation = footprint->GetOrientation();
if( footprint->IsFlipped() ) if( footprint->IsFlipped() )
{ {
@ -1026,7 +1026,7 @@ void ALTIUM_PCB::ParseComponentsBodies6Data( const CFB::CompoundFileReader& aRea
modelSettings.m_Rotation.y = NormalizeAngleDegrees( -elem.modelRotation.y, -180, 180 ); modelSettings.m_Rotation.y = NormalizeAngleDegrees( -elem.modelRotation.y, -180, 180 );
modelSettings.m_Rotation.z = NormalizeAngleDegrees( -elem.modelRotation.z modelSettings.m_Rotation.z = NormalizeAngleDegrees( -elem.modelRotation.z
+ elem.rotation + elem.rotation
+ orientation / 10, -180, 180 ); + orientation.AsDegrees(), -180, 180 );
modelSettings.m_Opacity = elem.bodyOpacity; modelSettings.m_Opacity = elem.bodyOpacity;
footprint->Models().push_back( modelSettings ); footprint->Models().push_back( modelSettings );
@ -2722,9 +2722,9 @@ void ALTIUM_PCB::ParseTexts6Data( const CFB::CompoundFileReader& aReader,
if( fpText ) if( fpText )
{ {
FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( fpText->GetParent() ); FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( fpText->GetParent() );
double orientation = parentFootprint->GetOrientation(); EDA_ANGLE orientation = parentFootprint->GetOrientation();
fpText->SetTextAngle( fpText->GetTextAngle().AsTenthsOfADegree() - orientation ); fpText->SetTextAngle( fpText->GetTextAngle() - orientation );
fpText->SetLocalCoord(); fpText->SetLocalCoord();
} }
} }

View File

@ -1537,12 +1537,12 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions()
} }
} }
wxPoint endOffset( csDim.Line.LeaderLineLength * cos( angRad ) * orientX, VECTOR2I endOffset( csDim.Line.LeaderLineLength * cos( angRad ) * orientX,
csDim.Line.LeaderLineLength * sin( angRad ) * orientY ); csDim.Line.LeaderLineLength * sin( angRad ) * orientY );
wxPoint endPoint = csDim.Line.End + endOffset; VECTOR2I endPoint = VECTOR2I( csDim.Line.End ) + endOffset;
wxPoint txtPoint( endPoint.x + ( csDim.Line.LeaderLineExtensionLength * orientX ), VECTOR2I txtPoint( endPoint.x + ( csDim.Line.LeaderLineExtensionLength * orientX ),
endPoint.y ); endPoint.y );
leaderDim->SetEnd( getKiCadPoint( endPoint ) ); leaderDim->SetEnd( getKiCadPoint( endPoint ) );
leaderDim->Text().SetTextPos( getKiCadPoint( txtPoint ) ); leaderDim->Text().SetTextPos( getKiCadPoint( txtPoint ) );
@ -1721,13 +1721,13 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents()
footprint->SetValue( wxEmptyString ); footprint->SetValue( wxEmptyString );
footprint->SetPosition( getKiCadPoint( comp.Origin ) ); footprint->SetPosition( getKiCadPoint( comp.Origin ) );
footprint->SetOrientation( getAngleTenthDegree( comp.OrientAngle ) ); footprint->SetOrientation( getAngle( comp.OrientAngle ) );
footprint->SetReference( comp.Name ); footprint->SetReference( comp.Name );
if( comp.Mirror ) if( comp.Mirror )
{ {
double mirroredAngle = - getAngleTenthDegree( comp.OrientAngle ); EDA_ANGLE mirroredAngle = - getAngle( comp.OrientAngle );
NORMALIZE_ANGLE_180( mirroredAngle ); mirroredAngle.Normalize180();
footprint->SetOrientation( mirroredAngle ); footprint->SetOrientation( mirroredAngle );
footprint->Flip( getKiCadPoint( comp.Origin ), true ); footprint->Flip( getKiCadPoint( comp.Origin ), true );
} }
@ -2879,7 +2879,7 @@ PCB_SHAPE* CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex( const POINT& aCadstar
if( aRotationAngle != 0.0 ) if( aRotationAngle != 0.0 )
shape->Rotate( aTransformCentre, aRotationAngle ); shape->Rotate( aTransformCentre, aRotationAngle );
if( aMoveVector != wxPoint{ 0, 0 } ) if( aMoveVector != VECTOR2I{ 0, 0 } )
shape->Move( aMoveVector ); shape->Move( aMoveVector );
if( isFootprint( aContainer ) && shape != nullptr ) if( isFootprint( aContainer ) && shape != nullptr )
@ -3242,8 +3242,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
txt->SetPos0( rotatedTextPos ); txt->SetPos0( rotatedTextPos );
txt->SetLayer( getKiCadLayer( aCadstarAttrLoc.LayerID ) ); txt->SetLayer( getKiCadLayer( aCadstarAttrLoc.LayerID ) );
txt->SetMirrored( aCadstarAttrLoc.Mirror ); txt->SetMirrored( aCadstarAttrLoc.Mirror );
txt->SetTextAngle( txt->SetTextAngle( getAngle( aCadstarAttrLoc.OrientAngle ) - aFootprint->GetOrientation() );
getAngleTenthDegree( aCadstarAttrLoc.OrientAngle ) - aFootprint->GetOrientation() );
if( aCadstarAttrLoc.Mirror ) // If mirroring, invert angle to match CADSTAR if( aCadstarAttrLoc.Mirror ) // If mirroring, invert angle to match CADSTAR
txt->SetTextAngle( -txt->GetTextAngle() ); txt->SetTextAngle( -txt->GetTextAngle() );
@ -3480,7 +3479,7 @@ double CADSTAR_PCB_ARCHIVE_LOADER::getHatchCodeAngleDegrees(
if( hcode.Hatches.size() < 1 ) if( hcode.Hatches.size() < 1 )
return m_board->GetDesignSettings().GetDefaultZoneSettings().m_HatchOrientation; return m_board->GetDesignSettings().GetDefaultZoneSettings().m_HatchOrientation;
else else
return getAngleDegrees( hcode.Hatches.at( 0 ).OrientAngle ); return getAngle( hcode.Hatches.at( 0 ).OrientAngle ).AsDegrees();
} }
@ -3570,9 +3569,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::checkAndLogHatchCode( const HATCHCODE_ID& aCads
"degrees apart. The imported hatching has two hatches 90 " "degrees apart. The imported hatching has two hatches 90 "
"degrees apart, oriented %.1f degrees from horizontal." ), "degrees apart, oriented %.1f degrees from horizontal." ),
hcode.Name, hcode.Name,
getAngleDegrees( abs( hcode.Hatches.at( 0 ).OrientAngle getAngle( abs( hcode.Hatches.at( 0 ).OrientAngle
- hcode.Hatches.at( 1 ).OrientAngle ) ), - hcode.Hatches.at( 1 ).OrientAngle ) ).AsDegrees(),
getAngleDegrees( hcode.Hatches.at( 0 ).OrientAngle ) ) ); getAngle( hcode.Hatches.at( 0 ).OrientAngle ).AsDegrees() ) );
} }
} }

View File

@ -1530,13 +1530,12 @@ void EAGLE_PLUGIN::orientFootprintAndText( FOOTPRINT* aFootprint, const EELEMENT
{ {
if( e.rot->mirror ) if( e.rot->mirror )
{ {
double orientation = e.rot->degrees + 180.0; aFootprint->SetOrientation( EDA_ANGLE( e.rot->degrees + 180.0, DEGREES_T ) );
aFootprint->SetOrientation( orientation * 10 );
aFootprint->Flip( aFootprint->GetPosition(), false ); aFootprint->Flip( aFootprint->GetPosition(), false );
} }
else else
{ {
aFootprint->SetOrientation( e.rot->degrees * 10 ); aFootprint->SetOrientation( EDA_ANGLE( e.rot->degrees, DEGREES_T ) );
} }
} }
@ -1592,7 +1591,7 @@ void EAGLE_PLUGIN::orientFPText( FOOTPRINT* aFootprint, const EELEMENT& e, FP_TE
// present, and this zero rotation becomes an override to the // present, and this zero rotation becomes an override to the
// package's text field. If they did not want zero, they specify // package's text field. If they did not want zero, they specify
// what they want explicitly. // what they want explicitly.
double degrees = a.rot ? a.rot->degrees : 0; double degrees = a.rot ? a.rot->degrees : 0.0;
double orient; // relative to parent double orient; // relative to parent
int sign = 1; int sign = 1;
@ -1607,24 +1606,24 @@ void EAGLE_PLUGIN::orientFPText( FOOTPRINT* aFootprint, const EELEMENT& e, FP_TE
if( degrees == 90 || degrees == 0 || spin ) if( degrees == 90 || degrees == 0 || spin )
{ {
orient = degrees - aFootprint->GetOrientation() / 10; orient = degrees - aFootprint->GetOrientation().AsDegrees();
aFPText->SetTextAngle( sign * orient * 10 ); aFPText->SetTextAngle( sign * orient * 10 );
} }
else if( degrees == 180 ) else if( degrees == 180 )
{ {
orient = 0 - aFootprint->GetOrientation() / 10; orient = 0 - aFootprint->GetOrientation().AsDegrees();
aFPText->SetTextAngle( sign * orient * 10 ); aFPText->SetTextAngle( sign * orient * 10 );
align = -align; align = -align;
} }
else if( degrees == 270 ) else if( degrees == 270 )
{ {
orient = 90 - aFootprint->GetOrientation() / 10; orient = 90 - aFootprint->GetOrientation().AsDegrees();
align = -align; align = -align;
aFPText->SetTextAngle( sign * orient * 10 ); aFPText->SetTextAngle( sign * orient * 10 );
} }
else else
{ {
orient = 90 - degrees - aFootprint->GetOrientation() / 10; orient = 90 - degrees - aFootprint->GetOrientation().AsDegrees();
aFPText->SetTextAngle( sign * orient * 10 ); aFPText->SetTextAngle( sign * orient * 10 );
} }
@ -1681,9 +1680,10 @@ void EAGLE_PLUGIN::orientFPText( FOOTPRINT* aFootprint, const EELEMENT& e, FP_TE
} }
else else
{ {
// Part is not smash so use Lib default for NAME/VALUE // the text is per the original // Part is not smash so use Lib default for NAME/VALUE
// package, sans <attribute>. // the text is per the original package, sans <attribute>.
double degrees = aFPText->GetTextAngle().AsDegrees() + aFootprint->GetOrientation() / 10.0; double degrees = aFPText->GetTextAngle().AsDegrees()
+ aFootprint->GetOrientation().AsDegrees();
// @todo there are a few more cases than these to contend with: // @todo there are a few more cases than these to contend with:
if( ( !aFPText->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ) ) if( ( !aFPText->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ) )

View File

@ -3425,7 +3425,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
if( token == T_NUMBER ) if( token == T_NUMBER )
{ {
footprint->SetOrientation( parseAngle() ); footprint->SetOrientation( EDA_ANGLE( parseAngle(), TENTHS_OF_A_DEGREE_T ) );
NeedRIGHT(); NeedRIGHT();
} }
else if( token != T_RIGHT ) else if( token != T_RIGHT )
@ -3565,7 +3565,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
{ {
FP_TEXT* text = parseFP_TEXT(); FP_TEXT* text = parseFP_TEXT();
text->SetParent( footprint.get() ); text->SetParent( footprint.get() );
double orientation = text->GetTextAngle().AsTenthsOfADegree(); EDA_ANGLE orientation = text->GetTextAngle();
orientation -= footprint->GetOrientation(); orientation -= footprint->GetOrientation();
text->SetTextAngle( orientation ); text->SetTextAngle( orientation );
text->SetDrawCoord(); text->SetDrawCoord();

View File

@ -1139,8 +1139,11 @@ void PCB_PLUGIN::format( const FOOTPRINT* aFootprint, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(at %s", m_out->Print( aNestLevel+1, "(at %s",
FormatInternalUnits( aFootprint->GetPosition() ).c_str() ); FormatInternalUnits( aFootprint->GetPosition() ).c_str() );
if( aFootprint->GetOrientation() != 0.0 ) if( !aFootprint->GetOrientation().IsZero() )
m_out->Print( 0, " %s", FormatAngle( aFootprint->GetOrientation() ).c_str() ); {
m_out->Print( 0, " %s",
FormatAngle( aFootprint->GetOrientation().AsTenthsOfADegree() ).c_str() );
}
m_out->Print( 0, ")\n" ); m_out->Print( 0, ")\n" );
} }
@ -1789,7 +1792,7 @@ void PCB_PLUGIN::format( const FP_TEXT* aText, int aNestLevel ) const
// Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle, // Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle,
// but internally the angle is held relative to its parent footprint. parent // but internally the angle is held relative to its parent footprint. parent
// may be NULL when saving a footprint outside a BOARD. // may be NULL when saving a footprint outside a BOARD.
double orient = aText->GetTextAngle().AsTenthsOfADegree(); EDA_ANGLE orient = aText->GetTextAngle();
FOOTPRINT* parent = static_cast<FOOTPRINT*>( aText->GetParent() ); FOOTPRINT* parent = static_cast<FOOTPRINT*>( aText->GetParent() );
if( parent ) if( parent )
@ -1806,12 +1809,12 @@ void PCB_PLUGIN::format( const FP_TEXT* aText, int aNestLevel ) const
#else #else
// Choose compatibility for now, even though this is only a 720 degree clamp // Choose compatibility for now, even though this is only a 720 degree clamp
// with two possible values for every angle. // with two possible values for every angle.
orient = NormalizeAngle360Min( orient + parent->GetOrientation() ); orient = ( orient + parent->GetOrientation() ).Normalize720();
#endif #endif
} }
if( orient != 0.0 ) if( !orient.IsZero() )
m_out->Print( 0, " %s", FormatAngle( orient ).c_str() ); m_out->Print( 0, " %s", FormatAngle( orient.AsTenthsOfADegree() ).c_str() );
if( !aText->IsKeepUpright() ) if( !aText->IsKeepUpright() )
m_out->Print( 0, " unlocked" ); m_out->Print( 0, " unlocked" );
@ -2431,7 +2434,7 @@ void PCB_PLUGIN::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* a
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aFootprint->Clone() ); FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aFootprint->Clone() );
// It's orientation should be zero and it should be on the front layer. // It's orientation should be zero and it should be on the front layer.
footprint->SetOrientation( 0 ); footprint->SetOrientation( ANGLE_0 );
if( footprint->GetLayer() != F_Cu ) if( footprint->GetLayer() != F_Cu )
{ {

View File

@ -1194,7 +1194,7 @@ void LEGACY_PLUGIN::loadFOOTPRINT( FOOTPRINT* aFootprint )
aFootprint->SetPosition( VECTOR2I( pos_x, pos_y ) ); aFootprint->SetPosition( VECTOR2I( pos_x, pos_y ) );
aFootprint->SetLayer( layer_id ); aFootprint->SetLayer( layer_id );
aFootprint->SetOrientation( orient ); aFootprint->SetOrientation( EDA_ANGLE( orient, TENTHS_OF_A_DEGREE_T ) );
const_cast<KIID&>( aFootprint->m_Uuid ) = KIID( uuid ); const_cast<KIID&>( aFootprint->m_Uuid ) = KIID( uuid );
aFootprint->SetLastEditTime( edittime ); aFootprint->SetLastEditTime( edittime );
} }
@ -1658,22 +1658,18 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( FP_TEXT* aText )
const char* txt_end; const char* txt_end;
const char* line = m_reader->Line(); // current (old) line const char* line = m_reader->Line(); // current (old) line
// sscanf( line + 1, "%d %d %d %d %d %d %d %s %s %d %s",
// &type, &m_Pos0.x, &m_Pos0.y, &m_Size.y, &m_Size.x,
// &m_Orient, &m_Thickness, BufCar1, BufCar2, &layer, BufCar3 ) >= 10 )
// e.g. "T1 6940 -16220 350 300 900 60 M I 20 N "CFCARD"\r\n" // e.g. "T1 6940 -16220 350 300 900 60 M I 20 N "CFCARD"\r\n"
// or T1 0 500 600 400 900 80 M V 20 N"74LS245" // or T1 0 500 600 400 900 80 M V 20 N"74LS245"
// ouch, the last example has no space between N and "74LS245" ! // ouch, the last example has no space between N and "74LS245" !
// that is an older version. // that is an older version.
int type = intParse( line+1, &data ); int type = intParse( line+1, &data );
BIU pos0_x = biuParse( data, &data ); BIU pos0_x = biuParse( data, &data );
BIU pos0_y = biuParse( data, &data ); BIU pos0_y = biuParse( data, &data );
BIU size0_y = biuParse( data, &data ); BIU size0_y = biuParse( data, &data );
BIU size0_x = biuParse( data, &data ); BIU size0_x = biuParse( data, &data );
double orient = degParse( data, &data ); EDA_ANGLE orient = EDA_ANGLE( degParse( data, &data ), TENTHS_OF_A_DEGREE_T );
BIU thickn = biuParse( data, &data ); BIU thickn = biuParse( data, &data );
// read the quoted text before the first call to strtok() which introduces // read the quoted text before the first call to strtok() which introduces
// NULs into the string and chops it into multiple C strings, something // NULs into the string and chops it into multiple C strings, something
@ -1709,7 +1705,7 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( FP_TEXT* aText )
aText->SetPos0( VECTOR2I( pos0_x, pos0_y ) ); aText->SetPos0( VECTOR2I( pos0_x, pos0_y ) );
aText->SetTextSize( wxSize( size0_x, size0_y ) ); aText->SetTextSize( wxSize( size0_x, size0_y ) );
orient -= ( static_cast<FOOTPRINT*>( aText->GetParent() ) )->GetOrientation(); orient -= ( static_cast<FOOTPRINT*>( aText->GetParentFootprint() ) )->GetOrientation();
aText->SetTextAngle( orient ); aText->SetTextAngle( orient );

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk> * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com> * Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
* Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2012-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -509,7 +509,7 @@ void PCB_FOOTPRINT::AddToBoard()
footprint->SetPosition( VECTOR2I( m_positionX, m_positionY ) ); footprint->SetPosition( VECTOR2I( m_positionX, m_positionY ) );
footprint->SetLayer( m_Mirror ? B_Cu : F_Cu ); footprint->SetLayer( m_Mirror ? B_Cu : F_Cu );
footprint->SetOrientation( m_rotation ); footprint->SetOrientation( EDA_ANGLE( m_rotation, TENTHS_OF_A_DEGREE_T ) );
footprint->SetLastEditTime( 0 ); footprint->SetLastEditTime( 0 );
LIB_ID fpID; LIB_ID fpID;

View File

@ -1846,7 +1846,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
{ {
VECTOR2I offset = m_endSnapPoint - p; VECTOR2I offset = m_endSnapPoint - p;
BOARD_ITEM* previewItem; BOARD_ITEM* previewItem;
wxPoint fp_offset = wxPoint( offset.Rotate( footprint->GetOrientationRadians() ) ); wxPoint fp_offset = wxPoint( offset.Rotate( footprint->GetOrientation().AsRadians() ) );
view()->ClearPreview(); view()->ClearPreview();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2015-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -878,9 +878,9 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
// IMAGE object coordinates are relative to the IMAGE not absolute board coordinates. // IMAGE object coordinates are relative to the IMAGE not absolute board coordinates.
ZONE untransformedZone( *zone ); ZONE untransformedZone( *zone );
double angle = -aFootprint->GetOrientation(); EDA_ANGLE angle = -aFootprint->GetOrientation();
NORMALIZE_ANGLE_POS( angle ); angle.Normalize();
untransformedZone.Rotate( aFootprint->GetPosition(), angle ); untransformedZone.Rotate( aFootprint->GetPosition(), angle.AsTenthsOfADegree() );
// keepout areas have a type. types are // keepout areas have a type. types are
// T_place_keepout, T_via_keepout, T_wire_keepout, // T_place_keepout, T_via_keepout, T_wire_keepout,

View File

@ -372,7 +372,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
if( place->side == T_front ) if( place->side == T_front )
{ {
// convert from degrees to tenths of degrees used in KiCad. // convert from degrees to tenths of degrees used in KiCad.
int orientation = KiROUND( place->rotation * 10.0 ); EDA_ANGLE orientation( place->rotation, DEGREES_T );
if( footprint->GetLayer() != F_Cu ) if( footprint->GetLayer() != F_Cu )
{ {
@ -384,7 +384,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
} }
else if( place->side == T_back ) else if( place->side == T_back )
{ {
int orientation = KiROUND( (place->rotation + 180.0) * 10.0 ); EDA_ANGLE orientation( place->rotation + 180.0, DEGREES_T );
if( footprint->GetLayer() != B_Cu ) if( footprint->GetLayer() != B_Cu )
{ {

View File

@ -1096,7 +1096,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
if( fp->IsFlipped() ) if( fp->IsFlipped() )
fp->Flip( fp->GetPosition(), m_frame->Settings().m_FlipLeftRight ); fp->Flip( fp->GetPosition(), m_frame->Settings().m_FlipLeftRight );
fp->SetOrientation( 0 ); fp->SetOrientation( ANGLE_0 );
fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
commit.Add( fp ); commit.Add( fp );

View File

@ -178,8 +178,7 @@ static void doPushPadProperties( BOARD& board, const PAD& aSrcPad, BOARD_COMMIT&
{ {
const FOOTPRINT* refFootprint = aSrcPad.GetParent(); const FOOTPRINT* refFootprint = aSrcPad.GetParent();
EDA_ANGLE srcPadAngle = aSrcPad.GetOrientation() EDA_ANGLE srcPadAngle = aSrcPad.GetOrientation() - refFootprint->GetOrientation();
- EDA_ANGLE( refFootprint->GetOrientation(), TENTHS_OF_A_DEGREE_T );
for( FOOTPRINT* footprint : board.Footprints() ) for( FOOTPRINT* footprint : board.Footprints() )
{ {
@ -194,8 +193,7 @@ static void doPushPadProperties( BOARD& board, const PAD& aSrcPad, BOARD_COMMIT&
if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) ) if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) )
continue; continue;
EDA_ANGLE padAngle = pad->GetOrientation() EDA_ANGLE padAngle = pad->GetOrientation() - footprint->GetOrientation();
- EDA_ANGLE( footprint->GetOrientation(), TENTHS_OF_A_DEGREE_T );
if( aPadOrientFilter && ( padAngle != srcPadAngle ) ) if( aPadOrientFilter && ( padAngle != srcPadAngle ) )
continue; continue;

View File

@ -675,8 +675,7 @@ static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOA
if( text->GetType() != FP_TEXT::TEXT_is_DIVERS ) if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
continue; continue;
text->SetTextAngle( text->GetTextAngle().AsTenthsOfADegree() text->SetTextAngle( text->GetTextAngle() + aClipFootprint->GetOrientation() );
+ aClipFootprint->GetOrientation() );
text->SetParent( nullptr ); text->SetParent( nullptr );
text->SetLocalCoord(); text->SetLocalCoord();