From 2645fa14957a89e669ce88877f5dcfbb9257853e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 10 Dec 2021 17:44:37 +0100 Subject: [PATCH] profile: remove fast argument of create_plot_info_new() This prevented calculation of the pressure data when dragging planner handles. However, this lead to weird artifacts. As an alternative, if this turns out to be too slow, we might disable the plotting of the pressure curves instead. That said, even on my super-slow fanless laptop, this performs reasonably. Signed-off-by: Berthold Stoeger --- core/profile.c | 8 +++----- core/profile.h | 2 +- core/save-profiledata.c | 4 ++-- profile-widget/profilescene.cpp | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/profile.c b/core/profile.c index 0445542c5..6d79ca41f 100644 --- a/core/profile.c +++ b/core/profile.c @@ -1270,7 +1270,7 @@ void init_plot_info(struct plot_info *pi) * The old data will be freed. Before the first call, the plot * info must be initialized with init_plot_info(). */ -void create_plot_info_new(const struct dive *dive, const struct divecomputer *dc, struct plot_info *pi, bool fast, const struct deco_state *planner_ds) +void create_plot_info_new(const struct dive *dive, const struct divecomputer *dc, struct plot_info *pi, const struct deco_state *planner_ds) { int o2, he, o2max; struct deco_state plot_deco_state; @@ -1294,10 +1294,8 @@ void create_plot_info_new(const struct dive *dive, const struct divecomputer *dc check_setpoint_events(dive, dc, pi); /* Populate setpoints */ setup_gas_sensor_pressure(dive, dc, pi); /* Try to populate our gas pressure knowledge */ - if (!fast) { - for (int cyl = 0; cyl < pi->nr_cylinders; cyl++) - populate_pressure_information(dive, dc, pi, cyl); - } + for (int cyl = 0; cyl < pi->nr_cylinders; cyl++) + populate_pressure_information(dive, dc, pi, cyl); fill_o2_values(dive, dc, pi); /* .. and insert the O2 sensor data having 0 values. */ calculate_sac(dive, dc, pi); /* Calculate sac */ diff --git a/core/profile.h b/core/profile.h index 637f56fb0..1bb5101a7 100644 --- a/core/profile.h +++ b/core/profile.h @@ -81,7 +81,7 @@ struct plot_data { extern void compare_samples(const struct dive *d, const struct plot_info *pi, int idx1, int idx2, char *buf, int bufsize, bool sum); extern void init_plot_info(struct plot_info *pi); /* when planner_dc is non-null, this is called in planner mode. */ -extern void create_plot_info_new(const struct dive *dive, const struct divecomputer *dc, struct plot_info *pi, bool fast, const struct deco_state *planner_ds); +extern void create_plot_info_new(const struct dive *dive, const struct divecomputer *dc, struct plot_info *pi, const struct deco_state *planner_ds); extern int get_plot_details_new(const struct dive *d, const struct plot_info *pi, int time, struct membuffer *); extern void free_plot_info_data(struct plot_info *pi); diff --git a/core/save-profiledata.c b/core/save-profiledata.c index c5adf515b..67ff8ddd7 100644 --- a/core/save-profiledata.c +++ b/core/save-profiledata.c @@ -213,7 +213,7 @@ static void save_profiles_buffer(struct membuffer *b, bool select_only) for_each_dive(i, dive) { if (select_only && !dive->selected) continue; - create_plot_info_new(dive, &dive->dc, &pi, false, planner_deco_state); + create_plot_info_new(dive, &dive->dc, &pi, planner_deco_state); put_headers(b, pi.nr_cylinders); for (int i = 0; i < pi.nr; i++) @@ -229,7 +229,7 @@ void save_subtitles_buffer(struct membuffer *b, struct dive *dive, int offset, i struct deco_state *planner_deco_state = NULL; init_plot_info(&pi); - create_plot_info_new(dive, &dive->dc, &pi, false, planner_deco_state); + create_plot_info_new(dive, &dive->dc, &pi, planner_deco_state); put_format(b, "[Script Info]\n"); put_format(b, "; Script generated by Subsurface %s\n", subsurface_canonical_version()); diff --git a/profile-widget/profilescene.cpp b/profile-widget/profilescene.cpp index 4e6922e45..8108e88f1 100644 --- a/profile-widget/profilescene.cpp +++ b/profile-widget/profilescene.cpp @@ -438,7 +438,7 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM * create_plot_info_new() automatically frees old plot data. */ if (!keepPlotInfo) - create_plot_info_new(d, get_dive_dc_const(d, dc), &plotInfo, !calcMax, planner_ds); + create_plot_info_new(d, get_dive_dc_const(d, dc), &plotInfo, planner_ds); bool hasHeartBeat = plotInfo.maxhr; // For mobile we might want to turn of some features that are normally shown.