summaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2017-03-25 11:15:13 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-03-28 11:17:03 -0700
commit5a235aea12681796a59ce5c001707c4c7ed206df (patch)
tree9f0c991ac6e1565e5a7da186a9b2f8c469aa8341 /profile-widget
parentbb31c77597f28976eb4784318fa7b01a28f3942b (diff)
downloadsubsurface-5a235aea12681796a59ce5c001707c4c7ed206df.tar.gz
minimal pO2 threshold: color the p02 graph also for minumum
Color the p02 graph also in red for going under the minumum p02 value as set in the Preferences. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/diveprofileitem.cpp28
-rw-r--r--profile-widget/diveprofileitem.h5
-rw-r--r--profile-widget/profilewidget2.cpp18
3 files changed, 33 insertions, 18 deletions
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp
index ad3bb151e..d8e6fd4b1 100644
--- a/profile-widget/diveprofileitem.cpp
+++ b/profile-widget/diveprofileitem.cpp
@@ -970,16 +970,28 @@ void PartialPressureGasItem::modelDataChanged(const QModelIndex &topLeft, const
QPolygonF poly;
QPolygonF alertpoly;
alertPolygons.clear();
- double threshold = 0.0;
- if (thresholdPtr)
- threshold = *thresholdPtr;
+ double threshold_min = 100.0; // yes, a ridiculous high partial pressure
+ double threshold_max = 0.0;
+ if (thresholdPtrMax)
+ threshold_max = *thresholdPtrMax;
+ if (thresholdPtrMin)
+ threshold_min = *thresholdPtrMin;
bool inAlertFragment = false;
for (int i = 0; i < dataModel->rowCount(); i++, entry++) {
double value = dataModel->index(i, vDataColumn).data().toDouble();
int time = dataModel->index(i, hDataColumn).data().toInt();
QPointF point(hAxis->posAtValue(time), vAxis->posAtValue(value));
poly.push_back(point);
- if (value >= threshold) {
+ if (thresholdPtrMax && value >= threshold_max) {
+ if (inAlertFragment) {
+ alertPolygons.back().push_back(point);
+ } else {
+ alertpoly.clear();
+ alertpoly.push_back(point);
+ alertPolygons.append(alertpoly);
+ inAlertFragment = true;
+ }
+ } else if (thresholdPtrMin && value <= threshold_min) {
if (inAlertFragment) {
alertPolygons.back().push_back(point);
} else {
@@ -1015,13 +1027,15 @@ void PartialPressureGasItem::paint(QPainter *painter, const QStyleOptionGraphics
painter->restore();
}
-void PartialPressureGasItem::setThreshouldSettingsKey(double *prefPointer)
+void PartialPressureGasItem::setThreshouldSettingsKey(double *prefPointerMin, double *prefPointerMax)
{
- thresholdPtr = prefPointer;
+ thresholdPtrMin = prefPointerMin;
+ thresholdPtrMax = prefPointerMax;
}
PartialPressureGasItem::PartialPressureGasItem() :
- thresholdPtr(NULL)
+ thresholdPtrMin(NULL),
+ thresholdPtrMax(NULL)
{
}
diff --git a/profile-widget/diveprofileitem.h b/profile-widget/diveprofileitem.h
index a42de0442..a8e724c3f 100644
--- a/profile-widget/diveprofileitem.h
+++ b/profile-widget/diveprofileitem.h
@@ -215,13 +215,14 @@ public:
PartialPressureGasItem();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
- void setThreshouldSettingsKey(double *prefPointer);
+ void setThreshouldSettingsKey(double *prefPointerMin, double *prefPointerMax);
void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey);
void setColors(const QColor &normalColor, const QColor &alertColor);
private:
QVector<QPolygonF> alertPolygons;
- double *thresholdPtr;
+ double *thresholdPtrMin;
+ double *thresholdPtrMax;
QString visibilityKey;
QColor normalColor;
QColor alertColor;
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index bae8bb6d9..c3a447b82 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -342,20 +342,20 @@ void ProfileWidget2::setupItemOnScene()
setupItem(diveProfileItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0);
setupItem(meanDepthItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::INSTANT_MEANDEPTH, DivePlotDataModel::TIME, 1);
-#define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS) \
+#define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS_MIN, THRESHOULD_SETTINGS_MAX) \
setupItem(ITEM, timeAxis, gasYAxis, dataModel, DivePlotDataModel::VERTICAL_COLUMN, DivePlotDataModel::TIME, 0); \
- ITEM->setThreshouldSettingsKey(THRESHOULD_SETTINGS); \
+ ITEM->setThreshouldSettingsKey(THRESHOULD_SETTINGS_MIN, THRESHOULD_SETTINGS_MAX); \
ITEM->setColors(getColor(COLOR, isGrayscale), getColor(COLOR_ALERT, isGrayscale)); \
ITEM->settingsChanged(); \
ITEM->setZValue(99);
- CREATE_PP_GAS(pn2GasItem, PN2, PN2, PN2_ALERT, &prefs.pp_graphs.pn2_threshold);
- CREATE_PP_GAS(pheGasItem, PHE, PHE, PHE_ALERT, &prefs.pp_graphs.phe_threshold);
- CREATE_PP_GAS(po2GasItem, PO2, PO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_max);
- CREATE_PP_GAS(o2SetpointGasItem, O2SETPOINT, PO2_ALERT, PO2_ALERT, &prefs.pp_graphs.po2_threshold_max);
- CREATE_PP_GAS(ccrsensor1GasItem, CCRSENSOR1, CCRSENSOR1, PO2_ALERT, &prefs.pp_graphs.po2_threshold_max);
- CREATE_PP_GAS(ccrsensor2GasItem, CCRSENSOR2, CCRSENSOR2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_max);
- CREATE_PP_GAS(ccrsensor3GasItem, CCRSENSOR3, CCRSENSOR3, PO2_ALERT, &prefs.pp_graphs.po2_threshold_max);
+ CREATE_PP_GAS(pn2GasItem, PN2, PN2, PN2_ALERT, NULL, &prefs.pp_graphs.pn2_threshold);
+ CREATE_PP_GAS(pheGasItem, PHE, PHE, PHE_ALERT, NULL, &prefs.pp_graphs.phe_threshold);
+ CREATE_PP_GAS(po2GasItem, PO2, PO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max);
+ CREATE_PP_GAS(o2SetpointGasItem, O2SETPOINT, PO2_ALERT, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max);
+ CREATE_PP_GAS(ccrsensor1GasItem, CCRSENSOR1, CCRSENSOR1, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max);
+ CREATE_PP_GAS(ccrsensor2GasItem, CCRSENSOR2, CCRSENSOR2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max);
+ CREATE_PP_GAS(ccrsensor3GasItem, CCRSENSOR3, CCRSENSOR3, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max);
#undef CREATE_PP_GAS
#ifndef SUBSURFACE_MOBILE