aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-21 17:07:22 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-21 14:23:33 -0800
commit58d9282955b5e3c1e60125784e95f8d300554f5e (patch)
tree5bd3650265ef36ffcf0586aaf83fa7fac1be1614 /qt-ui/profile
parent162d674c5b769293d7f898ba28592afad705f1a3 (diff)
downloadsubsurface-58d9282955b5e3c1e60125784e95f8d300554f5e.tar.gz
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 <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/diveprofileitem.cpp23
1 files changed, 21 insertions, 2 deletions
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 <QPen>
#include <QPainter>
@@ -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());