From: nds Date: Fri, 3 Jul 2015 08:13:29 +0000 (+0300) Subject: Shape plane filter should process shapes of objects selected in object browser. X-Git-Tag: V_1.3.0~119 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1db2ce63f51cc1a7bf6f029fea604cfa528aa1fd;p=modules%2Fshaper.git Shape plane filter should process shapes of objects selected in object browser. Using geom algo plane in the plane filter for futher modifications. Scenario: [crash] create sketch, create closed contour, create 2nd sketch, start translate operation, select with rectangle the prev sketch lines. Abort[sketch is selected in the OB]. Start translate again, crash[the sketch selected in OB is applyed to the multi selector control] --- diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.cpp b/src/ModuleBase/ModuleBase_ViewerFilters.cpp index 74304a35c..957b970e9 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.cpp +++ b/src/ModuleBase/ModuleBase_ViewerFilters.cpp @@ -22,6 +22,7 @@ #include #include #include +#include IMPLEMENT_STANDARD_HANDLE(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter); IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter); @@ -57,22 +58,25 @@ Standard_Boolean ModuleBase_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_Ent 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 (!myPlane.get()) + return Standard_True; + 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(); + gp_Pln aPlane = myPlane->impl(); switch (aType) { case TopAbs_VERTEX: { gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); - return myPlane.Distance(aPnt) < Precision::Confusion(); + return aPlane.Distance(aPnt) < Precision::Confusion(); } case TopAbs_EDGE: { @@ -82,14 +86,17 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_Enti 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(); + bool aD1 = aPlane.Distance(aFirstPnt) < Precision::Confusion(); + bool aD2 = aPlane.Distance(aMidPnt) < Precision::Confusion(); + bool aD3 = aPlane.Distance(aLastPnt) < Precision::Confusion(); return aD1 && aD2 && aD3; } default: // This is not object controlled by the filter return Standard_True; + // The object can be selected in Object browser and contain, for example, compound. + // The compound could not belong to any plane, so the result is false + return Standard_False; break; } } else { diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.h b/src/ModuleBase/ModuleBase_ViewerFilters.h index a5d404ee8..9c1ad9b46 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.h +++ b/src/ModuleBase/ModuleBase_ViewerFilters.h @@ -12,7 +12,8 @@ #include #include -#include + +#include class ModuleBase_IWorkshop; @@ -60,10 +61,10 @@ public: /// Set working plane /// \param thePane plane object - void setPlane(const gp_Pln& thePane) { myPlane = thePane; } + void setPlane(const std::shared_ptr& thePlane) { myPlane = thePlane; } /// Returns current working plane - gp_Pln plane() const { return myPlane; } + std::shared_ptr plane() const { return myPlane; } /// Returns True if the given owner is acceptable for selection /// \param theOwner the selected owner @@ -72,7 +73,7 @@ public: DEFINE_STANDARD_RTTI(ModuleBase_ShapeInPlaneFilter) private: /// Working plane - gp_Pln myPlane; + std::shared_ptr myPlane; }; #endif diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 1385c0970..7bc472b75 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -743,14 +743,15 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter); bool aHasPlane = false; + std::shared_ptr aPln; if (theOperation->isEditOperation()) { // If it is editing of sketch then it means that plane is already defined - std::shared_ptr aPln = PartSet_Tools::sketchPlane(myCurrentSketch); - if (aPln.get()) { - myPlaneFilter->setPlane(aPln->impl()); + aPln = PartSet_Tools::sketchPlane(myCurrentSketch); + if (aPln.get()) aHasPlane = true; - } } + myPlaneFilter->setPlane(aPln); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); // all sketch objects should be activated in the sketch selection modes by edit operation start // in case of creation operation, there is an active widget, which activates own selection mode @@ -956,7 +957,7 @@ bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr& thePln) { - myPlaneFilter->setPlane(thePln->impl()); + myPlaneFilter->setPlane(thePln); } void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,