summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-05-26 19:29:25 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-26 15:42:43 -0700
commit4e3793c05310009878a407d107b4ef330710c5f3 (patch)
treeb7a66a6aff48507b4a4571ce0c3e2e948d1011ba /qt-ui/profile
parentd9abf885c2ef7861ca85a52eec3c01e0c04861d5 (diff)
downloadsubsurface-4e3793c05310009878a407d107b4ef330710c5f3.tar.gz
Paint the dive red if the user is breaking ceiling on the planner.
This patch paints the dive red if the user is breaking ceiling on the planner - it's quite fast, it analizes the depth over the max(tissue_1 .. tissue_16) and changes the color of the profile. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/diveprofileitem.cpp26
-rw-r--r--qt-ui/profile/diveprofileitem.h3
2 files changed, 27 insertions, 2 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 2a6d5ac2f..976527f32 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -3,6 +3,7 @@
#include "divecartesianaxis.h"
#include "graphicsview-common.h"
#include "divetextitem.h"
+#include "profilewidget2.h"
#include "profile.h"
#include "dive.h"
#include "preferences.h"
@@ -136,6 +137,17 @@ void DiveProfileItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
}
}
+int DiveProfileItem::maxCeiling(int row)
+{
+ int max = -1;
+ plot_data *entry = dataModel->data().entry + row;
+ for (int tissue = 0; tissue < 16; tissue++) {
+ if (max < entry->ceilings[tissue])
+ max = entry->ceilings[tissue];
+ }
+ return max;
+}
+
void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
if (!shouldCalculateStuff(topLeft, bottomRight))
@@ -147,6 +159,18 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI
show_reported_ceiling = prefs.dcceiling;
reported_ceiling_in_red = prefs.redceiling;
+ profileColor = getColor(DEPTH_BOTTOM);
+
+ int currState = qobject_cast<ProfileWidget2 *>(scene()->views().first())->currentState;
+ if (currState == ProfileWidget2::PLAN) {
+ plot_data *entry = dataModel->data().entry + dataModel->rowCount() - 1;
+ for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) {
+ int max = maxCeiling(i);
+ if (entry->depth < max) {
+ profileColor = QColor(Qt::red);
+ }
+ }
+ }
/* Show any ceiling we may have encountered */
if (prefs.dcceiling && !prefs.redceiling) {
@@ -166,7 +190,7 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI
// This is the blueish gradient that the Depth Profile should have.
// It's a simple QLinearGradient with 2 stops, starting from top to bottom.
QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
- pat.setColorAt(1, getColor(DEPTH_BOTTOM));
+ pat.setColorAt(1, profileColor);
pat.setColorAt(0, getColor(DEPTH_TOP));
setBrush(QBrush(pat));
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index de0c6f0c9..916404c2e 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -77,10 +77,11 @@ public:
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
virtual void settingsChanged();
void plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color);
-
+ int maxCeiling(int row);
private:
unsigned int show_reported_ceiling;
unsigned int reported_ceiling_in_red;
+ QColor profileColor;
};
class DiveTemperatureItem : public AbstractProfilePolygonItem {