From 938d454409bac079494dfe2b3d186bcb0911606c Mon Sep 17 00:00:00 2001 From: aba Date: Thu, 21 Nov 2013 17:24:09 +0400 Subject: [PATCH] 0024288: Provide flipping text for AIS_Dimensions - OpenGl_Flipper class added to provide text flipping. - Added Graphic3d_Mat4, OpenGl_Mat4 definitions for use with TKOpenGl matrix types. - Added flipping parameters for dimensions with 3D text labels at AIS_Dimension class. - Test cases. --- src/AIS/AIS_Dimension.cxx | 3 + src/Graphic3d/FILES | 1 + src/Graphic3d/Graphic3d.cdl | 2 + src/Graphic3d/Graphic3d_GraphicDriver.cdl | 10 +- src/Graphic3d/Graphic3d_Group.cdl | 8 +- src/Graphic3d/Graphic3d_Group_13.cxx | 25 ++++ src/Graphic3d/Graphic3d_Mat4.hxx | 27 ++++ src/Graphic3d/Graphic3d_Vec.hxx | 1 + src/NCollection/NCollection_Mat4.hxx | 34 +++-- src/NCollection/NCollection_Vec2.hxx | 9 +- src/NCollection/NCollection_Vec3.hxx | 7 +- src/NCollection/NCollection_Vec4.hxx | 7 +- src/OpenGl/FILES | 2 + src/OpenGl/OpenGl_Flipper.cxx | 144 ++++++++++++++++++++++ src/OpenGl/OpenGl_Flipper.hxx | 64 ++++++++++ src/OpenGl/OpenGl_GraphicDriver.cxx | 15 ++- src/OpenGl/OpenGl_GraphicDriver.hxx | 3 +- src/OpenGl/OpenGl_Vec.hxx | 3 + src/TKOpenGl/EXTERNLIB | 1 + tests/bugs/vis/bug24288_1 | 46 +++++++ tests/bugs/vis/bug24288_2 | 46 +++++++ tests/bugs/vis/bug24288_3 | 46 +++++++ 22 files changed, 480 insertions(+), 24 deletions(-) create mode 100644 src/Graphic3d/Graphic3d_Mat4.hxx create mode 100644 src/OpenGl/OpenGl_Flipper.cxx create mode 100644 src/OpenGl/OpenGl_Flipper.hxx create mode 100644 tests/bugs/vis/bug24288_1 create mode 100644 tests/bugs/vis/bug24288_2 create mode 100644 tests/bugs/vis/bug24288_3 diff --git a/src/AIS/AIS_Dimension.cxx b/src/AIS/AIS_Dimension.cxx index e6f0e34a3b..55a75bc652 100644 --- a/src/AIS/AIS_Dimension.cxx +++ b/src/AIS/AIS_Dimension.cxx @@ -471,6 +471,8 @@ Standard_Real AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePres // Set display parameters for advanced selection BRepBndLib::AddClose (aTextShape, myGeom.myTextBndBox); // Drawing text + gp_Pnt aTextCenter = myGeom.myTextPosition.Translated (gp_Vec (theTextDir) * aTextWidth * 0.5); + Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_True, gp_Ax2 (aTextCenter, myWorkingPlane.Axis().Direction(), aTextDir)); if (myDrawer->DimensionAspect()->IsTextShaded()) { // Setting text shading and color parameters @@ -493,6 +495,7 @@ Standard_Real AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePres StdPrs_WFShape::Add (thePresentation, aTextShape, myDrawer); } // Creating new group for lines + Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_False, aPenAx3.Ax2()); Prs3d_Root::NewGroup (thePresentation); } else diff --git a/src/Graphic3d/FILES b/src/Graphic3d/FILES index 5341a18316..5698da7e12 100755 --- a/src/Graphic3d/FILES +++ b/src/Graphic3d/FILES @@ -60,6 +60,7 @@ Graphic3d_Vec.hxx Graphic3d_Vec2.hxx Graphic3d_Vec3.hxx Graphic3d_Vec4.hxx +Graphic3d_Mat4.hxx Graphic3d_Vertex.hxx Graphic3d_Vertex.cxx Graphic3d_MarkerImage.hxx diff --git a/src/Graphic3d/Graphic3d.cdl b/src/Graphic3d/Graphic3d.cdl index 70f77199f2..0c074697db 100755 --- a/src/Graphic3d/Graphic3d.cdl +++ b/src/Graphic3d/Graphic3d.cdl @@ -420,6 +420,8 @@ is primitive Vec2; primitive Vec3; primitive Vec4; + primitive Mat4; + primitive Mat4d; -------------------- -- Category: Classes diff --git a/src/Graphic3d/Graphic3d_GraphicDriver.cdl b/src/Graphic3d/Graphic3d_GraphicDriver.cdl index 63d7cab9dc..8dfb0535f8 100755 --- a/src/Graphic3d/Graphic3d_GraphicDriver.cdl +++ b/src/Graphic3d/Graphic3d_GraphicDriver.cdl @@ -91,7 +91,8 @@ uses NListOfHAsciiString from Graphic3d, FontAspect from Font, CGraduatedTrihedron from Graphic3d, - ClipPlane from Graphic3d + ClipPlane from Graphic3d, + Ax2 from gp raises @@ -456,6 +457,13 @@ is theIsEnabled: Boolean from Standard) is deferred; ---Purpose: sets the stencil test to theIsEnabled state; + + SetFlippingOptions (me : mutable; + theCGroup : CGroup from Graphic3d; + theIsEnabled: Boolean from Standard; + theRefPlane : Ax2 from gp) + is deferred; + ---Purpose: sets the flipping to theIsEnabled state for the given graphic group. ---------------------------------------- -- Category: Methods to create Text diff --git a/src/Graphic3d/Graphic3d_Group.cdl b/src/Graphic3d/Graphic3d_Group.cdl index 9c805ec4d9..c91f4005b6 100755 --- a/src/Graphic3d/Graphic3d_Group.cdl +++ b/src/Graphic3d/Graphic3d_Group.cdl @@ -91,7 +91,8 @@ class Group from Graphic3d inherits TShared ArrayOfPrimitives from Graphic3d, ListOfPArray from Graphic3d, TransModeFlags from Graphic3d, - CBounds from Graphic3d + CBounds from Graphic3d, + Ax2 from gp raises @@ -373,6 +374,11 @@ class Group from Graphic3d inherits TShared theIsEnabled: Boolean from Standard); ---Purpose: sets the stencil test to theIsEnabled state; + SetFlippingOptions (me : mutable; + theIsEnabled : Boolean from Standard; + theRefPlane : Ax2 from gp); + ---Purpose: sets the flipping to theIsEnabled state. + ---------------------------- -- Category: Inquire methods ---------------------------- diff --git a/src/Graphic3d/Graphic3d_Group_13.cxx b/src/Graphic3d/Graphic3d_Group_13.cxx index 52f797be43..1678f7070f 100755 --- a/src/Graphic3d/Graphic3d_Group_13.cxx +++ b/src/Graphic3d/Graphic3d_Group_13.cxx @@ -21,6 +21,11 @@ #include #include +// ======================================================================= +// function : AddPrimitiveArray +// purpose : +// ======================================================================= + void Graphic3d_Group :: AddPrimitiveArray ( const Handle(Graphic3d_ArrayOfPrimitives)& elem,const Standard_Boolean EvalMinMax ) { if (IsDeleted () ) return; @@ -60,6 +65,11 @@ void Graphic3d_Group :: AddPrimitiveArray ( const Handle(Graphic3d_ArrayOfPrimit Update (); } +// ======================================================================= +// function : UserDraw +// purpose : +// ======================================================================= + void Graphic3d_Group :: UserDraw ( const Standard_Address AnObject, const Standard_Boolean EvalMinMax, const Standard_Boolean ContainsFacet ) @@ -83,6 +93,21 @@ void Graphic3d_Group :: UserDraw ( const Standard_Address AnObject, Update (); } +// ======================================================================= +// function : SetFlippingOptions +// purpose : +// ======================================================================= + +void Graphic3d_Group::SetFlippingOptions (const Standard_Boolean theIsEnabled, + const gp_Ax2& theRefPlane) +{ + MyGraphicDriver->SetFlippingOptions (MyCGroup, theIsEnabled, theRefPlane); +} + +// ======================================================================= +// function : SetStencilTestOptions +// purpose : +// ======================================================================= void Graphic3d_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled) { MyGraphicDriver->SetStencilTestOptions (MyCGroup, theIsEnabled); diff --git a/src/Graphic3d/Graphic3d_Mat4.hxx b/src/Graphic3d/Graphic3d_Mat4.hxx new file mode 100644 index 0000000000..4b40fe8487 --- /dev/null +++ b/src/Graphic3d/Graphic3d_Mat4.hxx @@ -0,0 +1,27 @@ +// Copyright (c) 2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef _Graphic3d_Mat4_HeaderFile +#define _Graphic3d_Mat4_HeaderFile + +#include +#include + +typedef NCollection_Mat4 Graphic3d_Mat4; +typedef NCollection_Mat4 Graphic3d_Mat4d; + +#endif // _Graphic3d_Mat4_HeaderFile diff --git a/src/Graphic3d/Graphic3d_Vec.hxx b/src/Graphic3d/Graphic3d_Vec.hxx index f40483110b..7331e4f9cd 100644 --- a/src/Graphic3d/Graphic3d_Vec.hxx +++ b/src/Graphic3d/Graphic3d_Vec.hxx @@ -23,5 +23,6 @@ #include #include #include +#include #endif // _Graphic3d_Vec_H__ diff --git a/src/NCollection/NCollection_Mat4.hxx b/src/NCollection/NCollection_Mat4.hxx index babf3e85c4..f29570bb80 100644 --- a/src/NCollection/NCollection_Mat4.hxx +++ b/src/NCollection/NCollection_Mat4.hxx @@ -16,11 +16,6 @@ // limitation, any warranties of merchantability, fitness for a particular // purpose or non-infringement Please see the License for the specific terms // and conditions governing the rights and limitations under the License -// -// The code was inspired by "sView" project by -// Kirill GAVRILOV: https://github.com/gkv311/sview. -// Files: StGLMatrix.hxx, StGLMatrix.cxx. -// Copyright (c) 2010-2013 Kirill Gavrilov #ifndef _NCollection_Mat4_HeaderFile #define _NCollection_Mat4_HeaderFile @@ -210,9 +205,10 @@ public: } //! Raw access to the data (for OpenGL exchange). - const Element_t* GetData() const { return myMat; } - operator const Element_t*() const { return myMat; } - operator Element_t*() { return myMat; } + const Element_t* GetData() const { return myMat; } + Element_t* ChangeData() { return myMat; } + operator const Element_t*() const { return myMat; } + operator Element_t*() { return myMat; } //! Multiply by the vector (M * V). //! @param theVec [in] the vector to multiply. @@ -267,7 +263,7 @@ public: //! @return result of multiplication. NCollection_Mat4 operator* (const NCollection_Mat4& theMat) const { - return Mutiplied (theMat); + return Multiplied (theMat); } //! Compute matrix multiplication product. @@ -325,6 +321,24 @@ public: this->Multiply (aTempMat); } + //! Transpose the matrix. + //! @return transposed copy of the matrix. + NCollection_Mat4 Transposed() const + { + NCollection_Mat4 aTempMat; + aTempMat.SetRow (0, GetColumn (0)); + aTempMat.SetRow (1, GetColumn (1)); + aTempMat.SetRow (2, GetColumn (2)); + aTempMat.SetRow (3, GetColumn (3)); + return aTempMat; + } + + //! Transpose the matrix. + void Transpose() + { + *this = Transposed(); + } + //! Compute inverted matrix. //! @param theOutMx [out] the inverted matrix. //! @return true if reversion success. @@ -421,4 +435,4 @@ private: }; -#endif // _NCollection_Matrix_H__ +#endif // _NCollection_Mat4_HeaderFile diff --git a/src/NCollection/NCollection_Vec2.hxx b/src/NCollection/NCollection_Vec2.hxx index fed42146a0..9073789e10 100644 --- a/src/NCollection/NCollection_Vec2.hxx +++ b/src/NCollection/NCollection_Vec2.hxx @@ -91,10 +91,11 @@ public: //! Alias to 2nd component as Y coordinate in XY. Element_t& y() { return v[1]; } - //! Raw access to the data (to simplify OpenGL exchange). - const Element_t* GetData() const { return v; } - operator const Element_t*() const { return v; } - operator Element_t*() { return v; } + //! Raw access to the data (for OpenGL exchange). + const Element_t* GetData() const { return v; } + Element_t* ChangeData() { return v; } + operator const Element_t*() const { return v; } + operator Element_t*() { return v; } //! Compute per-component summary. NCollection_Vec2& operator+= (const NCollection_Vec2& theAdd) diff --git a/src/NCollection/NCollection_Vec3.hxx b/src/NCollection/NCollection_Vec3.hxx index 1e5bd82144..9e12deb33a 100644 --- a/src/NCollection/NCollection_Vec3.hxx +++ b/src/NCollection/NCollection_Vec3.hxx @@ -147,9 +147,10 @@ public: } //! Raw access to the data (for OpenGL exchange). - const Element_t* GetData() const { return v; } - operator const Element_t*() const { return v; } - operator Element_t*() { return v; } + const Element_t* GetData() const { return v; } + Element_t* ChangeData() { return v; } + operator const Element_t*() const { return v; } + operator Element_t*() { return v; } //! Compute per-component summary. NCollection_Vec3& operator+= (const NCollection_Vec3& theAdd) diff --git a/src/NCollection/NCollection_Vec4.hxx b/src/NCollection/NCollection_Vec4.hxx index e5d11fee1e..e6c1d454dd 100644 --- a/src/NCollection/NCollection_Vec4.hxx +++ b/src/NCollection/NCollection_Vec4.hxx @@ -193,9 +193,10 @@ public: } //! Raw access to the data (for OpenGL exchange). - const Element_t* GetData() const { return v; } - operator const Element_t*() const { return v; } - operator Element_t*() { return v; } + const Element_t* GetData() const { return v; } + Element_t* ChangeData() { return v; } + operator const Element_t*() const { return v; } + operator Element_t*() { return v; } //! Compute per-component summary. NCollection_Vec4& operator+= (const NCollection_Vec4& theAdd) diff --git a/src/OpenGl/FILES b/src/OpenGl/FILES index 95eea4e6b1..4a801950b3 100755 --- a/src/OpenGl/FILES +++ b/src/OpenGl/FILES @@ -143,3 +143,5 @@ OpenGl_SceneGeometry.cxx OpenGl_RaytraceTypes.hxx OpenGl_RaytraceSource.cxx OpenGl_Workspace_Raytrace.cxx +OpenGl_Flipper.hxx +OpenGl_Flipper.cxx diff --git a/src/OpenGl/OpenGl_Flipper.cxx b/src/OpenGl/OpenGl_Flipper.cxx new file mode 100644 index 0000000000..bf9f8fb10d --- /dev/null +++ b/src/OpenGl/OpenGl_Flipper.cxx @@ -0,0 +1,144 @@ +// Created on: 2013-11-11 +// Created by: Anastasia BORISOVA +// Copyright (c) 2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include +#include +#include + +#include + +// ======================================================================= +// function : Constructor +// purpose : +// ======================================================================= +OpenGl_Flipper::OpenGl_Flipper (const gp_Ax2& theReferenceSystem) +: OpenGl_Element(), + myReferenceOrigin ((Standard_ShortReal )theReferenceSystem.Location().X(), + (Standard_ShortReal )theReferenceSystem.Location().Y(), + (Standard_ShortReal )theReferenceSystem.Location().Z(), + 1.0f), + myReferenceX ((Standard_ShortReal )theReferenceSystem.XDirection().X(), + (Standard_ShortReal )theReferenceSystem.XDirection().Y(), + (Standard_ShortReal )theReferenceSystem.XDirection().Z(), + 1.0f), + myReferenceY ((Standard_ShortReal )theReferenceSystem.YDirection().X(), + (Standard_ShortReal )theReferenceSystem.YDirection().Y(), + (Standard_ShortReal )theReferenceSystem.YDirection().Z(), + 1.0f), + myReferenceZ ((Standard_ShortReal )theReferenceSystem.Axis().Direction().X(), + (Standard_ShortReal )theReferenceSystem.Axis().Direction().Y(), + (Standard_ShortReal )theReferenceSystem.Axis().Direction().Z(), + 1.0f), + myIsEnabled (Standard_True) +{ + // +} + +// ======================================================================= +// function : Release +// purpose : +// ======================================================================= +void OpenGl_Flipper::Release (const Handle(OpenGl_Context)& ) +{ + // +} + +// ======================================================================= +// function : Render +// purpose : +// ======================================================================= +void OpenGl_Flipper::Render (const Handle(OpenGl_Workspace)& theWorkspace) const +{ + if (!myIsEnabled) + { + glMatrixMode (GL_MODELVIEW); + glLoadMatrixf ((GLfloat*) theWorkspace->ViewMatrix()); + return; + } + + OpenGl_Mat4 aMatrixMV; + glGetFloatv (GL_MODELVIEW_MATRIX, aMatrixMV.ChangeData()); + + const OpenGl_Vec4 aMVReferenceOrigin = aMatrixMV * myReferenceOrigin; + const OpenGl_Vec4 aMVReferenceX = aMatrixMV * OpenGl_Vec4 (myReferenceX.xyz() + myReferenceOrigin.xyz(), 1.0f); + const OpenGl_Vec4 aMVReferenceY = aMatrixMV * OpenGl_Vec4 (myReferenceY.xyz() + myReferenceOrigin.xyz(), 1.0f); + const OpenGl_Vec4 aMVReferenceZ = aMatrixMV * OpenGl_Vec4 (myReferenceZ.xyz() + myReferenceOrigin.xyz(), 1.0f); + + const OpenGl_Vec4 aDirX = aMVReferenceX - aMVReferenceOrigin; + const OpenGl_Vec4 aDirY = aMVReferenceY - aMVReferenceOrigin; + const OpenGl_Vec4 aDirZ = aMVReferenceZ - aMVReferenceOrigin; + + Standard_Boolean isReversedX = aDirX.xyz().Dot (OpenGl_Vec3::DX()) < 0.0f; + Standard_Boolean isReversedY = aDirY.xyz().Dot (OpenGl_Vec3::DY()) < 0.0f; + Standard_Boolean isReversedZ = aDirZ.xyz().Dot (OpenGl_Vec3::DZ()) < 0.0f; + + // compute flipping (rotational transform) + OpenGl_Mat4 aTransform; + if ((isReversedX || isReversedY) && !isReversedZ) + { + // invert by Z axis: left, up vectors mirrored + aTransform.SetColumn (0, -aTransform.GetColumn (0).xyz()); + aTransform.SetColumn (1, -aTransform.GetColumn (1).xyz()); + } + else if (isReversedY && isReversedZ) + { + // rotate by X axis: up, forward vectors mirrored + aTransform.SetColumn (1, -aTransform.GetColumn (1).xyz()); + aTransform.SetColumn (2, -aTransform.GetColumn (2).xyz()); + } + else if (isReversedZ) + { + // rotate by Y axis: left, forward vectors mirrored + aTransform.SetColumn (0, -aTransform.GetColumn (0).xyz()); + aTransform.SetColumn (2, -aTransform.GetColumn (2).xyz()); + } + else + { + return; + } + + // do rotation in origin around reference system "forward" direction + OpenGl_Mat4 aRefAxes; + OpenGl_Mat4 aRefInv; + aRefAxes.SetColumn (0, myReferenceX.xyz()); + aRefAxes.SetColumn (1, myReferenceY.xyz()); + aRefAxes.SetColumn (2, myReferenceZ.xyz()); + aRefAxes.SetColumn (3, myReferenceOrigin.xyz()); + aRefAxes.Inverted (aRefInv); + + aTransform = aRefAxes * aTransform * aRefInv; + + // transform model-view matrix + aMatrixMV = aMatrixMV * aTransform; + + // load transformed model-view matrix + GLint aCurrMode = GL_MODELVIEW; + glGetIntegerv (GL_MATRIX_MODE, &aCurrMode); + if (aCurrMode != GL_MODELVIEW) + { + glMatrixMode (GL_MODELVIEW); + } + + glLoadMatrixf ((GLfloat*) aMatrixMV); + + if (aCurrMode != GL_MODELVIEW) + { + glMatrixMode (aCurrMode); + } +} diff --git a/src/OpenGl/OpenGl_Flipper.hxx b/src/OpenGl/OpenGl_Flipper.hxx new file mode 100644 index 0000000000..94c2014a65 --- /dev/null +++ b/src/OpenGl/OpenGl_Flipper.hxx @@ -0,0 +1,64 @@ +// Copyright (c) 2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef OpenGl_Flipper_Header +#define OpenGl_Flipper_Header + +#include +#include +#include + +class gp_Ax2; + +//! Being rendered, the elements modifies current model-view matrix such that the axes of +//! the specified reference system (in model space) become oriented in the following way: +//! - X - heads to the right side of view. +//! - Y - heads to the up side of view. +//! - N(Z) - heads towards the screen. +//! Originally, this element serves for need of flipping the 3D text of dimension presentations. +class OpenGl_Flipper : public OpenGl_Element +{ +public: + + //! Construct rendering element to flip model-view matrix + //! along the reference system to ensure up-Y, right-X orientation. + //! @param theReferenceSystem [in] the reference coordinate system. + Standard_EXPORT OpenGl_Flipper (const gp_Ax2& theReferenceSystem); + + //! Set options for the element. + //! @param theIsEnabled [in] flag indicates whether the flipper + //! matrix modification should be set up or restored back. + void SetOptions (const Standard_Boolean theIsEnabled) { myIsEnabled = theIsEnabled; } + + Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; + Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theCtx); + +public: + + DEFINE_STANDARD_ALLOC + +protected: + + OpenGl_Vec4 myReferenceOrigin; + OpenGl_Vec4 myReferenceX; + OpenGl_Vec4 myReferenceY; + OpenGl_Vec4 myReferenceZ; + Standard_Boolean myIsEnabled; + +}; + +#endif // OpenGl_Flipper_Header diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index 88c7179825..f67c51dcdc 100755 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -22,8 +22,8 @@ #endif #include - #include +#include #include #include #include @@ -582,3 +582,16 @@ void OpenGl_GraphicDriver::GraduatedTrihedronMinMaxValues (const Standard_ShortR { OpenGl_GraduatedTrihedron::SetMinMax (theMinX, theMinY, theMinZ, theMaxX, theMaxY, theMaxZ); } + +// ======================================================================= +// function : SetFlippingOptions +// purpose : Enable or disable flipping option for the given group +// ======================================================================= +void OpenGl_GraphicDriver::SetFlippingOptions (const Graphic3d_CGroup& theCGroup, + const Standard_Boolean theIsEnabled, + const gp_Ax2& theRefPlane) +{ + OpenGl_Flipper* aFlipper = new OpenGl_Flipper (theRefPlane); + aFlipper->SetOptions (theIsEnabled); + ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelNil, aFlipper); +} diff --git a/src/OpenGl/OpenGl_GraphicDriver.hxx b/src/OpenGl/OpenGl_GraphicDriver.hxx index fe53540320..426b714af1 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.hxx +++ b/src/OpenGl/OpenGl_GraphicDriver.hxx @@ -44,7 +44,7 @@ #include #include #include - +#include #include #include #include @@ -215,6 +215,7 @@ public: Standard_EXPORT void SetTransparency (const Standard_ShortReal ATransparency); Standard_EXPORT void UnsetTransparency (); Standard_EXPORT void SetLineAttributes (const Standard_Integer Type,const Standard_ShortReal Width); + Standard_EXPORT void SetFlippingOptions (const Graphic3d_CGroup& theCGroup, const Standard_Boolean theIsEnabled, const gp_Ax2& theRefPlane); //! Set text attributes for under-/overlayer.
//! argument defines the name of the font to be used,
diff --git a/src/OpenGl/OpenGl_Vec.hxx b/src/OpenGl/OpenGl_Vec.hxx index 41b5e5a1ea..a4c10b8d3f 100644 --- a/src/OpenGl/OpenGl_Vec.hxx +++ b/src/OpenGl/OpenGl_Vec.hxx @@ -46,4 +46,7 @@ typedef Graphic3d_Vec2d OpenGl_Vec2d; typedef Graphic3d_Vec3d OpenGl_Vec3d; typedef Graphic3d_Vec4d OpenGl_Vec4d; +typedef Graphic3d_Mat4 OpenGl_Mat4; +typedef Graphic3d_Mat4d OpenGl_Mat4d; + #endif // _OpenGl_Vec_H__ diff --git a/src/TKOpenGl/EXTERNLIB b/src/TKOpenGl/EXTERNLIB index 058f5720ad..a27a27af32 100755 --- a/src/TKOpenGl/EXTERNLIB +++ b/src/TKOpenGl/EXTERNLIB @@ -1,5 +1,6 @@ TKernel TKService +TKMath TKV3d CSF_OpenGlLibs CSF_objc diff --git a/tests/bugs/vis/bug24288_1 b/tests/bugs/vis/bug24288_1 new file mode 100644 index 0000000000..79c441db06 --- /dev/null +++ b/tests/bugs/vis/bug24288_1 @@ -0,0 +1,46 @@ +puts "============" +puts "CR24288" +puts "============" +puts "" +####################################################################### +# Provide a text flipping +# Test for text flipping after X rotation +####################################################################### +pload VISUALIZATION + +set m_pi 3,14 +set m_pi2 1,57 +vinit +vpoint radP1 0 0 0 +vpoint radP2 50 50 0 +vpoint radP3 100 0 0 +vcircle circle radP1 radP2 radP3 0 +vrotate 0 -$m_pi2 0 +verase radP1 radP2 radP3 +vdim -radius -name=dim -text=3d circle +vdisplay dim +vfit +vmoveto 102 144 + +set x_coord 153 +set y_coord 153 +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of radius dimension with 3d text before flipping is wrong." +} + +# X axis rotation +vrotate $m_pi 0 0 +vfit +vmoveto 201 206 + +set x_coord 269 +set y_coord 123 +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of radius dimension with 3d text with flipping after x rotation is wrong." +} + +set only_screen 1 diff --git a/tests/bugs/vis/bug24288_2 b/tests/bugs/vis/bug24288_2 new file mode 100644 index 0000000000..242f6f412a --- /dev/null +++ b/tests/bugs/vis/bug24288_2 @@ -0,0 +1,46 @@ +puts "============" +puts "CR24288" +puts "============" +puts "" +####################################################################### +# Provide a text flipping +# Test for text flipping after Y rotation +####################################################################### +pload VISUALIZATION + +set m_pi 3,14 +set m_pi2 1,57 +vinit +vpoint radP1 0 0 0 +vpoint radP2 50 50 0 +vpoint radP3 100 0 0 +vcircle circle radP1 radP2 radP3 0 +vrotate 0 -$m_pi2 0 +verase radP1 radP2 radP3 +vdim -radius -name=dim -text=3d circle +vdisplay dim +vfit +vmoveto 102 144 + +set x_coord 153 +set y_coord 153 +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of radius dimension with 3d text before flipping is wrong." +} + +# Y axis rotation +vrotate 0 $m_pi 0 +vfit +vmoveto 205 205 + +set x_coord 96 +set y_coord 296 +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of radius dimension with 3d text with flipping after y rotation is wrong." +} + +set only_screen 1 diff --git a/tests/bugs/vis/bug24288_3 b/tests/bugs/vis/bug24288_3 new file mode 100644 index 0000000000..091a901f2e --- /dev/null +++ b/tests/bugs/vis/bug24288_3 @@ -0,0 +1,46 @@ +puts "============" +puts "CR24288" +puts "============" +puts "" +####################################################################### +# Provide a text flipping +# Test for text flipping after Z rotation +####################################################################### +pload VISUALIZATION + +set m_pi 3,14 +set m_pi2 1,57 +vinit +vpoint radP1 0 0 0 +vpoint radP2 50 50 0 +vpoint radP3 100 0 0 +vcircle circle radP1 radP2 radP3 0 +vrotate 0 -$m_pi2 0 +verase radP1 radP2 radP3 +vdim -radius -name=dim -text=3d circle +vdisplay dim +vfit +vmoveto 102 144 + +set x_coord 153 +set y_coord 153 +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of radius dimension with 3d text before flipping is wrong." +} + +# Z axis rotation +vrotate 0 0 $m_pi +vfit +vmoveto 176 184 + +set x_coord 294 +set y_coord 257 +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of radius dimension with 3d text with flipping after z rotation is wrong." +} + +set only_screen 1