diff --git a/src/Mod/Sketcher/Gui/SketcherTransformationExpressionHelper.cpp b/src/Mod/Sketcher/Gui/SketcherTransformationExpressionHelper.cpp index f6224dc6b8..5a859810f8 100644 --- a/src/Mod/Sketcher/Gui/SketcherTransformationExpressionHelper.cpp +++ b/src/Mod/Sketcher/Gui/SketcherTransformationExpressionHelper.cpp @@ -54,10 +54,11 @@ void SketcherTransformationExpressionHelper::storeOriginalExpressions( = sketchObject->getExpression(spath); if (expr_info.expression) { - // map expression to geoid as a key - originalExpressions[geoId] = std::shared_ptr( - expr_info.expression->copy() - ); + // map expression to constraint index as a key, storing both expression and geoId + ConstraintExpressionInfo info; + info.expression = std::shared_ptr(expr_info.expression->copy()); + info.geoId = geoId; + originalExpressions[static_cast(i)] = info; } } } @@ -91,7 +92,7 @@ void SketcherTransformationExpressionHelper::copyExpressionsToNewConstraints( // try to find and apply a matching expression for this constraint bool expressionApplied = false; for (const auto& exprPair : originalExpressions) { - int originalGeoId = exprPair.first; + int originalGeoId = exprPair.second.geoId; int originalIndex = indexOfGeoId(listOfGeoIds, originalGeoId); if (originalIndex >= 0) { @@ -101,7 +102,7 @@ void SketcherTransformationExpressionHelper::copyExpressionsToNewConstraints( originalIndex, params, secondNumberOfCopies, - exprPair.second, + exprPair.second.expression, sketchObj ); diff --git a/src/Mod/Sketcher/Gui/SketcherTransformationExpressionHelper.h b/src/Mod/Sketcher/Gui/SketcherTransformationExpressionHelper.h index e8d39d5050..8118f5036f 100644 --- a/src/Mod/Sketcher/Gui/SketcherTransformationExpressionHelper.h +++ b/src/Mod/Sketcher/Gui/SketcherTransformationExpressionHelper.h @@ -84,6 +84,12 @@ private: int numberOfCopiesToMake; }; + struct ConstraintExpressionInfo + { + std::shared_ptr expression; + int geoId; // the geoId from listOfGeoIds that this constraint references + }; + /// calculate parameters needed for copy operations CopyCalculationParams calculateCopyParams( Sketcher::SketchObject* sketchObject, @@ -106,8 +112,8 @@ private: /// check if a constraint references the specified geometry ID bool constraintReferencesGeometry(const Sketcher::Constraint* cstr, int geoId) const; - // original geo id to expression mapping - std::map> originalExpressions; + // original constraint index to expression and geoId mapping + std::map originalExpressions; }; } // namespace SketcherGui