Gerbview: fix crash or incorrect drawings after code change in shape_line_chain
This commit is contained in:
parent
3e431d0d39
commit
962baf8b6c
|
@ -452,4 +452,5 @@ static void addHoleToPolygon( SHAPE_POLY_SET* aPolygon,
|
||||||
}
|
}
|
||||||
|
|
||||||
aPolygon->BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST );
|
aPolygon->BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST );
|
||||||
|
aPolygon->Fracture( SHAPE_POLY_SET::PM_FAST );
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,7 +370,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
|
||||||
if( aItem->m_Polygon.OutlineCount() == 0 )
|
if( aItem->m_Polygon.OutlineCount() == 0 )
|
||||||
aItem->ConvertSegmentToPolygon();
|
aItem->ConvertSegmentToPolygon();
|
||||||
|
|
||||||
drawPolygon( aItem, code, isFilled );
|
drawPolygon( aItem, aItem->m_Polygon, isFilled );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -383,7 +383,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxASSERT_MSG( false, wxT( "GERBER_DRAW_ITEM shape is unknown!" ) );
|
wxASSERT_MSG( false, "GERBER_DRAW_ITEM shape is unknown!" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,10 +401,16 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
|
||||||
|
|
||||||
|
|
||||||
void GERBVIEW_PAINTER::drawPolygon(
|
void GERBVIEW_PAINTER::drawPolygon(
|
||||||
GERBER_DRAW_ITEM* aParent, D_CODE* aCode, bool aFilled, bool aShift )
|
GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon, bool aFilled, bool aShift )
|
||||||
{
|
{
|
||||||
|
wxASSERT( aPolygon.OutlineCount() == 1 );
|
||||||
|
|
||||||
|
if( aPolygon.OutlineCount() == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
SHAPE_POLY_SET poly;
|
SHAPE_POLY_SET poly;
|
||||||
auto& pts = aCode->m_Polygon.COutline( 0 ).CPoints();
|
poly.NewOutline();
|
||||||
|
const std::vector<VECTOR2I> pts = aPolygon.COutline( 0 ).CPoints();
|
||||||
VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
|
VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
|
||||||
|
|
||||||
for( auto& pt : pts )
|
for( auto& pt : pts )
|
||||||
|
@ -426,7 +432,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
|
||||||
{
|
{
|
||||||
D_CODE* code = aItem->GetDcodeDescr();
|
D_CODE* code = aItem->GetDcodeDescr();
|
||||||
|
|
||||||
wxASSERT_MSG( code, wxT( "drawFlashedShape: Item has no D_CODE!" ) );
|
wxASSERT_MSG( code, "drawFlashedShape: Item has no D_CODE!" );
|
||||||
|
|
||||||
if( !code )
|
if( !code )
|
||||||
return;
|
return;
|
||||||
|
@ -451,10 +457,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
|
||||||
if( code->m_Polygon.OutlineCount() == 0 )
|
if( code->m_Polygon.OutlineCount() == 0 )
|
||||||
code->ConvertShapeToPolygon();
|
code->ConvertShapeToPolygon();
|
||||||
|
|
||||||
SHAPE_POLY_SET poly = code->m_Polygon;
|
drawPolygon( aItem, code->m_Polygon, aFilled, true );
|
||||||
poly.Move( VECTOR2I( aItem->m_Start ) );
|
|
||||||
|
|
||||||
drawPolygon( aItem, code, aFilled );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -479,7 +482,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
|
||||||
if( code->m_Polygon.OutlineCount() == 0 )
|
if( code->m_Polygon.OutlineCount() == 0 )
|
||||||
code->ConvertShapeToPolygon();
|
code->ConvertShapeToPolygon();
|
||||||
|
|
||||||
drawPolygon( aItem, code, aFilled );
|
drawPolygon( aItem, code->m_Polygon, aFilled, true );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -518,7 +521,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
|
||||||
if( code->m_Polygon.OutlineCount() == 0 )
|
if( code->m_Polygon.OutlineCount() == 0 )
|
||||||
code->ConvertShapeToPolygon();
|
code->ConvertShapeToPolygon();
|
||||||
|
|
||||||
drawPolygon( aItem, code, aFilled );
|
drawPolygon( aItem, code->m_Polygon, aFilled, true );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +531,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
|
||||||
if( code->m_Polygon.OutlineCount() == 0 )
|
if( code->m_Polygon.OutlineCount() == 0 )
|
||||||
code->ConvertShapeToPolygon();
|
code->ConvertShapeToPolygon();
|
||||||
|
|
||||||
drawPolygon( aItem, code, aFilled );
|
drawPolygon( aItem, code->m_Polygon, aFilled, true );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,11 +196,12 @@ protected:
|
||||||
/**
|
/**
|
||||||
* Helper routine to draw a polygon
|
* Helper routine to draw a polygon
|
||||||
* @param aParent Pointer to the draw item for AB Position calculation
|
* @param aParent Pointer to the draw item for AB Position calculation
|
||||||
* @param aCode Flash code pointer
|
* @param aPolygon the polygon to draw
|
||||||
* @param aFilled If true, draw the polygon as filled, otherwise only outline
|
* @param aFilled If true, draw the polygon as filled, otherwise only outline
|
||||||
* @param aShift If true, draw the polygon relative to the parent item position
|
* @param aShift If true, draw the polygon relative to the parent item position
|
||||||
*/
|
*/
|
||||||
void drawPolygon( GERBER_DRAW_ITEM* aParent, D_CODE* aCode, bool aFilled, bool aShift = false );
|
void drawPolygon( GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon,
|
||||||
|
bool aFilled, bool aShift = false );
|
||||||
|
|
||||||
/// Helper to draw a flashed shape (aka spot)
|
/// Helper to draw a flashed shape (aka spot)
|
||||||
void drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled );
|
void drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled );
|
||||||
|
|
Loading…
Reference in New Issue