Commit 5a6c088b authored by Marco Mattila's avatar Marco Mattila

Use circular interpolation for circles and arcs in pcbnew gerber plots.

parent f20bf0d2
...@@ -274,27 +274,35 @@ void GERBER_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, ...@@ -274,27 +274,35 @@ void GERBER_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
} }
void GERBER_PLOTTER::Circle( const wxPoint& aCentre, int aDiameter, FILL_T aFill, void GERBER_PLOTTER::Circle( const wxPoint& aCenter, int aDiameter, FILL_T aFill,
int aWidth ) int aWidth )
{ {
wxASSERT( outputFile ); Arc( aCenter, 0, 3600, aDiameter / 2, aFill, aWidth );
wxPoint start, end; }
double radius = aDiameter / 2;
const int delta = 3600 / 32; /* increment (in 0.1 degrees) to draw circles */
start.x = aCentre.x + KiROUND( radius ); void GERBER_PLOTTER::Arc( const wxPoint& aCenter, int aStAngle, int aEndAngle,
start.y = aCentre.y; int aRadius, FILL_T aFill, int aWidth )
{
wxASSERT( outputFile );
wxPoint start, end;
start.x = aCenter.x + KiROUND( aRadius*cos( DEG2RAD( aStAngle/10.0 ) ) );
start.y = aCenter.y - KiROUND( aRadius*sin( DEG2RAD( aStAngle/10.0 ) ) );
SetCurrentLineWidth( aWidth ); SetCurrentLineWidth( aWidth );
MoveTo( start ); MoveTo( start );
end.x = aCenter.x + KiROUND( aRadius*cos( DEG2RAD( aEndAngle/10.0 ) ) );
for( int ii = delta; ii < 3600; ii += delta ) end.y = aCenter.y - KiROUND( aRadius*sin( DEG2RAD( aEndAngle/10.0 ) ) );
{ DPOINT devEnd = userToDeviceCoordinates( end );
end.x = aCentre.x + (int) ( radius * cos( DEG2RAD( ii / 10.0 ) ) ); DPOINT devCenter = userToDeviceCoordinates( aCenter - start );
end.y = aCentre.y + (int) ( radius * sin( DEG2RAD( ii / 10.0 ) ) ); fprintf( outputFile, "G75*\n" ); // Multiquadrant mode
LineTo( end );
} if( aStAngle < aEndAngle )
fprintf( outputFile, "G03" );
FinishTo( start ); else
fprintf( outputFile, "G02" );
fprintf( outputFile, "X%dY%dI%dJ%dD01*\n", int( devEnd.x ), int( devEnd.y ),
int( devCenter.x ), int( devCenter.y ) );
fprintf( outputFile, "G74*\nG01*\n" ); // Back to single quadrant and linear interp.
} }
......
...@@ -679,6 +679,8 @@ public: ...@@ -679,6 +679,8 @@ public:
int width = -1 ); int width = -1 );
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
int width = -1 ); int width = -1 );
virtual void Arc( const wxPoint& aCenter, int aStAngle, int aEndAngle, int aRadius,
FILL_T aFill, int aWidth = -1 );
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
FILL_T aFill, int aWidth = -1); FILL_T aFill, int aWidth = -1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment