From 3abfc8e63b17d1d670b0e93aa747e000f03a8285 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Thu, 4 Dec 2014 16:42:00 +0100
Subject: [PATCH] Don't interpolate pressure while dragging waypoints

A profiler session in the planner shows that for deep long dives
a significant amount of CPU time is spent in populate_pressure_information()
which interpolates the cylinder pressure graphs.

This patch introduces a "fast" flag for the replot of the profile
which is active while the mouse button is still pressed and that
suppresses this calculation.

In the future, this flag could be used for other responsiveness tunings
of the plot.

Signed-off-by: Robert C. Helling <[email protected]>
---
 profile.c                        | 11 ++++++-----
 profile.h                        |  2 +-
 qt-ui/profile/profilewidget2.cpp |  2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/profile.c b/profile.c
index 20ac039..6efd05e 100644
--- a/profile.c
+++ b/profile.c
@@ -1028,7 +1028,7 @@ static void debug_print_profiledata(struct plot_info *pi)
  * sides, so that you can do end-points without having to worry
  * about it.
  */
-void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct 
plot_info *pi)
+void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct 
plot_info *pi, bool fast)
 {
        int o2, he, o2low;
        init_decompression(dive);
@@ -1049,10 +1049,11 @@ void create_plot_info_new(struct dive *dive, struct 
divecomputer *dc, struct plo
        check_gas_change_events(dive, dc, pi);                  /* Populate the 
gas index from the gas change events */
        check_setpoint_events(dive, dc, pi);                    /* Populate 
setpoints */
        setup_gas_sensor_pressure(dive, dc, pi);                /* Try to 
populate our gas pressure knowledge */
-       populate_pressure_information(dive, dc, pi, false);     /* .. calculate 
missing pressure entries for all gasses except o2 */
-       if (dc->dctype == CCR)                                  /* For CCR 
dives.. */
-               populate_pressure_information(dive, dc, pi, true); /* .. 
calculate missing o2 gas pressure entries */
-
+       if (!fast) {
+               populate_pressure_information(dive, dc, pi, false);     /* .. 
calculate missing pressure entries for all gasses except o2 */
+               if (dc->dctype == CCR)                                  /* For 
CCR dives.. */
+                       populate_pressure_information(dive, dc, pi, true); /* 
.. calculate missing o2 gas pressure entries */
+       }
        fill_o2_values(dc, pi, dive);                           /* .. and 
insert the O2 sensor data having 0 values. */
        calculate_sac(dive, pi); /* Calculate sac */
        calculate_deco_information(dive, dc, pi, false); /* and ceiling 
information, using gradient factor values in Preferences) */
diff --git a/profile.h b/profile.h
index 147e480..5d20095 100644
--- a/profile.h
+++ b/profile.h
@@ -70,7 +70,7 @@ struct plot_info calculate_max_limits_new(struct dive *dive, 
struct divecomputer
 void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, 
int bufsize, int sum);
 struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer 
*dc, struct plot_info *pi);
 struct plot_info *analyze_plot_info(struct plot_info *pi);
-void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct 
plot_info *pi);
+void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct 
plot_info *pi, bool fast);
 void calculate_deco_information(struct dive *dive, struct divecomputer *dc, 
struct plot_info *pi, bool print_mode);
 struct plot_data *get_plot_details_new(struct plot_info *pi, int time, struct 
membuffer *);
 
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 347cc1b..869a2ed 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -492,7 +492,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
         * shown.
         */
        plotInfo = calculate_max_limits_new(&displayed_dive, currentdc);
-       create_plot_info_new(&displayed_dive, currentdc, &plotInfo);
+       create_plot_info_new(&displayed_dive, currentdc, &plotInfo, 
!shouldCalculateMaxDepth);
        if(shouldCalculateMaxTime)
                maxtime = get_maxtime(&plotInfo);
 
-- 
1.9.3 (Apple Git-50)


Maybe this is a bit crude but it seems to work.

Best
Robert

-- 
.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oO
Robert C. Helling     Elite Master Course Theoretical and Mathematical Physics
                      Scientific Coordinator
                      Ludwig Maximilians Universitaet Muenchen, Dept. Physik
                      Phone: +49 89 2180-4523  Theresienstr. 39, rm. B339
                      http://www.atdotde.de

Enhance your privacy, use cryptography! My PGP keys have fingerprints
A9D1 A01D 13A5 31FA 6515  BB44 0820 367C 36BC 0C1D    and
DCED 37B6 251C 7861 270D  5613 95C7 9D32 9A8D 9B8F




Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to