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) {