From 91d9637224122a72393587c7acfca5174c4aeedc Mon Sep 17 00:00:00 2001 From: aba Date: Wed, 1 Jun 2016 18:37:51 +0300 Subject: [PATCH] 0027536: Visualization - incorrect behavior of zoom persisted objects 1) Zoom persistence mode now fixes object in pixel coordinates and is independent on view size 2) Used gp_GTrsf instead of gp_Trsf SelectMgr_ViewerSelector to store Graphic3d_Mat4d 3) Zoom persisted objects changed behavior (become bigger) therefore test cases were updated according to new state. 4) Corrected scale for rectangular frustum Updated test for manipulator --- src/Graphic3d/Graphic3d_TransformPers.hxx | 14 ++++++- src/MeshVS/MeshVS_DummySensitiveEntity.cxx | 4 +- src/MeshVS/MeshVS_DummySensitiveEntity.hxx | 2 +- .../OpenGl_BVHClipPrimitiveTrsfPersSet.cxx | 4 +- .../OpenGl_BVHClipPrimitiveTrsfPersSet.hxx | 2 + src/OpenGl/OpenGl_BVHTreeSelector.cxx | 11 ++++++ src/OpenGl/OpenGl_BVHTreeSelector.hxx | 15 +++++++ src/OpenGl/OpenGl_Layer.cxx | 5 ++- src/OpenGl/OpenGl_View_Redraw.cxx | 1 + src/PrsMgr/PrsMgr_PresentableObject.hxx | 5 ++- src/PrsMgr/PrsMgr_PresentableObject.lxx | 2 +- src/Select3D/Select3D_SensitiveEntity.cxx | 4 +- src/Select3D/Select3D_SensitiveEntity.hxx | 2 +- .../Select3D_SensitivePrimitiveArray.hxx | 4 +- .../Select3D_SensitiveTriangulation.cxx | 2 +- .../Select3D_SensitiveTriangulation.hxx | 4 +- .../SelectBasics_SensitiveEntity.hxx | 3 +- src/SelectMgr/SelectMgr_BaseFrustum.cxx | 10 +++++ src/SelectMgr/SelectMgr_BaseFrustum.hxx | 8 +++- src/SelectMgr/SelectMgr_FrustumBuilder.cxx | 11 ++++++ src/SelectMgr/SelectMgr_FrustumBuilder.hxx | 3 ++ .../SelectMgr_RectangularFrustum.cxx | 39 +++++++++---------- .../SelectMgr_RectangularFrustum.hxx | 2 +- .../SelectMgr_SelectableObjectTrsfPersSet.cxx | 4 +- .../SelectMgr_SelectableObjectTrsfPersSet.hxx | 2 + .../SelectMgr_SelectingVolumeManager.cxx | 11 +++++- .../SelectMgr_SelectingVolumeManager.hxx | 4 +- src/SelectMgr/SelectMgr_TriangularFrustum.cxx | 20 ++++------ src/SelectMgr/SelectMgr_TriangularFrustum.hxx | 2 +- .../SelectMgr_TriangularFrustumSet.cxx | 2 +- .../SelectMgr_TriangularFrustumSet.hxx | 2 +- src/SelectMgr/SelectMgr_ViewerSelector.cxx | 39 +++++++++++++------ src/SelectMgr/SelectMgr_ViewerSelector.hxx | 3 +- src/ViewerTest/ViewerTest.cxx | 30 ++++++++++---- tests/bugs/vis/bug25867 | 2 +- tests/bugs/vis/bug26344 | 6 +-- tests/bugs/vis/bug26719_1 | 11 +++--- tests/bugs/vis/bug26719_2 | 6 +-- tests/bugs/vis/bug26792 | 8 ++-- tests/bugs/vis/bug27536 | 30 ++++++++++++++ tests/v3d/manipulator/rotate | 4 +- tests/v3d/manipulator/scale | 2 +- tests/v3d/manipulator/translate | 4 +- tests/v3d/manipulator/zoom_persistence | 2 +- 44 files changed, 250 insertions(+), 101 deletions(-) create mode 100644 tests/bugs/vis/bug27536 diff --git a/src/Graphic3d/Graphic3d_TransformPers.hxx b/src/Graphic3d/Graphic3d_TransformPers.hxx index 4f5d6ba625..a687fad656 100644 --- a/src/Graphic3d/Graphic3d_TransformPers.hxx +++ b/src/Graphic3d/Graphic3d_TransformPers.hxx @@ -158,10 +158,22 @@ void Graphic3d_TransformPers::Apply (NCollection_Mat4& theProjection, } // Prevent zooming. - if ((Flags & Graphic3d_TMF_ZoomPers) || (Flags == Graphic3d_TMF_TriedronPers)) + if (Flags & Graphic3d_TMF_ZoomPers) + { + const T aDet00 = (2.0f / theViewportWidth) / theProjection.GetValue(0, 0); + const T aDet11 = (2.0f / theViewportHeight) / theProjection.GetValue(1, 1); + const T aDet2 = Max (aDet00, aDet11); + + theProjection.ChangeValue(0, 0) *= aDet00; + theProjection.ChangeValue(1, 1) *= aDet11; + theProjection.ChangeValue(2, 2) *= aDet2; + } + + if (Flags == Graphic3d_TMF_TriedronPers) { // Compute fixed-zoom multiplier. Actually function works ugly with TelPerspective! const T aDet2 = static_cast (0.002) / Max (theProjection.GetValue (1, 1), theProjection.GetValue (0, 0)); + theProjection.ChangeValue (0, 0) *= aDet2; theProjection.ChangeValue (1, 1) *= aDet2; theProjection.ChangeValue (2, 2) *= aDet2; diff --git a/src/MeshVS/MeshVS_DummySensitiveEntity.cxx b/src/MeshVS/MeshVS_DummySensitiveEntity.cxx index dcae01aaba..ce81d39f06 100644 --- a/src/MeshVS/MeshVS_DummySensitiveEntity.cxx +++ b/src/MeshVS/MeshVS_DummySensitiveEntity.cxx @@ -85,7 +85,7 @@ Standard_Boolean MeshVS_DummySensitiveEntity::HasInitLocation() const //function : InvInitLocation //purpose : //======================================================================= -inline gp_Trsf MeshVS_DummySensitiveEntity::InvInitLocation() const +inline gp_GTrsf MeshVS_DummySensitiveEntity::InvInitLocation() const { - return gp_Trsf(); + return gp_GTrsf(); } diff --git a/src/MeshVS/MeshVS_DummySensitiveEntity.hxx b/src/MeshVS/MeshVS_DummySensitiveEntity.hxx index f2981598a9..1e2bba9fde 100644 --- a/src/MeshVS/MeshVS_DummySensitiveEntity.hxx +++ b/src/MeshVS/MeshVS_DummySensitiveEntity.hxx @@ -49,7 +49,7 @@ public: Standard_EXPORT virtual Standard_Boolean HasInitLocation() const Standard_OVERRIDE; - Standard_EXPORT virtual gp_Trsf InvInitLocation() const Standard_OVERRIDE; + Standard_EXPORT virtual gp_GTrsf InvInitLocation() const Standard_OVERRIDE; DEFINE_STANDARD_RTTIEXT(MeshVS_DummySensitiveEntity,SelectBasics_SensitiveEntity) }; diff --git a/src/OpenGl/OpenGl_BVHClipPrimitiveTrsfPersSet.cxx b/src/OpenGl/OpenGl_BVHClipPrimitiveTrsfPersSet.cxx index 3807bc82b8..e351367c43 100644 --- a/src/OpenGl/OpenGl_BVHClipPrimitiveTrsfPersSet.cxx +++ b/src/OpenGl/OpenGl_BVHClipPrimitiveTrsfPersSet.cxx @@ -135,6 +135,8 @@ const OpenGl_Structure* OpenGl_BVHClipPrimitiveTrsfPersSet::GetStructureById (St const NCollection_Handle >& OpenGl_BVHClipPrimitiveTrsfPersSet::BVH (const OpenGl_Mat4& theProjectionMatrix, const OpenGl_Mat4& theWorldViewMatrix, + const Standard_Integer theViewportWidth, + const Standard_Integer theViewportHeight, const Graphic3d_WorldViewProjState& theWVPState) { if (!myIsDirty @@ -152,7 +154,7 @@ const NCollection_Handle >& HBndBox4f aBoundingBox = new Graphic3d_BndBox4f; *aBoundingBox = aStructure->BoundingBox(); - aStructure->TransformPersistence.Apply (theProjectionMatrix, theWorldViewMatrix, 0, 0, *aBoundingBox); + aStructure->TransformPersistence.Apply (theProjectionMatrix, theWorldViewMatrix, theViewportWidth, theViewportHeight, *aBoundingBox); myStructBoxes.Add (aBoundingBox); } diff --git a/src/OpenGl/OpenGl_BVHClipPrimitiveTrsfPersSet.hxx b/src/OpenGl/OpenGl_BVHClipPrimitiveTrsfPersSet.hxx index 563554d708..d838a0e42c 100644 --- a/src/OpenGl/OpenGl_BVHClipPrimitiveTrsfPersSet.hxx +++ b/src/OpenGl/OpenGl_BVHClipPrimitiveTrsfPersSet.hxx @@ -78,6 +78,8 @@ public: //! Returns BVH tree for the given world view projection (builds it if necessary). const NCollection_Handle >& BVH (const OpenGl_Mat4& theProjectionMatrix, const OpenGl_Mat4& theWorldViewMatrix, + const Standard_Integer theViewportWidth, + const Standard_Integer theViewportHeight, const Graphic3d_WorldViewProjState& theWVPState); private: diff --git a/src/OpenGl/OpenGl_BVHTreeSelector.cxx b/src/OpenGl/OpenGl_BVHTreeSelector.cxx index 09298ea4cb..0699286700 100644 --- a/src/OpenGl/OpenGl_BVHTreeSelector.cxx +++ b/src/OpenGl/OpenGl_BVHTreeSelector.cxx @@ -122,6 +122,17 @@ void OpenGl_BVHTreeSelector::SetViewVolume (const Handle(Graphic3d_Camera)& theC } } +// ======================================================================= +// function : SetViewportSize +// purpose : +// ======================================================================= +void OpenGl_BVHTreeSelector::SetViewportSize (const Standard_Integer theViewportWidth, + const Standard_Integer theViewportHeight) +{ + myViewportHeight = theViewportHeight; + myViewportWidth = theViewportWidth; +} + // ======================================================================= // function : SignedPlanePointDistance // purpose : diff --git a/src/OpenGl/OpenGl_BVHTreeSelector.hxx b/src/OpenGl/OpenGl_BVHTreeSelector.hxx index c111c21233..4824ddadc4 100644 --- a/src/OpenGl/OpenGl_BVHTreeSelector.hxx +++ b/src/OpenGl/OpenGl_BVHTreeSelector.hxx @@ -33,6 +33,8 @@ public: //! Retrieves view volume's planes equations and its vertices from projection and world-view matrices. Standard_EXPORT void SetViewVolume (const Handle(Graphic3d_Camera)& theCamera); + Standard_EXPORT void SetViewportSize (const Standard_Integer theViewportWidth, const Standard_Integer theViewportHeight); + //! Detects if AABB overlaps view volume using separating axis theorem (SAT). //! @param theMinPt [in] maximum point of AABB. //! @param theMaxPt [in] minimum point of AABB. @@ -56,6 +58,16 @@ public: return myWorldViewMat; } + Standard_Integer ViewportWidth() const + { + return myViewportWidth; + } + + Standard_Integer ViewportHeight() const + { + return myViewportHeight; + } + //! Returns state of current world view projection transformation matrices. const Graphic3d_WorldViewProjState& WorldViewProjState() const { @@ -118,6 +130,9 @@ protected: OpenGl_Mat4 myProjectionMat; OpenGl_Mat4 myWorldViewMat; + Standard_Integer myViewportWidth; + Standard_Integer myViewportHeight; + Graphic3d_WorldViewProjState myWorldViewProjState; //!< State of world view projection matrices. }; diff --git a/src/OpenGl/OpenGl_Layer.cxx b/src/OpenGl/OpenGl_Layer.cxx index 9a5c2de1a7..8b420d76d4 100644 --- a/src/OpenGl/OpenGl_Layer.cxx +++ b/src/OpenGl/OpenGl_Layer.cxx @@ -489,7 +489,10 @@ void OpenGl_Layer::traverse (OpenGl_BVHTreeSelector& theSelector) const const OpenGl_Mat4& aProjection = theSelector.ProjectionMatrix(); const OpenGl_Mat4& aWorldView = theSelector.WorldViewMatrix(); const Graphic3d_WorldViewProjState& aWVPState = theSelector.WorldViewProjState(); - aBVHTree = myBVHPrimitivesTrsfPers.BVH (aProjection, aWorldView, aWVPState); + const Standard_Integer aViewportWidth = theSelector.ViewportWidth(); + const Standard_Integer aViewportHeight = theSelector.ViewportHeight(); + + aBVHTree = myBVHPrimitivesTrsfPers.BVH (aProjection, aWorldView, aViewportWidth, aViewportHeight, aWVPState); } else { diff --git a/src/OpenGl/OpenGl_View_Redraw.cxx b/src/OpenGl/OpenGl_View_Redraw.cxx index 2a0e2d371e..d46965f886 100644 --- a/src/OpenGl/OpenGl_View_Redraw.cxx +++ b/src/OpenGl/OpenGl_View_Redraw.cxx @@ -779,6 +779,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, // Update states of OpenGl_BVHTreeSelector (frustum culling algorithm). myBVHSelector.SetViewVolume (myCamera); + myBVHSelector.SetViewportSize (myWindow->Width(), myWindow->Height()); const Handle(OpenGl_ShaderManager)& aManager = aContext->ShaderManager(); if (StateInfo (myCurrLightSourceState, aManager->LightSourceState().Index()) != myLastLightSourceState) diff --git a/src/PrsMgr/PrsMgr_PresentableObject.hxx b/src/PrsMgr/PrsMgr_PresentableObject.hxx index e1b4db12d5..3b25a15e7d 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.hxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.hxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -133,7 +134,7 @@ public: const gp_Trsf& Transformation() const; - const gp_Trsf& InversedTransformation() const; + const gp_GTrsf& InversedTransformation() const; //! resets local transformation to identity. Standard_EXPORT virtual void ResetTransformation(); @@ -288,7 +289,7 @@ private: PrsMgr_PresentableObjectPointer myParent; gp_Trsf myLocalTransformation; gp_Trsf myTransformation; - gp_Trsf myInvTransformation; + gp_GTrsf myInvTransformation; gp_Trsf myCombinedParentTransform; PrsMgr_ListOfPresentableObjects myChildren; diff --git a/src/PrsMgr/PrsMgr_PresentableObject.lxx b/src/PrsMgr/PrsMgr_PresentableObject.lxx index 8cb9c0f9f1..a3ea557eee 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.lxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.lxx @@ -32,7 +32,7 @@ inline const gp_Trsf& PrsMgr_PresentableObject::Transformation() const return myTransformation; } -inline const gp_Trsf& PrsMgr_PresentableObject::InversedTransformation() const +inline const gp_GTrsf& PrsMgr_PresentableObject::InversedTransformation() const { return myInvTransformation; } diff --git a/src/Select3D/Select3D_SensitiveEntity.cxx b/src/Select3D/Select3D_SensitiveEntity.cxx index f7387c33a2..697b81eec9 100644 --- a/src/Select3D/Select3D_SensitiveEntity.cxx +++ b/src/Select3D/Select3D_SensitiveEntity.cxx @@ -85,7 +85,7 @@ Standard_Boolean Select3D_SensitiveEntity::HasInitLocation() const // purpose : Returns inversed location transformation matrix if the shape corresponding // to this entity has init location set. Otherwise, returns identity matrix. //======================================================================= -gp_Trsf Select3D_SensitiveEntity::InvInitLocation() const +gp_GTrsf Select3D_SensitiveEntity::InvInitLocation() const { - return gp_Trsf(); + return gp_GTrsf(); } diff --git a/src/Select3D/Select3D_SensitiveEntity.hxx b/src/Select3D/Select3D_SensitiveEntity.hxx index b3fd8bdd38..7265e36fdc 100644 --- a/src/Select3D/Select3D_SensitiveEntity.hxx +++ b/src/Select3D/Select3D_SensitiveEntity.hxx @@ -83,7 +83,7 @@ public: //! Returns inversed location transformation matrix if the shape corresponding //! to this entity has init location set. Otherwise, returns identity matrix. - Standard_EXPORT virtual gp_Trsf InvInitLocation() const Standard_OVERRIDE; + Standard_EXPORT virtual gp_GTrsf InvInitLocation() const Standard_OVERRIDE; DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveEntity,SelectBasics_SensitiveEntity) diff --git a/src/Select3D/Select3D_SensitivePrimitiveArray.hxx b/src/Select3D/Select3D_SensitivePrimitiveArray.hxx index 4e858efe18..0c3402efb3 100644 --- a/src/Select3D/Select3D_SensitivePrimitiveArray.hxx +++ b/src/Select3D/Select3D_SensitivePrimitiveArray.hxx @@ -208,7 +208,7 @@ public: //! Returns inversed location transformation matrix if the shape corresponding //! to this entity has init location set. Otherwise, returns identity matrix. - virtual gp_Trsf InvInitLocation() const Standard_OVERRIDE + virtual gp_GTrsf InvInitLocation() const Standard_OVERRIDE { return myInvInitLocation; } @@ -261,7 +261,7 @@ private: gp_Pnt myCDG3D; //!< Center of the whole triangulation Select3D_BVHIndexBuffer myBvhIndices; //!< Indexes of edges or triangles for BVH tree mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the whole triangulation - gp_Trsf myInvInitLocation; + gp_GTrsf myInvInitLocation; Standard_Real myMinDepthElem; //!< the depth of nearest detected element Standard_Real myMinDepthNode; //!< the depth of nearest detected node Standard_Real myMinDepthEdge; //!< the depth of nearest detected edge diff --git a/src/Select3D/Select3D_SensitiveTriangulation.cxx b/src/Select3D/Select3D_SensitiveTriangulation.cxx index 3341f74299..88543d5ecd 100644 --- a/src/Select3D/Select3D_SensitiveTriangulation.cxx +++ b/src/Select3D/Select3D_SensitiveTriangulation.cxx @@ -429,7 +429,7 @@ Standard_Boolean Select3D_SensitiveTriangulation::HasInitLocation() const //function : InvInitLocation //purpose : //======================================================================= -gp_Trsf Select3D_SensitiveTriangulation::InvInitLocation() const +gp_GTrsf Select3D_SensitiveTriangulation::InvInitLocation() const { return myInvInitLocation; } diff --git a/src/Select3D/Select3D_SensitiveTriangulation.hxx b/src/Select3D/Select3D_SensitiveTriangulation.hxx index fd1f6a3451..5f212cdd54 100644 --- a/src/Select3D/Select3D_SensitiveTriangulation.hxx +++ b/src/Select3D/Select3D_SensitiveTriangulation.hxx @@ -106,7 +106,7 @@ public: //! Returns inversed location transformation matrix if the shape corresponding //! to this entity has init location set. Otherwise, returns identity matrix. - Standard_EXPORT virtual gp_Trsf InvInitLocation() const Standard_OVERRIDE; + Standard_EXPORT virtual gp_GTrsf InvInitLocation() const Standard_OVERRIDE; inline const TopLoc_Location& GetInitLocation() const; @@ -144,7 +144,7 @@ private: Standard_Integer myPrimitivesNb; //!< Amount of free edges or triangles depending on sensitivity type Handle(TColStd_HArray1OfInteger) myBVHPrimIndexes; //!< Indexes of edges or triangles for BVH build mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the whole triangulation - gp_Trsf myInvInitLocation; + gp_GTrsf myInvInitLocation; }; DEFINE_STANDARD_HANDLE(Select3D_SensitiveTriangulation, Select3D_SensitiveSet) diff --git a/src/SelectBasics/SelectBasics_SensitiveEntity.hxx b/src/SelectBasics/SelectBasics_SensitiveEntity.hxx index 9d6da1db66..d4d1431074 100644 --- a/src/SelectBasics/SelectBasics_SensitiveEntity.hxx +++ b/src/SelectBasics/SelectBasics_SensitiveEntity.hxx @@ -17,6 +17,7 @@ #ifndef _SelectBasics_SensitiveEntity_HeaderFile #define _SelectBasics_SensitiveEntity_HeaderFile +#include #include #include @@ -83,7 +84,7 @@ public: //! Returns inversed location transformation matrix if the shape corresponding //! to this entity has init location set. Otherwise, returns identity matrix. - virtual gp_Trsf InvInitLocation() const = 0; + virtual gp_GTrsf InvInitLocation() const = 0; DEFINE_STANDARD_RTTIEXT(SelectBasics_SensitiveEntity,MMgt_TShared) diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.cxx b/src/SelectMgr/SelectMgr_BaseFrustum.cxx index 3508da72b1..cf1066390f 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.cxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.cxx @@ -117,6 +117,16 @@ void SelectMgr_BaseFrustum::SetWindowSize (const Standard_Integer theWidth, cons myBuilder->SetWindowSize (theWidth, theHeight); } +//======================================================================= +// function : WindowSize +// purpose : +//======================================================================= +void SelectMgr_BaseFrustum::WindowSize (Standard_Integer& theWidth, + Standard_Integer& theHeight) +{ + myBuilder->WindowSize (theWidth, theHeight); +} + //======================================================================= // function : SetBuilder // purpose : diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.hxx b/src/SelectMgr/SelectMgr_BaseFrustum.hxx index 62e7de617d..5855c6db1e 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.hxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.hxx @@ -16,6 +16,7 @@ #ifndef _SelectMgr_BaseFrustum_HeaderFile #define _SelectMgr_BaseFrustum_HeaderFile +#include #include #include @@ -70,6 +71,9 @@ public: Standard_EXPORT void SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight); + Standard_EXPORT void WindowSize (Standard_Integer& theWidth, + Standard_Integer& theHeight); + //! Passes viewport parameters to builder Standard_EXPORT void SetViewport (const Standard_Real theX, const Standard_Real theY, @@ -102,8 +106,8 @@ public: //! There are no default parameters, but in case if: //! - transformation only is needed: @theScaleFactor must be initialized as any negative value; //! - scale only is needed: @theTrsf must be set to gp_Identity. - virtual NCollection_Handle ScaleAndTransform (const Standard_Integer /*theScaleFactor*/, - const gp_Trsf& /*theTrsf*/) { return NULL; } + Standard_EXPORT virtual NCollection_Handle ScaleAndTransform (const Standard_Integer /*theScaleFactor*/, + const gp_GTrsf& /*theTrsf*/) { return NULL; } //! SAT intersection test between defined volume and given axis-aligned box Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin, diff --git a/src/SelectMgr/SelectMgr_FrustumBuilder.cxx b/src/SelectMgr/SelectMgr_FrustumBuilder.cxx index 26138fcb94..75447a823d 100644 --- a/src/SelectMgr/SelectMgr_FrustumBuilder.cxx +++ b/src/SelectMgr/SelectMgr_FrustumBuilder.cxx @@ -114,6 +114,17 @@ void SelectMgr_FrustumBuilder::SetViewport (const Standard_Real theX, myIsViewportSet = Standard_True; } +//======================================================================= +// function : WindowSize +// purpose : +//======================================================================= +void SelectMgr_FrustumBuilder::WindowSize (Standard_Integer& theWidth, + Standard_Integer& theHeight) +{ + theWidth = myWidth; + theHeight = myHeight; +} + //======================================================================= // function : InvalidateViewport // purpose : diff --git a/src/SelectMgr/SelectMgr_FrustumBuilder.hxx b/src/SelectMgr/SelectMgr_FrustumBuilder.hxx index c4708acea1..c490aad4f1 100644 --- a/src/SelectMgr/SelectMgr_FrustumBuilder.hxx +++ b/src/SelectMgr/SelectMgr_FrustumBuilder.hxx @@ -62,6 +62,9 @@ public: Standard_EXPORT void InvalidateViewport(); + Standard_EXPORT void WindowSize (Standard_Integer& theWidth, + Standard_Integer& theHeight); + //! Calculates signed distance between plane with equation //! theEq and point thePnt Standard_EXPORT Standard_Real SignedPlanePntDist (const SelectMgr_Vec3& theEq, diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx index 664d3d4387..fe2c835c65 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx @@ -323,7 +323,7 @@ void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d& theMinPnt, // - scale only is needed: @theTrsf must be set to gp_Identity. // ======================================================================= NCollection_Handle SelectMgr_RectangularFrustum::ScaleAndTransform (const Standard_Integer theScaleFactor, - const gp_Trsf& theTrsf) + const gp_GTrsf& theTrsf) { Standard_ASSERT_RAISE (theScaleFactor > 0, "Error! Pixel tolerance for selection should be greater than zero"); @@ -357,26 +357,24 @@ NCollection_Handle SelectMgr_RectangularFrustum::ScaleAnd if (isToTrsf) { - aRes->myNearPickedPnt = aRef->myNearPickedPnt.Transformed (theTrsf); - aRes->myFarPickedPnt = aRef->myFarPickedPnt.Transformed (theTrsf); + const Standard_Real aRefScale = aRef->myFarPickedPnt.SquareDistance (aRef->myNearPickedPnt); + + gp_Pnt aPoint = aRef->myNearPickedPnt; + theTrsf.Transforms (aPoint.ChangeCoord()); + aRes->myNearPickedPnt = aPoint; + + aPoint.SetXYZ (aRef->myFarPickedPnt.XYZ()); + theTrsf.Transforms (aPoint.ChangeCoord()); + aRes->myFarPickedPnt = aPoint; + aRes->myViewRayDir = aRes->myFarPickedPnt.XYZ() - aRes->myNearPickedPnt.XYZ(); - // LeftTopNear - aRes->myVertices[0] = aRef->myVertices[0].Transformed (theTrsf); - // LeftTopFar - aRes->myVertices[1] = aRef->myVertices[1].Transformed (theTrsf); - // LeftBottomNear - aRes->myVertices[2] = aRef->myVertices[2].Transformed (theTrsf); - // LeftBottomFar - aRes->myVertices[3] = aRef->myVertices[3].Transformed (theTrsf); - // RightTopNear - aRes->myVertices[4] = aRef->myVertices[4].Transformed (theTrsf); - // RightTopFar - aRes->myVertices[5] = aRef->myVertices[5].Transformed (theTrsf); - // RightBottomNear - aRes->myVertices[6] = aRef->myVertices[6].Transformed (theTrsf); - // RightBottomFar - aRes->myVertices[7] = aRef->myVertices[7].Transformed (theTrsf); + for (Standard_Integer anIt = 0; anIt < 8; anIt++) + { + aPoint = aRef->myVertices[anIt]; + theTrsf.Transforms (aPoint.ChangeCoord()); + aRes->myVertices[anIt] = aPoint; + } // Horizontal aRes->myEdgeDirs[0] = aRes->myVertices[4].XYZ() - aRes->myVertices[0].XYZ(); @@ -391,7 +389,8 @@ NCollection_Handle SelectMgr_RectangularFrustum::ScaleAnd // RightUpper aRes->myEdgeDirs[5] = aRes->myVertices[4].XYZ() - aRes->myVertices[5].XYZ(); - aRes->myScale = 1.0 / theTrsf.ScaleFactor(); + // Compute scale to transform depth from local coordinate system to world coordinate system + aRes->myScale = Sqrt (aRefScale / aRes->myFarPickedPnt.SquareDistance (aRes->myNearPickedPnt)); } // compute frustum normals diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx index 9cf9c12173..de30a13fa8 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx @@ -51,7 +51,7 @@ public: //! - transformation only is needed: @theScaleFactor must be initialized as any negative value; //! - scale only is needed: @theTrsf must be set to gp_Identity. Standard_EXPORT virtual NCollection_Handle ScaleAndTransform (const Standard_Integer theScaleFactor, - const gp_Trsf& theTrsf) Standard_OVERRIDE; + const gp_GTrsf& theTrsf) Standard_OVERRIDE; // SAT Tests for different objects diff --git a/src/SelectMgr/SelectMgr_SelectableObjectTrsfPersSet.cxx b/src/SelectMgr/SelectMgr_SelectableObjectTrsfPersSet.cxx index facee7e905..47faa725df 100644 --- a/src/SelectMgr/SelectMgr_SelectableObjectTrsfPersSet.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObjectTrsfPersSet.cxx @@ -119,6 +119,8 @@ Standard_Boolean SelectMgr_SelectableObjectTrsfPersSet::Remove (const Handle(Sel const NCollection_Handle >& SelectMgr_SelectableObjectTrsfPersSet::BVH (const Graphic3d_Mat4d& theProjectionMatrix, const Graphic3d_Mat4d& theWorldViewMatrix, + const Standard_Integer theViewportWidth, + const Standard_Integer theViewportHeight, const Graphic3d_WorldViewProjState& theWVPState) { if (!myIsDirty && (myObjectBoxesState.IsValid() && !myObjectBoxesState.IsChanged(theWVPState))) @@ -139,7 +141,7 @@ const NCollection_Handle >& anObject->BoundingBox (aBoundingBox); if (!aBoundingBox.IsVoid()) { - anObject->TransformPersistence().Apply (theProjectionMatrix, theWorldViewMatrix, 0, 0, aBoundingBox); + anObject->TransformPersistence().Apply (theProjectionMatrix, theWorldViewMatrix, theViewportWidth, theViewportHeight, aBoundingBox); } } diff --git a/src/SelectMgr/SelectMgr_SelectableObjectTrsfPersSet.hxx b/src/SelectMgr/SelectMgr_SelectableObjectTrsfPersSet.hxx index 5c3aa43bff..94ccfc9e6d 100644 --- a/src/SelectMgr/SelectMgr_SelectableObjectTrsfPersSet.hxx +++ b/src/SelectMgr/SelectMgr_SelectableObjectTrsfPersSet.hxx @@ -87,6 +87,8 @@ public: //! Returns BVH tree for the given world view projection (builds it if necessary). Standard_EXPORT const NCollection_Handle >& BVH (const Graphic3d_Mat4d& theProjectionMatrix, const Graphic3d_Mat4d& theWorldViewMatrix, + const Standard_Integer theViewportWidth, + const Standard_Integer theViewportHeight, const Graphic3d_WorldViewProjState& theWVPState); private: diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx index 658900ed6f..8e975930d5 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx @@ -44,7 +44,7 @@ SelectMgr_SelectingVolumeManager::SelectMgr_SelectingVolumeManager (Standard_Boo // - scale only is needed: @theTrsf must be set to gp_Identity. //======================================================================= SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::ScaleAndTransform (const Standard_Integer theScaleFactor, - const gp_Trsf& theTrsf) + const gp_GTrsf& theTrsf) { SelectMgr_SelectingVolumeManager aMgr (Standard_False); @@ -137,6 +137,15 @@ const Graphic3d_WorldViewProjState& SelectMgr_SelectingVolumeManager::WorldViewP return mySelectingVolumes[Frustum]->WorldViewProjState(); } +//======================================================================= +// function : WindowSize +// purpose : +//======================================================================= +void SelectMgr_SelectingVolumeManager::WindowSize (Standard_Integer& theWidth, Standard_Integer& theHeight) +{ + mySelectingVolumes[Frustum]->WindowSize (theWidth, theHeight); +} + //======================================================================= // function : SetCamera // purpose : Updates viewport in all selecting volumes diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx index ac018e6fed..2900186a5f 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx @@ -47,7 +47,7 @@ public: //! - transformation only is needed: @theScaleFactor must be initialized as any negative value; //! - scale only is needed: @theTrsf must be set to gp_Identity. Standard_EXPORT virtual SelectMgr_SelectingVolumeManager ScaleAndTransform (const Standard_Integer theScaleFactor, - const gp_Trsf& theTrsf); + const gp_GTrsf& theTrsf); Standard_EXPORT virtual Standard_Integer GetActiveSelectionType() const Standard_OVERRIDE; @@ -68,6 +68,8 @@ public: //! @return current world view transformation common for all selecting volumes Standard_EXPORT const Graphic3d_Mat4d& WorldViewMatrix() const; + Standard_EXPORT void WindowSize (Standard_Integer& theWidth, Standard_Integer& theHeight); + //! @return current camera world view projection transformation state common for all selecting volumes Standard_EXPORT const Graphic3d_WorldViewProjState& WorldViewProjState() const; diff --git a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx index 79b02a1fc6..d67f7c788c 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx @@ -129,22 +129,16 @@ void SelectMgr_TriangularFrustum::Build (const gp_Pnt2d& theP1, // - scale only is needed: @theTrsf must be set to gp_Identity. //======================================================================= NCollection_Handle SelectMgr_TriangularFrustum::ScaleAndTransform (const Standard_Integer /*theScale*/, - const gp_Trsf& theTrsf) + const gp_GTrsf& theTrsf) { SelectMgr_TriangularFrustum* aRes = new SelectMgr_TriangularFrustum(); - // V0_Near - aRes->myVertices[0] = myVertices[0].Transformed (theTrsf); - // V1_Near - aRes->myVertices[1] = myVertices[1].Transformed (theTrsf); - // V2_Near - aRes->myVertices[2] = myVertices[2].Transformed (theTrsf); - // V0_Far - aRes->myVertices[3] = myVertices[3].Transformed (theTrsf); - // V1_Far - aRes->myVertices[4] = myVertices[4].Transformed (theTrsf); - // V2_Far - aRes->myVertices[5] = myVertices[5].Transformed (theTrsf); + for (Standard_Integer anIt = 0; anIt < 6; anIt++) + { + gp_Pnt aPoint = myVertices[anIt]; + theTrsf.Transforms (aPoint.ChangeCoord()); + aRes->myVertices[anIt] = aPoint; + } aRes->myIsOrthographic = myIsOrthographic; diff --git a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx index ceb104f378..3e6c8da7b1 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx @@ -41,7 +41,7 @@ public: //! Returns a copy of the frustum transformed according to the matrix given Standard_EXPORT virtual NCollection_Handle ScaleAndTransform (const Standard_Integer theScale, - const gp_Trsf& theTrsf) Standard_OVERRIDE; + const gp_GTrsf& theTrsf) Standard_OVERRIDE; // SAT Tests for different objects diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx index c5d8c9fb9d..efce1f80dd 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx @@ -109,7 +109,7 @@ void SelectMgr_TriangularFrustumSet::Build (const TColgp_Array1OfPnt2d& thePoint // - scale only is needed: @theTrsf must be set to gp_Identity. // ======================================================================= NCollection_Handle SelectMgr_TriangularFrustumSet::ScaleAndTransform (const Standard_Integer theScale, - const gp_Trsf& theTrsf) + const gp_GTrsf& theTrsf) { SelectMgr_TriangularFrustumSet* aRes = new SelectMgr_TriangularFrustumSet(); diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx index baad601daf..474bb355fa 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx @@ -48,7 +48,7 @@ public: //! Returns a copy of the frustum with all sub-volumes transformed according to the matrix given Standard_EXPORT virtual NCollection_Handle ScaleAndTransform (const Standard_Integer theScale, - const gp_Trsf& theTrsf) Standard_OVERRIDE; + const gp_GTrsf& theTrsf) Standard_OVERRIDE; Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt, const SelectMgr_Vec3& theMaxPnt, diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 1e2d3d9e2b..ecc735b004 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -19,6 +19,7 @@ // AGV OCT/23/03 : Optimize the method SortResult() (OCC4201) #include +#include #include #include #include @@ -267,12 +268,12 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive // necessary calculations //======================================================================= void SelectMgr_ViewerSelector::computeFrustum (const Handle(SelectBasics_SensitiveEntity)& theEnt, - const gp_Trsf& theInvTrsf, + const gp_GTrsf& theInvTrsf, SelectMgr_FrustumCache& theCachedMgrs, SelectMgr_SelectingVolumeManager& theResMgr) { Standard_Integer aScale = isToScaleFrustum (theEnt) ? sensitivity (theEnt) : 1; - const gp_Trsf aTrsfMtr = theEnt->HasInitLocation() ? theEnt->InvInitLocation() * theInvTrsf : theInvTrsf; + const gp_GTrsf aTrsfMtr = theEnt->HasInitLocation() ? theEnt->InvInitLocation() * theInvTrsf : theInvTrsf; const Standard_Boolean toScale = aScale != 1; const Standard_Boolean toTransform = aTrsfMtr.Form() != gp_Identity; if (toScale && toTransform) @@ -309,7 +310,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable const NCollection_Handle >& aSensitivesTree = anEntitySet->BVH(); - gp_Trsf aInversedTrsf; + gp_GTrsf aInversedTrsf; if (theObject->HasTransformation() || theObject->TransformPersistence().Flags) { @@ -321,14 +322,24 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable { const Graphic3d_Mat4d& aProjection = mySelectingVolumeMgr.ProjectionMatrix(); const Graphic3d_Mat4d& aWorldView = mySelectingVolumeMgr.WorldViewMatrix(); + Standard_Integer aViewportWidth; + Standard_Integer aViewportHeight; + mySelectingVolumeMgr.WindowSize (aViewportWidth, aViewportHeight); - gp_Trsf aTPers; - Graphic3d_Mat4d aMat = theObject->TransformPersistence().Compute (aProjection, aWorldView, 0, 0); - aTPers.SetValues (aMat.GetValue (0, 0), aMat.GetValue (0, 1), aMat.GetValue (0, 2), aMat.GetValue (0, 3), - aMat.GetValue (1, 0), aMat.GetValue (1, 1), aMat.GetValue (1, 2), aMat.GetValue (1, 3), - aMat.GetValue (2, 0), aMat.GetValue (2, 1), aMat.GetValue (2, 2), aMat.GetValue (2, 3)); + gp_GTrsf aTPers; + Graphic3d_Mat4d aMat = theObject->TransformPersistence().Compute (aProjection, aWorldView, aViewportWidth, aViewportHeight); + aTPers.SetValue (1, 1, aMat.GetValue (0, 0)); + aTPers.SetValue (1, 2, aMat.GetValue (0, 1)); + aTPers.SetValue (1, 3, aMat.GetValue (0, 2)); + aTPers.SetValue (2, 1, aMat.GetValue (1, 0)); + aTPers.SetValue (2, 2, aMat.GetValue (1, 1)); + aTPers.SetValue (2, 3, aMat.GetValue (1, 2)); + aTPers.SetValue (3, 1, aMat.GetValue (2, 0)); + aTPers.SetValue (3, 2, aMat.GetValue (2, 1)); + aTPers.SetValue (3, 3, aMat.GetValue (2, 2)); + aTPers.SetTranslationPart (gp_XYZ (aMat.GetValue (0, 3), aMat.GetValue (1, 3), aMat.GetValue (2, 3))); - aInversedTrsf = (aTPers * theObject->Transformation()).Inverted(); + aInversedTrsf = (aTPers * gp_GTrsf (theObject->Transformation())).Inverted(); } } @@ -429,7 +440,10 @@ void SelectMgr_ViewerSelector::TraverseSensitives() const Graphic3d_Mat4d& aProjection = mySelectingVolumeMgr.ProjectionMatrix(); const Graphic3d_Mat4d& aWorldView = mySelectingVolumeMgr.WorldViewMatrix(); const Graphic3d_WorldViewProjState& aWVPState = mySelectingVolumeMgr.WorldViewProjState(); - aBVHTree = mySelectableObjectsTrsfPers.BVH (aProjection, aWorldView, aWVPState); + Standard_Integer aViewportWidth; + Standard_Integer aViewportHeight; + mySelectingVolumeMgr.WindowSize (aViewportWidth, aViewportHeight); + aBVHTree = mySelectableObjectsTrsfPers.BVH (aProjection, aWorldView, aViewportWidth, aViewportHeight, aWVPState); } else { @@ -842,9 +856,12 @@ void SelectMgr_ViewerSelector::RebuildObjectsTree (const Standard_Boolean theIsF const Graphic3d_Mat4d& aProjection = mySelectingVolumeMgr.ProjectionMatrix(); const Graphic3d_Mat4d& aWorldView = mySelectingVolumeMgr.WorldViewMatrix(); const Graphic3d_WorldViewProjState& aWVPState = mySelectingVolumeMgr.WorldViewProjState(); + Standard_Integer aViewportWidth; + Standard_Integer aViewportHeight; + mySelectingVolumeMgr.WindowSize (aViewportWidth, aViewportHeight); mySelectableObjects.BVH(); - mySelectableObjectsTrsfPers.BVH (aProjection, aWorldView, aWVPState); + mySelectableObjectsTrsfPers.BVH (aProjection, aWorldView, aViewportWidth, aViewportHeight, aWVPState); } } diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.hxx b/src/SelectMgr/SelectMgr_ViewerSelector.hxx index 15a42716fe..c7ff4f4fd0 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.hxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.hxx @@ -310,10 +310,11 @@ private: //! needs to be scaled and transformed for the entity and performs //! necessary calculations void computeFrustum (const Handle(SelectBasics_SensitiveEntity)& theEnt, - const gp_Trsf& theInvTrsf, + const gp_GTrsf& theInvTrsf, SelectMgr_FrustumCache& theCachedMgrs, SelectMgr_SelectingVolumeManager& theResMgr); + protected: Standard_Boolean preferclosest; diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index af89e21f50..a216866317 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -4449,16 +4449,27 @@ static Standard_Integer VState (Draw_Interpretor& theDI, const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->DetectedEntity(); Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId()); Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); - gp_Trsf anInvTrsf; + gp_GTrsf anInvTrsf; if (anObj->TransformPersistence().Flags) { const Graphic3d_Mat4d& aProjection = aMgr.ProjectionMatrix(); const Graphic3d_Mat4d& aWorldView = aMgr.WorldViewMatrix(); + Standard_Integer aViewportWidth = 0; + Standard_Integer aViewportHeight = 0; + aMgr.WindowSize (aViewportWidth, aViewportHeight); - Graphic3d_Mat4d aMat = anObj->TransformPersistence().Compute (aProjection, aWorldView, 0, 0); - anInvTrsf.SetValues (aMat.GetValue (0, 0), aMat.GetValue (0, 1), aMat.GetValue (0, 2), aMat.GetValue (0, 3), - aMat.GetValue (1, 0), aMat.GetValue (1, 1), aMat.GetValue (1, 2), aMat.GetValue (1, 3), - aMat.GetValue (2, 0), aMat.GetValue (2, 1), aMat.GetValue (2, 2), aMat.GetValue (2, 3)); + Graphic3d_Mat4d aMat = anObj->TransformPersistence().Compute (aProjection, aWorldView, aViewportWidth, aViewportHeight); + + anInvTrsf.SetValue (1, 1, aMat.GetValue (0, 0)); + anInvTrsf.SetValue (1, 2, aMat.GetValue (0, 1)); + anInvTrsf.SetValue (1, 3, aMat.GetValue (0, 2)); + anInvTrsf.SetValue (2, 1, aMat.GetValue (1, 0)); + anInvTrsf.SetValue (2, 2, aMat.GetValue (1, 1)); + anInvTrsf.SetValue (2, 3, aMat.GetValue (1, 2)); + anInvTrsf.SetValue (3, 1, aMat.GetValue (2, 0)); + anInvTrsf.SetValue (3, 2, aMat.GetValue (2, 1)); + anInvTrsf.SetValue (3, 3, aMat.GetValue (2, 2)); + anInvTrsf.SetTranslationPart (gp_XYZ(aMat.GetValue (0, 3), aMat.GetValue (1, 3), aMat.GetValue (2, 3))); anInvTrsf.Invert(); } if (anObj->HasTransformation()) @@ -4477,8 +4488,13 @@ static Standard_Integer VState (Draw_Interpretor& theDI, : aMgr; SelectBasics_PickResult aResult; anEntity->Matches (anEntMgr, aResult); - gp_Pnt aDetectedPnt = anInvTrsf.Form() == gp_Identity ? - anEntMgr.DetectedPoint (aResult.Depth()) : anEntMgr.DetectedPoint (aResult.Depth()).Transformed (anInvTrsf.Inverted()); + + gp_Pnt aDetectedPnt = anEntMgr.DetectedPoint (aResult.Depth()); + + if (anInvTrsf.Form() != gp_Identity) + { + anInvTrsf.Inverted().Transforms (aDetectedPnt.ChangeCoord()); + } TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj); aName.LeftJustify (20, ' '); diff --git a/tests/bugs/vis/bug25867 b/tests/bugs/vis/bug25867 index 1b022d0fc0..23e0be8823 100644 --- a/tests/bugs/vis/bug25867 +++ b/tests/bugs/vis/bug25867 @@ -10,7 +10,7 @@ set anImage1 $imagedir/${casename}_1.png set anImage2 $imagedir/${casename}_2.png vinit box b1 -1 -1 -1 3 3 3 -box b2 4 4 4 30 20 20 +box b2 4 4 4 15 10 10 vdisplay b1 vdisplay b2 -trsfPers zoom -trsfPersPos 0 0 0 vfit diff --git a/tests/bugs/vis/bug26344 b/tests/bugs/vis/bug26344 index 3f7acd38b4..8b7ddd40d8 100644 --- a/tests/bugs/vis/bug26344 +++ b/tests/bugs/vis/bug26344 @@ -11,8 +11,8 @@ vinit View1 w=409 h=409 vtrihedron tri vpan 50 50 -box b1 50 50 50 -box b2 50 50 50 +box b1 25 25 25 +box b2 25 25 25 box b3 100 100 100 box b4 100 100 100 box b5 100 100 100 @@ -22,7 +22,7 @@ vpoint p1 200 200 200 vdisplay b1 -trsfPers zoom -trsfPersPos 200 200 200 vdisplay b2 -trsfPers zoom -trsfPersPos 200 200 200 -vsetlocation b2 -50 -50 -50 +vsetlocation b2 -25 -25 -25 vmoveto 384 78 if { ![checkcolor 384 78 0 1 1] } { diff --git a/tests/bugs/vis/bug26719_1 b/tests/bugs/vis/bug26719_1 index 00c5afd051..6a8b01f724 100644 --- a/tests/bugs/vis/bug26719_1 +++ b/tests/bugs/vis/bug26719_1 @@ -14,7 +14,7 @@ vsetdispmode 1 restore [locate_data_file face1.brep] f vdisplay f -box b1 50 50 50 +box b1 25 25 25 vdisplay b1 -trsfPers zoom -trsfPersPos 0 0 0 vviewparams -scale 588.7 -proj 0.69 -0.64 -0.38 @@ -25,7 +25,7 @@ vviewparams -eye 0.7 -1.14 -0.17 # with dynamic highlight color, check that the face is # not highlighted vmoveto 280 290 -if {[vreadpixel 290 297 name] != "CYAN1 1"} { +if {[vreadpixel 297 297 name] != "CYAN1 1"} { puts "ERROR: zoom persistent box is not highlighted dynamically!" } if {[vreadpixel 372 210 name] != "GOLDENROD1 1"} { @@ -45,7 +45,8 @@ vviewparams -eye 0.96 1.053 0.31 # move to a point on the box and check if it # will be highlighted dynamically vmoveto 264 135 -if {[vreadpixel 276 142 name] != "CYAN1 1"} { + +if {[vreadpixel 275 142 name] != "CYAN1 1"} { puts "ERROR: zoom persistent box is not highlighted dynamically in precision test!" } if {[vreadpixel 243 123 name] != "LIGHTGOLDENROD1 1"} { @@ -56,8 +57,8 @@ vmoveto 0 0 # move to a point on the face and check if it # will be highlighted dynamically -vmoveto 263 135 -if {[vreadpixel 276 142 name] != "GOLDENROD2 1"} { +vmoveto 259 135 +if {[vreadpixel 275 142 name] != "GOLDENROD3 1"} { puts "ERROR: zoom persistent box is highlighted instead in precision test!" } if {[vreadpixel 243 123 name] != "CYAN1 1"} { diff --git a/tests/bugs/vis/bug26719_2 b/tests/bugs/vis/bug26719_2 index 8e8de971a7..b4fa9ef8be 100644 --- a/tests/bugs/vis/bug26719_2 +++ b/tests/bugs/vis/bug26719_2 @@ -37,15 +37,15 @@ vinit vtrihedron tri vpan 50 50 -box b1 50 50 50 -box b2 50 50 50 +box b1 20.3 20.3 20.3 +box b2 20.3 20.3 20.3 box b3 150 150 150 100 100 100 vpoint p1 200 200 200 vdisplay b1 -trsfPers zoom -trsfPersPos 200 200 200 vdisplay b2 -trsfPers zoom -trsfPersPos 200 200 200 -vsetlocation b2 -50 -50 -50 +vsetlocation b2 -20.3 -20.3 -20.3 vdisplay b3 vsetdispmode 1 diff --git a/tests/bugs/vis/bug26792 b/tests/bugs/vis/bug26792 index 3e0b208ca7..c8614a3a51 100644 --- a/tests/bugs/vis/bug26792 +++ b/tests/bugs/vis/bug26792 @@ -8,14 +8,14 @@ vinit vclear vaxo -box b 100 100 100 +box b 50 50 50 vdisplay b -trsfPers zoom vzoom 0.01 vzfit checkcolor 204 184 1.0 1.0 0.0 -checkcolor 232 205 1.0 1.0 0.0 -checkcolor 262 182 1.0 1.0 0.0 -checkcolor 233 184 1.0 1.0 0.0 +checkcolor 238 205 1.0 1.0 0.0 +checkcolor 275 182 1.0 1.0 0.0 +checkcolor 239 184 1.0 1.0 0.0 checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/vis/bug27536 b/tests/bugs/vis/bug27536 new file mode 100644 index 0000000000..aee57ff133 --- /dev/null +++ b/tests/bugs/vis/bug27536 @@ -0,0 +1,30 @@ +puts "========" +puts "OCC27536" +puts "========" +puts "" +################################################################## +puts "Visualization - incorrect behavior of zoom persisted objects" +################################################################## + +set anImage1 $imagedir/${casename}_1.png +set anImage2 $imagedir/${casename}_2.png + +vinit +vclear +vaxo + +box b -50 -50 -50 100 100 100 +vdisplay b -trsfPers zoom -trsfPersPos 0 0 0 -dispmode 1 + +vdump $anImage1 + +vinit View2 w=200 h=400 +vaxo +vfit + +# Check that box was't resized in small view +if {[vreadpixel 165 200 name] != "DARKGOLDENROD3 1"} { + puts "ERROR: zoom persistent box is resized on view sizes changed!" +} + +vdump $anImage2 diff --git a/tests/v3d/manipulator/rotate b/tests/v3d/manipulator/rotate index 92f67fdbb2..d99535f2b5 100644 --- a/tests/v3d/manipulator/rotate +++ b/tests/v3d/manipulator/rotate @@ -37,7 +37,7 @@ vfit # attach manipulator # ------------------ -vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 +vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40 # ---------------------------------------------------- # test rotation around x axis (object reference frame) @@ -104,7 +104,7 @@ vsetdispmode 1 vaxo vfit -vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 +vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40 vmanipulator m -followRotation 0 # --------------------------------------------------- diff --git a/tests/v3d/manipulator/scale b/tests/v3d/manipulator/scale index 85ddaa1c98..1447c255dc 100644 --- a/tests/v3d/manipulator/scale +++ b/tests/v3d/manipulator/scale @@ -34,7 +34,7 @@ vfit # attach manipulator # ------------------ -vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 +vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40 # -------------------------- # test hilight and detection diff --git a/tests/v3d/manipulator/translate b/tests/v3d/manipulator/translate index 159651ee9d..b116ec6909 100644 --- a/tests/v3d/manipulator/translate +++ b/tests/v3d/manipulator/translate @@ -33,7 +33,7 @@ vfit # attach manipulator # ------------------ -vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 +vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40 vmanipulator m -followRotation 1 vmanipulator m -followTranslation 1 @@ -100,7 +100,7 @@ vfit # attach manipulator and rotate around z axis # ------------------------------------------- -vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 +vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40 vmanipulator m -followRotation 1 vmanipulator m -followTranslation 1 diff --git a/tests/v3d/manipulator/zoom_persistence b/tests/v3d/manipulator/zoom_persistence index 31bc3562fd..22f53c0bf0 100644 --- a/tests/v3d/manipulator/zoom_persistence +++ b/tests/v3d/manipulator/zoom_persistence @@ -58,7 +58,7 @@ vdump $anImage3 vfit -vmanipulator m2 -attach b2 -adjustPosition 1 -adjustSize 0 -enableModes 1 -zoomable 0 -size 100 +vmanipulator m2 -attach b2 -adjustPosition 1 -adjustSize 0 -enableModes 1 -zoomable 0 -size 40 set mouse_pick_1 {341 283} set mouse_pick_2 {277 246}