[TD]Handle ProjGroup in TaskCosmeticVertex

This commit is contained in:
wandererfan
2020-04-27 16:14:06 -04:00
committed by WandererFan
parent a584afcd91
commit 60adfc863f
2 changed files with 31 additions and 16 deletions

View File

@@ -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();
}
}

View File

@@ -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>
@@ -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);