From 9c2ebe24ff57ce6126b240f8f2c8f58d8a94ace7 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 16 May 2018 12:05:06 +0300 Subject: [PATCH] Issue #2473: Fix direction of selected trihedron --- src/ModuleBase/ModuleBase_ViewerFilters.cpp | 62 +++++++++------------ 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.cpp b/src/ModuleBase/ModuleBase_ViewerFilters.cpp index d4a77c29b..ccb8eae4c 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.cpp +++ b/src/ModuleBase/ModuleBase_ViewerFilters.cpp @@ -129,43 +129,35 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk( } } else { if (theOwner->HasSelectable()) { - // Check Trihedron sub-objects - Handle(SelectMgr_SelectableObject) aSelObj = theOwner->Selectable(); - Handle(Standard_Type) aType = aSelObj->DynamicType(); -#ifdef BEFORE_TRIHEDRON_PATCH - if (aType == STANDARD_TYPE(AIS_Axis)) { - Handle(AIS_Axis) aAxis = Handle(AIS_Axis)::DownCast(aSelObj); - gp_Lin aLine = aAxis->Component()->Lin(); - return aPlane.Contains(aLine, Precision::Confusion(), Precision::Angular()); - - } else if (aType == STANDARD_TYPE(AIS_Point)) { - Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(aSelObj); - return aPlane.Distance(aPoint->Component()->Pnt()) < Precision::Confusion(); - - } else if (aType == STANDARD_TYPE(AIS_Plane)) { - Handle(AIS_Plane) aAisPlane = Handle(AIS_Plane)::DownCast(aSelObj); - gp_Pln aPln = aAisPlane->Component()->Pln(); - return aPlane.Distance(aPln) < Precision::Confusion(); - } -#else - if (aType == STANDARD_TYPE(AIS_Trihedron)) { - Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aSelObj); - Handle(AIS_TrihedronOwner) aTrOwner = Handle(AIS_TrihedronOwner)::DownCast(theOwner); - if (!aTrOwner.IsNull()) - { - const Prs3d_DatumParts& aPart = aTrOwner->DatumPart(); - if (aPart >= Prs3d_DP_XAxis && aPart <= Prs3d_DP_ZAxis) - { - gp_Ax2 anAxis = aTrihedron->Component()->Ax2(); - gp_Dir aDir = anAxis.XDirection(); - gp_Lin aLine(aTrihedron->Component()->Location(), aDir); - return aPlane.Contains(aLine, Precision::Confusion(), Precision::Angular()); + // Check Trihedron sub-objects + Handle(SelectMgr_SelectableObject) aSelObj = theOwner->Selectable(); + Handle(Standard_Type) aType = aSelObj->DynamicType(); + if (aType == STANDARD_TYPE(AIS_Trihedron)) { + Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aSelObj); + Handle(AIS_TrihedronOwner) aTrOwner = Handle(AIS_TrihedronOwner)::DownCast(theOwner); + if (!aTrOwner.IsNull()) { + const Prs3d_DatumParts& aPart = aTrOwner->DatumPart(); + if (aPart >= Prs3d_DP_XAxis && aPart <= Prs3d_DP_ZAxis) { + gp_Ax2 anAxis = aTrihedron->Component()->Ax2(); + gp_Dir aDir; + switch (aPart) { + case Prs3d_DP_XAxis: + aDir = anAxis.XDirection(); + break; + case Prs3d_DP_YAxis: + aDir = anAxis.YDirection(); + break; + case Prs3d_DP_ZAxis: + aDir = anAxis.Direction(); + break; + } + gp_Lin aLine(aTrihedron->Component()->Location(), aDir); + return aPlane.Contains(aLine, Precision::Confusion(), Precision::Angular()); + } } } - } -#endif - // This is not object controlled by the filter - aValid = Standard_True; + // This is not object controlled by the filter + aValid = Standard_True; } } } -- 2.39.2