X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ViewerFilters.cpp;h=81f84dda6641d9c604cbac02c90ef19374fd4ecb;hb=ec091ee8278311fb7a69c54a68670b66edd8db2d;hp=6626a16683366bf0740d0ea7160a67fc18615fa5;hpb=7778069b85fb13f2cd02c3cf5ad8ba6233b24e11;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.cpp b/src/ModuleBase/ModuleBase_ViewerFilters.cpp index 6626a1668..81f84dda6 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.cpp +++ b/src/ModuleBase/ModuleBase_ViewerFilters.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: ModuleBase_ViewerFilters.cpp // Created: 07 Okt 2014 // Author: Vitaly SMETANNIKOV @@ -8,8 +10,17 @@ #include #include +#include #include +#include + +#include + +#include +#include +#include +#include IMPLEMENT_STANDARD_HANDLE(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter); IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter); @@ -22,15 +33,62 @@ Standard_Boolean ModuleBase_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_Ent Handle(AIS_InteractiveObject) aAisObj = Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); if (!aAisObj.IsNull()) { - boost::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); + std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj)); ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj); if (aObj) { DocumentPtr aDoc = aObj->document(); SessionPtr aMgr = ModelAPI_Session::get(); - return (aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument()); + return (aDoc == aMgr->activeDocument() || aDoc == aMgr->moduleDocument()); + } + else { + // This is not object controlled by the filter + return Standard_True; + } + } + } + return Standard_False; +} + + +IMPLEMENT_STANDARD_HANDLE(ModuleBase_ShapeInPlaneFilter, SelectMgr_Filter); +IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ShapeInPlaneFilter, SelectMgr_Filter); + +Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const +{ + if (theOwner->HasSelectable()) { + Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner); + if (!aShapeOwner.IsNull()) { + TopoDS_Shape aShape = aShapeOwner->Shape(); + TopAbs_ShapeEnum aType = aShape.ShapeType(); + switch (aType) { + case TopAbs_VERTEX: + { + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); + return myPlane.Distance(aPnt) < Precision::Confusion(); + } + case TopAbs_EDGE: + { + TopoDS_Edge aEdge = TopoDS::Edge(aShape); + Standard_Real aFirst, aLast; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aFirst, aLast); + gp_Pnt aFirstPnt = aCurve->Value(aFirst); + gp_Pnt aMidPnt = aCurve->Value((aFirst + aLast) / 2.); + gp_Pnt aLastPnt = aCurve->Value(aLast); + bool aD1 = myPlane.Distance(aFirstPnt) < Precision::Confusion(); + bool aD2 = myPlane.Distance(aMidPnt) < Precision::Confusion(); + bool aD3 = myPlane.Distance(aLastPnt) < Precision::Confusion(); + return aD1 && aD2 && aD3; + } + default: + // This is not object controlled by the filter + return Standard_True; + break; } + } else { + // This is not object controlled by the filter + return Standard_True; } } return Standard_False; -} \ No newline at end of file +}