Skip to content

Commit

Permalink
[TD]Handle ProjGroup in TaskCosmeticVertex
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Apr 28, 2020
1 parent f2f7d22 commit 1fc2e75
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/Mod/TechDraw/Gui/QGTracker.cpp
Expand Up @@ -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();
}
}
Expand Down
42 changes: 28 additions & 14 deletions src/Mod/TechDraw/Gui/TaskCosVertex.cpp
Expand Up @@ -47,6 +47,8 @@
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawProjGroup.h>
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
#include <Mod/TechDraw/App/Cosmetic.h>

#include <Mod/TechDraw/Gui/ui_TaskCosVertex.h>
Expand Down Expand Up @@ -218,28 +220,40 @@ void TaskCosVertex::startTracker(void)
void TaskCosVertex::onTrackerFinished(std::vector<QPointF> 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<DrawProjGroupItem*>(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);
Expand Down

0 comments on commit 1fc2e75

Please sign in to comment.