From b818be7d5dd426bb6d846ae2c46bc57abc82634e Mon Sep 17 00:00:00 2001 From: Paddle Date: Tue, 16 Jan 2024 17:59:38 +0100 Subject: [PATCH] SoDatumLabel : introduce distance arc helpers. --- src/Gui/SoDatumLabel.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ src/Gui/SoDatumLabel.h | 3 +++ 2 files changed, 43 insertions(+) diff --git a/src/Gui/SoDatumLabel.cpp b/src/Gui/SoDatumLabel.cpp index 2e2b44b3c4..52f1823317 100644 --- a/src/Gui/SoDatumLabel.cpp +++ b/src/Gui/SoDatumLabel.cpp @@ -93,6 +93,9 @@ SoDatumLabel::SoDatumLabel() SO_NODE_ADD_FIELD(param2, (0.f)); SO_NODE_ADD_FIELD(param4, (0.f)); SO_NODE_ADD_FIELD(param5, (0.f)); + SO_NODE_ADD_FIELD(param6, (0.f)); + SO_NODE_ADD_FIELD(param7, (0.f)); + SO_NODE_ADD_FIELD(param8, (0.f)); useAntialiasing = true; @@ -989,6 +992,43 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action) glVertex2f(ar3[0], ar3[1]); glVertex2f(ar4[0], ar4[1]); glEnd(); + + + if (this->datumtype.getValue() == DISTANCE) { + // Draw arc helpers if needed + float range1 = this->param4.getValue(); + if (range1 != 0.0) { + float startangle1 = this->param3.getValue(); + float radius1 = this->param5.getValue(); + SbVec3f center = points[2]; + int countSegments = std::max(6, abs(int(50.0 * range1 / (2 * M_PI)))); + double segment = range1 / (countSegments - 1); + + glBegin(GL_LINE_STRIP); + for (int i = 0; i < countSegments; i++) { + double theta = startangle1 + segment * i; + SbVec3f v1 = center + SbVec3f(radius1 * cos(theta), radius1 * sin(theta), 0); + glVertex2f(v1[0], v1[1]); + } + glEnd(); + } + float range2 = this->param7.getValue(); + if (range2 != 0.0) { + float startangle2 = this->param6.getValue(); + float radius2 = this->param8.getValue(); + SbVec3f center = points[3]; + int countSegments = std::max(6, abs(int(50.0 * range2 / (2 * M_PI)))); + double segment = range2 / (countSegments - 1); + + glBegin(GL_LINE_STRIP); + for (int i = 0; i < countSegments; i++) { + double theta = startangle2 + segment * i; + SbVec3f v1 = center + SbVec3f(radius2 * cos(theta), radius2 * sin(theta), 0); + glVertex2f(v1[0], v1[1]); + } + glEnd(); + } + } } else if (this->datumtype.getValue() == RADIUS || this->datumtype.getValue() == DIAMETER) { // Get the Points diff --git a/src/Gui/SoDatumLabel.h b/src/Gui/SoDatumLabel.h index 077069236a..2e55ffeb8e 100644 --- a/src/Gui/SoDatumLabel.h +++ b/src/Gui/SoDatumLabel.h @@ -77,6 +77,9 @@ public: SoSFFloat param3; SoSFFloat param4; SoSFFloat param5; + SoSFFloat param6; + SoSFFloat param7; + SoSFFloat param8; SoMFVec3f pnts; SoSFVec3f norm; SoSFImage image;