From fc89212acbb2a0b4bdaaad10708b94b9797d1a1f Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 20 Mar 2019 15:22:54 +0300 Subject: [PATCH] Issue #2889:Multi-selection of features in Object Browser --- src/ModuleBase/ModuleBase_WidgetValidated.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 9c00ba201..937464e3c 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -116,7 +116,8 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr& myPresentedObject = aResult; } else { - FeaturePtr aFeature = ModelAPI_Feature::feature(thePrs->object()); + //FeaturePtr aFeature = ModelAPI_Feature::feature(thePrs->object()); + FeaturePtr aFeature = std::dynamic_pointer_cast(thePrs->object()); if (aFeature.get()) { // Use feature as a reference to all its results myPresentedObject = aFeature; @@ -148,8 +149,11 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr& GeomShapePtr aShapePtr = ModelAPI_Tools::shape(aResult); if (aShapePtr.get()) { const TopoDS_Shape aTDShape = aShapePtr->impl(); - Handle(AIS_InteractiveObject) anIO = myWorkshop->selection()->getIO(thePrs); - anOwner = new StdSelect_BRepOwner(aTDShape, anIO); + AISObjectPtr aIOPtr = myWorkshop->findPresentation(aResult); + if (aIOPtr.get()) { + Handle(AIS_InteractiveObject) anIO = aIOPtr->impl(); + anOwner = new StdSelect_BRepOwner(aTDShape, anIO); + } } } aValid = !anOwner.IsNull(); // only results with a shape can be filtered @@ -439,12 +443,9 @@ QList ModuleBase_WidgetValidated::getFilteredSelected() void ModuleBase_WidgetValidated::filterPresentations(QList& theValues) { QList aValidatedValues; - - QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); - bool isDone = false; - for (; anIt != aLast; anIt++) { - if (isValidInFilters(*anIt)) - aValidatedValues.append(*anIt); + foreach(ModuleBase_ViewerPrsPtr aPrs, theValues) { + if (isValidInFilters(aPrs)) + aValidatedValues.append(aPrs); } if (aValidatedValues.size() != theValues.size()) { theValues.clear(); -- 2.39.2