From f842555582f95e62a08a08c07cd59d67e5a8f612 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Mon, 16 Feb 2026 16:45:22 -0700 Subject: [PATCH] style: Render unattached sketch vertices as unfilled circles Co-authored-by: aider (gemini/gemini-2.5-pro) --- src/ViewportWidget.cpp | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/ViewportWidget.cpp b/src/ViewportWidget.cpp index fdade48..2750a25 100644 --- a/src/ViewportWidget.cpp +++ b/src/ViewportWidget.cpp @@ -744,7 +744,6 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch) { glDisable(GL_DEPTH_TEST); glLineWidth(2.0f); - glPointSize(5.0f); QVector lineVertices; std::map vertexCounts; @@ -762,11 +761,33 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch) } } - QVector pointVertices; + QVector circleVertices; + const float radius = 0.005f * -m_camera->zoom(); + const int numSegments = 16; + auto sketchPlane = sketch->plane(); + for (const auto& pair : vertexCounts) { if (pair.second == 1) { - const gp_Pnt& p = pair.first; - pointVertices << p.X() << p.Y() << p.Z(); + const gp_Pnt& center = pair.first; + for (int i = 0; i < numSegments; ++i) { + float angle1 = (2.0f * qPi() * float(i)) / float(numSegments); + float angle2 = (2.0f * qPi() * float(i + 1)) / float(numSegments); + + float x1, y1, z1, x2, y2, z2; + + if (sketchPlane == SketchFeature::SketchPlane::XY) { + x1 = center.X() + radius * cos(angle1); y1 = center.Y() + radius * sin(angle1); z1 = center.Z(); + x2 = center.X() + radius * cos(angle2); y2 = center.Y() + radius * sin(angle2); z2 = center.Z(); + } else if (sketchPlane == SketchFeature::SketchPlane::XZ) { + x1 = center.X() + radius * cos(angle1); y1 = center.Y(); z1 = center.Z() + radius * sin(angle1); + x2 = center.X() + radius * cos(angle2); y2 = center.Y(); z2 = center.Z() + radius * sin(angle2); + } else { // YZ + x1 = center.X(); y1 = center.Y() + radius * cos(angle1); z1 = center.Z() + radius * sin(angle1); + x2 = center.X(); y2 = center.Y() + radius * cos(angle2); z2 = center.Z() + radius * sin(angle2); + } + circleVertices << x1 << y1 << z1; + circleVertices << x2 << y2 << z2; + } } } @@ -777,14 +798,9 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch) m_vbo.allocate(lineVertices.constData(), lineVertices.size() * sizeof(GLfloat)); glDrawArrays(GL_LINES, 0, lineVertices.size() / 3); } - if (!pointVertices.isEmpty()) { - glEnable(GL_POINT_SMOOTH); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - m_vbo.allocate(pointVertices.constData(), pointVertices.size() * sizeof(GLfloat)); - glDrawArrays(GL_POINTS, 0, pointVertices.size() / 3); - glDisable(GL_BLEND); - glDisable(GL_POINT_SMOOTH); + if (!circleVertices.isEmpty()) { + m_vbo.allocate(circleVertices.constData(), circleVertices.size() * sizeof(GLfloat)); + glDrawArrays(GL_LINES, 0, circleVertices.size() / 3); } glEnable(GL_DEPTH_TEST);