0027638: Optimisation of testdiff command
[occt.git] / src / Graphic3d / Graphic3d_AspectText3d.cxx
CommitLineData
b311480e 1// Created by: NW,JPB,CAL
2// Copyright (c) 1991-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
7fd59977 16// 30/11/98 ; FMN : S3819. Textes always visible.
7fd59977 17//-Version
81bba717 18//-Design Declaration of variables specific to the context
19// of trace of texts 3d
81bba717 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
7fd59977 25//-References
7fd59977 26//-Language C++ 2.0
7fd59977 27//-Declarations
7fd59977 28// for the class
7fd59977 29
aff395a3 30#include <Font_NameOfFont.hxx>
42cf5bc1 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>
7fd59977 37
92efcf78 38IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectText3d,MMgt_TShared)
39
7fd59977 40//-Aliases
7fd59977 41//-Global data definitions
7fd59977 42// -- la font utilisee
43// MyFont : NameOfFont;
7fd59977 44// -- la couleur
45// MyColor : Color;
7fd59977 46// -- l'echelle
47// MyFactor : Standard_Real;
7fd59977 48// -- l'espace entre caracteres
49// MySpace : Standard_Real;
7fd59977 50// -- le style
51// MyStyle : TypeOfStyleText;
7fd59977 52// -- le display type
53// MyDisplayType : TypeOfDisplayText;
7fd59977 54// -- la couleur du sous-titrage et pour le fond en mode decalage.
55// MyColorSubTitle : Color;
7fd59977 56//-Constructors
7fd59977 57//-Destructors
7fd59977 58//-Methods, in order
7fd59977 59Graphic3d_AspectText3d::Graphic3d_AspectText3d ():
aff395a3 60MyFont (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 61 MyTextZoomable = Standard_False;
62 MyTextAngle = 0.0;
eeaaaefb 63 MyTextFontAspect = Font_FA_Regular;
7fd59977 64}
65
66Graphic3d_AspectText3d::Graphic3d_AspectText3d (
67 const Quantity_Color& AColor,
68 const Standard_CString AFont,
69 const Standard_Real AFactor,
70 const Standard_Real ASpace,
71 const Aspect_TypeOfStyleText AStyle,
72 const Aspect_TypeOfDisplayText ADisplayType):
73MyFont(AFont), MyColor (AColor), MyFactor (AFactor), MySpace (ASpace), MyStyle (AStyle), MyDisplayType(ADisplayType), MyColorSubTitle (Quantity_NOC_WHITE) {
74 MyTextZoomable = Standard_False;
75 MyTextAngle = 0.0;
eeaaaefb 76 MyTextFontAspect = Font_FA_Regular;
7fd59977 77 if(MyFont.Length() == 0)
aff395a3 78 MyFont.AssignCat(Font_NOF_ASCII_MONO);
7fd59977 79
80 if (AFactor <= 0.0)
81 Graphic3d_AspectTextDefinitionError::Raise
82 ("Bad value for TextScaleFactor");
83
84}
85
86void Graphic3d_AspectText3d::SetColor (const Quantity_Color& AColor) {
87
88 MyColor = AColor;
89
90}
91
92void Graphic3d_AspectText3d::SetExpansionFactor (const Standard_Real AFactor) {
93
94 if (AFactor <= 0.0)
95 Graphic3d_AspectTextDefinitionError::Raise
96 ("Bad value for TextScaleFactor");
97
98 MyFactor = AFactor;
99
100}
101
102void Graphic3d_AspectText3d::SetFont (const Standard_CString AFont) {
103
104
105 TCollection_AsciiString aTemp("");
106 if( !strlen(AFont))
aff395a3 107 aTemp.AssignCat(Font_NOF_ASCII_MONO);
7fd59977 108 else
109 aTemp.AssignCat(AFont);
110 MyFont = aTemp;
111}
112
113void Graphic3d_AspectText3d::SetSpace (const Standard_Real ASpace) {
114
115 MySpace = ASpace;
116
117}
118
119void Graphic3d_AspectText3d::SetStyle(const Aspect_TypeOfStyleText AStyle) {
120
121 MyStyle = AStyle;
122
123}
124
125void Graphic3d_AspectText3d::SetDisplayType(const Aspect_TypeOfDisplayText ADisplayType) {
126
127 MyDisplayType = ADisplayType;
128
129}
130
131void Graphic3d_AspectText3d::SetColorSubTitle (const Quantity_Color& AColor) {
132
133 MyColorSubTitle = AColor;
134
135
136}
137
138
139void Graphic3d_AspectText3d::SetTextZoomable(const Standard_Boolean AFlag)
140{
141
142 MyTextZoomable = AFlag;
143
144}
145
146Standard_Boolean Graphic3d_AspectText3d::GetTextZoomable() const
147{
148 return MyTextZoomable;
149}
150
151void Graphic3d_AspectText3d::SetTextAngle(const Standard_Real AAngle)
152{
153 MyTextAngle = AAngle;
154}
155
156Standard_Real Graphic3d_AspectText3d::GetTextAngle() const
157{
158 return MyTextAngle;
159}
160
eeaaaefb 161void Graphic3d_AspectText3d::SetTextFontAspect(const Font_FontAspect AFontAspect)
7fd59977 162{
163 MyTextFontAspect = AFontAspect;
164}
165
eeaaaefb 166Font_FontAspect Graphic3d_AspectText3d::GetTextFontAspect() const
7fd59977 167{
168 return MyTextFontAspect;
169}
170
171
172
173void Graphic3d_AspectText3d::Values (Quantity_Color& AColor, Standard_CString& AFont, Standard_Real& AFactor, Standard_Real& ASpace) const {
174
175 AColor = MyColor;
176 AFont = MyFont.ToCString();
177 AFactor = MyFactor;
178 ASpace = MySpace;
179
180}
181void 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 {
182
183 AColor = MyColor;
184 AFont = MyFont.ToCString();
185 AFactor = MyFactor;
186 ASpace = MySpace;
187 AStyle = MyStyle;
188 ADisplayType = MyDisplayType;
189 AColorSubTitle = MyColorSubTitle;
190
191}
192void 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 {
193
194 AColor = MyColor;
195 AFont = MyFont.ToCString();
196 AFactor = MyFactor;
197 ASpace = MySpace;
198 AStyle = MyStyle;
199 ADisplayType = MyDisplayType;
200 AColorSubTitle = MyColorSubTitle;
201
202 ATextZoomable = MyTextZoomable;
203 ATextAngle = MyTextAngle;
204
205}
206
207void Graphic3d_AspectText3d::Values ( Quantity_Color& AColor,
208 Standard_CString& AFont,
209 Standard_Real& AFactor,
210 Standard_Real& ASpace,
211 Aspect_TypeOfStyleText& AStyle,
212 Aspect_TypeOfDisplayText& ADisplayType,
213 Quantity_Color& AColorSubTitle,
214 Standard_Boolean& ATextZoomable,
215 Standard_Real& ATextAngle,
eeaaaefb 216 Font_FontAspect& ATextFontAspect ) const
7fd59977 217{
218
219 AColor = MyColor;
220 AFont = MyFont.ToCString();
221 AFactor = MyFactor;
222 ASpace = MySpace;
223 AStyle = MyStyle;
224 ADisplayType = MyDisplayType;
225 AColorSubTitle = MyColorSubTitle;
226
227 ATextZoomable = MyTextZoomable;
228 ATextAngle = MyTextAngle;
229 ATextFontAspect = MyTextFontAspect;
230
231}
232
30f0ad28 233void Graphic3d_AspectText3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram)
234{
235 MyShaderProgram = theProgram;
236}
7fd59977 237
30f0ad28 238const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectText3d::ShaderProgram() const
239{
240 return MyShaderProgram;
241}