]> git.tdb.fi Git - ext/subsurface.git/blobdiff - profile.c
Some UI beauty patches:
[ext/subsurface.git] / profile.c
index b4b923095864a5a5736f901c3781d2dae6ac3ada..c0313032de7ba416c152285f31351c9a1b9d873a 100644 (file)
--- a/profile.c
+++ b/profile.c
@@ -47,6 +47,14 @@ static void plot_profile(struct dive *dive, cairo_t *cr,
        maxtime = round_seconds_up(dive->duration.seconds);
        maxdepth = round_feet_up(to_feet(dive->maxdepth));
 
+       /* Time markers: every 5 min */
+       scalex = maxtime;
+       scaley = 1.0;
+       for (i = 5*60; i < maxtime; i += 5*60) {
+               cairo_move_to(cr, SCALE(i, 0));
+               cairo_line_to(cr, SCALE(i, 1));
+       }
+
        /* Depth markers: every 15 ft */
        scalex = 1.0;
        scaley = maxdepth;
@@ -55,17 +63,15 @@ static void plot_profile(struct dive *dive, cairo_t *cr,
                cairo_move_to(cr, SCALE(0, i));
                cairo_line_to(cr, SCALE(1, i));
        }
+       cairo_stroke(cr);
 
-       /* Time markers: every 5 min */
-       scalex = maxtime;
-       scaley = 1.0;
-       for (i = 5*60; i < maxtime; i += 5*60) {
-               cairo_move_to(cr, SCALE(i, 0));
-               cairo_line_to(cr, SCALE(i, 1));
-       }
+       /* Show mean depth */
+       cairo_set_source_rgba(cr, 1, 0.2, 0.2, 0.40);
+       cairo_move_to(cr, SCALE(0, to_feet(dive->meandepth)));
+       cairo_line_to(cr, SCALE(1, to_feet(dive->meandepth)));
        cairo_stroke(cr);
 
-       scaley = maxdepth;
+       scalex = maxtime;
 
        sample = dive->sample;
        cairo_set_source_rgba(cr, 1, 0.2, 0.2, 0.80);
@@ -87,7 +93,7 @@ static void plot_profile(struct dive *dive, cairo_t *cr,
        cairo_stroke(cr);
 }
 
-static int get_tank_pressure_range(struct dive *dive, double *scalex, double *scaley)
+static int get_cylinder_pressure_range(struct dive *dive, double *scalex, double *scaley)
 {
        int i;
        double min, max;
@@ -100,9 +106,9 @@ static int get_tank_pressure_range(struct dive *dive, double *scalex, double *sc
                struct sample *sample = dive->sample + i;
                double bar;
 
-               if (!sample->tankpressure.mbar)
+               if (!sample->cylinderpressure.mbar)
                        continue;
-               bar = sample->tankpressure.mbar;
+               bar = sample->cylinderpressure.mbar;
                if (bar < min)
                        min = bar;
                if (bar > max)
@@ -114,13 +120,13 @@ static int get_tank_pressure_range(struct dive *dive, double *scalex, double *sc
        return 1;
 }
 
-static void plot_tank_pressure(struct dive *dive, cairo_t *cr,
+static void plot_cylinder_pressure(struct dive *dive, cairo_t *cr,
        double topx, double topy, double maxx, double maxy)
 {
        int i;
        double scalex, scaley;
 
-       if (!get_tank_pressure_range(dive, &scalex, &scaley))
+       if (!get_cylinder_pressure_range(dive, &scalex, &scaley))
                return;
 
        cairo_set_source_rgba(cr, 0.2, 1.0, 0.2, 0.80);
@@ -131,7 +137,7 @@ static void plot_tank_pressure(struct dive *dive, cairo_t *cr,
                struct sample *sample = dive->sample + i;
 
                sec = sample->time.seconds;
-               mbar = sample->tankpressure.mbar;
+               mbar = sample->cylinderpressure.mbar;
                if (!mbar)
                        continue;
                cairo_line_to(cr, SCALE(sec, mbar));
@@ -153,8 +159,8 @@ static void plot(cairo_t *cr, int w, int h, struct dive *dive)
        /* Depth profile */
        plot_profile(dive, cr, topx, topy, maxx, maxy);
 
-       /* Tank pressure plot? */
-       plot_tank_pressure(dive, cr, topx, topy, maxx, maxy);
+       /* Cylinder pressure plot? */
+       plot_cylinder_pressure(dive, cr, topx, topy, maxx, maxy);
 
        /* Bounding box last */
        scalex = scaley = 1.0;
@@ -194,7 +200,7 @@ GtkWidget *dive_profile_frame(void)
        GtkWidget *frame;
        GtkWidget *da;
 
-       frame = gtk_frame_new("Dive profile");
+       frame = gtk_frame_new("Dive Profile");
        gtk_widget_show(frame);
        da = gtk_drawing_area_new();
        gtk_widget_set_size_request(da, 450, 350);