0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / Graphic3d / Graphic3d_AspectText3d.cxx
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 //    30/11/98 ; FMN : S3819. Textes always visible.   
17 //-Version  
18 //-Design Declaration of variables specific to the context
19 //    of trace of texts 3d
20 //-Warning  A context of trace of text is defined by :
21 //    - the font used
22 //    - the color
23 //    - the scale
24 //    - the space between characters
25 //-References 
26 //-Language C++ 2.0
27 //-Declarations
28 // for the class
29
30 #include <Font_NameOfFont.hxx>
31 #include <Graphic3d_AspectText3d.hxx>
32 #include <Graphic3d_AspectTextDefinitionError.hxx>
33 #include <OSD_Environment.hxx>
34 #include <Quantity_Color.hxx>
35 #include <Standard_Type.hxx>
36 #include <TCollection_AsciiString.hxx>
37
38 //-Aliases
39 //-Global data definitions
40 //  -- la font utilisee
41 //  MyFont    : NameOfFont;
42 //  -- la couleur
43 //  MyColor   : Color;
44 //  -- l'echelle
45 //  MyFactor  : Standard_Real;
46 //  -- l'espace entre caracteres
47 //  MySpace   : Standard_Real;
48 //  -- le style
49 //  MyStyle   : TypeOfStyleText;
50 //  -- le display type
51 //  MyDisplayType : TypeOfDisplayText;
52 //  -- la couleur du sous-titrage et pour le fond en mode decalage.
53 //  MyColorSubTitle : Color;
54 //-Constructors
55 //-Destructors
56 //-Methods, in order
57 Graphic3d_AspectText3d::Graphic3d_AspectText3d ():
58 MyFont (Font_NOF_ASCII_MONO), MyColor (Quantity_NOC_YELLOW), MyFactor (1.0), MySpace (0.0), MyStyle (Aspect_TOST_NORMAL), MyDisplayType (Aspect_TODT_NORMAL), MyColorSubTitle (Quantity_NOC_WHITE) {
59   MyTextZoomable = Standard_False;
60   MyTextAngle = 0.0;
61   MyTextFontAspect = Font_FA_Regular;
62 }
63
64 Graphic3d_AspectText3d::Graphic3d_AspectText3d (
65   const Quantity_Color& AColor, 
66   const Standard_CString AFont, 
67   const Standard_Real AFactor, 
68   const Standard_Real ASpace,
69   const Aspect_TypeOfStyleText AStyle,
70   const Aspect_TypeOfDisplayText ADisplayType):
71 MyFont(AFont), MyColor (AColor), MyFactor (AFactor), MySpace (ASpace), MyStyle (AStyle), MyDisplayType(ADisplayType), MyColorSubTitle   (Quantity_NOC_WHITE) {
72   MyTextZoomable = Standard_False;
73   MyTextAngle = 0.0;
74   MyTextFontAspect = Font_FA_Regular;
75   if(MyFont.Length() == 0)
76     MyFont.AssignCat(Font_NOF_ASCII_MONO);
77
78   if (AFactor <= 0.0)
79     Graphic3d_AspectTextDefinitionError::Raise
80     ("Bad value for TextScaleFactor");
81
82 }
83
84 void Graphic3d_AspectText3d::SetColor (const Quantity_Color& AColor) {
85
86   MyColor = AColor;
87
88 }
89
90 void Graphic3d_AspectText3d::SetExpansionFactor (const Standard_Real AFactor) {
91
92   if (AFactor <= 0.0)
93     Graphic3d_AspectTextDefinitionError::Raise
94     ("Bad value for TextScaleFactor");
95
96   MyFactor = AFactor;
97
98 }
99
100 void Graphic3d_AspectText3d::SetFont (const Standard_CString AFont) {
101
102
103   TCollection_AsciiString aTemp("");
104   if( !strlen(AFont))
105     aTemp.AssignCat(Font_NOF_ASCII_MONO);
106   else
107     aTemp.AssignCat(AFont);
108   MyFont = aTemp;  
109 }
110
111 void Graphic3d_AspectText3d::SetSpace (const Standard_Real ASpace) {
112
113   MySpace = ASpace;
114
115 }
116
117 void Graphic3d_AspectText3d::SetStyle(const Aspect_TypeOfStyleText AStyle) {
118
119   MyStyle = AStyle;
120
121 }
122
123 void Graphic3d_AspectText3d::SetDisplayType(const Aspect_TypeOfDisplayText ADisplayType) {
124
125   MyDisplayType = ADisplayType;
126
127 }
128
129 void Graphic3d_AspectText3d::SetColorSubTitle (const Quantity_Color& AColor) {
130
131   MyColorSubTitle = AColor;
132
133
134 }
135
136
137 void Graphic3d_AspectText3d::SetTextZoomable(const Standard_Boolean AFlag) 
138 {
139
140   MyTextZoomable = AFlag;
141
142 }
143
144 Standard_Boolean Graphic3d_AspectText3d::GetTextZoomable() const
145 {
146   return MyTextZoomable;
147 }
148
149 void Graphic3d_AspectText3d::SetTextAngle(const Standard_Real AAngle) 
150 {
151   MyTextAngle = AAngle;
152 }
153
154 Standard_Real Graphic3d_AspectText3d::GetTextAngle() const
155 {
156   return MyTextAngle;
157 }
158
159 void Graphic3d_AspectText3d::SetTextFontAspect(const Font_FontAspect AFontAspect) 
160 {
161   MyTextFontAspect = AFontAspect;
162 }
163
164 Font_FontAspect Graphic3d_AspectText3d::GetTextFontAspect() const
165 {
166   return MyTextFontAspect;
167 }
168
169
170
171 void Graphic3d_AspectText3d::Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AFactor, Standard_Real& ASpace) const {
172
173   AColor    = MyColor;
174   AFont     = MyFont.ToCString();
175   AFactor   = MyFactor;
176   ASpace    = MySpace;
177
178 }
179 void Graphic3d_AspectText3d::Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AFactor, Standard_Real& ASpace, Aspect_TypeOfStyleText& AStyle,Aspect_TypeOfDisplayText& ADisplayType,Quantity_Color& AColorSubTitle) const {
180
181   AColor          = MyColor;
182   AFont           = MyFont.ToCString();
183   AFactor         = MyFactor;
184   ASpace          = MySpace;
185   AStyle          = MyStyle;
186   ADisplayType    = MyDisplayType;
187   AColorSubTitle  = MyColorSubTitle;
188
189 }
190 void Graphic3d_AspectText3d::Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AFactor, Standard_Real& ASpace, Aspect_TypeOfStyleText& AStyle,Aspect_TypeOfDisplayText& ADisplayType,Quantity_Color& AColorSubTitle, Standard_Boolean& ATextZoomable,Standard_Real& ATextAngle ) const {
191
192   AColor          = MyColor;
193   AFont           = MyFont.ToCString();
194   AFactor         = MyFactor;
195   ASpace          = MySpace;
196   AStyle          = MyStyle;
197   ADisplayType    = MyDisplayType;
198   AColorSubTitle  = MyColorSubTitle;
199
200   ATextZoomable   = MyTextZoomable;  
201   ATextAngle      = MyTextAngle;  
202
203 }
204
205 void Graphic3d_AspectText3d::Values ( Quantity_Color& AColor, 
206                                       Standard_CString& AFont,
207                                       Standard_Real& AFactor, 
208                                       Standard_Real& ASpace,
209                                       Aspect_TypeOfStyleText& AStyle,
210                                       Aspect_TypeOfDisplayText& ADisplayType,
211                                       Quantity_Color& AColorSubTitle, 
212                                       Standard_Boolean& ATextZoomable,
213                                       Standard_Real& ATextAngle,
214                                       Font_FontAspect& ATextFontAspect ) const 
215 {
216
217   AColor          = MyColor;
218   AFont           = MyFont.ToCString();
219   AFactor         = MyFactor;
220   ASpace          = MySpace;
221   AStyle          = MyStyle;
222   ADisplayType    = MyDisplayType;
223   AColorSubTitle  = MyColorSubTitle;
224
225   ATextZoomable   = MyTextZoomable;  
226   ATextAngle      = MyTextAngle;  
227   ATextFontAspect = MyTextFontAspect;
228
229 }
230
231 void Graphic3d_AspectText3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram)
232 {
233   MyShaderProgram = theProgram;
234 }
235
236 const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectText3d::ShaderProgram() const
237 {
238   return MyShaderProgram;
239 }