Sketcher.scale: scale constraint with the right index (#27188)

This commit is contained in:
theo-vt
2026-02-13 15:34:46 -06:00
committed by GitHub
parent 4938a6f75b
commit 9cbef0c5ce
+14 -11
View File
@@ -135,6 +135,7 @@ public:
if (deleteOriginal) {
deleteOriginalGeos();
}
int initialConstraintCount = sketchgui->getSketchObject()->Constraints.getSize();
commandAddShapeGeometryAndConstraints();
@@ -142,7 +143,7 @@ public:
reassignFacadeIds();
}
scaleLabels();
scaleLabels(initialConstraintCount);
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
@@ -347,22 +348,24 @@ private:
Base::Console().error("%s\n", e.what());
}
}
void scaleLabels()
void scaleLabels(int constraintIndexOffset)
{
SketchObject* sketch = sketchgui->getSketchObject();
for (auto toScale : listOfLabelsToScale) {
sketch->setLabelDistance(toScale.constrId, toScale.distance * scaleFactor);
int constrId = toScale.constrId + constraintIndexOffset;
// Label position or radii and diameters represent an angle, so
sketch->setLabelDistance(constrId, toScale.distance * static_cast<float>(scaleFactor));
// Label position or radii anddiameters represent an angle, so
// they should not be scaled
Sketcher::ConstraintType type = sketch->Constraints[toScale.constrId]->Type;
Sketcher::ConstraintType type = sketch->Constraints[constrId]->Type;
if (type == Sketcher::ConstraintType::Radius
|| type == Sketcher::ConstraintType::Diameter) {
sketch->setLabelPosition(toScale.constrId, toScale.position);
sketch->setLabelPosition(constrId, toScale.position);
}
else {
sketch->setLabelPosition(toScale.constrId, toScale.position * scaleFactor);
sketch->setLabelPosition(constrId, toScale.position * static_cast<float>(scaleFactor));
}
}
}
@@ -496,9 +499,8 @@ private:
}
const std::vector<Constraint*>& vals = Obj->Constraints.getValues();
for (size_t i = 0; i < vals.size(); ++i) {
auto cstr = vals[i];
int cstrIndex = 0;
for (auto cstr : vals) {
if (skipConstraint(cstr)) {
continue;
}
@@ -512,7 +514,7 @@ private:
if (firstIndex != GeoEnum::GeoUndef) {
listOfLabelsToScale.push_back(
LabelToScale {
.constrId = static_cast<int>(i),
.constrId = cstrIndex,
.position = cstr->LabelPosition,
.distance = cstr->LabelDistance
}
@@ -571,6 +573,7 @@ private:
}
ShapeConstraints.push_back(std::move(newConstr));
cstrIndex++;
}
}
}