Draw curves with separate loops

This commit is contained in:
Paul Dicker
2025-04-01 15:14:00 +02:00
committed by Stéphane Lesimple
parent a00dee7240
commit 57b55b2527

View File

@@ -371,52 +371,60 @@ void GuiRedrawAxes(Curve *curve)
void GuiRedrawCurve(Curve *curve, int last) void GuiRedrawCurve(Curve *curve, int last)
{ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(curve->widget)); { cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(curve->widget));
int i,x0,x1,fy0,fy1; int i,x0,x1,fy0;
x0 = GuiCurveX(curve, 0);
fy0 = GuiCurveY(curve, curve->fvalue[0]);
gdk_cairo_set_source_color(cr, Closure->curveColor); gdk_cairo_set_source_color(cr, Closure->curveColor);
cairo_set_line_width(cr, 1.0); cairo_set_line_width(cr, 1.0);
/* Draw the curve */ /* Draw integer bar curve */
for(i=1; i<=last; i++) if(curve->enable & DRAW_ICURVE)
{ x1 = GuiCurveX(curve, i); { gdk_cairo_set_source_color(cr, Closure->barColor);
x0 = GuiCurveX(curve, 0);
if(curve->enable & DRAW_ICURVE) for(i=1; i<=last; i++)
{ int iy = GuiCurveY(curve, curve->ivalue[i]); { x1 = GuiCurveX(curve, i);
int iy = GuiCurveY(curve, curve->ivalue[i]);
if(curve->ivalue[i] > 0) if(curve->ivalue[i] > 0)
{ gdk_cairo_set_source_color(cr, Closure->barColor); { cairo_rectangle(cr, x0, iy, x0==x1 ? 1 : x1-x0, curve->bottomY-iy);
cairo_rectangle(cr, x0, iy, x0==x1 ? 1 : x1-x0, curve->bottomY-iy);
cairo_fill(cr);
}
}
if(curve->enable & DRAW_LCURVE)
{ int iy = GuiCurveLogY(curve, curve->lvalue[i]);
if(curve->lvalue[i] > 0)
{ gdk_cairo_set_source_color(cr, Closure->logColor);
cairo_rectangle(cr, x0, iy, x0==x1 ? 1 : x1-x0, curve->bottomLY-iy);
cairo_fill(cr); cairo_fill(cr);
} }
x0 = x1;
} }
}
if(curve->enable & DRAW_FCURVE && curve->fvalue[i] >= 0) /* Draw logarithmic integer curve */
{ fy1 = GuiCurveY(curve, curve->fvalue[i]);
if(x0 < x1) if(curve->enable & DRAW_LCURVE)
{ gdk_cairo_set_source_color(cr, Closure->curveColor); { x0 = GuiCurveX(curve, 0);
cairo_move_to(cr, x0, fy0); for(i=1; i<=last; i++)
cairo_line_to(cr, x1, fy1); { gdk_cairo_set_source_color(cr, Closure->logColor);
cairo_stroke(cr); x1 = GuiCurveX(curve, i);
fy0 = fy1; int iy = GuiCurveLogY(curve, curve->lvalue[i]);
}
if(curve->lvalue[i] > 0)
{ cairo_rectangle(cr, x0, iy, x0==x1 ? 1 : x1-x0, curve->bottomLY-iy);
cairo_fill(cr);
}
x0 = x1;
} }
}
x0 = x1; /* Draw regular (floating point) curve */
if(curve->enable & DRAW_FCURVE)
{ x0 = GuiCurveX(curve, 0);
fy0 = GuiCurveY(curve, curve->fvalue[0]);
gdk_cairo_set_source_color(cr, Closure->curveColor);
cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
cairo_move_to(cr, x0, fy0);
for(i=1; i<=last; i++)
{ x1 = GuiCurveX(curve, i);
if(x0 < x1 && curve->fvalue[i] >= 0)
{ cairo_line_to(cr, x1, GuiCurveY(curve, curve->fvalue[i]));
x0 = x1;
}
}
cairo_stroke(cr);
} }
} }
#endif /* WITH_GUI_YES */ #endif /* WITH_GUI_YES */