fix: Update OpenCASCADE API usage for 2D/3D geometry conversion
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
+42
-41
@@ -18,6 +18,7 @@
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Dir2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
LineTool::LineTool(ViewportWidget* viewport)
|
||||
@@ -84,9 +85,9 @@ void LineTool::mousePressEvent(QMouseEvent *event)
|
||||
gp_Pnt mousePnt(currentMouseWorldPos.x(), currentMouseWorldPos.y(), currentMouseWorldPos.z());
|
||||
gp_Dir refDirGp(refDir.x(), refDir.y(), refDir.z());
|
||||
|
||||
gp_Pnt2d startPnt2d = ElCLib::Value(startPnt, plane);
|
||||
gp_Pnt2d mousePnt2d = ElCLib::Value(mousePnt, plane);
|
||||
gp_Dir2d refDir2d = ElCLib::Direction(plane, refDirGp);
|
||||
gp_Pnt2d startPnt2d(gp_Vec(plane.Location(), startPnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), startPnt).Dot(plane.YDirection()));
|
||||
gp_Pnt2d mousePnt2d(gp_Vec(plane.Location(), mousePnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), mousePnt).Dot(plane.YDirection()));
|
||||
gp_Dir2d refDir2d(refDirGp.Dot(plane.XDirection()), refDirGp.Dot(plane.YDirection()));
|
||||
|
||||
gp_Vec2d mouseVec2d(startPnt2d, mousePnt2d);
|
||||
double mouseAngle = qRadiansToDegrees(atan2(mouseVec2d.Y(), mouseVec2d.X()));
|
||||
@@ -106,7 +107,7 @@ void LineTool::mousePressEvent(QMouseEvent *event)
|
||||
}
|
||||
double finalAngleRad = qDegreesToRadians(refAngle + snappedAngle);
|
||||
gp_Dir2d finalDir2d(cos(finalAngleRad), sin(finalAngleRad));
|
||||
gp_Dir finalDir3d = ElCLib::Direction(finalDir2d, plane);
|
||||
gp_Dir finalDir3d = ElCLib::To3d(plane, finalDir2d);
|
||||
QVector3D finalDir(finalDir3d.X(), finalDir3d.Y(), finalDir3d.Z());
|
||||
double lineLength;
|
||||
if (lengthFromInput) lineLength = inputLength;
|
||||
@@ -137,14 +138,14 @@ void LineTool::mousePressEvent(QMouseEvent *event)
|
||||
gp_Pnt worldPos(worldPosQ.x(), worldPosQ.y(), worldPosQ.z());
|
||||
|
||||
if (m_viewport->isSnappingHorizontal() || m_viewport->isSnappingVertical()) {
|
||||
gp_Pnt2d worldPos2d = ElCLib::Value(worldPos, plane);
|
||||
gp_Pnt2d firstPoint2d = ElCLib::Value(m_firstLinePoint, plane);
|
||||
gp_Pnt2d worldPos2d(gp_Vec(plane.Location(), worldPos).Dot(plane.XDirection()), gp_Vec(plane.Location(), worldPos).Dot(plane.YDirection()));
|
||||
gp_Pnt2d firstPoint2d(gp_Vec(plane.Location(), m_firstLinePoint).Dot(plane.XDirection()), gp_Vec(plane.Location(), m_firstLinePoint).Dot(plane.YDirection()));
|
||||
if (m_viewport->isSnappingHorizontal()) {
|
||||
worldPos2d.SetY(firstPoint2d.Y());
|
||||
} else { // vertical
|
||||
worldPos2d.SetX(firstPoint2d.X());
|
||||
}
|
||||
worldPos = ElCLib::Value(worldPos2d, plane);
|
||||
worldPos = ElCLib::To3d(plane, worldPos2d);
|
||||
}
|
||||
p = worldPos;
|
||||
}
|
||||
@@ -187,8 +188,8 @@ void LineTool::mouseMoveEvent(QMouseEvent *event)
|
||||
gp_Pnt worldPos(worldPosQ.x(), worldPosQ.y(), worldPosQ.z());
|
||||
gp_Pnt startPos = m_firstLinePoint;
|
||||
|
||||
gp_Pnt2d worldPos2d = ElCLib::Value(worldPos, plane);
|
||||
gp_Pnt2d startPos2d = ElCLib::Value(startPos, plane);
|
||||
gp_Pnt2d worldPos2d(gp_Vec(plane.Location(), worldPos).Dot(plane.XDirection()), gp_Vec(plane.Location(), worldPos).Dot(plane.YDirection()));
|
||||
gp_Pnt2d startPos2d(gp_Vec(plane.Location(), startPos).Dot(plane.XDirection()), gp_Vec(plane.Location(), startPos).Dot(plane.YDirection()));
|
||||
gp_Vec2d delta(startPos2d, worldPos2d);
|
||||
|
||||
if (delta.Magnitude() > 1e-6) {
|
||||
@@ -250,9 +251,9 @@ void LineTool::finalizeCreation()
|
||||
gp_Pnt mousePnt(currentMouseWorldPos.x(), currentMouseWorldPos.y(), currentMouseWorldPos.z());
|
||||
gp_Dir refDirGp(refDir.x(), refDir.y(), refDir.z());
|
||||
|
||||
gp_Pnt2d startPnt2d = ElCLib::Value(startPnt, plane);
|
||||
gp_Pnt2d mousePnt2d = ElCLib::Value(mousePnt, plane);
|
||||
gp_Dir2d refDir2d = ElCLib::Direction(plane, refDirGp);
|
||||
gp_Pnt2d startPnt2d(gp_Vec(plane.Location(), startPnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), startPnt).Dot(plane.YDirection()));
|
||||
gp_Pnt2d mousePnt2d(gp_Vec(plane.Location(), mousePnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), mousePnt).Dot(plane.YDirection()));
|
||||
gp_Dir2d refDir2d(refDirGp.Dot(plane.XDirection()), refDirGp.Dot(plane.YDirection()));
|
||||
|
||||
gp_Vec2d mouseVec2d(startPnt2d, mousePnt2d);
|
||||
double mouseAngle = qRadiansToDegrees(atan2(mouseVec2d.Y(), mouseVec2d.X()));
|
||||
@@ -272,7 +273,7 @@ void LineTool::finalizeCreation()
|
||||
}
|
||||
double finalAngleRad = qDegreesToRadians(refAngle + snappedAngle);
|
||||
gp_Dir2d finalDir2d(cos(finalAngleRad), sin(finalAngleRad));
|
||||
gp_Dir finalDir3d = ElCLib::Direction(finalDir2d, plane);
|
||||
gp_Dir finalDir3d = ElCLib::To3d(plane, finalDir2d);
|
||||
QVector3D finalDir(finalDir3d.X(), finalDir3d.Y(), finalDir3d.Z());
|
||||
double lineLength;
|
||||
if (lengthFromInput) lineLength = inputLength;
|
||||
@@ -354,9 +355,9 @@ void LineTool::paintGL()
|
||||
gp_Pnt mousePnt(currentMouseWorldPos.x(), currentMouseWorldPos.y(), currentMouseWorldPos.z());
|
||||
gp_Dir refDirGp(refDir.x(), refDir.y(), refDir.z());
|
||||
|
||||
gp_Pnt2d startPnt2d = ElCLib::Value(startPnt, plane);
|
||||
gp_Pnt2d mousePnt2d = ElCLib::Value(mousePnt, plane);
|
||||
gp_Dir2d refDir2d = ElCLib::Direction(plane, refDirGp);
|
||||
gp_Pnt2d startPnt2d(gp_Vec(plane.Location(), startPnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), startPnt).Dot(plane.YDirection()));
|
||||
gp_Pnt2d mousePnt2d(gp_Vec(plane.Location(), mousePnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), mousePnt).Dot(plane.YDirection()));
|
||||
gp_Dir2d refDir2d(refDirGp.Dot(plane.XDirection()), refDirGp.Dot(plane.YDirection()));
|
||||
|
||||
gp_Vec2d mouseVec2d(startPnt2d, mousePnt2d);
|
||||
double mouseAngle = qRadiansToDegrees(atan2(mouseVec2d.Y(), mouseVec2d.X()));
|
||||
@@ -379,7 +380,7 @@ void LineTool::paintGL()
|
||||
|
||||
double finalAngleRad = qDegreesToRadians(refAngle + snappedAngle);
|
||||
gp_Dir2d finalDir2d(cos(finalAngleRad), sin(finalAngleRad));
|
||||
gp_Dir finalDir3d = ElCLib::Direction(finalDir2d, plane);
|
||||
gp_Dir finalDir3d = ElCLib::To3d(plane, finalDir2d);
|
||||
QVector3D finalDir(finalDir3d.X(), finalDir3d.Y(), finalDir3d.Z());
|
||||
|
||||
double lineLength;
|
||||
@@ -410,14 +411,14 @@ void LineTool::paintGL()
|
||||
} else if (m_viewport->isSnappingVertex()) {
|
||||
worldPosPnt = m_viewport->snapVertex();
|
||||
} else if (m_viewport->isSnappingHorizontal() || m_viewport->isSnappingVertical()) {
|
||||
gp_Pnt2d worldPos2d = ElCLib::Value(worldPosPnt, plane);
|
||||
gp_Pnt2d firstPoint2d = ElCLib::Value(m_firstLinePoint, plane);
|
||||
gp_Pnt2d worldPos2d(gp_Vec(plane.Location(), worldPosPnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), worldPosPnt).Dot(plane.YDirection()));
|
||||
gp_Pnt2d firstPoint2d(gp_Vec(plane.Location(), m_firstLinePoint).Dot(plane.XDirection()), gp_Vec(plane.Location(), m_firstLinePoint).Dot(plane.YDirection()));
|
||||
if (m_viewport->isSnappingHorizontal()) {
|
||||
worldPos2d.SetY(firstPoint2d.Y());
|
||||
} else { // vertical
|
||||
worldPos2d.SetX(firstPoint2d.X());
|
||||
}
|
||||
worldPosPnt = ElCLib::Value(worldPos2d, plane);
|
||||
worldPosPnt = ElCLib::To3d(plane, worldPos2d);
|
||||
}
|
||||
worldPos.setX(worldPosPnt.X()); worldPos.setY(worldPosPnt.Y()); worldPos.setZ(worldPosPnt.Z());
|
||||
}
|
||||
@@ -453,9 +454,9 @@ void LineTool::paintGL()
|
||||
gp_Pnt mousePnt(currentMouseWorldPos.x(), currentMouseWorldPos.y(), currentMouseWorldPos.z());
|
||||
gp_Dir refDirGp(refDir.x(), refDir.y(), refDir.z());
|
||||
|
||||
gp_Pnt2d startPnt2d = ElCLib::Value(startPnt, plane);
|
||||
gp_Pnt2d mousePnt2d = ElCLib::Value(mousePnt, plane);
|
||||
gp_Dir2d refDir2d = ElCLib::Direction(plane, refDirGp);
|
||||
gp_Pnt2d startPnt2d(gp_Vec(plane.Location(), startPnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), startPnt).Dot(plane.YDirection()));
|
||||
gp_Pnt2d mousePnt2d(gp_Vec(plane.Location(), mousePnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), mousePnt).Dot(plane.YDirection()));
|
||||
gp_Dir2d refDir2d(refDirGp.Dot(plane.XDirection()), refDirGp.Dot(plane.YDirection()));
|
||||
|
||||
gp_Vec2d mouseVec2d(startPnt2d, mousePnt2d);
|
||||
double mouseAngle = qRadiansToDegrees(atan2(mouseVec2d.Y(), mouseVec2d.X()));
|
||||
@@ -477,8 +478,8 @@ void LineTool::paintGL()
|
||||
gp_Dir refDirGp(refDir.x(), refDir.y(), refDir.z());
|
||||
gp_Dir lineDirGp(lineVec.x(), lineVec.y(), lineVec.z());
|
||||
|
||||
gp_Dir2d refDir2d = ElCLib::Direction(plane, refDirGp);
|
||||
gp_Dir2d lineDir2d = ElCLib::Direction(plane, lineDirGp);
|
||||
gp_Dir2d refDir2d(refDirGp.Dot(plane.XDirection()), refDirGp.Dot(plane.YDirection()));
|
||||
gp_Dir2d lineDir2d(lineDirGp.Dot(plane.XDirection()), lineDirGp.Dot(plane.YDirection()));
|
||||
|
||||
refAngle = atan2(refDir2d.Y(), refDir2d.X());
|
||||
lineAngle = atan2(lineDir2d.Y(), lineDir2d.X());
|
||||
@@ -492,9 +493,9 @@ void LineTool::paintGL()
|
||||
vertices.clear();
|
||||
|
||||
gp_Dir lineDirGp(lineVec.x(), lineVec.y(), lineVec.z());
|
||||
gp_Dir2d lineDir2d = ElCLib::Direction(plane, lineDirGp);
|
||||
gp_Dir2d lineDir2d(lineDirGp.Dot(plane.XDirection()), lineDirGp.Dot(plane.YDirection()));
|
||||
gp_Dir2d perpDir2d(-lineDir2d.Y(), lineDir2d.X());
|
||||
gp_Dir perpDir3d = ElCLib::Direction(perpDir2d, plane);
|
||||
gp_Dir perpDir3d = ElCLib::To3d(plane, perpDir2d);
|
||||
QVector3D perpVec(perpDir3d.X(), perpDir3d.Y(), perpDir3d.Z());
|
||||
|
||||
if (angleDiff < 0) {
|
||||
@@ -670,9 +671,9 @@ void LineTool::paint2D(QPainter& painter, const QMatrix4x4& modelView, const QMa
|
||||
gp_Pnt mousePnt(currentMouseWorldPos.x(), currentMouseWorldPos.y(), currentMouseWorldPos.z());
|
||||
gp_Dir refDirGp(refDir.x(), refDir.y(), refDir.z());
|
||||
|
||||
gp_Pnt2d startPnt2d = ElCLib::Value(startPnt, plane);
|
||||
gp_Pnt2d mousePnt2d = ElCLib::Value(mousePnt, plane);
|
||||
gp_Dir2d refDir2d = ElCLib::Direction(plane, refDirGp);
|
||||
gp_Pnt2d startPnt2d(gp_Vec(plane.Location(), startPnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), startPnt).Dot(plane.YDirection()));
|
||||
gp_Pnt2d mousePnt2d(gp_Vec(plane.Location(), mousePnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), mousePnt).Dot(plane.YDirection()));
|
||||
gp_Dir2d refDir2d(refDirGp.Dot(plane.XDirection()), refDirGp.Dot(plane.YDirection()));
|
||||
|
||||
gp_Vec2d mouseVec2d(startPnt2d, mousePnt2d);
|
||||
double mouseAngle = qRadiansToDegrees(atan2(mouseVec2d.Y(), mouseVec2d.X()));
|
||||
@@ -695,7 +696,7 @@ void LineTool::paint2D(QPainter& painter, const QMatrix4x4& modelView, const QMa
|
||||
|
||||
double finalAngleRad = qDegreesToRadians(refAngle + snappedAngle);
|
||||
gp_Dir2d finalDir2d(cos(finalAngleRad), sin(finalAngleRad));
|
||||
gp_Dir finalDir3d = ElCLib::Direction(finalDir2d, plane);
|
||||
gp_Dir finalDir3d = ElCLib::To3d(plane, finalDir2d);
|
||||
QVector3D finalDir(finalDir3d.X(), finalDir3d.Y(), finalDir3d.Z());
|
||||
|
||||
if (lengthFromInput) {
|
||||
@@ -726,14 +727,14 @@ void LineTool::paint2D(QPainter& painter, const QMatrix4x4& modelView, const QMa
|
||||
} else if (m_viewport->isSnappingVertex()) {
|
||||
worldPosPnt = m_viewport->snapVertex();
|
||||
} else if (m_viewport->isSnappingHorizontal() || m_viewport->isSnappingVertical()) {
|
||||
gp_Pnt2d worldPos2d = ElCLib::Value(worldPosPnt, plane);
|
||||
gp_Pnt2d firstPoint2d = ElCLib::Value(m_firstLinePoint, plane);
|
||||
gp_Pnt2d worldPos2d(gp_Vec(plane.Location(), worldPosPnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), worldPosPnt).Dot(plane.YDirection()));
|
||||
gp_Pnt2d firstPoint2d(gp_Vec(plane.Location(), m_firstLinePoint).Dot(plane.XDirection()), gp_Vec(plane.Location(), m_firstLinePoint).Dot(plane.YDirection()));
|
||||
if (m_viewport->isSnappingHorizontal()) {
|
||||
worldPos2d.SetY(firstPoint2d.Y());
|
||||
} else { // vertical
|
||||
worldPos2d.SetX(firstPoint2d.X());
|
||||
}
|
||||
worldPosPnt = ElCLib::Value(worldPos2d, plane);
|
||||
worldPosPnt = ElCLib::To3d(plane, worldPos2d);
|
||||
}
|
||||
worldPos.setX(worldPosPnt.X()); worldPos.setY(worldPosPnt.Y()); worldPos.setZ(worldPosPnt.Z());
|
||||
lineLength = (worldPos - startPos).length();
|
||||
@@ -759,9 +760,9 @@ void LineTool::paint2D(QPainter& painter, const QMatrix4x4& modelView, const QMa
|
||||
gp_Pnt mousePnt(currentMouseWorldPosForText.x(), currentMouseWorldPosForText.y(), currentMouseWorldPosForText.z());
|
||||
gp_Dir refDirGp(refDir.x(), refDir.y(), refDir.z());
|
||||
|
||||
gp_Pnt2d startPnt2d = ElCLib::Value(startPnt, plane);
|
||||
gp_Pnt2d mousePnt2d = ElCLib::Value(mousePnt, plane);
|
||||
gp_Dir2d refDir2d = ElCLib::Direction(plane, refDirGp);
|
||||
gp_Pnt2d startPnt2d(gp_Vec(plane.Location(), startPnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), startPnt).Dot(plane.YDirection()));
|
||||
gp_Pnt2d mousePnt2d(gp_Vec(plane.Location(), mousePnt).Dot(plane.XDirection()), gp_Vec(plane.Location(), mousePnt).Dot(plane.YDirection()));
|
||||
gp_Dir2d refDir2d(refDirGp.Dot(plane.XDirection()), refDirGp.Dot(plane.YDirection()));
|
||||
|
||||
gp_Vec2d mouseVec2d(startPnt2d, mousePnt2d);
|
||||
double mouseAngle = qRadiansToDegrees(atan2(mouseVec2d.Y(), mouseVec2d.X()));
|
||||
@@ -784,8 +785,8 @@ void LineTool::paint2D(QPainter& painter, const QMatrix4x4& modelView, const QMa
|
||||
gp_Dir refDirGp(refDir.x(), refDir.y(), refDir.z());
|
||||
gp_Dir lineDirGp(lineVec.x(), lineVec.y(), lineVec.z());
|
||||
|
||||
gp_Dir2d refDir2d = ElCLib::Direction(plane, refDirGp);
|
||||
gp_Dir2d lineDir2d = ElCLib::Direction(plane, lineDirGp);
|
||||
gp_Dir2d refDir2d(refDirGp.Dot(plane.XDirection()), refDirGp.Dot(plane.YDirection()));
|
||||
gp_Dir2d lineDir2d(lineDirGp.Dot(plane.XDirection()), lineDirGp.Dot(plane.YDirection()));
|
||||
|
||||
refAngle = atan2(refDir2d.Y(), refDir2d.X());
|
||||
lineAngle = atan2(lineDir2d.Y(), lineDir2d.X());
|
||||
@@ -796,9 +797,9 @@ void LineTool::paint2D(QPainter& painter, const QMatrix4x4& modelView, const QMa
|
||||
lineAngle = refAngle + angleDiff;
|
||||
|
||||
gp_Dir lineDirGp(lineVec.x(), lineVec.y(), lineVec.z());
|
||||
gp_Dir2d lineDir2d = ElCLib::Direction(plane, lineDirGp);
|
||||
gp_Dir2d lineDir2d(lineDirGp.Dot(plane.XDirection()), lineDirGp.Dot(plane.YDirection()));
|
||||
gp_Dir2d perpDir2d(-lineDir2d.Y(), lineDir2d.X());
|
||||
gp_Dir perpDir3d = ElCLib::Direction(perpDir2d, plane);
|
||||
gp_Dir perpDir3d = ElCLib::To3d(plane, perpDir2d);
|
||||
QVector3D perpVec(perpDir3d.X(), perpDir3d.Y(), perpDir3d.Z());
|
||||
|
||||
if (angleDiff < 0) {
|
||||
|
||||
Reference in New Issue
Block a user