X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_Group.cpp;h=6f855c97601e4f104516520f3764b4545c063de0;hb=449bcc64cb436f1ccf664236f431600b30ce84b4;hp=a0a7d362408d8fa2d5b6df058fcbc7d3b1511d0a;hpb=62dfa6f4f253701f32f55eb4d1852ceffce0fafb;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index a0a7d3624..6f855c976 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -56,7 +56,7 @@ static void sendMessage(const char* theMessageName, // ======================================================== -// ========= SketchSolver_Group =============== +// ========= SketchSolver_Group =============== // ======================================================== SketchSolver_Group::SketchSolver_Group(const CompositeFeaturePtr& theWorkplane) @@ -115,6 +115,62 @@ bool SketchSolver_Group::updateFeature(FeaturePtr theFeature) return myStorage->update(theFeature); } +#ifdef SUPPORT_NEW_MOVE +template +static SolverConstraintPtr move(StoragePtr theStorage, + SolverPtr theSketchSolver, + int theSketchDOF, + bool theEventsBlocked, + Type theFeatureOrPoint, + const std::shared_ptr& theFrom, + const std::shared_ptr& theTo) +{ + bool isEntityExists = (theStorage->entity(theFeatureOrPoint).get() != 0); + if (theSketchDOF == 0 && isEntityExists) { + // avoid moving elements of fully constrained sketch + theStorage->refresh(); + return SolverConstraintPtr(); + } + + // Create temporary Fixed constraint + std::shared_ptr aConstraint = + PlaneGCSSolver_Tools::createMovementConstraint(theFeatureOrPoint); + if (aConstraint) { + SolverConstraintPtr(aConstraint)->process(theStorage, theEventsBlocked); + if (aConstraint->error().empty()) { + if (!theStorage->isEmpty()) + theStorage->setNeedToResolve(true); + + theSketchSolver->initialize(); + aConstraint->startPoint(theFrom); + aConstraint->moveTo(theTo); + } else + theStorage->notify(aConstraint->movedFeature()); + } + + return aConstraint; +} + +bool SketchSolver_Group::moveFeature(FeaturePtr theFeature, + const std::shared_ptr& theFrom, + const std::shared_ptr& theTo) +{ + SolverConstraintPtr aConstraint = + move(myStorage, mySketchSolver, myDOF, myIsEventsBlocked, theFeature, theFrom, theTo); + setTemporary(aConstraint); + return true; +} + +bool SketchSolver_Group::movePoint(AttributePtr theAttribute, + const std::shared_ptr& theFrom, + const std::shared_ptr& theTo) +{ + SolverConstraintPtr aConstraint = + move(myStorage, mySketchSolver, myDOF, myIsEventsBlocked, theAttribute, theFrom, theTo); + setTemporary(aConstraint); + return true; +} +#else bool SketchSolver_Group::moveFeature(FeaturePtr theFeature) { bool isFeatureExists = (myStorage->entity(theFeature).get() != 0); @@ -142,6 +198,7 @@ bool SketchSolver_Group::moveFeature(FeaturePtr theFeature) return true; } +#endif // ============================================================================ // Function: resolveConstraints @@ -357,7 +414,8 @@ void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint) // ============================================================================ void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint) { - myTempConstraints.insert(theConstraint); + if (theConstraint) + myTempConstraints.insert(theConstraint); } // ============================================================================