1 // Created on: 2011-07-13
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2013 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef OpenGl_AspectText_Header
17 #define OpenGl_AspectText_Header
19 #include <InterfaceGraphic_Graphic3d.hxx>
20 #include <Font_FontAspect.hxx>
21 #include <Aspect_TypeOfStyleText.hxx>
22 #include <Aspect_TypeOfDisplayText.hxx>
23 #include <Graphic3d_CAspectText.hxx>
25 #include <TCollection_AsciiString.hxx>
27 #include <OpenGl_Element.hxx>
29 class OpenGl_ShaderProgram;
31 //! Text representation parameters
32 class OpenGl_AspectText : public OpenGl_Element
37 Standard_EXPORT OpenGl_AspectText();
38 Standard_EXPORT virtual ~OpenGl_AspectText();
41 Standard_EXPORT void SetAspect (const CALL_DEF_CONTEXTTEXT& theAspect);
43 //! @return font family name
44 const TCollection_AsciiString& FontName() const
49 //! @return font family name
50 TCollection_AsciiString& ChangeFontName()
55 //! @return is zoomable flag
56 bool IsZoomable() const
61 //! @return rotation angle
67 //! @return font aspect (regular/bold/italic)
68 Font_FontAspect FontAspect() const
73 //! @param theValue font aspect (regular/bold/italic)
74 void SetFontAspect (const Font_FontAspect theValue)
76 myFontAspect = theValue;
79 //! @return text color
80 const TEL_COLOUR& Color() const
85 //! @return text color
86 TEL_COLOUR& ChangeColor()
91 //! @return annotation style
92 Aspect_TypeOfStyleText StyleType() const
97 //! @return subtitle style (none/blend/decale/subtitle)
98 Aspect_TypeOfDisplayText DisplayType() const
100 return myDisplayType;
103 void SetDisplayType (const Aspect_TypeOfDisplayText theType)
105 myDisplayType = theType;
108 //! @return subtitle color
109 const TEL_COLOUR& SubtitleColor() const
111 return mySubtitleColor;
114 //! @return subtitle color
115 TEL_COLOUR& ChangeSubtitleColor()
117 return mySubtitleColor;
120 //! Init and return OpenGl shader program resource.
121 //! @return shader program resource.
122 const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
124 if (!myResources.IsShaderReady())
126 myResources.BuildShader (theCtx, myShaderProgram);
127 myResources.SetShaderReady();
130 return myResources.ShaderProgram;
133 Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
134 Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
138 TCollection_AsciiString myFont;
140 TEL_COLOUR mySubtitleColor;
142 Aspect_TypeOfStyleText myStyleType;
143 Aspect_TypeOfDisplayText myDisplayType;
144 Font_FontAspect myFontAspect;
146 Handle(Graphic3d_ShaderProgram) myShaderProgram;
151 mutable struct Resources
154 Resources() : myIsShaderReady (Standard_False) {}
156 Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
157 void SetShaderReady() { myIsShaderReady = Standard_True; }
158 void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
160 Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx,
161 const Handle(Graphic3d_ShaderProgram)& theShader);
163 Handle(OpenGl_ShaderProgram) ShaderProgram;
164 TCollection_AsciiString ShaderProgramId;
168 Standard_Boolean myIsShaderReady;
174 DEFINE_STANDARD_ALLOC
178 #endif // OpenGl_AspectText_Header