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>
24 #include <TCollection_AsciiString.hxx>
26 #include <OpenGl_Element.hxx>
27 #include <Handle_OpenGl_ShaderProgram.hxx>
29 //! Text representation parameters
30 class OpenGl_AspectText : public OpenGl_Element
36 virtual ~OpenGl_AspectText();
39 void SetAspect (const CALL_DEF_CONTEXTTEXT& theAspect);
41 //! @return font family name
42 const TCollection_AsciiString& FontName() const
47 //! @return font family name
48 TCollection_AsciiString& ChangeFontName()
53 //! @return is zoomable flag
54 bool IsZoomable() const
59 //! @return rotation angle
65 //! @return font aspect (regular/bold/italic)
66 Font_FontAspect FontAspect() const
71 //! @param theValue font aspect (regular/bold/italic)
72 void SetFontAspect (const Font_FontAspect theValue)
74 myFontAspect = theValue;
77 //! @return text color
78 const TEL_COLOUR& Color() const
83 //! @return text color
84 TEL_COLOUR& ChangeColor()
89 //! @return annotation style
90 Aspect_TypeOfStyleText StyleType() const
95 //! @return subtitle style (none/blend/decale/subtitle)
96 Aspect_TypeOfDisplayText DisplayType() const
101 void SetDisplayType (const Aspect_TypeOfDisplayText theType)
103 myDisplayType = theType;
106 //! @return subtitle color
107 const TEL_COLOUR& SubtitleColor() const
109 return mySubtitleColor;
112 //! @return subtitle color
113 TEL_COLOUR& ChangeSubtitleColor()
115 return mySubtitleColor;
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
122 if (!myResources.IsShaderReady())
124 myResources.BuildShader (theWorkspace, myShaderProgram);
125 myResources.SetShaderReady();
128 return myResources.ShaderProgram;
131 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
132 virtual void Release (const Handle(OpenGl_Context)& theContext);
136 TCollection_AsciiString myFont;
138 TEL_COLOUR mySubtitleColor;
140 Aspect_TypeOfStyleText myStyleType;
141 Aspect_TypeOfDisplayText myDisplayType;
142 Font_FontAspect myFontAspect;
144 Handle(Graphic3d_ShaderProgram) myShaderProgram;
149 mutable struct Resources
152 Resources() : myIsShaderReady (Standard_False) {}
154 Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
155 void SetShaderReady() { myIsShaderReady = Standard_True; }
156 void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
158 void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader);
160 Handle(OpenGl_ShaderProgram) ShaderProgram;
161 TCollection_AsciiString ShaderProgramId;
165 Standard_Boolean myIsShaderReady;
171 DEFINE_STANDARD_ALLOC
175 #endif // OpenGl_AspectText_Header