From 19da974edcd715cf6ff0a11526f431f3ad890861 Mon Sep 17 00:00:00 2001 From: vro Date: Tue, 19 Oct 2021 18:57:23 +0300 Subject: [PATCH] 0032632: Visualization, AIS_ViewCube - the class AIS_ViewCubeSensitive is hidden inside CXX file --- src/AIS/AIS_ViewCube.cxx | 72 +++++++++++++++++++++------------------- src/AIS/AIS_ViewCube.hxx | 22 ++++++++++++ 2 files changed, 59 insertions(+), 35 deletions(-) diff --git a/src/AIS/AIS_ViewCube.cxx b/src/AIS/AIS_ViewCube.cxx index 756f6226a3..1e405cb44f 100644 --- a/src/AIS/AIS_ViewCube.cxx +++ b/src/AIS/AIS_ViewCube.cxx @@ -27,13 +27,13 @@ #include #include #include -#include #include #include #include IMPLEMENT_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner) +IMPLEMENT_STANDARD_RTTIEXT(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray) namespace { @@ -56,46 +56,48 @@ namespace } } -//! Simple sensitive element for picking by point only. -class AIS_ViewCubeSensitive : public Select3D_SensitivePrimitiveArray +//======================================================================= +//function : AIS_ViewCubeSensitive +//purpose : +//======================================================================= +AIS_ViewCubeSensitive::AIS_ViewCubeSensitive (const Handle(SelectMgr_EntityOwner)& theOwner, + const Handle(Graphic3d_ArrayOfTriangles)& theTris) +: Select3D_SensitivePrimitiveArray (theOwner) { - DEFINE_STANDARD_RTTI_INLINE(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray) -public: - //! Constructor. - AIS_ViewCubeSensitive (const Handle(SelectMgr_EntityOwner)& theOwner, - const Handle(Graphic3d_ArrayOfTriangles)& theTris) - : Select3D_SensitivePrimitiveArray (theOwner) + InitTriangulation (theTris->Attributes(), theTris->Indices(), TopLoc_Location()); +} + +//======================================================================= +//function : Matches +//purpose : +//======================================================================= +Standard_Boolean AIS_ViewCubeSensitive::Matches (SelectBasics_SelectingVolumeManager& theMgr, + SelectBasics_PickResult& thePickResult) +{ + return isValidRay (theMgr) && Select3D_SensitivePrimitiveArray::Matches (theMgr, thePickResult); +} + +//======================================================================= +//function : isValidRay +//purpose : +//======================================================================= +bool AIS_ViewCubeSensitive::isValidRay (const SelectBasics_SelectingVolumeManager& theMgr) const +{ + if (theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point) { - InitTriangulation (theTris->Attributes(), theTris->Indices(), TopLoc_Location()); + // disallow rectangular selection + return false; } - //! Checks whether element overlaps current selecting volume. - virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr, - SelectBasics_PickResult& thePickResult) Standard_OVERRIDE + if (AIS_ViewCubeOwner* anOwner = dynamic_cast(myOwnerId.get())) { - return isValidRay (theMgr) - && Select3D_SensitivePrimitiveArray::Matches (theMgr, thePickResult); + const Standard_Real anAngleToler = 10.0 * M_PI / 180.0; + const gp_Dir aRay = theMgr.GetViewRayDirection(); + const gp_Dir aDir = V3d::GetProjAxis (anOwner->MainOrientation()); + return !aRay.IsNormal (aDir, anAngleToler); } - - //! Checks if picking ray can be used for detection. - bool isValidRay (const SelectBasics_SelectingVolumeManager& theMgr) const - { - if (theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point) - { - // disallow rectangular selection - return false; - } - - if (AIS_ViewCubeOwner* anOwner = dynamic_cast(myOwnerId.get())) - { - const Standard_Real anAngleToler = 10.0 * M_PI / 180.0; - const gp_Dir aRay = theMgr.GetViewRayDirection(); - const gp_Dir aDir = V3d::GetProjAxis (anOwner->MainOrientation()); - return !aRay.IsNormal (aDir, anAngleToler); - } - return true; - } -}; + return true; +} //======================================================================= //function : IsBoxSide diff --git a/src/AIS/AIS_ViewCube.hxx b/src/AIS/AIS_ViewCube.hxx index 4da9de27f9..32428cf04f 100644 --- a/src/AIS/AIS_ViewCube.hxx +++ b/src/AIS/AIS_ViewCube.hxx @@ -24,6 +24,7 @@ #include #include #include +#include class AIS_AnimationCamera; class AIS_ViewCubeOwner; @@ -724,4 +725,25 @@ protected: }; +//! Simple sensitive element for picking by point only. +class AIS_ViewCubeSensitive : public Select3D_SensitivePrimitiveArray +{ + DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray) +public: + + //! Constructor. + Standard_EXPORT AIS_ViewCubeSensitive (const Handle(SelectMgr_EntityOwner)& theOwner, + const Handle(Graphic3d_ArrayOfTriangles)& theTris); + + //! Checks whether element overlaps current selecting volume. + Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr, + SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; + +protected: + + //! Checks if picking ray can be used for detection. + Standard_EXPORT bool isValidRay (const SelectBasics_SelectingVolumeManager& theMgr) const; + +}; + #endif // _AIS_ViewCube_HeaderFile