From 58d9282955b5e3c1e60125784e95f8d300554f5e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 21 Jan 2014 17:07:22 -0200 Subject: Show dive computer ceiling This patch adds dive computer calculated ceiling on the profile graph as a 'hole' on it. There's an item that paints it in red - maybe we shouldn't offer an option here and show that only in red? Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/diveprofileitem.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index cec7667c2..d190efcc1 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -6,6 +6,7 @@ #include "profile.h" #include "dive.h" #include "profilegraphics.h" +#include "preferences.h" #include #include @@ -17,7 +18,7 @@ AbstractProfilePolygonItem::AbstractProfilePolygonItem(): QObject(), QGraphicsPolygonItem(), hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1) { - + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(modelDataChanged())); } void AbstractProfilePolygonItem::setHorizontalAxis(DiveCartesianAxis* horizontal) @@ -79,7 +80,7 @@ void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* o // This paints the Polygon + Background. I'm setting the pen to QPen() so we don't get a black line here, // after all we need to plot the correct velocities colors later. - setPen(QPen()); + setPen(Qt::NoPen); QGraphicsPolygonItem::paint(painter, option, widget); // Here we actually paint the boundaries of the Polygon using the colors that the model provides. @@ -100,6 +101,24 @@ void DiveProfileItem::modelDataChanged(){ AbstractProfilePolygonItem::modelDataChanged(); if(polygon().isEmpty()) return; + + /* Show any ceiling we may have encountered */ + if (prefs.profile_dc_ceiling) { + QPolygonF p = polygon(); + plot_data *entry = dataModel->data() + dataModel->rowCount()-1; + for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) { + if (!entry->in_deco) { + /* not in deco implies this is a safety stop, no ceiling */ + p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(0))); + } else if (entry->stopdepth < entry->depth) { + p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->stopdepth))); + } else { + p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->depth))); + } + } + setPolygon(p); + } + // 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()); -- cgit v1.2.3-70-g09d2