mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-03 01:50:24 +08:00
GraphViewer: added "Show mouse cursor position (m)" context menu option.
This commit is contained in:
@@ -172,6 +172,7 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void wheelEvent ( QWheelEvent * event );
|
virtual void wheelEvent ( QWheelEvent * event );
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent * event);
|
||||||
virtual void contextMenuEvent(QContextMenuEvent * event);
|
virtual void contextMenuEvent(QContextMenuEvent * event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -228,6 +229,7 @@ private:
|
|||||||
float _loopClosureOutlierThr;
|
float _loopClosureOutlierThr;
|
||||||
float _maxLinkLength;
|
float _maxLinkLength;
|
||||||
bool _orientationENU;
|
bool _orientationENU;
|
||||||
|
bool _mouseTracking;
|
||||||
ViewPlane _viewPlane;
|
ViewPlane _viewPlane;
|
||||||
bool _ensureFrameVisible;
|
bool _ensureFrameVisible;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#endif
|
#endif
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QToolTip>
|
||||||
|
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
@@ -316,6 +317,7 @@ GraphViewer::GraphViewer(QWidget * parent) :
|
|||||||
_loopClosureOutlierThr(0),
|
_loopClosureOutlierThr(0),
|
||||||
_maxLinkLength(0.02f),
|
_maxLinkLength(0.02f),
|
||||||
_orientationENU(false),
|
_orientationENU(false),
|
||||||
|
_mouseTracking(false),
|
||||||
_viewPlane(XY),
|
_viewPlane(XY),
|
||||||
_ensureFrameVisible(true)
|
_ensureFrameVisible(true)
|
||||||
{
|
{
|
||||||
@@ -1789,6 +1791,24 @@ void GraphViewer::wheelEvent ( QWheelEvent * event )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphViewer::mouseMoveEvent(QMouseEvent * event)
|
||||||
|
{
|
||||||
|
QPointF scenePoint = mapToScene(event->pos());
|
||||||
|
if(_mouseTracking && 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));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QToolTip::hideText();
|
||||||
|
}
|
||||||
|
QGraphicsView::mouseMoveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
QIcon createIcon(const QColor & color)
|
QIcon createIcon(const QColor & color)
|
||||||
{
|
{
|
||||||
QPixmap pixmap(50, 50);
|
QPixmap pixmap(50, 50);
|
||||||
@@ -1878,6 +1898,7 @@ void GraphViewer::contextMenuEvent(QContextMenuEvent * event)
|
|||||||
QAction * aShowHideGPSGraph;
|
QAction * aShowHideGPSGraph;
|
||||||
QAction * aShowHideOdomCacheOverlay;
|
QAction * aShowHideOdomCacheOverlay;
|
||||||
QAction * aOrientationENU;
|
QAction * aOrientationENU;
|
||||||
|
QAction * aMouseTracking;
|
||||||
QAction * aViewPlaneXY;
|
QAction * aViewPlaneXY;
|
||||||
QAction * aViewPlaneXZ;
|
QAction * aViewPlaneXZ;
|
||||||
QAction * aViewPlaneYZ;
|
QAction * aViewPlaneYZ;
|
||||||
@@ -1976,6 +1997,9 @@ void GraphViewer::contextMenuEvent(QContextMenuEvent * event)
|
|||||||
aOrientationENU = menu.addAction(tr("ENU Orientation"));
|
aOrientationENU = menu.addAction(tr("ENU Orientation"));
|
||||||
aOrientationENU->setCheckable(true);
|
aOrientationENU->setCheckable(true);
|
||||||
aOrientationENU->setChecked(_orientationENU);
|
aOrientationENU->setChecked(_orientationENU);
|
||||||
|
aMouseTracking = menu.addAction(tr("Show mouse cursor position (m)"));
|
||||||
|
aMouseTracking->setCheckable(true);
|
||||||
|
aMouseTracking->setChecked(_mouseTracking);
|
||||||
aShowHideGraph->setEnabled(_nodeItems.size() && _viewPlane == XY);
|
aShowHideGraph->setEnabled(_nodeItems.size() && _viewPlane == XY);
|
||||||
aShowHideGraphNodes->setEnabled(_nodeItems.size() && _graphRoot->isVisible());
|
aShowHideGraphNodes->setEnabled(_nodeItems.size() && _graphRoot->isVisible());
|
||||||
aShowHideGlobalPath->setEnabled(_globalPathLinkItems.size());
|
aShowHideGlobalPath->setEnabled(_globalPathLinkItems.size());
|
||||||
@@ -2405,6 +2429,10 @@ void GraphViewer::contextMenuEvent(QContextMenuEvent * event)
|
|||||||
{
|
{
|
||||||
this->setOrientationENU(!this->isOrientationENU());
|
this->setOrientationENU(!this->isOrientationENU());
|
||||||
}
|
}
|
||||||
|
else if(r == aMouseTracking)
|
||||||
|
{
|
||||||
|
_mouseTracking = aMouseTracking->isChecked();
|
||||||
|
}
|
||||||
else if(r == aViewPlaneXY)
|
else if(r == aViewPlaneXY)
|
||||||
{
|
{
|
||||||
this->setViewPlane(XY);
|
this->setViewPlane(XY);
|
||||||
|
|||||||
Reference in New Issue
Block a user