From fa5716667e361f4bb60b845adc6563acb83ec6f4 Mon Sep 17 00:00:00 2001 From: rraphael Date: Mon, 11 Jan 2021 11:35:24 +0100 Subject: [PATCH] filter multiselection shapes for BuildPlugin features --- src/ModuleBase/CMakeLists.txt | 1 + src/ModuleBase/ModuleBase_WidgetValidated.cpp | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index 43b268aab..f64dfeed7 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -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} ) diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index feb6a380a..a02d2589e 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -35,6 +35,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -480,6 +484,59 @@ QList 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 shapeTypes; + for (auto aSelection: aSelected){ + auto aShape = aSelection->shape(); + if (aShape) + shapeTypes.insert(aShape->shapeType()); + } + + std::vector 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; } -- 2.39.2