Some more EDA_ANGLE cleanup.
This commit is contained in:
parent
ef6ce972d6
commit
e84c574830
|
@ -523,12 +523,14 @@ EDA_ANGLE EDA_SHAPE::GetArcAngle() const
|
|||
}
|
||||
|
||||
|
||||
void EDA_SHAPE::SetArcAngleAndEnd( double aAngle, bool aCheckNegativeAngle )
|
||||
void EDA_SHAPE::SetArcAngleAndEnd( const EDA_ANGLE& aAngle, bool aCheckNegativeAngle )
|
||||
{
|
||||
m_end = m_start;
|
||||
RotatePoint( m_end, m_arcCenter, -NormalizeAngle360Max( aAngle ) );
|
||||
EDA_ANGLE angle( aAngle );
|
||||
|
||||
if( aCheckNegativeAngle && aAngle < 0 )
|
||||
m_end = m_start;
|
||||
RotatePoint( m_end, m_arcCenter, -angle.Normalize720() );
|
||||
|
||||
if( aCheckNegativeAngle && aAngle < ANGLE_0 )
|
||||
{
|
||||
std::swap( m_start, m_end );
|
||||
m_endsSwapped = true;
|
||||
|
|
|
@ -317,14 +317,17 @@ void CAIRO_GAL_BASE::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
|
|||
}
|
||||
|
||||
|
||||
void CAIRO_GAL_BASE::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
|
||||
double aEndAngle )
|
||||
void CAIRO_GAL_BASE::DrawArc( const VECTOR2D& aCenterPoint, double aRadius,
|
||||
const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle )
|
||||
{
|
||||
syncLineWidth();
|
||||
|
||||
double startAngle = aStartAngle.AsRadians();
|
||||
double endAngle = aEndAngle.AsRadians();
|
||||
|
||||
// calculate start and end arc angles according to the rotation transform matrix
|
||||
// and normalize:
|
||||
arc_angles_xform_and_normalize( aStartAngle, aEndAngle );
|
||||
arc_angles_xform_and_normalize( startAngle, endAngle );
|
||||
|
||||
double r = xform( aRadius );
|
||||
|
||||
|
@ -342,7 +345,7 @@ void CAIRO_GAL_BASE::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, doub
|
|||
if( m_isFillEnabled )
|
||||
cairo_move_to( m_currentContext, mid.x, mid.y );
|
||||
|
||||
cairo_arc( m_currentContext, mid.x, mid.y, r, aStartAngle, aEndAngle );
|
||||
cairo_arc( m_currentContext, mid.x, mid.y, r, startAngle, endAngle );
|
||||
|
||||
if( m_isFillEnabled )
|
||||
cairo_close_path( m_currentContext );
|
||||
|
@ -354,8 +357,8 @@ void CAIRO_GAL_BASE::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, doub
|
|||
|
||||
|
||||
void CAIRO_GAL_BASE::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
||||
double aStartAngle, double aEndAngle, double aWidth,
|
||||
double aMaxError )
|
||||
const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle,
|
||||
double aWidth, double aMaxError )
|
||||
{
|
||||
// Note: aMaxError is not used because Cairo can draw true arcs
|
||||
if( m_isFillEnabled )
|
||||
|
@ -373,8 +376,8 @@ void CAIRO_GAL_BASE::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadiu
|
|||
|
||||
// calculate start and end arc angles according to the rotation transform matrix
|
||||
// and normalize:
|
||||
double startAngleS = aStartAngle;
|
||||
double endAngleS = aEndAngle;
|
||||
double startAngleS = aStartAngle.AsRadians();
|
||||
double endAngleS = aEndAngle.AsRadians();
|
||||
arc_angles_xform_and_normalize( startAngleS, endAngleS );
|
||||
|
||||
double r = xform( aRadius );
|
||||
|
|
|
@ -803,14 +803,17 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
|
|||
}
|
||||
|
||||
|
||||
void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
|
||||
double aEndAngle )
|
||||
void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius,
|
||||
const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle )
|
||||
{
|
||||
if( aRadius <= 0 )
|
||||
return;
|
||||
|
||||
double startAngle = aStartAngle.AsRadians();
|
||||
double endAngle = aEndAngle.AsRadians();
|
||||
|
||||
// Swap the angles, if start angle is greater than end angle
|
||||
SWAP( aStartAngle, >, aEndAngle );
|
||||
SWAP( startAngle, >, endAngle );
|
||||
|
||||
const double alphaIncrement = calcAngleStep( aRadius );
|
||||
|
||||
|
@ -824,7 +827,7 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
|
|||
m_currentManager->Shader( SHADER_NONE );
|
||||
|
||||
// Triangle fan
|
||||
for( alpha = aStartAngle; ( alpha + alphaIncrement ) < aEndAngle; )
|
||||
for( alpha = startAngle; ( alpha + alphaIncrement ) < endAngle; )
|
||||
{
|
||||
m_currentManager->Reserve( 3 );
|
||||
m_currentManager->Vertex( 0.0, 0.0, m_layerDepth );
|
||||
|
@ -836,7 +839,7 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
|
|||
}
|
||||
|
||||
// The last missing triangle
|
||||
const VECTOR2D endPoint( cos( aEndAngle ) * aRadius, sin( aEndAngle ) * aRadius );
|
||||
const VECTOR2D endPoint( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
|
||||
|
||||
m_currentManager->Reserve( 3 );
|
||||
m_currentManager->Vertex( 0.0, 0.0, m_layerDepth );
|
||||
|
@ -849,10 +852,10 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
|
|||
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
|
||||
m_strokeColor.a );
|
||||
|
||||
VECTOR2D p( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius );
|
||||
VECTOR2D p( cos( startAngle ) * aRadius, sin( startAngle ) * aRadius );
|
||||
double alpha;
|
||||
|
||||
for( alpha = aStartAngle + alphaIncrement; alpha <= aEndAngle; alpha += alphaIncrement )
|
||||
for( alpha = startAngle + alphaIncrement; alpha <= endAngle; alpha += alphaIncrement )
|
||||
{
|
||||
VECTOR2D p_next( cos( alpha ) * aRadius, sin( alpha ) * aRadius );
|
||||
DrawLine( p, p_next );
|
||||
|
@ -861,9 +864,9 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
|
|||
}
|
||||
|
||||
// Draw the last missing part
|
||||
if( alpha != aEndAngle )
|
||||
if( alpha != endAngle )
|
||||
{
|
||||
VECTOR2D p_last( cos( aEndAngle ) * aRadius, sin( aEndAngle ) * aRadius );
|
||||
VECTOR2D p_last( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
|
||||
DrawLine( p, p_last );
|
||||
}
|
||||
}
|
||||
|
@ -873,7 +876,7 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
|
|||
|
||||
|
||||
void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
||||
double aStartAngle, double aEndAngle,
|
||||
const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle,
|
||||
double aWidth, double aMaxError )
|
||||
{
|
||||
if( aRadius <= 0 )
|
||||
|
@ -885,8 +888,11 @@ void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
|||
return;
|
||||
}
|
||||
|
||||
double startAngle = aStartAngle.AsRadians();
|
||||
double endAngle = aEndAngle.AsRadians();
|
||||
|
||||
// Swap the angles, if start angle is greater than end angle
|
||||
SWAP( aStartAngle, >, aEndAngle );
|
||||
SWAP( startAngle, >, endAngle );
|
||||
|
||||
// Calculate the seg count to approximate the arc with aMaxError or less
|
||||
int segCount360 = GetArcToSegmentCount( aRadius, aMaxError, FULL_CIRCLE );
|
||||
|
@ -896,14 +902,14 @@ void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
|||
// Refinement: Use a segment count multiple of 2, because we have a control point
|
||||
// on the middle of the arc, and the look is better if it is on a segment junction
|
||||
// because there is no approx error
|
||||
int seg_count = KiROUND( ( aEndAngle - aStartAngle ) / alphaIncrement );
|
||||
int seg_count = KiROUND( ( endAngle - startAngle ) / alphaIncrement );
|
||||
|
||||
if( seg_count % 2 != 0 )
|
||||
seg_count += 1;
|
||||
|
||||
// Recalculate alphaIncrement with a even integer number of segment
|
||||
if( seg_count )
|
||||
alphaIncrement = ( aEndAngle - aStartAngle ) / seg_count;
|
||||
alphaIncrement = ( endAngle - startAngle ) / seg_count;
|
||||
|
||||
Save();
|
||||
m_currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 );
|
||||
|
@ -914,21 +920,21 @@ void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
|||
m_strokeColor.a );
|
||||
|
||||
double width = aWidth / 2.0;
|
||||
VECTOR2D startPoint( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius );
|
||||
VECTOR2D endPoint( cos( aEndAngle ) * aRadius, sin( aEndAngle ) * aRadius );
|
||||
VECTOR2D startPoint( cos( startAngle ) * aRadius, sin( startAngle ) * aRadius );
|
||||
VECTOR2D endPoint( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
|
||||
|
||||
drawStrokedSemiCircle( startPoint, width, aStartAngle + M_PI );
|
||||
drawStrokedSemiCircle( endPoint, width, aEndAngle );
|
||||
drawStrokedSemiCircle( startPoint, width, startAngle + M_PI );
|
||||
drawStrokedSemiCircle( endPoint, width, endAngle );
|
||||
|
||||
VECTOR2D pOuter( cos( aStartAngle ) * ( aRadius + width ),
|
||||
sin( aStartAngle ) * ( aRadius + width ) );
|
||||
VECTOR2D pOuter( cos( startAngle ) * ( aRadius + width ),
|
||||
sin( startAngle ) * ( aRadius + width ) );
|
||||
|
||||
VECTOR2D pInner( cos( aStartAngle ) * ( aRadius - width ),
|
||||
sin( aStartAngle ) * ( aRadius - width ) );
|
||||
VECTOR2D pInner( cos( startAngle ) * ( aRadius - width ),
|
||||
sin( startAngle ) * ( aRadius - width ) );
|
||||
|
||||
double alpha;
|
||||
|
||||
for( alpha = aStartAngle + alphaIncrement; alpha <= aEndAngle; alpha += alphaIncrement )
|
||||
for( alpha = startAngle + alphaIncrement; alpha <= endAngle; alpha += alphaIncrement )
|
||||
{
|
||||
VECTOR2D pNextOuter( cos( alpha ) * ( aRadius + width ),
|
||||
sin( alpha ) * ( aRadius + width ) );
|
||||
|
@ -943,12 +949,12 @@ void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
|||
}
|
||||
|
||||
// Draw the last missing part
|
||||
if( alpha != aEndAngle )
|
||||
if( alpha != endAngle )
|
||||
{
|
||||
VECTOR2D pLastOuter( cos( aEndAngle ) * ( aRadius + width ),
|
||||
sin( aEndAngle ) * ( aRadius + width ) );
|
||||
VECTOR2D pLastInner( cos( aEndAngle ) * ( aRadius - width ),
|
||||
sin( aEndAngle ) * ( aRadius - width ) );
|
||||
VECTOR2D pLastOuter( cos( endAngle ) * ( aRadius + width ),
|
||||
sin( endAngle ) * ( aRadius + width ) );
|
||||
VECTOR2D pLastInner( cos( endAngle ) * ( aRadius - width ),
|
||||
sin( endAngle ) * ( aRadius - width ) );
|
||||
|
||||
DrawLine( pOuter, pLastOuter );
|
||||
DrawLine( pInner, pLastInner );
|
||||
|
@ -960,10 +966,10 @@ void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
|||
m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a );
|
||||
SetLineWidth( aWidth );
|
||||
|
||||
VECTOR2D p( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius );
|
||||
VECTOR2D p( cos( startAngle ) * aRadius, sin( startAngle ) * aRadius );
|
||||
double alpha;
|
||||
|
||||
for( alpha = aStartAngle + alphaIncrement; alpha <= aEndAngle; alpha += alphaIncrement )
|
||||
for( alpha = startAngle + alphaIncrement; alpha <= endAngle; alpha += alphaIncrement )
|
||||
{
|
||||
VECTOR2D p_next( cos( alpha ) * aRadius, sin( alpha ) * aRadius );
|
||||
DrawLine( p, p_next );
|
||||
|
@ -972,9 +978,9 @@ void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
|||
}
|
||||
|
||||
// Draw the last missing part
|
||||
if( alpha != aEndAngle )
|
||||
if( alpha != endAngle )
|
||||
{
|
||||
VECTOR2D p_last( cos( aEndAngle ) * aRadius, sin( aEndAngle ) * aRadius );
|
||||
VECTOR2D p_last( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
|
||||
DrawLine( p, p_last );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,34 +128,34 @@ void STROKE_PARAMS::Stroke( const SHAPE* aShape, PLOT_DASH_TYPE aLineStyle, int
|
|||
double C = 2.0 * M_PI * r;
|
||||
VECTOR2I center = arc->GetCenter();
|
||||
VECTOR2D startRadial( arc->GetP0() - center );
|
||||
double startAngle = 180.0 / M_PI * atan2( startRadial.y, startRadial.x );
|
||||
EDA_ANGLE startAngle( startRadial );
|
||||
VECTOR2D endRadial( arc->GetP1() - center );
|
||||
double arcEndAngle = 180.0 / M_PI * atan2( endRadial.y, endRadial.x );
|
||||
EDA_ANGLE arcEndAngle( endRadial );
|
||||
|
||||
if( arcEndAngle == startAngle )
|
||||
arcEndAngle = startAngle + 360.0; // ring, not null
|
||||
arcEndAngle = startAngle + ANGLE_360; // ring, not null
|
||||
|
||||
if( startAngle > arcEndAngle )
|
||||
{
|
||||
if( arcEndAngle < 0 )
|
||||
arcEndAngle = NormalizeAngleDegrees( arcEndAngle, 0.0, 360.0 );
|
||||
if( arcEndAngle < ANGLE_0 )
|
||||
arcEndAngle = arcEndAngle.Normalize();
|
||||
else
|
||||
startAngle = NormalizeAngleDegrees( startAngle, -360.0, 0.0 );
|
||||
startAngle = startAngle.Normalize() - ANGLE_360;
|
||||
}
|
||||
|
||||
wxASSERT( startAngle < arcEndAngle );
|
||||
|
||||
for( size_t i = 0; i < 10000 && startAngle < arcEndAngle; ++i )
|
||||
{
|
||||
double theta = 360.0 * strokes[ i % wrapAround ] / C;
|
||||
double endAngle = std::min( startAngle + theta, arcEndAngle );
|
||||
EDA_ANGLE theta = ANGLE_360 * strokes[ i % wrapAround ] / C;
|
||||
EDA_ANGLE endAngle = std::min( startAngle + theta, arcEndAngle );
|
||||
|
||||
if( i % 2 == 0 )
|
||||
{
|
||||
VECTOR2I a( center.x + r * cos( startAngle * M_PI / 180.0 ),
|
||||
center.y + r * sin( startAngle * M_PI / 180.0 ) );
|
||||
VECTOR2I b( center.x + r * cos( endAngle * M_PI / 180.0 ),
|
||||
center.y + r * sin( endAngle * M_PI / 180.0 ) );
|
||||
VECTOR2I a( center.x + r * cos( startAngle.AsRadians() ),
|
||||
center.y + r * sin( startAngle.AsRadians() ) );
|
||||
VECTOR2I b( center.x + r * cos( endAngle.AsRadians() ),
|
||||
center.y + r * sin( endAngle.AsRadians() ) );
|
||||
|
||||
aStroker( a, b );
|
||||
}
|
||||
|
|
|
@ -94,7 +94,8 @@ struct VIEW_OVERLAY::COMMAND_CIRCLE : public VIEW_OVERLAY::COMMAND
|
|||
|
||||
struct VIEW_OVERLAY::COMMAND_ARC : public VIEW_OVERLAY::COMMAND
|
||||
{
|
||||
COMMAND_ARC( const VECTOR2D& aCenter, double aRadius, double aStartAngle, double aEndAngle ) :
|
||||
COMMAND_ARC( const VECTOR2D& aCenter, double aRadius, const EDA_ANGLE& aStartAngle,
|
||||
const EDA_ANGLE& aEndAngle ) :
|
||||
m_center( aCenter ),
|
||||
m_radius( aRadius ),
|
||||
m_startAngle( aStartAngle ),
|
||||
|
@ -108,8 +109,8 @@ struct VIEW_OVERLAY::COMMAND_ARC : public VIEW_OVERLAY::COMMAND
|
|||
|
||||
VECTOR2D m_center;
|
||||
double m_radius;
|
||||
double m_startAngle;
|
||||
double m_endAngle;
|
||||
EDA_ANGLE m_startAngle;
|
||||
EDA_ANGLE m_endAngle;
|
||||
};
|
||||
|
||||
|
||||
|
@ -363,8 +364,8 @@ void VIEW_OVERLAY::Circle( const VECTOR2D& aCenterPoint, double aRadius )
|
|||
}
|
||||
|
||||
|
||||
void VIEW_OVERLAY::Arc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
|
||||
double aEndAngle )
|
||||
void VIEW_OVERLAY::Arc( const VECTOR2D& aCenterPoint, double aRadius, const EDA_ANGLE& aStartAngle,
|
||||
const EDA_ANGLE& aEndAngle )
|
||||
{
|
||||
m_commands.push_back( new COMMAND_ARC( aCenterPoint, aRadius, aStartAngle, aEndAngle ) );
|
||||
}
|
||||
|
|
|
@ -643,8 +643,8 @@ void SCH_PAINTER::draw( const LIB_SHAPE *aShape, int aLayer )
|
|||
|
||||
TRANSFORM().MapAngles( &startAngle, &endAngle );
|
||||
|
||||
m_gal->DrawArc( mapCoords( aShape->GetCenter() ), aShape->GetRadius(),
|
||||
startAngle.AsRadians(), endAngle.AsRadians() );
|
||||
m_gal->DrawArc( mapCoords( aShape->GetCenter() ), aShape->GetRadius(), startAngle,
|
||||
endAngle );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1356,8 +1356,8 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer )
|
|||
EDA_ANGLE endAngle;
|
||||
aShape->CalcArcAngles( startAngle, endAngle );
|
||||
|
||||
m_gal->DrawArc( aShape->GetCenter(), aShape->GetRadius(),
|
||||
startAngle.AsRadians(), endAngle.AsRadians() );
|
||||
m_gal->DrawArc( aShape->GetCenter(), aShape->GetRadius(), startAngle,
|
||||
endAngle );
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -1326,7 +1326,7 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map<wxString, wxString>& aPropertie
|
|||
|
||||
arc->SetCenter( elem.center + m_sheetOffset );
|
||||
arc->SetStart( elem.center + startOffset + m_sheetOffset );
|
||||
arc->SetArcAngleAndEnd( includedAngle.Normalize().AsTenthsOfADegree(), true );
|
||||
arc->SetArcAngleAndEnd( includedAngle.Normalize(), true );
|
||||
|
||||
arc->SetStroke( STROKE_PARAMS( elem.lineWidth, PLOT_DASH_TYPE::SOLID ) );
|
||||
|
||||
|
|
|
@ -83,7 +83,8 @@ bool TRANSFORM::MapAngles( EDA_ANGLE* aAngle1, EDA_ANGLE* aAngle2 ) const
|
|||
|
||||
static const EDA_ANGLE epsilon( 0.1, DEGREES_T );
|
||||
|
||||
double x, y, t;
|
||||
double x, y;
|
||||
VECTOR2D v;
|
||||
bool swap = false;
|
||||
|
||||
EDA_ANGLE delta = *aAngle2 - *aAngle1;
|
||||
|
@ -96,17 +97,13 @@ bool TRANSFORM::MapAngles( EDA_ANGLE* aAngle1, EDA_ANGLE* aAngle2 ) const
|
|||
|
||||
x = cos( aAngle1->AsRadians() );
|
||||
y = sin( aAngle1->AsRadians() );
|
||||
t = x * x1 + y * y1;
|
||||
y = x * x2 + y * y2;
|
||||
x = t;
|
||||
*aAngle1 = EDA_ANGLE( VECTOR2I( x, y ) );
|
||||
v = VECTOR2D( x * x1 + y * y1, x * x2 + y * y2 );
|
||||
*aAngle1 = EDA_ANGLE( v );
|
||||
|
||||
x = cos( aAngle2->AsRadians() );
|
||||
y = sin( aAngle2->AsRadians() );
|
||||
t = x * x1 + y * y1;
|
||||
y = x * x2 + y * y2;
|
||||
x = t;
|
||||
*aAngle2 = EDA_ANGLE( VECTOR2I( x, y ) );
|
||||
v = VECTOR2D( x * x1 + y * y1, x * x2 + y * y2 );
|
||||
*aAngle2 = EDA_ANGLE( v );
|
||||
|
||||
aAngle1->Normalize();
|
||||
aAngle2->Normalize();
|
||||
|
@ -116,9 +113,7 @@ bool TRANSFORM::MapAngles( EDA_ANGLE* aAngle1, EDA_ANGLE* aAngle2 ) const
|
|||
|
||||
if( *aAngle2 - *aAngle1 > ANGLE_180 ) // Need to swap the two angles
|
||||
{
|
||||
EDA_ANGLE temp = *aAngle1;
|
||||
*aAngle1 = *aAngle2;
|
||||
*aAngle2 = temp;
|
||||
std::swap( *aAngle1, *aAngle2 );
|
||||
|
||||
aAngle1->Normalize();
|
||||
aAngle2->Normalize();
|
||||
|
|
|
@ -519,7 +519,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
|
|||
aBuffer.push_back( currpt );
|
||||
|
||||
// Rotate rectangle and move it to the actual start point
|
||||
double angle = ArcTangente( delta.y, delta.x );
|
||||
EDA_ANGLE angle( delta );
|
||||
|
||||
for( unsigned ii = 0; ii < 4; ii++ )
|
||||
{
|
||||
|
|
|
@ -319,18 +319,18 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
|
|||
m_gal->SetIsStroke( !isFilled );
|
||||
m_gal->SetLineWidth( isFilled ? width : m_gerbviewSettings.m_outlineWidth );
|
||||
|
||||
double startAngle = startVec.Angle();
|
||||
double endAngle = endVec.Angle();
|
||||
EDA_ANGLE startAngle( startVec );
|
||||
EDA_ANGLE endAngle( endVec );
|
||||
|
||||
// GAL fills in direction of increasing angle, so we have to convert
|
||||
// the angle from the -PI to PI domain of atan2() to ensure that
|
||||
// the arc goes in the right direction
|
||||
if( startAngle > endAngle )
|
||||
endAngle += (2 * M_PI);
|
||||
endAngle += ANGLE_360;
|
||||
|
||||
// In Gerber, 360-degree arcs are stored in the file with start equal to end
|
||||
if( arcStart == arcEnd )
|
||||
endAngle = startAngle + 2*M_PI;
|
||||
endAngle = startAngle + ANGLE_360;
|
||||
|
||||
m_gal->DrawArcSegment( center, radius, startAngle, endAngle, width, ARC_HIGH_DEF );
|
||||
|
||||
|
|
|
@ -160,10 +160,8 @@ public:
|
|||
|
||||
/**
|
||||
* Set the end point from the angle center and start.
|
||||
*
|
||||
* @param aAngle is tenths of degrees.
|
||||
*/
|
||||
void SetArcAngleAndEnd( double aAngle, bool aCheckNegativeAngle = false );
|
||||
void SetArcAngleAndEnd( const EDA_ANGLE& aAngle, bool aCheckNegativeAngle = false );
|
||||
|
||||
EDA_ANGLE GetArcAngle() const;
|
||||
|
||||
|
|
|
@ -79,12 +79,12 @@ public:
|
|||
|
||||
/// @copydoc GAL::DrawArc()
|
||||
void DrawArc( const VECTOR2D& aCenterPoint, double aRadius,
|
||||
double aStartAngle, double aEndAngle ) override;
|
||||
const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle ) override;
|
||||
|
||||
/// @copydoc GAL::DrawArcSegment()
|
||||
/// Note: aMaxError is not used in Cairo, because Cairo can draw true arcs
|
||||
void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
||||
double aStartAngle, double aEndAngle, double aWidth,
|
||||
const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle, double aWidth,
|
||||
double aMaxError ) override;
|
||||
|
||||
/// @copydoc GAL::DrawRectangle()
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <newstroke_font.h>
|
||||
#include <font/stroke_font.h>
|
||||
#include <eda_rect.h>
|
||||
#include <geometry/eda_angle.h>
|
||||
|
||||
class SHAPE_LINE_CHAIN;
|
||||
class SHAPE_POLY_SET;
|
||||
|
@ -134,8 +135,8 @@ public:
|
|||
* @param aStartAngle is the start angle of the arc.
|
||||
* @param aEndAngle is the end angle of the arc.
|
||||
*/
|
||||
virtual void DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
|
||||
double aEndAngle ) {};
|
||||
virtual void DrawArc( const VECTOR2D& aCenterPoint, double aRadius,
|
||||
const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle ) {};
|
||||
|
||||
/**
|
||||
* Draw an arc segment.
|
||||
|
@ -155,8 +156,9 @@ public:
|
|||
* @param aMaxError is the max allowed error to create segments to approximate a circle.
|
||||
* It has meaning only for back ends that can't draw a true arc, and use segments to approximate.
|
||||
*/
|
||||
virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
|
||||
double aEndAngle, double aWidth, double aMaxError ) {};
|
||||
virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
||||
const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle,
|
||||
double aWidth, double aMaxError ) {};
|
||||
|
||||
/**
|
||||
* Draw a rectangle.
|
||||
|
|
|
@ -126,13 +126,12 @@ public:
|
|||
void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) override;
|
||||
|
||||
/// @copydoc GAL::DrawArc()
|
||||
void DrawArc( const VECTOR2D& aCenterPoint, double aRadius,
|
||||
double aStartAngle, double aEndAngle ) override;
|
||||
void DrawArc( const VECTOR2D& aCenterPoint, double aRadius, const EDA_ANGLE& aStartAngle,
|
||||
const EDA_ANGLE& aEndAngle ) override;
|
||||
|
||||
/// @copydoc GAL::DrawArcSegment()
|
||||
void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
||||
double aStartAngle, double aEndAngle, double aWidth,
|
||||
double aMaxError ) override;
|
||||
void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, const EDA_ANGLE& aStartAngle,
|
||||
const EDA_ANGLE& aEndAngle, double aWidth, double aMaxError ) override;
|
||||
|
||||
/// @copydoc GAL::DrawRectangle()
|
||||
void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) override;
|
||||
|
|
|
@ -80,7 +80,8 @@ public:
|
|||
void Line( const SEG& aSeg );
|
||||
void Segment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, double aWidth );
|
||||
void Circle( const VECTOR2D& aCenterPoint, double aRadius );
|
||||
void Arc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, double aEndAngle );
|
||||
void Arc( const VECTOR2D& aCenterPoint, double aRadius, const EDA_ANGLE& aStartAngle,
|
||||
const EDA_ANGLE& aEndAngle );
|
||||
void Rectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint );
|
||||
void Cross( const VECTOR2D& aP, int aSize );
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
{
|
||||
case RADIANS_T:
|
||||
m_radians = aValue;
|
||||
m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS );
|
||||
m_value = KiROUND( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
{
|
||||
case RADIANS_T:
|
||||
m_radians = aValue;
|
||||
m_value = int( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS );
|
||||
m_value = KiROUND( aValue / TENTHS_OF_A_DEGREE_TO_RADIANS );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -78,6 +78,50 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
explicit EDA_ANGLE( const VECTOR2D& aVector ) :
|
||||
m_value( 0 ),
|
||||
m_radians( 0.0 ),
|
||||
m_initial_type( TENTHS_OF_A_DEGREE_T )
|
||||
{
|
||||
if( aVector.x == 0.0 && aVector.y == 0.0 )
|
||||
{
|
||||
m_value = 0;
|
||||
}
|
||||
else if( aVector.y == 0.0 )
|
||||
{
|
||||
if( aVector.x >= 0 )
|
||||
m_value = 0;
|
||||
else
|
||||
m_value = -1800;
|
||||
}
|
||||
else if( aVector.x == 0.0 )
|
||||
{
|
||||
if( aVector.y >= 0.0 )
|
||||
m_value = 900;
|
||||
else
|
||||
m_value = -900;
|
||||
}
|
||||
else if( aVector.x == aVector.y )
|
||||
{
|
||||
if( aVector.x >= 0.0 )
|
||||
m_value = 450;
|
||||
else
|
||||
m_value = -1800 + 450;
|
||||
}
|
||||
else if( aVector.x == -aVector.y )
|
||||
{
|
||||
if( aVector.x >= 0.0 )
|
||||
m_value = -450;
|
||||
else
|
||||
m_value = 1800 - 450;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_value = KiROUND( atan2( (double) aVector.y, (double) aVector.x )
|
||||
/ TENTHS_OF_A_DEGREE_TO_RADIANS );
|
||||
}
|
||||
}
|
||||
|
||||
explicit EDA_ANGLE( const VECTOR2I& aVector ) :
|
||||
m_value( 0 ),
|
||||
m_radians( 0.0 ),
|
||||
|
@ -119,8 +163,8 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
m_value = atan2( (double) aVector.y, (double) aVector.x )
|
||||
/ TENTHS_OF_A_DEGREE_TO_RADIANS;
|
||||
m_value = KiROUND( atan2( (double) aVector.y, (double) aVector.x )
|
||||
/ TENTHS_OF_A_DEGREE_TO_RADIANS );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -246,33 +246,6 @@ inline double RAD2DECIDEG( double rad ) { return rad * 1800.0 / M_PI; }
|
|||
/* These are templated over T (and not simply double) because Eeschema
|
||||
is still using int for angles in some place */
|
||||
|
||||
/// Normalize angle to be >=-360.0 and <= 360.0
|
||||
/// Angle can be equal to -360 or +360
|
||||
template <class T> inline T NormalizeAngle360Max( T Angle )
|
||||
{
|
||||
while( Angle < -3600 )
|
||||
Angle += 3600;
|
||||
|
||||
while( Angle > 3600 )
|
||||
Angle -= 3600;
|
||||
|
||||
return Angle;
|
||||
}
|
||||
|
||||
/// Normalize angle to be in the 0.0 .. -360.0 range: angle is in 1/10 degrees.
|
||||
template <class T>
|
||||
inline T NormalizeAngleNeg( T Angle )
|
||||
{
|
||||
while( Angle <= -3600 )
|
||||
Angle += 3600;
|
||||
|
||||
while( Angle > 0 )
|
||||
Angle -= 3600;
|
||||
|
||||
return Angle;
|
||||
}
|
||||
|
||||
|
||||
/// Normalize angle to be in the 0.0 .. 360.0 range: angle is in 1/10 degrees.
|
||||
template <class T> inline T NormalizeAnglePos( T Angle )
|
||||
{
|
||||
|
@ -289,18 +262,6 @@ template <class T> inline void NORMALIZE_ANGLE_POS( T& Angle )
|
|||
}
|
||||
|
||||
|
||||
/// Normalize angle to be aMin < angle <= aMax angle is in degrees.
|
||||
inline double NormalizeAngleDegrees( double Angle, double aMin, double aMax )
|
||||
{
|
||||
while( Angle < aMin )
|
||||
Angle += 360.0;
|
||||
|
||||
while( Angle >= aMax )
|
||||
Angle -= 360.0;
|
||||
|
||||
return Angle;
|
||||
}
|
||||
|
||||
/// Normalize angle to be in the -180.0 .. 180.0 range
|
||||
template <class T> inline T NormalizeAngle180( T Angle )
|
||||
{
|
||||
|
|
|
@ -208,14 +208,18 @@ SHAPE_ARC& SHAPE_ARC::ConstructFromStartEndCenter( const VECTOR2I& aStart, const
|
|||
VECTOR2I startLine = aStart - aCenter;
|
||||
VECTOR2I endLine = aEnd - aCenter;
|
||||
|
||||
double startangle = NormalizeAnglePos(RAD2DECIDEG( startLine.Angle() ));
|
||||
double endangle = NormalizeAnglePos(RAD2DECIDEG( endLine.Angle() ));
|
||||
double angle = endangle - startangle;
|
||||
EDA_ANGLE startAngle( startLine );
|
||||
EDA_ANGLE endAngle( endLine );
|
||||
|
||||
startAngle.Normalize();
|
||||
endAngle.Normalize();
|
||||
|
||||
EDA_ANGLE angle = endAngle - startAngle;
|
||||
|
||||
if( aClockwise )
|
||||
angle = NormalizeAngleNeg( angle );
|
||||
angle = angle.Normalize() - ANGLE_360;
|
||||
else
|
||||
angle = NormalizeAnglePos( angle );
|
||||
angle = angle.Normalize();
|
||||
|
||||
m_start = aStart;
|
||||
m_end = aEnd;
|
||||
|
|
|
@ -166,15 +166,15 @@ const VECTOR2I CalcArcMid( const VECTOR2I& aStart, const VECTOR2I& aEnd, const V
|
|||
VECTOR2I startVector = aStart - aCenter;
|
||||
VECTOR2I endVector = aEnd - aCenter;
|
||||
|
||||
double startAngle = ArcTangente( startVector.y, startVector.x );
|
||||
double endAngle = ArcTangente( endVector.y, endVector.x );
|
||||
double midPointRotAngleDeciDeg = NormalizeAngle180( startAngle - endAngle ) / 2;
|
||||
EDA_ANGLE startAngle( startVector );
|
||||
EDA_ANGLE endAngle( endVector );
|
||||
EDA_ANGLE midPointRotAngle = ( startAngle - endAngle ).Normalize180() / 2;
|
||||
|
||||
if( !aMinArcAngle )
|
||||
midPointRotAngleDeciDeg += 1800.0;
|
||||
midPointRotAngle += ANGLE_180;
|
||||
|
||||
VECTOR2I newMid = aStart;
|
||||
RotatePoint( newMid, aCenter, midPointRotAngleDeciDeg );
|
||||
RotatePoint( newMid, aCenter, midPointRotAngle );
|
||||
|
||||
return newMid;
|
||||
}
|
||||
|
|
|
@ -190,26 +190,26 @@ bool DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow()
|
|||
switch( m_shape->GetShape() )
|
||||
{
|
||||
case SHAPE_T::SEGMENT:
|
||||
m_shape->SetStart( wxPoint( m_startX.GetValue(), m_startY.GetValue() ) );
|
||||
m_shape->SetEnd( wxPoint( m_endX.GetValue(), m_endY.GetValue() ) );
|
||||
m_shape->SetStart( VECTOR2I( m_startX.GetValue(), m_startY.GetValue() ) );
|
||||
m_shape->SetEnd( VECTOR2I( m_endX.GetValue(), m_endY.GetValue() ) );
|
||||
break;
|
||||
|
||||
case SHAPE_T::BEZIER:
|
||||
m_shape->SetStart( wxPoint( m_startX.GetValue(), m_startY.GetValue() ) );
|
||||
m_shape->SetEnd( wxPoint( m_endX.GetValue(), m_endY.GetValue() ) );
|
||||
m_shape->SetBezierC1( wxPoint( m_ctrl1X.GetValue(), m_ctrl1Y.GetValue()));
|
||||
m_shape->SetBezierC1( wxPoint( m_ctrl2X.GetValue(), m_ctrl2Y.GetValue()));
|
||||
m_shape->SetStart( VECTOR2I( m_startX.GetValue(), m_startY.GetValue() ) );
|
||||
m_shape->SetEnd( VECTOR2I( m_endX.GetValue(), m_endY.GetValue() ) );
|
||||
m_shape->SetBezierC1( VECTOR2I( m_ctrl1X.GetValue(), m_ctrl1Y.GetValue()));
|
||||
m_shape->SetBezierC1( VECTOR2I( m_ctrl2X.GetValue(), m_ctrl2Y.GetValue()));
|
||||
break;
|
||||
|
||||
case SHAPE_T::ARC:
|
||||
m_shape->SetCenter( wxPoint( m_endX.GetValue(), m_endY.GetValue() ) );
|
||||
m_shape->SetStart( wxPoint( m_startX.GetValue(), m_startY.GetValue() ) );
|
||||
m_shape->SetArcAngleAndEnd( m_radius.GetValue() );
|
||||
m_shape->SetCenter( VECTOR2I( m_endX.GetValue(), m_endY.GetValue() ) );
|
||||
m_shape->SetStart( VECTOR2I( m_startX.GetValue(), m_startY.GetValue() ) );
|
||||
m_shape->SetArcAngleAndEnd( m_radius.GetAngleValue() );
|
||||
break;
|
||||
|
||||
case SHAPE_T::CIRCLE:
|
||||
m_shape->SetStart( wxPoint( m_startX.GetValue(), m_startY.GetValue() ) );
|
||||
m_shape->SetEnd( m_shape->GetStart() + wxPoint( m_radius.GetValue(), 0 ) );
|
||||
m_shape->SetStart( VECTOR2I( m_startX.GetValue(), m_startY.GetValue() ) );
|
||||
m_shape->SetEnd( m_shape->GetStart() + VECTOR2I( m_radius.GetValue(), 0 ) );
|
||||
break;
|
||||
|
||||
case SHAPE_T::POLY:
|
||||
|
|
|
@ -184,12 +184,14 @@ VECTOR2I FP_SHAPE::GetArcMid0() const
|
|||
}
|
||||
|
||||
|
||||
void FP_SHAPE::SetArcAngleAndEnd0( double aAngle, bool aCheckNegativeAngle )
|
||||
void FP_SHAPE::SetArcAngleAndEnd0( const EDA_ANGLE& aAngle, bool aCheckNegativeAngle )
|
||||
{
|
||||
m_end0 = m_start0;
|
||||
RotatePoint( m_end0, m_arcCenter0, -NormalizeAngle360Max( aAngle ) );
|
||||
EDA_ANGLE angle( aAngle );
|
||||
|
||||
if( aCheckNegativeAngle && aAngle < 0 )
|
||||
m_end0 = m_start0;
|
||||
RotatePoint( m_end0, m_arcCenter0, -angle.Normalize720() );
|
||||
|
||||
if( aCheckNegativeAngle && aAngle < ANGLE_0 )
|
||||
std::swap( m_start0, m_end0 );
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
* Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
|
||||
* @param aAngle is tenths of degrees, but will soon be degrees.
|
||||
*/
|
||||
void SetArcAngleAndEnd0( double aAngle, bool aCheckNegativeAngle = false );
|
||||
void SetArcAngleAndEnd0( const EDA_ANGLE& aAngle, bool aCheckNegativeAngle = false );
|
||||
|
||||
void SetArcGeometry0( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd );
|
||||
|
||||
|
|
|
@ -269,8 +269,8 @@ public:
|
|||
void AddPrimitiveCircle( const VECTOR2I& aCenter, int aRadius, int aThickness, bool aFilled );
|
||||
void AddPrimitiveRect( const VECTOR2I& aStart, const VECTOR2I& aEnd, int aThickness,
|
||||
bool aFilled );
|
||||
void AddPrimitiveArc( const VECTOR2I& aCenter, const VECTOR2I& aStart, int aArcAngle,
|
||||
int aThickness );
|
||||
void AddPrimitiveArc( const VECTOR2I& aCenter, const VECTOR2I& aStart,
|
||||
const EDA_ANGLE& aArcAngle, int aThickness );
|
||||
void AddPrimitiveCurve( const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCtrl1,
|
||||
const VECTOR2I& aCtrl2, int aThickness );
|
||||
|
||||
|
|
|
@ -80,8 +80,8 @@ void PAD::AddPrimitiveSegment( const VECTOR2I& aStart, const VECTOR2I& aEnd, int
|
|||
}
|
||||
|
||||
|
||||
void PAD::AddPrimitiveArc( const VECTOR2I& aCenter, const VECTOR2I& aStart, int aArcAngle,
|
||||
int aThickness )
|
||||
void PAD::AddPrimitiveArc( const VECTOR2I& aCenter, const VECTOR2I& aStart,
|
||||
const EDA_ANGLE& aArcAngle, int aThickness )
|
||||
{
|
||||
PCB_SHAPE* item = new PCB_SHAPE( nullptr, SHAPE_T::ARC );
|
||||
item->SetFilled( false );
|
||||
|
|
|
@ -670,8 +670,8 @@ void PCB_PAINTER::draw( const PCB_ARC* aArc, int aLayer )
|
|||
m_gal->SetIsFill( not outline_mode );
|
||||
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
||||
|
||||
m_gal->DrawArcSegment( center, radius, start_angle.AsRadians(),
|
||||
( start_angle + angle ).AsRadians(), width, m_maxError );
|
||||
m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle, width,
|
||||
m_maxError );
|
||||
}
|
||||
|
||||
// Clearance lines
|
||||
|
@ -686,9 +686,8 @@ void PCB_PAINTER::draw( const PCB_ARC* aArc, int aLayer )
|
|||
m_gal->SetIsStroke( true );
|
||||
m_gal->SetStrokeColor( color );
|
||||
|
||||
m_gal->DrawArcSegment( center, radius, start_angle.AsRadians(),
|
||||
( start_angle + angle ).AsRadians(), width + clearance * 2,
|
||||
m_maxError );
|
||||
m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle,
|
||||
width + clearance * 2, m_maxError );
|
||||
}
|
||||
|
||||
// Debug only: enable this code only to test the TransformArcToPolygon function
|
||||
|
@ -829,22 +828,22 @@ void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
|
|||
if( !outline_mode )
|
||||
m_gal->SetLineWidth( ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0 );
|
||||
|
||||
m_gal->DrawArc( center, radius, M_PI * -0.375, M_PI * 0.375 );
|
||||
m_gal->DrawArc( center, radius, M_PI * 0.625, M_PI * 1.375 );
|
||||
m_gal->DrawArc( center, radius, EDA_ANGLE( -60, DEGREES_T ), EDA_ANGLE( 60, DEGREES_T ) );
|
||||
m_gal->DrawArc( center, radius, EDA_ANGLE( 120, DEGREES_T ), EDA_ANGLE( 240, DEGREES_T ) );
|
||||
|
||||
if( outline_mode )
|
||||
m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, layerTop ) );
|
||||
else
|
||||
m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerTop ) );
|
||||
|
||||
m_gal->DrawArc( center, radius, M_PI * 1.375, M_PI * 1.625 );
|
||||
m_gal->DrawArc( center, radius, EDA_ANGLE( 240, DEGREES_T ), EDA_ANGLE( 300, DEGREES_T ) );
|
||||
|
||||
if( outline_mode )
|
||||
m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
|
||||
else
|
||||
m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
|
||||
|
||||
m_gal->DrawArc( center, radius, M_PI * 0.375, M_PI * 0.625 );
|
||||
m_gal->DrawArc( center, radius, EDA_ANGLE( 60, DEGREES_T ), EDA_ANGLE( 120, DEGREES_T ) );
|
||||
}
|
||||
|
||||
// Clearance lines
|
||||
|
@ -1407,18 +1406,16 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
|
|||
|
||||
if( outline_mode )
|
||||
{
|
||||
m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(),
|
||||
startAngle.AsRadians(), endAngle.AsRadians(), thickness,
|
||||
m_maxError );
|
||||
m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
|
||||
endAngle, thickness, m_maxError );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gal->SetIsFill( true );
|
||||
m_gal->SetIsStroke( false );
|
||||
|
||||
m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(),
|
||||
startAngle.AsRadians(), endAngle.AsRadians(), thickness,
|
||||
m_maxError );
|
||||
m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
|
||||
endAngle, thickness, m_maxError );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -967,6 +967,19 @@ void ALTIUM_PCB::ParseComponents6Data( const CFB::CompoundFileReader& aReader,
|
|||
}
|
||||
|
||||
|
||||
/// Normalize angle to be aMin < angle <= aMax angle is in degrees.
|
||||
double normalizeAngleDegrees( double Angle, double aMin, double aMax )
|
||||
{
|
||||
while( Angle < aMin )
|
||||
Angle += 360.0;
|
||||
|
||||
while( Angle >= aMax )
|
||||
Angle -= 360.0;
|
||||
|
||||
return Angle;
|
||||
}
|
||||
|
||||
|
||||
void ALTIUM_PCB::ParseComponentsBodies6Data( const CFB::CompoundFileReader& aReader,
|
||||
const CFB::COMPOUND_FILE_ENTRY* aEntry )
|
||||
{
|
||||
|
@ -1023,11 +1036,12 @@ void ALTIUM_PCB::ParseComponentsBodies6Data( const CFB::CompoundFileReader& aRea
|
|||
|
||||
RotatePoint( &modelSettings.m_Offset.x, &modelSettings.m_Offset.y, orientation );
|
||||
|
||||
modelSettings.m_Rotation.x = NormalizeAngleDegrees( -elem.modelRotation.x, -180, 180 );
|
||||
modelSettings.m_Rotation.y = NormalizeAngleDegrees( -elem.modelRotation.y, -180, 180 );
|
||||
modelSettings.m_Rotation.z = NormalizeAngleDegrees( -elem.modelRotation.z
|
||||
modelSettings.m_Rotation.x = normalizeAngleDegrees( -elem.modelRotation.x, -180, 180 );
|
||||
modelSettings.m_Rotation.y = normalizeAngleDegrees( -elem.modelRotation.y, -180, 180 );
|
||||
modelSettings.m_Rotation.z = normalizeAngleDegrees( -elem.modelRotation.z
|
||||
+ elem.rotation
|
||||
+ orientation.AsDegrees(), -180, 180 );
|
||||
+ orientation.AsDegrees(),
|
||||
-180, 180 );
|
||||
modelSettings.m_Opacity = elem.bodyOpacity;
|
||||
|
||||
footprint->Models().push_back( modelSettings );
|
||||
|
@ -1920,7 +1934,7 @@ void ALTIUM_PCB::ParseArcs6Data( const CFB::CompoundFileReader& aReader,
|
|||
|
||||
shape.SetCenter( elem.center );
|
||||
shape.SetStart( elem.center + startOffset );
|
||||
shape.SetArcAngleAndEnd( includedAngle.Normalize().AsTenthsOfADegree(), true );
|
||||
shape.SetArcAngleAndEnd( includedAngle.Normalize(), true );
|
||||
};
|
||||
|
||||
ALTIUM_PARSER reader( aReader, aEntry );
|
||||
|
|
|
@ -2857,9 +2857,9 @@ PCB_SHAPE* CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex( const POINT& aCadstar
|
|||
// with opposite start/end points and same centre point)
|
||||
|
||||
if( cw )
|
||||
shape->SetArcAngleAndEnd( arcAngle.Normalize().AsTenthsOfADegree() );
|
||||
shape->SetArcAngleAndEnd( arcAngle.Normalize() );
|
||||
else
|
||||
shape->SetArcAngleAndEnd( -arcAngle.Normalize().AsTenthsOfADegree(), true );
|
||||
shape->SetArcAngleAndEnd( -arcAngle.Normalize(), true );
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -726,7 +726,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
|||
shape->SetShape( SHAPE_T::ARC );
|
||||
shape->SetCenter( center );
|
||||
shape->SetStart( start );
|
||||
shape->SetArcAngleAndEnd( *w.curve * -10.0, true ); // KiCad rotates the other way
|
||||
shape->SetArcAngleAndEnd( -EDA_ANGLE( *w.curve, DEGREES_T ), true ); // KiCad rotates the other way
|
||||
}
|
||||
|
||||
shape->SetLayer( layer );
|
||||
|
@ -1801,7 +1801,7 @@ void EAGLE_PLUGIN::packageWire( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const
|
|||
|
||||
dwg->SetCenter0( center );
|
||||
dwg->SetStart0( start );
|
||||
dwg->SetArcAngleAndEnd0( *w.curve * -10.0, true ); // KiCad rotates the other way
|
||||
dwg->SetArcAngleAndEnd0( -EDA_ANGLE( *w.curve, DEGREES_T ), true ); // KiCad rotates the other way
|
||||
}
|
||||
|
||||
dwg->SetLayer( layer );
|
||||
|
|
|
@ -501,13 +501,14 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader )
|
|||
shape->SetCenter0( centre );
|
||||
|
||||
// Pcbnew start angles are inverted and 180 degrees from Geda PCB angles.
|
||||
double start_angle = parseInt( parameters[6], -10.0 ) + 1800.0;
|
||||
EDA_ANGLE start_angle( (int) parseInt( parameters[6], -10.0 ), TENTHS_OF_A_DEGREE_T );
|
||||
start_angle += ANGLE_180;
|
||||
|
||||
// Pcbnew delta angle direction is the opposite of Geda PCB delta angles.
|
||||
double sweep_angle = parseInt( parameters[7], -10.0 );
|
||||
EDA_ANGLE sweep_angle( (int) parseInt( parameters[7], -10.0 ), TENTHS_OF_A_DEGREE_T );
|
||||
|
||||
// Geda PCB does not support circles.
|
||||
if( sweep_angle == -3600.0 )
|
||||
if( sweep_angle == -ANGLE_360 )
|
||||
shape->SetShape( SHAPE_T::CIRCLE );
|
||||
|
||||
// Calculate start point coordinate of arc
|
||||
|
|
|
@ -542,9 +542,9 @@ void PCB_PARSER::parseRenderCache( EDA_TEXT* text )
|
|||
|
||||
NeedSYMBOLorNUMBER();
|
||||
wxString cacheText = FROM_UTF8( CurText() );
|
||||
double cacheAngle = parseAngle( "render cache angle" );
|
||||
EDA_ANGLE cacheAngle( parseDouble( "render cache angle" ), DEGREES_T );
|
||||
|
||||
text->SetupRenderCache( cacheText, EDA_ANGLE( cacheAngle, TENTHS_OF_A_DEGREE_T ) );
|
||||
text->SetupRenderCache( cacheText, cacheAngle );
|
||||
|
||||
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
||||
{
|
||||
|
@ -2675,7 +2675,6 @@ PCB_SHAPE* PCB_PARSER::parsePCB_SHAPE()
|
|||
}
|
||||
|
||||
bool foundFill = false;
|
||||
double angle;
|
||||
|
||||
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
||||
{
|
||||
|
@ -2689,7 +2688,7 @@ PCB_SHAPE* PCB_PARSER::parsePCB_SHAPE()
|
|||
case T_angle:
|
||||
if( m_requiredVersion <= LEGACY_ARC_FORMATTING )
|
||||
{
|
||||
angle = parseAngle( "arc angle" );
|
||||
EDA_ANGLE angle( parseDouble( "arc angle" ), DEGREES_T );
|
||||
|
||||
if( shape->GetShape() == SHAPE_T::ARC )
|
||||
shape->SetArcAngleAndEnd( angle, true );
|
||||
|
@ -2831,7 +2830,7 @@ PCB_TEXT* PCB_PARSER::parsePCB_TEXT()
|
|||
|
||||
if( token == T_NUMBER )
|
||||
{
|
||||
text->SetTextAngle( EDA_ANGLE( parseAngle(), TENTHS_OF_A_DEGREE_T ) );
|
||||
text->SetTextAngle( EDA_ANGLE( parseDouble(), DEGREES_T ) );
|
||||
NeedRIGHT();
|
||||
}
|
||||
else if( token != T_RIGHT )
|
||||
|
@ -3425,7 +3424,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
|
|||
|
||||
if( token == T_NUMBER )
|
||||
{
|
||||
footprint->SetOrientation( EDA_ANGLE( parseAngle(), TENTHS_OF_A_DEGREE_T ) );
|
||||
footprint->SetOrientation( EDA_ANGLE( parseDouble(), DEGREES_T ) );
|
||||
NeedRIGHT();
|
||||
}
|
||||
else if( token != T_RIGHT )
|
||||
|
@ -3735,7 +3734,7 @@ FP_TEXT* PCB_PARSER::parseFP_TEXT()
|
|||
|
||||
if( CurTok() == T_NUMBER )
|
||||
{
|
||||
text->SetTextAngle( EDA_ANGLE( parseAngle(), TENTHS_OF_A_DEGREE_T ) );
|
||||
text->SetTextAngle( EDA_ANGLE( parseDouble(), DEGREES_T ) );
|
||||
NextTok();
|
||||
}
|
||||
|
||||
|
@ -3845,7 +3844,7 @@ FP_SHAPE* PCB_PARSER::parseFP_SHAPE()
|
|||
if( token != T_angle )
|
||||
Expecting( T_angle );
|
||||
|
||||
shape->SetArcAngleAndEnd0( parseAngle( "segment angle" ), true );
|
||||
shape->SetArcAngleAndEnd0( EDA_ANGLE( parseDouble( "arc angle" ), DEGREES_T ), true );
|
||||
NeedRIGHT();
|
||||
}
|
||||
else
|
||||
|
@ -4273,7 +4272,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
|
|||
|
||||
if( token == T_NUMBER )
|
||||
{
|
||||
pad->SetOrientation( EDA_ANGLE( parseAngle(), TENTHS_OF_A_DEGREE_T ) );
|
||||
pad->SetOrientation( EDA_ANGLE( parseDouble(), DEGREES_T ) );
|
||||
NeedRIGHT();
|
||||
}
|
||||
else if( token != T_RIGHT )
|
||||
|
@ -4437,7 +4436,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
|
|||
break;
|
||||
|
||||
case T_thermal_bridge_angle:
|
||||
pad->SetThermalSpokeAngle( EDA_ANGLE( parseAngle( "thermal spoke angle value" ), TENTHS_OF_A_DEGREE_T ) );
|
||||
pad->SetThermalSpokeAngle( EDA_ANGLE( parseDouble( "thermal spoke angle" ), DEGREES_T ) );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
@ -4513,36 +4512,14 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
|
|||
|
||||
switch( token )
|
||||
{
|
||||
case T_pad_prop_bga:
|
||||
pad->SetProperty( PAD_PROP::BGA );
|
||||
break;
|
||||
|
||||
case T_pad_prop_fiducial_glob:
|
||||
pad->SetProperty( PAD_PROP::FIDUCIAL_GLBL );
|
||||
break;
|
||||
|
||||
case T_pad_prop_fiducial_loc:
|
||||
pad->SetProperty( PAD_PROP::FIDUCIAL_LOCAL );
|
||||
break;
|
||||
|
||||
case T_pad_prop_testpoint:
|
||||
pad->SetProperty( PAD_PROP::TESTPOINT );
|
||||
break;
|
||||
|
||||
case T_pad_prop_castellated:
|
||||
pad->SetProperty( PAD_PROP::CASTELLATED );
|
||||
break;
|
||||
|
||||
case T_pad_prop_heatsink:
|
||||
pad->SetProperty( PAD_PROP::HEATSINK );
|
||||
break;
|
||||
|
||||
case T_none:
|
||||
pad->SetProperty( PAD_PROP::NONE );
|
||||
break;
|
||||
|
||||
case T_RIGHT:
|
||||
break;
|
||||
case T_pad_prop_bga: pad->SetProperty( PAD_PROP::BGA ); break;
|
||||
case T_pad_prop_fiducial_glob: pad->SetProperty( PAD_PROP::FIDUCIAL_GLBL ); break;
|
||||
case T_pad_prop_fiducial_loc: pad->SetProperty( PAD_PROP::FIDUCIAL_LOCAL ); break;
|
||||
case T_pad_prop_testpoint: pad->SetProperty( PAD_PROP::TESTPOINT ); break;
|
||||
case T_pad_prop_castellated: pad->SetProperty( PAD_PROP::CASTELLATED ); break;
|
||||
case T_pad_prop_heatsink: pad->SetProperty( PAD_PROP::HEATSINK ); break;
|
||||
case T_none: pad->SetProperty( PAD_PROP::NONE ); break;
|
||||
case T_RIGHT: break;
|
||||
|
||||
default:
|
||||
#if 0 // Currently: skip unknown property
|
||||
|
@ -4577,8 +4554,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
|
|||
case T_gr_arc:
|
||||
dummyShape = parsePCB_SHAPE();
|
||||
pad->AddPrimitiveArc( dummyShape->GetCenter(), dummyShape->GetStart(),
|
||||
dummyShape->GetArcAngle().AsTenthsOfADegree(),
|
||||
dummyShape->GetWidth() );
|
||||
dummyShape->GetArcAngle(), dummyShape->GetWidth() );
|
||||
break;
|
||||
|
||||
case T_gr_line:
|
||||
|
@ -4609,8 +4585,8 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
|
|||
case T_gr_curve:
|
||||
dummyShape = parsePCB_SHAPE();
|
||||
pad->AddPrimitiveCurve( dummyShape->GetStart(), dummyShape->GetEnd(),
|
||||
dummyShape->GetBezierC1(),
|
||||
dummyShape->GetBezierC2(), dummyShape->GetWidth() );
|
||||
dummyShape->GetBezierC1(), dummyShape->GetBezierC2(),
|
||||
dummyShape->GetWidth() );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -289,16 +289,6 @@ private:
|
|||
return parseDouble( GetTokenText( aToken ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse angles into deci-degrees.
|
||||
*/
|
||||
double parseAngle() { return parseDouble() * 10.0; }
|
||||
|
||||
inline double parseAngle( const char* aExpected )
|
||||
{
|
||||
return parseDouble( aExpected ) * 10.0;
|
||||
}
|
||||
|
||||
int parseBoardUnits();
|
||||
|
||||
int parseBoardUnits( const char* aExpected );
|
||||
|
|
|
@ -1337,7 +1337,7 @@ void LEGACY_PLUGIN::loadPAD( FOOTPRINT* aFootprint )
|
|||
BIU size_y = biuParse( data, &data );
|
||||
BIU delta_x = biuParse( data, &data );
|
||||
BIU delta_y = biuParse( data, &data );
|
||||
double orient = degParse( data );
|
||||
EDA_ANGLE orient = degParse( data );
|
||||
|
||||
switch( padchar )
|
||||
{
|
||||
|
@ -1376,7 +1376,7 @@ void LEGACY_PLUGIN::loadPAD( FOOTPRINT* aFootprint )
|
|||
pad->SetShape( static_cast<PAD_SHAPE>( padshape ) );
|
||||
pad->SetSize( wxSize( size_x, size_y ) );
|
||||
pad->SetDelta( wxSize( delta_x, delta_y ) );
|
||||
pad->SetOrientation( EDA_ANGLE( orient, TENTHS_OF_A_DEGREE_T ) );
|
||||
pad->SetOrientation( orient );
|
||||
}
|
||||
else if( TESTLINE( "Dr" ) ) // (Dr)ill
|
||||
{
|
||||
|
@ -1558,7 +1558,7 @@ void LEGACY_PLUGIN::loadFP_SHAPE( FOOTPRINT* aFootprint )
|
|||
BIU center0_y = biuParse( data, &data );
|
||||
BIU start0_x = biuParse( data, &data );
|
||||
BIU start0_y = biuParse( data, &data );
|
||||
double angle = degParse( data, &data );
|
||||
EDA_ANGLE angle = degParse( data, &data );
|
||||
|
||||
width = biuParse( data, &data );
|
||||
layer = intParse( data );
|
||||
|
@ -1668,7 +1668,7 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( FP_TEXT* aText )
|
|||
BIU pos0_y = biuParse( data, &data );
|
||||
BIU size0_y = biuParse( data, &data );
|
||||
BIU size0_x = biuParse( data, &data );
|
||||
EDA_ANGLE orient = EDA_ANGLE( degParse( data, &data ), TENTHS_OF_A_DEGREE_T );
|
||||
EDA_ANGLE orient = degParse( data, &data );
|
||||
BIU thickn = biuParse( data, &data );
|
||||
|
||||
// read the quoted text before the first call to strtok() which introduces
|
||||
|
@ -1822,7 +1822,6 @@ void LEGACY_PLUGIN::loadPCB_LINE()
|
|||
{
|
||||
BIU x = 0;
|
||||
BIU y;
|
||||
double angle;
|
||||
|
||||
data = strtok_r( line + SZ( "De" ), delims, &saveptr );
|
||||
|
||||
|
@ -1846,21 +1845,24 @@ void LEGACY_PLUGIN::loadPCB_LINE()
|
|||
ignore_unused( intParse( data ) );
|
||||
break;
|
||||
case 2:
|
||||
angle = degParse( data );
|
||||
{
|
||||
EDA_ANGLE angle = degParse( data );
|
||||
|
||||
if( dseg->GetShape() == SHAPE_T::ARC )
|
||||
dseg->SetArcAngleAndEnd( angle, true ); // m_Angle
|
||||
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
const_cast<KIID&>( dseg->m_Uuid ) = KIID( data );
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
EDA_ITEM_FLAGS state;
|
||||
state = static_cast<EDA_ITEM_FLAGS>( hexParse( data ) );
|
||||
dseg->SetState( state, true );
|
||||
break;
|
||||
|
||||
}
|
||||
// Bezier Control Points
|
||||
case 5:
|
||||
x = biuParse( data );
|
||||
|
@ -1869,7 +1871,6 @@ void LEGACY_PLUGIN::loadPCB_LINE()
|
|||
y = biuParse( data );
|
||||
dseg->SetBezierC1( VECTOR2I( x, y ) );
|
||||
break;
|
||||
|
||||
case 7:
|
||||
x = biuParse( data );
|
||||
break;
|
||||
|
@ -2015,7 +2016,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT()
|
|||
size.y = biuParse( data, &data );
|
||||
|
||||
BIU thickn = biuParse( data, &data );
|
||||
EDA_ANGLE angle = EDA_ANGLE( degParse( data ), TENTHS_OF_A_DEGREE_T );
|
||||
EDA_ANGLE angle = degParse( data );
|
||||
|
||||
pcbtxt->SetTextSize( size );
|
||||
pcbtxt->SetTextThickness( thickn );
|
||||
|
@ -2648,7 +2649,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
|
|||
BIU width = biuParse( data, &data );
|
||||
BIU height = biuParse( data, &data );
|
||||
BIU thickn = biuParse( data, &data );
|
||||
EDA_ANGLE orient = EDA_ANGLE( degParse( data, &data ), TENTHS_OF_A_DEGREE_T );
|
||||
EDA_ANGLE orient = degParse( data, &data );
|
||||
char* mirror = strtok_r( (char*) data, delims, (char**) &data );
|
||||
|
||||
dim->Text().SetTextPos( VECTOR2I( pos_x, pos_y ) );
|
||||
|
@ -2808,7 +2809,7 @@ BIU LEGACY_PLUGIN::biuParse( const char* aValue, const char** nptrptr )
|
|||
}
|
||||
|
||||
|
||||
double LEGACY_PLUGIN::degParse( const char* aValue, const char** nptrptr )
|
||||
EDA_ANGLE LEGACY_PLUGIN::degParse( const char* aValue, const char** nptrptr )
|
||||
{
|
||||
char* nptr;
|
||||
|
||||
|
@ -2839,7 +2840,7 @@ double LEGACY_PLUGIN::degParse( const char* aValue, const char** nptrptr )
|
|||
if( nptrptr )
|
||||
*nptrptr = nptr;
|
||||
|
||||
return fval;
|
||||
return EDA_ANGLE( fval, TENTHS_OF_A_DEGREE_T );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <string>
|
||||
#include <layer_ids.h>
|
||||
#include <memory>
|
||||
#include <geometry/eda_angle.h>
|
||||
|
||||
|
||||
// FOOTPRINT_LIBRARY_HEADER_CNT gives the number of characters to compare to detect
|
||||
|
@ -131,18 +132,14 @@ protected:
|
|||
BIU biuParse( const char* aValue, const char** nptrptr = nullptr );
|
||||
|
||||
/**
|
||||
* Parse an ASCII decimal floating point value which is certainly an angle.
|
||||
*
|
||||
* This is a dedicated function for encapsulating support for the migration from
|
||||
* tenths of degrees to degrees in floating point. This function is the complement of
|
||||
* fmtDEG(). One has to know what the other is doing.
|
||||
* Parse an ASCII decimal floating point value which is certainly an angle in tenths of
|
||||
* a degree.
|
||||
*
|
||||
* @param aValue is the ASCII value in C locale form with possible leading whitespace.
|
||||
* @param nptrptr may be NULL, but if not, then it tells where to put a pointer to the
|
||||
* next unconsumed input text. See "man strtod" for more information.
|
||||
* @return the string converted to a primitive double type
|
||||
*/
|
||||
double degParse( const char* aValue, const char** nptrptr = nullptr );
|
||||
EDA_ANGLE degParse( const char* aValue, const char** nptrptr = nullptr );
|
||||
|
||||
void checkVersion();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ PCB_ARC::PCB_ARC( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
|
|||
m_objType = wxT( 'A' );
|
||||
m_StartX = 0;
|
||||
m_StartY = 0;
|
||||
m_Angle = 0;
|
||||
m_Angle = ANGLE_0;
|
||||
m_Width = 0;
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,7 @@ void PCB_ARC::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
|
|||
{
|
||||
XNODE* lNode;
|
||||
int r = 0;
|
||||
int endX = 0;
|
||||
int endY = 0;
|
||||
VECTOR2I end;
|
||||
|
||||
m_PCadLayer = aLayer;
|
||||
m_KiCadLayer = GetKiCadLayer();
|
||||
|
@ -96,19 +95,25 @@ void PCB_ARC::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
|
|||
lNode = lNode->GetNext();
|
||||
|
||||
if( lNode )
|
||||
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &endX, &endY, aActualConversion );
|
||||
|
||||
if( m_StartX == endX && m_StartY == endY )
|
||||
{
|
||||
m_Angle = 3600;
|
||||
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &end.x, &end.y,
|
||||
aActualConversion );
|
||||
}
|
||||
|
||||
VECTOR2I position( m_positionX, m_positionY );
|
||||
VECTOR2I start( m_StartX, m_StartY );
|
||||
|
||||
if( start == end )
|
||||
{
|
||||
m_Angle = ANGLE_360;
|
||||
}
|
||||
else
|
||||
{
|
||||
double alpha1 = ArcTangente( m_StartY - m_positionY, m_StartX - m_positionX );
|
||||
double alpha2 = ArcTangente( endY - m_positionY, endX - m_positionX );
|
||||
EDA_ANGLE alpha1( start - position );
|
||||
EDA_ANGLE alpha2( end - position );
|
||||
m_Angle = alpha1 - alpha2;
|
||||
|
||||
NORMALIZE_ANGLE_POS( m_Angle );
|
||||
m_Angle.Normalize();
|
||||
}
|
||||
}
|
||||
else if( aNode->GetName() == wxT( "arc" ) )
|
||||
|
@ -140,7 +145,7 @@ void PCB_ARC::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
|
|||
lNode = FindNode( aNode, wxT( "sweepAngle" ) );
|
||||
|
||||
if( lNode )
|
||||
m_Angle = StrToInt1Units( lNode->GetNodeContent() );
|
||||
m_Angle = EDA_ANGLE( StrToInt1Units( lNode->GetNodeContent() ), TENTHS_OF_A_DEGREE_T );
|
||||
|
||||
m_StartX = m_positionX + KiROUND( r * cos( a.AsRadians() ) );
|
||||
m_StartY = m_positionY - KiROUND( r * sin( a.AsRadians() ) );
|
||||
|
@ -204,7 +209,7 @@ void PCB_ARC::AddToBoard()
|
|||
|
||||
bool PCB_ARC::IsCircle()
|
||||
{
|
||||
return ( m_Angle == 3600 );
|
||||
return ( m_Angle == ANGLE_360 );
|
||||
}
|
||||
|
||||
} // namespace PCAD2KICAD
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
int m_StartX;
|
||||
int m_StartY;
|
||||
double m_Angle;
|
||||
EDA_ANGLE m_Angle;
|
||||
int m_Width;
|
||||
|
||||
private:
|
||||
|
|
|
@ -185,9 +185,8 @@ void ROUTER_PREVIEW_ITEM::drawLineChain( const SHAPE_LINE_CHAIN_BASE* aL, KIGFX:
|
|||
for( size_t s = 0; lineChain && s < lineChain->ArcCount(); s++ )
|
||||
{
|
||||
const SHAPE_ARC& arc = lineChain->CArcs()[s];
|
||||
|
||||
double start_angle = arc.GetStartAngle().AsRadians();
|
||||
double angle = arc.GetCentralAngle().AsRadians();
|
||||
EDA_ANGLE start_angle = arc.GetStartAngle();
|
||||
EDA_ANGLE angle = arc.GetCentralAngle();
|
||||
|
||||
gal->DrawArc( arc.GetCenter(), arc.GetRadius(), start_angle, start_angle + angle);
|
||||
}
|
||||
|
@ -355,9 +354,8 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons
|
|||
{
|
||||
const SHAPE_ARC* arc = static_cast<const SHAPE_ARC*>( aShape );
|
||||
const int w = arc->GetWidth();
|
||||
|
||||
double start_angle = arc->GetStartAngle().AsRadians();
|
||||
double angle = arc->GetCentralAngle().AsRadians();
|
||||
EDA_ANGLE start_angle = arc->GetStartAngle();
|
||||
EDA_ANGLE angle = arc->GetCentralAngle();
|
||||
|
||||
gal->SetIsFill( false );
|
||||
gal->SetIsStroke( true );
|
||||
|
|
|
@ -1947,7 +1947,7 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool
|
|||
{
|
||||
if( arcManager.GetStep() == KIGFX::PREVIEW::ARC_GEOM_MANAGER::SET_START )
|
||||
{
|
||||
graphic->SetArcAngleAndEnd( 900 );
|
||||
graphic->SetArcAngleAndEnd( ANGLE_90 );
|
||||
frame()->OnEditItemRequest( graphic );
|
||||
m_view->Update( &preview );
|
||||
frame()->SetMsgPanel( graphic );
|
||||
|
|
|
@ -57,13 +57,13 @@ void DrawPolyline( FOOTPRINT& aFootprint, const std::vector<VECTOR2I>& aPts, int
|
|||
|
||||
|
||||
void DrawArc( FOOTPRINT& aFootprint, const VECTOR2I& aCentre, const VECTOR2I& aStart,
|
||||
double aAngle, int aWidth, PCB_LAYER_ID aLayer )
|
||||
const EDA_ANGLE& aAngle, int aWidth, PCB_LAYER_ID aLayer )
|
||||
{
|
||||
std::unique_ptr<FP_SHAPE> arc = std::make_unique<FP_SHAPE>( &aFootprint, SHAPE_T::ARC );
|
||||
|
||||
arc->SetCenter0( aCentre );
|
||||
arc->SetStart0( aStart );
|
||||
arc->SetArcAngleAndEnd0( aAngle * 10 );
|
||||
arc->SetArcAngleAndEnd0( aAngle );
|
||||
|
||||
arc->SetStroke( STROKE_PARAMS( aWidth, PLOT_DASH_TYPE::SOLID ) );
|
||||
arc->SetLayer( aLayer );
|
||||
|
@ -100,10 +100,10 @@ void DrawRect( FOOTPRINT& aFootprint, const VECTOR2I& aPos, const VECTOR2I& aSiz
|
|||
|
||||
if( aRadius > 0 )
|
||||
{
|
||||
DrawArc( aFootprint, { xin_r, yin_t }, { x_r, yin_t }, 90, aWidth, aLayer );
|
||||
DrawArc( aFootprint, { xin_l, yin_t }, { xin_l, y_t }, 90, aWidth, aLayer );
|
||||
DrawArc( aFootprint, { xin_l, yin_b }, { x_l, yin_b }, 90, aWidth, aLayer );
|
||||
DrawArc( aFootprint, { xin_r, yin_b }, { xin_r, y_b }, 90, aWidth, aLayer );
|
||||
DrawArc( aFootprint, { xin_r, yin_t }, { x_r, yin_t }, ANGLE_90, aWidth, aLayer );
|
||||
DrawArc( aFootprint, { xin_l, yin_t }, { xin_l, y_t }, ANGLE_90, aWidth, aLayer );
|
||||
DrawArc( aFootprint, { xin_l, yin_b }, { x_l, yin_b }, ANGLE_90, aWidth, aLayer );
|
||||
DrawArc( aFootprint, { xin_r, yin_b }, { xin_r, y_b }, ANGLE_90, aWidth, aLayer );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <layer_ids.h>
|
||||
#include <math/vector2d.h>
|
||||
#include <geometry/eda_angle.h>
|
||||
|
||||
class FOOTPRINT;
|
||||
class SEG;
|
||||
|
@ -65,12 +66,12 @@ void DrawPolyline( FOOTPRINT& aFootprint, const std::vector<VECTOR2I>& aPts, int
|
|||
* @param aMod The footprint to add the segment to
|
||||
* @param aCentre The arc centre
|
||||
* @param aStart The arc start point
|
||||
* @param aAngle The arc angle (degrees, NOT deci-degrees)
|
||||
* @param aAngle The arc angle
|
||||
* @param aWidth The width of the arc segment
|
||||
* @param aLayer The layer to draw on
|
||||
*/
|
||||
void DrawArc( FOOTPRINT& aFootprint, const VECTOR2I& aCentre, const VECTOR2I& aStart,
|
||||
double aAngle, int aWidth, PCB_LAYER_ID aLayer );
|
||||
const EDA_ANGLE& aAngle, int aWidth, PCB_LAYER_ID aLayer );
|
||||
|
||||
/**
|
||||
* Draw a rectangle on a footprint
|
||||
|
|
|
@ -236,7 +236,7 @@ public:
|
|||
virtual void AddBox( const BOX2I& aB, const KIGFX::COLOR4D& aColor,
|
||||
const std::string& aName,
|
||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override;
|
||||
virtual void Clear(){};
|
||||
virtual void Clear() override {};
|
||||
|
||||
int GetStageCount() const { return m_stages.size(); }
|
||||
|
||||
|
|
|
@ -256,8 +256,8 @@ void PNS_LOG_VIEWER_OVERLAY::AnnotatedPoint( const VECTOR2I p, int size, std::st
|
|||
void PNS_LOG_VIEWER_OVERLAY::Arc( const SHAPE_ARC& arc )
|
||||
{
|
||||
double radius = arc.GetRadius();
|
||||
double start_angle = arc.GetStartAngle().AsRadians();
|
||||
double angle = arc.GetCentralAngle().AsRadians();
|
||||
EDA_ANGLE start_angle = arc.GetStartAngle();
|
||||
EDA_ANGLE angle = arc.GetCentralAngle();
|
||||
|
||||
KIGFX::VIEW_OVERLAY::SetLineWidth( arc.GetWidth() / 10 );
|
||||
KIGFX::VIEW_OVERLAY::Arc( arc.GetCenter(), radius, start_angle, start_angle + angle );
|
||||
|
|
Loading…
Reference in New Issue