0030748: Visualization - Marker displayed in immediate layer ruins QT Quick view...
[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>
21#include <Graphic3d_TypeOfBackground.hxx>
bf5f0ca2 22#include <OpenGl_Aspects.hxx>
0b0320e7 23#include <OpenGl_PrimitiveArray.hxx>
24#include <OpenGl_Vec.hxx>
25#include <OpenGl_Workspace.hxx>
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
37 Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
38
0b0320e7 39 //! Check if background parameters are set properly
40 Standard_EXPORT bool IsDefined() const;
41
0b0320e7 42 //! Sets background texture parameters
43 Standard_EXPORT void SetTextureParameters (const Aspect_FillMethod theFillMethod);
44
45 //! Sets texture fill method
46 Standard_EXPORT void SetTextureFillMethod (const Aspect_FillMethod theFillMethod);
47
48 //! Gets background texture fill method
49 Aspect_FillMethod TextureFillMethod() const { return myFillMethod; }
50
51 //! Gets background gradient fill method
52 Aspect_GradientFillMethod GradientFillMethod() const { return myGradientParams.type; }
53
189f85a3 54 //! Returns color of gradient background for the given index.
55 const OpenGl_Vec4& GradientColor (const Standard_Integer theIndex) const { return (&myGradientParams.color1)[theIndex]; }
56
0b0320e7 57 //! Sets type of gradient fill method
58 Standard_EXPORT void SetGradientFillMethod (const Aspect_GradientFillMethod theType);
59
60 //! Sets background gradient parameters
61 Standard_EXPORT void SetGradientParameters (const Quantity_Color& theColor1,
62 const Quantity_Color& theColor2,
63 const Aspect_GradientFillMethod theType);
64
0b0320e7 65protected: //! @name Internal structure for storing gradient parameters
66
67 struct OpenGl_GradientParameters
68 {
69 OpenGl_Vec4 color1;
70 OpenGl_Vec4 color2;
71 Aspect_GradientFillMethod type;
72 };
73
74protected:
75
3bffef55 76 //! Fill attributes arrays for background array according to its type:
77 //! - for gradient background its attributes consist of colors and gradient coordinates
78 //! - for texture one its attributes consist of position and texture coordinates.
79 Standard_EXPORT Standard_Boolean init (const Handle(OpenGl_Workspace)& theWorkspace) const;
80
0b0320e7 81 //! Initializes gradient arrays.
3bffef55 82 Standard_EXPORT Standard_Boolean createGradientArray() const;
0b0320e7 83
84 //! Initializes texture arrays.
85 //! @param theWorkspace OpenGl workspace that stores texture in the current enabled face aspect.
3bffef55 86 Standard_EXPORT Standard_Boolean createTextureArray (const Handle(OpenGl_Workspace)& theWorkspace) const;
0b0320e7 87
88 //! Marks array parameters as changed,
89 //! on next rendering stage array data is to be updated.
90 Standard_EXPORT void invalidateData();
91
92protected:
93
3bffef55 94 Graphic3d_TransformPers myTrsfPers; //!< transformation persistence
95 Graphic3d_TypeOfBackground myType; //!< Type of background: texture or gradient.
96 Aspect_FillMethod myFillMethod; //!< Texture parameters
97 mutable OpenGl_GradientParameters myGradientParams; //!< Gradient parameters
98 mutable Standard_Integer myViewWidth; //!< view width used for array initialization
99 mutable Standard_Integer myViewHeight; //!< view height used for array initialization
100 mutable Standard_Boolean myToUpdate; //!< Shows if array parameters were changed and data (myAttribs storage) is to be updated
0b0320e7 101
102};
103
104#endif // OpenGl_BackgroundArray_Header