]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
1. Check the owner is already selected and do not call for it AddOrRemoveSelected,
authornds <natalia.donis@opencascade.com>
Sat, 27 Dec 2014 12:09:12 +0000 (15:09 +0300)
committernds <natalia.donis@opencascade.com>
Sat, 27 Dec 2014 12:09:12 +0000 (15:09 +0300)
2. An attempt to restore selection for the edited attribute. The result is the selection is not restored - to debug it.

src/PartSet/PartSet_SketcherMgr.cpp
src/XGUI/XGUI_SelectionMgr.cpp

index 9871a0e9403d6ca619d1c0e5158d37e777aa09b4..0bfbaa816f885b1c68fa16fa9ae1bb0cb1852b43 100644 (file)
@@ -255,7 +255,14 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     double dX =  aX - myCurX;
     double dY =  aY - myCurY;
 
+    ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+    XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+    XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+    bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
+
     if ((myEditingAttr.size() == 1) && myEditingAttr.first()) {
+      FeaturePtr aSketchFeature = myEditingFeatures.first();
+
       // probably we have prehighlighted point
       AttributePtr aAttr = myEditingAttr.first();
       std::string aAttrId = aAttr->id();
@@ -271,18 +278,20 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
           }
         }
       }
+      // restore the previous selection
+      SelectMgr_IndexedMapOfOwner anOwnersToSelect;
+      std::set<AttributePtr> aSelectedAttributes;
+      aSelectedAttributes.insert(aAttr);
+      getSelectionOwners(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes,
+                         std::set<ResultPtr>(), anOwnersToSelect);
+      aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
+      // restore the previous selection
     } else {
-      ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
-      XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
-      XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
-      bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
-
       foreach(FeaturePtr aFeature, myEditingFeatures) {
         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
         if (aSketchFeature) {
           // save the previous selection
-
           std::set<AttributePtr> aSelectedAttributes;
           std::set<ResultPtr> aSelectedResults;
           getCurrentSelection(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes,
@@ -301,7 +310,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
           aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
           // restore the previous selection
         }
-        ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent, true);
+        ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent);
         Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
       }
       // TODO: set here
@@ -309,9 +318,10 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
       //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 
       //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
-      aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
-      aDisplayer->updateViewer();
     }
+
+    aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
+    aDisplayer->updateViewer();
     myDragDone = true;
     myCurX = aX;
     myCurY = aY;
@@ -550,10 +560,8 @@ void PartSet_SketcherMgr::getSelectionOwners(const ObjectPtr& theObject,
         }
       }
       else if (aShapeType == TopAbs_EDGE) {
-        bool aFound = theSelectedResults.find(aResult) != theSelectedResults.end();
-        int anIndex = anOwnersToSelect.FindIndex(anOwner);
-        if (theSelectedResults.find(aResult) != theSelectedResults.end()/* &&
-            anOwnersToSelect.FindIndex(anOwner) < 0*/)
+        if (theSelectedResults.find(aResult) != theSelectedResults.end() &&
+            anOwnersToSelect.FindIndex(anOwner) <= 0)
           anOwnersToSelect.Add(anOwner);
       }
     }
index 94c8462678eb96a170794f0b2afc83cf2dc4606c..b0d22089f8c3da6c6c7fe48836be2822bbe9225d 100644 (file)
@@ -44,9 +44,16 @@ void XGUI_SelectionMgr::connectViewers()
 void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners,
                                           bool isUpdateViewer)
 {
+  SelectMgr_IndexedMapOfOwner aSelectedOwners;
+  selection()->selectedOwners(aSelectedOwners);
+
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   for  (Standard_Integer i = 1, n = theSelectedOwners.Extent(); i <= n; i++)  {
-    aContext->AddOrRemoveSelected(theSelectedOwners(i), isUpdateViewer);
+    Handle(SelectMgr_EntityOwner) anOwner = theSelectedOwners(i);
+    if (aSelectedOwners.FindIndex(anOwner) > 0)
+      continue;
+
+    aContext->AddOrRemoveSelected(anOwner, isUpdateViewer);
   }
 }