Salome HOME
Shape plane filter should process shapes of objects selected in object browser.
[modules/shaper.git] / src / PartSet / PartSet_Filters.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_Filters.cpp
4 // Created:     08 Nov 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "PartSet_Filters.h"
8
9 #include <ModuleBase_IWorkshop.h>
10 #include "ModuleBase_IModule.h"
11
12 #include <ModelAPI_Feature.h>
13 #include <FeaturesPlugin_Group.h>
14
15 #include <AIS_InteractiveObject.hxx>
16 #include <AIS_Shape.hxx>
17
18
19 IMPLEMENT_STANDARD_HANDLE(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter);
20 IMPLEMENT_STANDARD_RTTIEXT(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter);
21
22 Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
23 {
24   ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
25   // the shapes from different documents should be provided if there is no started operation
26   // in order to show/hide results
27   if (!anOperation)
28     return true;
29
30   if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) {
31     std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
32     if (theOwner->HasSelectable()) {
33       Handle(AIS_InteractiveObject) aAisObj = 
34         Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
35       if (!aAisObj.IsNull()) {
36         aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
37       }
38     }
39     ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
40     if (aObj) {
41       FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
42       if (aFeature) {
43         return aFeature->getKind() != FeaturesPlugin_Group::ID();
44       } else 
45         return Standard_True;
46     } else
47       // This is not object controlled by the filter
48       return Standard_True;
49   }
50   return Standard_False;
51 }