Salome HOME
Issue #348 Validate sketch is disabled when point coordinates are set manually
[modules/shaper.git] / src / XGUI / XGUI_Displayer.cpp
index 22b76ad2eafae3bb03d009aaf614b84982cedaba..8dd2d2e25f8388fe9bfa1a9a30b20ec45e2a5d23 100644 (file)
@@ -208,6 +208,25 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
     Handle(AIS_InteractiveContext) aContext = AISContext();
     if (aContext.IsNull())
       return;
+    // Check that the visualized shape is the same and the redisplay is not necessary
+    // Redisplay of AIS object leads to this object selection compute and the selection 
+    // in the browser is lost
+    // become
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult.get() != NULL) {
+      Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
+      if (!aShapePrs.IsNull()) {
+        std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
+        if (aShapePtr.get()) {
+          const TopoDS_Shape& aShape = aShapePrs->Shape();
+          std::shared_ptr<GeomAPI_Shape> anAISShapePtr(new GeomAPI_Shape());
+          anAISShapePtr->setImpl(new TopoDS_Shape(aShape));
+
+          if (aShapePtr->isEqual(anAISShapePtr))
+            return;
+        }
+      }
+    }
     aContext->Redisplay(aAISIO, false);
     if (isUpdateViewer)
       updateViewer();
@@ -299,7 +318,7 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes)
   //myUseExternalObjects = true;
 
   AIS_ListOfInteractive aPrsList;
-  displayedObjects(aContext, aPrsList);
+  ::displayedObjects(aContext, aPrsList);
 
   Handle(AIS_Trihedron) aTrihedron;
   AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
@@ -339,7 +358,7 @@ void XGUI_Displayer::deactivateObjects()
 
   //aContext->NotUseDisplayedObjects();
   AIS_ListOfInteractive aPrsList;
-  displayedObjects(aContext, aPrsList);
+  ::displayedObjects(aContext, aPrsList);
 
   AIS_ListIteratorOfListOfInteractive aLIt;
   //Handle(AIS_Trihedron) aTrihedron;