0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / OpenGl / OpenGl_BackgroundArray.hxx
CommitLineData
0b0320e7 1// Created on: 2015-01-16
2// Created by: Anastasia BORISOVA
3// Copyright (c) 2015 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef OpenGl_BackgroundArray_Header
17#define OpenGl_BackgroundArray_Header
18
19#include <Aspect_GradientFillMethod.hxx>
20#include <Aspect_FillMethod.hxx>
1220d98e 21#include <Graphic3d_Camera.hxx>
0b0320e7 22#include <Graphic3d_TypeOfBackground.hxx>
bf5f0ca2 23#include <OpenGl_Aspects.hxx>
0b0320e7 24#include <OpenGl_PrimitiveArray.hxx>
25#include <OpenGl_Vec.hxx>
0b0320e7 26
27//! Tool class for generating reusable data for
28//! gradient or texture background rendering.
29class OpenGl_BackgroundArray : public OpenGl_PrimitiveArray
30{
31public:
32
33 //! Main constructor.
34 Standard_EXPORT OpenGl_BackgroundArray (const Graphic3d_TypeOfBackground theType);
35
3bffef55 36 //! Render primitives to the window
cdc54fb0 37 Standard_EXPORT void Render (const Handle(OpenGl_Workspace)& theWorkspace,
38 Graphic3d_Camera::Projection theProjection) const;
3bffef55 39
0b0320e7 40 //! Check if background parameters are set properly
41 Standard_EXPORT bool IsDefined() const;
42
0b0320e7 43 //! Sets background texture parameters
44 Standard_EXPORT void SetTextureParameters (const Aspect_FillMethod theFillMethod);
45
46 //! Sets texture fill method
47 Standard_EXPORT void SetTextureFillMethod (const Aspect_FillMethod theFillMethod);
48
49 //! Gets background texture fill method
50 Aspect_FillMethod TextureFillMethod() const { return myFillMethod; }
51
52 //! Gets background gradient fill method
53 Aspect_GradientFillMethod GradientFillMethod() const { return myGradientParams.type; }
54
189f85a3 55 //! Returns color of gradient background for the given index.
56 const OpenGl_Vec4& GradientColor (const Standard_Integer theIndex) const { return (&myGradientParams.color1)[theIndex]; }
57
0b0320e7 58 //! Sets type of gradient fill method
59 Standard_EXPORT void SetGradientFillMethod (const Aspect_GradientFillMethod theType);
60
61 //! Sets background gradient parameters
62 Standard_EXPORT void SetGradientParameters (const Quantity_Color& theColor1,
63 const Quantity_Color& theColor2,
64 const Aspect_GradientFillMethod theType);
65
0b0320e7 66protected: //! @name Internal structure for storing gradient parameters
67
68 struct OpenGl_GradientParameters
69 {
70 OpenGl_Vec4 color1;
71 OpenGl_Vec4 color2;
72 Aspect_GradientFillMethod type;
73 };
74
75protected:
76
3bffef55 77 //! Fill attributes arrays for background array according to its type:
78 //! - for gradient background its attributes consist of colors and gradient coordinates
79 //! - for texture one its attributes consist of position and texture coordinates.
80 Standard_EXPORT Standard_Boolean init (const Handle(OpenGl_Workspace)& theWorkspace) const;
81
0b0320e7 82 //! Initializes gradient arrays.
ba00aab7 83 Standard_EXPORT Standard_Boolean createGradientArray (const Handle(OpenGl_Context)& theCtx) const;
0b0320e7 84
85 //! Initializes texture arrays.
86 //! @param theWorkspace OpenGl workspace that stores texture in the current enabled face aspect.
3bffef55 87 Standard_EXPORT Standard_Boolean createTextureArray (const Handle(OpenGl_Workspace)& theWorkspace) const;
0b0320e7 88
077a220c 89 //! Initializes cubemap arrays.
90 Standard_EXPORT Standard_Boolean createCubeMapArray() const;
91
0b0320e7 92 //! Marks array parameters as changed,
93 //! on next rendering stage array data is to be updated.
94 Standard_EXPORT void invalidateData();
95
cdc54fb0 96 using OpenGl_PrimitiveArray::Render;
97
0b0320e7 98protected:
99
3bffef55 100 Graphic3d_TypeOfBackground myType; //!< Type of background: texture or gradient.
101 Aspect_FillMethod myFillMethod; //!< Texture parameters
102 mutable OpenGl_GradientParameters myGradientParams; //!< Gradient parameters
103 mutable Standard_Integer myViewWidth; //!< view width used for array initialization
104 mutable Standard_Integer myViewHeight; //!< view height used for array initialization
105 mutable Standard_Boolean myToUpdate; //!< Shows if array parameters were changed and data (myAttribs storage) is to be updated
0b0320e7 106
107};
108
109#endif // OpenGl_BackgroundArray_Header