diff --git a/src/Mod/TechDraw/Gui/QGTracker.cpp b/src/Mod/TechDraw/Gui/QGTracker.cpp index 244cc62ed0..0fddf9f0e3 100644 --- a/src/Mod/TechDraw/Gui/QGTracker.cpp +++ b/src/Mod/TechDraw/Gui/QGTracker.cpp @@ -257,11 +257,12 @@ void QGTracker::onMousePress(QPointF pos) break; } } else if (m_points.size() == 1) { //first point selected + //just return pos to caller getPickedQGIV(pos); - setCursor(Qt::CrossCursor); + setCursor(Qt::CrossCursor); //why cross?? // Q_EMIT qViewPicked(pos, m_qgParent); //not in use yet. if (mode == TrackerMode::Point) { - setPoint(m_points); + setPoint(m_points); //first point is mouse click scene pos terminateDrawing(); } } diff --git a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp index 09a7f548ff..e43b095ac5 100644 --- a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp +++ b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp @@ -47,6 +47,8 @@ #include #include #include +#include +#include #include #include @@ -218,28 +220,40 @@ void TaskCosVertex::startTracker(void) void TaskCosVertex::onTrackerFinished(std::vector pts, QGIView* qgParent) { // Base::Console().Message("TCV::onTrackerFinished()\n"); + (void) qgParent; if (pts.empty()) { Base::Console().Error("TaskCosVertex - no points available\n"); return; } - if (qgParent != nullptr) { - m_qgParent = qgParent; - } else { - //if vertex is outside of baseFeat, qgParent will be nullptr - QGVPage* qgvp = m_mdi->getQGVPage(); - QGIView* qgiv = qgvp->findQViewForDocObj(m_baseFeat); - m_qgParent = qgiv; - Base::Console().Message("TaskCosVertex - qgParent is nullptr\n"); -// return; - } - //save point unscaled. + QPointF dragEnd = pts.front(); //scene pos of mouse click + double scale = m_baseFeat->getScale(); - QPointF temp = pts.front(); - QPointF temp2 = m_qgParent->mapFromScene(temp) / scale; - m_savePoint = Rez::appX(temp2); + double x = Rez::guiX(m_baseFeat->X.getValue()); + double y = Rez::guiX(m_baseFeat->Y.getValue()); + + DrawViewPart* dvp = m_baseFeat; + DrawProjGroupItem* dpgi = dynamic_cast(dvp); + if (dpgi != nullptr) { + DrawProjGroup* dpg = dpgi->getPGroup(); + if (dpg == nullptr) { + Base::Console().Message("TCV:onTrackerFinished - projection group is confused\n"); + //TODO::throw something. + return; + } + x += Rez::guiX(dpg->X.getValue()); + y += Rez::guiX(dpg->Y.getValue()); + } + //x,y are scene pos of dvp/dpgi + + QPointF basePosScene(x, -y); //base position in scene coords + QPointF displace = dragEnd - basePosScene; + QPointF scenePosCV = displace / scale; + + m_savePoint = Rez::appX(scenePosCV); pointFromTracker = true; updateUi(); + m_tracker->sleep(true); m_inProgressLock = false; ui->pbTracker->setEnabled(false);