kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #11893
patch to fix bug in DXF plot
Hi folks,
There is a bug in DXF plot which changes the included angle of arcs. To demonstrate the bug:
1. in the edge cutout layer, create a rectangle with rounded corners and plot the layer to DXF. Since KiCad will write a PCB file with all angles = +90, everything is OK.
2. Delete the cutout layer and import the DXF. At this point everything should look OK.
3. Plot the dxf again; this time things go bad because the DXF importer marked some angles as -90 in Step 2.
4. Import the bad DXF (or view it with MCAD software).
I have only fixed the bug in BRDITEMS_PLOTTER::PlotDrawSegment and only for DXF plotting. I did not create tests to check if the problem exists with other types of plotting routines (it is possible others are affected, but not necessarily so) and I did not investigate problems with exporting an Arc in BRDITEMS_PLOTTER::Plot_1_EdgeModule.
Cheers,
Cirilo
=== modified file 'pcbnew/plot_brditems_plotter.cpp'
--- pcbnew/plot_brditems_plotter.cpp 2013-12-05 12:24:27 +0000
+++ pcbnew/plot_brditems_plotter.cpp 2013-12-17 09:49:54 +0000
@@ -401,7 +401,7 @@
double startAngle = ArcTangente( end.y - pos.y, end.x - pos.x );
double endAngle = startAngle + aEdge->GetAngle();
-
+
if ( ( GetFormat() == PLOT_FORMAT_DXF ) &&
( m_layerMask & ( SILKSCREEN_LAYER_BACK | DRAW_LAYER | COMMENT_LAYER ) ) )
m_plotter->ThickArc( pos, -startAngle, -endAngle, radius, thickness, GetMode() );
@@ -615,6 +615,23 @@
radius = KiROUND( GetLineLength( end, start ) );
StAngle = ArcTangente( end.y - start.y, end.x - start.x );
EndAngle = StAngle + aSeg->GetAngle();
+
+ if ( GetFormat() == PLOT_FORMAT_DXF )
+ {
+ if( aSeg->GetAngle() >= -1800 && aSeg->GetAngle() <= 1800 )
+ {
+ // ensure that normally startAngle < endAngle
+ if( StAngle > EndAngle )
+ std::swap( StAngle, EndAngle );
+ }
+ else
+ {
+ // ensure that normally startAngle > endAngle
+ if( StAngle < EndAngle )
+ std::swap( StAngle, EndAngle );
+ }
+ }
+
m_plotter->ThickArc( start, -EndAngle, -StAngle, radius, thickness, GetMode() );
break;
Follow ups