diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-12-30 21:57:12 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-30 16:14:53 -0800 |
commit | b3e3947b79e91d76db1d9d14f6c3701dad53a224 (patch) | |
tree | 6c36d983b784dea15b2d1d27844911d92c101fec /qt-ui/profile/diveprofileitem.cpp | |
parent | d6fddcaadc6e912a94561483ae8a1297e12a5c3e (diff) | |
download | subsurface-b3e3947b79e91d76db1d9d14f6c3701dad53a224.tar.gz |
Make the moving mean depth line work
It's a bit jumpy, but works.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/diveprofileitem.cpp')
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 1d930ad6a..03a2451a2 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -812,7 +812,7 @@ void DiveReportedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsIte QGraphicsPolygonItem::paint(painter, option, widget); } -MeanDepthLine::MeanDepthLine() : meanDepth(0), leftText(new DiveTextItem(this)), rightText(new DiveTextItem(this)) +MeanDepthLine::MeanDepthLine() : meanDepth(0), leftText(new DiveTextItem(this)), rightText(new DiveTextItem(this)), model(NULL) { leftText->setAlignment(Qt::AlignRight | Qt::AlignBottom); leftText->setBrush(getColor(MEAN_DEPTH)); @@ -930,12 +930,23 @@ void PartialPressureGasItem::setColors(const QColor &normal, const QColor &alert alertColor = alert; } -InstantMeanDepthLine::InstantMeanDepthLine() +InstantMeanDepthLine::InstantMeanDepthLine(): vAxis(NULL), hAxis(NULL) { } void InstantMeanDepthLine::mouseMoved(int time, int depth) { + if (model == NULL || scene() == NULL || vAxis == NULL || hAxis == NULL) + return; + int count = model->data().nr; + for(int i = 0; i < count; i++){ + struct plot_data pI = model->data().entry[i]; + if (pI.sec == time) { + setMeanDepth(pI.running_sum / time); + setLine(0, 0, hAxis->posAtValue(time), 0); + setPos(pos().x(), vAxis->posAtValue(pI.running_sum / time)); + } + } } |