From 516b77e267ed9c0ba05c1efadec0cdab5b55cac7 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 18 Mar 2015 14:09:12 +0300 Subject: [PATCH] Multi-selection widget to be used in the extrusion feature. --- src/ModuleBase/ModuleBase_ResultPrs.h | 3 + .../ModuleBase_WidgetMultiSelector.cpp | 57 ++++++++++++++----- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ResultPrs.h b/src/ModuleBase/ModuleBase_ResultPrs.h index 2cc200c31..99fa17923 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.h +++ b/src/ModuleBase/ModuleBase_ResultPrs.h @@ -34,6 +34,9 @@ public: /// Returns True if the presentation is in sketch mode Standard_EXPORT bool isSketchMode() const { return myIsSketchMode; } + /// Returns a list of faces + Standard_EXPORT const std::list >& facesList() { return myFacesList; } + DEFINE_STANDARD_RTTI(ModuleBase_ResultPrs) protected: /// Redefinition of virtual function diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index e816891a6..edf9f03ad 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -198,6 +198,8 @@ void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged() } //******************************************************************** +#include +#include void ModuleBase_WidgetMultiSelector::onSelectionChanged() { ModuleBase_ISelection* aSelection = myWorkshop->selection(); @@ -211,23 +213,50 @@ void ModuleBase_WidgetMultiSelector::onSelectionChanged() GeomShapePtr aShape; for (aIt = aOwnersList.cbegin(); aIt != aOwnersList.cend(); aShpIt.Next(), aIt++) { ResultPtr aResult = std::dynamic_pointer_cast(*aIt); - if (myFeature) { - // We can not select a result of our feature - const std::list& aResList = myFeature->results(); - std::list::const_iterator aIt; - bool isSkipSelf = false; - for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) { - if ((*aIt) == aResult) { - isSkipSelf = true; - break; + // this case should be moved to PartSet module after redesign this class + if (aShpIt.Value().ShapeType() == TopAbs_COMPOUND) { + int aValue = 0; + AIS_ListOfInteractive aList; + aSelection->selectedAISObjects(aList); + AIS_ListIteratorOfListOfInteractive aLIt(aList); + Handle(AIS_InteractiveObject) anAISIO; + for(; aLIt.More(); aLIt.Next()){ + anAISIO = aLIt.Value(); + Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(anAISIO); + if (!aResultPrs.IsNull()) { + const std::list >& aResultFaces = aResultPrs->facesList(); + std::list>::const_iterator aIt; + for (aIt = aResultFaces.cbegin(); aIt != aResultFaces.cend(); ++aIt) { + TopoDS_Shape aFace = (*aIt)->impl(); + + aShape = std::shared_ptr(new GeomAPI_Shape()); + aShape->setImpl(new TopoDS_Shape(aShpIt.Value())); + + mySelection.append(GeomSelection(aResult, aShape)); + } } } - if(isSkipSelf) - continue; } - aShape = std::shared_ptr(new GeomAPI_Shape()); - aShape->setImpl(new TopoDS_Shape(aShpIt.Value())); - mySelection.append(GeomSelection(aResult, aShape)); + else { + if (myFeature) { + // We can not select a result of our feature + const std::list& aResList = myFeature->results(); + std::list::const_iterator aIt; + bool isSkipSelf = false; + for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) { + if ((*aIt) == aResult) { + isSkipSelf = true; + break; + } + } + if(isSkipSelf) + continue; + } + aShape = std::shared_ptr(new GeomAPI_Shape()); + aShape->setImpl(new TopoDS_Shape(aShpIt.Value())); + + mySelection.append(GeomSelection(aResult, aShape)); + } } //updateSelectionList(); emit valuesChanged(); -- 2.39.2