From c2a90cc3dc7275d22f1ccc9ac600543e295af437 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 9 Feb 2016 14:12:42 +0300 Subject: [PATCH] Sending by sketcher the list of constraints which are not conflicting already. --- src/SketchSolver/SketchSolver_Group.cpp | 24 ++++++++++++++++++++---- src/SketchSolver/SketchSolver_Group.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index d6c8b0218..204410560 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -98,6 +98,11 @@ SketchSolver_Group::~SketchSolver_Group() { myConstraints.clear(); GroupIndexer::REMOVE_GROUP(myID); + // send the message that there is no more conflicting constraints + if (!myConflictingConstraints.empty()) { + sendMessage(EVENT_SOLVER_REPAIRED, myConflictingConstraints); + myConflictingConstraints.clear(); + } } // ============================================================================ @@ -345,20 +350,31 @@ bool SketchSolver_Group::resolveConstraints() if (myPrevResult != STATUS_OK || myPrevResult == STATUS_UNKNOWN) { getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(""); // the error message should be changed before sending the message - sendMessage(EVENT_SOLVER_REPAIRED); + sendMessage(EVENT_SOLVER_REPAIRED, myConflictingConstraints); + myConflictingConstraints.clear(); myPrevResult = STATUS_OK; } } else { mySketchSolver->undo(); if (!myConstraints.empty()) { -// Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this); + // the error message should be changed before sending the message getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::CONSTRAINTS()); if (myPrevResult != aResult || myPrevResult == STATUS_UNKNOWN) { // Obtain list of conflicting constraints std::set aConflicting = myStorage->getConflictingConstraints(mySketchSolver); - // the error message should be changed before sending the message - sendMessage(EVENT_SOLVER_FAILED, aConflicting); + if (myConflictingConstraints.empty()) + sendMessage(EVENT_SOLVER_FAILED, aConflicting); + else { + std::set::iterator anIt = aConflicting.begin(); + for (; anIt != aConflicting.end(); ++anIt) + myConflictingConstraints.erase(*anIt); + if (!myConflictingConstraints.empty()) { + // some constraints does not conflict, send corresponding message + sendMessage(EVENT_SOLVER_REPAIRED, myConflictingConstraints); + } + } + myConflictingConstraints = aConflicting; myPrevResult = aResult; } } diff --git a/src/SketchSolver/SketchSolver_Group.h b/src/SketchSolver/SketchSolver_Group.h index 6d7dff339..1586f6818 100644 --- a/src/SketchSolver/SketchSolver_Group.h +++ b/src/SketchSolver/SketchSolver_Group.h @@ -162,6 +162,7 @@ private: SolverPtr mySketchSolver; ///< Solver for set of equations obtained by constraints SketchSolver_SolveStatus myPrevResult; ///< Result of previous solution of the set of constraints + std::set myConflictingConstraints; ///< List of conflicting constraints }; #endif -- 2.39.2