diff --git a/Include/nmNum/nmPlot/nmPlotView.h b/Include/nmNum/nmPlot/nmPlotView.h index 80c4633c..077c22d4 100644 --- a/Include/nmNum/nmPlot/nmPlotView.h +++ b/Include/nmNum/nmPlot/nmPlotView.h @@ -26,6 +26,9 @@ public slots: signals: + // 鼠标在绘图区内的位置,使用模型坐标。 + void sigPointerPos(double x, double y); + protected: // 拖拽支持 diff --git a/Src/nmNum/nmPlot/nmPlotView.cpp b/Src/nmNum/nmPlot/nmPlotView.cpp index 3f10a045..e0f91f55 100644 --- a/Src/nmNum/nmPlot/nmPlotView.cpp +++ b/Src/nmNum/nmPlot/nmPlotView.cpp @@ -15,6 +15,8 @@ ZX_DEFINE_DYNAMIC(mPlotView, nmPlotView) nmPlotView::nmPlotView() { + // 未按下鼠标时也接收视口移动事件,实时更新模型位置。 + viewport()->setMouseTracking(true); } void nmPlotView::onPrepareContextMenu(QMenu* pMenu, @@ -140,6 +142,8 @@ void nmPlotView::mouseMoveEvent(QMouseEvent* e) // 状态栏 if (rt.contains(pos)) { + // 复用坐标轴换算结果,通知模型位置窗口刷新坐标。 + emit sigPointerPos(dX, dY); s = tr(" Current Pos:%1-%2").arg(sValueX).arg(sValueY); if (!sValueY2.isEmpty()) s += QString("-%1").arg(sValueY2);