From 7d764bc51fb4ba0527f224e6ea6fb4898da82502 Mon Sep 17 00:00:00 2001 From: dbv Date: Wed, 2 Mar 2016 16:17:27 +0300 Subject: [PATCH] Issue #1351: partition is not done When selecting compsolid and it subsolids with rectangle selection or shift selection will select only whole compsolid. --- src/ModuleBase/ModuleBase_WidgetValidated.cpp | 42 +++++++++++++++++++ src/ModuleBase/ModuleBase_WidgetValidated.h | 4 ++ 2 files changed, 46 insertions(+) diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 6e4873753..eedfb2b79 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include @@ -304,6 +306,8 @@ QList ModuleBase_WidgetValidated::getFilteredSelected() if (!anOBSelected.isEmpty()) ModuleBase_ISelection::appendSelected(anOBSelected, aSelected); + filterCompSolids(aSelected); + return aSelected; } @@ -323,3 +327,41 @@ void ModuleBase_WidgetValidated::filterPresentations(QList theValues = aValidatedValues; } } + +//******************************************************************** +void ModuleBase_WidgetValidated::filterCompSolids(QList& theValues) +{ + std::set aCompSolids; + QList aValidatedValues; + + // Collect compsolids. + QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); + for (; anIt != aLast; anIt++) { + const ModuleBase_ViewerPrs& aViewerPrs = *anIt; + ObjectPtr anObject = aViewerPrs.object(); + ResultCompSolidPtr aResultCompSolid = std::dynamic_pointer_cast(anObject); + if(aResultCompSolid.get()) { + aCompSolids.insert(aResultCompSolid); + } + } + + // Filter sub-solids of compsolids. + anIt = theValues.begin(); + for (; anIt != aLast; anIt++) { + const ModuleBase_ViewerPrs& aViewerPrs = *anIt; + ObjectPtr anObject = aViewerPrs.object(); + ResultPtr aResult = std::dynamic_pointer_cast(anObject); + ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aResult); + if(aResCompSolidPtr.get() && (aCompSolids.find(aResCompSolidPtr) != aCompSolids.end())) { + // Skip sub-solid of compsolid. + continue; + } else { + aValidatedValues.append(*anIt); + } + } + + if (aValidatedValues.size() != theValues.size()) { + theValues.clear(); + theValues = aValidatedValues; + } +} diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index e7c84a942..f60cd1a0e 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -122,6 +122,10 @@ protected: /// \param theValues a list of presentations. void filterPresentations(QList& theValues); + /// Remove subshapes of compsolids if whole compsolid is present. + /// \param theValues a list of presentations. + void filterCompSolids(QList& theValues); + /// It obtains selection filters from the workshop and activates them in the active viewer /// \param toActivate a flag about activation or deactivation the filters /// \return true if the selection filter of the widget is activated in viewer context -- 2.39.2