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>
This commit is contained in:
Tomaz Canabrava 2014-01-21 14:59:19 -02:00 committed by Dirk Hohndel
parent b1df7aeb4e
commit 8065374793
7 changed files with 56 additions and 3 deletions

View file

@ -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);
}