1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0026344: Visualization - provide a support of zoom persistent selection

1) New Graphic3d_TransformPers structure for defining parameters and algorithm methods, featuring:
    a) application of transformation to projection and world view matrices;
    b) computation of model-world transformation of persistent object;
    c) computation of transformed bounding box of persistent object.

2) Transform persistence algorithm does not make any changes to model-world transformation of object (deals with projection and world view matrices only), thus making possible to employ local transformation in a usual way.

3) Support of BVH selection for transform persistent objects (pan, rotate, zoom, trihedron persistence only).

4) Support efficient frustum culling for transform persistent objects (pan, rotate, zoom, trihedron persistence only).

5) Support of z-fitting algorithm for world-view space transform persistent objects (rotate, zoom persistence only).

6) Rewrite usage of transform persistence structures and utilities classes:
    a) Replaced Graphic3d_CTransPers, TEL_TRANSFORM_PERSISTENCE by Graphic3d_TransformPers;
    b) Move functions from OpenGl_Utils.hxx to Graphic3d_TransformUtils.hxx;
    c) Extract matrix stack class from OpenGl_Utils.hxx to OpenGl_MatrixStack.hxx;

7) New class Graphic3d_WorldViewProjState to keep track of projection, world view matrices changes for a camera.

8) New test case bugs/vis/bug26344.

9) Renamed method Graphic3d_Camera::ModelViewState of  to ::WorldViewState for consistency.
This commit is contained in:
apl
2015-07-20 11:41:38 +03:00
committed by bugmaster
parent 317d68c924
commit 825aa485a3
59 changed files with 2324 additions and 1156 deletions

View File

@@ -118,7 +118,6 @@ public:
OpenGl_Structure::OpenGl_Structure (const Handle(Graphic3d_StructureManager)& theManager)
: Graphic3d_CStructure (theManager),
myTransformation (NULL),
myTransPers (NULL),
myAspectLine (NULL),
myAspectFace (NULL),
myAspectMarker (NULL),
@@ -141,7 +140,6 @@ OpenGl_Structure::~OpenGl_Structure()
{
Release (Handle(OpenGl_Context)());
delete myTransformation; myTransformation = NULL;
delete myTransPers; myTransPers = NULL;
}
// =======================================================================
@@ -150,8 +148,6 @@ OpenGl_Structure::~OpenGl_Structure()
// =======================================================================
void OpenGl_Structure::UpdateAspects()
{
SetTransformPersistence (TransformPersistence);
if (ContextLine.IsDef)
SetAspectLine (ContextLine);
@@ -194,22 +190,6 @@ void OpenGl_Structure::UpdateTransformation()
}
}
// =======================================================================
// function : SetTransformPersistence
// purpose :
// =======================================================================
void OpenGl_Structure::SetTransformPersistence(const CALL_DEF_TRANSFORM_PERSISTENCE &ATransPers)
{
if (!myTransPers)
myTransPers = new TEL_TRANSFORM_PERSISTENCE;
myTransPers->mode = ATransPers.Flag;
myTransPers->pointX = ATransPers.Point.x;
myTransPers->pointY = ATransPers.Point.y;
myTransPers->pointZ = ATransPers.Point.z;
MarkAsNotCulled();
}
// =======================================================================
// function : SetAspectLine
// purpose :
@@ -558,32 +538,40 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
const Standard_Boolean anOldGlNormalize = aCtx->IsGlNormalizeEnabled();
// Apply local transformation
OpenGl_Mat4 aModelWorld;
if (myTransformation)
{
OpenGl_Matrix aModelWorld;
OpenGl_Transposemat3 (&aModelWorld, myTransformation);
aCtx->ModelWorldState.Push();
aCtx->ModelWorldState.SetCurrent (OpenGl_Mat4::Map ((Standard_ShortReal* )aModelWorld.mat));
OpenGl_Transposemat3 ((OpenGl_Matrix*)aModelWorld.ChangeData(), myTransformation);
Standard_ShortReal aScaleX = OpenGl_Vec3 (myTransformation->mat[0][0],
myTransformation->mat[0][1],
myTransformation->mat[0][2]).SquareModulus();
Standard_ShortReal aScaleX = OpenGl_Vec3 (aModelWorld.GetValue (0, 0),
aModelWorld.GetValue (1, 0),
aModelWorld.GetValue (2, 0)).SquareModulus();
// Scale transform detected.
if (Abs (aScaleX - 1.f) > Precision::Confusion())
{
aCtx->SetGlNormalizeEnabled (Standard_True);
}
}
// Apply transform persistence
const TEL_TRANSFORM_PERSISTENCE *aTransPersistence = NULL;
if ( myTransPers && myTransPers->mode != 0 )
aCtx->ModelWorldState.Push();
aCtx->ModelWorldState.SetCurrent (aModelWorld);
}
if (TransformPersistence.Flags)
{
aTransPersistence = theWorkspace->ActiveView()->BeginTransformPersistence (aCtx, myTransPers, theWorkspace->Width(), theWorkspace->Height());
OpenGl_Mat4 aProjection = aCtx->ProjectionState.Current();
OpenGl_Mat4 aWorldView = aCtx->WorldViewState.Current();
TransformPersistence.Apply (aProjection, aWorldView, theWorkspace->Width(), theWorkspace->Height());
aCtx->ProjectionState.Push();
aCtx->WorldViewState.Push();
aCtx->ProjectionState.SetCurrent (aProjection);
aCtx->WorldViewState.SetCurrent (aWorldView);
aCtx->ApplyProjectionMatrix();
}
if (aModelWorld || TransformPersistence.Flags)
{
aCtx->ApplyModelViewMatrix();
}
// Take into account transform persistence
aCtx->ApplyModelViewMatrix();
// Apply aspects
const OpenGl_AspectLine *anAspectLine = theWorkspace->AspectLine (Standard_False);
@@ -692,12 +680,22 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
}
}
// Apply local transformation
if (myTransformation)
// Restore local transformation
if (!aModelWorld.IsIdentity())
{
aCtx->ModelWorldState.Pop();
aCtx->SetGlNormalizeEnabled (anOldGlNormalize);
}
if (TransformPersistence.Flags)
{
aCtx->ProjectionState.Pop();
aCtx->WorldViewState.Pop();
aCtx->ApplyProjectionMatrix();
}
if (!aModelWorld.IsIdentity() || TransformPersistence.Flags)
{
aCtx->ApplyWorldViewMatrix();
}
// Restore highlight color
theWorkspace->HighlightColor = aHighlightColor;
@@ -708,12 +706,6 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
theWorkspace->SetAspectMarker (anAspectMarker);
theWorkspace->SetAspectText (anAspectText);
// Restore transform persistence
if ( myTransPers && myTransPers->mode != 0 )
{
theWorkspace->ActiveView()->BeginTransformPersistence (aCtx, aTransPersistence, theWorkspace->Width(), theWorkspace->Height());
}
// Apply highlight box
if (!myHighlightBox.IsNull())
{