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>
28 #include <Handle_OpenGl_ShaderProgram.hxx>
30 //! Text representation parameters
31 class OpenGl_AspectText : public OpenGl_Element
36 Standard_EXPORT OpenGl_AspectText();
37 Standard_EXPORT virtual ~OpenGl_AspectText();
40 Standard_EXPORT void SetAspect (const CALL_DEF_CONTEXTTEXT& theAspect);
42 //! @return font family name
43 const TCollection_AsciiString& FontName() const
48 //! @return font family name
49 TCollection_AsciiString& ChangeFontName()
54 //! @return is zoomable flag
55 bool IsZoomable() const
60 //! @return rotation angle
66 //! @return font aspect (regular/bold/italic)
67 Font_FontAspect FontAspect() const
72 //! @param theValue font aspect (regular/bold/italic)
73 void SetFontAspect (const Font_FontAspect theValue)
75 myFontAspect = theValue;
78 //! @return text color
79 const TEL_COLOUR& Color() const
84 //! @return text color
85 TEL_COLOUR& ChangeColor()
90 //! @return annotation style
91 Aspect_TypeOfStyleText StyleType() const
96 //! @return subtitle style (none/blend/decale/subtitle)
97 Aspect_TypeOfDisplayText DisplayType() const
102 void SetDisplayType (const Aspect_TypeOfDisplayText theType)
104 myDisplayType = theType;
107 //! @return subtitle color
108 const TEL_COLOUR& SubtitleColor() const
110 return mySubtitleColor;
113 //! @return subtitle color
114 TEL_COLOUR& ChangeSubtitleColor()
116 return mySubtitleColor;
119 //! Init and return OpenGl shader program resource.
120 //! @return shader program resource.
121 const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
123 if (!myResources.IsShaderReady())
125 myResources.BuildShader (theCtx, myShaderProgram);
126 myResources.SetShaderReady();
129 return myResources.ShaderProgram;
132 Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
133 Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
137 TCollection_AsciiString myFont;
139 TEL_COLOUR mySubtitleColor;
141 Aspect_TypeOfStyleText myStyleType;
142 Aspect_TypeOfDisplayText myDisplayType;
143 Font_FontAspect myFontAspect;
145 Handle(Graphic3d_ShaderProgram) myShaderProgram;
150 mutable struct Resources
153 Resources() : myIsShaderReady (Standard_False) {}
155 Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
156 void SetShaderReady() { myIsShaderReady = Standard_True; }
157 void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
159 Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx,
160 const Handle(Graphic3d_ShaderProgram)& theShader);
162 Handle(OpenGl_ShaderProgram) ShaderProgram;
163 TCollection_AsciiString ShaderProgramId;
167 Standard_Boolean myIsShaderReady;
173 DEFINE_STANDARD_ALLOC
177 #endif // OpenGl_AspectText_Header