From 42812634bfcf30688b152307c64b2e4a0425d8b0 Mon Sep 17 00:00:00 2001 From: lh <2334563547@qq.com> Date: Wed, 25 Nov 2026 10:06:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(nmPlot):=20=E6=94=AF=E6=8C=81=E6=8C=89=20E?= =?UTF-8?q?sc=20=E5=8F=96=E6=B6=88=E5=9C=B0=E5=9B=BE=E6=AF=94=E4=BE=8B?= =?UTF-8?q?=E5=B0=BA=E7=BB=98=E5=88=B6=20=E6=8E=A5=E5=85=A5=E7=BB=98?= =?UTF-8?q?=E5=9B=BE=E5=B7=A5=E5=85=B7=E7=9A=84=E5=8F=96=E6=B6=88=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=EF=BC=8C=E6=B8=85=E7=90=86=E6=A0=87=E5=AE=9A=E9=A2=84?= =?UTF-8?q?=E8=A7=88=EF=BC=8C=E5=B9=B6=E9=98=B2=E6=AD=A2=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E9=BC=A0=E6=A0=87=E6=9D=BE=E5=BC=80=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=A0=87=E5=AE=9A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp | 6 ++++++ Src/nmNum/nmPlot/nmObjLineMeasuringScaleTool.cpp | 2 ++ Src/nmNum/nmPlot/nmObjLineTool.cpp | 11 +++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp b/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp index b2027e01..90265189 100644 --- a/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp +++ b/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp @@ -284,7 +284,13 @@ bool nmGuiPlotCmdHelper::runAction(QString sAction) { pPlot->appendTools(pObjTool); connect(pObjTool, SIGNAL(sigPtsFinished(QVector&)), this, SLOT(slotObjPtsFinished(QVector&))); + connect(pObjTool, SIGNAL(sigCreationCancelled()), + this, SLOT(slotObjCreationCancelled())); m_activeTools.insert(NMOT_Line_MeasuringScale, pObjTool); + pObjTool->beginCreationCursor(); + if (pNmPlot->m_pPlotView != nullptr) { + pNmPlot->m_pPlotView->setFocus(Qt::OtherFocusReason); + } return true; } else if (isMeasureAction) { nmObjLineMeasureTool* pMeasureTool = new nmObjLineMeasureTool(); diff --git a/Src/nmNum/nmPlot/nmObjLineMeasuringScaleTool.cpp b/Src/nmNum/nmPlot/nmObjLineMeasuringScaleTool.cpp index be5534ca..831a0578 100644 --- a/Src/nmNum/nmPlot/nmObjLineMeasuringScaleTool.cpp +++ b/Src/nmNum/nmPlot/nmObjLineMeasuringScaleTool.cpp @@ -8,6 +8,8 @@ nmObjLineMeasuringScaleTool::nmObjLineMeasuringScaleTool() { setText(tr("nObjLineMeasuringScaleTool")); m_oNot = NMOT_Line_MeasuringScale; + enableInteractionCursor(); + enableEscapeCancellation(); nmDataLogFile::getInstance()->writeLog(" nmObjLineMeasuringScaleTool ++++++++ " + QString::number(m_oNot)); } diff --git a/Src/nmNum/nmPlot/nmObjLineTool.cpp b/Src/nmNum/nmPlot/nmObjLineTool.cpp index e17a951b..d919bc4d 100644 --- a/Src/nmNum/nmPlot/nmObjLineTool.cpp +++ b/Src/nmNum/nmPlot/nmObjLineTool.cpp @@ -11,6 +11,7 @@ nmObjLineTool::nmObjLineTool() : nmObjPointTool() bool nmObjLineTool::onLeftDown(const QPointF& pt) { + if (m_bCreationCancelled) return true; if (NULL == m_pObj) { m_ptStart = pt; @@ -23,6 +24,7 @@ bool nmObjLineTool::onLeftDown(const QPointF& pt) bool nmObjLineTool::onMouseMove(const QPointF& pt) { + if (m_bCreationCancelled) return true; if (NULL == m_pObj) { m_ptMove = pt; @@ -44,13 +46,13 @@ bool nmObjLineTool::onMouseMove(const QPointF& pt) bool nmObjLineTool::onLeftUp(const QPointF& pt) { + // 工具移除后,框架仍可能转发取消前那次按压的松手事件。 + if (m_bCreationCancelled) return true; if (NULL == m_pObj) { + if (!m_bTracking || getView() == nullptr) return true; getView()->setSnapshotMode(false); - if (m_bTracking) - { - m_bTracking = false; - } + m_bTracking = false; QVector vec; vec << m_ptStart << pt; @@ -73,6 +75,7 @@ bool nmObjLineTool::onLeftDoubleClick(const QPointF& pt) void nmObjLineTool::onPaint(QPainter* painter, const ZxPaintParam& param) { + if (m_bCreationCancelled) return; nmObjLine* pObj = dynamic_cast(m_pObj); if (pObj == NULL) {