X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_Manager.cpp;h=8bebc53c4247037984ef7b9c14fb112e7c6903f4;hb=77ce6d35ac8d2f0fdaecb4f23e0870bf74e36103;hp=a9d47533e95b12fb5cb18ad2dc632add3e8c13a5;hpb=77d6e03555d0d46232e09ace4178f66f8c9b40ee;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index a9d47533e..8bebc53c4 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -87,6 +88,19 @@ static void featuresOrderedByType(const std::set& theOriginalFeatures } } +static void setPoint(AttributePtr theAttribute, + const int thePointIndex, + const std::shared_ptr theValue) +{ + AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast(theAttribute); + AttributePoint2DArrayPtr aPointArrayAttr = + std::dynamic_pointer_cast(theAttribute); + if (aPointAttr) + aPointAttr->setValue(theValue); + else if (aPointArrayAttr && thePointIndex >= 0) + aPointArrayAttr->setPnt(thePointIndex, theValue); +} + // ======================================================== @@ -180,8 +194,8 @@ void SketchSolver_Manager::processEvent( std::dynamic_pointer_cast(theMessage); ObjectPtr aMovedObject = aMoveMsg->movedObject(); - std::shared_ptr aMovedPoint = - std::dynamic_pointer_cast(aMoveMsg->movedAttribute()); + AttributePtr aMovedAttribute = aMoveMsg->movedAttribute(); + int aMovedPoint = aMoveMsg->movedPointIndex(); const std::shared_ptr& aFrom = aMoveMsg->originalPosition(); const std::shared_ptr& aTo = aMoveMsg->currentPosition(); @@ -192,8 +206,8 @@ void SketchSolver_Manager::processEvent( std::dynamic_pointer_cast(aMovedFeature); if (aSketchFeature && !aSketchFeature->isMacro()) needToResolve = moveFeature(aSketchFeature, aFrom, aTo); - } else if (aMovedPoint) - needToResolve = moveAttribute(aMovedPoint, aFrom, aTo); + } else if (aMovedAttribute) + needToResolve = moveAttribute(aMovedAttribute, aMovedPoint, aFrom, aTo); } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { std::shared_ptr aDeleteMsg = @@ -349,7 +363,8 @@ bool SketchSolver_Manager::moveFeature( // Purpose: move given attribute in appropriate group // ============================================================================ bool SketchSolver_Manager::moveAttribute( - const std::shared_ptr& theMovedAttribute, + const std::shared_ptr& theMovedAttribute, + const int theMovedPointIndex, const std::shared_ptr& theFrom, const std::shared_ptr& theTo) { @@ -358,7 +373,7 @@ bool SketchSolver_Manager::moveAttribute( std::dynamic_pointer_cast(anOwner); if (aConstraint) { - theMovedAttribute->setValue(theTo); + setPoint(theMovedAttribute, theMovedPointIndex, theTo); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); return true; } @@ -369,12 +384,12 @@ bool SketchSolver_Manager::moveAttribute( if (aSketchFeature) aGroup = findGroup(aSketchFeature); if (!aGroup) { - theMovedAttribute->setValue(theTo); + setPoint(theMovedAttribute, theMovedPointIndex, theTo); return false; } aGroup->blockEvents(true); - return aGroup->movePoint(theMovedAttribute, theFrom, theTo); + return aGroup->movePoint(theMovedAttribute, theMovedPointIndex, theFrom, theTo); } // ============================================================================