From: azv Date: Thu, 24 Dec 2015 10:46:52 +0000 (+0300) Subject: Implement extended status of previously solved/failed set of constraints X-Git-Tag: V_2.1.0~71 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=68cbc95e5d425d4e706307a069c8d58506cb0527;p=modules%2Fshaper.git Implement extended status of previously solved/failed set of constraints --- 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 };