X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Filters.cpp;h=b7e5ccbb1e62e2d116921ed8220e201ff44e65af;hb=8d8cd4bfaf5af5db0fe563e3e75b2526e472dbe0;hp=2851ea877dc2fac100e4d03b987cd42eceebc1a7;hpb=7074394f8f08413d885f63be01df6bd5007b868c;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Filters.cpp b/src/PartSet/PartSet_Filters.cpp index 2851ea877..b7e5ccbb1 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-2019 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" @@ -26,6 +25,8 @@ #include #include +#include +#include #include #include @@ -57,11 +58,19 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& 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() && aResult->groupName() == ModelAPI_ResultPart::group()) { - SessionPtr aMgr = ModelAPI_Session::get(); - aValid = aMgr->activeDocument() == aMgr->moduleDocument(); + if (aResult.get()) { + std::string aResultGroupName = aResult->groupName(); + if (aResultGroupName == ModelAPI_ResultPart::group()) { + SessionPtr aMgr = ModelAPI_Session::get(); + aValid = aMgr->activeDocument() == aMgr->moduleDocument(); + } else if (aResultGroupName == ModelAPI_ResultGroup::group() || + aResultGroupName == ModelAPI_ResultField::group()) { + aValid = Standard_False; + } else + aValid = Standard_True; } - else { + else { // possibly this code is obsolete, as a feature object can be selected in recovery + // only and there can not be Group feature FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); if (aFeature) { aValid = aFeature->getKind() != "Group"; @@ -79,6 +88,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