Salome HOME
Fix for the issue #1695 : don't display circle on start point creation in arc by...
[modules/shaper.git] / src / XGUI / XGUI_Displayer.cpp
index e2c7460f6749ec23856c2614078ee7a50f662097..24e7b9eb6f740d8dce04b28d42172ace6b21faea 100644 (file)
@@ -154,15 +154,15 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
       anAIS = aPrs->getAISObject(anAIS);
       if (anAIS.get()) {
         // correct deviation coefficient for 
-        Handle(AIS_InteractiveObject) anAISPrs = anAIS->impl<Handle(AIS_InteractiveObject)>();
+        /*Handle(AIS_InteractiveObject) anAISPrs = anAIS->impl<Handle(AIS_InteractiveObject)>();
         if (!anAISPrs.IsNull()) {
           Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
           if (!aShapePrs.IsNull()) {
             TopoDS_Shape aShape = aShapePrs->Shape();
             if (!aShape.IsNull())
-              ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, anAISPrs->Attributes());
+              //ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, anAISPrs->Attributes());
           }
-        }
+        }*/
       }
     } else {
       ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
@@ -670,12 +670,12 @@ void XGUI_Displayer::setSelected(const  QList<ModuleBase_ViewerPrsPtr>& theValue
     updateViewer();
 }
 
-void XGUI_Displayer::clearSelected()
+void XGUI_Displayer::clearSelected(const bool theUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (!aContext.IsNull()) {
     aContext->UnhilightCurrents(false);
-    aContext->ClearSelected();
+    aContext->ClearSelected(theUpdateViewer);
   }
 }
 
@@ -907,6 +907,11 @@ void XGUI_Displayer::activateAIS(const Handle(AIS_InteractiveObject)& theIO,
                                  const int theMode, const bool theUpdateViewer) const
 {
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  if (!theIO.IsNull() && theIO == getTrihedron()) {
+    if (theMode != AIS_Shape::SelectionType(TopAbs_EDGE) &&
+        theMode != AIS_Shape::SelectionType(TopAbs_VERTEX))
+      return;
+  }
   if (!aContext.IsNull()) {
     if (myWorkshop->module()) {
       int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode);
@@ -1407,8 +1412,19 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th
   aLContext->MainSelector()->ActiveOwners(anActiveOwners);
   NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
   Handle(SelectMgr_EntityOwner) anOwner;
+
+  /// It is very important to check that the owner is processed only once and has a map of
+  /// processed owners because SetSelected works as a switch.
+  /// If count of calls setSelectec is even, the object stays in the previous state
+  /// (selected, deselected)
+  /// OCCT: to write about the problem that active owners method returns one owner several times
+  QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
   for (; anOwnersIt.More(); anOwnersIt.Next()) {
     anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
+    if (aSelectedIds.contains((long)anOwner.Access()))
+      continue;
+    aSelectedIds.append((long)anOwner.Access());
+
     Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
     if (!BROwnr.IsNull() && BROwnr->HasShape()) {
       const TopoDS_Shape& aShape = BROwnr->Shape();