From: vsv Date: Wed, 15 Apr 2015 13:53:35 +0000 (+0300) Subject: Optimize Delete command item X-Git-Tag: V_1.1.0~23^2~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2156bcfa18fd2ceeb4b427fc50604231775e3f3e;p=modules%2Fshaper.git Optimize Delete command item --- diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index fa4426281..73e5e1214 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -149,35 +149,26 @@ bool PartSet_MenuMgr::addViewerItems(QMenu* theMenu, const QMapworkshop()->selection(); - NCollection_List aShapeList; - std::list aObjectsList; - aSelection->selectedShapes(aShapeList, aObjectsList); bool aIsDetach = false; - - // Check that selected shape is not attribute - // if at least a one shape is attribute then we can not add auxiliary item bool hasAttribute = false; - if (aShapeList.Extent() > 0) { - NCollection_List::Iterator aIt(aShapeList); - std::list::const_iterator aItObj; - TopoDS_Shape aShape; - ObjectPtr aObj; - ResultPtr aResult; - for (aItObj = aObjectsList.cbegin(); aIt.More(); aIt.Next(), aItObj++) { - aShape = aIt.Value(); - aObj = (*aItObj); - aResult = std::dynamic_pointer_cast(aObj); - if (aResult.get() != NULL) { - if (!aShape.IsEqual(aResult->shape()->impl())) { - hasAttribute = true; - break; - } - } + bool hasFeature = false; + + QList aPrsList = aSelection->getSelected(); + TopoDS_Shape aShape; + ResultPtr aResult; + foreach(ModuleBase_ViewerPrs aPrs, aPrsList) { + aResult = std::dynamic_pointer_cast(aPrs.object()); + if (aResult.get() != NULL) { + aShape = aPrs.shape(); + if (aShape.IsEqual(aResult->shape()->impl())) + hasFeature = true; + else + hasAttribute = true; } } - if (aShapeList.Extent() == 1) { - TopoDS_Shape aShape = aShapeList.First(); + if (aPrsList.size() == 1) { + TopoDS_Shape aShape = aPrsList.first().shape(); if (aShape.ShapeType() == TopAbs_VERTEX) { // Find 2d coordinates FeaturePtr aSketchFea = myModule->sketchMgr()->activeSketch(); @@ -187,7 +178,7 @@ bool PartSet_MenuMgr::addViewerItems(QMenu* theMenu, const QMap aSelPnt = PartSet_Tools::convertTo2D(aSketchFea, aPnt3d); // Find coincident in these coordinates - ObjectPtr aObj = aObjectsList.front(); + ObjectPtr aObj = aPrsList.first().object(); FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); const std::set& aRefsList = aFeature->data()->refsToMe(); std::set::const_iterator aIt; @@ -226,18 +217,8 @@ bool PartSet_MenuMgr::addViewerItems(QMenu* theMenu, const QMapselectedPresentations(); - if ((!aIsDetach) && (aObjects.size() > 0)) { - bool hasFeature = false; - FeaturePtr aFeature; - foreach (ObjectPtr aObject, aObjects) { - aFeature = ModelAPI_Feature::feature(aObject); - if (aFeature.get() != NULL) { - hasFeature = true; - } - } - if (hasFeature && (!hasAttribute)) - theMenu->addAction(theStdActions["DELETE_CMD"]); + if ((!aIsDetach) && hasFeature) { + theMenu->addAction(theStdActions["DELETE_CMD"]); } if (hasAttribute) return true;