[TechDraw]Detail highlight drag (fix #21828) (#22036)

* [TD]add preferences for detail highlight snapping

* [TD]fix highlight drag issues

* Update src/Mod/TechDraw/Gui/TaskDetail.cpp

minor format change from benj5378.

Co-authored-by: Benjamin Bræstrup Sayoc <benj5378@outlook.com>

---------

Co-authored-by: Benjamin Bræstrup Sayoc <benj5378@outlook.com>
This commit is contained in:
WandererFan
2025-06-23 12:13:27 -04:00
committed by GitHub
parent c25782551b
commit 51184b99d5
13 changed files with 230 additions and 125 deletions

View File

@@ -718,6 +718,38 @@ void DrawViewPart::onFacesFinished()
requestPaint();
}
//! returns the position of the first visible vertex within snap radius of newAnchorPoint. newAnchorPoint
//! should be unscaled in conventional coordinates. if no suitable vertex is found, newAnchorPoint
//! is returned. the result is unscaled and inverted?
Base::Vector3d DrawViewPart::snapHighlightToVertex(Base::Vector3d newAnchorPoint,
double radius) const
{
if (!Preferences::snapDetailHighlights()) {
return newAnchorPoint;
}
double snapRadius = radius * Preferences::detailSnapRadius();
double dvpScale = getScale();
std::vector<Base::Vector3d> vertexPoints;
auto vertsAll = getVertexGeometry();
double nearDistance{std::numeric_limits<double>::max()};
Base::Vector3d nearPoint{newAnchorPoint};
for (auto& vert: vertsAll) {
if (vert->getHlrVisible()) {
Base::Vector3d vertPointUnscaled = DU::invertY(vert->point()) / dvpScale;
double distanceToVertex = (vertPointUnscaled - newAnchorPoint).Length();
if (distanceToVertex < snapRadius &&
distanceToVertex < nearDistance) {
nearDistance = distanceToVertex;
nearPoint = vertPointUnscaled;
}
}
}
return nearPoint;
}
//retrieve all the face hatches associated with this dvp
std::vector<TechDraw::DrawHatch*> DrawViewPart::getHatches() const
{