1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_ViewerFilters.cpp
4 // Created: 07 Okt 2014
5 // Author: Vitaly SMETANNIKOV
8 #include "ModuleBase_FilterNoConsructionSubShapes.h"
9 #include "ModuleBase_IWorkshop.h"
11 #include <ModelAPI_Session.h>
12 #include <ModelAPI_Document.h>
13 #include <ModelAPI_ResultConstruction.h>
15 #include <AIS_InteractiveObject.hxx>
16 #include <AIS_Shape.hxx>
18 #include <StdSelect_BRepOwner.hxx>
20 #include <BRep_Tool.hxx>
22 #include <TopoDS_Edge.hxx>
23 #include <Geom_Curve.hxx>
25 #include <ModelAPI_CompositeFeature.h>
26 #include <GeomAPI_ICustomPrs.h>
29 IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterNoConsructionSubShapes, SelectMgr_Filter);
30 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterNoConsructionSubShapes, SelectMgr_Filter);
32 Standard_Boolean ModuleBase_FilterNoConsructionSubShapes::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
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())
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);
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;
61 return Standard_False;