Browse Source

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.
pull/13/head
Seth Hillbrand 7 years ago
parent
commit
2e0887d49f
  1. 38
      pcbnew/convert_drawsegment_list_to_polygon.cpp
  2. 17
      pcbnew/plot_brditems_plotter.cpp

38
pcbnew/convert_drawsegment_list_to_polygon.cpp

@ -33,6 +33,7 @@
#include <macros.h>
#include <class_drawsegment.h>
#include <class_module.h>
#include <base_units.h>
#include <convert_basic_shapes_to_polygon.h>
#include <geometry/geometry_utils.h>
@ -285,13 +286,20 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& 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<DRAWSEGMENT*>& 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<DRAWSEGMENT*>& 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 )

17
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;
}

Loading…
Cancel
Save