mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
profile: pass dive to RulerItem
Instead of accessing the global displayed_dive variable in RulerItem, pass the dive. This is a step in making the profile reentrant. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
54e8fe5d9e
commit
88c6ce988d
5 changed files with 11 additions and 9 deletions
|
@ -1585,7 +1585,7 @@ int get_plot_details_new(const struct dive *d, const struct plot_info *pi, int t
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compare two plot_data entries and writes the results into a string */
|
/* Compare two plot_data entries and writes the results into a string */
|
||||||
void compare_samples(struct plot_info *pi, int idx1, int idx2, char *buf, int bufsize, bool sum)
|
void compare_samples(const struct dive *d, const struct plot_info *pi, int idx1, int idx2, char *buf, int bufsize, bool sum)
|
||||||
{
|
{
|
||||||
struct plot_data *start, *stop, *data;
|
struct plot_data *start, *stop, *data;
|
||||||
const char *depth_unit, *pressure_unit, *vertical_speed_unit;
|
const char *depth_unit, *pressure_unit, *vertical_speed_unit;
|
||||||
|
@ -1691,11 +1691,11 @@ void compare_samples(struct plot_info *pi, int idx1, int idx2, char *buf, int bu
|
||||||
memcpy(buf2, buf, bufsize);
|
memcpy(buf2, buf, bufsize);
|
||||||
|
|
||||||
/* Only print if gas has been used */
|
/* Only print if gas has been used */
|
||||||
if (bar_used) {
|
if (bar_used && d->cylinders.nr > 0) {
|
||||||
pressurevalue = get_pressure_units(bar_used, &pressure_unit);
|
pressurevalue = get_pressure_units(bar_used, &pressure_unit);
|
||||||
memcpy(buf2, buf, bufsize);
|
memcpy(buf2, buf, bufsize);
|
||||||
snprintf_loc(buf, bufsize, translate("gettextFromC", "%s ΔP:%d%s"), buf2, pressurevalue, pressure_unit);
|
snprintf_loc(buf, bufsize, translate("gettextFromC", "%s ΔP:%d%s"), buf2, pressurevalue, pressure_unit);
|
||||||
cylinder_t *cyl = get_cylinder(&displayed_dive, 0);
|
cylinder_t *cyl = get_cylinder(d, 0);
|
||||||
/* if we didn't cross a tank change and know the cylidner size as well, show SAC rate */
|
/* if we didn't cross a tank change and know the cylidner size as well, show SAC rate */
|
||||||
if (!crossed_tankchange && cyl->type.size.mliter) {
|
if (!crossed_tankchange && cyl->type.size.mliter) {
|
||||||
double volume_value;
|
double volume_value;
|
||||||
|
@ -1713,7 +1713,7 @@ void compare_samples(struct plot_info *pi, int idx1, int idx2, char *buf, int bu
|
||||||
int volume_used = gas_volume(cyl, first_pressure) - gas_volume(cyl, stop_pressure);
|
int volume_used = gas_volume(cyl, first_pressure) - gas_volume(cyl, stop_pressure);
|
||||||
|
|
||||||
/* Mean pressure in ATM */
|
/* Mean pressure in ATM */
|
||||||
double atm = depth_to_atm(avg_depth, &displayed_dive);
|
double atm = depth_to_atm(avg_depth, d);
|
||||||
|
|
||||||
/* milliliters per minute */
|
/* milliliters per minute */
|
||||||
int sac = lrint(volume_used / atm * 60 / delta_time);
|
int sac = lrint(volume_used / atm * 60 / delta_time);
|
||||||
|
|
|
@ -80,7 +80,7 @@ struct plot_data {
|
||||||
bool icd_warning;
|
bool icd_warning;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void compare_samples(struct plot_info *p1, int idx1, int idx2, char *buf, int bufsize, bool sum);
|
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);
|
extern void init_plot_info(struct plot_info *pi);
|
||||||
/* when planner_dc is non-null, this is called in planner mode. */
|
/* when planner_dc is non-null, this is called in planner mode. */
|
||||||
extern void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool fast, const struct deco_state *planner_ds);
|
extern void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool fast, const struct deco_state *planner_ds);
|
||||||
|
|
|
@ -691,7 +691,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
|
||||||
cylinderPressureAxis->setMinimum(plotInfo.minpressure);
|
cylinderPressureAxis->setMinimum(plotInfo.minpressure);
|
||||||
cylinderPressureAxis->setMaximum(plotInfo.maxpressure);
|
cylinderPressureAxis->setMaximum(plotInfo.maxpressure);
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
rulerItem->setPlotInfo(plotInfo);
|
rulerItem->setPlotInfo(&displayed_dive, plotInfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SUBSURFACE_MOBILE
|
#ifdef SUBSURFACE_MOBILE
|
||||||
|
|
|
@ -113,7 +113,7 @@ void RulerItem2::recalculate()
|
||||||
}
|
}
|
||||||
QLineF line(startPoint, endPoint);
|
QLineF line(startPoint, endPoint);
|
||||||
setLine(line);
|
setLine(line);
|
||||||
compare_samples(&pInfo, source->idx, dest->idx, buffer, 500, 1);
|
compare_samples(dive, &pInfo, source->idx, dest->idx, buffer, 500, 1);
|
||||||
text = QString(buffer);
|
text = QString(buffer);
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
|
@ -148,8 +148,9 @@ RulerNodeItem2 *RulerItem2::destNode() const
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RulerItem2::setPlotInfo(const plot_info &info)
|
void RulerItem2::setPlotInfo(const struct dive *d, const plot_info &info)
|
||||||
{
|
{
|
||||||
|
dive = d;
|
||||||
pInfo = info;
|
pInfo = info;
|
||||||
dest->setPlotInfo(info);
|
dest->setPlotInfo(info);
|
||||||
source->setPlotInfo(info);
|
source->setPlotInfo(info);
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
explicit RulerItem2();
|
explicit RulerItem2();
|
||||||
void recalculate();
|
void recalculate();
|
||||||
|
|
||||||
void setPlotInfo(const struct plot_info &pInfo);
|
void setPlotInfo(const struct dive *d, const struct plot_info &pInfo);
|
||||||
RulerNodeItem2 *sourceNode() const;
|
RulerNodeItem2 *sourceNode() const;
|
||||||
RulerNodeItem2 *destNode() const;
|
RulerNodeItem2 *destNode() const;
|
||||||
void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth);
|
void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth);
|
||||||
|
@ -47,6 +47,7 @@ slots:
|
||||||
void settingsChanged(bool toggled);
|
void settingsChanged(bool toggled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const struct dive *dive;
|
||||||
struct plot_info pInfo;
|
struct plot_info pInfo;
|
||||||
QPointF startPoint, endPoint;
|
QPointF startPoint, endPoint;
|
||||||
RulerNodeItem2 *source, *dest;
|
RulerNodeItem2 *source, *dest;
|
||||||
|
|
Loading…
Reference in a new issue