X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=profile.c;h=1b7db1d904909bbb440dfe4e184e0579132fafa1;hb=f3134cbb8995267e6a18b9564f3022e7fe7314a9;hp=531839368bf4cd53b89c386ef84a5c15c5b02078;hpb=957aaf619f22465b4aa1898c925831a6270c1230;p=ext%2Fsubsurface.git diff --git a/profile.c b/profile.c index 5318393..1b7db1d 100644 --- a/profile.c +++ b/profile.c @@ -158,22 +158,12 @@ static void plot_text(struct graphics_context *gc, const text_render_options_t * static void render_depth_sample(struct graphics_context *gc, struct plot_data *entry, const text_render_options_t *tro) { - int sec = entry->sec; - depth_t depth = { entry->val }; - const char *fmt; + int sec = entry->sec, decimals; double d; - switch (output_units.length) { - case METERS: - d = depth.mm / 1000.0; - fmt = "%.1f"; - break; - case FEET: - d = to_feet(depth); - fmt = "%.0f"; - break; - } - plot_text(gc, tro, sec, depth.mm, fmt, d); + d = get_depth_units(entry->val, &decimals, NULL); + + plot_text(gc, tro, sec, entry->val, "%.*f", decimals, d); } static void plot_text_samples(struct graphics_context *gc, struct plot_info *pi) @@ -620,7 +610,7 @@ static struct plot_info *analyze_plot_info(struct plot_info *pi) /* if our samples are short and we aren't too FAST*/ if (entry[0].sec - entry[-1].sec < 30 && entry->velocity < FAST) { int past = -2; - while (pi->entry <= entry-past && entry[0].sec - entry[past].sec < 30) + while (i+past > 0 && entry[0].sec - entry[past].sec < 30) past--; entry->velocity = velocity((entry[0].val - entry[past].val) / (entry[0].sec - entry[past].sec)); @@ -743,4 +733,5 @@ void plot(struct graphics_context *gc, int w, int h, struct dive *dive) cairo_close_path(gc->cr); cairo_stroke(gc->cr); + free(pi); }