From 68cbc95e5d425d4e706307a069c8d58506cb0527 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 24 Dec 2015 13:46:52 +0300 Subject: [PATCH] Implement extended status of previously solved/failed set of constraints --- src/SketchSolver/SketchSolver_Group.cpp | 14 +++++++------- src/SketchSolver/SketchSolver_Group.h | 2 +- src/SketchSolver/SketchSolver_ISolver.h | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 11f25e8d0..7ef43366f 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -77,7 +77,7 @@ static void sendMessage(const char* theMessageName) SketchSolver_Group::SketchSolver_Group( std::shared_ptr theWorkplane) : myID(GroupIndexer::NEW_GROUP()), - myPrevSolved(true) + myPrevResult(STATUS_UNKNOWN) { // Initialize workplane myWorkplaneID = EID_UNKNOWN; @@ -333,31 +333,31 @@ bool SketchSolver_Group::resolveConstraints() } catch (...) { // Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this); getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::SOLVESPACE_CRASH()); - if (myPrevSolved) { + if (myPrevResult == STATUS_OK || myPrevResult == STATUS_UNKNOWN) { // the error message should be changed before sending the message sendMessage(EVENT_SOLVER_FAILED); - myPrevSolved = false; + myPrevResult = STATUS_FAILED; } mySketchSolver->undo(); return false; } if (aResult == STATUS_OK || aResult == STATUS_EMPTYSET) { // solution succeeded, store results into correspondent attributes myStorage->refresh(); - if (!myPrevSolved) { + 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); - myPrevSolved = true; + myPrevResult = STATUS_OK; } } else { mySketchSolver->undo(); if (!myConstraints.empty()) { // Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this); getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::CONSTRAINTS()); - if (myPrevSolved) { + if (myPrevResult != aResult || myPrevResult == STATUS_UNKNOWN) { // the error message should be changed before sending the message sendMessage(EVENT_SOLVER_FAILED); - myPrevSolved = false; + myPrevResult = aResult; } } } diff --git a/src/SketchSolver/SketchSolver_Group.h b/src/SketchSolver/SketchSolver_Group.h index 4eb67e619..f1520d3bd 100644 --- a/src/SketchSolver/SketchSolver_Group.h +++ b/src/SketchSolver/SketchSolver_Group.h @@ -168,7 +168,7 @@ private: SolverPtr mySketchSolver; ///< Solver for set of equations obtained by constraints - bool myPrevSolved; ///< Indicates that previous solving was done correctly + SketchSolver_SolveStatus myPrevResult; ///< Result of previous solution of the set of constraints }; #endif diff --git a/src/SketchSolver/SketchSolver_ISolver.h b/src/SketchSolver/SketchSolver_ISolver.h index 19c2c5e22..a23807ee3 100644 --- a/src/SketchSolver/SketchSolver_ISolver.h +++ b/src/SketchSolver/SketchSolver_ISolver.h @@ -16,7 +16,8 @@ enum SketchSolver_SolveStatus { STATUS_OK, STATUS_INCONSISTENT, STATUS_EMPTYSET, - STATUS_FAILED // set if no one other status is applicable + STATUS_FAILED, // set if no one other status is applicable + STATUS_UNKNOWN // set for newly created groups }; -- 2.30.2