Move BOARD_ITEM::Rotate() to EDA_ANGLE.
This commit is contained in:
parent
abd3f5bc2b
commit
c9487bad18
|
@ -21,9 +21,10 @@
|
|||
#include <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_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 );
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <eda_item.h>
|
||||
#include <eda_units.h>
|
||||
#include <eda_angle.h>
|
||||
#include <convert_to_biu.h>
|
||||
#include <gr_basic.h>
|
||||
#include <layer_ids.h>
|
||||
|
@ -254,10 +255,9 @@ public:
|
|||
/**
|
||||
* Rotate this object.
|
||||
*
|
||||
* @param aRotCentre the rotation point.
|
||||
* @param aAngle the rotation angle in 0.1 degree.
|
||||
* @param aRotCentre the rotation center point.
|
||||
*/
|
||||
virtual void Rotate( const VECTOR2I& aRotCentre, double aAngle );
|
||||
virtual void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle );
|
||||
|
||||
/**
|
||||
* Flip this object, i.e. change the board side for this object.
|
||||
|
|
|
@ -263,6 +263,7 @@ 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;
|
||||
|
@ -314,6 +315,11 @@ inline bool operator<=( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB )
|
|||
return aAngleA.AsTenthsOfADegree() <= aAngleB.AsTenthsOfADegree();
|
||||
}
|
||||
|
||||
inline bool operator>=( const EDA_ANGLE& aAngleA, const EDA_ANGLE& aAngleB )
|
||||
{
|
||||
return aAngleA.AsTenthsOfADegree() >= aAngleB.AsTenthsOfADegree();
|
||||
}
|
||||
|
||||
|
||||
static constexpr EDA_ANGLE& ANGLE_HORIZONTAL = EDA_ANGLE::m_Angle0;
|
||||
static constexpr EDA_ANGLE& ANGLE_VERTICAL = EDA_ANGLE::m_Angle90;
|
||||
|
@ -322,8 +328,10 @@ static constexpr EDA_ANGLE& FULL_CIRCLE = EDA_ANGLE::m_Angle360;
|
|||
static constexpr EDA_ANGLE& ANGLE_0 = EDA_ANGLE::m_Angle0;
|
||||
static constexpr EDA_ANGLE& ANGLE_45 = EDA_ANGLE::m_Angle45;
|
||||
static constexpr EDA_ANGLE& ANGLE_90 = EDA_ANGLE::m_Angle90;
|
||||
static constexpr EDA_ANGLE& ANGLE_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;
|
||||
|
||||
|
||||
#endif // EDA_ANGLE_H
|
||||
|
|
|
@ -174,7 +174,7 @@ public:
|
|||
void Move( const VECTOR2I& aMoveVector ) override;
|
||||
|
||||
///< @copydoc BOARD_ITEM::Rotate
|
||||
void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
///< @copydoc BOARD_ITEM::Flip
|
||||
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
||||
|
|
|
@ -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(), transform.m_rotation * 10 );
|
||||
aItem.Rotate( aItem.GetPosition(), EDA_ANGLE( transform.m_rotation, DEGREES_T ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ BOARD_ITEM_CONTAINER* BOARD_ITEM::GetParentFootprint() const
|
|||
}
|
||||
|
||||
|
||||
void BOARD_ITEM::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void BOARD_ITEM::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
wxMessageBox( wxT( "virtual BOARD_ITEM::Rotate used, should not occur" ), GetClass() );
|
||||
}
|
||||
|
|
|
@ -444,10 +444,7 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow()
|
|||
EDA_ANGLE orient( m_orientation.GetDoubleValue(), TENTHS_OF_A_DEGREE_T );
|
||||
|
||||
if( m_footprint->GetOrientation() != orient )
|
||||
{
|
||||
m_footprint->Rotate( m_footprint->GetPosition(),
|
||||
( orient - m_footprint->GetOrientation() ).AsTenthsOfADegree() );
|
||||
}
|
||||
m_footprint->Rotate( m_footprint->GetPosition(), orient - m_footprint->GetOrientation() );
|
||||
|
||||
// Set component side, that also have effect on the fields positions on board
|
||||
bool change_layer = false;
|
||||
|
|
|
@ -631,7 +631,7 @@ void DIALOG_PAD_PRIMITIVES_TRANSFORM::Transform( std::vector<std::shared_ptr<PCB
|
|||
|
||||
shape->Move( currMoveVect );
|
||||
shape->Scale( scale );
|
||||
shape->Rotate( wxPoint( 0, 0 ), curr_rotation );
|
||||
shape->Rotate( VECTOR2I( 0, 0 ), EDA_ANGLE( curr_rotation, TENTHS_OF_A_DEGREE_T ) );
|
||||
}
|
||||
|
||||
// Prepare new transform on duplication:
|
||||
|
|
|
@ -1477,7 +1477,7 @@ void DIALOG_PAD_PROPERTIES::redraw()
|
|||
{
|
||||
PCB_SHAPE* dummyShape = (PCB_SHAPE*) m_primitives[select]->Clone();
|
||||
dummyShape->SetLayer( SELECTED_ITEMS_LAYER );
|
||||
dummyShape->Rotate( VECTOR2I( 0, 0), m_dummyPad->GetOrientation().AsTenthsOfADegree() );
|
||||
dummyShape->Rotate( VECTOR2I( 0, 0), m_dummyPad->GetOrientation() );
|
||||
dummyShape->Move( m_dummyPad->GetPosition() );
|
||||
|
||||
view->Add( dummyShape );
|
||||
|
|
|
@ -1482,22 +1482,22 @@ void FOOTPRINT::Move( const VECTOR2I& aMoveVector )
|
|||
}
|
||||
|
||||
|
||||
void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void FOOTPRINT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
double orientation = GetOrientation().AsTenthsOfADegree();
|
||||
double newOrientation = orientation + aAngle;
|
||||
VECTOR2I newpos = m_pos;
|
||||
EDA_ANGLE orientation = GetOrientation();
|
||||
EDA_ANGLE newOrientation = orientation + aAngle;
|
||||
VECTOR2I newpos = m_pos;
|
||||
RotatePoint( newpos, aRotCentre, aAngle );
|
||||
SetPosition( newpos );
|
||||
SetOrientation( EDA_ANGLE( newOrientation, TENTHS_OF_A_DEGREE_T ) );
|
||||
SetOrientation( newOrientation );
|
||||
|
||||
m_reference->KeepUpright( orientation, newOrientation );
|
||||
m_value->KeepUpright( orientation, newOrientation );
|
||||
m_reference->KeepUpright( orientation.AsTenthsOfADegree(), newOrientation.AsTenthsOfADegree() );
|
||||
m_value->KeepUpright( orientation.AsTenthsOfADegree(), newOrientation.AsTenthsOfADegree() );
|
||||
|
||||
for( BOARD_ITEM* item : m_drawings )
|
||||
{
|
||||
if( item->Type() == PCB_FP_TEXT_T )
|
||||
static_cast<FP_TEXT*>( item )->KeepUpright( orientation, newOrientation );
|
||||
static_cast<FP_TEXT*>( item )->KeepUpright( orientation.AsTenthsOfADegree(), newOrientation.AsTenthsOfADegree() );
|
||||
}
|
||||
|
||||
m_boundingBoxCacheTimeStamp = 0;
|
||||
|
@ -1565,7 +1565,7 @@ void FOOTPRINT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
|
|||
|
||||
// Now rotate 180 deg if required
|
||||
if( aFlipLeftRight )
|
||||
Rotate( aCentre, 1800.0 );
|
||||
Rotate( aCentre, ANGLE_180 );
|
||||
|
||||
m_boundingBoxCacheTimeStamp = 0;
|
||||
m_visibleBBoxCacheTimeStamp = 0;
|
||||
|
@ -1718,7 +1718,7 @@ void FOOTPRINT::SetOrientation( const EDA_ANGLE& aNewAngle )
|
|||
}
|
||||
|
||||
for( ZONE* zone : m_fp_zones )
|
||||
zone->Rotate( GetPosition(), angleChange.AsTenthsOfADegree() );
|
||||
zone->Rotate( GetPosition(), angleChange );
|
||||
|
||||
// Update of the reference and value.
|
||||
m_reference->SetDrawCoord();
|
||||
|
|
|
@ -261,7 +261,7 @@ public:
|
|||
|
||||
void Move( const VECTOR2I& aMoveVector ) override;
|
||||
|
||||
void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ void FP_SHAPE::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
|
|||
SetDrawCoord();
|
||||
}
|
||||
|
||||
void FP_SHAPE::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void FP_SHAPE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
// We should rotate the relative coordinates, but to avoid duplicate code do the base class
|
||||
// rotation of draw coordinates, which is acceptable because in the footprint editor
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
* This is a footprint shape modification.
|
||||
* (should be only called by a footprint editing function )
|
||||
*/
|
||||
void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
/**
|
||||
* Flip entity relative to aCentre.
|
||||
|
|
|
@ -128,7 +128,7 @@ void FP_TEXT::KeepUpright( double aOldOrientation, double aNewOrientation )
|
|||
}
|
||||
|
||||
|
||||
void FP_TEXT::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void FP_TEXT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
// Used in footprint editing
|
||||
// Note also in footprint editor, m_Pos0 = m_Pos
|
||||
|
@ -137,7 +137,7 @@ void FP_TEXT::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
|||
RotatePoint( pt, aRotCentre, aAngle );
|
||||
SetTextPos( pt );
|
||||
|
||||
SetTextAngle( GetTextAngle().AsTenthsOfADegree() + aAngle );
|
||||
SetTextAngle( GetTextAngle() + aAngle );
|
||||
SetLocalCoord();
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ void FP_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() ) );
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
|
||||
/// Rotate text, in footprint editor
|
||||
/// (for instance in footprint rotation transform)
|
||||
void Rotate( const VECTOR2I& aOffset, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aOffset, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
/// Flip entity during footprint flip
|
||||
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
||||
|
|
|
@ -1088,11 +1088,11 @@ int PAD::Compare( const PAD* aPadRef, const PAD* aPadCmp )
|
|||
}
|
||||
|
||||
|
||||
void PAD::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void PAD::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
RotatePoint( m_pos, aRotCentre, aAngle );
|
||||
|
||||
m_orient += EDA_ANGLE( aAngle, TENTHS_OF_A_DEGREE_T );
|
||||
m_orient += aAngle;
|
||||
m_orient.Normalize();
|
||||
|
||||
SetLocalCoord();
|
||||
|
|
|
@ -629,7 +629,7 @@ public:
|
|||
SetDirty();
|
||||
}
|
||||
|
||||
void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* 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
|
||||
|
@ -211,12 +211,11 @@ void PCB_DIMENSION_BASE::Move( const VECTOR2I& offset )
|
|||
}
|
||||
|
||||
|
||||
void PCB_DIMENSION_BASE::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void PCB_DIMENSION_BASE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
double newAngle = m_text.GetTextAngle().AsTenthsOfADegree() + aAngle;
|
||||
EDA_ANGLE newAngle = m_text.GetTextAngle() + aAngle;
|
||||
|
||||
if( newAngle >= 3600 )
|
||||
newAngle -= 3600;
|
||||
newAngle.Normalize();
|
||||
|
||||
m_text.SetTextAngle( newAngle );
|
||||
|
||||
|
@ -874,16 +873,18 @@ void PCB_DIM_ORTHOGONAL::updateText()
|
|||
}
|
||||
|
||||
|
||||
void PCB_DIM_ORTHOGONAL::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void PCB_DIM_ORTHOGONAL::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
EDA_ANGLE angle( aAngle );
|
||||
|
||||
// restrict angle to -179.9 to 180.0 degrees
|
||||
if( aAngle > 1800 )
|
||||
if( angle > ANGLE_180 )
|
||||
{
|
||||
aAngle -= 3600;
|
||||
angle -= ANGLE_360;
|
||||
}
|
||||
else if( aAngle <= -1800 )
|
||||
else if( angle <= -ANGLE_180 )
|
||||
{
|
||||
aAngle += 3600;
|
||||
angle += ANGLE_360;
|
||||
}
|
||||
|
||||
// adjust orientation and height to new angle
|
||||
|
@ -891,7 +892,7 @@ void PCB_DIM_ORTHOGONAL::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
|||
// in the other cases we will use the nearest 90 degree angle to
|
||||
// choose at least an approximate axis for the target orientation
|
||||
// In case of exactly 45 or 135 degrees, we will round towards zero for consistency
|
||||
if( aAngle > 450 && aAngle <= 1350 )
|
||||
if( angle > ANGLE_45 && angle <= ANGLE_135 )
|
||||
{
|
||||
// about 90 degree
|
||||
if( m_orientation == DIR::HORIZONTAL )
|
||||
|
@ -904,7 +905,7 @@ void PCB_DIM_ORTHOGONAL::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
|||
m_height = -m_height;
|
||||
}
|
||||
}
|
||||
else if( aAngle < -450 && aAngle >= -1350 )
|
||||
else if( angle < -ANGLE_45 && angle >= -ANGLE_135 )
|
||||
{
|
||||
// about -90 degree
|
||||
if( m_orientation == DIR::HORIZONTAL )
|
||||
|
@ -917,14 +918,14 @@ void PCB_DIM_ORTHOGONAL::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
|||
m_orientation = DIR::HORIZONTAL;
|
||||
}
|
||||
}
|
||||
else if( aAngle > 1350 || aAngle < -1350 )
|
||||
else if( angle > ANGLE_135 || angle < -ANGLE_135 )
|
||||
{
|
||||
// about 180 degree
|
||||
m_height = -m_height;
|
||||
}
|
||||
|
||||
// this will update m_crossBarStart and m_crossbarEnd
|
||||
PCB_DIMENSION_BASE::Rotate( aRotCentre, aAngle );
|
||||
PCB_DIMENSION_BASE::Rotate( aRotCentre, angle );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ public:
|
|||
// BOARD_ITEM overrides
|
||||
|
||||
void Move( const VECTOR2I& offset ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
||||
|
||||
/**
|
||||
|
@ -460,7 +460,7 @@ public:
|
|||
{
|
||||
return wxT( "PCB_DIM_ORTHOGONAL" );
|
||||
}
|
||||
void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
protected:
|
||||
void updateGeometry() override;
|
||||
|
|
|
@ -296,7 +296,7 @@ void PCB_GROUP::Move( const VECTOR2I& aMoveVector )
|
|||
}
|
||||
|
||||
|
||||
void PCB_GROUP::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void PCB_GROUP::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
for( BOARD_ITEM* item : m_items )
|
||||
item->Rotate( aRotCentre, aAngle );
|
||||
|
|
|
@ -164,7 +164,7 @@ void PCB_MARKER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
|
|||
}
|
||||
|
||||
|
||||
void PCB_MARKER::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void PCB_MARKER::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
// Marker geometry isn't user-editable
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
m_Pos += aMoveVector;
|
||||
}
|
||||
|
||||
void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
||||
|
||||
|
|
|
@ -106,9 +106,9 @@ void PCB_SHAPE::Scale( double aScale )
|
|||
}
|
||||
|
||||
|
||||
void PCB_SHAPE::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void PCB_SHAPE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
rotate( aRotCentre, aAngle );
|
||||
rotate( aRotCentre, aAngle.AsTenthsOfADegree() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ public:
|
|||
|
||||
virtual void Move( const VECTOR2I& aMoveVector ) override;
|
||||
|
||||
virtual void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
virtual void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
virtual void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ bool PCB_TARGET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
|
|||
}
|
||||
|
||||
|
||||
void PCB_TARGET::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void PCB_TARGET::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
RotatePoint( m_pos, aRotCentre, aAngle );
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
m_pos += aMoveVector;
|
||||
}
|
||||
|
||||
void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
||||
|
||||
|
|
|
@ -167,13 +167,13 @@ bool PCB_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
|
|||
}
|
||||
|
||||
|
||||
void PCB_TEXT::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void PCB_TEXT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
VECTOR2I pt = GetTextPos();
|
||||
RotatePoint( pt, aRotCentre, aAngle );
|
||||
SetTextPos( pt );
|
||||
|
||||
SetTextAngle( GetTextAngle().AsTenthsOfADegree() + aAngle );
|
||||
SetTextAngle( GetTextAngle() + aAngle );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
void SetTextAngle( double aAngle ) override;
|
||||
void SetTextAngle( const EDA_ANGLE& aAngle );
|
||||
|
||||
void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
||||
|
||||
|
|
|
@ -262,14 +262,14 @@ double PCB_TRACK::GetLength() const
|
|||
}
|
||||
|
||||
|
||||
void PCB_TRACK::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void PCB_TRACK::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
RotatePoint( m_Start, aRotCentre, aAngle );
|
||||
RotatePoint( m_End, aRotCentre, aAngle );
|
||||
}
|
||||
|
||||
|
||||
void PCB_ARC::Rotate( const VECTOR2I& aRotCentre, double aAngle )
|
||||
void PCB_ARC::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
RotatePoint( m_Start, aRotCentre, aAngle );
|
||||
RotatePoint( m_End, aRotCentre, aAngle );
|
||||
|
|
|
@ -90,7 +90,7 @@ public:
|
|||
m_End += aMoveVector;
|
||||
}
|
||||
|
||||
void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
||||
|
||||
|
@ -263,7 +263,7 @@ public:
|
|||
m_End += aMoveVector;
|
||||
}
|
||||
|
||||
virtual void Rotate( const VECTOR2I& aRotCentre, double aAngle ) override;
|
||||
virtual void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
virtual void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
|
||||
|
||||
|
|
|
@ -2309,7 +2309,7 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem )
|
|||
aElem.position + VECTOR2I( -aElem.topsize.x / 2, aElem.topsize.y / 2 ) } );
|
||||
|
||||
if( aElem.direction != 0 )
|
||||
shape->Rotate( aElem.position, aElem.direction * 10 );
|
||||
shape->Rotate( aElem.position, EDA_ANGLE( aElem.direction, DEGREES_T ) );
|
||||
|
||||
HelperShapeSetLocalCoord( shape, aElem.component );
|
||||
}
|
||||
|
@ -2368,7 +2368,7 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem )
|
|||
}
|
||||
|
||||
if( aElem.direction != 0 )
|
||||
shape->Rotate( aElem.position, aElem.direction * 10 );
|
||||
shape->Rotate( aElem.position, EDA_ANGLE( aElem.direction, DEGREES_T ) );
|
||||
|
||||
HelperShapeSetLocalCoord( shape, aElem.component );
|
||||
}
|
||||
|
@ -2407,7 +2407,7 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem )
|
|||
}
|
||||
|
||||
if( aElem.direction != 0 )
|
||||
shape->Rotate( aElem.position, aElem.direction * 10. );
|
||||
shape->Rotate( aElem.position, EDA_ANGLE( aElem.direction, DEGREES_T ) );
|
||||
|
||||
HelperShapeSetLocalCoord( shape, aElem.component );
|
||||
}
|
||||
|
@ -2435,7 +2435,7 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem )
|
|||
p22 + chamferX, p22 + chamferY, p21 - chamferY, p21 + chamferX } );
|
||||
|
||||
if( aElem.direction != 0. )
|
||||
shape->Rotate( aElem.position, aElem.direction * 10 );
|
||||
shape->Rotate( aElem.position, EDA_ANGLE( aElem.direction, DEGREES_T ) );
|
||||
|
||||
HelperShapeSetLocalCoord( shape, aElem.component );
|
||||
}
|
||||
|
@ -2877,7 +2877,7 @@ void ALTIUM_PCB::ParseFills6Data( const CFB::CompoundFileReader& aReader,
|
|||
}
|
||||
|
||||
if( elem.rotation != 0. )
|
||||
zone->Rotate( center, elem.rotation * 10 );
|
||||
zone->Rotate( center, EDA_ANGLE( elem.rotation, DEGREES_T ) );
|
||||
|
||||
zone->SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE,
|
||||
ZONE::GetDefaultHatchPitch(), true );
|
||||
|
@ -2893,7 +2893,7 @@ void ALTIUM_PCB::ParseFills6Data( const CFB::CompoundFileReader& aReader,
|
|||
shape->SetPolyPoints( { p11, p12, p22, p21 } );
|
||||
|
||||
if( elem.rotation != 0. )
|
||||
shape->Rotate( center, elem.rotation * 10 );
|
||||
shape->Rotate( center, EDA_ANGLE( elem.rotation, DEGREES_T ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1181,8 +1181,7 @@ PAD* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad( const COMPONENT_PAD& aCadstarPad,
|
|||
padShape->SetPolyShape( padOutline );
|
||||
padShape->SetStroke( STROKE_PARAMS( 0 ) );
|
||||
padShape->Move( padOffset - drillOffset );
|
||||
padShape->Rotate( VECTOR2I( 0, 0 ),
|
||||
1800.0 - getAngleTenthDegree( csPadcode.SlotOrientation ) );
|
||||
padShape->Rotate( VECTOR2I( 0, 0 ), ANGLE_180 - getAngle( csPadcode.SlotOrientation ) );
|
||||
|
||||
SHAPE_POLY_SET editedPadOutline = padShape->GetPolyShape();
|
||||
|
||||
|
@ -2877,7 +2876,7 @@ PCB_SHAPE* CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex( const POINT& aCadstar
|
|||
}
|
||||
|
||||
if( aRotationAngle != 0.0 )
|
||||
shape->Rotate( aTransformCentre, aRotationAngle );
|
||||
shape->Rotate( aTransformCentre, EDA_ANGLE( aRotationAngle, TENTHS_OF_A_DEGREE_T ) );
|
||||
|
||||
if( aMoveVector != VECTOR2I{ 0, 0 } )
|
||||
shape->Move( aMoveVector );
|
||||
|
|
|
@ -945,7 +945,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
|||
zone->AppendCorner( VECTOR2I( kicad_x( r.x1 ), kicad_y( r.y2 ) ), outlineIdx );
|
||||
|
||||
if( r.rot )
|
||||
zone->Rotate( zone->GetPosition(), r.rot->degrees * 10 );
|
||||
zone->Rotate( zone->GetPosition(), EDA_ANGLE( r.rot->degrees, DEGREES_T ) );
|
||||
|
||||
// this is not my fault:
|
||||
zone->SetBorderDisplayStyle( outline_hatch, ZONE::GetDefaultHatchPitch(),
|
||||
|
@ -2051,7 +2051,7 @@ void EAGLE_PLUGIN::packageRectangle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) c
|
|||
{
|
||||
VECTOR2I center( ( kicad_x( r.x1 ) + kicad_x( r.x2 ) ) / 2,
|
||||
( kicad_y( r.y1 ) + kicad_y( r.y2 ) ) / 2 );
|
||||
zone->Rotate( center, r.rot->degrees * 10 );
|
||||
zone->Rotate( center, EDA_ANGLE( r.rot->degrees, DEGREES_T ) );
|
||||
}
|
||||
|
||||
zone->SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE,
|
||||
|
@ -2093,7 +2093,7 @@ void EAGLE_PLUGIN::packageRectangle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) c
|
|||
dwg->SetEnd0( end );
|
||||
|
||||
if( r.rot )
|
||||
dwg->Rotate( dwg->GetCenter(), r.rot->degrees * 10 );
|
||||
dwg->Rotate( dwg->GetCenter(), EDA_ANGLE( r.rot->degrees, DEGREES_T ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -880,7 +880,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
|
|||
|
||||
EDA_ANGLE angle = -aFootprint->GetOrientation();
|
||||
angle.Normalize();
|
||||
untransformedZone.Rotate( aFootprint->GetPosition(), angle.AsTenthsOfADegree() );
|
||||
untransformedZone.Rotate( aFootprint->GetPosition(), angle );
|
||||
|
||||
// keepout areas have a type. types are
|
||||
// T_place_keepout, T_via_keepout, T_wire_keepout,
|
||||
|
|
|
@ -1484,7 +1484,7 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
static_cast<BOARD_ITEM*>( item )->Rotate( refPt, rotateAngle );
|
||||
static_cast<BOARD_ITEM*>( item )->Rotate( refPt, EDA_ANGLE( rotateAngle, TENTHS_OF_A_DEGREE_T ) );
|
||||
}
|
||||
|
||||
if( !m_dragging )
|
||||
|
@ -1986,8 +1986,9 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( ret == wxID_OK )
|
||||
{
|
||||
VECTOR2I rp = selection.GetCenter();
|
||||
wxPoint selCenter( rp.x, rp.y );
|
||||
EDA_ANGLE angle( rotation, TENTHS_OF_A_DEGREE_T );
|
||||
VECTOR2I rp = selection.GetCenter();
|
||||
wxPoint selCenter( rp.x, rp.y );
|
||||
|
||||
// Make sure the rotation is from the right reference point
|
||||
selCenter += translation;
|
||||
|
@ -2024,16 +2025,16 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
|
|||
switch( rotationAnchor )
|
||||
{
|
||||
case ROTATE_AROUND_ITEM_ANCHOR:
|
||||
item->Rotate( item->GetPosition(), rotation );
|
||||
item->Rotate( item->GetPosition(), angle );
|
||||
break;
|
||||
case ROTATE_AROUND_SEL_CENTER:
|
||||
item->Rotate( selCenter, rotation );
|
||||
item->Rotate( selCenter, angle );
|
||||
break;
|
||||
case ROTATE_AROUND_USER_ORIGIN:
|
||||
item->Rotate( frame()->GetScreen()->m_LocalOrigin, rotation );
|
||||
item->Rotate( frame()->GetScreen()->m_LocalOrigin, angle );
|
||||
break;
|
||||
case ROTATE_AROUND_AUX_ORIGIN:
|
||||
item->Rotate( board()->GetDesignSettings().GetAuxOrigin(), rotation );
|
||||
item->Rotate( board()->GetDesignSettings().GetAuxOrigin(), angle );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -665,7 +665,7 @@ PCB_LAYER_ID PAD_TOOL::explodePad( PAD* aPad )
|
|||
|
||||
shape->SetLocalCoord();
|
||||
shape->Move( aPad->GetPosition() );
|
||||
shape->Rotate( aPad->GetPosition(), aPad->GetOrientation().AsTenthsOfADegree() );
|
||||
shape->Rotate( aPad->GetPosition(), aPad->GetOrientation() );
|
||||
shape->SetLayer( layer );
|
||||
|
||||
commit.Add( shape );
|
||||
|
@ -748,14 +748,14 @@ void PAD_TOOL::recombinePad( PAD* aPad )
|
|||
if( aPad->GetSizeX() > aPad->GetSizeY() )
|
||||
aPad->SetSizeX( aPad->GetSizeY() );
|
||||
|
||||
aPad->SetOffset( wxPoint( 0, 0 ) );
|
||||
aPad->SetOffset( VECTOR2I( 0, 0 ) );
|
||||
|
||||
PCB_SHAPE* shape = new PCB_SHAPE( nullptr, SHAPE_T::POLY );
|
||||
shape->SetFilled( true );
|
||||
shape->SetStroke( STROKE_PARAMS( 0, PLOT_DASH_TYPE::SOLID ) );
|
||||
shape->SetPolyShape( existingOutline );
|
||||
shape->Move( - aPad->GetPosition() );
|
||||
shape->Rotate( wxPoint( 0, 0 ), - aPad->GetOrientation().AsTenthsOfADegree() );
|
||||
shape->Rotate( VECTOR2I( 0, 0 ), - aPad->GetOrientation() );
|
||||
|
||||
aPad->AddPrimitive( shape );
|
||||
}
|
||||
|
@ -802,7 +802,7 @@ void PAD_TOOL::recombinePad( PAD* aPad )
|
|||
}
|
||||
|
||||
pcbShape->Move( - aPad->GetPosition() );
|
||||
pcbShape->Rotate( wxPoint( 0, 0 ), - aPad->GetOrientation().AsTenthsOfADegree() );
|
||||
pcbShape->Rotate( VECTOR2I( 0, 0 ), - aPad->GetOrientation() );
|
||||
aPad->AddPrimitive( pcbShape );
|
||||
|
||||
fpShape->SetFlags( STRUCT_DELETED );
|
||||
|
|
|
@ -218,7 +218,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
|
|||
if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
|
||||
{
|
||||
const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
|
||||
newItem->Rotate( newItem->GetPosition(), rotationAngle );
|
||||
newItem->Rotate( newItem->GetPosition(), EDA_ANGLE( rotationAngle, TENTHS_OF_A_DEGREE_T ) );
|
||||
view()->Update( &preview );
|
||||
}
|
||||
else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
|
||||
|
|
|
@ -683,27 +683,25 @@ void ZONE::MoveEdge( const VECTOR2I& offset, int aEdge )
|
|||
}
|
||||
|
||||
|
||||
void ZONE::Rotate( const VECTOR2I& aCentre, double aAngle )
|
||||
void ZONE::Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
aAngle = -DECIDEG2RAD( aAngle );
|
||||
|
||||
m_Poly->Rotate( aAngle, VECTOR2I( aCentre ) );
|
||||
m_Poly->Rotate( -aAngle.AsRadians(), VECTOR2I( aCentre ) );
|
||||
HatchBorder();
|
||||
|
||||
/* rotate filled areas: */
|
||||
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
|
||||
pair.second.Rotate( aAngle, aCentre );
|
||||
pair.second.Rotate( -aAngle.AsRadians(), aCentre );
|
||||
|
||||
for( std::pair<const PCB_LAYER_ID, std::vector<SEG> >& pair : m_FillSegmList )
|
||||
{
|
||||
for( SEG& seg : pair.second )
|
||||
{
|
||||
VECTOR2I a( seg.A );
|
||||
RotatePoint( a, aCentre, aAngle );
|
||||
RotatePoint( a, aCentre, -aAngle.AsRadians() );
|
||||
seg.A = a;
|
||||
|
||||
VECTOR2I b( seg.B );
|
||||
RotatePoint( b, aCentre, aAngle );
|
||||
RotatePoint( b, aCentre, -aAngle.AsRadians() );
|
||||
seg.B = a;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -506,12 +506,11 @@ public:
|
|||
void MoveEdge( const VECTOR2I& offset, int aEdge );
|
||||
|
||||
/**
|
||||
* Move the outlines.
|
||||
* Rotate the outlines.
|
||||
*
|
||||
* @param aCentre is rot centre
|
||||
* @param aAngle is in 0.1 degree
|
||||
*/
|
||||
void Rotate( const VECTOR2I& aCentre, double aAngle ) override;
|
||||
void Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle ) override;
|
||||
|
||||
/**
|
||||
* Flip this object, i.e. change the board side for this object
|
||||
|
|
|
@ -247,10 +247,10 @@ BOOST_AUTO_TEST_CASE( Rotate )
|
|||
|
||||
// Four equivalent 90 degree rotations are an identity.
|
||||
|
||||
item->Rotate( aRef, 900 );
|
||||
item->Rotate( aRef, 900 );
|
||||
item->Rotate( aRef, 900 );
|
||||
item->Rotate( aRef, 900 );
|
||||
item->Rotate( aRef, ANGLE_90 );
|
||||
item->Rotate( aRef, ANGLE_90 );
|
||||
item->Rotate( aRef, ANGLE_90 );
|
||||
item->Rotate( aRef, ANGLE_90 );
|
||||
|
||||
FP_SHAPE* fpShape = dynamic_cast<FP_SHAPE*>( aOriginalItem );
|
||||
|
||||
|
|
Loading…
Reference in New Issue