From: vsv Date: Thu, 14 May 2020 07:41:04 +0000 (+0300) Subject: bos #19068: Unable to quit Sketch because of conflicting constraint X-Git-Tag: V9_5_0b1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fdd802da7683f66ca609cf12b1e11be9642149d6;p=modules%2Fshaper.git bos #19068: Unable to quit Sketch because of conflicting constraint --- diff --git a/src/PartSet/PartSet_OverconstraintListener.cpp b/src/PartSet/PartSet_OverconstraintListener.cpp index 321dc4d78..67dd02e09 100644 --- a/src/PartSet/PartSet_OverconstraintListener.cpp +++ b/src/PartSet/PartSet_OverconstraintListener.cpp @@ -284,13 +284,17 @@ void PartSet_OverconstraintListener::redisplayObjects( static Events_Loop* aLoop = Events_Loop::loop(); static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_VISUAL_ATTRIBUTES); + static Events_ID EVENT_REDISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); std::set::const_iterator anIt = theObjects.begin(), aLast = theObjects.end(); - for (; anIt != aLast; anIt++) - aECreator->sendUpdated(*anIt, EVENT_DISP); - + for (; anIt != aLast; anIt++) { + ObjectPtr aObj = *anIt; + aECreator->sendUpdated(aObj, EVENT_DISP); + aECreator->sendUpdated(aObj, EVENT_REDISP); + } aLoop->flush(EVENT_DISP); + aLoop->flush(EVENT_REDISP); } PartSet_Module* PartSet_OverconstraintListener::module() const diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 342435a2c..9f0571e11 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -1195,8 +1195,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) workshop()->selectionActivate()->updateSelectionFilters(); workshop()->selectionActivate()->updateSelectionModes(); - Events_Loop::loop()->flush(EVENT_DISP); Events_Loop::loop()->flush(EVENT_ATTR); + Events_Loop::loop()->flush(EVENT_DISP); myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch); @@ -2283,22 +2283,23 @@ std::vector PartSet_SketcherMgr::colorOfObject(const ObjectPtr& theObject, PartSet_OverconstraintListener* aOCListener = myModule->overconstraintListener(); std::string aKind = theFeature->getKind(); + if (aOCListener->isConflictingObject(theObject)) { + return Config_PropManager::color("Visualization", "sketch_overconstraint_color"); + } + if (aOCListener->isFullyConstrained()) { + return Config_PropManager::color("Visualization", "sketch_fully_constrained_color"); + } if (isDistanceKind(aKind)) { - if (aOCListener->isConflictingObject(theObject)) - return Config_PropManager::color("Visualization", "sketch_overconstraint_color"); return Config_PropManager::color("Visualization", "sketch_dimension_color"); } + if (aKind == SketchPlugin_ConstraintCoincidence::ID()) + return std::vector(3, 0); + if (isExternal(theFeature)) return Config_PropManager::color("Visualization", "sketch_external_color"); if (isConstruction) return Config_PropManager::color("Visualization", "sketch_auxiliary_color"); - if (aOCListener->isFullyConstrained()) { - return Config_PropManager::color("Visualization", "sketch_fully_constrained_color"); - } - else if (aOCListener->isConflictingObject(theObject)) { - return Config_PropManager::color("Visualization", "sketch_overconstraint_color"); - } return Config_PropManager::color("Visualization", "sketch_entity_color"); } diff --git a/src/SketcherPrs/SketcherPrs_Coincident.cpp b/src/SketcherPrs/SketcherPrs_Coincident.cpp index a21600856..43bac7a56 100644 --- a/src/SketcherPrs/SketcherPrs_Coincident.cpp +++ b/src/SketcherPrs/SketcherPrs_Coincident.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -48,8 +49,9 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Coincident, AIS_InteractiveObject); SketcherPrs_Coincident::SketcherPrs_Coincident(ModelAPI_Feature* theConstraint, SketchPlugin_Sketch* theSketch) : AIS_InteractiveObject(), myConstraint(theConstraint), mySketch(theSketch), - myPoint(gp_Pnt(0.0, 0.0, 0.0)), myIsCustomColor(false) + myPoint(gp_Pnt(0.0, 0.0, 0.0)) { + SetColor(Quantity_NOC_BLACK); } bool SketcherPrs_Coincident::IsReadyToDisplay(ModelAPI_Feature* theConstraint, @@ -137,18 +139,19 @@ void SketcherPrs_Coincident::Compute( } } } - Quantity_Color aExternalColor = aIsEdge ? Quantity_NOC_BLACK : Quantity_NOC_YELLOW; - Quantity_Color aInternalColor = aIsEdge ? Quantity_NOC_YELLOW : Quantity_NOC_BLACK; + Quantity_Color aMainColor; + Color(aMainColor); + Quantity_Color aExternalColor = aIsEdge ? aMainColor : Quantity_NOC_YELLOW; + Quantity_Color aInternalColor = aIsEdge ? Quantity_NOC_YELLOW : aMainColor; int aRatio = SketcherPrs_Tools::pixelRatio(); // Create the presentation as a combination of standard point markers - bool aCustomColor = myIsCustomColor; // The external yellow contour Handle(Graphic3d_AspectMarker3d) aPtA = new Graphic3d_AspectMarker3d(); aPtA->SetType(Aspect_TOM_RING3); aPtA->SetScale(2. * aRatio); - aPtA->SetColor(!aCustomColor ? aExternalColor : myCustomColor); + aPtA->SetColor(aExternalColor); Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation); aGroup->SetPrimitivesAspect(aPtA); @@ -160,7 +163,7 @@ void SketcherPrs_Coincident::Compute( aPtA = new Graphic3d_AspectMarker3d(); aPtA->SetType(aIsEdge ? Aspect_TOM_STAR : Aspect_TOM_RING1); aPtA->SetScale(1. * aRatio); - aPtA->SetColor(!aCustomColor ? aInternalColor : myCustomColor); + aPtA->SetColor(aInternalColor); aGroup->SetPrimitivesAspect(aPtA); aGroup->AddPrimitiveArray (aPntArray); @@ -168,7 +171,7 @@ void SketcherPrs_Coincident::Compute( aPtA = new Graphic3d_AspectMarker3d(); aPtA->SetType(Aspect_TOM_POINT); aPtA->SetScale(5. * aRatio); - aPtA->SetColor(!aCustomColor ? aInternalColor : myCustomColor); + aPtA->SetColor(aInternalColor); aGroup->SetPrimitivesAspect(aPtA); aGroup->AddPrimitiveArray (aPntArray); @@ -183,23 +186,3 @@ void SketcherPrs_Coincident::ComputeSelection(const Handle(SelectMgr_Selection)& { // There is no selection of coincident - a point is selected instead of coincidence } - -void SketcherPrs_Coincident::SetColor(const Quantity_NameOfColor aCol) -{ - SetColor(Quantity_Color(aCol)); -} - -void SketcherPrs_Coincident::SetColor(const Quantity_Color &aCol) -{ - hasOwnColor=Standard_True; -} - -void SketcherPrs_Coincident::SetCustomColor(const std::vector& theColor) -{ - myIsCustomColor = !theColor.empty(); - if (myIsCustomColor) - myCustomColor = Quantity_Color(theColor[0] / 255., theColor[1] / 255., - theColor[2] / 255., Quantity_TOC_RGB); - else - myCustomColor = Quantity_Color(); -} diff --git a/src/SketcherPrs/SketcherPrs_Coincident.h b/src/SketcherPrs/SketcherPrs_Coincident.h index 861da3734..c55f70121 100644 --- a/src/SketcherPrs/SketcherPrs_Coincident.h +++ b/src/SketcherPrs/SketcherPrs_Coincident.h @@ -44,19 +44,6 @@ public: Standard_EXPORT SketcherPrs_Coincident(ModelAPI_Feature* theConstraint, SketchPlugin_Sketch* theSketch); - /// Defines color for the presentation - /// \param aColor a color object - Standard_EXPORT virtual void SetColor(const Quantity_Color& aColor); - - /// Defines color for the presentation - /// \param aColor a color name - Standard_EXPORT virtual void SetColor(const Quantity_NameOfColor aColor); - - /// Set state of the presentation, in case of custom color, the icon of the presentation is - /// visualized in error color. - /// \param theColor a custom color for object presentation - Standard_EXPORT void SetCustomColor(const std::vector& theColor); - /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation /// \param theConstraint a constraint feature /// \param thePlane a coordinate plane of current sketch @@ -84,8 +71,6 @@ private: ModelAPI_Feature* myConstraint; SketchPlugin_Sketch* mySketch; gp_Pnt myPoint; - bool myIsCustomColor; /// state if the presentation is visualized in custom color - Quantity_Color myCustomColor; /// the color of mid ring if there is a conflict }; diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 9dc673f19..365717787 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -160,6 +160,8 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer) aScreen->setViewScale(getViewScale()); } anAIS = aPrs->getAISObject(anAIS); + if (anAIS.get()) + myWorkshop->module()->customizePresentation(theObject, anAIS); } else { anAIS = myWorkshop->module()->createPresentation(theObject); isShading = true;