From a7ad78e10359d42a505d32dd159f086225f60a73 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 18 Feb 2026 11:50:24 -0700 Subject: [PATCH] fix: Correct coordinate system for sketch plane geometry and rendering Co-authored-by: aider (gemini/gemini-2.5-pro) --- src/SketchFeature.cpp | 16 ++++++++-------- src/ViewportWidget.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/SketchFeature.cpp b/src/SketchFeature.cpp index ef95687..fc46cf0 100644 --- a/src/SketchFeature.cpp +++ b/src/SketchFeature.cpp @@ -65,14 +65,14 @@ void SketchFeature::buildShape() gp_Pnt other_corner1, other_corner2; if (m_plane == SketchPlane::XY) { - other_corner1.SetCoord(c1.X(), c2.Y(), c1.Z()); - other_corner2.SetCoord(c2.X(), c1.Y(), c1.Z()); + other_corner1.SetCoord(c2.X(), c1.Y(), c1.Z()); + other_corner2.SetCoord(c1.X(), c1.Y(), c2.Z()); } else if (m_plane == SketchPlane::XZ) { - other_corner1.SetCoord(c1.X(), c1.Y(), c2.Z()); - other_corner2.SetCoord(c2.X(), c1.Y(), c1.Z()); - } else { // YZ - other_corner1.SetCoord(c1.X(), c1.Y(), c2.Z()); + other_corner1.SetCoord(c2.X(), c1.Y(), c1.Z()); other_corner2.SetCoord(c1.X(), c2.Y(), c1.Z()); + } else { // YZ + other_corner1.SetCoord(c1.X(), c2.Y(), c1.Z()); + other_corner2.SetCoord(c1.X(), c1.Y(), c2.Z()); } BRepBuilderAPI_MakeEdge me1(c1, other_corner1); @@ -93,8 +93,8 @@ void SketchFeature::buildShape() double radius = circle->radius(); gp_Dir normal; switch (m_plane) { - case SketchPlane::XY: normal = gp::DZ(); break; - case SketchPlane::XZ: normal = gp::DY(); break; + case SketchPlane::XY: normal = gp::DY(); break; + case SketchPlane::XZ: normal = gp::DZ(); break; case SketchPlane::YZ: normal = gp::DX(); break; } gp_Ax2 axis(center, normal); diff --git a/src/ViewportWidget.cpp b/src/ViewportWidget.cpp index df0b0d9..510d64a 100644 --- a/src/ViewportWidget.cpp +++ b/src/ViewportWidget.cpp @@ -544,11 +544,11 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch) switch (sketch->plane()) { case SketchFeature::SketchPlane::XY: u_axis = QVector3D(1, 0, 0); - v_axis = QVector3D(0, 1, 0); + v_axis = QVector3D(0, 0, 1); break; case SketchFeature::SketchPlane::XZ: u_axis = QVector3D(1, 0, 0); - v_axis = QVector3D(0, 0, 1); + v_axis = QVector3D(0, 1, 0); break; case SketchFeature::SketchPlane::YZ: u_axis = QVector3D(0, 1, 0); @@ -574,10 +574,10 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch) gp_Pnt p2, p4; if (sketch->plane() == SketchFeature::SketchPlane::XY) { p2.SetCoord(p3.X(), p1.Y(), p1.Z()); - p4.SetCoord(p1.X(), p3.Y(), p1.Z()); + p4.SetCoord(p1.X(), p1.Y(), p3.Z()); } else if (sketch->plane() == SketchFeature::SketchPlane::XZ) { p2.SetCoord(p3.X(), p1.Y(), p1.Z()); - p4.SetCoord(p1.X(), p1.Y(), p3.Z()); + p4.SetCoord(p1.X(), p3.Y(), p1.Z()); } else if (sketch->plane() == SketchFeature::SketchPlane::YZ) { p2.SetCoord(p1.X(), p3.Y(), p1.Z()); p4.SetCoord(p1.X(), p1.Y(), p3.Z());