Salome HOME
Ignore selection of groups for operations
[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   bool aValid = true;
25   ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
26   // the shapes from different documents should be provided if there is no started operation
27   // in order to show/hide results
28   if (anOperation) {
29     aValid = false;
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           aValid = aFeature->getKind() != FeaturesPlugin_Group::ID();
44         } else 
45           aValid = Standard_True;
46       } else
47         // This is not object controlled by the filter
48         aValid = Standard_True;
49     }
50   }
51 #ifdef DEBUG_FILTERS
52   qDebug(QString("PartSet_GlobalFilter::IsOk = %1").arg(aValid).toStdString().c_str());
53 #endif
54   return aValid;
55 }