#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <Geom_Curve.hxx>
+#include <gp_Pln.hxx>
IMPLEMENT_STANDARD_HANDLE(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
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<gp_Pln>();
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:
{
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 {
#include <SelectMgr_Filter.hxx>
#include <SelectMgr_EntityOwner.hxx>
-#include <gp_Pln.hxx>
+
+#include <GeomAPI_Pln.h>
class ModuleBase_IWorkshop;
/// Set working plane
/// \param thePane plane object
- void setPlane(const gp_Pln& thePane) { myPlane = thePane; }
+ void setPlane(const std::shared_ptr<GeomAPI_Pln>& thePlane) { myPlane = thePlane; }
/// Returns current working plane
- gp_Pln plane() const { return myPlane; }
+ std::shared_ptr<GeomAPI_Pln> plane() const { return myPlane; }
/// Returns True if the given owner is acceptable for selection
/// \param theOwner the selected owner
DEFINE_STANDARD_RTTI(ModuleBase_ShapeInPlaneFilter)
private:
/// Working plane
- gp_Pln myPlane;
+ std::shared_ptr<GeomAPI_Pln> myPlane;
};
#endif
myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
bool aHasPlane = false;
+ std::shared_ptr<GeomAPI_Pln> aPln;
if (theOperation->isEditOperation()) {
// If it is editing of sketch then it means that plane is already defined
- std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
- if (aPln.get()) {
- myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
+ 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
void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
{
- myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
+ myPlaneFilter->setPlane(thePln);
}
void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,