From 2e0887d49f7ff81ac6efdb80e73ef0da1136d384 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 2 Dec 2018 08:33:12 -0700 Subject: [PATCH] pcbnew: correctly display edgecut polygons in modules Commit 1858b7dca corrected the handling of polygons on the edge cut layer for board items. This adjusts for the possibility of polygons in modules on the edge cut layer by applying the module offset/rotation to the polygon elements. --- .../convert_drawsegment_list_to_polygon.cpp | 38 ++++++++++++++++--- pcbnew/plot_brditems_plotter.cpp | 17 ++++++++- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/pcbnew/convert_drawsegment_list_to_polygon.cpp b/pcbnew/convert_drawsegment_list_to_polygon.cpp index e0d6f490d1..e4c26134d5 100644 --- a/pcbnew/convert_drawsegment_list_to_polygon.cpp +++ b/pcbnew/convert_drawsegment_list_to_polygon.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -285,13 +286,20 @@ bool ConvertOutlineToPolygon( std::vector& aSegList, SHAPE_POLY_SE case S_POLYGON: { const auto poly = graphic->GetPolyShape(); + MODULE* module = aSegList[0]->GetParentModule(); + double orientation = module ? module->GetOrientation() : 0.0; + VECTOR2I offset = module ? module->GetPosition() : VECTOR2I( 0, 0 ); for( auto iter = poly.CIterate(); iter; iter++ ) { - if( iter->x < xmin.x ) + auto pt = *iter; + RotatePoint( pt, orientation ); + pt += offset; + + if( pt.x < xmin.x ) { - xmin.x = iter->x; - xmin.y = iter->y; + xmin.x = pt.x; + xmin.y = pt.y; xmini = i; } } @@ -319,7 +327,19 @@ bool ConvertOutlineToPolygon( std::vector& aSegList, SHAPE_POLY_SE } else if( graphic->GetShape() == S_POLYGON ) { - aPolygons = graphic->GetPolyShape(); + MODULE* module = graphic->GetParentModule(); // NULL for items not in footprints + double orientation = module ? module->GetOrientation() : 0.0; + VECTOR2I offset = module ? module->GetPosition() : VECTOR2I( 0, 0 ); + + aPolygons.NewOutline(); + + for( auto it = graphic->GetPolyShape().CIterate( 0 ); it; it++ ) + { + auto pt = *it; + RotatePoint( pt, orientation ); + pt += offset; + aPolygons.Append( pt ); + } } else { @@ -488,9 +508,17 @@ bool ConvertOutlineToPolygon( std::vector& aSegList, SHAPE_POLY_SE // do not connect to other elements, so we process them independently if( graphic->GetShape() == S_POLYGON ) { + MODULE* module = graphic->GetParentModule(); // NULL for items not in footprints + double orientation = module ? module->GetOrientation() : 0.0; + VECTOR2I offset = module ? module->GetPosition() : VECTOR2I( 0, 0 ); + for( auto it = graphic->GetPolyShape().CIterate(); it; it++ ) { - aPolygons.Append( *it, -1, hole ); + auto val = *it; + RotatePoint( val, orientation ); + val += offset; + + aPolygons.Append( val, -1, hole ); } } else if( graphic->GetShape() == S_CIRCLE ) diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 819a4ca549..ab5d2bca30 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -534,7 +534,22 @@ void BRDITEMS_PLOTTER::Plot_1_EdgeModule( EDGE_MODULE* aEdge ) cornerList.push_back( corner ); } - m_plotter->PlotPoly( cornerList, FILLED_SHAPE, thickness, &gbr_metadata ); + if( m_layerMask[ Edge_Cuts ] ) + { + for( size_t i = 1; i < cornerList.size(); i++ ) + { + m_plotter->ThickSegment( cornerList[i-1], cornerList[i], + thickness, GetPlotMode(), &gbr_metadata ); + } + + m_plotter->ThickSegment( cornerList.back(), cornerList.front(), + thickness, GetPlotMode(), &gbr_metadata ); + + } + else + { + m_plotter->PlotPoly( cornerList, FILLED_SHAPE, thickness, &gbr_metadata ); + } } break; }