From: nds Date: Wed, 29 Mar 2017 13:07:54 +0000 (+0300) Subject: Issue #2029 Change the color of the Sketch when fully constrained X-Git-Tag: V_2.7.0~147 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=676faa067d071656365dcfdfd501c73ac26c7b7f;p=modules%2Fshaper.git Issue #2029 Change the color of the Sketch when fully constrained --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index fb64f4a7f..139801633 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1014,9 +1014,10 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the if (!anObject) return aCustomized; + std::vector aColor; + bool aCustomColor = myOverconstraintListener->hasCustomColor(anObject, aColor); + if (!theResult.get()) { - std::vector aColor; - bool isConflicting = myOverconstraintListener->hasCustomColor(anObject, aColor); // customize sketch symbol presentation if (thePrs.get()) { Handle(AIS_InteractiveObject) anAISIO = thePrs->impl(); @@ -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]); diff --git a/src/PartSet/PartSet_OverconstraintListener.cpp b/src/PartSet/PartSet_OverconstraintListener.cpp index fa20c5490..40ec725ce 100755 --- a/src/PartSet/PartSet_OverconstraintListener.cpp +++ b/src/PartSet/PartSet_OverconstraintListener.cpp @@ -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 aModifiedObjects; + PartSet_Module* aModule = dynamic_cast(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 aResults = aFeature->results(); + for (std::list::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& theConflictingObjects) { std::set aModifiedObjects; - //std::vector aColor; - //getConflictingColor(aColor); // set error state for new objects and append them in the internal map of objects std::set::const_iterator