Browse Source

Pcbnew: handle circles in polygon booleans

pull/18/head
John Beard 5 months ago
parent
commit
401eba4e91
  1. 11
      pcbnew/tools/edit_tool.cpp
  2. 16
      pcbnew/tools/item_modification_routine.cpp

11
pcbnew/tools/edit_tool.cpp

@ -160,7 +160,8 @@ static std::shared_ptr<CONDITIONAL_MENU> makeShapeModificationMenu( TOOL_INTERAC
static const std::vector<KICAD_T> lineExtendTypes = { PCB_SHAPE_LOCATE_SEGMENT_T };
static const std::vector<KICAD_T> polygonBooleanTypes = { PCB_SHAPE_LOCATE_RECT_T,
PCB_SHAPE_LOCATE_POLY_T };
PCB_SHAPE_LOCATE_POLY_T,
PCB_SHAPE_LOCATE_CIRCLE_T };
static const std::vector<KICAD_T> polygonSimplifyTypes = { PCB_SHAPE_LOCATE_POLY_T,
PCB_ZONE_T };
@ -1829,7 +1830,13 @@ int EDIT_TOOL::BooleanPolygons( const TOOL_EVENT& aEvent )
{
BOARD_ITEM* item = aCollector[i];
if( !item->IsType( { PCB_SHAPE_LOCATE_POLY_T, PCB_SHAPE_LOCATE_RECT_T } ) )
static const std::vector<KICAD_T> polygonBooleanTypes = {
PCB_SHAPE_LOCATE_POLY_T,
PCB_SHAPE_LOCATE_RECT_T,
PCB_SHAPE_LOCATE_CIRCLE_T,
};
if( !item->IsType( polygonBooleanTypes ) )
aCollector.Remove( item );
}
},

16
pcbnew/tools/item_modification_routine.cpp

@ -454,18 +454,26 @@ void POLYGON_BOOLEAN_ROUTINE::ProcessShape( PCB_SHAPE& aPcbShape )
}
case SHAPE_T::RECTANGLE:
{
SHAPE_POLY_SET rect_poly;
poly = std::make_unique<SHAPE_POLY_SET>();
const std::vector<VECTOR2I> rect_pts = aPcbShape.GetRectCorners();
rect_poly.NewOutline();
poly->NewOutline();
for( const VECTOR2I& pt : rect_pts )
{
rect_poly.Append( pt );
poly->Append( pt );
}
break;
}
case SHAPE_T::CIRCLE:
{
poly = std::make_unique<SHAPE_POLY_SET>();
const SHAPE_ARC arc{ aPcbShape.GetCenter(), aPcbShape.GetCenter() + VECTOR2I{ aPcbShape.GetRadius(), 0 },
FULL_CIRCLE, 0 };
poly = std::make_unique<SHAPE_POLY_SET>( std::move( rect_poly ) );
poly->NewOutline();
poly->Append( arc );
break;
}
default:

Loading…
Cancel
Save