mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
profile: fix crosshairs
In planner and edit mode, the cursor position is indicated using crosshairs. They broke when changing to absolute scaling. To fix them, remember the plot-area in the profile scene and draw the crosshairs only inside this area (not on top of axes). However, limit the position of the horizontal line to the actual profile (dont paint inside the partial pressure, etc graphs). The vertical line is painted above those graphs, so that a timestamp can be related to partial pressure, tissue loading, etc. Also, set the z-value of the crosshairs. It was painted inconsistently above some and below other chart features. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
26c6344e70
commit
352cdcc863
3 changed files with 13 additions and 13 deletions
|
@ -316,7 +316,8 @@ void ProfileScene::updateAxes(bool diveHasHeartBeat, bool simplified)
|
|||
}
|
||||
|
||||
bottomBorder -= timeAxis->height();
|
||||
timeAxis->setPosition(QRectF(leftBorder, topBorder, width, bottomBorder - topBorder));
|
||||
profileRegion = QRectF(leftBorder, topBorder, width, bottomBorder - topBorder);
|
||||
timeAxis->setPosition(profileRegion);
|
||||
|
||||
if (prefs.tankbar) {
|
||||
bottomBorder -= tankItem->height();
|
||||
|
|
|
@ -68,6 +68,7 @@ private:
|
|||
int maxdepth;
|
||||
|
||||
struct plot_info plotInfo;
|
||||
QRectF profileRegion; // Region inside the axes, where the crosshair is painted in plan and edit mode.
|
||||
DiveCartesianAxis *profileYAxis;
|
||||
DiveCartesianAxis *gasYAxis;
|
||||
DiveCartesianAxis *temperatureAxis;
|
||||
|
|
|
@ -157,6 +157,8 @@ void ProfileWidget2::setupItemOnScene()
|
|||
toolTipItem->setTimeAxis(profileScene->timeAxis);
|
||||
rulerItem->setZValue(9997);
|
||||
rulerItem->setAxis(profileScene->timeAxis, profileScene->profileYAxis);
|
||||
mouseFollowerHorizontal->setZValue(9996);
|
||||
mouseFollowerVertical->setZValue(9995);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -352,14 +354,14 @@ void ProfileWidget2::mouseMoveEvent(QMouseEvent *event)
|
|||
plotDive(d, dc, RenderFlags::Instant | RenderFlags::DontRecalculatePlotInfo); // TODO: animations don't work when scrolling
|
||||
}
|
||||
|
||||
double vValue = profileScene->profileYAxis->valueAt(pos);
|
||||
double hValue = profileScene->timeAxis->valueAt(pos);
|
||||
|
||||
if (profileScene->profileYAxis->maximum() >= vValue && profileScene->profileYAxis->minimum() <= vValue)
|
||||
mouseFollowerHorizontal->setPos(profileScene->timeAxis->pos().x(), pos.y());
|
||||
|
||||
if (profileScene->timeAxis->maximum() >= hValue && profileScene->timeAxis->minimum() <= hValue)
|
||||
mouseFollowerVertical->setPos(pos.x(), profileScene->profileYAxis->line().y1());
|
||||
if (currentState == PLAN || currentState == EDIT) {
|
||||
QRectF rect = profileScene->profileRegion;
|
||||
auto [miny, maxy] = profileScene->profileYAxis->screenMinMax();
|
||||
double x = std::clamp(pos.x(), rect.left(), rect.right());
|
||||
double y = std::clamp(pos.y(), miny, maxy);
|
||||
mouseFollowerHorizontal->setLine(rect.left(), y, rect.right(), y);
|
||||
mouseFollowerVertical->setLine(x, rect.top(), x, rect.bottom());
|
||||
}
|
||||
}
|
||||
|
||||
bool ProfileWidget2::eventFilter(QObject *object, QEvent *event)
|
||||
|
@ -441,8 +443,6 @@ void ProfileWidget2::setEditState(const dive *d, int dc)
|
|||
setProfileState(d, dc);
|
||||
mouseFollowerHorizontal->setVisible(true);
|
||||
mouseFollowerVertical->setVisible(true);
|
||||
mouseFollowerHorizontal->setLine(profileScene->timeAxis->line());
|
||||
mouseFollowerVertical->setLine(QLineF(0, profileScene->profileYAxis->pos().y(), 0, profileScene->timeAxis->pos().y()));
|
||||
disconnectTemporaryConnections();
|
||||
actionsForKeys[Qt::Key_Left]->setShortcut(Qt::Key_Left);
|
||||
actionsForKeys[Qt::Key_Right]->setShortcut(Qt::Key_Right);
|
||||
|
@ -469,8 +469,6 @@ void ProfileWidget2::setPlanState(const dive *d, int dc)
|
|||
setProfileState(d, dc);
|
||||
mouseFollowerHorizontal->setVisible(true);
|
||||
mouseFollowerVertical->setVisible(true);
|
||||
mouseFollowerHorizontal->setLine(profileScene->timeAxis->line());
|
||||
mouseFollowerVertical->setLine(QLineF(0, profileScene->profileYAxis->pos().y(), 0, profileScene->timeAxis->pos().y()));
|
||||
disconnectTemporaryConnections();
|
||||
actionsForKeys[Qt::Key_Left]->setShortcut(Qt::Key_Left);
|
||||
actionsForKeys[Qt::Key_Right]->setShortcut(Qt::Key_Right);
|
||||
|
|
Loading…
Reference in a new issue