Fix dashed/dotted line rendering in simulator graphs

The horizontal segment merging optimization was breaking non-solid pen
styles by combining line segments, which altered the dash/dot pattern.
This fix only applies the merging optimization for solid pens and extends
the reduced chunk size handling to all non-solid pen styles.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18887
This commit is contained in:
Seth Hillbrand
2026-01-08 08:38:27 -08:00
parent 1875ed211b
commit 233fa0366f
+10 -4
View File
@@ -630,7 +630,11 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
#else
int chunkSize = 100000;
#endif
if( dc.GetPen().GetStyle() == wxPENSTYLE_DOT )
wxPenStyle penStyle = dc.GetPen().GetStyle();
bool isSolidPen = ( penStyle == wxPENSTYLE_SOLID
|| penStyle == wxPENSTYLE_TRANSPARENT );
if( !isSolidPen )
chunkSize /= 500;
drawPoints.push_back( pointList[0] ); // push the first point in list
@@ -638,9 +642,11 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w )
for( size_t ii = 1; ii < pointList.size()-1; ii++ )
{
// Skip intermediate points between the first point and the last point of the
// segment candidate
if( drawPoints.back().y == pointList[ii].y &&
drawPoints.back().y == pointList[ii+1].y )
// segment candidate. This optimization merges horizontal line segments, which
// breaks non-solid pen styles by altering segment lengths.
if( isSolidPen
&& drawPoints.back().y == pointList[ii].y
&& drawPoints.back().y == pointList[ii+1].y )
{
continue;
}