mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0024374: Flipping affects highlight presentation of dimension. Model-view matrix restoring in immediate mode was added in OpenGl_Flipper::Render() method. Test case was added.
This commit is contained in:
parent
1d7ca641c7
commit
0f8c0fb8c8
@ -18,6 +18,9 @@
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#include <OpenGl_Flipper.hxx>
|
||||
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
#include <OpenGl_Vec.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
@ -65,13 +68,73 @@ void OpenGl_Flipper::Release (const Handle(OpenGl_Context)& )
|
||||
// =======================================================================
|
||||
void OpenGl_Flipper::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
// Check if rendering is to be in immediate mode
|
||||
const Standard_Boolean isImmediate = (theWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0;
|
||||
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
||||
GLint aCurrMode = GL_MODELVIEW;
|
||||
glGetIntegerv (GL_MATRIX_MODE, &aCurrMode);
|
||||
|
||||
if (!myIsEnabled)
|
||||
{
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadMatrixf ((GLfloat*) theWorkspace->ViewMatrix());
|
||||
// Restore transformation
|
||||
if (isImmediate)
|
||||
{
|
||||
if (aCurrMode != GL_MODELVIEW)
|
||||
{
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
if (aCurrMode != GL_MODELVIEW)
|
||||
{
|
||||
glMatrixMode (aCurrMode);
|
||||
}
|
||||
|
||||
Tmatrix3 aModelWorldState = { { 1.f, 0.f, 0.f, 0.f },
|
||||
{ 0.f, 1.f, 0.f, 0.f },
|
||||
{ 0.f, 0.f, 1.f, 0.f },
|
||||
{ 0.f, 0.f, 0.f, 1.f } };
|
||||
|
||||
aContext->ShaderManager()->RevertModelWorldStateTo (aModelWorldState);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update current model-view matrix in the top of the stack
|
||||
// replacing it with StructureMatrixT*ViewMatrix from the workspace.
|
||||
theWorkspace->UpdateModelViewMatrix();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (isImmediate)
|
||||
{
|
||||
|
||||
if (!aContext->ShaderManager()->IsEmpty())
|
||||
{
|
||||
Tmatrix3 aWorldView;
|
||||
glGetFloatv (GL_MODELVIEW_MATRIX, *aWorldView);
|
||||
|
||||
Tmatrix3 aProjection;
|
||||
glGetFloatv (GL_PROJECTION_MATRIX, *aProjection);
|
||||
|
||||
aContext->ShaderManager()->UpdateWorldViewStateTo (aWorldView);
|
||||
aContext->ShaderManager()->UpdateProjectionStateTo (aProjection);
|
||||
}
|
||||
|
||||
if (aCurrMode != GL_MODELVIEW)
|
||||
{
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
if (aCurrMode != GL_MODELVIEW)
|
||||
{
|
||||
glMatrixMode (aCurrMode);
|
||||
}
|
||||
}
|
||||
|
||||
OpenGl_Mat4 aMatrixMV;
|
||||
glGetFloatv (GL_MODELVIEW_MATRIX, aMatrixMV.ChangeData());
|
||||
|
||||
@ -128,8 +191,6 @@ void OpenGl_Flipper::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
aMatrixMV = aMatrixMV * aTransform;
|
||||
|
||||
// load transformed model-view matrix
|
||||
GLint aCurrMode = GL_MODELVIEW;
|
||||
glGetIntegerv (GL_MATRIX_MODE, &aCurrMode);
|
||||
if (aCurrMode != GL_MODELVIEW)
|
||||
{
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
|
@ -104,6 +104,7 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay,
|
||||
TextParam_applied (NULL),
|
||||
ViewMatrix_applied (&myDefaultMatrix),
|
||||
StructureMatrix_applied (&myDefaultMatrix),
|
||||
myModelViewMatrix (myDefaultMatrix),
|
||||
PolygonOffset_applied (NULL)
|
||||
{
|
||||
theDisplay->InitAttributes();
|
||||
|
@ -155,6 +155,10 @@ public:
|
||||
const OpenGl_Matrix* SetViewMatrix (const OpenGl_Matrix* );
|
||||
const OpenGl_Matrix* SetStructureMatrix (const OpenGl_Matrix*, bool aRevert = false);
|
||||
|
||||
//! Updates current model-view matrix
|
||||
//! replacing it with StructureMatrixT*ViewMatrix from the workspace.
|
||||
const void UpdateModelViewMatrix();
|
||||
|
||||
const OpenGl_AspectLine* SetAspectLine (const OpenGl_AspectLine* theAspect);
|
||||
const OpenGl_AspectFace* SetAspectFace (const OpenGl_AspectFace* theAspect);
|
||||
const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect);
|
||||
@ -413,6 +417,9 @@ protected: //! @name fields related to status
|
||||
const OpenGl_Matrix* ViewMatrix_applied;
|
||||
const OpenGl_Matrix* StructureMatrix_applied;
|
||||
|
||||
//! Model matrix with applied structure transformations
|
||||
OpenGl_Matrix myModelViewMatrix;
|
||||
|
||||
const TEL_POFFSET_PARAM* PolygonOffset_applied;
|
||||
|
||||
OpenGl_AspectFace myAspectFaceHl; // Hiddenline aspect
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <OpenGl_AspectText.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
#include <OpenGl_telem_util.hxx>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
@ -425,18 +426,13 @@ const OpenGl_AspectText * OpenGl_Workspace::SetAspectText(const OpenGl_AspectTex
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
const OpenGl_Matrix * OpenGl_Workspace::SetViewMatrix(const OpenGl_Matrix *AMatrix)
|
||||
const OpenGl_Matrix * OpenGl_Workspace::SetViewMatrix (const OpenGl_Matrix *AMatrix)
|
||||
{
|
||||
const OpenGl_Matrix *ViewMatrix_old = ViewMatrix_applied;
|
||||
ViewMatrix_applied = AMatrix;
|
||||
|
||||
OpenGl_Matrix lmat;
|
||||
OpenGl_Transposemat3( &lmat, StructureMatrix_applied );
|
||||
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
OpenGl_Matrix rmat;
|
||||
OpenGl_Multiplymat3 (&rmat, &lmat, ViewMatrix_applied);
|
||||
glLoadMatrixf ((const GLfloat* )rmat.mat);
|
||||
// Update model-view matrix with new view matrix
|
||||
UpdateModelViewMatrix();
|
||||
|
||||
return ViewMatrix_old;
|
||||
}
|
||||
@ -451,10 +447,8 @@ const OpenGl_Matrix * OpenGl_Workspace::SetStructureMatrix (const OpenGl_Matrix
|
||||
OpenGl_Matrix lmat;
|
||||
OpenGl_Transposemat3( &lmat, AMatrix );
|
||||
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
OpenGl_Matrix rmat;
|
||||
OpenGl_Multiplymat3 (&rmat, &lmat, ViewMatrix_applied);
|
||||
glLoadMatrixf ((const GLfloat* )rmat.mat);
|
||||
// Update model-view matrix with new structure matrix
|
||||
UpdateModelViewMatrix();
|
||||
|
||||
if (!myGlContext->ShaderManager()->IsEmpty())
|
||||
{
|
||||
@ -473,6 +467,18 @@ const OpenGl_Matrix * OpenGl_Workspace::SetStructureMatrix (const OpenGl_Matrix
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
const void OpenGl_Workspace::UpdateModelViewMatrix()
|
||||
{
|
||||
OpenGl_Matrix aStructureMatT;
|
||||
OpenGl_Transposemat3( &aStructureMatT, StructureMatrix_applied);
|
||||
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
OpenGl_Multiplymat3 (&myModelViewMatrix, &aStructureMatT, ViewMatrix_applied);
|
||||
glLoadMatrixf ((const GLfloat* )&myModelViewMatrix.mat);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
const OpenGl_AspectLine * OpenGl_Workspace::AspectLine(const Standard_Boolean WithApply)
|
||||
{
|
||||
if ( WithApply && (AspectLine_set != AspectLine_applied) )
|
||||
|
28
tests/bugs/vis/bug24374
Normal file
28
tests/bugs/vis/bug24374
Normal file
@ -0,0 +1,28 @@
|
||||
puts "============"
|
||||
puts "CR24374"
|
||||
puts "============"
|
||||
puts ""
|
||||
#######################################################################
|
||||
# Flipping affects highlight presentation of dimension
|
||||
#######################################################################
|
||||
pload ALL
|
||||
pload QAcommands
|
||||
box b 100 100 100
|
||||
explode b e
|
||||
vdisplay b
|
||||
vdisplay b_9
|
||||
vdim -length -name=dim1 b_9 -text=3d -plane=zox
|
||||
vdisplay dim1
|
||||
vselmode b 2 1
|
||||
vfit
|
||||
vmoveto 110 352
|
||||
|
||||
set x_coord 161
|
||||
set y_coord 372
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
|
||||
if { $stat != 1 } {
|
||||
puts "Error : Highlighting of dimension with flipping in local context failed."
|
||||
}
|
||||
|
||||
set only_screen 1
|
Loading…
x
Reference in New Issue
Block a user