4bb65b4537d74dec3a043550aae477172d3b763e
[occt.git] / src / Graphic3d / Graphic3d_AspectText3d.hxx
1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _Graphic3d_AspectText3d_HeaderFile
17 #define _Graphic3d_AspectText3d_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
21
22 #include <TCollection_AsciiString.hxx>
23 #include <Quantity_Color.hxx>
24 #include <Standard_Real.hxx>
25 #include <Aspect_TypeOfStyleText.hxx>
26 #include <Aspect_TypeOfDisplayText.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <Font_FontAspect.hxx>
29 #include <Graphic3d_ShaderProgram.hxx>
30 #include <MMgt_TShared.hxx>
31 #include <Standard_CString.hxx>
32 class Graphic3d_AspectTextDefinitionError;
33 class Quantity_Color;
34
35
36 class Graphic3d_AspectText3d;
37 DEFINE_STANDARD_HANDLE(Graphic3d_AspectText3d, MMgt_TShared)
38
39 //! Creates and updates a group of attributes for
40 //! text primitives. This group contains the colour,
41 //! font, expansion factor (height/width ratio), and
42 //! inter-character space.
43 //!
44 //! NOTE: The font name is stored in the aspect instance
45 //! so it is safe to pass it as const char* to OpenGl package
46 //! without copying the string. However, the aspect should not
47 //! be deleted until the text drawn using this aspect is no longer
48 //! visible. The best practice is to keep the aspect in the object's drawer.
49 class Graphic3d_AspectText3d : public MMgt_TShared
50 {
51
52 public:
53
54   
55   //! Creates a context table for text primitives
56   //! defined with the following default values:
57   //!
58   //! Colour                    : NOC_YELLOW
59   //! Font                      : NOF_ASCII_MONO
60   //! Expansion factor          : 1.
61   //! Space between characters  : 0.
62   //! The style                 : TOST_NORMAL
63   //! The display type          : TODT_NORMAL
64   Standard_EXPORT Graphic3d_AspectText3d();
65   
66   //! Creates a context table for text primitives
67   //! defined with the specified values.
68   //! AFont may be to take means from User(example "Courier New")
69   //! or Font name defined in Font_NameOfFont(example Font_NOF_ASCII_MONO)
70   //! or use default font("Courier")
71   Standard_EXPORT Graphic3d_AspectText3d(const Quantity_Color& AColor, const Standard_CString AFont, const Standard_Real AExpansionFactor, const Standard_Real ASpace, const Aspect_TypeOfStyleText AStyle = Aspect_TOST_NORMAL, const Aspect_TypeOfDisplayText ADisplayType = Aspect_TODT_NORMAL);
72   
73   //! Modifies the colour of <me>.
74   Standard_EXPORT void SetColor (const Quantity_Color& AColor);
75   
76   //! Modifies the expansion factor (height/width ratio)
77   //! If the factor is less than 1, the characters will
78   //! be higher than they are wide.
79   Standard_EXPORT void SetExpansionFactor (const Standard_Real AFactor);
80   
81   //! Modifies the font of <me>.
82   Standard_EXPORT void SetFont (const Standard_CString AFont);
83   
84   //! Modifies the space between the characters.
85   Standard_EXPORT void SetSpace (const Standard_Real ASpace);
86   
87   //! Modifies the style of the text.
88   //! TOST_NORMAL     Default text. The text is displayed like any other graphic object.
89   //! This text can be hidden by another object that is nearest from the
90   //! point of view.
91   //! TOST_ANNOTATION The text is always visible. The texte is displayed
92   //! over the other object according to the priority.
93   Standard_EXPORT void SetStyle (const Aspect_TypeOfStyleText AStyle);
94   
95   //! Define the display type of the text.
96   //!
97   //! TODT_NORMAL     Default display. Text only.
98   //! TODT_SUBTITLE   There is a subtitle under the text.
99   //! TODT_DEKALE     The text is displayed with a 3D style.
100   //! TODT_BLEND      The text is displayed in XOR.
101   //! TODT_DIMENSION  Dimension line under text will be invisible.
102   Standard_EXPORT void SetDisplayType (const Aspect_TypeOfDisplayText ADisplayType);
103   
104   //! Modifies the colour of the subtitle for the TODT_SUBTITLE TextDisplayType
105   //! and the colour of backgroubd for the TODT_DEKALE TextDisplayType.
106   Standard_EXPORT void SetColorSubTitle (const Quantity_Color& AColor);
107   
108   //! Turns usage of text zoomable on/off
109   Standard_EXPORT void SetTextZoomable (const Standard_Boolean AFlag);
110   
111   //! Returns TRUE when the Text Zoomable is on.
112   Standard_EXPORT Standard_Boolean GetTextZoomable() const;
113   
114   //! Turns usage of text rotated
115   Standard_EXPORT void SetTextAngle (const Standard_Real AAngle);
116   
117   //! Returns Angle of degree
118   Standard_EXPORT Standard_Real GetTextAngle() const;
119   
120   //! Turns usage of Aspect text
121   Standard_EXPORT void SetTextFontAspect (const Font_FontAspect AFontAspect);
122   
123   //! Returns text FontAspect
124   Standard_EXPORT Font_FontAspect GetTextFontAspect() const;
125   
126   //! Sets up OpenGL/GLSL shader program.
127   Standard_EXPORT void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram);
128   
129   //! Returns the current values of the group <me>.
130   Standard_EXPORT void Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AnExpansionFactor, Standard_Real& ASpace) const;
131   
132   //! Returns the current values of the group <me>.
133   Standard_EXPORT void Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AnExpansionFactor, Standard_Real& ASpace, Aspect_TypeOfStyleText& AStyle, Aspect_TypeOfDisplayText& ADisplayType, Quantity_Color& AColorSubTitle) const;
134   
135   //! Returns the current values of the group <me>.
136   Standard_EXPORT void Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AnExpansionFactor, Standard_Real& ASpace, Aspect_TypeOfStyleText& AStyle, Aspect_TypeOfDisplayText& ADisplayType, Quantity_Color& AColorSubTitle, Standard_Boolean& ATextZoomable, Standard_Real& ATextAngle) const;
137   
138   //! Returns the current values of the group <me>.
139   Standard_EXPORT void Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AnExpansionFactor, Standard_Real& ASpace, Aspect_TypeOfStyleText& AStyle, Aspect_TypeOfDisplayText& ADisplayType, Quantity_Color& AColorSubTitle, Standard_Boolean& ATextZoomable, Standard_Real& ATextAngle, Font_FontAspect& ATextFontAspect) const;
140   
141   Standard_EXPORT const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const;
142
143
144
145
146   DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectText3d,MMgt_TShared)
147
148 protected:
149
150
151
152
153 private:
154
155
156   TCollection_AsciiString MyFont;
157   Quantity_Color MyColor;
158   Standard_Real MyFactor;
159   Standard_Real MySpace;
160   Aspect_TypeOfStyleText MyStyle;
161   Aspect_TypeOfDisplayText MyDisplayType;
162   Quantity_Color MyColorSubTitle;
163   Standard_Boolean MyTextZoomable;
164   Standard_Real MyTextAngle;
165   Font_FontAspect MyTextFontAspect;
166   Handle(Graphic3d_ShaderProgram) MyShaderProgram;
167
168
169 };
170
171
172
173
174
175
176
177 #endif // _Graphic3d_AspectText3d_HeaderFile