Safety for negative pen widths.

This commit is contained in:
Jeff Young 2023-09-14 13:39:35 +01:00
parent 8cf291e423
commit c7e865e4a2
5 changed files with 16 additions and 5 deletions

View File

@ -594,8 +594,7 @@ void PLOTTER::ThickArc( const VECTOR2D& centre, const EDA_ANGLE& aStartAngle,
}
void PLOTTER::ThickArc( const EDA_SHAPE& aArcShape,
OUTLINE_MODE aTraceMode, void* aData )
void PLOTTER::ThickArc( const EDA_SHAPE& aArcShape, OUTLINE_MODE aTraceMode, void* aData )
{
VECTOR2D center = aArcShape.getCenter();
VECTOR2D mid = aArcShape.GetArcMid();

View File

@ -107,7 +107,7 @@ public:
void SetFillColor( const COLOR4D& aColor ) { m_fillColor = aColor; }
void SetWidth( int aWidth ) { m_stroke.SetWidth( aWidth ); }
int GetWidth() const { return m_stroke.GetWidth(); }
virtual int GetWidth() const { return m_stroke.GetWidth(); }
virtual int GetEffectiveWidth() const { return GetWidth(); }
void SetLineStyle( const PLOT_DASH_TYPE aStyle );

View File

@ -382,8 +382,8 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aShapeList, SHAPE_POLY_SE
// Ensure the approximated Bezier shape is built
// a good value is between (Bezier curve width / 2) and (Bezier curve width)
// ( and at least 0.05 mm to avoid very small segments)
int min_segm_lenght = std::max( pcbIUScale.mmToIU( 0.05 ), graphic->GetWidth() );
graphic->RebuildBezierToSegmentsPointsList( min_segm_lenght );
int min_segm_length = std::max( pcbIUScale.mmToIU( 0.05 ), graphic->GetWidth() );
graphic->RebuildBezierToSegmentsPointsList( min_segm_length );
if( reverse )
{

View File

@ -146,6 +146,16 @@ std::vector<VECTOR2I> PCB_SHAPE::GetConnectionPoints() const
}
int PCB_SHAPE::GetWidth() const
{
// A stroke width of 0 in PCBNew means no-border, but negative stroke-widths are only used
// in EEschema (see SCH_SHAPE::GetPenWidth()).
// Since negative stroke widths can trip up down-stream code (such as the Gerber plotter), we
// weed them out here.
return std::max( EDA_SHAPE::GetWidth(), 0 );
}
void PCB_SHAPE::StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings )
{
m_stroke.SetWidth( settings.GetLineThickness( GetLayer() ) );

View File

@ -82,6 +82,8 @@ public:
STROKE_PARAMS GetStroke() const override { return m_stroke; }
void SetStroke( const STROKE_PARAMS& aStroke ) override { m_stroke = aStroke; }
int GetWidth() const override;
void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) override;
/**