Skip to content

Commit

Permalink
GraphView: fixed mouse cursor tracking inverted x-y values
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Mar 1, 2024
1 parent c24f95a commit 33b875e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions guilib/src/GraphViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1794,12 +1794,12 @@ void GraphViewer::wheelEvent ( QWheelEvent * event )
void GraphViewer::mouseMoveEvent(QMouseEvent * event)
{
QPointF scenePoint = mapToScene(event->pos());
if(_mouseTracking && this->sceneRect().contains(scenePoint))
if(_mouseTracking && _viewPlane==XY && this->sceneRect().contains(scenePoint))
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QToolTip::showText(event->globalPosition().toPoint(), QString("%1,%2").arg(scenePoint.x()/100.0).arg(scenePoint.y()/100.0));
#else
QToolTip::showText(event->globalPos(), QString("%1m %2m").arg(scenePoint.x()/100.0).arg(scenePoint.y()/100.0));
QToolTip::showText(event->globalPos(), QString("%1m %2m").arg(-scenePoint.y()/100.0).arg(-scenePoint.x()/100.0));
#endif
}
else
Expand Down Expand Up @@ -2000,6 +2000,7 @@ void GraphViewer::contextMenuEvent(QContextMenuEvent * event)
aMouseTracking = menu.addAction(tr("Show mouse cursor position (m)"));
aMouseTracking->setCheckable(true);
aMouseTracking->setChecked(_mouseTracking);
aMouseTracking->setEnabled(_viewPlane == XY);
aShowHideGraph->setEnabled(_nodeItems.size() && _viewPlane == XY);
aShowHideGraphNodes->setEnabled(_nodeItems.size() && _graphRoot->isVisible());
aShowHideGlobalPath->setEnabled(_globalPathLinkItems.size());
Expand Down

0 comments on commit 33b875e

Please sign in to comment.