Handle 360° arcs on import as circles

KiCad breaks a bit when dealing with 360° arcs, so convert them to
circles on import.  The break happens when converting to polygons for
viewing, the arc is passed from start->mid->end format to
center->start->angle format.  At 360°, the angle is normalized to 0
This commit is contained in:
Seth Hillbrand 2021-12-18 07:55:08 -08:00 committed by Wayne Stambaugh
parent a17a58203b
commit bd0fbea044
2 changed files with 58 additions and 1 deletions

View File

@ -1076,6 +1076,9 @@ FABMASTER::GRAPHIC_ARC* FABMASTER::processArc( const FABMASTER::GRAPHIC_DATA& aD
RotatePoint( mid, center, -angle / 2.0 );
if( start == end )
new_arc->shape = GR_SHAPE_CIRCLE;
new_arc->result = SHAPE_ARC( start, mid, end, 0 );
return new_arc;
@ -2111,6 +2114,27 @@ bool FABMASTER::loadFootprints( BOARD* aBoard )
fp->Add( line, ADD_MODE::APPEND );
break;
}
case GR_SHAPE_CIRCLE:
{
const GRAPHIC_ARC* lsrc = static_cast<const GRAPHIC_ARC*>( seg.get() );
FP_SHAPE* circle = new FP_SHAPE( fp, SHAPE_T::CIRCLE );
circle->SetLayer( layer );
circle->SetCenter( wxPoint( lsrc->center_x, lsrc->center_y ) );
circle->SetEnd( wxPoint( lsrc->end_x, lsrc->end_y ) );
circle->SetWidth( lsrc->width );
circle->SetLocalCoord();
if( lsrc->width == 0 )
circle->SetWidth( ds.GetLineThickness( circle->GetLayer() ) );
if( src->mirror )
circle->Flip( circle->GetCenter(), false );
fp->Add( circle, ADD_MODE::APPEND );
break;
}
case GR_SHAPE_ARC:
{
const GRAPHIC_ARC* lsrc = static_cast<const GRAPHIC_ARC*>( seg.get() );
@ -2762,6 +2786,23 @@ bool FABMASTER::loadOutline( BOARD* aBoard, const std::unique_ptr<FABMASTER::TRA
aBoard->Add( line, ADD_MODE::APPEND );
break;
}
case GR_SHAPE_CIRCLE:
{
const GRAPHIC_ARC* lsrc = static_cast<const GRAPHIC_ARC*>( seg.get() );
PCB_SHAPE* circle = new PCB_SHAPE( aBoard, SHAPE_T::CIRCLE );
circle->SetLayer( layer );
circle->SetCenter( wxPoint( lsrc->center_x, lsrc->center_y ) );
circle->SetEnd( wxPoint( lsrc->end_x, lsrc->end_y ) );
circle->SetWidth( lsrc->width );
if( lsrc->width == 0 )
circle->SetWidth( aBoard->GetDesignSettings().GetLineThickness( circle->GetLayer() ) );
aBoard->Add( circle, ADD_MODE::APPEND );
break;
}
case GR_SHAPE_ARC:
{
const GRAPHIC_ARC* src = static_cast<const GRAPHIC_ARC*>( seg.get() );
@ -2877,6 +2918,20 @@ bool FABMASTER::loadGraphics( BOARD* aBoard )
aBoard->Add( line, ADD_MODE::APPEND );
break;
}
case GR_SHAPE_CIRCLE:
{
const GRAPHIC_ARC* src = static_cast<const GRAPHIC_ARC*>( seg.get() );
PCB_SHAPE* circle = new PCB_SHAPE( aBoard, SHAPE_T::CIRCLE );
circle->SetLayer( layer );
circle->SetCenter( wxPoint( src->center_x, src->center_y ) );
circle->SetEnd( wxPoint( src->end_x, src->end_y ) );
circle->SetWidth( src->width );
aBoard->Add( circle, ADD_MODE::APPEND );
break;
}
case GR_SHAPE_ARC:
{
const GRAPHIC_ARC* src = static_cast<const GRAPHIC_ARC*>( seg.get() );
@ -2901,6 +2956,7 @@ bool FABMASTER::loadGraphics( BOARD* aBoard )
rect->SetStart( wxPoint( src->start_x, src->start_y ) );
rect->SetEnd( wxPoint( src->end_x, src->end_y ) );
rect->SetWidth( 0 );
rect->SetFilled( true );
aBoard->Add( rect, ADD_MODE::APPEND );
break;
}

View File

@ -191,7 +191,8 @@ private:
GR_SHAPE_LINE,
GR_SHAPE_TEXT,
GR_SHAPE_RECTANGLE,
GR_SHAPE_ARC
GR_SHAPE_ARC,
GR_SHAPE_CIRCLE ///! Not actually in Fabmaster but we use for 360° arcs
};
enum GRAPHIC_TYPE