Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-07-13 |
2 | // Created by: Sergey ZERCHANINOV | |
a174a3c5 | 3 | // Copyright (c) 2011-2013 OPEN CASCADE SAS |
b311480e | 4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public | |
6 | // License Version 6.5 (the "License"). You may not use the content of this file | |
7 | // except in compliance with the License. Please obtain a copy of the License | |
8 | // at http://www.opencascade.org and read it completely before using this file. | |
9 | // | |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
12 | // | |
13 | // The Original Code and all software distributed under the License is | |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
15 | // Initial Developer hereby disclaims all such warranties, including without | |
16 | // limitation, any warranties of merchantability, fitness for a particular | |
17 | // purpose or non-infringement. Please see the License for the specific terms | |
18 | // and conditions governing the rights and limitations under the License. | |
19 | ||
2166f0fa SK |
20 | #ifndef OpenGl_AspectText_Header |
21 | #define OpenGl_AspectText_Header | |
22 | ||
bf75be98 | 23 | #include <InterfaceGraphic_Graphic3d.hxx> |
eeaaaefb | 24 | #include <Font_FontAspect.hxx> |
2166f0fa SK |
25 | #include <Aspect_TypeOfStyleText.hxx> |
26 | #include <Aspect_TypeOfDisplayText.hxx> | |
27 | ||
a174a3c5 | 28 | #include <TCollection_AsciiString.hxx> |
29 | ||
2166f0fa | 30 | #include <OpenGl_Element.hxx> |
30f0ad28 | 31 | #include <Handle_OpenGl_ShaderProgram.hxx> |
2166f0fa | 32 | |
a174a3c5 | 33 | //! Text representation parameters |
2166f0fa SK |
34 | class OpenGl_AspectText : public OpenGl_Element |
35 | { | |
2166f0fa | 36 | |
5e27df78 | 37 | public: |
38 | ||
39 | OpenGl_AspectText(); | |
40 | virtual ~OpenGl_AspectText(); | |
2166f0fa | 41 | |
a174a3c5 | 42 | //! Copy parameters |
fd4a6963 | 43 | void SetAspect (const CALL_DEF_CONTEXTTEXT& theAspect); |
a174a3c5 | 44 | |
45 | //! @return font family name | |
46 | const TCollection_AsciiString& FontName() const | |
47 | { | |
48 | return myFont; | |
49 | } | |
50 | ||
51 | //! @return font family name | |
52 | TCollection_AsciiString& ChangeFontName() | |
53 | { | |
54 | return myFont; | |
55 | } | |
56 | ||
57 | //! @return is zoomable flag | |
58 | bool IsZoomable() const | |
59 | { | |
60 | return myZoomable; | |
61 | } | |
62 | ||
63 | //! @return rotation angle | |
64 | float Angle() const | |
65 | { | |
66 | return myAngle; | |
67 | } | |
68 | ||
69 | //! @return font aspect (regular/bold/italic) | |
70 | Font_FontAspect FontAspect() const | |
71 | { | |
72 | return myFontAspect; | |
73 | } | |
74 | ||
75 | //! @param theValue font aspect (regular/bold/italic) | |
76 | void SetFontAspect (const Font_FontAspect theValue) | |
77 | { | |
78 | myFontAspect = theValue; | |
79 | } | |
80 | ||
81 | //! @return text color | |
82 | const TEL_COLOUR& Color() const | |
83 | { | |
84 | return myColor; | |
85 | } | |
86 | ||
87 | //! @return text color | |
88 | TEL_COLOUR& ChangeColor() | |
89 | { | |
90 | return myColor; | |
91 | } | |
92 | ||
93 | //! @return annotation style | |
94 | Aspect_TypeOfStyleText StyleType() const | |
95 | { | |
96 | return myStyleType; | |
97 | } | |
98 | ||
99 | //! @return subtitle style (none/blend/decale/subtitle) | |
100 | Aspect_TypeOfDisplayText DisplayType() const | |
101 | { | |
102 | return myDisplayType; | |
103 | } | |
104 | ||
105 | void SetDisplayType (const Aspect_TypeOfDisplayText theType) | |
106 | { | |
107 | myDisplayType = theType; | |
108 | } | |
109 | ||
110 | //! @return subtitle color | |
111 | const TEL_COLOUR& SubtitleColor() const | |
112 | { | |
113 | return mySubtitleColor; | |
114 | } | |
115 | ||
116 | //! @return subtitle color | |
117 | TEL_COLOUR& ChangeSubtitleColor() | |
118 | { | |
119 | return mySubtitleColor; | |
120 | } | |
2166f0fa | 121 | |
30f0ad28 | 122 | //! Init and return OpenGl shader program resource. |
123 | //! @return shader program resource. | |
124 | const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Workspace)& theWorkspace) const | |
125 | { | |
126 | if (!myResources.IsShaderReady()) | |
127 | { | |
128 | myResources.BuildShader (theWorkspace, myShaderProgram); | |
129 | myResources.SetShaderReady(); | |
130 | } | |
131 | ||
132 | return myResources.ShaderProgram; | |
133 | } | |
134 | ||
5e27df78 | 135 | virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; |
136 | virtual void Release (const Handle(OpenGl_Context)& theContext); | |
2166f0fa | 137 | |
5e27df78 | 138 | protected: |
2166f0fa | 139 | |
30f0ad28 | 140 | TCollection_AsciiString myFont; |
141 | TEL_COLOUR myColor; | |
142 | TEL_COLOUR mySubtitleColor; | |
143 | float myAngle; | |
144 | Aspect_TypeOfStyleText myStyleType; | |
145 | Aspect_TypeOfDisplayText myDisplayType; | |
146 | Font_FontAspect myFontAspect; | |
147 | bool myZoomable; | |
148 | Handle(Graphic3d_ShaderProgram) myShaderProgram; | |
149 | ||
150 | protected: | |
151 | ||
152 | //! OpenGl resources | |
153 | mutable struct Resources | |
154 | { | |
155 | public: | |
156 | Resources() : myIsShaderReady (Standard_False) {} | |
157 | ||
158 | Standard_Boolean IsShaderReady() const { return myIsShaderReady; } | |
159 | void SetShaderReady() { myIsShaderReady = Standard_True; } | |
160 | void ResetShader () { myIsShaderReady = Standard_False; } | |
161 | ||
162 | void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader); | |
163 | ||
164 | Handle(OpenGl_ShaderProgram) ShaderProgram; | |
165 | TCollection_AsciiString ShaderProgramId; | |
166 | ||
167 | private: | |
168 | ||
169 | Standard_Boolean myIsShaderReady; | |
170 | ||
171 | } myResources; | |
2166f0fa | 172 | |
5e27df78 | 173 | public: |
174 | ||
1c35b92f | 175 | DEFINE_STANDARD_ALLOC |
5e27df78 | 176 | |
2166f0fa SK |
177 | }; |
178 | ||
a174a3c5 | 179 | #endif // OpenGl_AspectText_Header |