From 71fcffeb13911c63ec2afb75f232c99dd74defd1 Mon Sep 17 00:00:00 2001 From: nds Date: Sat, 27 Dec 2014 15:09:12 +0300 Subject: [PATCH] 1. Check the owner is already selected and do not call for it AddOrRemoveSelected, 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 | 34 ++++++++++++++++++----------- src/XGUI/XGUI_SelectionMgr.cpp | 9 +++++++- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 9871a0e94..0bfbaa816 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -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(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 aSelectedAttributes; + aSelectedAttributes.insert(aAttr); + getSelectionOwners(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes, + std::set(), anOwnersToSelect); + aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false); + // restore the previous selection } else { - ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); - XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); - XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); - bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false); - foreach(FeaturePtr aFeature, myEditingFeatures) { std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(aFeature); if (aSketchFeature) { // save the previous selection - std::set aSelectedAttributes; std::set 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); } } diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index 94c846267..b0d22089f 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -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); } } -- 2.39.2