[TD]fix location of CV on rotated views
This commit is contained in:
@@ -137,7 +137,8 @@ void TaskCosVertex::addCosVertex(QPointF qPos)
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Add Cosmetic Vertex"));
|
||||
|
||||
// Base::Console().Message("TCV::addCosVertex(%s)\n", TechDraw::DrawUtil::formatVector(qPos).c_str());
|
||||
Base::Vector3d pos(qPos.x(), -qPos.y());
|
||||
Base::Vector3d pos = DU::invertY(DU::toVector3d(qPos));
|
||||
pos = CosmeticVertex::makeCanonicalPoint(m_baseFeat, pos);
|
||||
// int idx =
|
||||
(void) m_baseFeat->addCosmeticVertex(pos);
|
||||
m_baseFeat->requestPaint();
|
||||
@@ -215,7 +216,6 @@ void TaskCosVertex::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParen
|
||||
|
||||
QPointF dragEnd = pts.front(); //scene pos of mouse click
|
||||
|
||||
double scale = m_baseFeat->getScale();
|
||||
double x = Rez::guiX(m_baseFeat->X.getValue());
|
||||
double y = Rez::guiX(m_baseFeat->Y.getValue());
|
||||
|
||||
@@ -235,19 +235,13 @@ void TaskCosVertex::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParen
|
||||
|
||||
QPointF basePosScene(x, -y); //base position in scene coords
|
||||
QPointF displace = dragEnd - basePosScene;
|
||||
QPointF scenePosCV = displace / scale;
|
||||
QPointF scenePosCV = displace;
|
||||
|
||||
// if the base view is rotated, we need to unrotate it before saving
|
||||
double rotDeg = m_baseFeat->Rotation.getValue();
|
||||
if (rotDeg != 0.0) {
|
||||
// Invert Y value so the math works.
|
||||
Base::Vector3d posToRotate = DU::invertY(DU::toVector3d(scenePosCV));
|
||||
double rotRad = rotDeg * M_PI / 180.0;
|
||||
// we always rotate around the origin.
|
||||
posToRotate.RotateZ(-rotRad);
|
||||
// now put Y value back to display form
|
||||
scenePosCV = DU::toQPointF(DU::invertY(posToRotate));
|
||||
}
|
||||
// Invert Y value so the math works.
|
||||
Base::Vector3d posToRotate = DU::invertY(DU::toVector3d(scenePosCV));
|
||||
posToRotate = CosmeticVertex::makeCanonicalPoint(m_baseFeat, posToRotate);
|
||||
// now put Y value back to display form
|
||||
scenePosCV = DU::toQPointF(DU::invertY(posToRotate));
|
||||
|
||||
m_savePoint = Rez::appX(scenePosCV);
|
||||
updateUi();
|
||||
|
||||
Reference in New Issue
Block a user