X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Filters.cpp;h=8d66327f8cf6549617ba16f5968839c958efc4a8;hb=825fc0c15ec31fb813103b3062fa1e51c0a2d10e;hp=3842bc8b9ca21b3913dfb84adc468302e6ec749c;hpb=abac27c7c46a40f8bf1f96f6c54d62c1c929c6c3;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Filters.cpp b/src/PartSet/PartSet_Filters.cpp index 3842bc8b9..8d66327f8 100644 --- a/src/PartSet/PartSet_Filters.cpp +++ b/src/PartSet/PartSet_Filters.cpp @@ -8,12 +8,15 @@ #include #include "ModuleBase_IModule.h" +#include #include -#include +#include +#include #include #include +#include IMPLEMENT_STANDARD_HANDLE(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter); @@ -25,12 +28,12 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation(); // the shapes from different documents should be provided if there is no started operation // in order to show/hide results - if (!anOperation) { + 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) aAisObj = Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); if (!aAisObj.IsNull()) { aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj)); @@ -38,11 +41,20 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& } ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj); if (aObj) { - FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); - if (aFeature) { - aValid = aFeature->getKind() != FeaturesPlugin_Group::ID(); - } else - aValid = Standard_True; + 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(); + } + else { + FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); + if (aFeature) { + aValid = aFeature->getKind() != "Group"; + } else + aValid = Standard_True; + } } else // This is not object controlled by the filter aValid = Standard_True; @@ -53,3 +65,68 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& #endif return aValid; } + +IMPLEMENT_STANDARD_HANDLE(PartSet_CirclePointFilter, SelectMgr_Filter); +IMPLEMENT_STANDARD_RTTIEXT(PartSet_CirclePointFilter, SelectMgr_Filter); + +Standard_Boolean + PartSet_CirclePointFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const +{ + ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation(); + if(!anOperation) { + return Standard_True; + } + + if(theOwner->HasSelectable() == Standard_False) { + return Standard_True; + } + + Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner); + if(aBrepOwner.IsNull()) { + return Standard_True; + } + + const TopoDS_Shape& aShape = aBrepOwner->Shape(); + if(aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX) { + return Standard_True; + } + + Handle(ModuleBase_ResultPrs) aResultPrs = + Handle(ModuleBase_ResultPrs)::DownCast(theOwner->Selectable()); + if(aResultPrs.IsNull()) { + return Standard_True; + } + + std::shared_ptr aGeomAISObj(new GeomAPI_AISObject()); + aGeomAISObj->setImpl(new Handle(AIS_InteractiveObject)(aResultPrs)); + ObjectPtr anObj = myWorkshop->findPresentedObject(aGeomAISObj); + if(!anObj.get()) { + return Standard_True; + } + + ResultPtr aResult = std::dynamic_pointer_cast(anObj); + if(!aResult.get()) { + return Standard_True; + } + + DocumentPtr aDocument = aResult->document(); + if(!aDocument.get()) { + return Standard_True; + } + + FeaturePtr aFeature = aDocument->feature(aResult); + if(!aFeature.get() || aFeature->getKind() != "SketchCircle") { + return Standard_True; + } + + const TopoDS_Shape anOwnerShape = aResultPrs->Shape(); + if(anOwnerShape.ShapeType() == TopAbs_EDGE) { + return Standard_False; + } + +#ifdef DEBUG_FILTERS + qDebug(QString("PartSet_ShapeDocumentFilter::IsOk = %1").arg(aValid).toStdString().c_str()); +#endif + + return Standard_True; +}