Repository: FreeCAD/FreeCAD
File: src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp (C++)

Code before:
                    QString::fromLatin1(constrIdsNode->string.getValue().getString());

                if (combinedConstrBoxes.count(constrIdsStr)) {

                    // 1. Get the icon group size in device independent pixels.
                    SbVec3s iconGroupSize = getDisplayedSize(static_cast<SoImage*>(tail));

                    // 2. Get the icon group's absolute world position from its
                    // SoZoomTranslation node.
                    SoZoomTranslation* translation = nullptr;
                    SoNode* firstTransNode = sep->getChild(
                        static_cast<int>(ConstraintNodePosition::FirstTranslationIndex));
                    if (dynamic_cast<SoZoomTranslation*>(firstTransNode)) {
                        translation = static_cast<SoZoomTranslation*>(firstTransNode);
                    }
                    if (!translation) {
                        continue;
                    }

                    SbVec3f absPos = translation->abPos.getValue();
                    SbVec3f trans = translation->translation.getValue();
                    float scaleFactor = translation->getScaleFactor();

                    // If this is the second icon in a pair, add its relative translation.
                    int secondIndex = static_cast<int>(ConstraintNodePosition::SecondIconIndex);
                    if (sep->getNumChildren() > secondIndex) {
                        SoNode* secondIconNode = sep->getChild(secondIndex);
                        if (tail == secondIconNode) {
                            auto translation2 = static_cast<SoZoomTranslation*>(sep->getChild(
                                static_cast<int>(ConstraintNodePosition::SecondTranslationIndex)));
                            absPos += translation2->abPos.getValue();
                            trans += translation2->translation.getValue();
                            scaleFactor = translation2->getScaleFactor();
                        }
                    }

                    // 3. Calculate the icon's center in world coordinates.
                    SbVec3f iconGroupWorldPos = absPos + scaleFactor * trans;

                    // 4. Project both the icon's center and the picked point to screen coordinates
                    // (device independent pixels). This is the key: both points are now in the same
                    // coordinate system.
                    SbVec2f iconGroupScreenCenter =
                        ViewProviderSketchCoinAttorney::getScreenCoordinates(
                            viewProvider,
                            SbVec2f(iconGroupWorldPos[0], iconGroupWorldPos[1]));

                    SbVec2f cursorScreenPos = ViewProviderSketchCoinAttorney::getScreenCoordinates(
                        viewProvider,
                        SbVec2f(Point->getPoint()[0], Point->getPoint()[1]));


Review comment (suggestion):
```suggestion
                    if (int secondIndex = static_cast<int>(ConstraintNodePosition::SecondIconIndex);
                        secondIndex < sep->getNumChildren()) {
```

Code after:
                    QString::fromLatin1(constrIdsNode->string.getValue().getString());

                if (combinedConstrBoxes.count(constrIdsStr)) {

                    // 1. Get the icon group size in device independent pixels.
                    SbVec3s iconGroupSize = getDisplayedSize(static_cast<SoImage*>(tail));

                    // 2. Get the icon group's absolute world position from its
                    // SoZoomTranslation node.
                    SoZoomTranslation* translation = nullptr;
                    SoNode* firstTransNode = sep->getChild(
                        static_cast<int>(ConstraintNodePosition::FirstTranslationIndex));
                    if (dynamic_cast<SoZoomTranslation*>(firstTransNode)) {
                        translation = static_cast<SoZoomTranslation*>(firstTransNode);
                    }
                    if (!translation) {
                        continue;
                    }

                    SbVec3f absPos = translation->abPos.getValue();
                    SbVec3f trans = translation->translation.getValue();
                    float scaleFactor = translation->getScaleFactor();

                    // If this is the second icon in a pair, add its relative translation.
                    if (int secondIndex = static_cast<int>(ConstraintNodePosition::SecondIconIndex);
                        secondIndex < sep->getNumChildren()) {
                        SoNode* secondIconNode = sep->getChild(secondIndex);
                        if (tail == secondIconNode) {
                            auto translation2 = static_cast<SoZoomTranslation*>(sep->getChild(
                                static_cast<int>(ConstraintNodePosition::SecondTranslationIndex)));
                            absPos += translation2->abPos.getValue();
                            trans += translation2->translation.getValue();
                            scaleFactor = translation2->getScaleFactor();
                        }
                    }

                    // 3. Calculate the icon's center in world coordinates.
                    SbVec3f iconGroupWorldPos = absPos + scaleFactor * trans;

                    // 4. Project both the icon's center and the picked point to screen coordinates
                    // (device independent pixels). This is the key: both points are now in the same
                    // coordinate system.
                    SbVec2f iconGroupScreenCenter =
                        ViewProviderSketchCoinAttorney::getScreenCoordinates(
                            viewProvider,
                            SbVec2f(iconGroupWorldPos[0], iconGroupWorldPos[1]));

                    SbVec2f cursorScreenPos = ViewProviderSketchCoinAttorney::getScreenCoordinates(
                        viewProvider,
                        SbVec2f(Point->getPoint()[0], Point->getPoint()[1]));