fix: Update OpenCASCADE 2D/3D point conversion API in Snapping
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
+9
-8
@@ -22,6 +22,7 @@
|
||||
#include <optional>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
Snapping::Snapping(ViewportWidget* viewport) : m_viewport(viewport)
|
||||
@@ -41,7 +42,7 @@ bool Snapping::update(const QPoint& mousePos)
|
||||
gp_Pnt worldPos(worldPosQ.x(), worldPosQ.y(), worldPosQ.z());
|
||||
const float snapRectHalfSize = 0.0075f * -m_viewport->camera()->zoom();
|
||||
|
||||
gp_Pnt2d worldPos2d = ElCLib::To2d(worldPos, plane);
|
||||
gp_Pnt2d worldPos2d(gp_Vec(plane.Location(), worldPos).Dot(plane.XDirection()), gp_Vec(plane.Location(), worldPos).Dot(plane.YDirection()));
|
||||
shouldSnap = qAbs(worldPos2d.X()) < snapRectHalfSize && qAbs(worldPos2d.Y()) < snapRectHalfSize;
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ bool Snapping::update(const QPoint& mousePos)
|
||||
const auto& plane = currentPlaneOpt.value();
|
||||
QVector3D worldPosQ = m_viewport->unproject(mousePos, plane);
|
||||
gp_Pnt worldPos(worldPosQ.x(), worldPosQ.y(), worldPosQ.z());
|
||||
gp_Pnt2d worldPos2d = ElCLib::To2d(worldPos, plane);
|
||||
gp_Pnt2d worldPos2d(gp_Vec(plane.Location(), worldPos).Dot(plane.XDirection()), gp_Vec(plane.Location(), worldPos).Dot(plane.YDirection()));
|
||||
const float snapRectHalfSize = 0.0075f * -m_viewport->camera()->zoom();
|
||||
|
||||
for (Feature* feature : m_viewport->document()->features()) {
|
||||
@@ -65,7 +66,7 @@ bool Snapping::update(const QPoint& mousePos)
|
||||
auto line = static_cast<const SketchLine*>(obj);
|
||||
const gp_Pnt vertices[] = {line->startPoint(), line->endPoint()};
|
||||
for (const auto& vertex : vertices) {
|
||||
gp_Pnt2d vertex2d = ElCLib::To2d(vertex, plane);
|
||||
gp_Pnt2d vertex2d(gp_Vec(plane.Location(), vertex).Dot(plane.XDirection()), gp_Vec(plane.Location(), vertex).Dot(plane.YDirection()));
|
||||
bool isClose = qAbs(worldPos2d.X() - vertex2d.X()) < snapRectHalfSize && qAbs(worldPos2d.Y() - vertex2d.Y()) < snapRectHalfSize;
|
||||
|
||||
if (isClose) {
|
||||
@@ -80,18 +81,18 @@ bool Snapping::update(const QPoint& mousePos)
|
||||
const auto& p1 = rect->corner1();
|
||||
const auto& p3 = rect->corner2();
|
||||
|
||||
gp_Pnt2d p1_2d = ElCLib::To2d(p1, rectPlane);
|
||||
gp_Pnt2d p3_2d = ElCLib::To2d(p3, rectPlane);
|
||||
gp_Pnt2d p1_2d(gp_Vec(rectPlane.Location(), p1).Dot(rectPlane.XDirection()), gp_Vec(rectPlane.Location(), p1).Dot(rectPlane.YDirection()));
|
||||
gp_Pnt2d p3_2d(gp_Vec(rectPlane.Location(), p3).Dot(rectPlane.XDirection()), gp_Vec(rectPlane.Location(), p3).Dot(rectPlane.YDirection()));
|
||||
|
||||
gp_Pnt2d p2_2d(p3_2d.X(), p1_2d.Y());
|
||||
gp_Pnt2d p4_2d(p1_2d.X(), p3_2d.Y());
|
||||
|
||||
gp_Pnt p2 = ElCLib::To3d(p2_2d, rectPlane);
|
||||
gp_Pnt p4 = ElCLib::To3d(p4_2d, rectPlane);
|
||||
gp_Pnt p2 = ElCLib::To3d(rectPlane, p2_2d);
|
||||
gp_Pnt p4 = ElCLib::To3d(rectPlane, p4_2d);
|
||||
|
||||
const gp_Pnt vertices[] = {p1, p2, p3, p4};
|
||||
for (const auto& vertex : vertices) {
|
||||
gp_Pnt2d vertex2d = ElCLib::To2d(vertex, plane);
|
||||
gp_Pnt2d vertex2d(gp_Vec(plane.Location(), vertex).Dot(plane.XDirection()), gp_Vec(plane.Location(), vertex).Dot(plane.YDirection()));
|
||||
bool isClose = qAbs(worldPos2d.X() - vertex2d.X()) < snapRectHalfSize && qAbs(worldPos2d.Y() - vertex2d.Y()) < snapRectHalfSize;
|
||||
|
||||
if (isClose) {
|
||||
|
||||
Reference in New Issue
Block a user