Allow bezier->line/poly conversion

Fixes https://gitlab.com/kicad/code/kicad/issues/12778
This commit is contained in:
Seth Hillbrand 2022-10-31 12:48:23 -07:00
parent 8963e4187a
commit c7c4439027
3 changed files with 36 additions and 1 deletions

View File

@ -133,6 +133,7 @@ enum KICAD_T
PCB_SHAPE_LOCATE_CIRCLE_T,
PCB_SHAPE_LOCATE_ARC_T,
PCB_SHAPE_LOCATE_POLY_T,
PCB_SHAPE_LOCATE_BEZIER_T,
// Schematic draw Items. The order of these items effects the sort order.
// It is currently ordered to mimic the old Eeschema locate behavior where

View File

@ -77,6 +77,8 @@ bool PCB_SHAPE::IsType( const std::vector<KICAD_T>& aScanTypes ) const
sametype = m_shape == SHAPE_T::SEGMENT;
else if( scanType == PCB_SHAPE_LOCATE_POLY_T )
sametype = m_shape == SHAPE_T::POLY;
else if( scanType == PCB_SHAPE_LOCATE_BEZIER_T )
sametype = m_shape == SHAPE_T::BEZIER;
if( sametype )
return true;

View File

@ -151,7 +151,8 @@ bool CONVERT_TOOL::Init()
m_menu->SetTitle( _( "Create from Selection" ) );
auto graphicLines = S_C::OnlyTypes( { PCB_SHAPE_LOCATE_SEGMENT_T, PCB_SHAPE_LOCATE_RECT_T,
PCB_SHAPE_LOCATE_CIRCLE_T, PCB_SHAPE_LOCATE_ARC_T } )
PCB_SHAPE_LOCATE_CIRCLE_T, PCB_SHAPE_LOCATE_ARC_T,
PCB_SHAPE_LOCATE_BEZIER_T } )
&& P_S_C::SameLayer();
auto graphicToTrack = S_C::OnlyTypes( { PCB_SHAPE_LOCATE_SEGMENT_T, PCB_SHAPE_LOCATE_ARC_T } );
@ -452,6 +453,36 @@ SHAPE_POLY_SET CONVERT_TOOL::makePolysFromChainedSegs( const std::deque<EDA_ITEM
else
outline.Insert( 0, aAnchor == arc.GetP0() ? arc : arc.Reversed() );
}
else if( aItem->IsType( { PCB_SHAPE_LOCATE_BEZIER_T } ) )
{
PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
if( aAnchor == graphic->GetStart() )
{
for( auto it = graphic->GetBezierPoints().begin();
it != graphic->GetBezierPoints().end();
++it )
{
if( aDirection )
outline.Append( *it );
else
outline.Insert( 0, *it );
}
}
else
{
for( auto it = graphic->GetBezierPoints().rbegin();
it != graphic->GetBezierPoints().rend();
++it )
{
if( aDirection )
outline.Append( *it );
else
outline.Insert( 0, *it );
}
}
}
else
{
std::optional<SEG> nextSeg = getStartEndPoints( aItem, &width );
@ -921,6 +952,7 @@ std::optional<SEG> CONVERT_TOOL::getStartEndPoints( EDA_ITEM* aItem, int* aWidth
case SHAPE_T::SEGMENT:
case SHAPE_T::ARC:
case SHAPE_T::POLY:
case SHAPE_T::BEZIER:
if( shape->GetStart() == shape->GetEnd() )
return std::nullopt;