1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-07-30 13:05:50 +03:00
occt/src/OpenGl/OpenGl_MatrixState.hxx
apl 825aa485a3 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.
2015-07-29 13:39:27 +03:00

89 lines
2.4 KiB
C++

// Created on: 2014-09-30
// Created by: Denis BOGOLEPOV
// Copyright (c) 2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _OpenGl_MatrixState_H__
#define _OpenGl_MatrixState_H__
#include <OpenGl_Vec.hxx>
#include <NCollection_Vector.hxx>
//! Software implementation for OpenGL matrix stack.
template<class T>
class OpenGl_MatrixState
{
public:
//! Constructs matrix state object.
OpenGl_MatrixState()
: myStack (8),
myStackHead (-1)
{
//
}
//! Pushes current matrix into stack.
void Push()
{
if (++myStackHead >= myStack.Size())
{
myStack.Append (myCurrent);
}
else
{
myStack.SetValue (myStackHead, myCurrent);
}
}
//! Pops matrix from stack to current.
void Pop()
{
Standard_ASSERT_RETURN (myStackHead != -1, "Matrix stack already empty when MatrixState.Pop() called.", );
myCurrent = myStack.Value (myStackHead--);
}
//! @return current matrix.
const typename OpenGl::MatrixType<T>::Mat4& Current()
{
return myCurrent;
}
//! Sets given matrix as current.
void SetCurrent (const typename OpenGl::MatrixType<T>::Mat4& theNewCurrent)
{
myCurrent = theNewCurrent;
}
//! Sets given matrix as current.
template <typename Other_t>
void SetCurrent (const typename OpenGl::MatrixType<Other_t>::Mat4& theNewCurrent)
{
myCurrent.Convert (theNewCurrent);
}
//! Sets current matrix to identity.
void SetIdentity()
{
myCurrent = typename OpenGl::MatrixType<T>::Mat4();
}
private:
NCollection_Vector<typename OpenGl::MatrixType<T>::Mat4> myStack; //!< Collection used to maintenance matrix stack
typename OpenGl::MatrixType<T>::Mat4 myCurrent; //!< Current matrix
Standard_Integer myStackHead; //!< Index of stack head
};
#endif // _OpenGl_MatrixState_H__