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