From: vsv Date: Wed, 24 Jun 2020 09:31:25 +0000 (+0300) Subject: Issue #3262: Undo automatic constraint even several conflicting objects were sent X-Git-Tag: V9_6_0a1~60^2~46 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4f2b6051720d6f2c52d19a9313ce9885042d6b2a;p=modules%2Fshaper.git Issue #3262: Undo automatic constraint even several conflicting objects were sent --- diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index ac3a6ff4d..ae3ebdab0 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -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; } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 7aaeed01a..eeb18584f 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1859,29 +1859,25 @@ void PartSet_Module::enableCustomModes() { void PartSet_Module::onConflictingConstraints() { const std::set& aConstraints = myOverconstraintListener->conflictingObjects(); - if (aConstraints.size() == 1) { - QObjectPtrList aObjectsList; - std::set::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::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()); } } diff --git a/src/PartSet/PartSet_OverconstraintListener.cpp b/src/PartSet/PartSet_OverconstraintListener.cpp index a0eff2c34..f94b11213 100644 --- a/src/PartSet/PartSet_OverconstraintListener.cpp +++ b/src/PartSet/PartSet_OverconstraintListener.cpp @@ -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::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(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(aObj); - if (aFeature) { - std::string aType = aFeature->getKind(); - if ((aType == SketchPlugin_ConstraintHorizontal::ID()) || - (aType == SketchPlugin_ConstraintVertical::ID())) { - PartSet_Module* aModule = dynamic_cast(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(myWorkshop->module()); + QTimer::singleShot(5, aModule, SLOT(onConflictingConstraints())); } return isUpdated;