File indexing completed on 2026-10-06 09:21:50
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 Standard_EXPORT OpenGl_Text(const occ::handle<Graphic3d_Text>& theTextParams);
0033
0034
0035 Standard_EXPORT ~OpenGl_Text() override;
0036
0037
0038
0039
0040 Standard_EXPORT void Reset(const occ::handle<OpenGl_Context>& theCtx);
0041
0042
0043
0044 const occ::handle<Graphic3d_Text>& Text() const { return myText; }
0045
0046
0047
0048 void SetText(const occ::handle<Graphic3d_Text>& theText) { myText = theText; }
0049
0050
0051 bool Is2D() const { return myIs2d; }
0052
0053
0054 void Set2D(const bool theEnable) { myIs2d = theEnable; }
0055
0056
0057 Standard_EXPORT void SetFontSize(const occ::handle<OpenGl_Context>& theContext,
0058 const int theFontSize);
0059
0060 Standard_EXPORT void Render(const occ::handle<OpenGl_Workspace>& theWorkspace) const override;
0061 Standard_EXPORT void Release(OpenGl_Context* theContext) override;
0062
0063
0064
0065 Standard_EXPORT size_t EstimatedDataSize() const override;
0066
0067
0068 Standard_EXPORT void UpdateDrawStats(Graphic3d_FrameStatsDataTmp& theStats,
0069 bool theIsDetailed) const override;
0070
0071 public:
0072
0073 Standard_EXPORT OpenGl_Text();
0074
0075
0076 Standard_EXPORT static TCollection_AsciiString FontKey(const OpenGl_Aspects& theAspect,
0077 int theHeight,
0078 unsigned int theResolution,
0079 Font_Hinting theFontHinting);
0080
0081
0082 Standard_EXPORT static occ::handle<OpenGl_Font> FindFont(
0083 const occ::handle<OpenGl_Context>& theCtx,
0084 const OpenGl_Aspects& theAspect,
0085 int theHeight,
0086 unsigned int theResolution,
0087 Font_Hinting theFontHinting,
0088 const TCollection_AsciiString& theKey);
0089
0090
0091 Standard_EXPORT static void StringSize(const occ::handle<OpenGl_Context>& theCtx,
0092 const NCollection_String& theText,
0093 const OpenGl_Aspects& theTextAspect,
0094 const float theHeight,
0095 const unsigned int theResolution,
0096 const Font_Hinting theFontHinting,
0097 float& theWidth,
0098 float& theAscent,
0099 float& theDescent);
0100
0101
0102 Standard_EXPORT void Render(
0103 const occ::handle<OpenGl_Context>& theCtx,
0104 const OpenGl_Aspects& theTextAspect,
0105 unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION,
0106 Font_Hinting theFontHinting = Font_Hinting_Off) const;
0107
0108
0109 Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override;
0110
0111
0112 public:
0113
0114 Standard_DEPRECATED(
0115 "Deprecated method Init() with obsolete arguments, use Init() and Text() instead of it")
0116 Standard_EXPORT void Init(const occ::handle<OpenGl_Context>& theCtx,
0117 const char* theText,
0118 const NCollection_Vec3<float>& thePoint);
0119
0120
0121 Standard_DEPRECATED("Deprecated method SetPosition(), use Graphic3d_Text for it")
0122 Standard_EXPORT void SetPosition(const NCollection_Vec3<float>& thePoint);
0123
0124 protected:
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 void setupMatrix(const occ::handle<OpenGl_Context>& theCtx,
0134 const OpenGl_Aspects& theTextAspect,
0135 const NCollection_Vec3<float>& theDVec) const;
0136
0137
0138 void drawText(const occ::handle<OpenGl_Context>& theCtx,
0139 const OpenGl_Aspects& theTextAspect) const;
0140
0141
0142 void drawRect(const occ::handle<OpenGl_Context>& theCtx,
0143 const OpenGl_Aspects& theTextAspect,
0144 const NCollection_Vec4<float>& theColorSubs) const;
0145
0146
0147 void render(const occ::handle<OpenGl_Context>& theCtx,
0148 const OpenGl_Aspects& theTextAspect,
0149 const NCollection_Vec4<float>& theColorText,
0150 const NCollection_Vec4<float>& theColorSubs,
0151 unsigned int theResolution,
0152 Font_Hinting theFontHinting) const;
0153
0154 protected:
0155 occ::handle<Graphic3d_Text> myText;
0156 mutable occ::handle<OpenGl_Font> myFont;
0157 mutable NCollection_DynamicArray<GLuint> myTextures;
0158 mutable NCollection_DynamicArray<occ::handle<OpenGl_VertexBuffer>>
0159 myVertsVbo;
0160
0161 mutable NCollection_DynamicArray<occ::handle<OpenGl_VertexBuffer>> myTCrdsVbo;
0162 mutable occ::handle<OpenGl_VertexBuffer> myBndVertsVbo;
0163
0164 mutable Font_Rect myBndBox;
0165
0166 protected:
0167 mutable NCollection_Mat4<double> myProjMatrix;
0168 mutable NCollection_Mat4<double> myModelMatrix;
0169 mutable NCollection_Mat4<double> myOrientationMatrix;
0170 mutable NCollection_Vec3<double> myWinXYZ;
0171 mutable GLdouble myScaleHeight;
0172
0173 protected:
0174 bool myIs2d;
0175
0176 public:
0177 DEFINE_STANDARD_ALLOC
0178 };
0179
0180 #endif