style: Render unattached sketch vertices as unfilled circles
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -744,7 +744,6 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch)
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glLineWidth(2.0f);
|
||||
glPointSize(5.0f);
|
||||
|
||||
QVector<GLfloat> lineVertices;
|
||||
std::map<gp_Pnt, int, PntComparator> vertexCounts;
|
||||
@@ -762,11 +761,33 @@ void ViewportWidget::drawSketch(const SketchFeature* sketch)
|
||||
}
|
||||
}
|
||||
|
||||
QVector<GLfloat> pointVertices;
|
||||
QVector<GLfloat> 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);
|
||||
|
||||
Reference in New Issue
Block a user