File indexing completed on 2025-01-18 10:04:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef OpenGl_Text_HeaderFile
0017 #define OpenGl_Text_HeaderFile
0018
0019 #include <OpenGl_Element.hxx>
0020
0021 #include <OpenGl_TextBuilder.hxx>
0022
0023 #include <Graphic3d_RenderingParams.hxx>
0024 #include <Graphic3d_Text.hxx>
0025
0026
0027 class OpenGl_Text : public OpenGl_Element
0028 {
0029
0030 public:
0031
0032
0033 Standard_EXPORT OpenGl_Text (const Handle(Graphic3d_Text)& theTextParams);
0034
0035
0036 Standard_EXPORT virtual ~OpenGl_Text();
0037
0038
0039
0040
0041 Standard_EXPORT void Reset (const Handle(OpenGl_Context)& theCtx);
0042
0043
0044
0045 const Handle(Graphic3d_Text)& Text() const { return myText; }
0046
0047
0048
0049 void SetText (const Handle(Graphic3d_Text)& theText) { myText = theText; }
0050
0051
0052 Standard_Boolean Is2D() const { return myIs2d; }
0053
0054
0055 void Set2D (const Standard_Boolean theEnable) { myIs2d = theEnable; }
0056
0057
0058 Standard_EXPORT void SetFontSize (const Handle(OpenGl_Context)& theContext,
0059 const Standard_Integer theFontSize);
0060
0061 Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
0062 Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
0063
0064
0065 Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
0066
0067
0068 Standard_EXPORT virtual void UpdateDrawStats (Graphic3d_FrameStatsDataTmp& theStats,
0069 bool theIsDetailed) const Standard_OVERRIDE;
0070
0071 public:
0072
0073
0074 Standard_EXPORT OpenGl_Text();
0075
0076
0077 Standard_EXPORT static TCollection_AsciiString FontKey (const OpenGl_Aspects& theAspect,
0078 Standard_Integer theHeight,
0079 unsigned int theResolution,
0080 Font_Hinting theFontHinting);
0081
0082
0083 Standard_EXPORT static Handle(OpenGl_Font) FindFont (const Handle(OpenGl_Context)& theCtx,
0084 const OpenGl_Aspects& theAspect,
0085 Standard_Integer theHeight,
0086 unsigned int theResolution,
0087 Font_Hinting theFontHinting,
0088 const TCollection_AsciiString& theKey);
0089
0090
0091 Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
0092 const NCollection_String& theText,
0093 const OpenGl_Aspects& theTextAspect,
0094 const Standard_ShortReal theHeight,
0095 const unsigned int theResolution,
0096 const Font_Hinting theFontHinting,
0097 Standard_ShortReal& theWidth,
0098 Standard_ShortReal& theAscent,
0099 Standard_ShortReal& theDescent);
0100
0101
0102 Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
0103 const OpenGl_Aspects& theTextAspect,
0104 unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION,
0105 Font_Hinting theFontHinting = Font_Hinting_Off) const;
0106
0107
0108 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0109
0110
0111 public:
0112
0113
0114 Standard_DEPRECATED("Deprecated method Init() with obsolete arguments, use Init() and Text() instead of it")
0115 Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
0116 const Standard_Utf8Char* theText,
0117 const OpenGl_Vec3& thePoint);
0118
0119
0120 Standard_DEPRECATED("Deprecated method SetPosition(), use Graphic3d_Text for it")
0121 Standard_EXPORT void SetPosition (const OpenGl_Vec3& thePoint);
0122
0123 protected:
0124
0125 friend class OpenGl_Trihedron;
0126 friend class OpenGl_GraduatedTrihedron;
0127
0128
0129 Standard_EXPORT void releaseVbos (OpenGl_Context* theCtx);
0130
0131 private:
0132
0133
0134 void setupMatrix (const Handle(OpenGl_Context)& theCtx,
0135 const OpenGl_Aspects& theTextAspect,
0136 const OpenGl_Vec3& theDVec) const;
0137
0138
0139 void drawText (const Handle(OpenGl_Context)& theCtx,
0140 const OpenGl_Aspects& theTextAspect) const;
0141
0142
0143 void drawRect (const Handle(OpenGl_Context)& theCtx,
0144 const OpenGl_Aspects& theTextAspect,
0145 const OpenGl_Vec4& theColorSubs) const;
0146
0147
0148 void render (const Handle(OpenGl_Context)& theCtx,
0149 const OpenGl_Aspects& theTextAspect,
0150 const OpenGl_Vec4& theColorText,
0151 const OpenGl_Vec4& theColorSubs,
0152 unsigned int theResolution,
0153 Font_Hinting theFontHinting) const;
0154
0155 protected:
0156
0157 Handle(Graphic3d_Text) myText;
0158 mutable Handle(OpenGl_Font) myFont;
0159 mutable NCollection_Vector<GLuint> myTextures;
0160 mutable NCollection_Vector<Handle(OpenGl_VertexBuffer)> myVertsVbo;
0161 mutable NCollection_Vector<Handle(OpenGl_VertexBuffer)> myTCrdsVbo;
0162 mutable Handle(OpenGl_VertexBuffer) myBndVertsVbo;
0163 mutable Font_Rect myBndBox;
0164
0165 protected:
0166
0167 mutable OpenGl_Mat4d myProjMatrix;
0168 mutable OpenGl_Mat4d myModelMatrix;
0169 mutable OpenGl_Mat4d myOrientationMatrix;
0170 mutable OpenGl_Vec3d myWinXYZ;
0171 mutable GLdouble myScaleHeight;
0172
0173 protected:
0174
0175 Standard_Boolean myIs2d;
0176 public:
0177
0178 DEFINE_STANDARD_ALLOC
0179
0180 };
0181
0182 #endif