]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
bos #19068: Unable to quit Sketch because of conflicting constraint
authorvsv <vsv@opencascade.com>
Thu, 14 May 2020 07:41:04 +0000 (10:41 +0300)
committervsv <vsv@opencascade.com>
Thu, 14 May 2020 07:41:04 +0000 (10:41 +0300)
src/PartSet/PartSet_OverconstraintListener.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/SketcherPrs/SketcherPrs_Coincident.cpp
src/SketcherPrs/SketcherPrs_Coincident.h
src/XGUI/XGUI_Displayer.cpp

index 321dc4d78771f2b17b76fcbb774a93f7faed1c91..67dd02e0940d3e62654385d749e536b650eb4e3e 100644 (file)
@@ -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<ObjectPtr>::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
index 342435a2c91da47cd76f759c52b8a8b5657f9def..9f0571e11f828161a5f09e639ad0691128a545f3 100644 (file)
@@ -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<int> 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<int>(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");
 }
 
index a216008562a0e602c56eeadbfd659c57d3e2764e..43bac7a5613923312f06f72679f511912d3824c3 100644 (file)
@@ -34,6 +34,7 @@
 #include <SketchPlugin_Constraint.h>
 #include <SketchPlugin_ConstraintCoincidence.h>
 
+#include <AIS_InteractiveContext.hxx>
 #include <Graphic3d_AspectMarker3d.hxx>
 #include <Graphic3d_ArrayOfPoints.hxx>
 #include <Prs3d_PointAspect.hxx>
@@ -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<int>& 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();
-}
index 861da3734a132eaf0827fa68c311137b82d5a190..c55f7012103aa01007afbc3228d55c794b4cf19e 100644 (file)
@@ -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<int>& 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
 };
 
 
index 9dc673f19d5d2661c8e1e12d4251e5e8ec6fa189..365717787f32673d3354683ad92582762cfb9546 100644 (file)
@@ -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;