MCPcopy Create free account
hub / github.com/LibreCAD/LibreCAD / opFindResize

Method opFindResize

plugins/circletools/circletools.cpp:928–1031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

926}
927
928void 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;

Callers

nothing calls this directly

Calls 15

scanCircleStatsFunction · 0.85
logSepFunction · 0.85
logLineFunction · 0.85
statsTextFunction · 0.85
warnFunction · 0.85
circleGeomKeyFunction · 0.85
infoFunction · 0.85
circleToolsLogFilePathFunction · 0.85
getRealMethod · 0.80
getAllEntitiesMethod · 0.80
toStringMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected