Better code.
This commit is contained in:
parent
453015586a
commit
65cdef0290
|
@ -539,7 +539,6 @@ void PLOTTER::sketchOval( const VECTOR2I& aPos, const VECTOR2I& aSize, const EDA
|
||||||
SetCurrentLineWidth( aWidth );
|
SetCurrentLineWidth( aWidth );
|
||||||
|
|
||||||
EDA_ANGLE orient( aOrient );
|
EDA_ANGLE orient( aOrient );
|
||||||
VECTOR2I pt;
|
|
||||||
VECTOR2I size( aSize );
|
VECTOR2I size( aSize );
|
||||||
|
|
||||||
if( size.x > size.y )
|
if( size.x > size.y )
|
||||||
|
@ -551,32 +550,39 @@ void PLOTTER::sketchOval( const VECTOR2I& aPos, const VECTOR2I& aSize, const EDA
|
||||||
int deltaxy = size.y - size.x; /* distance between centers of the oval */
|
int deltaxy = size.y - size.x; /* distance between centers of the oval */
|
||||||
int radius = size.x / 2;
|
int radius = size.x / 2;
|
||||||
|
|
||||||
pt.x = -radius;
|
// Build a vertical oval shape giving the start and end points of arcs and edges,
|
||||||
pt.y = -deltaxy / 2;
|
// and the middle point of arcs
|
||||||
RotatePoint( pt, orient );
|
std::vector<VECTOR2I> corners;
|
||||||
MoveTo( pt + aPos );
|
corners.reserve( 6 );
|
||||||
pt.x = -radius;
|
// Shape is (x = corner and arc ends, c = arc centre)
|
||||||
pt.y = deltaxy / 2;
|
// xcx
|
||||||
RotatePoint( pt, orient );
|
//
|
||||||
FinishTo( pt + aPos );
|
// xcx
|
||||||
|
int half_height = deltaxy / 2;
|
||||||
|
corners.emplace_back( -radius, -half_height );
|
||||||
|
corners.emplace_back( -radius, half_height );
|
||||||
|
corners.emplace_back( 0, half_height );
|
||||||
|
corners.emplace_back( radius, half_height );
|
||||||
|
corners.emplace_back( radius, -half_height );
|
||||||
|
corners.emplace_back( 0, -half_height );
|
||||||
|
|
||||||
pt.x = radius;
|
// Rotate and move to the actual position
|
||||||
pt.y = -deltaxy / 2;
|
for( size_t ii = 0; ii < corners.size(); ii++ )
|
||||||
RotatePoint( pt, orient );
|
{
|
||||||
MoveTo( pt + aPos );
|
RotatePoint( corners[ii], orient );
|
||||||
pt.x = radius;
|
corners[ii] += aPos;
|
||||||
pt.y = deltaxy / 2;
|
}
|
||||||
RotatePoint( pt, orient );
|
|
||||||
FinishTo( pt + aPos );
|
|
||||||
|
|
||||||
pt.x = 0;
|
// Gen shape:
|
||||||
pt.y = deltaxy / 2;
|
MoveTo( corners[0] );
|
||||||
RotatePoint( pt, orient );
|
FinishTo( corners[1] );
|
||||||
Arc( pt + aPos, orient + ANGLE_180, orient + ANGLE_360, radius, FILL_T::NO_FILL );
|
|
||||||
pt.x = 0;
|
Arc( corners[2], orient + ANGLE_180, orient + ANGLE_360, radius, FILL_T::NO_FILL );
|
||||||
pt.y = -deltaxy / 2;
|
|
||||||
RotatePoint( pt, orient );
|
MoveTo( corners[3] );
|
||||||
Arc( pt + aPos, orient, orient + ANGLE_180, radius, FILL_T::NO_FILL );
|
FinishTo( corners[4] );
|
||||||
|
|
||||||
|
Arc( corners[5], orient, orient + ANGLE_180, radius, FILL_T::NO_FILL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue