diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-08-05 18:27:00 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-08-05 14:43:18 -0700 |
commit | eb4e64d22a8fec880cc1f1007da5f09a88b312b5 (patch) | |
tree | c19afc76b476f62c31ecb0ed5e4ebbc33ee18cdb /qt-ui | |
parent | f9d38100c4647aa427d2fbd4202e18e8bb1cd4bb (diff) | |
download | subsurface-eb4e64d22a8fec880cc1f1007da5f09a88b312b5.tar.gz |
Add lines that follow the mouse helping see time and depth.
This was missing from the conversion from the oldPlanner
to the new one, and it also works ok on the profile.
One thing is missing is the Labels on the bottom / left
saying which position it is, but it's already userful.
Fixes #674
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 28 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index c3a289dfa..b19ca81e1 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -86,6 +86,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), po2GasItem(new PartialPressureGasItem()), heartBeatAxis(new DiveCartesianAxis()), heartBeatItem(new DiveHeartrateItem()), + mouseFollowerHorizontal(new DiveLineItem()), + mouseFollowerVertical(new DiveLineItem()), rulerItem(new RulerItem2()), isGrayscale(false), printMode(false), @@ -158,6 +160,10 @@ void ProfileWidget2::addItemsToScene() scene()->addItem(rulerItem); scene()->addItem(rulerItem->sourceNode()); scene()->addItem(rulerItem->destNode()); + scene()->addItem(mouseFollowerHorizontal); + scene()->addItem(mouseFollowerVertical); + mouseFollowerHorizontal->setPen(QPen(QColor(Qt::red).lighter())); + mouseFollowerVertical->setPen(QPen(QColor(Qt::red).lighter())); Q_FOREACH (DiveCalculatedTissue *tissue, allTissues) { scene()->addItem(tissue); } @@ -665,6 +671,20 @@ void ProfileWidget2::mouseMoveEvent(QMouseEvent *event) scrollViewTo(event->pos()); toolTipItem->setPos(mapToScene(toolTipPos)); } + + QPointF pos = mapToScene(event->pos()); + qreal vValue = profileYAxis->valueAt(pos); + qreal hValue = timeAxis->valueAt(pos); + if ( profileYAxis->maximum() >= vValue + && profileYAxis->minimum() <= vValue){ + mouseFollowerHorizontal->setPos(timeAxis->pos().x(), pos.y()); + } + if ( timeAxis->maximum() >= hValue + && timeAxis->minimum() <= hValue){ + mouseFollowerVertical->setPos(pos.x(), profileYAxis->line().y1()); + } + + } bool ProfileWidget2::eventFilter(QObject *object, QEvent *event) @@ -706,6 +726,8 @@ void ProfileWidget2::setEmptyState() pn2GasItem->setVisible(false); po2GasItem->setVisible(false); pheGasItem->setVisible(false); + mouseFollowerHorizontal->setVisible(false); + mouseFollowerVertical->setVisible(false); #define HIDE_ALL(TYPE, CONTAINER) \ Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false); @@ -788,6 +810,10 @@ void ProfileWidget2::setProfileState() HIDE_ALL(DiveHandler, handles); HIDE_ALL(QGraphicsSimpleTextItem, gases); #undef HIDE_ALL + mouseFollowerHorizontal->setVisible(true); + mouseFollowerVertical->setVisible(true); + mouseFollowerHorizontal->setLine(timeAxis->line()); + mouseFollowerVertical->setLine(QLineF(0, profileYAxis->pos().y(), 0, timeAxis->pos().y())); } void ProfileWidget2::setAddState() @@ -1055,6 +1081,8 @@ void ProfileWidget2::setPrintMode(bool mode, bool grayscale) { printMode = mode; isGrayscale = mode ? grayscale : false; + mouseFollowerHorizontal->setVisible( !mode ); + mouseFollowerVertical->setVisible( !mode ); } void ProfileWidget2::setFontPrintScale(double scale) diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index bcde4a23a..c3db9845c 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -161,6 +161,8 @@ private: PartialPressureGasItem *po2GasItem; DiveCartesianAxis *heartBeatAxis; DiveHeartrateItem *heartBeatItem; + DiveLineItem *mouseFollowerVertical; + DiveLineItem *mouseFollowerHorizontal; RulerItem2 *rulerItem; bool isGrayscale; bool printMode; |