From: nds Date: Sat, 27 Dec 2014 10:50:37 +0000 (+0300) Subject: The local selection restore for a feature vertex (it is checked on the line feature) X-Git-Tag: V_0.7.0_rc1~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e1e3a021354eac8f9a74b8a5fa363cec81f2f62c;p=modules%2Fshaper.git The local selection restore for a feature vertex (it is checked on the line feature) Restore the selection for the results also. --- diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index a7c217a82..9871a0e94 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -283,8 +283,8 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve if (aSketchFeature) { // save the previous selection - std::list aSelectedAttributes; - std::list aSelectedResults; + std::set aSelectedAttributes; + std::set aSelectedResults; getCurrentSelection(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes, aSelectedResults); // save the previous selection: end @@ -461,8 +461,8 @@ void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr& th void PartSet_SketcherMgr::getCurrentSelection(const ObjectPtr& theObject, const FeaturePtr& theSketch, ModuleBase_IWorkshop* theWorkshop, - std::list& theSelectedAttributes, - std::list& theSelectedResults) + std::set& theSelectedAttributes, + std::set& theSelectedResults) { FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); if (aFeature.get() == NULL) @@ -473,13 +473,11 @@ void PartSet_SketcherMgr::getCurrentSelection(const ObjectPtr& theObject, XGUI_ModuleConnector* aConnector = dynamic_cast(theWorkshop); XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); - // TODO: check all results and IPresentable feature std::list aResults = aFeature->results(); std::list::const_iterator aIt; for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { ResultPtr aResult = *aIt; - AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult); if (aAISObj.get() == NULL) continue; @@ -490,12 +488,8 @@ void PartSet_SketcherMgr::getCurrentSelection(const ObjectPtr& theObject, aContext->SelectedOwner()); if (aBRepOwner.IsNull()) continue; - Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast( aBRepOwner->Selectable()); - if (anIO != anAISIO) - continue; - if (aBRepOwner->HasShape()) { const TopoDS_Shape& aShape = aBRepOwner->Shape(); TopAbs_ShapeEnum aShapeType = aShape.ShapeType(); @@ -503,10 +497,11 @@ void PartSet_SketcherMgr::getCurrentSelection(const ObjectPtr& theObject, AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theObject, aShape, theSketch); if (aPntAttr.get() != NULL) - theSelectedAttributes.push_back(aPntAttr); + theSelectedAttributes.insert(aPntAttr); } - else if (aShapeType == TopAbs_EDGE) { - theSelectedResults.push_back(aResult); + else if (aShapeType == TopAbs_EDGE && + theSelectedResults.find(aResult) == theSelectedResults.end()) { + theSelectedResults.insert(aResult); } } } @@ -516,8 +511,8 @@ void PartSet_SketcherMgr::getCurrentSelection(const ObjectPtr& theObject, void PartSet_SketcherMgr::getSelectionOwners(const ObjectPtr& theObject, const FeaturePtr& theSketch, ModuleBase_IWorkshop* theWorkshop, - const std::list& theSelectedAttributes, - const std::list& theSelectedResults, + const std::set& theSelectedAttributes, + const std::set& theSelectedResults, SelectMgr_IndexedMapOfOwner& anOwnersToSelect) { FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); @@ -529,16 +524,17 @@ void PartSet_SketcherMgr::getSelectionOwners(const ObjectPtr& theObject, XGUI_ModuleConnector* aConnector = dynamic_cast(theWorkshop); XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); - // TODO: check all results and IPresentable feature - ResultPtr aResult = aFeature->firstResult(); - - AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult); - - if (aAISObj.get() != NULL) { + std::list aResults = aFeature->results(); + std::list::const_iterator aIt; + for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) + { + ResultPtr aResult = *aIt; + AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult); + if (aAISObj.get() == NULL) + continue; Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl(); - SelectMgr_IndexedMapOfOwner aSelectedOwners; - + SelectMgr_IndexedMapOfOwner aSelectedOwners; aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners); for ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) { Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i)); @@ -548,17 +544,18 @@ void PartSet_SketcherMgr::getSelectionOwners(const ObjectPtr& theObject, TopAbs_ShapeEnum aShapeType = aShape.ShapeType(); if (aShapeType == TopAbs_VERTEX) { AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(aFeature, aShape, theSketch); - if (aPntAttr.get() != NULL) { - std::list::const_iterator anIt = theSelectedAttributes.begin(), - aLast = theSelectedAttributes.end(); - for (; anIt != aLast; anIt++) { - AttributePtr anAttrIt = *anIt; - if (anAttrIt.get() == aPntAttr.get()) { - anOwnersToSelect.Add(anOwner); - } - } + if (aPntAttr.get() != NULL && + theSelectedAttributes.find(aPntAttr) != theSelectedAttributes.end()) { + anOwnersToSelect.Add(anOwner); } } + 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*/) + anOwnersToSelect.Add(anOwner); + } } } }