]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Multi-selection widget to be used in the extrusion feature.
authornds <natalia.donis@opencascade.com>
Wed, 18 Mar 2015 11:09:12 +0000 (14:09 +0300)
committernds <natalia.donis@opencascade.com>
Wed, 18 Mar 2015 11:09:12 +0000 (14:09 +0300)
src/ModuleBase/ModuleBase_ResultPrs.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp

index 2cc200c310946fdd751c25e0066d3f061d1038f9..99fa1792312bc981ee382306ea0b172836394f4d 100644 (file)
@@ -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<std::shared_ptr<GeomAPI_Shape> >& facesList() { return myFacesList; }
+
   DEFINE_STANDARD_RTTI(ModuleBase_ResultPrs)
 protected:
   /// Redefinition of virtual function
index e816891a6585968c16310391fa9e48fa891d3d3b..edf9f03ade3c5062e41dbd527c7a2772dbc1045c 100644 (file)
@@ -198,6 +198,8 @@ void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
 }
 
 //********************************************************************
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <ModuleBase_ResultPrs.h>
 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<ModelAPI_Result>(*aIt);
-    if (myFeature) {
-      // We can not select a result of our feature
-      const std::list<ResultPtr>& aResList = myFeature->results();
-      std::list<ResultPtr>::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<std::shared_ptr<GeomAPI_Shape> >& aResultFaces = aResultPrs->facesList();
+          std::list<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
+          for (aIt = aResultFaces.cbegin(); aIt != aResultFaces.cend(); ++aIt) {
+            TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
+            
+            aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+            aShape->setImpl(new TopoDS_Shape(aShpIt.Value()));
+
+            mySelection.append(GeomSelection(aResult, aShape));
+          }
         }
       }
-      if(isSkipSelf)
-        continue;
     }
-    aShape = std::shared_ptr<GeomAPI_Shape>(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<ResultPtr>& aResList = myFeature->results();
+        std::list<ResultPtr>::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<GeomAPI_Shape>(new GeomAPI_Shape());
+      aShape->setImpl(new TopoDS_Shape(aShpIt.Value()));
+
+      mySelection.append(GeomSelection(aResult, aShape));
+    }
   }
   //updateSelectionList();
   emit valuesChanged();