]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3262: Undo automatic constraint even several conflicting objects were sent
authorvsv <vsv@opencascade.com>
Wed, 24 Jun 2020 09:31:25 +0000 (12:31 +0300)
committervsv <vsv@opencascade.com>
Wed, 24 Jun 2020 09:31:38 +0000 (12:31 +0300)
src/GeomAPI/GeomAPI_AISObject.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OverconstraintListener.cpp

index ac3a6ff4d2f2341954e610a386b62647ed0371f6..ae3ebdab0f2d916455f243dfa67714f05ad2c0da 100644 (file)
@@ -370,15 +370,19 @@ bool GeomAPI_AISObject::setColor(int theR, int theG, int theB)
   if (aColor.IsEqual(aCurrentColor))
     return false;
 
+  Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
   Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS);
   if (!aDimAIS.IsNull()) {
     aDimAIS->DimensionAspect()->SetCommonColor(aColor);
+    if (!aContext.IsNull())
+      aContext->Redisplay(aDimAIS, false);
+  }
+  else {
+    if (!aContext.IsNull())
+      aContext->SetColor(anAIS, aColor, false);
+    else
+      anAIS->SetColor(aColor);
   }
-  Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
-  if (!aContext.IsNull())
-    aContext->SetColor(anAIS, aColor, false);
-  else
-    anAIS->SetColor(aColor);
   return true;
 }
 
index 7aaeed01ac9bf5c6e1fce13962a0d8242668739c..eeb18584f342dc5f8d26077e92f3bf73e85267d8 100644 (file)
@@ -1859,29 +1859,25 @@ void PartSet_Module::enableCustomModes() {
 void PartSet_Module::onConflictingConstraints()
 {
   const std::set<ObjectPtr>& aConstraints = myOverconstraintListener->conflictingObjects();
-  if (aConstraints.size() == 1) {
-    QObjectPtrList aObjectsList;
-    std::set<ObjectPtr>::const_iterator aIt;
-    for (aIt = aConstraints.cbegin(); aIt != aConstraints.cend(); aIt++) {
-      if (mySketchReentrantMgr->isLastAutoConstraint(*aIt))
-        aObjectsList.append(*aIt);
-    }
-    if (aObjectsList.size() > 0) {
-      XGUI_Workshop* aWorkshop = getWorkshop();
-      QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
-      ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription);
-      XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
-
-      ModuleBase_Operation* anOp = anOpMgr->currentOperation();
-      if (sketchMgr()->isNestedSketchOperation(anOp))
-        anOp->abort();
+  QObjectPtrList aObjectsList;
+  std::set<ObjectPtr>::const_iterator aIt;
+  for (aIt = aConstraints.cbegin(); aIt != aConstraints.cend(); aIt++) {
+    if (mySketchReentrantMgr->isLastAutoConstraint(*aIt))
+      aObjectsList.append(*aIt);
+  }
+  if (aObjectsList.size() > 0) {
+    XGUI_Workshop* aWorkshop = getWorkshop();
+    QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
+    ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription);
+    XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
 
-      anOpMgr->startOperation(anOpAction);
-      aWorkshop->deleteFeatures(aObjectsList);
-      anOpMgr->commitOperation();
-      ModuleBase_Tools::flushUpdated(sketchMgr()->activeSketch());
+    ModuleBase_Operation* anOp = anOpMgr->currentOperation();
+    if (sketchMgr()->isNestedSketchOperation(anOp))
+      anOp->abort();
 
-      myWorkshop->viewer()->update();
-    }
+    anOpMgr->startOperation(anOpAction);
+    aWorkshop->deleteFeatures(aObjectsList);
+    anOpMgr->commitOperation();
+    ModuleBase_Tools::flushUpdated(sketchMgr()->activeSketch());
   }
 }
index a0eff2c34b011e8f26821d22bb0df2b9553379b9..f94b112136735e710515eee678d556f5231a06cd 100644 (file)
@@ -245,30 +245,32 @@ bool PartSet_OverconstraintListener::appendConflictingObjects(
   // set error state for new objects and append them in the internal map of objects
   std::set<ObjectPtr>::const_iterator
     anIt = theConflictingObjects.begin(), aLast = theConflictingObjects.end();
+  FeaturePtr aFeature;
+  bool isHVConstraint = false;
   for (; anIt != aLast; anIt++) {
     ObjectPtr anObject = *anIt;
     if (myConflictingObjects.find(anObject) == myConflictingObjects.end()) { // it is not found
       aModifiedObjects.insert(anObject);
       myConflictingObjects.insert(anObject);
     }
+    if (!isHVConstraint) {
+      aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+      if (aFeature) {
+        std::string aType = aFeature->getKind();
+        isHVConstraint = (aType == SketchPlugin_ConstraintHorizontal::ID()) ||
+          (aType == SketchPlugin_ConstraintVertical::ID());
+      }
+    }
   }
   bool isUpdated = !aModifiedObjects.empty();
   if (isUpdated)
     redisplayObjects(aModifiedObjects);
 
-  if (myConflictingObjects.size() == 1) {
-    // If the conflicting object is an automatic constraint caused the conflict
-    // then it has to be deleted
-    ObjectPtr aObj = *theConflictingObjects.cbegin();
-    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
-    if (aFeature) {
-      std::string aType = aFeature->getKind();
-      if ((aType == SketchPlugin_ConstraintHorizontal::ID()) ||
-        (aType == SketchPlugin_ConstraintVertical::ID())) {
-        PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
-        QTimer::singleShot(5, aModule, SLOT(onConflictingConstraints()));
-      }
-    }
+  // If the conflicting object is an automatic constraint caused the conflict
+  // then it has to be deleted
+  if (isHVConstraint) {
+    PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+    QTimer::singleShot(5, aModule, SLOT(onConflictingConstraints()));
   }
 
   return isUpdated;