mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Hand planner variables to profile
Pass the planner state struct to the profile computation so it can use deco_time and first ceiling to display VPM-B ceiling. Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
parent
8e21a65653
commit
088db5e12b
6 changed files with 15 additions and 8 deletions
|
@ -986,14 +986,18 @@ static void calculate_ndl_tts(struct deco_state *ds, struct dive *dive, struct p
|
||||||
|
|
||||||
/* Let's try to do some deco calculations.
|
/* Let's try to do some deco calculations.
|
||||||
*/
|
*/
|
||||||
void calculate_deco_information(struct deco_state *ds, struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool print_mode)
|
void calculate_deco_information(struct deco_state *ds, struct deco_state *planner_ds, struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool print_mode)
|
||||||
{
|
{
|
||||||
int i, count_iteration = 0;
|
int i, count_iteration = 0;
|
||||||
double surface_pressure = (dc->surface_pressure.mbar ? dc->surface_pressure.mbar : get_surface_pressure_in_mbar(dive, true)) / 1000.0;
|
double surface_pressure = (dc->surface_pressure.mbar ? dc->surface_pressure.mbar : get_surface_pressure_in_mbar(dive, true)) / 1000.0;
|
||||||
bool first_iteration = true;
|
bool first_iteration = true;
|
||||||
int prev_deco_time = 10000000, time_deep_ceiling = 0;
|
int prev_deco_time = 10000000, time_deep_ceiling = 0;
|
||||||
if (!in_planner())
|
if (!in_planner()) {
|
||||||
ds->deco_time = 0;
|
ds->deco_time = 0;
|
||||||
|
} else {
|
||||||
|
ds->deco_time = planner_ds->deco_time;
|
||||||
|
ds->first_ceiling_pressure = planner_ds->first_ceiling_pressure;
|
||||||
|
}
|
||||||
struct deco_state *cache_data_initial = NULL;
|
struct deco_state *cache_data_initial = NULL;
|
||||||
lock_planner();
|
lock_planner();
|
||||||
/* For VPM-B outside the planner, cache the initial deco state for CVA iterations */
|
/* For VPM-B outside the planner, cache the initial deco state for CVA iterations */
|
||||||
|
@ -1300,7 +1304,7 @@ static void debug_print_profiledata(struct plot_info *pi)
|
||||||
* sides, so that you can do end-points without having to worry
|
* sides, so that you can do end-points without having to worry
|
||||||
* about it.
|
* about it.
|
||||||
*/
|
*/
|
||||||
void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool fast)
|
void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool fast, struct deco_state *planner_ds)
|
||||||
{
|
{
|
||||||
int o2, he, o2max;
|
int o2, he, o2max;
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
|
@ -1333,7 +1337,7 @@ void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plo
|
||||||
fill_o2_values(dive, dc, pi); /* .. and insert the O2 sensor data having 0 values. */
|
fill_o2_values(dive, dc, pi); /* .. and insert the O2 sensor data having 0 values. */
|
||||||
calculate_sac(dive, dc, pi); /* Calculate sac */
|
calculate_sac(dive, dc, pi); /* Calculate sac */
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
calculate_deco_information(&plot_deco_state, dive, dc, pi, false); /* and ceiling information, using gradient factor values in Preferences) */
|
calculate_deco_information(&plot_deco_state, planner_ds, dive, dc, pi, false); /* and ceiling information, using gradient factor values in Preferences) */
|
||||||
#endif
|
#endif
|
||||||
calculate_gas_information_new(dive, dc, pi); /* Calculate gas partial pressures */
|
calculate_gas_information_new(dive, dc, pi); /* Calculate gas partial pressures */
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,8 @@ 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);
|
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_data *populate_plot_entries(struct dive *dive, struct divecomputer *dc, struct plot_info *pi);
|
||||||
struct plot_info *analyze_plot_info(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, bool fast);
|
void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool fast, struct deco_state *planner_ds);
|
||||||
void calculate_deco_information(struct deco_state *ds, struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool print_mode);
|
void calculate_deco_information(struct deco_state *ds, struct deco_state *planner_de, 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 *);
|
struct plot_data *get_plot_details_new(struct plot_info *pi, int time, struct membuffer *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -640,7 +640,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
|
||||||
* shown.
|
* shown.
|
||||||
*/
|
*/
|
||||||
plotInfo = calculate_max_limits_new(&displayed_dive, currentdc);
|
plotInfo = calculate_max_limits_new(&displayed_dive, currentdc);
|
||||||
create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth);
|
create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth, &DivePlannerPointsModel::instance()->final_deco_state);
|
||||||
int newMaxtime = get_maxtime(&plotInfo);
|
int newMaxtime = get_maxtime(&plotInfo);
|
||||||
if (shouldCalculateMaxTime || newMaxtime > maxtime)
|
if (shouldCalculateMaxTime || newMaxtime > maxtime)
|
||||||
maxtime = newMaxtime;
|
maxtime = newMaxtime;
|
||||||
|
|
|
@ -924,6 +924,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
|
||||||
struct deco_state plan_deco_state;
|
struct deco_state plan_deco_state;
|
||||||
plan(&plan_deco_state, &diveplan, &displayed_dive, DECOTIMESTEP, stoptable, &cache, isPlanner(), false);
|
plan(&plan_deco_state, &diveplan, &displayed_dive, DECOTIMESTEP, stoptable, &cache, isPlanner(), false);
|
||||||
//QtConcurrent::run(this, &DivePlannerPointsModel::computeVariations, &ds_after_previous_dives);
|
//QtConcurrent::run(this, &DivePlannerPointsModel::computeVariations, &ds_after_previous_dives);
|
||||||
|
final_deco_state = plan_deco_state;
|
||||||
emit calculatedPlanNotes();
|
emit calculatedPlanNotes();
|
||||||
}
|
}
|
||||||
// throw away the cache
|
// throw away the cache
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
int lastEnteredPoint();
|
int lastEnteredPoint();
|
||||||
void removeDeco();
|
void removeDeco();
|
||||||
static bool addingDeco;
|
static bool addingDeco;
|
||||||
|
struct deco_state final_deco_state;
|
||||||
|
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "qt-models/diveplotdatamodel.h"
|
#include "qt-models/diveplotdatamodel.h"
|
||||||
|
#include "qt-models/diveplannermodel.h"
|
||||||
#include "core/dive.h"
|
#include "core/dive.h"
|
||||||
#include "core/profile.h"
|
#include "core/profile.h"
|
||||||
#include "core/divelist.h"
|
#include "core/divelist.h"
|
||||||
|
@ -232,7 +233,7 @@ void DivePlotDataModel::calculateDecompression()
|
||||||
{
|
{
|
||||||
struct divecomputer *dc = select_dc(&displayed_dive);
|
struct divecomputer *dc = select_dc(&displayed_dive);
|
||||||
init_decompression(&plot_deco_state, &displayed_dive);
|
init_decompression(&plot_deco_state, &displayed_dive);
|
||||||
calculate_deco_information(&plot_deco_state, &displayed_dive, dc, &pInfo, false);
|
calculate_deco_information(&plot_deco_state, &(DivePlannerPointsModel::instance()->final_deco_state), &displayed_dive, dc, &pInfo, false);
|
||||||
dataChanged(index(0, CEILING), index(pInfo.nr - 1, TISSUE_16));
|
dataChanged(index(0, CEILING), index(pInfo.nr - 1, TISSUE_16));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue