0024947: Redesign OCCT legacy type system
[occt.git] / src / OpenGl / OpenGl_CappingPlaneResource.hxx
CommitLineData
4269bd1b 1// Created on: 2013-08-15
2// Created by: Anton POLETAEV
d5f74e42 3// Copyright (c) 2013-2014 OPEN CASCADE SAS
4269bd1b 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
4269bd1b 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
4269bd1b 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
4269bd1b 15
16#ifndef _OpenGl_CappingPlaneResource_H__
17#define _OpenGl_CappingPlaneResource_H__
18
e1c659da 19#include <OpenGl_PrimitiveArray.hxx>
4269bd1b 20#include <OpenGl_Resource.hxx>
21#include <OpenGl_AspectFace.hxx>
22#include <OpenGl_Matrix.hxx>
23#include <Graphic3d_ClipPlane.hxx>
24
25class Handle(OpenGl_Context);
26
27DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
28
29//! Container of graphical resources for rendering capping plane
30//! associated to graphical clipping plane.
31//! This resource holds data necessary for OpenGl_CappingAlgo.
32//! This object is implemented as OpenGl resource for the following reasons:
33//! - one instance should be shared between contexts.
34//! - instance associated to Graphic3d_ClipPlane data by id.
35//! - should created and released within context (owns OpenGl elements and resources).
36class OpenGl_CappingPlaneResource : public OpenGl_Resource
37{
38public:
39
40 //! Constructor.
41 //! Create capping plane presentation associated to clipping plane data.
42 //! @param thePlane [in] the plane data.
43 Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane);
44
45 //! Destroy object.
46 Standard_EXPORT virtual ~OpenGl_CappingPlaneResource();
47
48 //! Update resource data in the passed context.
49 //! @param theContext [in] the context.
50 Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext);
51
52 //! Release associated OpenGl resources.
53 //! @param theContext [in] the resource context.
e1c659da 54 Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
4269bd1b 55
56 //! @return aspect face for rendering capping surface.
57 inline const OpenGl_AspectFace* AspectFace() const { return myAspect; }
58
59 //! @return evaluated orientation matrix to transform infinite plane.
60 inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
61
e1c659da 62 //! @return primitive array of vertices to render infinite plane.
63 inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; }
64
4269bd1b 65private:
66
67 //! Update precomputed plane orientation matrix.
68 void UpdateTransform();
69
70 //! Update resources.
71 //! @param theContext [in] the context.
72 void UpdateAspect (const Handle(OpenGl_Context)& theContext);
73
74private:
75
e1c659da 76 OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
4269bd1b 77 OpenGl_Matrix myOrientation; //!< plane transformation matrix.
78 OpenGl_AspectFace* myAspect; //!< capping face aspect.
79 Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
80 unsigned int myEquationMod; //!< modification counter for plane equation.
81 unsigned int myAspectMod; //!< modification counter for aspect.
82
83public:
84
85 DEFINE_STANDARD_RTTI(OpenGl_CappingPlaneResource) // Type definition
86
87};
88
89#endif