Gerbview: fix missing pad shapes when exporting to Pcbnew.

This commit is contained in:
jean-pierre charras 2022-09-07 18:54:04 +02:00
parent 4efa13a3e3
commit 0b233d593a
7 changed files with 33 additions and 25 deletions

View File

@ -862,7 +862,7 @@ SHAPE_POLY_SET* APERTURE_MACRO::GetApertureMacroShape( const GERBER_DRAW_ITEM* a
}
void APERTURE_MACRO::DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC,
void APERTURE_MACRO::DrawApertureMacroShape( const GERBER_DRAW_ITEM* aParent, wxDC* aDC,
const COLOR4D& aColor, const VECTOR2I& aShapePos,
bool aFilledShape )
{

View File

@ -202,7 +202,8 @@ struct APERTURE_MACRO
* @param aShapePos is the actual shape position.
* @param aFilledShape set to true to draw in filled mode, false to draw in sketch mode.
*/
void DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
void DrawApertureMacroShape( const GERBER_DRAW_ITEM* aParent, wxDC* aDC,
const COLOR4D& aColor,
const VECTOR2I& aShapePos, bool aFilledShape );
/**

View File

@ -144,7 +144,7 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
}
void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
void D_CODE::DrawFlashedShape( const GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
const VECTOR2I& aShapePos, bool aFilledShape )
{
int radius;
@ -174,7 +174,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR
else // rectangular hole
{
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
ConvertShapeToPolygon( aParent );
DrawFlashedPolygon( aParent, aDC, aColor, aFilledShape, aShapePos );
}
@ -201,7 +201,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR
else
{
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
ConvertShapeToPolygon( aParent );
DrawFlashedPolygon( aParent, aDC, aColor, aFilledShape, aShapePos );
}
@ -242,7 +242,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR
else
{
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
ConvertShapeToPolygon( aParent );
DrawFlashedPolygon( aParent, aDC, aColor, aFilledShape, aShapePos );
}
@ -252,7 +252,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR
case APT_POLYGON:
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
ConvertShapeToPolygon( aParent );
DrawFlashedPolygon( aParent, aDC, aColor, aFilledShape, aShapePos );
break;
@ -260,7 +260,8 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR
}
void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
void D_CODE::DrawFlashedPolygon( const GERBER_DRAW_ITEM* aParent, wxDC* aDC,
const COLOR4D& aColor,
bool aFilled, const VECTOR2I& aPosition )
{
if( m_Polygon.OutlineCount() == 0 )
@ -290,7 +291,7 @@ static void addHoleToPolygon( SHAPE_POLY_SET* aPolygon, APERTURE_DEF_HOLETYPE aH
const VECTOR2I& aSize, const VECTOR2I& aAnchorPos );
void D_CODE::ConvertShapeToPolygon()
void D_CODE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent )
{
VECTOR2I initialpos;
VECTOR2I currpos;
@ -372,8 +373,7 @@ void D_CODE::ConvertShapeToPolygon()
addHoleToPolygon( &m_Polygon, m_DrillShape, m_Drill, initialpos );
}
break;
break;
case APT_POLYGON:
m_Polygon.NewOutline();
@ -402,8 +402,9 @@ void D_CODE::ConvertShapeToPolygon()
break;
case APT_MACRO:
// TODO
APERTURE_MACRO* macro = GetMacro();
SHAPE_POLY_SET* macroShape = macro->GetApertureMacroShape( aParent, initialpos );
m_Polygon.Append( *macroShape );
break;
}
}

View File

@ -141,7 +141,8 @@ public:
* @param aShapePos is the actual shape position
* @param aFilledShape set to true to draw in filled mode, false to draw in sketch mode
*/
void DrawFlashedShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
void DrawFlashedShape( const GERBER_DRAW_ITEM* aParent, wxDC* aDC,
const COLOR4D& aColor,
const VECTOR2I& aShapePos, bool aFilledShape );
/**
@ -157,7 +158,8 @@ public:
* @param aFilled set to true to draw in filled mode, false to draw in sketch mode.
* @param aPosition is the actual shape position.
*/
void DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
void DrawFlashedPolygon( const GERBER_DRAW_ITEM* aParent, wxDC* aDC,
const COLOR4D& aColor,
bool aFilled, const VECTOR2I& aPosition );
/**
@ -165,8 +167,10 @@ public:
*
* Arcs and circles are approximated by segments. Useful when a shape is not a graphic
* primitive (shape with hole, rotated shape ... ) and cannot be easily drawn.
* @param aParent is the #GERBER_DRAW_ITEM using this DCode.
* Not used in all shapes, used for APT_MACRO
*/
void ConvertShapeToPolygon();
void ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent );
/**
* Calculate a value that can be used to evaluate the size of text when displaying the

View File

@ -170,7 +170,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( const GERBER_DRAW_ITEM* aGbrIt
case GBR_SPOT_OVAL:
case GBR_SPOT_POLY:
case GBR_SPOT_MACRO:
d_codeDescr->ConvertShapeToPolygon();
d_codeDescr->ConvertShapeToPolygon( aGbrItem );
writePcbPolygon( d_codeDescr->m_Polygon, aLayer, aGbrItem->GetABPosition( seg_start ) );
break;
@ -281,6 +281,8 @@ void GBR_TO_PCB_EXPORTER::export_copper_item( const GERBER_DRAW_ITEM* aGbrItem,
case GBR_SPOT_CIRCLE:
case GBR_SPOT_RECT:
case GBR_SPOT_OVAL:
case GBR_SPOT_POLY:
case GBR_SPOT_MACRO:
export_flashed_copper_item( aGbrItem, aLayer );
break;
@ -395,7 +397,6 @@ void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( const GERBER_DRAW_ITEM* aG
static D_CODE flashed_item_D_CODE( 0 );
D_CODE* d_codeDescr = aGbrItem->GetDcodeDescr();
SHAPE_POLY_SET polygon;
if( d_codeDescr == nullptr )
d_codeDescr = &flashed_item_D_CODE;
@ -423,8 +424,9 @@ void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( const GERBER_DRAW_ITEM* aG
return;
}
d_codeDescr->ConvertShapeToPolygon();
writePcbPolygon( d_codeDescr->m_Polygon, aLayer, offset );
APERTURE_MACRO* macro = d_codeDescr->GetMacro();
SHAPE_POLY_SET* macroShape = macro->GetApertureMacroShape( aGbrItem, VECTOR2I( 0, 0 ) );
writePcbPolygon( *macroShape, aLayer, offset );
}

View File

@ -323,7 +323,7 @@ const BOX2I GERBER_DRAW_ITEM::GetBoundingBox() const
if( code )
{
if( code->m_Polygon.OutlineCount() == 0 )
code->ConvertShapeToPolygon();
code->ConvertShapeToPolygon( this );
bbox.Inflate( code->m_Polygon.BBox().GetWidth() / 2,
code->m_Polygon.BBox().GetHeight() / 2 );

View File

@ -473,7 +473,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
else // rectangular hole
{
if( code->m_Polygon.OutlineCount() == 0 )
code->ConvertShapeToPolygon();
code->ConvertShapeToPolygon( aItem );
drawPolygon( aItem, code->m_Polygon, aFilled, true );
}
@ -498,7 +498,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
else
{
if( code->m_Polygon.OutlineCount() == 0 )
code->ConvertShapeToPolygon();
code->ConvertShapeToPolygon( aItem );
drawPolygon( aItem, code->m_Polygon, aFilled, true );
}
@ -537,7 +537,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
else
{
if( code->m_Polygon.OutlineCount() == 0 )
code->ConvertShapeToPolygon();
code->ConvertShapeToPolygon( aItem );
drawPolygon( aItem, code->m_Polygon, aFilled, true );
}
@ -546,7 +546,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
case GBR_SPOT_POLY:
if( code->m_Polygon.OutlineCount() == 0 )
code->ConvertShapeToPolygon();
code->ConvertShapeToPolygon( aItem );
drawPolygon( aItem, code->m_Polygon, aFilled, true );
break;