]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_FilterValidated.cpp
Salome HOME
Multi-selection widget to be used in the extrusion feature.
[modules/shaper.git] / src / ModuleBase / ModuleBase_FilterValidated.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_FilterValidated.h
4 // Created:     17 Mar 2015
5 // Author:      Natalia ERMOLAEVA
6
7
8 #include "ModuleBase_FilterValidated.h"
9 #include "ModuleBase_IWorkshop.h"
10
11 #include <ModelAPI_Session.h>
12 #include <ModelAPI_Document.h>
13 #include <ModelAPI_ResultConstruction.h>
14
15 #include <AIS_InteractiveObject.hxx>
16 #include <AIS_Shape.hxx>
17
18 #include <StdSelect_BRepOwner.hxx>
19
20 #include <BRep_Tool.hxx>
21 #include <TopoDS.hxx>
22 #include <TopoDS_Edge.hxx>
23 #include <Geom_Curve.hxx>
24
25 #include <ModelAPI_CompositeFeature.h>
26 #include <GeomAPI_ICustomPrs.h>
27
28
29 IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterValidated, SelectMgr_Filter);
30 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterValidated, SelectMgr_Filter);
31
32 Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
33 {
34 /*  // global selection should be ignored, the filter processes only selected sub-shapes
35   Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
36   if (!aShapeOwner.IsNull()) {
37     if (!aShapeOwner->ComesFromDecomposition())
38       return Standard_True;
39   }
40
41   if (theOwner->HasSelectable()) {
42     Handle(AIS_InteractiveObject) aAisObj = 
43       Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
44     if (!aAisObj.IsNull()) {
45       std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
46       aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
47       ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
48
49       ResultConstructionPtr aConstr = 
50         std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
51       if (aConstr != NULL) {
52         // it provides selection only on compositie features, construction without composite
53         // feature is not selectable
54         FeaturePtr aFeature = ModelAPI_Feature::feature(aConstr);
55         CompositeFeaturePtr aComposite = 
56           std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
57         return aComposite && aComposite->numberOfSubs() > 0;
58       }
59     }
60   }
61   */
62   return Standard_False;
63 }
64