summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-21 12:12:54 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-21 12:12:54 -0700
commit515a9171523f7d8aa85f2caab262ba7d6320c33c (patch)
treed1f49227a67701bacbba0679839fcba0d7b8f9d0 /profile.c
parent184eecf7c0dbcbdecba097411828afaac30773aa (diff)
downloadsubsurface-515a9171523f7d8aa85f2caab262ba7d6320c33c.tar.gz
Add helper function for doing depth unit calculations
.. and use it for printing too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/profile.c b/profile.c
index 3f3dd42bc..1b7db1d90 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)