#include "dive.h"
#include "display.h"
+#include "divelist.h"
int selected_dive = 0;
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;
struct sample *sample = dive->sample + i;
double bar;
- if (!sample->tankpressure.mbar)
+ /* FIXME! We only track cylinder 0 right now */
+ if (sample->cylinderindex)
continue;
- bar = sample->tankpressure.mbar;
+ if (!sample->cylinderpressure.mbar)
+ continue;
+ bar = sample->cylinderpressure.mbar;
if (bar < min)
min = bar;
if (bar > max)
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);
- cairo_move_to(cr, SCALE(0, dive->beginning_pressure.mbar));
+ cairo_move_to(cr, SCALE(0, dive->cylinder[0].start.mbar));
for (i = 1; i < dive->samples; i++) {
int sec, mbar;
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));
}
- cairo_line_to(cr, SCALE(dive->duration.seconds, dive->end_pressure.mbar));
+ cairo_line_to(cr, SCALE(dive->duration.seconds, dive->cylinder[0].end.mbar));
cairo_stroke(cr);
}
/* 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;
return FALSE;
}
-GtkWidget *dive_profile_frame(void)
+GtkWidget *dive_profile_widget(void)
{
- GtkWidget *frame;
GtkWidget *da;
- frame = gtk_frame_new("Dive profile");
- gtk_widget_show(frame);
da = gtk_drawing_area_new();
gtk_widget_set_size_request(da, 450, 350);
g_signal_connect(da, "expose_event", G_CALLBACK(expose_event), NULL);
- gtk_container_add(GTK_CONTAINER(frame), da);
- return frame;
+ return da;
}