1 // Created on: 2011-07-13
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2013 OPEN CASCADE SAS
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.
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.
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.
20 #ifndef OpenGl_AspectText_Header
21 #define OpenGl_AspectText_Header
23 #include <InterfaceGraphic_Graphic3d.hxx>
24 #include <Font_FontAspect.hxx>
25 #include <Aspect_TypeOfStyleText.hxx>
26 #include <Aspect_TypeOfDisplayText.hxx>
28 #include <TCollection_AsciiString.hxx>
30 #include <OpenGl_Element.hxx>
31 #include <Handle_OpenGl_ShaderProgram.hxx>
33 //! Text representation parameters
34 class OpenGl_AspectText : public OpenGl_Element
40 virtual ~OpenGl_AspectText();
43 void SetAspect (const CALL_DEF_CONTEXTTEXT& theAspect);
45 //! @return font family name
46 const TCollection_AsciiString& FontName() const
51 //! @return font family name
52 TCollection_AsciiString& ChangeFontName()
57 //! @return is zoomable flag
58 bool IsZoomable() const
63 //! @return rotation angle
69 //! @return font aspect (regular/bold/italic)
70 Font_FontAspect FontAspect() const
75 //! @param theValue font aspect (regular/bold/italic)
76 void SetFontAspect (const Font_FontAspect theValue)
78 myFontAspect = theValue;
81 //! @return text color
82 const TEL_COLOUR& Color() const
87 //! @return text color
88 TEL_COLOUR& ChangeColor()
93 //! @return annotation style
94 Aspect_TypeOfStyleText StyleType() const
99 //! @return subtitle style (none/blend/decale/subtitle)
100 Aspect_TypeOfDisplayText DisplayType() const
102 return myDisplayType;
105 void SetDisplayType (const Aspect_TypeOfDisplayText theType)
107 myDisplayType = theType;
110 //! @return subtitle color
111 const TEL_COLOUR& SubtitleColor() const
113 return mySubtitleColor;
116 //! @return subtitle color
117 TEL_COLOUR& ChangeSubtitleColor()
119 return mySubtitleColor;
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
126 if (!myResources.IsShaderReady())
128 myResources.BuildShader (theWorkspace, myShaderProgram);
129 myResources.SetShaderReady();
132 return myResources.ShaderProgram;
135 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
136 virtual void Release (const Handle(OpenGl_Context)& theContext);
140 TCollection_AsciiString myFont;
142 TEL_COLOUR mySubtitleColor;
144 Aspect_TypeOfStyleText myStyleType;
145 Aspect_TypeOfDisplayText myDisplayType;
146 Font_FontAspect myFontAspect;
148 Handle(Graphic3d_ShaderProgram) myShaderProgram;
153 mutable struct Resources
156 Resources() : myIsShaderReady (Standard_False) {}
158 Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
159 void SetShaderReady() { myIsShaderReady = Standard_True; }
160 void ResetShader () { myIsShaderReady = Standard_False; }
162 void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader);
164 Handle(OpenGl_ShaderProgram) ShaderProgram;
165 TCollection_AsciiString ShaderProgramId;
169 Standard_Boolean myIsShaderReady;
175 DEFINE_STANDARD_ALLOC
179 #endif // OpenGl_AspectText_Header