summaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-02-13 17:42:03 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-02-17 07:26:55 -0800
commitc6d78bc134870fa2d9361b3f928451b7ab915043 (patch)
tree305ca5af1f55d3aefd918cc7ad73b806ef88af53 /profile-widget
parent65720d2fcef50ad66c741eba1c3c00bb01b74671 (diff)
downloadsubsurface-c6d78bc134870fa2d9361b3f928451b7ab915043.tar.gz
planner: pass in_planner argument to replot()
To remove reliance on global state, pass an "in_planner" argument to AbstractProfilePolygonItem::replot(). Thus, calls to in_planner() can be removed. This is a bit sad, since the in_planner argument is now passed to numerous replot() reimplementations of classes derived from AbstractProfilePolygonItem. However, it is only needed for one, viz. DiveGasPressureItem. Well, perhaps in the future more features will depend on the planner mode... Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/diveprofileitem.cpp30
-rw-r--r--profile-widget/diveprofileitem.h24
-rw-r--r--profile-widget/profilewidget2.cpp2
3 files changed, 28 insertions, 28 deletions
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp
index fca21b3f4..aa529364c 100644
--- a/profile-widget/diveprofileitem.cpp
+++ b/profile-widget/diveprofileitem.cpp
@@ -31,7 +31,7 @@ void AbstractProfilePolygonItem::setVisible(bool visible)
QGraphicsPolygonItem::setVisible(visible);
}
-void AbstractProfilePolygonItem::replot(const dive *)
+void AbstractProfilePolygonItem::replot(const dive *, bool)
{
// 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
@@ -85,9 +85,9 @@ void DiveProfileItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
painter->restore();
}
-void DiveProfileItem::replot(const dive *d)
+void DiveProfileItem::replot(const dive *d, bool in_planner)
{
- AbstractProfilePolygonItem::replot(d);
+ AbstractProfilePolygonItem::replot(d, in_planner);
if (polygon().isEmpty())
return;
@@ -165,7 +165,7 @@ DiveHeartrateItem::DiveHeartrateItem(const DivePlotDataModel &model, const DiveC
connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::hrgraphChanged, this, &DiveHeartrateItem::setVisible);
}
-void DiveHeartrateItem::replot(const dive *)
+void DiveHeartrateItem::replot(const dive *, bool)
{
int last = -300, last_printed_hr = 0, sec = 0;
struct {
@@ -244,7 +244,7 @@ DivePercentageItem::DivePercentageItem(const DivePlotDataModel &model, const Div
connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::percentagegraphChanged, this, &DivePercentageItem::setVisible);
}
-void DivePercentageItem::replot(const dive *d)
+void DivePercentageItem::replot(const dive *d, bool)
{
// Ignore empty values. a heart rate of 0 would be a bad sign.
QPolygonF poly;
@@ -318,7 +318,7 @@ DiveAmbPressureItem::DiveAmbPressureItem(const DivePlotDataModel &model, const D
setPen(pen);
}
-void DiveAmbPressureItem::replot(const dive *)
+void DiveAmbPressureItem::replot(const dive *, bool)
{
int sec = 0;
@@ -359,7 +359,7 @@ DiveGFLineItem::DiveGFLineItem(const DivePlotDataModel &model, const DiveCartesi
setPen(pen);
}
-void DiveGFLineItem::replot(const dive *)
+void DiveGFLineItem::replot(const dive *, bool)
{
int sec = 0;
@@ -400,7 +400,7 @@ DiveTemperatureItem::DiveTemperatureItem(const DivePlotDataModel &model, const D
setPen(pen);
}
-void DiveTemperatureItem::replot(const dive *)
+void DiveTemperatureItem::replot(const dive *, bool)
{
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;
}
-void DiveMeanDepthItem::replot(const dive *)
+void DiveMeanDepthItem::replot(const dive *, bool)
{
double meandepthvalue = 0.0;
@@ -525,7 +525,7 @@ void DiveMeanDepthItem::createTextItem()
texts.append(text);
}
-void DiveGasPressureItem::replot(const dive *d)
+void DiveGasPressureItem::replot(const dive *d, bool in_planner)
{
const struct plot_info *pInfo = &dataModel.data();
std::vector<int> plotted_cyl(pInfo->nr_cylinders, false);
@@ -548,7 +548,7 @@ void DiveGasPressureItem::replot(const dive *d)
boundingPoly.push_back(point);
QColor color;
- if (!in_planner()) {
+ if (in_planner) {
if (entry->sac)
color = getSacColor(entry->sac, d->sac);
else
@@ -699,9 +699,9 @@ DiveCalculatedCeiling::DiveCalculatedCeiling(const DivePlotDataModel &model, con
setVisible(prefs.calcceiling);
}
-void DiveCalculatedCeiling::replot(const dive *d)
+void DiveCalculatedCeiling::replot(const dive *d, bool in_planner)
{
- AbstractProfilePolygonItem::replot(d);
+ AbstractProfilePolygonItem::replot(d, in_planner);
// Add 2 points to close the polygon.
QPolygonF poly = polygon();
if (poly.isEmpty())
@@ -747,7 +747,7 @@ DiveReportedCeiling::DiveReportedCeiling(const DivePlotDataModel &model, const D
setVisible(prefs.dcceiling);
}
-void DiveReportedCeiling::replot(const dive *)
+void DiveReportedCeiling::replot(const dive *, bool)
{
QPolygonF p;
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);
}
-void PartialPressureGasItem::replot(const dive *)
+void PartialPressureGasItem::replot(const dive *, bool)
{
plot_data *entry = dataModel.data().entry;
QPolygonF poly;
diff --git a/profile-widget/diveprofileitem.h b/profile-widget/diveprofileitem.h
index f4e0df113..01e9fb3da 100644
--- a/profile-widget/diveprofileitem.h
+++ b/profile-widget/diveprofileitem.h
@@ -39,7 +39,7 @@ public:
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;
void clear();
- virtual void replot(const dive *d);
+ virtual void replot(const dive *d, bool in_planner);
public
slots:
void setVisible(bool visible);
@@ -59,7 +59,7 @@ class DiveProfileItem : public AbstractProfilePolygonItem {
public:
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 replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color);
int maxCeiling(int row);
@@ -73,7 +73,7 @@ class DiveMeanDepthItem : public AbstractProfilePolygonItem {
Q_OBJECT
public:
DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
- void replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
private:
@@ -86,7 +86,7 @@ class DiveTemperatureItem : public AbstractProfilePolygonItem {
Q_OBJECT
public:
DiveTemperatureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
- void replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
private:
@@ -97,7 +97,7 @@ class DiveHeartrateItem : public AbstractProfilePolygonItem {
Q_OBJECT
public:
DiveHeartrateItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
- void replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
private:
@@ -109,7 +109,7 @@ class DivePercentageItem : public AbstractProfilePolygonItem {
Q_OBJECT
public:
DivePercentageItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, int i);
- void replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
private:
@@ -124,7 +124,7 @@ class DiveAmbPressureItem : public AbstractProfilePolygonItem {
Q_OBJECT
public:
DiveAmbPressureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
- void replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
private:
@@ -135,7 +135,7 @@ class DiveGFLineItem : public AbstractProfilePolygonItem {
Q_OBJECT
public:
DiveGFLineItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
- void replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
private:
@@ -147,7 +147,7 @@ class DiveGasPressureItem : public AbstractProfilePolygonItem {
public:
using AbstractProfilePolygonItem::AbstractProfilePolygonItem;
- void replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
private:
@@ -166,7 +166,7 @@ class DiveCalculatedCeiling : public AbstractProfilePolygonItem {
public:
DiveCalculatedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
const DiveCartesianAxis &vAxis, int vColumn, ProfileWidget2 *profileWidget);
- void replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
private:
@@ -178,7 +178,7 @@ class DiveReportedCeiling : public AbstractProfilePolygonItem {
public:
DiveReportedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
- void replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
};
@@ -195,7 +195,7 @@ class PartialPressureGasItem : public AbstractProfilePolygonItem {
public:
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 replot(const dive *d) override;
+ void replot(const dive *d, bool in_planner) override;
void setThresholdSettingsKey(const double *prefPointerMin, const double *prefPointerMax);
void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey);
void setColors(const QColor &normalColor, const QColor &alertColor);
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 62a14ea5d..0808e2932 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -728,7 +728,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
// Replot dive items
for (AbstractProfilePolygonItem *item: profileItems)
- item->replot(&displayed_dive);
+ item->replot(&displayed_dive, currentState == PLAN);
// 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