summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile/diveprofileitem.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-21 14:59:19 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-21 11:35:09 -0800
commit8065374793908894b47cfd1c2bb0b9913d404bb4 (patch)
treedf2fe4bfec7a05ce3e255cdcf06a38b6f7aded4c /qt-ui/profile/diveprofileitem.cpp
parentb1df7aeb4e06cfc512d19b2f7e7f5b455dea0c22 (diff)
downloadsubsurface-8065374793908894b47cfd1c2bb0b9913d404bb4.tar.gz
Add the DiveCalculatedCeiling item.
This item plots the DiveCalculatedCeiling over the profile. I still need to add the Calc All Tissues version. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/diveprofileitem.cpp')
-rw-r--r--qt-ui/profile/diveprofileitem.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 7c339eba9..cec7667c2 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -318,3 +318,30 @@ void DiveGasPressureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte
}
}
}
+
+void DiveCalculatedCeiling::modelDataChanged()
+{
+ // We don't have enougth data to calculate things, quit.
+ if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1)
+ return;
+ AbstractProfilePolygonItem::modelDataChanged();
+ // Add 2 points to close the polygon.
+ QPolygonF poly = polygon();
+ QPointF p1 = poly.first();
+ QPointF p2 = poly.last();
+
+ poly.prepend(QPointF(p1.x(), vAxis->posAtValue(0)));
+ poly.append(QPointF(p2.x(), vAxis->posAtValue(0)));
+ setPolygon(poly);
+
+ QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
+ pat.setColorAt(0, getColor(CALC_CEILING_SHALLOW));
+ pat.setColorAt(1, getColor(CALC_CEILING_DEEP));
+ setPen(QPen(QBrush(Qt::NoBrush),0));
+ setBrush(pat);
+}
+
+void DiveCalculatedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+{
+ QGraphicsPolygonItem::paint(painter, option, widget);
+}