| 926 | } |
| 927 | |
| 928 | void CircleToolsPlugin::opFindResize(Document_Interface* doc, QWidget* parent) { |
| 929 | const QString title = QStringLiteral("CircleTools"); |
| 930 | |
| 931 | const CircleStats statsBefore = scanCircleStats(doc); |
| 932 | logSep(); |
| 933 | logLine(QStringLiteral("opFindResize START")); |
| 934 | logLine(QStringLiteral("BEFORE %1").arg(statsText(statsBefore))); |
| 935 | |
| 936 | RefCircle ref; |
| 937 | if (!promptReferenceCircle(doc, parent, ref)) return; |
| 938 | |
| 939 | double tol = 0.0; |
| 940 | if (!promptTolerance(doc, parent, tol)) return; |
| 941 | |
| 942 | int layerMode = 0; |
| 943 | QString layerName; |
| 944 | if (!promptLayerFilter(doc, parent, layerMode, layerName)) return; |
| 945 | |
| 946 | qreal newDia = 0.0; |
| 947 | if (!doc->getReal(&newDia, QStringLiteral("New diameter for FOUND circles (drawing units):"), title)) return; |
| 948 | if (newDia <= 0.0) { |
| 949 | warn(parent, title, QStringLiteral("Diameter must be > 0.")); |
| 950 | return; |
| 951 | } |
| 952 | const double newR = static_cast<double>(newDia) / 2.0; |
| 953 | |
| 954 | QList<Plug_Entity*> all; |
| 955 | if (!doc->getAllEntities(&all, false)) return; |
| 956 | |
| 957 | int changed = 0; |
| 958 | int checked = 0; |
| 959 | |
| 960 | QSet<qulonglong> seenIds; |
| 961 | QSet<QString> seenGeom; |
| 962 | |
| 963 | for (Plug_Entity* e : all) { |
| 964 | if (!e) continue; |
| 965 | QHash<int, QVariant> data; |
| 966 | e->getData(&data); |
| 967 | |
| 968 | if (!isCircle(data)) continue; |
| 969 | |
| 970 | // IMPORTANT: ignore invisible entities (undo/redo history, not shown in the drawing) |
| 971 | const int vis = data.contains(DPI::VISIBLE) ? data.value(DPI::VISIBLE).toInt() : 1; |
| 972 | if (vis != 1) continue; |
| 973 | |
| 974 | const QString lay = data.value(DPI::LAYER).toString(); |
| 975 | if (layerMode == 1 && lay != ref.layer) continue; |
| 976 | if (layerMode == 2 && lay != layerName) continue; |
| 977 | |
| 978 | // Dedupe: avoid processing the same circle multiple times via wrappers/history |
| 979 | const QString gk = circleGeomKey(data); |
| 980 | if (seenGeom.contains(gk)) continue; |
| 981 | seenGeom.insert(gk); |
| 982 | |
| 983 | const qulonglong eid = static_cast<qulonglong>(data.value(DPI::EID).toULongLong()); |
| 984 | if (eid != 0) { |
| 985 | if (seenIds.contains(eid)) continue; |
nothing calls this directly
no test coverage detected