mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
profile: pass dive to plot function of profile-items
Instead of accessing the global displayed_dive variable, pass the dive to the various profile items. This is a step in making the profile code reentrant. This removes the last user of the displayed_dc macro, which can now be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
be9f9efb0e
commit
193513a61f
4 changed files with 31 additions and 31 deletions
|
@ -113,7 +113,6 @@ extern struct dive displayed_dive;
|
||||||
extern unsigned int dc_number;
|
extern unsigned int dc_number;
|
||||||
extern struct dive *current_dive;
|
extern struct dive *current_dive;
|
||||||
#define current_dc (get_dive_dc(current_dive, dc_number))
|
#define current_dc (get_dive_dc(current_dive, dc_number))
|
||||||
#define displayed_dc (get_dive_dc(&displayed_dive, dc_number))
|
|
||||||
|
|
||||||
extern struct dive *get_dive(int nr);
|
extern struct dive *get_dive(int nr);
|
||||||
extern struct dive *get_dive_from_table(int nr, const struct dive_table *dt);
|
extern struct dive *get_dive_from_table(int nr, const struct dive_table *dt);
|
||||||
|
|
|
@ -31,7 +31,7 @@ void AbstractProfilePolygonItem::setVisible(bool visible)
|
||||||
QGraphicsPolygonItem::setVisible(visible);
|
QGraphicsPolygonItem::setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractProfilePolygonItem::replot()
|
void AbstractProfilePolygonItem::replot(const dive *)
|
||||||
{
|
{
|
||||||
// Calculate the polygon. This is the polygon that will be painted on screen
|
// Calculate the polygon. This is the polygon that will be painted on screen
|
||||||
// on the ::paint method. Here we calculate the correct position of the points
|
// on the ::paint method. Here we calculate the correct position of the points
|
||||||
|
@ -85,9 +85,9 @@ void DiveProfileItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveProfileItem::replot()
|
void DiveProfileItem::replot(const dive *d)
|
||||||
{
|
{
|
||||||
AbstractProfilePolygonItem::replot();
|
AbstractProfilePolygonItem::replot(d);
|
||||||
if (polygon().isEmpty())
|
if (polygon().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ DiveHeartrateItem::DiveHeartrateItem(const DivePlotDataModel &model, const DiveC
|
||||||
connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::hrgraphChanged, this, &DiveHeartrateItem::setVisible);
|
connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::hrgraphChanged, this, &DiveHeartrateItem::setVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveHeartrateItem::replot()
|
void DiveHeartrateItem::replot(const dive *)
|
||||||
{
|
{
|
||||||
int last = -300, last_printed_hr = 0, sec = 0;
|
int last = -300, last_printed_hr = 0, sec = 0;
|
||||||
struct {
|
struct {
|
||||||
|
@ -244,7 +244,7 @@ DivePercentageItem::DivePercentageItem(const DivePlotDataModel &model, const Div
|
||||||
connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::percentagegraphChanged, this, &DivePercentageItem::setVisible);
|
connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::percentagegraphChanged, this, &DivePercentageItem::setVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePercentageItem::replot()
|
void DivePercentageItem::replot(const dive *d)
|
||||||
{
|
{
|
||||||
// Ignore empty values. a heart rate of 0 would be a bad sign.
|
// Ignore empty values. a heart rate of 0 would be a bad sign.
|
||||||
QPolygonF poly;
|
QPolygonF poly;
|
||||||
|
@ -257,7 +257,7 @@ void DivePercentageItem::replot()
|
||||||
double value = dataModel.index(i, vDataColumn).data().toDouble();
|
double value = dataModel.index(i, vDataColumn).data().toDouble();
|
||||||
struct gasmix gasmix = gasmix_air;
|
struct gasmix gasmix = gasmix_air;
|
||||||
const struct event *ev = NULL;
|
const struct event *ev = NULL;
|
||||||
gasmix = get_gasmix(&displayed_dive, displayed_dc, sec, &ev, gasmix);
|
gasmix = get_gasmix(d, get_dive_dc_const(d, dc_number), sec, &ev, gasmix);
|
||||||
int inert = get_n2(gasmix) + get_he(gasmix);
|
int inert = get_n2(gasmix) + get_he(gasmix);
|
||||||
colors.push_back(ColorScale(value, inert));
|
colors.push_back(ColorScale(value, inert));
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ DiveAmbPressureItem::DiveAmbPressureItem(const DivePlotDataModel &model, const D
|
||||||
setPen(pen);
|
setPen(pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveAmbPressureItem::replot()
|
void DiveAmbPressureItem::replot(const dive *)
|
||||||
{
|
{
|
||||||
int sec = 0;
|
int sec = 0;
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ DiveGFLineItem::DiveGFLineItem(const DivePlotDataModel &model, const DiveCartesi
|
||||||
setPen(pen);
|
setPen(pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveGFLineItem::replot()
|
void DiveGFLineItem::replot(const dive *)
|
||||||
{
|
{
|
||||||
int sec = 0;
|
int sec = 0;
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ DiveTemperatureItem::DiveTemperatureItem(const DivePlotDataModel &model, const D
|
||||||
setPen(pen);
|
setPen(pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveTemperatureItem::replot()
|
void DiveTemperatureItem::replot(const dive *)
|
||||||
{
|
{
|
||||||
int last = -300, last_printed_temp = 0, sec = 0, last_valid_temp = 0;
|
int last = -300, last_printed_temp = 0, sec = 0, last_valid_temp = 0;
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ DiveMeanDepthItem::DiveMeanDepthItem(const DivePlotDataModel &model, const DiveC
|
||||||
lastRunningSum = 0.0;
|
lastRunningSum = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveMeanDepthItem::replot()
|
void DiveMeanDepthItem::replot(const dive *)
|
||||||
{
|
{
|
||||||
double meandepthvalue = 0.0;
|
double meandepthvalue = 0.0;
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ void DiveMeanDepthItem::createTextItem()
|
||||||
texts.append(text);
|
texts.append(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveGasPressureItem::replot()
|
void DiveGasPressureItem::replot(const dive *d)
|
||||||
{
|
{
|
||||||
const struct plot_info *pInfo = &dataModel.data();
|
const struct plot_info *pInfo = &dataModel.data();
|
||||||
std::vector<int> plotted_cyl(pInfo->nr_cylinders, false);
|
std::vector<int> plotted_cyl(pInfo->nr_cylinders, false);
|
||||||
|
@ -550,7 +550,7 @@ void DiveGasPressureItem::replot()
|
||||||
QColor color;
|
QColor color;
|
||||||
if (!in_planner()) {
|
if (!in_planner()) {
|
||||||
if (entry->sac)
|
if (entry->sac)
|
||||||
color = getSacColor(entry->sac, displayed_dive.sac);
|
color = getSacColor(entry->sac, d->sac);
|
||||||
else
|
else
|
||||||
color = MED_GRAY_HIGH_TRANS;
|
color = MED_GRAY_HIGH_TRANS;
|
||||||
} else {
|
} else {
|
||||||
|
@ -629,7 +629,7 @@ void DiveGasPressureItem::replot()
|
||||||
label_y_offset = -7 * axisLog;
|
label_y_offset = -7 * axisLog;
|
||||||
}
|
}
|
||||||
plotPressureValue(mbar, entry->sec, alignVar, value_y_offset);
|
plotPressureValue(mbar, entry->sec, alignVar, value_y_offset);
|
||||||
plotGasValue(mbar, entry->sec, get_cylinder(&displayed_dive, cyl)->gasmix, alignVar, label_y_offset);
|
plotGasValue(mbar, entry->sec, get_cylinder(d, cyl)->gasmix, alignVar, label_y_offset);
|
||||||
seen_cyl[cyl] = true;
|
seen_cyl[cyl] = true;
|
||||||
|
|
||||||
/* Alternate alignment as we see cylinder use.. */
|
/* Alternate alignment as we see cylinder use.. */
|
||||||
|
@ -699,9 +699,9 @@ DiveCalculatedCeiling::DiveCalculatedCeiling(const DivePlotDataModel &model, con
|
||||||
setVisible(prefs.calcceiling);
|
setVisible(prefs.calcceiling);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveCalculatedCeiling::replot()
|
void DiveCalculatedCeiling::replot(const dive *d)
|
||||||
{
|
{
|
||||||
AbstractProfilePolygonItem::replot();
|
AbstractProfilePolygonItem::replot(d);
|
||||||
// Add 2 points to close the polygon.
|
// Add 2 points to close the polygon.
|
||||||
QPolygonF poly = polygon();
|
QPolygonF poly = polygon();
|
||||||
if (poly.isEmpty())
|
if (poly.isEmpty())
|
||||||
|
@ -747,7 +747,7 @@ DiveReportedCeiling::DiveReportedCeiling(const DivePlotDataModel &model, const D
|
||||||
setVisible(prefs.dcceiling);
|
setVisible(prefs.dcceiling);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveReportedCeiling::replot()
|
void DiveReportedCeiling::replot(const dive *)
|
||||||
{
|
{
|
||||||
QPolygonF p;
|
QPolygonF p;
|
||||||
p.append(QPointF(hAxis.posAtValue(0), vAxis.posAtValue(0)));
|
p.append(QPointF(hAxis.posAtValue(0), vAxis.posAtValue(0)));
|
||||||
|
@ -780,7 +780,7 @@ void DiveReportedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
||||||
QGraphicsPolygonItem::paint(painter, option, widget);
|
QGraphicsPolygonItem::paint(painter, option, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartialPressureGasItem::replot()
|
void PartialPressureGasItem::replot(const dive *)
|
||||||
{
|
{
|
||||||
plot_data *entry = dataModel.data().entry;
|
plot_data *entry = dataModel.data().entry;
|
||||||
QPolygonF poly;
|
QPolygonF poly;
|
||||||
|
|
|
@ -28,6 +28,7 @@ class DiveTextItem;
|
||||||
class DiveCartesianAxis;
|
class DiveCartesianAxis;
|
||||||
class QAbstractTableModel;
|
class QAbstractTableModel;
|
||||||
struct plot_data;
|
struct plot_data;
|
||||||
|
struct dive;
|
||||||
|
|
||||||
class AbstractProfilePolygonItem : public QObject, public QGraphicsPolygonItem {
|
class AbstractProfilePolygonItem : public QObject, public QGraphicsPolygonItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -38,7 +39,7 @@ public:
|
||||||
AbstractProfilePolygonItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
AbstractProfilePolygonItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
|
||||||
void clear();
|
void clear();
|
||||||
virtual void replot();
|
virtual void replot(const dive *d);
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
|
@ -67,7 +68,7 @@ class DiveProfileItem : public AbstractProfilePolygonItem {
|
||||||
public:
|
public:
|
||||||
DiveProfileItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
DiveProfileItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color);
|
void plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color);
|
||||||
int maxCeiling(int row);
|
int maxCeiling(int row);
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ class DiveMeanDepthItem : public AbstractProfilePolygonItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -94,7 +95,7 @@ class DiveTemperatureItem : public AbstractProfilePolygonItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DiveTemperatureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
DiveTemperatureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -105,7 +106,7 @@ class DiveHeartrateItem : public AbstractProfilePolygonItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DiveHeartrateItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
DiveHeartrateItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -117,7 +118,7 @@ class DivePercentageItem : public AbstractProfilePolygonItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DivePercentageItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, int i);
|
DivePercentageItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, int i);
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -132,7 +133,7 @@ class DiveAmbPressureItem : public AbstractProfilePolygonItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DiveAmbPressureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
DiveAmbPressureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -143,7 +144,7 @@ class DiveGFLineItem : public AbstractProfilePolygonItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DiveGFLineItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
DiveGFLineItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -155,7 +156,7 @@ class DiveGasPressureItem : public AbstractProfilePolygonItem {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using AbstractProfilePolygonItem::AbstractProfilePolygonItem;
|
using AbstractProfilePolygonItem::AbstractProfilePolygonItem;
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -174,7 +175,7 @@ class DiveCalculatedCeiling : public AbstractProfilePolygonItem {
|
||||||
public:
|
public:
|
||||||
DiveCalculatedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
DiveCalculatedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||||
const DiveCartesianAxis &vAxis, int vColumn, ProfileWidget2 *profileWidget);
|
const DiveCartesianAxis &vAxis, int vColumn, ProfileWidget2 *profileWidget);
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -186,7 +187,7 @@ class DiveReportedCeiling : public AbstractProfilePolygonItem {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DiveReportedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
DiveReportedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -203,7 +204,7 @@ class PartialPressureGasItem : public AbstractProfilePolygonItem {
|
||||||
public:
|
public:
|
||||||
PartialPressureGasItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
PartialPressureGasItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||||
void replot() override;
|
void replot(const dive *d) override;
|
||||||
void setThresholdSettingsKey(const double *prefPointerMin, const double *prefPointerMax);
|
void setThresholdSettingsKey(const double *prefPointerMin, const double *prefPointerMax);
|
||||||
void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey);
|
void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey);
|
||||||
void setColors(const QColor &normalColor, const QColor &alertColor);
|
void setColors(const QColor &normalColor, const QColor &alertColor);
|
||||||
|
|
|
@ -737,7 +737,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
|
||||||
|
|
||||||
// Replot dive items
|
// Replot dive items
|
||||||
for (AbstractProfilePolygonItem *item: profileItems)
|
for (AbstractProfilePolygonItem *item: profileItems)
|
||||||
item->replot();
|
item->replot(&displayed_dive);
|
||||||
|
|
||||||
// The event items are a bit special since we don't know how many events are going to
|
// The event items are a bit special since we don't know how many events are going to
|
||||||
// exist on a dive, so I cant create cache items for that. that's why they are here
|
// exist on a dive, so I cant create cache items for that. that's why they are here
|
||||||
|
|
Loading…
Reference in a new issue