Salome HOME
Sending by sketcher the list of constraints which are not conflicting already.
authorazv <azv@opencascade.com>
Tue, 9 Feb 2016 11:12:42 +0000 (14:12 +0300)
committerdbv <dbv@opencascade.com>
Tue, 16 Feb 2016 14:04:40 +0000 (17:04 +0300)
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h

index d6c8b0218cd86e6547b1cc33d9cad5c8e98115fd..204410560c943f4996ea32b18f7441457456eb9a 100644 (file)
@@ -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<ObjectPtr> 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<ObjectPtr>::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;
         }
       }
index 6d7dff33926702865e2210582e7686e7cccfe48f..1586f6818924a2710ddd7ef7aba0e658bc474a74 100644 (file)
@@ -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<ObjectPtr>      myConflictingConstraints; ///< List of conflicting constraints
 };
 
 #endif