X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=profile.c;h=9d84ff29d64de926983555be28660abcef2786dc;hb=feec55504084baf022517d39e72431b4d361a217;hp=b67557088762f330d31e07e20da699193d62bdf4;hpb=059f047788a9549e448f6e9f108a9f55b81ee64c;p=ext%2Fsubsurface.git diff --git a/profile.c b/profile.c index b675570..9d84ff2 100644 --- a/profile.c +++ b/profile.c @@ -8,16 +8,21 @@ int selected_dive = 0; #define ROUND_UP(x,y) ((((x)+(y)-1)/(y))*(y)) -#define MAX(x,y) ((x) > (y) ? (x) : (y)) +/* + * When showing dive profiles, we scale things to the + * current dive. However, we don't scale past less than + * 30 minutes or 90 ft, just so that small dives show + * up as such. + */ static int round_seconds_up(int seconds) { - return MAX(30, ROUND_UP(seconds, 60*10)); + return MAX(30*60, ROUND_UP(seconds, 60*10)); } static int round_feet_up(int feet) { - return MAX(45, ROUND_UP(feet+5, 15)); + return MAX(90, ROUND_UP(feet+5, 15)); } /* Scale to 0,0 -> maxx,maxy */ @@ -95,7 +100,7 @@ static void plot(cairo_t *cr, int w, int h, struct dive *dive, int samples, stru static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) { - struct dive *dive = dive_table.dives[selected_dive]; + struct dive *dive = current_dive; cairo_t *cr; int w,h; @@ -106,7 +111,7 @@ static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer cairo_set_source_rgb(cr, 0, 0, 0); cairo_paint(cr); - if (dive->samples) + if (dive && dive->samples) plot(cr, w, h, dive, dive->samples, dive->sample); cairo_destroy(cr);