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 | // |
973c2be1 | 5 | // This file is part of Open CASCADE Technology software library. |
b311480e | 6 | // |
973c2be1 | 7 | // This library is free software; you can redistribute it and / or modify it |
8 | // under the terms of the GNU Lesser General Public 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. | |
b311480e | 12 | // |
973c2be1 | 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. | |
b311480e | 15 | |
2166f0fa SK |
16 | #ifndef OpenGl_AspectText_Header |
17 | #define OpenGl_AspectText_Header | |
18 | ||
bf75be98 | 19 | #include <InterfaceGraphic_Graphic3d.hxx> |
eeaaaefb | 20 | #include <Font_FontAspect.hxx> |
2166f0fa SK |
21 | #include <Aspect_TypeOfStyleText.hxx> |
22 | #include <Aspect_TypeOfDisplayText.hxx> | |
23 | ||
a174a3c5 | 24 | #include <TCollection_AsciiString.hxx> |
25 | ||
2166f0fa | 26 | #include <OpenGl_Element.hxx> |
30f0ad28 | 27 | #include <Handle_OpenGl_ShaderProgram.hxx> |
2166f0fa | 28 | |
a174a3c5 | 29 | //! Text representation parameters |
2166f0fa SK |
30 | class OpenGl_AspectText : public OpenGl_Element |
31 | { | |
2166f0fa | 32 | |
5e27df78 | 33 | public: |
34 | ||
35 | OpenGl_AspectText(); | |
36 | virtual ~OpenGl_AspectText(); | |
2166f0fa | 37 | |
a174a3c5 | 38 | //! Copy parameters |
fd4a6963 | 39 | void SetAspect (const CALL_DEF_CONTEXTTEXT& theAspect); |
a174a3c5 | 40 | |
41 | //! @return font family name | |
42 | const TCollection_AsciiString& FontName() const | |
43 | { | |
44 | return myFont; | |
45 | } | |
46 | ||
47 | //! @return font family name | |
48 | TCollection_AsciiString& ChangeFontName() | |
49 | { | |
50 | return myFont; | |
51 | } | |
52 | ||
53 | //! @return is zoomable flag | |
54 | bool IsZoomable() const | |
55 | { | |
56 | return myZoomable; | |
57 | } | |
58 | ||
59 | //! @return rotation angle | |
60 | float Angle() const | |
61 | { | |
62 | return myAngle; | |
63 | } | |
64 | ||
65 | //! @return font aspect (regular/bold/italic) | |
66 | Font_FontAspect FontAspect() const | |
67 | { | |
68 | return myFontAspect; | |
69 | } | |
70 | ||
71 | //! @param theValue font aspect (regular/bold/italic) | |
72 | void SetFontAspect (const Font_FontAspect theValue) | |
73 | { | |
74 | myFontAspect = theValue; | |
75 | } | |
76 | ||
77 | //! @return text color | |
78 | const TEL_COLOUR& Color() const | |
79 | { | |
80 | return myColor; | |
81 | } | |
82 | ||
83 | //! @return text color | |
84 | TEL_COLOUR& ChangeColor() | |
85 | { | |
86 | return myColor; | |
87 | } | |
88 | ||
89 | //! @return annotation style | |
90 | Aspect_TypeOfStyleText StyleType() const | |
91 | { | |
92 | return myStyleType; | |
93 | } | |
94 | ||
95 | //! @return subtitle style (none/blend/decale/subtitle) | |
96 | Aspect_TypeOfDisplayText DisplayType() const | |
97 | { | |
98 | return myDisplayType; | |
99 | } | |
100 | ||
101 | void SetDisplayType (const Aspect_TypeOfDisplayText theType) | |
102 | { | |
103 | myDisplayType = theType; | |
104 | } | |
105 | ||
106 | //! @return subtitle color | |
107 | const TEL_COLOUR& SubtitleColor() const | |
108 | { | |
109 | return mySubtitleColor; | |
110 | } | |
111 | ||
112 | //! @return subtitle color | |
113 | TEL_COLOUR& ChangeSubtitleColor() | |
114 | { | |
115 | return mySubtitleColor; | |
116 | } | |
2166f0fa | 117 | |
30f0ad28 | 118 | //! Init and return OpenGl shader program resource. |
119 | //! @return shader program resource. | |
120 | const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Workspace)& theWorkspace) const | |
121 | { | |
122 | if (!myResources.IsShaderReady()) | |
123 | { | |
124 | myResources.BuildShader (theWorkspace, myShaderProgram); | |
125 | myResources.SetShaderReady(); | |
126 | } | |
127 | ||
128 | return myResources.ShaderProgram; | |
129 | } | |
130 | ||
5e27df78 | 131 | virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; |
132 | virtual void Release (const Handle(OpenGl_Context)& theContext); | |
2166f0fa | 133 | |
5e27df78 | 134 | protected: |
2166f0fa | 135 | |
30f0ad28 | 136 | TCollection_AsciiString myFont; |
137 | TEL_COLOUR myColor; | |
138 | TEL_COLOUR mySubtitleColor; | |
139 | float myAngle; | |
140 | Aspect_TypeOfStyleText myStyleType; | |
141 | Aspect_TypeOfDisplayText myDisplayType; | |
142 | Font_FontAspect myFontAspect; | |
143 | bool myZoomable; | |
144 | Handle(Graphic3d_ShaderProgram) myShaderProgram; | |
145 | ||
146 | protected: | |
147 | ||
148 | //! OpenGl resources | |
149 | mutable struct Resources | |
150 | { | |
151 | public: | |
152 | Resources() : myIsShaderReady (Standard_False) {} | |
153 | ||
154 | Standard_Boolean IsShaderReady() const { return myIsShaderReady; } | |
f85399e5 | 155 | void SetShaderReady() { myIsShaderReady = Standard_True; } |
156 | void ResetShaderReadiness() { myIsShaderReady = Standard_False; } | |
30f0ad28 | 157 | |
158 | void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader); | |
159 | ||
160 | Handle(OpenGl_ShaderProgram) ShaderProgram; | |
161 | TCollection_AsciiString ShaderProgramId; | |
162 | ||
163 | private: | |
164 | ||
165 | Standard_Boolean myIsShaderReady; | |
166 | ||
167 | } myResources; | |
2166f0fa | 168 | |
5e27df78 | 169 | public: |
170 | ||
1c35b92f | 171 | DEFINE_STANDARD_ALLOC |
5e27df78 | 172 | |
2166f0fa SK |
173 | }; |
174 | ||
a174a3c5 | 175 | #endif // OpenGl_AspectText_Header |