- scalex = maxtime;
-
- sample = dive->sample;
- cairo_set_source_rgba(cr, 1, 0.2, 0.2, 0.80);
- begins = sample->time.seconds;
- cairo_move_to(cr, SCALE(sample->time.seconds, to_feet(sample->depth)));
- for (i = 1; i < dive->samples; i++) {
- sample++;
- sec = sample->time.seconds;
- depth = to_feet(sample->depth);
- cairo_line_to(cr, SCALE(sec, depth));
- }
- scaley = 1.0;
- cairo_line_to(cr, SCALE(sec, 0));
- cairo_line_to(cr, SCALE(begins, 0));
- cairo_close_path(cr);
- cairo_set_source_rgba(cr, 1, 0.2, 0.2, 0.20);
- cairo_fill_preserve(cr);
- cairo_set_source_rgba(cr, 1, 0.2, 0.2, 0.80);
- cairo_stroke(cr);
+ gc->leftx = 0; gc->rightx = maxtime;
+
+ /*
+ * These are good for debugging text placement etc,
+ * but not for actual display..
+ */
+ if (0) {
+ plot_smoothed_profile(gc, pi);
+ plot_minmax_profile(gc, pi);
+ }
+
+ set_source_rgba(gc, 1, 0.2, 0.2, 0.80);
+
+ /* Do the depth profile for the neat fill */
+ gc->topy = 0; gc->bottomy = maxdepth;
+ set_source_rgba(gc, 1, 0.2, 0.2, 0.20);
+
+ entry = pi->entry;
+ move_to(gc, 0, 0);
+ for (i = 0; i < pi->nr; i++, entry++)
+ line_to(gc, entry->sec, entry->depth);
+ cairo_close_path(gc->cr);
+ if (gc->printer) {
+ set_source_rgba(gc, 1, 1, 1, 0.2);
+ cairo_fill_preserve(cr);
+ set_source_rgb(gc, 1, 1, 1);
+ cairo_stroke(cr);
+ return;
+ }
+ cairo_fill(gc->cr);
+
+ /* Now do it again for the velocity colors */
+ entry = pi->entry;
+ for (i = 1; i < pi->nr; i++) {
+ entry++;
+ sec = entry->sec;
+ /* we want to draw the segments in different colors
+ * representing the vertical velocity, so we need to
+ * chop this into short segments */
+ rgb_t color = rgb[entry->velocity];
+ depth = entry->depth;
+ set_source_rgb(gc, color.r, color.g, color.b);
+ move_to(gc, entry[-1].sec, entry[-1].depth);
+ line_to(gc, sec, depth);
+ cairo_stroke(cr);
+ }
+}
+
+static int setup_temperature_limits(struct graphics_context *gc, struct plot_info *pi)
+{
+ int maxtime, mintemp, maxtemp, delta;
+
+ /* Get plot scaling limits */
+ maxtime = get_maxtime(pi);
+ mintemp = pi->mintemp;
+ maxtemp = pi->maxtemp;
+
+ gc->leftx = 0; gc->rightx = maxtime;
+ /* Show temperatures in roughly the lower third, but make sure the scale
+ is at least somewhat reasonable */
+ delta = maxtemp - mintemp;
+ if (delta > 3000) { /* more than 3K in fluctuation */
+ gc->topy = maxtemp + delta*2;
+ gc->bottomy = mintemp - delta/2;
+ } else {
+ gc->topy = maxtemp + 1500 + delta*2;
+ gc->bottomy = mintemp - delta/2;
+ }
+
+ return maxtemp > mintemp;
+}
+
+static void plot_single_temp_text(struct graphics_context *gc, int sec, int mkelvin)
+{
+ int deg;
+ const char *unit;
+ static const text_render_options_t tro = {12, 0.2, 0.2, 1.0, LEFT, TOP};
+ temperature_t temperature = { mkelvin };
+
+ if (output_units.temperature == FAHRENHEIT) {
+ deg = to_F(temperature);
+ unit = UTF8_DEGREE "F";
+ } else {
+ deg = to_C(temperature);
+ unit = UTF8_DEGREE "C";
+ }
+ plot_text(gc, &tro, sec, temperature.mkelvin, "%d%s", deg, unit);