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