Skip to content

Commit 1fc2e75

Browse files
committed
[TD]Handle ProjGroup in TaskCosmeticVertex
1 parent f2f7d22 commit 1fc2e75

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

src/Mod/TechDraw/Gui/QGTracker.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,12 @@ void QGTracker::onMousePress(QPointF pos)
257257
break;
258258
}
259259
} else if (m_points.size() == 1) { //first point selected
260+
//just return pos to caller
260261
getPickedQGIV(pos);
261-
setCursor(Qt::CrossCursor);
262+
setCursor(Qt::CrossCursor); //why cross??
262263
// Q_EMIT qViewPicked(pos, m_qgParent); //not in use yet.
263264
if (mode == TrackerMode::Point) {
264-
setPoint(m_points);
265+
setPoint(m_points); //first point is mouse click scene pos
265266
terminateDrawing();
266267
}
267268
}

src/Mod/TechDraw/Gui/TaskCosVertex.cpp

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#include <Mod/TechDraw/App/DrawUtil.h>
4848
#include <Mod/TechDraw/App/DrawView.h>
4949
#include <Mod/TechDraw/App/DrawViewPart.h>
50+
#include <Mod/TechDraw/App/DrawProjGroup.h>
51+
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
5052
#include <Mod/TechDraw/App/Cosmetic.h>
5153

5254
#include <Mod/TechDraw/Gui/ui_TaskCosVertex.h>
@@ -218,28 +220,40 @@ void TaskCosVertex::startTracker(void)
218220
void TaskCosVertex::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParent)
219221
{
220222
// Base::Console().Message("TCV::onTrackerFinished()\n");
223+
(void) qgParent;
221224
if (pts.empty()) {
222225
Base::Console().Error("TaskCosVertex - no points available\n");
223226
return;
224227
}
225-
if (qgParent != nullptr) {
226-
m_qgParent = qgParent;
227-
} else {
228-
//if vertex is outside of baseFeat, qgParent will be nullptr
229-
QGVPage* qgvp = m_mdi->getQGVPage();
230-
QGIView* qgiv = qgvp->findQViewForDocObj(m_baseFeat);
231-
m_qgParent = qgiv;
232-
Base::Console().Message("TaskCosVertex - qgParent is nullptr\n");
233-
// return;
234-
}
235228

236-
//save point unscaled.
229+
QPointF dragEnd = pts.front(); //scene pos of mouse click
230+
237231
double scale = m_baseFeat->getScale();
238-
QPointF temp = pts.front();
239-
QPointF temp2 = m_qgParent->mapFromScene(temp) / scale;
240-
m_savePoint = Rez::appX(temp2);
232+
double x = Rez::guiX(m_baseFeat->X.getValue());
233+
double y = Rez::guiX(m_baseFeat->Y.getValue());
234+
235+
DrawViewPart* dvp = m_baseFeat;
236+
DrawProjGroupItem* dpgi = dynamic_cast<DrawProjGroupItem*>(dvp);
237+
if (dpgi != nullptr) {
238+
DrawProjGroup* dpg = dpgi->getPGroup();
239+
if (dpg == nullptr) {
240+
Base::Console().Message("TCV:onTrackerFinished - projection group is confused\n");
241+
//TODO::throw something.
242+
return;
243+
}
244+
x += Rez::guiX(dpg->X.getValue());
245+
y += Rez::guiX(dpg->Y.getValue());
246+
}
247+
//x,y are scene pos of dvp/dpgi
248+
249+
QPointF basePosScene(x, -y); //base position in scene coords
250+
QPointF displace = dragEnd - basePosScene;
251+
QPointF scenePosCV = displace / scale;
252+
253+
m_savePoint = Rez::appX(scenePosCV);
241254
pointFromTracker = true;
242255
updateUi();
256+
243257
m_tracker->sleep(true);
244258
m_inProgressLock = false;
245259
ui->pbTracker->setEnabled(false);

0 commit comments

Comments
 (0)