]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2029 Change the color of the Sketch when fully constrained
authornds <nds@opencascade.com>
Wed, 29 Mar 2017 13:07:54 +0000 (16:07 +0300)
committernds <nds@opencascade.com>
Wed, 29 Mar 2017 13:08:40 +0000 (16:08 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OverconstraintListener.cpp

index fb64f4a7fcd61e0012af83c3a617150591c6fa91..13980163387fb97fff304c441ef890e4ab50e620 100755 (executable)
@@ -1014,9 +1014,10 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the
   if (!anObject)
     return aCustomized;
 
+  std::vector<int> aColor;
+  bool aCustomColor = myOverconstraintListener->hasCustomColor(anObject, aColor);
+
   if (!theResult.get()) {
-    std::vector<int> aColor;
-    bool isConflicting = myOverconstraintListener->hasCustomColor(anObject, aColor);
     // customize sketch symbol presentation
     if (thePrs.get()) {
       Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
@@ -1038,7 +1039,7 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the
     }
     // customize sketch dimension constraint presentation
     if (!aCustomized) {
-      if (!isConflicting)
+      if (!aCustomColor)
         XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
       if (!aColor.empty()) {
         aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
index fa20c54908f0f3bc9a5404fd4f5a52af9393662d..40ec725ce0d601393503e8465b63552ff15ec6ab 100755 (executable)
@@ -29,7 +29,7 @@
 //#define DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
 
 PartSet_OverconstraintListener::PartSet_OverconstraintListener(ModuleBase_IWorkshop* theWorkshop)
-: myWorkshop(theWorkshop)
+: myWorkshop(theWorkshop), myIsFullyConstrained(false)
 {
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_FAILED));
@@ -110,7 +110,24 @@ void PartSet_OverconstraintListener::processEvent(
   }
   else if (anEventID == Events_Loop::eventByName(EVENT_SKETCH_UNDER_CONSTRAINED) ||
            anEventID == Events_Loop::eventByName(EVENT_SKETCH_FULLY_CONSTRAINED)) {
+    bool aPrevFullyConstrained = myIsFullyConstrained;
     myIsFullyConstrained = anEventID == Events_Loop::eventByName(EVENT_SKETCH_FULLY_CONSTRAINED);
+
+    if (aPrevFullyConstrained != myIsFullyConstrained) {
+      std::set<ObjectPtr> aModifiedObjects;
+      PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+      CompositeFeaturePtr aSketch = aModule->sketchMgr()->activeSketch();
+      for (int i = 0; i < aSketch->numberOfSubs(); i++) {
+        FeaturePtr aFeature = aSketch->subFeature(i);
+        aModifiedObjects.insert(aFeature); // is necessary to redisplay presentations
+        std::list<ResultPtr> aResults = aFeature->results();
+        for (std::list<ResultPtr>::const_iterator aIt = aResults.begin();
+             aIt != aResults.end(); ++aIt) {
+          aModifiedObjects.insert(*aIt);
+        }
+      }
+      redisplayObjects(aModifiedObjects);
+    }
   }
 
 #ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
@@ -124,8 +141,6 @@ bool PartSet_OverconstraintListener::appendConflictingObjects(
                                                const std::set<ObjectPtr>& theConflictingObjects)
 {
   std::set<ObjectPtr> aModifiedObjects;
-  //std::vector<int> aColor;
-  //getConflictingColor(aColor);
 
   // set error state for new objects and append them in the internal map of objects
   std::set<ObjectPtr>::const_iterator