X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Filters.cpp;h=ac23d62844480d7c863f5f48f95df7cc23972b02;hb=3b02241a66e6be241eebbe70df42349293c5f4ab;hp=afe4fbbda47d0090db276282818800f086cda5f5;hpb=2714903267d23cd0c81166c506fb3edd1e069d40;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Filters.cpp b/src/PartSet/PartSet_Filters.cpp index afe4fbbda..ac23d6284 100644 --- a/src/PartSet/PartSet_Filters.cpp +++ b/src/PartSet/PartSet_Filters.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "PartSet_Filters.h" @@ -27,42 +26,71 @@ #include #include #include +#include #include #include #include +#include +#include #include IMPLEMENT_STANDARD_RTTIEXT(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter); +PartSet_GlobalFilter::PartSet_GlobalFilter(ModuleBase_IWorkshop* theWorkshop) + : ModuleBase_ShapeDocumentFilter(theWorkshop) +{ + addNonSelectableType(ModelAPI_ResultField::group().c_str()); + addNonSelectableType(ModelAPI_ResultGroup::group().c_str()); +} + + Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const { bool aValid = true; + std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); + Handle(AIS_InteractiveObject) aAisObj; + if (theOwner->HasSelectable()) { + aAisObj = Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); + if (!aAisObj.IsNull()) { + aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj)); + } + } + ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj); ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation(); + +#ifdef HAVE_SALOME + if (!aObj.get()) { + // Workaround to enable View Cube and Trihedron selection + if (!aAisObj.IsNull()) { + if (aAisObj->IsKind(STANDARD_TYPE(AIS_Trihedron)) || + aAisObj->IsKind(STANDARD_TYPE(AIS_ViewCube))) { + return true; + } + } + + // Issue #3161: Do not use presentations for non-SHAPER objects + if (!anOperation) + return false; + } +#endif + // the shapes from different documents should be provided if there is no started operation // in order to show/hide results if (anOperation) { aValid = false; if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) { - std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); - if (theOwner->HasSelectable()) { - Handle(AIS_InteractiveObject) aAisObj = - Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); - if (!aAisObj.IsNull()) { - aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj)); - } - } - ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj); if (aObj) { ResultPtr aResult = std::dynamic_pointer_cast(aObj); // result of parts belongs to PartSet document and can be selected only when PartSet // is active in order to do not select the result of the active part. if (aResult.get()) { - if (aResult->groupName() == ModelAPI_ResultPart::group()) { + std::string aResultGroupName = aResult->groupName(); + if (aResultGroupName == ModelAPI_ResultPart::group()) { SessionPtr aMgr = ModelAPI_Session::get(); aValid = aMgr->activeDocument() == aMgr->moduleDocument(); - } else if (aResult->groupName() == ModelAPI_ResultGroup::group()) { + } else if (myNonSelectableTypes.contains(aResultGroupName.c_str())) { aValid = Standard_False; } else aValid = Standard_True; @@ -71,7 +99,7 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& // only and there can not be Group feature FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); if (aFeature) { - aValid = aFeature->getKind() != "Group"; + aValid = !myNonSelectableTypes.contains(aFeature->getKind().c_str()); } else aValid = Standard_True; } @@ -86,6 +114,42 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& return aValid; } +IMPLEMENT_STANDARD_RTTIEXT(PartSet_ResultGroupNameFilter, SelectMgr_Filter); + +void PartSet_ResultGroupNameFilter::setGroupNames(const std::set& theGroupNames) +{ + myGroupNames = theGroupNames; +} + +Standard_Boolean PartSet_ResultGroupNameFilter::IsOk( + const Handle(SelectMgr_EntityOwner)& theOwner) const +{ + std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); + if (theOwner->HasSelectable()) { + Handle(AIS_InteractiveObject) aAisObj = + Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); + if (!aAisObj.IsNull()) { + aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj)); + } + } + ObjectPtr anObject = myWorkshop->findPresentedObject(aAISObj); + if (!anObject.get()) + return true; + + ResultPtr aResult = std::dynamic_pointer_cast(anObject); + // result of parts belongs to PartSet document and can be selected only when PartSet + // is active in order to do not select the result of the active part. + if (!aResult.get()) + return true; + + std::string aGroupName = aResult->groupName();// == ModelAPI_ResultPart::group()) { + if (myGroupNames.find(aGroupName) != myGroupNames.end()) + return false; // the object of the filtered type is found + + return true; +} + + IMPLEMENT_STANDARD_RTTIEXT(PartSet_CirclePointFilter, SelectMgr_Filter); Standard_Boolean @@ -134,7 +198,9 @@ Standard_Boolean } FeaturePtr aFeature = aDocument->feature(aResult); - if(!aFeature.get() || aFeature->getKind() != "SketchCircle") { + if(!aFeature.get() || + ((aFeature->getKind() != "SketchCircle") && + (aFeature->getKind() != "SketchBSplinePeriodic"))) { return Standard_True; }