]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
filter multiselection shapes for BuildPlugin features
authorrraphael <raphael.raphael@c-s.fr>
Mon, 11 Jan 2021 10:35:24 +0000 (11:35 +0100)
committerrraphael <raphael.raphael@c-s.fr>
Fri, 15 Jan 2021 11:13:33 +0000 (12:13 +0100)
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_WidgetValidated.cpp

index 43b268aab2e772f9b64fb51f225255eb43f1b1e6..f64dfeed72b76622f9163a5b62a7181f8915e508 100644 (file)
@@ -280,6 +280,7 @@ INCLUDE_DIRECTORIES(
     ${PROJECT_SOURCE_DIR}/src/GeomAPI
     ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
     ${PROJECT_SOURCE_DIR}/src/Locale
+    ${PROJECT_SOURCE_DIR}/src/BuildPlugin
     ${SUIT_INCLUDE}
 )
 
index feb6a380a24c291d93119642122fd36d5be7e409..a02d2589e08de96e083933c1593be234176e2c9a 100644 (file)
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_AttributeSelection.h>
 
+#include <BuildPlugin_Face.h>
+#include <BuildPlugin_Wire.h>
+#include <BuildPlugin_Solid.h>
+
 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <StdSelect_BRepOwner.hxx>
@@ -480,6 +484,59 @@ QList<ModuleBase_ViewerPrsPtr> ModuleBase_WidgetValidated::getFilteredSelected()
 
   filterCompSolids(aSelected);
 
+  if (myFeatureId == BuildPlugin_Face::ID() || myFeatureId == BuildPlugin_Wire::ID() ||
+      myFeatureId == BuildPlugin_Solid::ID())
+  {
+    /// remove objects of sub-type if ojects of correct type is in List,  in some cases :
+    /// - Face builder: edges, faces and wires selected
+    ///                 --> remove edges and wires
+    /// Wire builder: wires and edges selected
+    ///               --> remove egdes
+    /// Solid builder: faces and shapes shells or solids seleted
+    ///                --> remove faces
+
+    std::set<GeomAPI_Shape::ShapeType> shapeTypes;
+    for (auto aSelection: aSelected){
+      auto aShape = aSelection->shape();
+      if (aShape)
+        shapeTypes.insert(aShape->shapeType());
+    }
+
+    std::vector<ModuleBase_ViewerPrsPtr> aRemove;
+
+    if (myFeatureId == BuildPlugin_Face::ID() && shapeTypes.find(GeomAPI_Shape::FACE) != shapeTypes.end())
+    {
+      for(auto aSelection: aSelected){
+        auto aType = aSelection->shape()->shapeType();
+        if (aType == GeomAPI_Shape::WIRE || aType == GeomAPI_Shape::EDGE)
+          aRemove.push_back(aSelection);
+      }
+    }
+    else if (myFeatureId == BuildPlugin_Wire::ID() && shapeTypes.find(GeomAPI_Shape::WIRE) != shapeTypes.end())
+    {
+      for(auto aSelection: aSelected){
+        auto aType = aSelection->shape()->shapeType();
+        if (aType == GeomAPI_Shape::EDGE)
+          aRemove.push_back(aSelection);
+      }
+    }
+    else if (myFeatureId == BuildPlugin_Solid::ID() &&
+             (shapeTypes.find(GeomAPI_Shape::SHAPE) != shapeTypes.end() ||
+              shapeTypes.find(GeomAPI_Shape::SOLID) != shapeTypes.end() ||
+              shapeTypes.find(GeomAPI_Shape::SHELL) != shapeTypes.end()) )
+    {
+      for(auto aSelection: aSelected){
+        auto aType = aSelection->shape()->shapeType();
+        if( aType == GeomAPI_Shape::FACE)
+          aRemove.push_back(aSelection);
+      }
+    }
+
+    for(auto aSelection: aRemove){
+      aSelected.removeOne(aSelection);
+    }
+  }
+
   return aSelected;
 }