|
47 | 47 | #include <Mod/TechDraw/App/DrawUtil.h>
|
48 | 48 | #include <Mod/TechDraw/App/DrawView.h>
|
49 | 49 | #include <Mod/TechDraw/App/DrawViewPart.h>
|
| 50 | +#include <Mod/TechDraw/App/DrawProjGroup.h> |
| 51 | +#include <Mod/TechDraw/App/DrawProjGroupItem.h> |
50 | 52 | #include <Mod/TechDraw/App/Cosmetic.h>
|
51 | 53 |
|
52 | 54 | #include <Mod/TechDraw/Gui/ui_TaskCosVertex.h>
|
@@ -218,28 +220,40 @@ void TaskCosVertex::startTracker(void)
|
218 | 220 | void TaskCosVertex::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParent)
|
219 | 221 | {
|
220 | 222 | // Base::Console().Message("TCV::onTrackerFinished()\n");
|
| 223 | + (void) qgParent; |
221 | 224 | if (pts.empty()) {
|
222 | 225 | Base::Console().Error("TaskCosVertex - no points available\n");
|
223 | 226 | return;
|
224 | 227 | }
|
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 |
| - } |
235 | 228 |
|
236 |
| - //save point unscaled. |
| 229 | + QPointF dragEnd = pts.front(); //scene pos of mouse click |
| 230 | + |
237 | 231 | 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); |
241 | 254 | pointFromTracker = true;
|
242 | 255 | updateUi();
|
| 256 | + |
243 | 257 | m_tracker->sleep(true);
|
244 | 258 | m_inProgressLock = false;
|
245 | 259 | ui->pbTracker->setEnabled(false);
|
|
0 commit comments