0023415: OSD_FontMgr can't idenify aspect for fonts with names dependant on system...
[occt.git] / src / Graphic3d / Graphic3d_AspectText3d.cxx
CommitLineData
b311480e 1// Created by: NW,JPB,CAL
2// Copyright (c) 1991-1999 Matra Datavision
3// Copyright (c) 1999-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
7fd59977 21// 30/11/98 ; FMN : S3819. Textes always visible.
22
7fd59977 23
24//-Version
25
81bba717 26//-Design Declaration of variables specific to the context
27// of trace of texts 3d
28
29//-Warning A context of trace of text is defined by :
30// - the font used
31// - the color
32// - the scale
33// - the space between characters
7fd59977 34
35//-References
36
37//-Language C++ 2.0
38
39//-Declarations
40
41// for the class
42#include <Graphic3d_AspectText3d.ixx>
43
44#include <TCollection_AsciiString.hxx>
45#include <OSD_Environment.hxx>
46
aff395a3 47#include <Font_NameOfFont.hxx>
7fd59977 48
49//-Aliases
50
51//-Global data definitions
52
53// -- la font utilisee
54// MyFont : NameOfFont;
55
56// -- la couleur
57// MyColor : Color;
58
59// -- l'echelle
60// MyFactor : Standard_Real;
61
62// -- l'espace entre caracteres
63// MySpace : Standard_Real;
64
65// -- le style
66// MyStyle : TypeOfStyleText;
67
68// -- le display type
69// MyDisplayType : TypeOfDisplayText;
70
71// -- la couleur du sous-titrage et pour le fond en mode decalage.
72// MyColorSubTitle : Color;
73
74//-Constructors
75
76//-Destructors
77
78//-Methods, in order
79
80
81
82Graphic3d_AspectText3d::Graphic3d_AspectText3d ():
aff395a3 83MyFont (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) {
7fd59977 84 MyTextZoomable = Standard_False;
85 MyTextAngle = 0.0;
eeaaaefb 86 MyTextFontAspect = Font_FA_Regular;
7fd59977 87}
88
89Graphic3d_AspectText3d::Graphic3d_AspectText3d (
90 const Quantity_Color& AColor,
91 const Standard_CString AFont,
92 const Standard_Real AFactor,
93 const Standard_Real ASpace,
94 const Aspect_TypeOfStyleText AStyle,
95 const Aspect_TypeOfDisplayText ADisplayType):
96MyFont(AFont), MyColor (AColor), MyFactor (AFactor), MySpace (ASpace), MyStyle (AStyle), MyDisplayType(ADisplayType), MyColorSubTitle (Quantity_NOC_WHITE) {
97 MyTextZoomable = Standard_False;
98 MyTextAngle = 0.0;
eeaaaefb 99 MyTextFontAspect = Font_FA_Regular;
7fd59977 100 if(MyFont.Length() == 0)
aff395a3 101 MyFont.AssignCat(Font_NOF_ASCII_MONO);
7fd59977 102
103 if (AFactor <= 0.0)
104 Graphic3d_AspectTextDefinitionError::Raise
105 ("Bad value for TextScaleFactor");
106
107}
108
109void Graphic3d_AspectText3d::SetColor (const Quantity_Color& AColor) {
110
111 MyColor = AColor;
112
113}
114
115void Graphic3d_AspectText3d::SetExpansionFactor (const Standard_Real AFactor) {
116
117 if (AFactor <= 0.0)
118 Graphic3d_AspectTextDefinitionError::Raise
119 ("Bad value for TextScaleFactor");
120
121 MyFactor = AFactor;
122
123}
124
125void Graphic3d_AspectText3d::SetFont (const Standard_CString AFont) {
126
127
128 TCollection_AsciiString aTemp("");
129 if( !strlen(AFont))
aff395a3 130 aTemp.AssignCat(Font_NOF_ASCII_MONO);
7fd59977 131 else
132 aTemp.AssignCat(AFont);
133 MyFont = aTemp;
134}
135
136void Graphic3d_AspectText3d::SetSpace (const Standard_Real ASpace) {
137
138 MySpace = ASpace;
139
140}
141
142void Graphic3d_AspectText3d::SetStyle(const Aspect_TypeOfStyleText AStyle) {
143
144 MyStyle = AStyle;
145
146}
147
148void Graphic3d_AspectText3d::SetDisplayType(const Aspect_TypeOfDisplayText ADisplayType) {
149
150 MyDisplayType = ADisplayType;
151
152}
153
154void Graphic3d_AspectText3d::SetColorSubTitle (const Quantity_Color& AColor) {
155
156 MyColorSubTitle = AColor;
157
158
159}
160
161
162void Graphic3d_AspectText3d::SetTextZoomable(const Standard_Boolean AFlag)
163{
164
165 MyTextZoomable = AFlag;
166
167}
168
169Standard_Boolean Graphic3d_AspectText3d::GetTextZoomable() const
170{
171 return MyTextZoomable;
172}
173
174void Graphic3d_AspectText3d::SetTextAngle(const Standard_Real AAngle)
175{
176 MyTextAngle = AAngle;
177}
178
179Standard_Real Graphic3d_AspectText3d::GetTextAngle() const
180{
181 return MyTextAngle;
182}
183
eeaaaefb 184void Graphic3d_AspectText3d::SetTextFontAspect(const Font_FontAspect AFontAspect)
7fd59977 185{
186 MyTextFontAspect = AFontAspect;
187}
188
eeaaaefb 189Font_FontAspect Graphic3d_AspectText3d::GetTextFontAspect() const
7fd59977 190{
191 return MyTextFontAspect;
192}
193
194
195
196void Graphic3d_AspectText3d::Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AFactor, Standard_Real& ASpace) const {
197
198 AColor = MyColor;
199 AFont = MyFont.ToCString();
200 AFactor = MyFactor;
201 ASpace = MySpace;
202
203}
204void 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 {
205
206 AColor = MyColor;
207 AFont = MyFont.ToCString();
208 AFactor = MyFactor;
209 ASpace = MySpace;
210 AStyle = MyStyle;
211 ADisplayType = MyDisplayType;
212 AColorSubTitle = MyColorSubTitle;
213
214}
215void 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 {
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
228}
229
230void Graphic3d_AspectText3d::Values ( Quantity_Color& AColor,
231 Standard_CString& AFont,
232 Standard_Real& AFactor,
233 Standard_Real& ASpace,
234 Aspect_TypeOfStyleText& AStyle,
235 Aspect_TypeOfDisplayText& ADisplayType,
236 Quantity_Color& AColorSubTitle,
237 Standard_Boolean& ATextZoomable,
238 Standard_Real& ATextAngle,
eeaaaefb 239 Font_FontAspect& ATextFontAspect ) const
7fd59977 240{
241
242 AColor = MyColor;
243 AFont = MyFont.ToCString();
244 AFactor = MyFactor;
245 ASpace = MySpace;
246 AStyle = MyStyle;
247 ADisplayType = MyDisplayType;
248 AColorSubTitle = MyColorSubTitle;
249
250 ATextZoomable = MyTextZoomable;
251 ATextAngle = MyTextAngle;
252 ATextFontAspect = MyTextFontAspect;
253
254}
255
256
257